ResizeFilter
Enumerator options for imageOptimizerOptions.resizeFilter.
Constants
Nearest("nearest") Uses the value of nearby translated pixel values.Bilinear("bilinear") Uses an average of a 2x2 environment of pixels.Linear("linear") Same asBilenear.Bicubic("bicubic") Uses an average of a 4x4 environment of pixels, weighing the innermost pixels higher.Cubic("cubic") Same asBicubic.Lanczos2("lanczos2") Uses the Lanczos filter to increase the ability to detect edges and linear features within an image and uses sinc resampling to provide the best possible reconstruction.Lanczos3("lanczos3") Lanczos3 uses a better approximation of the sinc resampling function. (Default)Lanczos("lanczos") Same asLanczos3.
Examples
import { ResizeFilter, 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,
width: 2560,
resizeFilter: ResizeFilter.Linear
},
backend: 'w3'
});
}