Take a 1024 px square of 1 px black-and-white squares and halve it. The pattern cannot survive: every output pixel now covers exactly one black and one white source pixel, so the output is a flat field, and the only question left is what value that field should have.
It should have the value of half the light. A black pixel emits nothing and a white pixel emits everything, so the average of the two is half of everything, and the sRGB transfer function says half of everything is 188. That is not a preference or a convention; the curve is defined as the encoding of a linear quantity, and half of that quantity encodes to 187.5.
The field I got was 127.
Same file, four implementations, one 2× downscale:
| path | output level |
|---|---|
PIL, Image.LANCZOS | 127.0 |
PIL, Image.BOX | 128.0 |
sips (CoreGraphics) | 127.5 |
Chrome canvas, drawImage at high quality | 127.0 |
None of them is broken and none of them is guessing. They all average the numbers the file stores instead of the light those numbers stand for, and for a pattern at the edge of what the grid can hold, the two answers are 60 levels apart. That is not a rendering detail. It is a resize that keeps the mean of the code and throws away 58% of the light.
The gap is a property of the pair, not of the filter
For a 2× box the arithmetic is one line. The output is the mean of two code values, (a + b) / 2. The light it should carry is the mean of the two lights, encode((lin(a) + lin(b)) / 2). The second is a concave function of the first — the encode curve bends, and its bend is the whole story:
| pair being averaged | sRGB average | light average | gap |
|---|---|---|---|
| 0 and 255 | 127.5 | 187.5 | 60.0 |
| 20 and 235 | 127.5 | 173.2 | 45.7 |
| 0 and 128 | 64.0 | 92.4 | 28.4 |
| 60 and 200 | 130.0 | 151.4 | 21.4 |
| 0 and 40 | 20.0 | 26.5 | 6.5 |
| 100 and 155 | 127.5 | 131.2 | 3.7 |
Two things about that table are worth keeping. The gap is not monotone in the mean — 0 and 128 have a bigger gap than 60 and 200, because the curve bends hardest near the bottom. And the gap is zero exactly on the diagonal: averaging two equal values is the one case where the spaces agree, which is why a flat area is a fair test of a resampler and an edge is not.
The direction is fixed. Over 4,000 random pairs the sRGB average was never once lighter than the light average: the largest signed difference is 0.0, at the pairs where the two values are equal, and the mean is −12.1 levels. That is Jensen's inequality doing its job rather than a property of any particular kernel — for a concave function, the function of the average is at least the average of the function, so an sRGB resize can only ever darken a mixed pixel, never lighten it.
So the filter is not the lever. BOX gave 128 and LANCZOS gave 127 for the same input, and the difference between them is the kernel's negative lobes subtracting a little light, not the kernel being more correct. A Lanczos kernel and a triangle kernel and a Mitchell kernel all have weights that sum to one, which is precisely the condition under which the output is a weighted average of code values and the concavity applies. Getting the weights right does not move you into the other space.
Neither is the size of the resize. I ran the same 1 px checkerboard down by 1.25×, 1.5×, 2×, 3×, 4×, 6× and 8×, and the difference between the two paths stayed between 60 and 61 levels every time. It cannot do anything else: a downscale preserves the mean of the code by construction, and the mean of the light is what it should have preserved.
And it is not a downscale phenomenon either. Doubling the same checkerboard — interpolating rather than averaging — gives 127.5 in sRGB space and 180.4 in light, a mean difference of 52.9 levels over the whole frame. The trigger is mixing, not shrinking. Anywhere a resampler has to invent a value between two neighbours that differ, it invents the wrong one.
What the four tools on this machine do
The same 1024 px file, the same 2× downscale, the mean of the result:
| path | mean level | against 187.5 |
|---|---|---|
| light average, closed form | 187.5 | — |
| PIL, resampling in linear light | 188.0 | +0.5 |
PIL, LANCZOS | 127.0 | −60.5 |
PIL, BOX | 128.0 | −59.5 |
sips (CoreGraphics) | 127.5 | −60.0 |
| Chrome canvas, high quality | 127.0 | −60.5 |
I expected to find a split here, with at least one of the system paths doing it in light. There isn't one. CoreGraphics resamples the stored values; so does the browser; so does Pillow. The +0.5 on my own row is rounding in the re-encode, and it is the same rounding the closed form has.
Where it lands in a packshot
A 60-level error sounds like something you would have noticed. The reason you have not is that it only exists where the resize destroys detail, and it vanishes as soon as the neighbours it averages are similar. Measured as the share of the scene's light that survives a 2× downscale:
| content | light kept, sRGB path | light kept, linear path |
|---|---|---|
| 1 px checkerboard | 42.4% | 100.6% |
| 1 px lines, 4 px pitch | 75.1% | 100.1% |
| text at 17 px | 99.95% | 100.0% |
| a real packshot | 99.98% | 100.0% |
The last two rows are the honest half of this. A photograph is mostly made of neighbours that are already close, so the concave average and the light average coincide: on my mug shot the frame mean moves by 0.02 levels, the mean per-pixel difference is 0.05, and no pixel is off by more than 7. If you resized this photo either way and looked at it, you could not tell.
What does move is the fine structure, and it moves by the amounts in the first column of the pair table:
- The silhouette. A black-to-white edge downscaled 2× is wrong across a 2 px band — two output pixels, at every factor from 1.25× to 4× — wide enough to see on a 1200 px image, narrow enough that a per-block or per-image metric never notices. The peak inside that band runs from 22 to 71 levels, depending on where the edge falls relative to the sample grid and on how much the kernel rings; the 71 is a factor of 3, where Lanczos overshoots and adds its own error to the averaging error.
- The soft edge the file already has. Widening the transition from 0 px to 1, 3, 6 and 24 px drops the peak from 61 to 37, 14, 3 and finally 1 level. This is why a photographed edge is nearly immune and a mathematically sharp cutout is not: the lens already did the averaging in light, before the file existed.
- Printed text. Text at 17 px in the source, downscaled by two, comes out with 637 pixels below an ink threshold where the light path gives 504 — 26% more of the frame reads as ink, which is why downscaled label copy looks bolder than the original. At 60 px the same test moves 2%: the detail has to be near the output pixel to be affected.
- The matte's own edge. The same concavity is what an alpha composite does. A semi-transparent edge pixel at alpha 0.5 over white, against a dark navy product, comes out
137, 157, 187in sRGB space and188, 191, 202in light — 51, 34 and 15 levels too dark per channel. The lighter the product, the smaller the error, and for a near-white product it is zero, which is why a dark product on white shows a rim and a cream one does not.
Doing it in light
Two transfer functions and one resize. The only trap is that Pillow's float mode needs a contiguous plane per channel — a slice of an (H, W, 3) array has a row stride of three floats, and fromarray does not copy, so it reads the channels interleaved. The values that come back look plausible, in pairs that sum to one, and are wrong:
import numpy as np from PIL import Image def to_linear(x): x = np.asarray(x, dtype=np.float64) return np.where(x <= 0.04045, x / 12.92, ((x + 0.055) / 1.055) ** 2.4) def to_srgb(x): x = np.clip(np.asarray(x, dtype=np.float64), 0.0, 1.0) return np.where(x <= 0.0031308, x * 12.92, 1.055 * x ** (1 / 2.4) - 0.055) def resize_in_light(im, size, resample=Image.LANCZOS): a = to_linear(np.asarray(im.convert("RGB")) / 255.0) chans = [Image.fromarray(np.ascontiguousarray(a[:, :, c], dtype=np.float32), "F") .resize(size, resample) for c in range(3)] lin = np.stack([np.asarray(c, dtype=np.float64) for c in chans], axis=2) return Image.fromarray(np.clip(np.round(to_srgb(lin) * 255), 0, 255).astype(np.uint8)) Two things about running it in a real pipeline.
The output is lighter, and the amount is proportional to how much detail the resize destroyed. On the packshot that is 0.02 levels and invisible; on a downscaled logo or a fine texture it is 10 to 60, and visible. If your gallery was tuned on sRGB resizes, the images that will look different are the ones with hard graphics in them, which is exactly the set that was wrong.
And the difference survives encoding, so it is not a theoretical one you can defer. Re-encoding both results as JPEG at quality 95, 85 and 70 leaves 127.00 and 188.00 untouched to two decimals — a flat field is the easiest thing for a DCT to represent, and luminance is not subsampled, so nothing in the encoder recovers the light that the resize dropped.
The check
One function, and it is the whole diagnosis:
def light(im): a = np.asarray(im.convert("RGB"), dtype=np.float64) return to_linear(a / 255.0).mean() Resize a file, then compare light before and after. A correct path returns the same number to rounding; an sRGB path returns less, and the deficit is the share of the scene that the resize deleted. On a normal photograph the deficit is 0.02% and tells you nothing. On a graphic, a texture, a downscaled wordmark or a cutout silhouette it is tens of percent, and it is the difference between a thumbnail that looks like the object and one that looks like a slightly heavier version of it.
I work on PicViva, and this is the step I had to fix before anything downstream was worth measuring. Our resize for marketplaces has to hit 1000, 1200 and 1600 px from whatever was uploaded, and every one of those targets is a downscale — so the one operation that decides whether a label stays readable is also the one that silently darkens it. Doing the resample in linear light is about fifteen lines, and the reason I wrote it down is the size of the gap: 60 levels at full contrast, on every hard edge in the frame, from four tools that all agree with each other and are all in the wrong space.
If you want the neighbouring problem — which kernel to use once you are in the right space — that one has its own measurements: five resampling filters on one product photo.





