Image Thumbnailing
Updated at:2025-11-03
Overview
This document describes methods for processing images into thumbnails.
Image thumbnail parameters
Command parameters
| Parameter name | Abbreviated command | Types | Value range | Command description | Default value | Required or not |
|---|---|---|---|---|---|---|
| scale | s | unsigned int | 0,1,2 | Specify the scaling method. s_0 indicates no cropping, proportional scaling; s_1 indicates stretch and scaling; s_2 indicates proportionally centered cropping and scaling. |
0 | No |
| width | w | unsigned int | 1~4096 | Specify the maximum width of the target thumbnail ( unit: px). |
- | When s_1, s_2, is required |
| height | h | unsigned int | 1~4096 | Specify the maximum height of the target thumbnail ( unit: px). |
- | When s_1, s_2, is required |
| limit | l | unsigned int | 0,1 | Specify whether to limit the size of the scaled image: l_0 indicates no limit on the scaled image size; l_1 indicates limiting the scaled image size (length and width) to not exceed the original image size. | 0 | No |
Notes:
- When s_0 (no cropping, proportional scaling):
- Either w or h can be specified, and the image will be scaled proportionally based on the provided parameter. For example, with an original image size of 100 × 200, specifying w_50 results in a processed size of 50 × 100, while specifying h_50 results in a processed size of 25 × 50.
- If both w and h are specified, the system will scale proportionally using the smaller ratio of "target width/original width" and "target height/original height." For instance, with an original image size of 400 × 500 and resizing parameters w_100 and h_200, since "100/400" < "200/500," the system scales based on w_100, producing a target size of 100 × 125.
- When s_1, both w and h must be specified;
- When using s_2, both w and h must be specified. After specifying these, the image will be scaled proportionally based on the larger ratio of "target width/original width" and "target height/original height." The side with the larger ratio is then centrally cropped. For example, with an original image size of 500 × 1000 and parameters s_2, w_250, and h_600, since "250/500" < "600/1000," scaling is based on the target height of 600, and the width is centrally cropped to 250.
Example
- Resize the image to a height of 200, adjusting the width proportionally.
https://doc.bce.baidu.com/bce-documentation/BOS/image.jpg@h_200

- Resize the image to a width of 150 and a height of 200, with an absolute target image quality of 60 and format set to PNG.
https://doc.bce.baidu.com/bce-documentation/BOS/image.jpg@s_1,w_150,h_200,q_60,f_png

- Perform proportional scaling and centered cropping on the image, achieving a width of 80 and height of 100.
https://doc.bce.baidu.com/bce-documentation/BOS/image.jpg@s_2,w_80,h_100

- Resize the image to a width of 150 and a height of 100, rotate it 90° counterclockwise, and display it in a progressive manner.
https://doc.bce.baidu.com/bce-documentation/BOS/image.jpg@s_1,w_150,h_100,a_-90,d_progressive

