FitMyPic

Resizing

Four resize algorithms, measured on the same images

The algorithm behind a resize decides whether you get moire, a soft image, or a halo around every edge. Here is what each one does, with the numbers.

By FitMyPic Editorial Published 2026-10-22 Last reviewed 2026-10-22 How we test

At a glance

  • Four algorithms, the same four test images, measured against a true area-average reference.
  • Nearest-neighbour left 5.7x more residual noise in flat areas than an ideal downscale (moiré you can see) and scored SSIM 0.60 against 0.99 for the smooth filters.
  • Bicubic produced the closest match to the reference when shrinking a photo: SSIM 0.994, PSNR 49.9 dB.
  • When enlarging a hard edge 4x, bicubic overshoots the edge by 10/255 on each side and Lanczos by 15/255 — the "sharpening halo" is a mathematical property, not a bug.
  • The worst downscale also produced the largest JPEG afterwards: 79.9 KB (nearest) against 49.5 KB (bilinear) for the same content.

What "resize" actually means

Scaling an image is a resampling problem. Every output pixel is a weighted average of the input pixels around it, and the algorithm is nothing more than the choice of weights. That choice decides three things you can see in the result: how much of the original detail survives, whether new patterns appear that were never in the file (aliasing), and whether edges acquire a bright or dark halo (ringing).

We tested the four algorithms available in virtually every image library and browser:

Algorithm Weights Cost Character
Nearest neighbour Picks the single closest source pixel lowest Blocky when enlarging, moiré when shrinking
Bilinear Linear falloff over 2 pixels low Soft, no halos, blurs fine detail
Bicubic Cubic falloff over 4 pixels medium Crisp, slight halos on hard edges
Lanczos Windowed sinc over 6-8 pixels highest Crispest, most pronounced halos

Shrinking: the reference is an area average

For integer ratios there is a defensible "correct" answer: average every block of source pixels into one output pixel. That is a box filter, it is what a camera does when it burns pixels into a smaller sensor, and it is the reference we compare against.

Test: a 2000x2000 pattern with a hard edge and fine noise, shrunk to 500x500 (4x reduction). One half of the image is a single flat colour, so any structure that survives there is noise the algorithm failed to remove.

Method PSNR vs reference SSIM vs reference Residual noise in the flat half Time
NEAREST 31.7 dB 0.603 6.85 3 ms
BILINEAR 44.4 dB 0.981 1.18 85 ms
BICUBIC 46.6 dB 0.986 1.44 141 ms
LANCZOS 46.5 dB 0.984 1.57 236 ms
Downscaling 2000 to 500 px: method vs result 0 13 26 39 52 32 7 NEAREST 44 1 BILINEAR 47 1 BICUBIC 47 2 LANCZOS PSNR vs box reference (dB) halftone noise left behind (lower is better)
Downscaling 2000 to 500 pixels. Higher PSNR is better; residual noise is what an ideal filter would have removed entirely.

Nearest neighbour is not a subtle failure. It reads one of every sixteen pixels and ignores the rest, so a fine repeating pattern in the source turns into a coarse repeating pattern in the output — the classic moiré you see in photographs of fabric, brickwork or a computer screen. That is why it is the right choice only for pixel art, where every source pixel is supposed to stay a block.

Between bilinear, bicubic and Lanczos the differences are small when shrinking: bicubic matched the reference most closely, Lanczos left slightly more residual noise because its wider kernel keeps more high-frequency energy. All three are acceptable; none of them is close to nearest.

Shrinking a real photograph

The prediction pattern holds on photographic content, where the measure is how close each method comes to a straight area average.

Method PSNR vs area average SSIM JPEG q85 size of the result
NEAREST 39.7 dB 0.917 79.9 KB
BILINEAR 48.9 dB 0.990 49.5 KB
BICUBIC 49.9 dB 0.994 52.8 KB
LANCZOS 49.1 dB 0.992 54.1 KB

The last column is the surprise. Nearest neighbour produced the smallest intermediate image — it has no smoothing to store — and then the largest JPEG, 61% bigger than bilinear's. Aliased edges are hard edges, and hard edges are exactly what JPEG spends bits on. A cheaper resize does not produce a cheaper file; it moves the cost into the compressor.

Enlarging: ringing is the trade you make for sharpness

Upscaling cannot invent detail, so the only real question is how gracefully each method interpolates. We enlarged a 400x400 image with a hard vertical step (values 90 and 220) four times and measured how far the result overshoots the original values.

Method Overshoot above the bright side Undershoot below the dark side Visible effect
NEAREST 0 0 Stair-step blocks along every diagonal
BILINEAR 0 0 Soft edges, no halo
BICUBIC 10/255 10/255 Slight bright rim on one side, dark rim on the other
LANCZOS 15/255 15/255 Clearly visible halo, sharpest local contrast

Those numbers are the honest answer to a question people ask constantly: "why does my upscaled logo have a bright outline?" It is not a bug in your tool. Any filter that can produce a sharp edge from a soft one must overshoot — the negative lobes in a cubic or sinc kernel are what make the edge crisp, and they also ring.

Speed

Cost scales with the kernel width: on the same input, nearest took 3 ms, bilinear 85 ms, bicubic 141 ms and Lanczos 236 ms in our test environment. For a single image in a browser tab this is invisible. For a thousand-image batch it is the difference between a two-minute job and a twenty-minute one — if you are processing at scale, bilinear is a defensible choice when shrinking, and the quality difference against bicubic is under one SSIM point.

What to use, and when

Job Use Avoid
Shrink a photo for the web Bicubic or Lanczos Nearest
Shrink a large batch quickly Bilinear Nearest
Enlarge a photo slightly (up to 2x) Bicubic, then a light sharpen Nearest
Enlarge more than 2x Bicubic or Lanczos, accept softness, see the upscaling guide Lanczos followed by aggressive sharpening
Pixel art, sprites, screenshots of pixel UI Nearest Any smoothing filter
Images with transparency Any smooth filter that handles alpha correctly Anything that samples colour without alpha

One rule that matters more than the algorithm choice: resize once. Re-saving and resizing repeatedly compounds resampling artefacts, and each pass through a lossy format adds compression damage on top. Work from the largest original you have, do the resize in a single step to the final dimensions, and only then compress.

Both tools on this site resize with a high-order filter at their highest quality setting (pica at quality: 3, with alpha-safe sampling), which is the bicubic-to-Lanczos class rather than the browser's default bilinear path.

Reproduce it

  • corpus.zip — the test images used for these measurements
  • study-c-resize.csv — every method, every test, with PSNR, SSIM, ringing and timings
  • bench_kit.py — the script that produced the numbers, including the box-filter reference implementation
  • README.txt — how to run the scripts

What this test does not cover

Ringing and aliasing were measured on synthetic patterns where an exact reference exists; a real photograph has no ground truth, so the "best" method there is a judgement call supported by the reference comparison, not proven by it. Timings came from one environment. And the JPEG sizes at the end of the chain depend on the encoder, so treat the 79.9 KB against 49.5 KB as a ratio rather than a rule.

Resize, compress and convert images in your browser

Everything happens on your device — no upload, no account.

Open the image tools

Sources

  • Pillow resampling documentation (filters, Image.Resampling) — https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.resize
  • pica resampling library documentation (filters and quality levels) — https://github.com/nodeca/pica
  • SSIM index, original paper (Wang et al.) — https://ece.uwaterloo.ca/~z70wang/publications/ssim.pdf
  • ImageMagick "Resize or Resample" (filter families, aliasing) — https://imagemagick.org/Usage/resize/