Chuyển tới nội dung chính

Format Conversion

Selecting an Output Format

Use the format parameter to convert the image to a different format on the fly.

/format=webp/https://example.com/photo.jpg

If format is not specified, the output format matches the input format - no conversion is applied.

Supported output formats

ValueDescription
webpWebP - good compression with transparency support
jpegJPEG - universal compatibility, lossy
pngPNG - lossless, supports transparency
avifAVIF - best compression, slower encoding
gifGIF - animated image support
bmpBMP - uncompressed bitmap
tiffTIFF - high-quality, lossless
icoICO - Windows icon format
jxlJPEG XL - next-gen, wide gamut support

Quality

The q parameter controls lossy compression quality for JPEG and WebP output.

ParamTypeRangeDefault
qinteger1-100Encoder default

Higher values produce larger files with better quality. Lower values produce smaller files with more compression artifacts.

/webp,q85/https://example.com/photo.jpg
/jpeg,q70/https://example.com/photo.jpg
thông tin

The q parameter only applies to jpeg and webp output. It has no effect on lossless formats such as png, bmp, or tiff.


Format Comparison

FormatCompressionTransparencyAnimationNotes
webpGood (lossy/lossless)YesYesBroad browser support, ideal for web
avifExcellentYesYesSmaller files than WebP, slower to encode
jxlExcellentYesYesNext-gen format, wide color gamut
jpegGood (lossy)NoNoUniversal compatibility, best for photos
pngModerate (lossless)YesNoBest for graphics, logos, screenshots
gifLowPartial (1-bit)YesLegacy animated format
bmpNone (uncompressed)NoNoRaw pixels, large file size
tiffOptional (lossless)YesNoHigh-quality archival use
ico-YesNoResized to standard icon sizes
mẹo

For web use, prefer webp or avif. WebP is well-supported across all modern browsers and offers a good balance of quality and file size. AVIF provides better compression but may be slower to generate for large images.


ICO Output

When format=ico is specified, the image is resized to standard Windows icon dimensions before encoding. This makes it suitable for use as a favicon or application icon.

/format=ico/https://example.com/logo.png

Examples

Convert JPEG to WebP

/format=webp/https://example.com/photo.jpg

Convert to WebP with quality

/webp,q85/https://example.com/photo.jpg

Resize and convert in one request

/800x600,webp,q80/https://example.com/photo.jpg

Lossless PNG output

/format=png/https://example.com/photo.jpg

Generate a favicon

/32x32,ico/https://example.com/logo.png

High-efficiency AVIF for bandwidth savings

/avif,q75/https://example.com/photo.jpg