Processing Images
This section describes the URL constitution to process images using REST APIs. Once you have enabled OBS successfully, you can call REST APIs to process images simply by inputting a URL that complies with the command rules of Image Processing in the address box of the browser.
URL Constitution
A URL consists of the OBS domain name, bucket name, the original image name, and processing command or style name.
Command Access Method
URL format: https://bucketName.endpoint/objectName?x-image-process=image/commands
- endpoint is the endpoint address of the region where the bucket resides. You can obtain the endpoint address from the basic information of the bucket. For details about OBS regions and endpoints, see Regions and Endpoints.
- bucketName is the name of the bucket that accommodates the image to be processed on OBS.
- objectName is the name of the original image stored in the bucketName bucket on OBS. The suffix of the image name must be consistent with formats that are supported by Image Processing.
- commands are the processing commands. Three types of delimiters are used between commands or command parameters. See Delimiters. If no commands are entered, the original image will be returned.
For example: https://image-demo.obs.cn-north-1.myhuaweicloud.com/example.jpg?x-image-process=image/crop,x_100,y_50
Delimiters are separation identifiers used in URLs to distinguish one field from another in the command. For details, see Table 1.
|
Name |
Character |
Sequence |
Description |
|---|---|---|---|
|
Parameter delimiter |
_ |
Fixed |
Delimiter between the command parameter and its value. |
|
Command delimiter |
, |
Irrelevant |
Delimiter between multiple command parameters. |
|
Pipe delimiter |
/ |
Relevant |
Delimiter between two processing commands. See Pipes. |
If an image is to be processed by multiple operations, such as cropping and resizing, the operation commands need to be connected to each other by the pipe delimiter "/". The processing operations are executed from left to right according to the designated sequence of pipes.
For example, https://image-demo.obs.cn-north-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,w_100,h_100/quality,q_80 contains two pipes. The execution sequence is from left to right. The command output of left pipe is used as the command input of the right pipe.
Style Access Method
URL format: https://bucketName.endpoint/objectName?x-image-process=style/stylename.
- endpoint is the endpoint address of the region where the bucket resides. You can obtain the endpoint address from the basic information of the bucket. For details about OBS regions and endpoints, see Regions and Endpoints.
- bucketName is the bucket name on OBS.
- objectName is the name of the original image stored in the bucketName bucket on OBS. The suffix of the image name must be consistent with formats that are supported by Image Processing.
- stylename is the style name that has been created in the bucketName bucket on OBS Console. Currently, you cannot perform other operations related to styles by calling REST APIs, such as creating, changing, and deleting styles.
Example: https://image-demo.obs.cn-north-4.myhuaweicloud.com/example.jpg?x-image-process=style/stylename
Last Article: Uploading Images
Next Article: Typical Cases
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.