You can process images stored in Object Storage Service (OSS) by adding processing parameters to a GetObject request. For example, you can perform operations such as adding watermarks or converting formats.
Processing parameters
You can process images stored in Object Storage Service (OSS) using one or more parameters, or encapsulate multiple parameters in an image style to process them in batches. For more information about image styles, see Image styles.
If you specify multiple processing parameters, OSS applies them in the order provided. The following table describes the processing parameters.
|
Actions |
Parameter |
Description |
|
resize |
Resizes an image to the specified dimensions. |
|
|
watermark |
Adds an image or text watermark to an image. |
|
|
crop |
Crops an image into a rectangle with the specified dimensions. |
|
|
quality |
Adjusts the quality of images in JPG and WebP formats. |
|
|
format |
Converts the image format. |
|
|
format |
Converts an image to the HEIF or AVIF format, which provides a high compression ratio. |
|
|
info |
Retrieves image information, including basic and EXIF data. |
|
|
auto-orient |
Automatically rotates an image based on its orientation parameter. |
|
|
circle |
Crops a circular area of a specified size from the image's center. |
|
|
indexcrop |
Slices an image into sections of a specified size along the x- or y-axis and returns one section. |
|
|
rounded-corners |
Crops an image into a rounded rectangle with the specified corner radius. |
|
|
blur |
Blurs an image. |
|
|
rotate |
Rotates an image clockwise by the specified angle. |
|
|
interlace |
Enables progressive display for a JPG image. |
|
|
average-hue |
Retrieves the average hue of an image. |
|
|
bright |
Adjusts the brightness of an image. |
|
|
sharpen |
Sharpens an image. |
|
|
contrast |
Adjusts the contrast of an image. |
For example, after you add the image resizing resize and quality transformation quality parameters to the source image example.jpg, the file URL is https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/resize,w_300/quality,q_90. You can configure different rules to have Alibaba Cloud CDN retrieve either the source image or the processed image during back-to-origin.
-
Fetch the source image
After you enable parameter filtering on Alibaba Cloud CDN, all parameters after the question mark (?) are removed from file URL requests, allowing the request to directly hit the source image
example.jpg. -
Fetch the processed image
Enable parameter retention in Alibaba Cloud CDN to keep all parameters after the question mark (?) in the request URL. The back-to-origin request then fetches the processed image.
For more information about how to configure back-to-origin rules for Alibaba Cloud CDN, see Ignore parameters.
Image processing methods
You can process images using object URLs, API operations, or SDKs. For more information, see Image processing methods.
Limitations
|
Parameter |
Description |
|
Image formats |
|
|
Image size |
The source image cannot exceed 20 MB in size. |
|
Image width and height |
The maximum width or height of the source image is 4,096 px for rotation. For all other operations, the maximum is 30,000 px, and the total number of pixels cannot exceed 250 million. The total number of pixels for a dynamic image, such as a GIF image, is calculated as Note
When you convert an image to the WebP format, both the width and height of the source image must not exceed 16,383 px. Otherwise, the conversion fails. |
|
Image compression |
After resizing, the width or height of the output image cannot exceed 16,384 px, and the total number of pixels cannot exceed 16,777,216. |
|
Advanced image compression |
After resizing, the dimensions of a HEIC image cannot exceed 4,096 × 4,096 px, and the dimensions of an AVIF image cannot exceed 4,096 × 2,304 px. |
|
Image styles |
You can create a maximum of 50 image styles per bucket. If your business requires more styles, submit a ticket. Note
You can include multiple processing parameters in a single image style to perform complex image transformations. For more information, see Image styles. |
|
Processing capability |
Note
For computationally intensive scenarios, such as encoding WebP, AVIF, or HEIF images at resolutions higher than 1080p, or if you need to exceed these limits, contact technical support to evaluate your specific usage requirements. |
Billing
The following fees apply to the Image Processing (IMG) service:
-
Request fees
Each image processing operation generates one GetObject request, and billing is based on the total number of requests. For more information, see Request fees.
-
Traffic fees
You are charged for outbound traffic over the internet based on the size of the processed images. For more information, see Traffic fees.
Versions
Image Processing (IMG) provides two API versions. This topic describes the new API version. The old API version is no longer updated. For more information about the compatibility between the two versions, see Differences between the old and new versions of IMG.