A product photo arrives lying on its side. You turn it 90 degrees, save it, and nothing about that operation feels risky. There is no crop, no resize, no quality slider in sight. A rotation is just a rotation.
I put that assumption to the test on 16 real product photos, with sha256 hashes pinned so the corpus cannot drift between runs. I compared five ways of making the same clockwise turn, and then compared each one against the decoded pixels that turn was supposed to produce. The result is not that one tool has a bug. It is that four of them re-encode the image on the way past, and the re-encoding is invisible at the size you preview at.
The number that made me keep going: in Pillow, turn 90 degrees and then turn back, and 83.19% of the pixels no longer match the original file. The average difference is only 2.153 levels out of 255, which is why nobody files a bug report.
That combination — almost every pixel touched, almost no visible change — is what makes this worth measuring carefully. A screenshot will not show it. A file-size check will point at the wrong cause. Only a decoded-pixel comparison against a known reference tells you what happened.
The control: a rotation you can undo
Before measuring damage, I needed a rotation that provably does none. That is jpegtran, which transforms JPEG DCT coefficients directly instead of decoding to pixels and encoding again.
jpegtran -copy all -rotate 90 -outfile turned.jpg original.jpg jpegtran -copy all -rotate 270 -outfile back.jpg turned.jpg If this really is a coefficient-level transform, the second command must restore the exact same decoded pixels. I ran that round trip at three chroma sampling factors, starting each time from a freshly encoded base file so the only variable was the transform:
| Sampling | Pixels changed on one turn | Mean levels | Pixels changed after round trip |
|---|---|---|---|
| 4:4:4 | 30,866 of 589,824 | 0.0446 | 0 |
| 4:2:2 | 32,361 of 589,824 | 0.0463 | 0 |
| 4:2:0 | 67,685 of 589,824 | 0.0939 | 0 |
Zero is the control, not the discovery. Every comparison below is measured against that baseline: if jpegtran had shown even one differing pixel after the round trip, the test harness would be wrong and the rest of the numbers would be meaningless.
The harness was wrong on the first attempt, which is worth recording because the mistake produces a very confident-looking number. I called the same clockwise-turn function twice for the return leg. That is a 180 degree turn, not a round trip, and comparing it with the original gave a mean error near 59 levels — a spectacular result that meant nothing. The return leg has to be the opposite turn: -rotate 270 for jpegtran, ROTATE_90 for Pillow, --rotate 270 for sips. A round trip that does not return to the starting orientation is not a round trip.
Note the first column, though. Even the lossless path does not give you a decoded copy of the rotated image on the first turn. That is a separate point and I will come back to it.
Four tools, one turn
Here is what the five paths actually do. The reference is the original decoded RGB array rotated in memory with np.rot90(k=-1) — the exact pixel arrangement a 90 degree turn means. Every tool produced a JPEG, which was then decoded back to RGB before comparison. Averaged over all 16 photos:
| Path | Mean levels changed | Pixels moved | Worst single pixel |
|---|---|---|---|
jpegtran -rotate 90 | 0.062 | 7.98% | 3 |
Chrome canvas, toDataURL('image/jpeg', 0.95) | 0.946 | 70.64% | 12.875 |
transpose(ROTATE_270), quality 95 | 1.039 | 74.22% | 14.1 |
sips --rotate 90 | 1.234 | 76.81% | 16.8 |
transpose(ROTATE_270), default save | 2.040 | 83.14% | 39.8 |
The Pillow path that most people write is the last one:
from PIL import Image im = Image.open("original.jpg") im.transpose(Image.Transpose.ROTATE_270).save("turned.jpg") transpose() itself never touches pixel values — it is a view operation, and on an uncompressed image it would be exact. The loss happens in save(). An 8-bit JPEG cannot store the array as-is, so the encoder quantises DCT coefficients again. The picture survives; the file does not.
At quality 95, the same code drops to 1.039 levels and 74.22% of pixels, so quality matters. But notice that even the best re-encode here is more than fifteen times the jpegtran reading, and Chrome at quality 0.95 still moves 70.64% of pixels. None of these is a broken implementation. They are all doing what their APIs say: decode, transform, encode.
Chrome's export quality is a second variable on the same path. Dropping the canvas encoder from 0.95 to 0.90 moves the mean from 0.946 to 1.188 levels and the changed-pixel share from 70.64% to 73.91%. This is the ordinary re-encode tradeoff, not a rotation effect — but it sits directly on top of the rotation, and neither shows up in the canvas API.
The first turn does the damage
The obvious next question is whether turning repeatedly makes it worse. It does, but barely — and the shape of that curve is more useful than the endpoint.
| Pillow, default save | Mean levels changed | Pixels moved |
|---|---|---|
| One turn | 2.040 | 83.14% |
| Turn, then turn back | 2.153 | 83.19% |
| Four turns, back to the original orientation | 2.161 | 83.20% |
Two turns cost roughly 5.5% more than one, not twice as much. Four turns cost 0.4% more than two. Repeated JPEG encoding converges: the second pass quantises coefficients that were already quantised on the first, so it has much less left to change. That is the same mechanism that makes a re-save settle after a few passes, and it means the file you get after one rotation is already the damaged one.
The worst case in the corpus is worth stating plainly. Averages over 16 photos make this look gentle; individual files do not always oblige.
| Worst photo, turn and back | Mean levels | Max pixel | Pixels moved | PSNR |
|---|---|---|---|---|
| Pillow, default save | 3.620 | 47 | 97.56% | 34.09 dB |
sips --rotate 90 | 2.008 | 24 | 93.85% | 39.51 dB |
transpose, quality 95 | 1.771 | 21 | 91.70% | 40.59 dB |
Raising quality helps, but it cannot reverse anything:
| Save quality | Mean levels, one turn | Pixels moved |
|---|---|---|
| 60 | 3.988 | 98.59% |
| 75 | 3.413 | 97.43% |
| 85 | 2.788 | 96.14% |
| 95 | 1.579 | 90.44% |
| 100 | 0.379 | 42.27% |
Even at quality 100, with the quality slider all the way over, 42.27% of pixels still differ from the rotated original. There is no setting on this path that gives the pixels back, because the information was discarded when the first file was encoded and again when the second one was.
Reversible is not the same as pixel-identical
This is the distinction that makes the jpegtran result easy to misread. Its round trip changes zero decoded pixels, so the transform is genuinely reversible. Its single turn is not a decoded copy of the image rotated in memory: 30,866 pixels shift by up to 3 levels in the 4:4:4 case.
Two effects sit on top of each other. First, an inverse DCT is not rotation-invariant under integer rounding: the same coefficients decoded in a transposed block can round one level differently. That accounts for the 4:4:4 reading, where there is no chroma subsampling at all. Second, 4:2:0 stores one chroma sample per 2×2 pixel block, so a 90 degree turn also moves the chroma phase. That roughly doubles the affected pixel count to 67,685 and the mean from 0.0446 to 0.0939.
Neither effect accumulates. Rotate back and the coefficient grid returns to exactly where it started, which is why the round-trip column is zero for all three sampling factors. If you need the file to survive a chain of edits, reversibility is the property worth paying attention to, not per-step pixel identity.
A comment on my previous piece made a related point about kernel choice: some errors only appear when there is contrast, others only when there is structure. This one needs neither. It shows up on a flat field, because a 90 degree turn on a JPEG is not a move of pixels at all in four of these five implementations.
What else the re-encode takes
The pixel error is small enough to ignore in most catalogues. The metadata loss is not small, and it is easier to check.
| After one clockwise turn | jpegtran | Pillow default save |
|---|---|---|
| ICC profile | 456 bytes kept | 0 bytes |
| File size | +2.19% | −74.95% |
| Pixels changed, turn and back | 0.00% | 83.19% |
The size drop is not a property of rotation. Pillow's default save() writes quality 75 regardless of the quality of the incoming file, so a 355,373 byte source becomes 102,778 bytes. That is a quality reset with a rotation attached. jpegtran grows the file by 2.19% on average instead, because transposing DCT blocks changes how well entropy coding packs them — the coefficients are the same, the bytes are not.
The ICC result is unambiguous: -copy all carries the 456-byte profile through, while a plain save() writes no profile at all. If colour management downstream depends on that profile, a rotation can quietly change how the product is rendered without changing a single visible pixel in the preview.
A few practical rules fall out of this:
- For a pure 90 degree turn on a JPEG, use a coefficient-domain transform such as
jpegtranor libjpeg-turbo's equivalent, and pass the flag that copies markers. - If you must go through pixels, set quality explicitly and pass the ICC profile back in. Do not rely on the default.
- Treat "turn and turn back" as two encodes, not a no-op. If an editor asks you to save after every orientation tweak, you are paying that cost per tweak.
- If the source carries an orientation tag, establish first whether the tool honours it on open. "Turn 90 degrees" means two different things depending on whether the file was already rotated in memory.
- Verify with a round trip rather than a screenshot. Decode, turn, turn back, decode, compare. Zero changed pixels is a claim you can actually test.
This is the same shape as the coverage question in the alpha and blur piece: two paths through the same library, both returning plausible files, one silently carrying information the other drops. The tool that looks simplest is not necessarily the one that preserves the most.
If you are preparing images for several marketplaces and want to check the result after a rotation rather than reason about it, the marketplace resize checker is one place to do that.





