All Products
Search
Document Center

Object Storage Service:Convert image formats

Last Updated:Feb 22, 2024

You can specify the format parameter in the image URL to convert the format of an image that is stored in Object Storage Service (OSS) without downloading the image. This topic describes the format parameter and provides examples on how to convert the format of an image.

Scenarios

  • Adaptive to different devices and platforms: Different browsers, operating systems, or mobile devices may support different image formats. For example, the WebP format provides better compression efficiency on browsers. With OSS image format conversion, uploaded images can be converted into multiple formats to ensure compatibility and optimal display effects on various devices.

  • Reduced storage costs: Some image formats, such as WebP, usually provide smaller sizes than other traditional formats while maintaining visual quality. You can convert image formats to reduce storage usage without compromising image quality. This way, storage costs are reduced.

  • Unified resource management: In e-commerce, social networking, media, and other industries, images uploaded by a large number of users need to be standardized. You can convert uploaded images to a specific format for subsequent management and distribution.

Parameter description

Parameter name: format.

The following table describes the valid values of the format parameter.

Valid value

Description

jpg

Converts the format of a source image to JPG.

Important

Images in the HEIC format that support alpha channels cannot be converted to JPG images.

png

Converts the format of a source image to PNG.

webp

Converts the format of a source image to WebP.

bmp

Converts the format of a source image to BMP.

gif

Converts the format of a source image to GIF. The conversion takes effect only when the source image is also a GIF image. If the source image is not in the GIF format, the processed image is stored in the original format.

tiff

Converts the format of a source image to TIFF.

Usage notes

  • If an image processing (IMG) request includes the format and resize parameters, we recommend that you place the format parameter at the end.

    Example: image/resize,w_100/format,jpg

  • If an IMG request includes the format, resize, and watermark parameters, we recommend that you place the format parameter after the resize parameter.

    Example: image/resize,w_100/format,jpg/watermark,...

  • If the source image does not support alpha channels, the format of the source image is converted to a format that supports alpha channels. Formats that support alpha channels include PNG, WebP, and BMP. By default, OSS fills the transparent area with white.

  • You cannot use OSS to fill the transparent area with black.

Examples

You can use object URLs, OSS SDKs, or API operations to configure IMG parameters that are used to process images. In this example, object URLs are used. You can use object URLs to configure IMG parameters only for public-read images. If you want to configure IMG parameters for private images, use OSS SDKs or API operations. For more information, see IMG implementation modes.

In the following examples, an image in the image-demo bucket in the China (Hangzhou) region is used as the source image. The image can be accessed over the Internet by using the following URL:

FAQ

What do I do if black borders appear when the image format is converted?

The image format has a default quality. If no quality is specified during format conversion, the image format is converted based on the default quality. In this case, black borders may appear in the image.

If you want to improve the image quality, we recommend that you set the image quality parameter to 100 (?x-oss-process=image/quality,Q_100). For more information about image quality adjustment, see Adjust image quality.

Does the image format conversion affect the page loading speed?

The image format conversion affects the page loading speed.

Can I convert the format of a GIF image to MP4?

Yes, you can convert the format of a GIF image to MP4. To do so, you need to submit a ticket.