Generate a thumbnail of the image as required or make the specified scaling.

Note
The supported formats include jpg, png, bmp, gif, webp, and tiff.

Parameters

Operation name: resize

  • Scale up and down with specified width and height
    Name Description Value range
    m Specify the scaling mode: 
    • lfit: proportional scaling. It refers to the maximum image that is limited in the rectangle of the specified w and h.
    • mfit: proportional scaling. It refers to the minimum image extending out of the rectangle of the specified w and h.
    • fill: fixed width and height. It refers to the cropped and centered minimum image extending out of the rectangle of the specified w and h.
    • pad: fixed width and height, scaling down and filling.
    • fixed: fixed width and height, enforced scaling down.
    [lfit, mfit, fill, pad, fixed], the default value is lfit.
    w Specify the target width. 1-4096
    h Specify the target height. 1-4096
    l Specify the longer side of the target. 1-4096
    s Specify the shorter side of the target. 1-4096
    limit Specify whether to process the target thumbnail when it is larger than the original image. 1 indicates not to process, and 0 indicates to process. 0/1. The default value is 1
    color When you set the scaling mode as pad (scaling down and filling), you can select the filling color (The default is white). Filling format of parameters: use hexadecimal color codes, for example 00FF00 (green). [000000-FFFFFF]
  • Proportional scaling
  • Name Description Value range
    p Percentage. If it is smaller than 100, it means to scale down; if it is bigger than 100, it means to scale up. 1-1000

Note

  • For the original image:
    • Formats supported: jpg, png, bmp, gif, webp, and tiff.
    • File size cannot exceed 20 MB.
    • When using the image rotation, the width or height of the image cannot exceed 4096.
  • For the thumbnail: The scaled image size is restricted. The product of the width and height of the target thumbnail cannot exceed 4096 x 4096, and the length of a single side cannot exceed 4096 x 4.
  • When the width or height of a thumbnail is specified, the image is scaled by a single side by default in the case of proportional scaling. With fixed width and height, the image is scaled down by assuming equal width and height.
  • When only the width or height of a thumbnail is specified, the image is returned in the same format as the original image. If you want to save the image into other formats, see Quality Transformation and Format conversion.
  • When resize is called, the image cannot be enlarged by default. That is, if the requested image is larger than the original image, the original image is returned. If you want to enlarge the image, add the parameterlimit,0 to be called (for example: https://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/resize,w_500,limit_0)

Example

Scaling-down by a single side (by width and height)
Scaling-down by a single side (by the longer side and shorter side)
Scaling-down based on target width or height
Proportional scaling, restricted in a rectangle frame
Proportional scaling, restricted out of a rectangle frame
Fixed width and height, automatic cropping
Fixed width and height, scaling down and filling