SquishPixel Blog · Image optimisation · Browsers · Front-end

Browser canvas upscaling uses bilinear only, and imageSmoothingQuality changes nothing

According to a DEV Community post, the author measured how a browser canvas resamples images, using an impulse response instead of relying on documentation. An impulse response means drawing a single white pixel on a black canvas, enlarging it, and reading the resulting pixel values to reveal the filter used.

The result was a triangle shape, which is bilinear filtering (a simple method that blends neighbouring pixels). The pattern held at 2x, 4x and 8x. In Chrome 157 on Linux, the 'low', 'medium' and 'high' values of imageSmoothingQuality produced byte-identical output. The author says the setting appears to be a hint that matters only when shrinking images, and could not make it take effect even there.

The post also tested upscaling in two steps, such as 128 to 256 pixels and then 256 to 512. Compared with a single draw, this cost up to 0.59 dB in image quality when the scale factor was below 3x. At 3x and above the differences fell to about 0.10 dB, which the author treats as noise. Control tests, including drawing an image at its own size, were run to check the method.

The author also found the canvas averages colour values as stored (sRGB), not in linear light. A test with three black pixels and one white returned 63, not 188. On one photo, linear-light upscaling scored 0.41 dB lower than the native path, though the author says that result is biased by how the ground truth was made. For a 4x upscale, the canvas result matched PIL's bilinear closely and sat far from PIL's Lanczos, a sharper filter. The author puts the gap at about 1 dB. createImageBitmap with resizeQuality: 'high' followed a different path, not a better one.

Why it matters

If you resize images in the browser, for example in an upload tool or an image editor on your site, you should not expect sharp, Lanczos-style results from the canvas. The quality setting will not change that, at least in the browser the author tested. Treat it as a single bilinear filter.

Chaining several small enlargements is a common habit and the post suggests it quietly adds blur. These are one author's measurements in one browser, so check your own results. But the advice is simple: enlarge once, or keep any intermediate size at least 3x the final size. For better quality the author points to a WebGL shader or WASM resampler where you choose the filter.

Source: DEV Community. This brief summarises their reporting; read the original for the full detail.