Challenge
When using the image processing service Object Storage Service (OSS) by Alibaba Cloud, GIF-formatted files become static images after image scaling or adding waterprints using image styles. The following example shows the URL of the source image and the URL after image processing:
- The URL of the source image is:
http://XXX.oss-cn-hangzhou.aliyuncs.com/aliyuntest/raytestray.gif - Image processing URL:
http://XXX.oss-cn-hangzhou.aliyuncs.com/aliyuntest/raytestray.gif?x-oss-process=image/auto-orient,1/format,gif/resize,m_lfit,w_440/quality,q_90
Cause
The reasons why GIF files become static images in image scaling and image watermarking scenarios are as follows:
- Image scaling: GIF images do not support the auto-orient and quality parameters.
- Add image watermark: The animation feature is not enabled.
Modification method
GIF files do not support the auto-orient and quality parameters
See the following operations to check the URL for image processing:
- Check whether the URL of the image scaling process contains the auto-orient and quality parameters. Delete the auto-orient and quality parameters in the URL for access testing, or static images.
http://XXX.oss-cn-hangzhou.aliyuncs.com/aliyuntest/raytestray.gif?x-oss-process=image/format,gif/resize,m_lfit,w_440
- Delete
format,gifparameters in the link or addformat,gifparameters directly to the end of the link.http://XXX.oss-cn-hangzhou.aliyuncs.com/aliyuntest/raytestray.gif?x-oss-process=image/resize,m_lfit,w_440http://XXX.oss-cn-hangzhou.aliyuncs.com/aliyuntest/raytestray.gif?x-oss-process=image/resize,m_lfit,w_440/format,gif
Check whether the animation feature is enabled.
If you add a watermark to an image file stored in OSS, you must enable the animation feature. The following example shows how to enable the animation feature:
Note: Only image watermarks are supported. Text watermarks are not supported.
http://XXX.oss-cn-beijing.aliyuncs.com/1.gif?x-oss-process=image/watermark,image_MDA4LnBuZw,x_10,y_10,animation_1/format,gif
Applicable scope
- Object Storage Service (OSS)