Updated on 2024-10-24 GMT+08:00

Using Image Processing on OBS Console

Process

On the image processing page of OBS Console, you can create a processing style for an image by specifying parameters on the GUI or by editing code. You can then view the new image effect on the Preview Image tab page on the image's details page. You can also click Copy Link to get the link for accessing the new image.

You can use OBS Console, OBS SDKs, or REST APIs to process images. Figure 1 shows the flowchart of using image processing on OBS Console.

Figure 1 Flowchart of using image processing on OBS Console

Procedure 1: Logging In to OBS Console

Before using image processing, you must have a cloud service account and enable OBS. Once OBS is enabled, image processing is available for use. To use OBS properly, make sure that you have sufficient account balance or you have a valid payment method. If you have already enabled OBS and you can use it properly, skip this section.

  1. Visit the Huawei Cloud official website.
  2. Create a HUAWEI ID.

    If you already have one, start from 3.
    1. On the right of the top navigation bar, click Sign Up.
    2. Complete the account creation as instructed.

      After the creation is complete, you will be navigated to your information page.

  3. On the right of the top navigation bar, click Sign In, and enter the username and password.
  4. On the right of the top navigation menu, click Console to go to the management console.
  5. Click Service List and choose Storage > Object Storage Service.
  6. (Recommended) Make sure that you have sufficient account balance or you have a valid payment method, so that you can properly use OBS.

Procedure 2: Uploading an Image

For the constraints on the format and size of images you can upload, see Notes and Constraints.

  1. On the console homepage, click Service List in the upper left corner and choose Storage > Object Storage Service.
  2. In the bucket list, click the bucket you want to go to the Objects page.
  3. Click Upload Object to open the Upload Object dialog box.
  4. Click add files marked by red box in Figure 2 to open the local file browser.

    Figure 2 Uploading an image

  5. Select the image that you want to upload and click Open.
  6. Click Upload.

Procedure 3: Creating an Image Style

Each image style specifies a set of processing operations, including cropping, compression, and adding watermarks. For multiple images that require the same processing operations in a bucket, you can create an image style to apply it to the images.

When creating a style, you can preview the style effect of the sample image on the right in real time.

When using REST APIs to access image processing, you can call the style name in the URL to avoid entering complex commands. For details about the domain name rules for API access, see Access with a Style Name.

You can create up to 100 styles for a bucket.

You can also replicate existing image processing styles from another bucket.

If you are an IAM user, before creating an image style, make sure that programmatic access has been enabled for yourself. For details, see Viewing or Modifying IAM User Information.

  1. On the console homepage, click Service List in the upper left corner and choose Storage > Object Storage Service.
  2. Click a desired bucket name. In the navigation pane, choose Data Processing > Image Processing.

    Figure 3 Image processing


  3. Click Create to go to the style editing page shown in Figure 4.

    Figure 4 Creating a style


  4. On the editing page, specify a style name and configure properties:

    • Style Name

      Enter an easy-to-remember style name. Only letters (uppercase or lowercase), digits, periods (.), underscores (_), and hyphens (-) are allowed. The style name contains 1 to 256 characters, for example, rotate_0001.

    • Edit Mode

      Choose either GUI or Code to create an image style by configuring parameters or by editing code.

      An example code is as follows:

      image/sharpen,100/blur,r_1,s_1/resize,m_lfit,h_400,w_400,limit_1
    • Other settings

      Configure the image effect, resizing, watermark, and output.

  5. Click OK to save the style. The new style will be displayed in the style list.

Replicating Image Styles

You can replicate an existing image style to quickly create one.

  1. On the console homepage, click Service List in the upper left corner and choose Storage > Object Storage Service.
  2. Click a desired bucket name. In the navigation pane, choose Data Processing > Image Processing.
  3. Click Replicate.
  4. Select a replication source, which is the source bucket where the required image styles were configured.

    • The image styles replicated from a source bucket will not overwrite existing styles in the current bucket, and any that conflict with the existing ones will not be replicated.
    • The version of both source and destination buckets must be 3.0.
    • You can remove the styles that you do not want to replicate.
    Figure 5 Replicating image styles


  5. Click OK to replicate the image styles to the current bucket.

Procedure 4: Using the Image Style

You can use existing image styles in a bucket in either of the following ways:

  • Copying a link (see Copying a Link): On an image's details page of OBS Console, you can copy a link for accessing the image with a style applied on the Preview Image tab page. By pasting the copied link in a browser, you can get the new image.
  • Editing a domain name: You can edit a domain name by referring to the format given below and open it in a browser to have the image with the style applied.
    <Image link>?x-image-process=style/<Style name>

    Image link can be obtained from the image details page. For details, see Editing a Domain Name. Style name is the one defined when the style was created. A style name can contain only uppercase or lowercase letters, digits, periods (.), underscores (_), and hyphens (-) and is 1 to 256 characters long, for example, rotate_0001.

Copying a Link

  1. On the console homepage, click Service List in the upper left corner and choose Storage > Object Storage Service.
  2. Click the name of the bucket that houses desired styles to go to the Objects page.
  3. Click the name of an existing image or of a newly uploaded image to go to its details page.
  4. Click the Preview Image tab to preview the image effect in one or more styles.

    Figure 6 Preview Image

  5. Click Copy Link in the style card you want. If Copied successfully. is prompted, you have got the link for accessing the image with the style applied.

Editing a Domain Name

  1. On the OBS object list page, click an image to be processed to go to its details page.
  2. Choose Object ACL > User Access > Anonymous User and click Edit. In the displayed dialog box, grant the object read permission to anonymous users and click OK. For details, see Figure 7.

    Figure 7 Granting the object read permission to anonymous users


  3. Click the icon next to Link to copy the image link.
  4. Add ?x-image-process=style/<Style name> to the end of the copied link and open the new link in a browser. Then, you can access the image with the style applied.

    Link example:

    https://bucketname.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=style/stylename

    The links and style names above are for reference only. Change them accordingly in practice.