This topic provides answers to frequently asked questions about Image Processing (IMG) provided by Object Storage Service (OSS).

If the processed image cannot be properly displayed, you can use the ?x-oss-process=image/info parameter to query information about the source image and determine whether the properties of the source image exceed the limits of IMG. Each side of the image cannot exceed 4,096 pixels. The total pixel number of the image cannot exceed 4,096 × 4,096.

How do I use IMG to save images in different specifications?

If you want to save small images other than original images in a bucket, you can add a parameter to an IMG request to save processed images to the bucket as objects. For more information, see Save processed images.

Why is an image downloaded when I use a browser to preview the image?

The possible reason is that the image format is not supported by the browser. We recommend that you use a browser that is compatible with the image format (such as the Google Chrome browser) to preview the image.

Why does a GIF image become a static image after the GIF image is processed?

The format of GIF images is retained only when one or more of the following IMG operations are performed: resizing, cropping, and adding watermarks. If you perform IMG operations other than the preceding operations on GIF images, GIF images become static images.

What do I do if the "MemLimitExceeded" error is reported when I process an image?

Cause: When you use IMG, the size of the image is limited. For the rotate operation, the height or width of the source image cannot exceed 4,096 pixels. For other operations, the height or width of the source image cannot exceed 30,000 pixels, and the total pixel number of the source image cannot exceed 250 million. When the image exceeds the limit, the "MemLimitExceeded" error is reported.

Note The total pixel number of a dynamic image, such as a GIF image, is calculated by using the following formula: Width × Height × Number of image frames. The total pixel number of a static image, such as a PNG image, is calculated by using the following formula: Width × Height.

Solution: You can use the resize parameters to adjust the sizes of the images that are stored in OSS. For more information about the IMG parameters that are used to resize an image, see Resize images.

What do I do if the "The channel can be only accessed using style" error is reported when I access an image?

Cause: After you enable source image protection for a bucket, anonymous requesters can access images in the bucket only by adding style parameters in the requests or by using signed URLs. If you use IMG parameters to specify an image, such as ?x-oss-process=image/format,webp, the error is reported.

Solution: We recommend that you disable source image protection. For more information about source image protection, see Protect source images.

What do I do if the "Picture exceed the maximum allowable rotation range" error is reported when I rotate an image?

Cause: The length of a single side of the source image exceeds 4,096 pixels, or the total pixel number of the image exceeds 4,096 × 4,096.

Troubleshooting:
  1. Use the ?x-oss-process=image/info parameter in the request to query information about the image and determine whether the length of a single side of or the total pixel number of the image exceeds limits.
  2. The value of ImageWidth is 5100, which exceeds 4096.

Solution: Use the auto-orient,0 parameter in the request to disable automatic rotation. Then, use the resize parameter in the request to adjust the image size, and rotate the image. Example: http://test.oss-cn-beijing.aliyuncs.com/123/myphoto5.jpg?x-oss-process=image/auto-orient,0/resize,m_lfit,h_2000,w_2000,limit_1/rotate,90.

What do I do if the average tone queried by OSS does not match that of the image?

Cause: The average tone is not calculated based on the ratios of colors but on the prominent colors of the image center. The average tone of an image is calculated based on the following logic:
  1. Calculate the average colors of the image.
  2. Traverse each pixel. Calculate the difference between the pixel color and each average color. If the difference is greater than a threshold, the pixel is added to the list of prominent pixels.
  3. Calculate the average value of the prominent pixels. The average value is the average tone.

Solution: Use the ?x-oss-process=image/average-hue parameter to query the average tone of the image.

What do I do if black outlines appear when I add a watermark to an image?

Cause: The black outlines are not caused by IMG. When you add a watermark to a source image, the source image is overlaid with the watermark. If the watermark and source image differ in RGB values, black outlines may appear after the source image is overlaid. This phenomenon is common when you use image processing tools.

Use the ?x-oss-process=image/average-hue parameter to query the RGB parameters of the two images. You can add this parameter to the end of the source image URL to determine whether the RGB values of the two images are the same.

Solution: Use the t parameter. In this case, the RGB value of the source image is 0x0e0e0e. The RGB value of the watermark is 0xffffff. When you add the watermark to the image, the black outlines appear. You can use the t parameter to adjust the transparency and make the outlines invisible. The t value ranges from 1 to 100. Example: http://image-demo.img-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/resize,w_300/watermark,image_cGFuZGEucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLFBfMzA,t_90,g_se,x_10,y_10,t_50.

What do I do if my image fails to be accessed over CDN back-to-origin?

Use OSS endpoints to test whether the image can be accessed. Use the following URLs to analyze the cause:

http://test.oss-cn-beijing.aliyuncs.com/MomClass/ChuXin/3_2_336_462.jpg@30-30bl

http://test.img-cn-beijing.aliyuncs.com/MomClass/ChuXin/3_2_336_462.jpg@30-30bl

  • img-cn-region.aliyuncs.com indicates the OSS endpoint of the earlier version. OSS endpoints of the earlier version and the current version differ in the delimiter and syntax used for IMG.
  • oss-cn-region.aliyuncs.com indicates the endpoint used after 2017. This endpoint does not support the syntax of IMG or the at sign (@) as those used in the earlier endpoint. To access an image whose endpoint contains img, synchronize the endpoint with the latest OSS endpoint.

The preceding endpoint of the earlier version uses Gaussian Blur-related parameters. After the earlier endpoint is synchronized with the latest OSS endpoint, you can access the image by using the latest OSS endpoint.

http://test.oss-cn-beijing.aliyuncs.com/MomClass/ChuXin/3_2_336_462.jpg?x-oss-process=image/blur,r_3,s_30

What do I do if my image color is brightened after the image is resized?

Solution: Use tools such as Photoshop to query the color model of the source image. If the source image uses the RGB color model, the colors remain unchanged after the image is resized. If the source image uses the CMYK color model, the colors slightly change after the image is resized. The support for CMYK is in progress. Colors change after the image is resized.

What do I do if my image can be opened from my local computer, but the system shows that the image has been corrupted when I process the image?

Problem description: My image can be opened from my computer. However, OSS shows that the image is corrupted when I upload the image to OSS and process the image.

Troubleshooting:
  1. Obtain the original OSS URL and use the ?x-oss-process=image/info parameter to query information about the source image. If no image information is found, an error is reported, which indicates that the source image is corrupted.
  2. To troubleshoot this problem, use the ImageMagick tool to adjust the image. If an error is reported, the image is corrupted. The following code provides an example on how to resize the image:
    convert -resize 1024x768 1123331261_15353307414801n.jpg
The corrupted image can be opened from the local computer because the local image viewer has repaired the image. However, OSS does not repair the corrupted image. Therefore, the image cannot be displayed by the browser.

What do I do if my image stored in OSS is rotated 90 degrees?

Problem description: The image can be accessed by using an OSS endpoint. Source image
When the image is accessed over CDN, the image is rotated 90 degrees. Image that is rotated 90 degrees

Cause: OSS works properly because the image can be accessed by using an OSS endpoint. However, when the image is accessed over CDN, the image is rotated 90 degrees. This is caused by the browser. You can use the ?x-oss-process=image/info parameter to query the rotation 90 parameter included in the source image.

Solution: Delete the rotation 90 parameter.

What do I do if IMG does not take effect after CDN is used to access an image?

Troubleshooting: Check whether the parameter filtering feature is enabled for CDN. If this feature is enabled, parameters that follow the question mark (?) are removed from the URL. For more information, see Ignore parameters.

What do I do if the "Picture exceed the maximum allowable rotation range" error is reported when I use IMG to process an image?

Troubleshooting:
  • Use the ImageMagick tool to check whether the automatic rotation feature is enabled for the source image.
  • Use the auto-orient,0 parameter to process the image. If the image can be processed, the source image has automatic rotation enabled.

If the source image has automatic rotation enabled, the width and height of the image cannot exceed 4,096 pixels.

What do I do if a blank image appears when I access an image configured with CDN from an iOS device by using a URL that includes IMG parameters, but the image is accessible after I refresh the web page or when I access the image from a computer?

Cause: OSS works properly because the image can be accessed from the computer and mobile phone. Otherwise, the image cannot be accessed from a computer.

Troubleshooting:
  1. Check whether the image can be directly accessed from a mobile phone.
    • If the image can be directly accessed, whereas the access over CDN is abnormal, CDN point-of-presence (POP) errors may cause that loading failures occur or that incorrect content is cached on CDN POPs.
    • If the image cannot be directly accessed, but can be accessed by using CDN after the website is refreshed. One possible cause is that incorrect content is cached on CDN POPs.
  2. Check whether the image can be directly accessed from a computer.
    • If the image can be directly accessed, the problem may be caused by the mobile phone.
    • If the image cannot be directly accessed, the problem may be caused by the image.

What do I do if I cannot open the source image and processed image that are stored in OSS?

To use ImageMagick to troubleshoot images in OSS, perform the following steps:
  1. Run the following command to download a demo image:
    wget https://zh.mobi/test/123.jpg                  

    Sample success response:

    --2018-11-2210:55:16--  https://zh.mobi/test/123.jpg
    The IP address of the zh.mobi host is being resolved...
    The host has sent an HTTP request and is waiting for a response... 200 OK
    Image size: 4141232 (3.9M) [image/jpeg]
    The image is saved as 123.jpg.
    100%[========================================================================================>] 4,141,232 12.5 MB/s Time: 0.3s.   
    2018-11-2210:55:16 (12.5 MB/s) - 123.jpg is saved.[4141232/4141232])                       
  2. Download the image processing tool ImageMagick.
  3. Run the following command to check the encoding of the image:
    identify 123.jpg                        

    The following error response is returned. The response indicates an image encoding error. The error is not caused by OSS. You can use ImageMagick to analyze similar errors.

    identify: Not a JPEG file: starts with 0x000x00 `123.jpg' @ error/jpeg.c/JPEGErrorHandler/316.

What do I do if a split line appears after I process my image?

Processed image with a split line

Cause: No split lines exist. This is caused by pixel changes after the image is processed. The source image is an RGB (true color) image whose height is 2,560 pixels and width is 1,440 pixels. After the image is processed, the image height is cropped to 1,920 pixels, and the image width is cropped to 1,080 pixels. The image size in pixels is reduced, which causes abnormal display of the image.

Solution: Use the quality,Q_100 parameter to increase the absolute quality value of the image to 100.

What do I do if the BadRequest error is reported during image processing?

<Error>
<Code>BadRequest</Code>
<Message>This image format is not supported.</Message>
<RequestId>62E2288D50ED1C30361E****</RequestId>
<HostId>examplebucket.oss-cn-beijing.aliyuncs.com</HostId>
</Error>
Troubleshooting:
  1. Use the convert command supported by ImageMagick to view the format of the source image.
  2. Check whether IMG supports the image format. For more information about image formats supported by IMG, see Limits.

Solution: Convert the format of the image to a format supported by IMG.

What do I do if the InvalidArgument error is reported during image processing?

<Error>
<Code>InvalidArgument</Code>
<Message>The value: 0 of parameter: w is invalid.</Message>
<RequestId>62E2288D50ED1C30361E****</RequestId>
<HostId>examplebucket.oss-cn-beijing.aliyuncs.com</HostId>
</Error>

Solution: Check the request parameters of the source image. Parameters similar to 2018089926****.jpg@0w_2e_1l_1an.src are supported by endpoints in the img-cn-xx format. After an endpoint in the img-cn-xx format is converted to an endpoint in the oss-cn-xxx format, IMG no longer supports the request method of the original endpoint. In this case, the original endpoint does not support the HTTPS access method.

What do I do if the BadWebPImage error is reported during image processing?

<Error>
<Code>BadWebPImage</Code>
<Message>The webp image file may be damaged.</Message>
<RequestId>62E2288D50ED1C30361E****</RequestId>
<HostId>examplebucket.oss-cn-beijing.aliyuncs.com</HostId>
</Error>
Causes:
  • The source image is in the WebP format and is corrupted.
  • The source image is in the WebP format and is not corrupted. However, a whitelist is not applied to perform IMG-related operations on the image.

Solution: To perform IMG-related operations on a dynamic image that is in the WebP format and is not corrupted,submit a ticket .

Can OSS identify custom query parameters used for dynamically resizing an image in a URL?

OSS cannot identify custom query parameters used for dynamically resizing an image in a URL.

Can I display a text watermark in two lines and add multiple text watermarks to an image?

A text watermark cannot be displayed in multiple lines in OSS. However, you can add multiple text watermarks to an image. For more information, see Add watermarks.