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

Parameter description

Parameter name: format.

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

Valid valueDescription
jpgSaves the source image in the JPG format.
Important Images in the HEIC format that support alpha channels cannot be saved in the JPG format.
pngSaves the source image in the PNG format.
webpSaves the source image in the WebP format.
bmpSaves the source image in the BMP format.
gifSaves the source image in the GIF format. If the source image is not in the GIF format, the image is saved in the original format.
tiffSaves the source image in the TIFF format.
Note
  • 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 in white.
  • You cannot use OSS to fill the transparent area in black.

Usage notes

  • When you perform a standard resize operation on an image, we recommend that you add the format parameter to the end of the Image Processing (IMG) parameter.

    Example: image/resize,w_100/format,jpg

  • When you resize and watermark an image, we recommend that you add the format parameter to the end of the resize parameter.

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

Examples

You can process images by using object URLs, OSS SDKs, or API operations. In this example, object URLs are used. For more information about how to use OSS SDKs and API operations to process images, see IMG implementation modes.

In the following examples, an image in a bucket named image-demo 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 being 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, see Adjust image quality.

Does the image format conversion affect the page loading speed?

The image format conversion affects the page loading speed.