format
Specifies the desired output encoding for the image.
The format
parameter enables the source image to be converted (a.k.a., "transcoded") from one encoded format to another. This is useful when the source image has been saved in a sub-optimal file format that hinders performance.
Syntax
format={value}
Allowed values
Value | Description |
---|---|
auto | Automatically use the best format based on browser support and image/transform characteristics |
avif | AVIF |
bjpg | Baseline JPEG (also bjpeg ) |
gif | Graphics Interchange Format |
jpg | JPEG (also jpeg ) |
jxl | JPEGXL (also jpegxl ) |
mp4 | MP4 (H.264) |
pjpg | Progressive JPEG (also pjpeg ) |
pjxl | Progressive JPEGXL (also pjpegxl ) |
png | Portable Network Graphics |
png8 | Portable Network Graphics palette image with 256 colors and 8-bit transparency |
webp | WebP |
webpll | WebP (Lossless) |
webply | WebP (Lossy) |
Notes
- The source image can be any of the following image formats:
AVIF
,JPEG
,JPEGXL
,PNG
,GIF
,WEBP
. - JPEG, progressive JPEG, WebP (Lossy), and PNG8 have a sliding quality scale that supports the
quality
parameter. - GIF and PNG do not have a sliding quality scale. They do not support the
quality
parameter. - A progressive JPEG
pjpg
is an image created using the JPEG suite of compression algorithms that will "fade in" successive waves of lines until the entire image has completely arrived. For this reason, progressive JPEG images typically appear to load quicker than the Baseline JPEGjpg
format. - WebP support is available in Google Chrome, Mozilla Firefox 65 and later, Safari 14 and later, Opera, and Android Browser.
- Lossless compression is currently supported for WebP and JPEGXL only.
- GIF to WebP conversion does not support animated GIFs.
- MP4 conversion is only available for animated GIF source images.
- AVIF and JPEGXL are premium features of Fastly's Image Optimizer and choosing them as an encoding format will increase your bill. Specific charges will appear on your service order.
About the auto
value
The auto behavior aims to provide the optimal output format based on client capabilities as well as information related to the source image and transform characteristics. In that regard, we may adopt different heuristics to determine the output format for different source images or transforms.
When using format=auto
, the image format delivered is always compatible with the current browser regardless of the source image format. This means a JPEGXL source image can safely be used in a browser where JPEGXL is not supported, and the resulting image is always viewable. With other format parameters and with auto=webp
and auto=avif
, there are some cases where the original format may be used.
auto
intelligently chooses the best format to deliver to the user prioritizing:- JPEGXL
- AVIF
- WebP
- Source image format / JPEG
- Images default to lossy unless the
quality
parameter is set to100
. - If no
quality
parameter is set, the default JPEG quality specified in IO default settings is used. - Allows the use of JPEGXL, AVIF, or WebP as the source image format in cases where that image format is not support in the viewing environment.
- Quality mapping uses an SSIM similarity score between formats.
- Takes precedence if combined with the
auto
parameter.
Examples
Click the links to view the transformed image using a demo Fastly IO service.
Example usage | Description |
---|---|
?format=png8 | Convert to PNG8 |
?format=mp4 | Convert an animated GIF to MP4 video |
?format=pjpg&quality=95 | Convert to a progressive JPEG with 95% quality |
?format=auto | Convert the image intelligently to the most efficient output format |
?format=auto&quality=100 | Convert the image intelligently to a lossless format |