Image tools

Tools that work on the pixels of one raster image — reshaping it, marking it, sampling it, or reading the words out of it — inside a browser tab.

7 tools · nothing uploaded · no sign-up

Decoding is wider than encoding

A browser opens more image formats than it can write back. Decoding tries createImageBitmap first and an image element second, which rescues some older AVIF and BMP variants the first path rejects; HEIC decodes on neither outside Safari. Writing is narrower — PNG, JPEG and WebP, where the browser has an encoder — so a GIF or BMP that opened perfectly comes back as a lossless PNG, an animated one as its first frame.

A canvas asked for a format it cannot encode returns a PNG under the name you asked for, so the blob's type has to be checked. And JPEG has no alpha: transparent pixels come out black unless the canvas is painted white first.

The ceiling is memory, not file size

Decoded, a picture is four bytes per pixel: a flat-colour 16,384 by 16,384 PNG holds under a megabyte on disk and 1.07 GB of RGBA in memory. So the text reader takes width and height from the file's own header — PNG, JPEG, WebP, GIF and BMP each state them in the first 256 kilobytes — and refuses past 50 megapixels before decoding. AVIF and HEIC keep theirs in unparsed ISO-BMFF boxes, so they meet the 40 MB ceiling alone.

One long side is a separate test: a 100,000 by 40 strip is exactly four megapixels, passes any area budget, then fails to allocate a canvas. A side over 20,000 pixels is refused as undrawable, and what passes is clamped to 16,384. Re-encoding has its own ceiling: on iOS a canvas above roughly 16.7 megapixels returns nothing, not an error.

Reading pixels rather than rewriting them

Recognition is Tesseract, trained on scanned documents: high contrast, upright, roughly 300 DPI. A photograph is none of those, so it is rebuilt first — greyscaled, contrast-stretched between its 2nd and 98th percentiles, then thresholded against each pixel's own neighbourhood, since a side-lit page turns half solid under one global cut-off. A short side under 1000 pixels is enlarged up to fourfold, everything capped at four megapixels, above which recognition stops improving. Skew is left alone: an angle estimated wrongly is worse than none.

Colour sampling inverts the problem: the preview is drawn at most 640 pixels wide, so a pixel read from it would be a blend of neighbours; the values come from a separate full-resolution canvas with smoothing off.