Resizing Images
This function is available for GUI, Code, and API calling mode. The image can be resized by setting a fixed width, height, or proportion.
- Long side refers to the side with a larger original to target size ratio, and short side refers to the side with the smaller ratio. For example, if the original image size is 400 px × 200 px and the target size is 100 px × 100 px, the longer side is 400 px and the shorter side is 200 px because 400/100 = 4, 200/100 = 2, and 4 > 2.
- 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 format is as follows:
Table 1 describes the parameters in detail.
Operation name: resize
|
Parameter |
Value Description |
Code Example |
|---|---|---|
|
m |
Type of resizing. The parameter can be set to lfit, mfit, fill, pad, and fixed. The default value is lfit.
|
image/resize,m_lfit,h_100,w_100 |
|
p |
Percentage of aspect ratio. Other parameters cannot be used simultaneously with p. p ranges [1, 1000]. If the value:
|
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 |
|
l |
Specifies the long side of the target thumbnail. Value range: [1, 4096] The long side has a specified value, and the short side is scaled based on the ratio. |
image/resize,l_100 |
|
s |
Specifies the short side of the target thumbnail. Value range: [1, 4096] The short side has a specified value, and the long side is scaled based on the ratio. |
image/resize,s_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.
|
image/resize,p_150,limit_0 |
Example
- Set the height to 100, and process the width proportionally (.lfit by default).

- Lock aspect ratio, specify the shorter side to resize the image into a 100 x 100 one.
https://e-share.obs.cn-north-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,m_lfit,h_100,w_100

- Set long side size to 100 and the short side is scaled based on the ratio.
https://e-share.obs.cn-north-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,l_100

- Fix the width and height, center and crop, resize the image into a 100 x 100 one.
https://e-share.obs.cn-north-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,m_fill,h_100,w_100

- Fix the width and height to 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://e-share.obs.cn-north-1.myhuaweicloud.com/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://e-share.obs.cn-north-1.myhuaweicloud.com/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.

- Call the parameter p to scale down the image to 30%.
https://e-share.obs.cn-north-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,p_30

Last Article: Blur
Next Article: Rotating Images
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.