Format
Enumerator options for imageOptimizerOptions.format.
Constants
Auto("auto") Automatically use the best format based on browser support and image/transform characteristicsAVIF("avif") AVIFBJPG("bjpg") Baseline JPEGGIF("gif") Graphics Interchange FormatJPG("jpg") JPEGJXL("jxl") JPEGXLMP4("mp4") MP4 (H.264)PJPG("pjpg") Progressive JPEGPJXL("pjxl") Progressive JPEGXLPNG("png") Portable Network GraphicsPNG8("png8") Portable Network Graphics palette image with 256 colors and 8-bit transparencySVG("svg") Scalable Vector GraphicsWEBP("webp") WebPWEBPLL("webpll") WebP (Lossless)WEBPLY("webply") WebP (Lossy)
Examples
import { Format, Region } from 'fastly:image-optimizer';
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
async function handleRequest(event) {
return await fetch('https://www.w3.org/Graphics/PNG/text2.png', {
imageOptimizerOptions: {
region: Region.UsEast,
format: Format.PNG
},
backend: 'w3'
});
}