Skip to main content
Version: 3.36.0

Optimize

Enumerator options for imageOptimizerOptions.optimize.

Constants

  • Low ("low") Output image quality will be similar to the input image quality.
  • Medium ("medium") More optimization is allowed. We attempt to preserve the visual quality of the input image.
  • High ("high") Minor visual artifacts may be visible. This produces the smallest file.

Examples

import { Optimize, 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,
optimize: Optimize.High
},
backend: 'w3'
});
}