Skip to main content
Version: 3.36.0

Format

Enumerator options for imageOptimizerOptions.format.

Constants

  • Auto ("auto") Automatically use the best format based on browser support and image/transform characteristics
  • AVIF ("avif") AVIF
  • BJPG ("bjpg") Baseline JPEG
  • GIF ("gif") Graphics Interchange Format
  • JPG ("jpg") JPEG
  • JXL ("jxl") JPEGXL
  • MP4 ("mp4") MP4 (H.264)
  • PJPG ("pjpg") Progressive JPEG
  • PJXL ("pjxl") Progressive JPEGXL
  • PNG ("png") Portable Network Graphics
  • PNG8 ("png8") Portable Network Graphics palette image with 256 colors and 8-bit transparency
  • SVG ("svg") Scalable Vector Graphics
  • WEBP ("webp") WebP
  • WEBPLL ("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'
});
}