You can specify Image Processing (IMG) parameters in GetObject requests to process image objects that are stored in Object Storage Service (OSS). For example, you can add image watermarks to images or convert image formats.
OSS allows you to use one or more parameters to process images. You can also specify multiple IMG parameters in a style to process images at a time. For more information about image styles, see Image styles.
If you specify multiple IMG parameters, OSS processes the image in the order in which the parameters are specified. The following table describes IMG parameters.
|Resize images||resize||Resizes images.|
|Add watermarks||watermark||Adds image watermarks or text watermarks to images.|
|Custom crop||crop||Crops rectangular images based on the specified size.|
|Adjust image quality||quality||Adjusts the quality of images in the JPG format and WebP format.|
|Format conversion||format||Converts images to specified formats.|
|Query the EXIF data of an image||info||Obtains image information, including basic information and Exchangeable Image File Format (EXIF) information.|
|Auto-rotate||auto-orient||Auto-rotates images for which the auto-orient parameter is configured.|
|Circle crop||circle||Crops images into circles of the specified size based on the center point of images.|
|Indexed cut||indexcrop||Crops images along the specified horizontal axis or vertical axis and selects one of the images.|
|Rounded rectangle||rounded-corners||Crops images into rounded rectangles based on the specified rounded corner size.|
|Rotate||rotate||Rotates images clockwise based on the specified angle.|
|Gradual display||interlace||Configures gradual display for JPG images.|
|Query the average tone||average-hue||Queries the dominant color of images.|
|Brightness||bright||Adjusts the brightness of images.|
|Contrast||contrast||Adjusts the contrast of images.|
qualityparameters to process the
example.jpgimage, the URL of the image in the request is
https://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/resize,w_300/quality,q_90. You can configure CDN back-to-origin rules to filter or retain the IMG parameters contained in the URLs of images that you want to retrieve. This way, you can retrieve source images or images that are processed by using IMG parameters.
- Retrieve source images
You can enable the parameter filtering feature of CDN to filter out all parameters that follow the question mark (?) in the URL of the image that you want to retrieve. In this example, the
example.jpgsource image is retrieved.
- Retrieve processed images
You can enable the parameter retaining feature of CDN to retain all parameters that follow the question mark (?) in the URL of the image that you want to retrieve. In this example, the processed image is retrieved.
For more information about how to configure CDN back-to-origin rules, see Ignore parameters.
You can use object URLs, API operations, and SDKs to process images. For more information, see IMG implementation modes.
- Limits on source images
- Only JPG, PNG, BMP, GIF, WebP, and TIFF images are supported.
- The source image cannot exceed 20 MB in size.
- For the rotate operation, the height or width of the source image cannot exceed 4,096
pixels. For other operations, the width or height of the source image cannot exceed
30,000 pixels, and the total pixel number of the source image cannot exceed 250 million.
The total pixel number of a dynamic image, such as a GIF image, is calculated based on the following formula:
Width × Height × Number of image frames. The total pixel number of a static image, such as a PNG image, is calculated based on the following formula:
Width × Height.
- Limits on dynamic images
You can resize, crop, rotate, and add image watermarks to only dynamic images, such as GIF images.
To encode and decode dynamic images in the WebP format, submit a ticket.
- Limits on resized images
The width or height of a resized image cannot exceed 16,384 pixels. The total pixel number of the resized image cannot exceed 16,777,216.
- Limits on image styles
You can create up to 50 image styles for each bucket. To create more than 50 styles for a bucket, submit a ticket.
- API operation calling fees
A GetObject request is generated each time you use IMG to process an image. You are charged based on the number of generated requests. For more information about API operation calling fees, see API operation calling fees.
- Traffic fees
You are charged for the outbound traffic over the Internet based on the size of the processed images. For more information about traffic fees, see Traffic fees.
IMG provides two versions of API operations. This topic describes the API operations of the new version. The API operations of the previous version are not updated. For more information about the compatibility between the new version and the previous version of API operations, see FAQ on using old and new versions of APIs and domain names.