
What Is Lanczos Resampling?
Lanczos resampling is a method for calculating pixel values when resizing an image. It combines nearby source pixels using weights derived from a windowed sinc filter, aiming to retain sharpness while producing smooth transitions. For media workflows, Lanczos affects how a resized image looks before it is encoded as JPEG, WebP, AVIF, or another output format.
It’s commonly used for photographic images, particularly when reducing large originals into smaller delivery sizes. Pillow, for example, provides a Lanczos filter for its image resizing and thumbnail operations.
How Lanczos Resampling Works
Calculate Weighted Pixel Contributions
Resizing creates a new pixel grid that generally does not align with the original grid. Software must calculate which source pixels contribute to each output pixel.
Lanczos resampling assigns weights according to the distance between those source samples and the output sampling position. Some weights are negative, helping retain crisp transitions but also creating the possibility of overshoot around strong edges. The result is a weighted combination of source values, rather than a simple selection or equal average.
Limit the Filter’s Reach
The sinc function extends indefinitely, making its direct use impractical for ordinary image processing. Lanczos multiplies it by a finite window, restricting the calculation to a manageable neighborhood. A wider support generally involves more source contributions and a different balance between detail retention and artifacts.
Account for the Resize Direction
When downsampling, filtering must suppress detail that the smaller pixel grid cannot represent reliably. Otherwise, fine patterns can turn into false patterns or jagged edges, collectively associated with aliasing.
When enlarging, interpolation estimates values between existing samples. It can produce smoother, sharper-looking output, but cannot recover original scene detail absent from the source.
The scale factor and implementation therefore matter alongside the filter name.
Lanczos vs. Other Resampling Methods
Different methods offer different practical tradeoffs:
| Method | How it calculates output | Typical consideration |
|---|---|---|
| Nearest neighbor | Selects a nearby source pixel | Preserves hard pixel boundaries |
| Bilinear | Uses linear interpolation | Relatively simple, often softer |
| Bicubic | Uses cubic interpolation | Balances smoothness and sharpness |
| Lanczos | Uses windowed sinc weights | Retains crisp detail but can introduce ringing |
Performance also varies. Pillow’s comparison places Lanczos among its more computationally demanding resizing filters.
