Updated on 2024-03-04 GMT+08:00

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 putting a URL that complies with the command rules of image processing in a 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 bucket's basic information. 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 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.

Example: https://hw-image-demo.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=image/crop,x_100,y_50

  • Delimiters

Delimiters are separation identifiers used in URLs to distinguish one field from another in the command. For details, see Table 1.

Table 1 Delimiters

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.

  • 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.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,w_100,h_100/quality,q_80 has two pipes. The pipes will be executed from left to right in sequence and the command output of the previous pipe will be used as the input of the next 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 bucket's basic information. 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 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.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=style/stylename