Skip to main content
Version: 3.36.0

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 as Bilenear.
  • Bicubic ("bicubic") Uses an average of a 4x4 environment of pixels, weighing the innermost pixels higher.
  • Cubic ("cubic") Same as Bicubic.
  • 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 as Lanczos3.

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'
});
}