How it works

How image scaling works here

Everything on this page describes code that runs in your browser when you use the tools. Nothing is computed on a server.

1 · Decoding

Your browser decodes the file (JPEG, PNG, WebP, GIF, BMP, AVIF; HEIC in Safari), applies the camera’s orientation tag, and hands over 8-bit RGBA pixels. A JPEG or PNG’s stated DPI is read from its JFIF header or pHYs chunk.

2 · Classical resampling

The engine runs in a Web Worker. For each output pixel it computes which source pixels contribute and with what weight (a contribution table), separately for columns and rows. It resamples each source row horizontally, then combines rows vertically. Only a window of rows as tall as the filter is held in memory at once, so reducing a 48-megapixel photo needs a few megabytes of working space.

  • Linear light. sRGB values are converted to linear light with the exact sRGB curve before weighting and converted back through a 65,536-step table afterwards.
  • Premultiplied alpha. Colour is weighted by opacity, then divided out again, so transparent pixels never bleed into edges.
  • Anti-aliasing. When reducing by a factor k, the filter is stretched k times so every source pixel under an output pixel contributes. Box uses exact fractional coverage.
  • Clamping. Sharp filters can overshoot; values are clamped to the valid range before encoding.
  • Regions. Any rectangle of the output can be computed alone; Fill & crop and the comparison lab use this to avoid computing pixels they would discard.

The filters

  • Nearest neighbour — Copies pixels. Hard, blocky edges on enlargements and shimmering aliasing on reductions; exactly right for pixel art.
  • Box (area average) (radius 0.5) — Averages every source pixel that falls inside each output pixel. Clean, alias-free reductions; soft and blocky when enlarging.
  • Bilinear (triangle) (radius 1) — Blends the nearest pixels linearly. Smooth and fast, visibly soft on enlargements.
  • Bicubic (Catmull-Rom) (radius 2) — The sharp bicubic most editors call ‘bicubic’. Crisper than bilinear with a faint halo on hard edges.
  • Bicubic (Mitchell) (radius 2) — A balanced cubic: a little softer than Catmull-Rom, almost no ringing. A safe choice for big enlargements.
  • Lanczos-2 (radius 2) — Windowed sinc with two lobes. Sharp, with mild ringing.
  • Lanczos-3 (radius 3) — Windowed sinc with three lobes. The sharpest classical filter, best for photographs; can ring next to hard edges.

Auto picks Lanczos-3 for reductions and enlargements up to 2×, and Mitchell above 2×.

3 · AI enlargement

AI detail ×4 (Real-ESRGAN) (4.6 MB, BSD-3-Clause (Real-ESRGAN general-x4v3 weights)) and AI fast ×3 (ESPCN) (234 KB, Apache-2.0 (ONNX model zoo, sub-pixel CNN 2016)) run with ONNX Runtime Web, on WebGPU when an adapter is available and on WebAssembly otherwise. The model file comes from our model file server after you agree, is checked by length and SHA-256, and is cached. The picture is processed in overlapping tiles; only each tile’s centre is kept. If the GPU returns invalid output, the session is rebuilt on WebAssembly and the job continues. Results then go through an exact Lanczos-3 resample to your requested size. Transparency is enlarged separately with Lanczos-3, because the networks work on colour only.

A memory guard caps AI output at 48 megapixels on desktops and 16 megapixels on phones and low-memory devices; bigger requests reduce the input first.

4 · Pixel art

Integer nearest copies each pixel into an exact block. Scale2x and Scale3x (the EPX family) compare each pixel with its neighbours and take corners from them where edges agree; Scale4x is Scale2x twice. The grid detector measures the spacing of colour changes along both axes, takes their greatest common divisor and confirms the blocks are uniform before offering to restore a 1× sprite.

5 · Content-aware scaling

Seam carving with forward energy: dynamic programming finds the top-to-bottom path whose removal creates the least new edge between pixels that become neighbours. Seams are removed one at a time, or found and then duplicated (averaged with their neighbour) in batches of at most half the width to widen. Height changes run on the transposed picture. Brush masks add or subtract a large cost. Seams are computed on a copy of up to 1 megapixel.

6 · Encoding and DPI

Results are encoded by the browser as PNG, JPEG or WebP. JPEG has no transparency, so transparent areas are flattened onto white first. DPI is written by rewriting the JPEG JFIF density fields or inserting a PNG pHYs chunk. “Change DPI only” patches those bytes in the original file and copies the compressed picture data unchanged. Batch results are packed into a stored (uncompressed) ZIP built in the browser.

See it for yourself in the scaling lab.