This topic provides answers to frequently asked questions about OSS Image Processing (IMG).
If you encounter problems such as invalid parameter values, you can use the
? x-oss-process=image/info parameter to check whether parameter values of the source image exceed thresholds.
Each side of the image cannot exceed 4,096 pixels. The product of dimensions cannot
exceed 4,096 pixels × 4,096 pixels.
What do I do if "Picture exceed the maximum allowable rotation range" is reported when I rotate an image?
Cause: The length of a single side of the source image exceeds 4,096 pixels, or the product of dimensions of four sides exceed 4,096 pixels × 4,096 pixels.
- Use the
? x-oss-process=image/infoparameter to obtain information about the image and determine whether the length of a single side or product of dimensions exceed limits.
ImageWidthvalue is 5100, which exceeds 4096.
Solution: Use the
auto-orient,0 parameter to disable automatic rotation, use the
resize parameter 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?
- Calculate the average colors of the image.
- 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.
- 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 average tone-related parameters for the OSS 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.
? 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 parameter values of
the two images are the same.
Solution: The RGB parameter value of the source image is 0x0e0e0e. The RGB parameter
value of the watermark is 0xffffff. When you add the watermark to the image, the black
outline appears. You can use the
t parameter to adjust the transparency and make the outline invisible. Valid values
of t: 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 style fails to be accessed over CDN back-to-origin?
Use OSS endpoints to test whether the image style can be accessed. Use the following URLs to analyze the cause:
- 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 through the latest OSS endpoint.
What do I do if my image color is brightened 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 local computer, but the system shows that the image has been corrupted when I upload the image to OSS and process the image.
- Obtain the URL of the source image. Use
? x-oss-process=image/infoto view information of the source image. If the source image is unavailable, and an error is reported, the source image is corrupted.
- To troubleshoot this problem, use the ImageMagick tool to adjust the image. If an
error is reported, the image is corrupted. An example of resizing the image:
convert -resize 1024x768 1123331261_15353307414801n.jpg
What do I do if an image stored in OSS is rotated 90 degrees?
Cause: OSS works properly because the image can be accessed through an OSS endpoint.
The possible cause lies in how the browser processes the image because the image is
rotated when the image is accessed over CDN. Use the
? x-oss-process=image/info parameter to query information about the source image. The
rotation 90 parameter is included.
Solution: Delete the rotation-related parameters.
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 when the image is accessed over CDN. For more information, see Configure parameter filtering.
What do I do if "Picture exceed the maximum allowable rotation range" is reported when I use an image?
- Use the ImageMagick tool to check whether the automatic rotation feature is enabled for the source image.
- Use the
auto-orient,0parameter 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 image width and height 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 through an 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.
- Check whether access from a mobile phone to the image in OSS is normal.
- If the image in OSS is accessible, whereas the access over CDN is abnormal, CDN node errors may cause loading failures or incorrect content is cached on CDN nodes.
- If access to OSS and over CDN are both abnormal, but access over CDN becomes normal after the website is refreshed. One possible cause is that incorrect content is cached on CDN nodes.
- Check whether access from a computer to the image in OSS is normal.
- If the access is normal, the cause lies in the mobile phone.
- If the access is abnormal, the cause lies in the image.
In this case, the image format is WebP. iOS does not support this format.
What do I do if I cannot open the source image and processed image that are stored in OSS?
- Download one of the images.
[root@edas02 aliyun-oss-php-sdk]# wget https://zh.mobi/test/123.jpg --2018-11-2210:55:16-- https://zh.mobi/test/123.jpg The IP address of the zh.mobi host is being resolved. The HTTP request is sent. Waiting for the response. 200 OK Image size: 4141232 (3.9M) [image/jpeg]. The image is saved as 123.jpg. 100%[========================================================================================>] 4,141,232 12.5MB/s Time: 0.3s. 2018-11-2210:55:16 (12.5 MB/s) - 123.jpg [4141232/4141232]) saved.
- Use ImageMagick to check the encoding methods used for the image.
[root@edas02 aliyun-oss-php-sdk]# identify 123.jpg identify: Not a JPEG file: starts with 0x000x00 `123.jpg' @ error/jpeg.c/JPEGErrorHandler/316. [root@edas02 aliyun-oss-php-sdk]#
If an encoding method error occurs, the cause does not lie in OSS. You can use this tool to analyze similar errors.
What do I do if a split line appears after I process my image?
Cause: No split lines exist, but a problem 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,092 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 "BadRequest" is reported when I use IMG?
- Use the convert command supported by ImageMagick to view the format of the source image.
- Check whether the format of the source image is supported by IMG. For more information about image formats supported by OSS, see Usage notes.
Solution: Convert the format of the image to a format supported by IMG.
What do I do if "InvalidArgument" is reported when I use IMG?
Cause: Check the request parameters of the source image. Parameters similar to
20180899269957.jpg@0w_2e_1l_1an.src are supported by the endpoints in the
img-cn-xx format. After img-cn-xx is changed to
oss-cn-xxx, endpoints in the oss-cn-xxx format does not support access that uses the request
method of img-cn-xx-based endpoints. img-cn-xx-based endpoints do not support access
Can OSS identify custom query parameters used for dynamically resizing an image in a URL?
No, this function is unavailable in OSS.
How do I display a text watermark in two lines and can I 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.