What a machine computes

A chain of resizes remembers its smallest picture

A picture resized several times, each tool keeping the aspect of the picture it was handed, carries every tool's rounding to the end: nothing undoes an earlier one, because the next tool rounds the aspect it was given. The final squeeze is bounded by the sum of every step's one rounding and fills it, so the smallest picture in the chain dominates, and an enlargement after a thumbnail brings the thumbnail's half pixel back magnified: 14 px of height at 690 px wide through a 25 px icon. The roundings add as a root of the count, floors add in a straight line, and a tool that keeps the source's own aspect forgets them all but its last.

Worth reading first: A pixel is not a point · The pixel that is not square.

A thumbnail gives its camera a pixel it cannot see resized a crop once. A tool given a target width keeps the picture’s aspect by computing a height, which comes out fractional and is rounded, and that leaves the picture’s two focal lengths scaled by two different ratios of whole numbers. They disagree by at most one rounding of the target’s height, 1/(2h)1/(2h), the picture’s edge moves by at most half a target pixel, and no reading of a box and a square in the thumbnail is fine enough to see either.

The essay ended by pointing out that a picture on the web is rarely resized once. A crop becomes a figure at one width, the figure is scaled by a device’s ratio, and a preview card is cut from the page at a third width, each step taken by a tool that knows nothing about the others. A display’s scales cancel, if they are true maps had already followed a picture through several resamples, from a renderer’s buffer to a compositor to a screenshot, and found the roundings telescope: each undone by the next scale, so that only the last survives. The question was whether a chain of thumbnails does the same, or whether its roundings add; and whether a chain that enlarges between two reductions brings the crop’s own half pixel back at the largest scale it passed through.

A chain of resizes does not telescope. Each tool rounds the aspect it was handed, so every earlier rounding is kept, and the one that dominates is the rounding made in the smallest picture the chain passed through. The crop’s own half pixel, by contrast, comes back at the last scale and no other.

Three ways to reach 690 pixels

The crop is the earlier one: 211 by 131 logical pixels of a 1280 by 720 window composited at a device scale of 1.5, landing on 316 by 196 panel pixels when each edge is rounded. Its aspect asks for a picture 690 px wide to be 427.97 px tall.

A crop resized to 690 px wide through a 25 px picture keeps that picture's rounding, enlargedThe 211 × 131 logical crop, 316 × 196 on a panel at a device scale of 1.5, resized to 690 px wide three ways, each tool rounding the height from the picture it was handed. Straight to 690: 428 px tall against 427.97 asked for, a squeeze of 0.006%. Through a 117 px thumbnail first, 73 px tall: 431 px at the end, 0.71%. Through a 25 px picture, 16 px tall: 442 px at the end, 3.28%, 14.0 px taller than the crop's aspect. Each final picture is the crop scaled once; what differs is the height the last tool was handed.316 × 196690 × 428straight to 690fy/fx − 1 = 0.01%316 × 196117 × 73690 × 431via a 117 px thumbnailfy/fx − 1 = 0.71%316 × 19625 × 16690 × 442via a 25 px picturefy/fx − 1 = 3.28%boxes at 0.2 of their pixelseach tool rounds the height it was handed
Fig. 1 The crop resized to 690 px wide three ways, the boxes drawn at a fifth of their pixels: straight there, through a 117 px thumbnail first, and through a 25 px icon first, each tool rounding the height from the picture it was handed. The slider changes the width of the picture in between.

Straight to 690, one tool rounds 427.97 to 428, and the picture’s two focal lengths agree to 0.006%. Through a 117 px thumbnail first, the first tool makes the thumbnail 73 px tall from an asked-for 72.57, and the second tool, handed a 117 by 73 picture, asks for 690×73/117=430.51690 \times 73/117 = 430.51 and makes it 431. The final picture is 3 px taller than the crop’s aspect wants, a squeeze of 0.71%. Through a 25 px icon, the first tool rounds 15.51 to 16, the second asks for 441.6 and makes 442, and the final picture is 14 px too tall, a squeeze of 3.28%.

The reason is in what the second tool is told. It is handed a picture and keeps that picture’s aspect, and the picture’s aspect already carries the first rounding. Nothing in a 117 by 73 thumbnail says that it was meant to be 117 by 72.57, so the second tool keeps the error as faithfully as it keeps the scene. Written as a product, each step multiplies the picture’s aspect by 1+ei1 + e_i, its own rounding relative to its own height, and the squeeze at the end is

fyfx=∏i(1+ei),∣ei∣≤12hi,\frac{f_y}{f_x} = \prod_i (1 + e_i), \qquad |e_i| \le \frac{1}{2h_i},

where hih_i is the height the ii-th tool asked for before rounding. No later factor undoes an earlier one, because no later tool knows it is there.

The display’s chain was different in exactly one respect. Its scales were all of the whole frame and each was set from a stated size the next step knew, so the composition of true maps carried every pixel through to a final size that had been fixed in advance. Here the final size is not fixed in advance. It is computed, one tool at a time, from the previous tool’s answer. A rounded viewport has two focal lengths met the same arithmetic at the other end of the pipeline, where a renderer takes its aspect from a requested size and rounds the buffer, and there too the rounding was harmless only because one stated size was read once.

The bound is the sum, and the smallest picture’s share is largest

If every factor can be as large as its own rounding allows, the bound on the chain is the sum of the roundings, to first order. Whether a real chain comes near it is a separate question.

After a picture in between, the squeeze at 690 px is bounded by both roundings, and the smaller picture's dominatesThe crop resized to a width between 24 and 690 px and then to 690 px, each height rounded from the picture before it. The squeeze of the final picture (solid) against the sum of the two steps' roundings, 1/(2h₁) + 1/(2h₂) (dotted), which it fills to 98%, and against the last step's alone, ±0.117% (thin solid). Through 117 px it is 0.71%, through 61 px 0.47%, through 30 px 2.11%, through 25 px 3.28%. A tool that takes the height from the source's aspect instead (dashed) rounds once, at the end, and stays at 0.006% whatever came before.2550100200400690-4-2024width of the picture in between (px), on a log scalefy/fx − 1 at 690 px (%)each from its inputfrom the sourceboth roundingsthe last alonecrop → in between → 690 pxthe last rounding alone: ±0.117%
Fig. 2 The crop resized to an intermediate width between 24 and 690 px and then to 690 px, with the final picture’s squeeze against the sum of the two steps’ roundings and against the last step’s alone; and the squeeze when the second tool keeps the source’s aspect instead.

Sweeping the intermediate width through every whole pixel from 24 to 690, the final squeeze saws back and forth inside the sum of the two roundings and reaches 98% of it, so the sum is the chain’s real size and not a loose ceiling. The last step’s rounding alone allows ±0.117%, and through most small intermediate pictures the squeeze is far outside that: 0.71% through 117 px, 0.47% through 61, 2.11% through 30, 3.28% through 25. As the intermediate picture grows the envelope narrows towards the last step’s, and once the intermediate is as large as the final, the two roundings are equal partners and the squeeze can be about twice what one step leaves.

The sum is dominated by its largest term, and the largest term belongs to the smallest picture, since 1/(2h)1/(2h) grows as hh shrinks. That is the sense in which a chain remembers its smallest picture. A thumbnail 73 px tall can contribute up to 0.69% on its own; a figure 431 px tall, 0.12%. A chain that passes through a thumbnail on the way to a large picture carries the thumbnail’s share whatever the large picture’s own rounding does.

The dashed line is a tool that does not take the aspect from its input. An image service that stores an original’s width and height, and computes every derived size from those, rounds once, at the size it produces, and the chain telescopes as the display’s did: 0.006% at 690 px whatever came before. The difference between the two tools is not their arithmetic, which is identical, but where they read the aspect from. A chain is safe exactly when every tool in it reads the same stated aspect and no tool reads another’s output.

This also answers the earlier essay’s question about enlargements. A chain that enlarges between two reductions, crop to 117 px, then up to 1,280, then down to a 300 px card, ends with a squeeze of 0.497% against the card’s own bound of 0.269%. The same card made from a 640 px figure enlarged to 960 ends at −0.041%. The enlargement in the middle contributes almost nothing either way; what separates them is the 117 px thumbnail, whose rounding the enlargement then carries forward.

Half a thumbnail pixel, at the scale of the last picture

A percentage of the focal length is one reading of the squeeze. What a person looking at the picture sees is where its edges are.

In the final picture the error is a whole number of pixels, and up to half the small picture's pixel, enlargedThe same chains, the final picture's height less the height the crop's aspect asks for at 690 px wide, 427.97 px: the bottom edge's error, which every other row shares in proportion. The final height is a whole number, so the error is a whole number of pixels plus 0.03. Its bound (dotted) is half a final pixel for the last step plus half the intermediate picture's pixel carried at the scale from it to the end, 690/w. It reaches 14.03 px through a 25 px picture, and 3.03 px through 117. From the source's aspect it is 0.03 px for every chain.2550100200400690-10010width of the picture in between (px), on a log scalefinal height less the aspect's (px)half-pixels carriedcrop → in between → 690 pxworst 14.0 px via 25 px
Fig. 3 The same chains: the final picture’s height less the height the crop’s aspect asks for at 690 px, which is the bottom edge’s error and is shared by every other row in proportion, against the half pixels of the two steps carried to the end.

The final picture’s height is a whole number, so its error against the 427.97 px the aspect wants is a whole number of pixels plus 0.03. A single step can only make it 0.03 px, the rounding of the last tool. Through 117 px it is 3.03 px; through 25 px, 14.03 px, the worst over every intermediate width. The bound drawn is the half pixel each step’s rounding moves its own bottom edge, carried at the scale from that step’s picture to the end: half a final pixel for the last tool, plus half an intermediate pixel times 690/w690/w for the one before. Half a pixel of a 25 px icon, scaled up 27.6 times, is 13.8 final pixels.

Every other row is moved in proportion to its height, so a point at the picture’s middle is wrong by half the edge’s error and a point at the top by none. That is a uniform vertical stretch of the scene, the shape the pixel that is not square drew for a camera with tall pixels, and for a reader of the picture it is the same thing: a circle drawn as an ellipse 3% taller than it is wide, a square drawn as an oblong.

The crop’s own rounding behaves differently, and the difference answers the second half of the earlier question. When the crop lands on the panel, each edge is rounded to a whole panel pixel, and a crop moves the frame and not the camera found that this moves the picture’s principal point by under half a panel pixel. Every resize after that is a true map, and true maps compose into one: s2(s1(c+12)−12+12)−12=s1s2(c+12)−12s_2(s_1(c + \tfrac12) - \tfrac12 + \tfrac12) - \tfrac12 = s_1 s_2 (c + \tfrac12) - \tfrac12. So the crop’s half pixel reaches the final picture at the product of the scales, which is the final width over the panel width, 690/316, whatever the chain did in between. An enlargement to 1,280 px in the middle of the chain does not bring it back at 1,280’s scale; it is undone by the reduction that follows, exactly. What an intermediate picture cannot undo is its own rounding, because that rounding is a change to the picture’s shape and not a change to its scale.

What can be read off the end of the chain

The single-resize essay found that a thumbnail’s squeeze is invisible: a recovery reading the pixel’s shape from a box and a square, the reading that a square closes the line of cameras built on the family of cameras a box leaves a line of cameras found, is always coarser than one rounding. A chain changes one of the two quantities. Its squeeze can be several percent at the end, in a final picture 690 px wide, where a box and a square are read to 0.24% if their lines are found to a tenth of a pixel. On those numbers the squeeze would stand out at ten times the reading’s spread.

A chain's squeeze is read no better than its smallest picture allows, and that is never fine enough to see itThe largest squeeze one rounding can leave in a picture of a given width, 1/(2h) (solid), against the spread with which a box and a square read the squeeze from lines found to 0.5 px (dashed) and 0.1 px (dotted) of that picture's own pixels. An enlargement adds no detail, so a chain is read at best as finely as its smallest picture. At 64 px the bound is 1.26% and the readings' spreads 46% and 4.7%; at 690 px, 0.117%, 1.4% and 0.24%. The finer reading is never less than 2.0 times the bound.641002004006900.1%0.3%1%3%10%30%width of the smallest picture in the chain (px)squeeze (%)one roundingread to 0.5 pxread to 0.1 pxbox and square, 400 reads eachfiner reading ≥ 2.0× the bound
Fig. 4 The largest squeeze one rounding can leave in a picture of a given width, against the spread with which a box and a square read the squeeze from lines found to half a pixel and to a tenth of a pixel of that picture’s own pixels.

But the final picture of a chain through a 25 px icon has been enlarged from 25 px, and an enlargement adds no detail. The lines of a box in it are as sharp as they were in the icon and no sharper: a line found to a tenth of an icon pixel is found to 2.8 final pixels. So the reading’s precision belongs to the smallest picture in the chain, just as the squeeze’s size does. The figure compares the two at the same width. At 64 px the largest squeeze is 1.26% and the box and square read it with a spread of 46% from half-pixel lines and 4.7% from tenth-pixel ones. At 690 px, 0.117% against 1.4% and 0.24%. The finer reading is never less than 2.0 times the squeeze it would need to see, at any width tried, and the smallest picture sets both.

That is the second way a chain remembers its smallest picture, and the two memories cancel for a reader. The squeeze a chain leaves is large in the final picture’s terms and small in the smallest picture’s, and the smallest picture’s terms are the ones in which it can be read. A recovery told that a chained picture’s pixels are square is wrong by the chain’s squeeze, which can be several percent, and still cannot find that out from the picture.

Roundings add as a root, floors in a straight line

A chain that passes through a tiny picture is an extreme case. A chain whose every picture is of a reasonable size still adds its roundings, and how fast it does so depends on whether they can cancel.

Each resize adds its rounding in quadrature, so a chain's squeeze grows as the root of its length, unless every tool reads the sourceChains of one to six resizes, each to a width drawn evenly from 160 to 960 px, 3,000 chains at each length. Each tool rounding the height from its input (solid): a root-mean-square squeeze of 0.120% for one resize, 0.209% for three and 0.289% for six, against the sum of every step's rounding variance, √Σ 1/(12hᵢ²) (dotted), 0.292% at six. Every tool rounding from the source's aspect (dashed): 0.120% for one and 0.118% for six, the last rounding alone.00.1000.2000.300123456resizes in the chainroot-mean-square squeeze (%)from each inputfrom the source√Σ 1/(12h²)widths drawn from 160 to 960 px3,000 chains at each length
Fig. 5 Chains of one to six resizes, each to a width drawn evenly from 160 to 960 px, 3,000 chains at each length: the root-mean-square squeeze when each tool keeps its input’s aspect, against the sum of every step’s rounding variance, and when every tool keeps the source’s aspect.

A rounding error of a whole height is spread evenly between plus and minus half a pixel, so its variance relative to the height is 1/(12h2)1/(12h^2), and independent roundings add their variances. Over 3,000 chains at each length, the root-mean-square squeeze is 0.120% after one resize, 0.209% after three and 0.289% after six, against the predicted ∑1/(12hi2)\sqrt{\sum 1/(12h_i^2)} of 0.292% at six. The roundings are independent to the precision the measurement keeps, and the chain’s squeeze grows as the square root of the number of tools, a random walk whose steps are each tool’s rounding. Six reasonable tools leave a typical squeeze two and a half times one tool’s.

Every tool reading the source’s aspect instead leaves 0.120% after one resize and 0.118% after six. The last rounding alone survives, as it did on the display, and the length of the chain does not matter at all.

A chain of tools that floor the height loses a step's rounding at every step, and the loss adds in a straight lineThe same chains, each height floored (integer division) instead of rounded. Floored, the mean squeeze is −0.176% after one resize, −0.541% after three and −1.078% after six, half a pixel of each step's height lost at every step on average, with a spread of 0.381% about it. Rounded, the mean is −0.006% after six and the spread 0.289%. A floored chain's pixels are always short, and its error adds in a straight line where a rounded chain's adds as a root.-1.50-1-0.5000123456resizes in the chainmean squeeze, ± one spread (%)height flooredheight roundeddotted: one spread either sidefloored pixels are always short
Fig. 6 The same chains with each height floored by integer division instead of rounded: the mean squeeze and one spread either side, against the rounded chains’.

A tool that floors the height, which is what integer division does and what a surprising amount of image code does by default, never rounds up. Its error is between zero and one whole pixel short, half a pixel on average, so every step loses half a pixel of its own height on average and the losses cannot cancel. Floored, the mean squeeze is −0.176% after one resize, −0.541% after three and −1.078% after six, falling in a straight line, with a spread of 0.381% about it at six. Rounded, the mean after six is −0.006% and the spread 0.289%. After six floored tools the typical picture is a percent short, every pixel wider than tall, and the spread about that bias is smaller than the bias itself.

That is the case where pooling, which the single-resize essay offered as the one route by which a squeeze could show itself, actually would. A collection of pictures that went through the same flooring chain carries a common bias, and the bias does not average away however many are read. A rounding chain’s squeeze does average away, since it is as often one way as the other.

Chains the way the web makes them

The chains above draw their widths evenly. A real chain has a shape: a crop is placed as a figure several hundred pixels wide, a page scales it by the device’s ratio, and a card or a preview is cut at a smaller width. Each step is chosen by somebody who does not know about the others.

Chains made the way the web makes them mostly stay inside the last step's rounding, and one in seven does not4,000 chains of three tools that know nothing of each other: the crop resized to a figure 360 to 1,200 px wide, scaled by a device ratio of 1, 1.25, 1.5, 2 or 3, then made into a card 120 to 600 px wide, each height rounded from its input. The final squeeze over the last step's bound, 1/(2h) of the card: 14.3% of chains exceed it, by up to 2.71 times. Most stay inside because the card is the smallest picture in its chain, so its own rounding is the largest term, and the earlier steps add small ones.0200400600800012final squeeze ÷ the last step's one roundingchainsthe last step's roundingfigure → device ratio → card14.3% past the last rounding
Fig. 7 4,000 chains of three tools that know nothing of each other, a figure 360 to 1,200 px wide, a device ratio of 1, 1.25, 1.5, 2 or 3, and a card 120 to 600 px wide: the final squeeze as a multiple of the last step’s own rounding.

In this shape most chains stay inside the last step’s bound: 85.7% of the 4,000 do, and 14.3% exceed it, by up to 2.71 times. The reason is that the last picture is usually the smallest. A card 120 to 600 px wide is smaller than the figure it was cut from, so its own rounding is the chain’s largest term, and the figure’s adds a fraction of it. The chains that exceed it are the ones whose card is large and whose figure is small, or whose roundings happened to fall the same way.

The device ratio is the step nobody thinks about, and for integer ratios it does nothing at all: a picture 117 by 73 scaled by 2 is 234 by 146 exactly, with no height to round, and the measurement confirms that a ratio of 2 or 3 leaves every chain’s squeeze unchanged to the last digit. A ratio of 1.25 or 1.5 does round, when the height is not a multiple of four or two, but at the device’s size the height is large and the rounding small. The step to worry about is the one that makes the smallest picture, and on the web that is usually a thumbnail somebody asked for on purpose.

So the earlier essay’s single-resize bound is a fair working rule for most published pictures, and it fails in two recognisable cases: a chain that ends larger than one of its middle pictures, and a chain of tools that floor. Both are cases where the smallest picture was not the last.

Where the arithmetic came from

Every tool uses the true map, sending a pixel’s centre to a pixel’s centre, as halving a picture moves its centre found a tool must if it is not to shift the picture’s middle. A tool that multiplies coordinates instead adds its own shift at every step, and those shifts add as well; they move the principal point, which is a separate error from the squeeze measured here and is the one a careful reader of a tile is an off-centre frustum would expect a chain to accumulate too.

Heights are rounded or floored exactly, in whole-number arithmetic, so a height that falls on exactly half a pixel rounds up whatever a floating-point division would have made of it. A tool that rounds half to even differs only on those ties.

Each tool is given a width. A tool given a height instead rounds the width, and the same analysis applies with the roles of the two focal lengths exchanged; a chain that mixes the two kinds can have its roundings fall on both axes, and its squeeze is then the difference of two sums.

The reading compared is a box and a square, the recovery the earlier essays used. A calibration target read with many points reads the squeeze more finely, but it reads it in the picture’s information, and an enlarged picture holds the information of the smallest picture it came from.

Nothing here models the resampling filter. A real resize blurs as well as rounding, and a chain of resizes blurs repeatedly. The blur moves no edge’s centre, so it does not change the geometry measured here; it does make every line harder to find, which only strengthens the conclusion that the squeeze cannot be read.

Still open: whether a crop between two resizes walks the centre the way a rounding walks the shape

Every chain here resizes a whole picture. Real pipelines also crop in the middle: a figure is resized, a square card is cut from its centre, and the card is resized again. A crop is the step a crop moves the frame and not the camera measured, and it rounds the crop’s edges in the pixels of whichever picture it is taken from, which moves the principal point by up to half of that picture’s pixel. A resize carries the move at its scale, and the next crop adds its own.

The measurement that settles it interleaves crops and resizes, each crop centred on its picture and rounding its own corner, and asks whether the principal point’s error adds in the same way as the squeeze — as a sum, dominated by the crop taken from the smallest picture — or whether a centred crop’s rounding, which falls on both sides of the middle, cancels where a resize’s does not; and whether a chain that only ever takes centred crops from even-sized pictures, which a careful tool could guarantee, keeps the principal point exactly where the renderer put it.

A chain of resizes keeps every tool’s rounding, because each tool keeps the aspect of the picture it was handed and that aspect already carries the earlier roundings. The final squeeze is bounded by the sum of the steps’ roundings and fills it, so the smallest picture dominates, and an enlargement after a thumbnail brings the thumbnail’s half pixel back at the final scale. The crop’s own half pixel comes back only at the final scale, since true maps compose. Rounded steps add as a root of their number, floored steps in a straight line, and a tool that reads the source’s own aspect rounds once. The squeeze is read no better than the smallest picture allows, which is never fine enough to see it.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Aspect ratioBiasFocal lengthIdentifiabilityQuantisationrandom walk