Resizing

This function is available for GUI, Code, and API calling mode.

The image can be resized by setting a fixed width, height, or proportion.

NOTE:
  • The longer side of the resized image should not be larger than 4096 x 4, and width x height should not be larger than 4096 x 4096.
  • If you only specify the height or width, the image will be scaled by the side that you specify by default. If you choose fixed width and height mode, the width and height are equal by default. After resized, the image will be returned in original format.
  • By default, when you resize an image, its size will be limited to not be enlarged. If you want the image to become larger after resizing, you need to call the parameter "limit,0" to obtain the enlarged image, otherwise the original image will be returned. The parameter is called in the format: https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,w_500,limit_0.

Table 1 lists the parameters.

Operation name: resize

Table 1 Resize settings

Parameter

Value Description

Code Example

m

Type of resizing. The parameter can be set to lfitmfitfillpad, and fixed. The default value is lfit.

  • lfit: Specify a rectangle of w and h, lock the aspect ratio, and obtain the largest image in the rectangle.
  • mfit: Specify a rectangle of w and h, lock the aspect ratio, and obtain the smallest image in the extended area of rectangle.
  • fill: Specify a rectangle of w and h, and lock the aspect ratio. Obtain the smallest image in the extended area of the rectangle, and center and crop it. That is, center and crop the mfit-type image.
  • pad: Specify a rectangle of w and h and lock the aspect ratio. Obtain the largest image in the rectangle and pad the blank area. That is, pad the blank area of the lfit-type image.
  • fixed: Resize the image by setting a fixed width and height.

image/resize,m_lfit,h_100,w_100

p

Percentage of aspect ratio. Other parameters cannot be used simultaneously with pp ranges [1, 1000]. If the value:

  • < 100: The image is scaled up.
  • = 100: Keep the original size.
  • > 100: The image is scaled down.

image/resize,p_50

h

Height of the resized image, ranging [1, 4096].

image/resize,m_lfit,h_100

w

Width of the image after resizing, ranging [1, 4096].

image/resize,m_fixed,h_100,w_100

color

Padding color, used in pad (after resizing) mode.

The color is set by a hexadecimal code, from 000000 to FFFFFF. The default color is white.

image/resize,m_pad,h_100,w_100,color_FF0000

limit

Whether to limit the resized image if it is larger than the original image. The value can be 0 or 1. The default value is 1.

  • 0: Not limit.
  • 1: Limit.

image/resize,p_150,limit_0

Example

  • Set the height to 100, and process the width proportionally (.lfit by default).

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,m_lfit,h_100

  • Lock aspect ratio, specify the shorter side to resize the image into a 100 x 100 one.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,m_lfit,h_100,w_100

  • Fix the width and height, center and crop, resize the image into a 100 x 100 one.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,m_fill,h_100,w_100

  • Fix the width and height to 100.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,m_fixed,h_100,w_100

  • Fix the width and height. Resize the image into a 100 x 100 one by specifying the shorter side and pad the blank area in white.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,m_pad,h_100,w_100

  • Fix the width and height. Resize the image into a 100 x 100 one by specifying the shorter side and pad the blank area in red.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,m_pad,h_100,w_100,color_FF0000

  • Scale up the image by 150%. Call the parameter limit,0 to obtain the enlarged image.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,p_150,limit_0

  • Call the parameter p to scale down the image to 30%.

    https://obs.cn-north-1.myhwclouds.com/ya89soshla6s4uma-ims-example-cn-north-1/example.jpg?x-image-process=image/resize,p_30

Registration