How Image Resizing Works: Nearest-Neighbour, Bilinear and Bicubic Interpolation
When you resize a 4000 × 3000 phone photo to the 200 × 230 pixels an exam form wants, the software has to invent every new pixel from the old ones. How it does that is called interpolation or resampling. It is a standard topic in image processing and computer graphics courses, and it decides whether the result looks sharp, blurry, jagged or shimmering. This article explains the three classic methods with worked numbers, and shows how browsers expose them.
In short: nearest-neighbour copies the closest source pixel (fast, blocky). Bilinear blends the 4 nearest pixels (smooth). Bicubic fits curves through 16 pixels (smoother and sharper). When shrinking an image a lot, the method must also average many source pixels, otherwise fine detail turns into jagged or shimmering patterns (aliasing).
Step 0: mapping a destination pixel back to the source
Every method starts by asking, for each output pixel, "where would this pixel be in the original?" With a scale factor s = source width ÷ destination width, one common convention that lines up pixel centres is:
source_x = (dest_x + 0.5) × s − 0.5
Example values: shrinking a 4000-pixel-wide photo to 200 pixels gives s = 20. Output pixel 0 maps to source x = 9.5, output pixel 1 maps to 29.5, and so on. The answer is usually a fraction, between real pixels. The methods differ in how they fill that gap.
Method 1: nearest-neighbour
Round the source position and copy that pixel. There is no blending, so it is very fast and keeps hard edges. Enlarged pixel art and QR codes stay crisp. For photos it produces blocky "staircase" edges when enlarging. When shrinking it simply skips most source pixels, for example 19 of every 20 in the example above, so thin lines can disappear or break up.
Method 2: bilinear
Take the 4 surrounding pixels and blend linearly, first horizontally and then vertically. With fractional offsets fx and fy (0–1):
top = P00 + fx × (P10 − P00)
bottom = P01 + fx × (P11 − P01)
value = top + fy × (bottom − top)
Worked example (example values): the four neighbours are P00 = 10, P10 = 20, P01 = 30, P11 = 40, and the target is at fx = 0.25, fy = 0.5. Top = 10 + 0.25 × 10 = 12.5. Bottom = 30 + 0.25 × 10 = 32.5. Value = 12.5 + 0.5 × 20 = 22.5. Nearest-neighbour would have returned 10 or 30, depending on rounding.
Bilinear gives smooth results for moderate scaling. When enlarging a lot it looks soft, because it can only produce straight-line ramps between pixels.
Method 3: bicubic
Bicubic uses a 4 × 4 neighbourhood (16 pixels) and a cubic weighting curve in each direction. Because a cubic can bend, it follows the shape of the image better than straight lines. Edges look sharper than with bilinear. Some cubic kernels slightly overshoot near edges, which can show as a faint bright or dark outline, the same "ringing" idea you meet in JPEG compression. There are several cubic kernels, and different software uses different ones. That is one reason two apps resize the same photo slightly differently.
| Method | Source pixels used | Speed | Typical look | Good for |
|---|---|---|---|---|
| Nearest-neighbour | 1 | Fastest | Blocky, jagged | Pixel art, QR codes, exact 2× / 3× scaling |
| Bilinear | 4 | Fast | Smooth, can be soft | Moderate resizing, previews |
| Bicubic | 16 | Slower | Smooth and sharper | Photos, final output |
The real problem when shrinking: aliasing
Interpolation formulas only look at a few neighbours. When you shrink by 20×, each output pixel should represent a 20 × 20 area (400 source pixels), but bilinear looks at only 4 of them. Fine patterns such as hair, fabric or printed text then turn into false patterns (moiré) or jagged lines. Good downscalers fix this by averaging or filtering the whole area: area-averaging ("box") filters, or shrinking in several steps of about half each time. Then they interpolate.
Practical consequence: a 4000-pixel photo shrunk straight to 200 pixels with a basic method can look worse than the same photo shrunk in steps (4000 → 2000 → 1000 → 500 → 250 → 200). The file size is about the same, but the detail is cleaner.
How browsers expose these choices
- Canvas: MDN documents that
imageSmoothingEnableddecides whether scaled images are smoothed (true by default).imageSmoothingQualitycan be "low", "medium" or "high", and the default is "low". Browsers decide which exact algorithm each level uses. Crop Desk's image tools draw on a canvas with smoothing quality set to high. - CSS: the
image-renderingproperty sets the scaling algorithm for displayed images, with values such asauto,smooth,crisp-edgesandpixelated. It only changes how an image is displayed, not the file.
Resizing and aspect ratio
Interpolation answers "what colour is the new pixel?". It does not decide the shape. If the width and height are scaled by different factors, every method will stretch the image. Exam portals that require, for example, 200 × 230 pixels expect you to crop to that ratio first and then resize. Why stretched photos get rejected explains the crop-then-resize method. cm to pixels at 200 and 300 DPI helps when a notice gives the size in centimetres.
Exercise
- Shrink one detailed photo (with hair or fabric) to 200 pixels wide in the image resizer, and also in a basic image viewer.
- Zoom both results to 400% and compare the edges and textures.
- Enlarge a 50 × 50 icon to 400 × 400. Smoothing makes it soft; nearest-neighbour keeps it blocky but sharp.
Resize a photo to exact pixels for your form.
Open the image resizerFrequently asked questions
Which resizing method is best for photos?
Bicubic or a high-quality smoothing setting, combined with proper averaging when shrinking a lot. Nearest-neighbour suits pixel art and QR codes.
Why does my shrunk photo look jagged?
Large reductions with only a few neighbours sampled cause aliasing. Shrinking in steps, or with area averaging, gives cleaner results.
Does resizing change the aspect ratio?
Only if width and height are scaled by different factors. Crop to the required ratio first, then resize.
Sources
- MDN Web Docs – CanvasRenderingContext2D.imageSmoothingEnabled
- MDN Web Docs – CanvasRenderingContext2D.imageSmoothingQuality
- MDN Web Docs – image-rendering (CSS)
- MDN Web Docs – CanvasRenderingContext2D.drawImage()
Sources checked on 23 November 2026. Official notices and orders change; the latest version on the issuing body's website is final.