Are rotations in Windows Photo Viewer lossless for JPEG files?
Asked 5/24/2011
6 views
2 answers
0
If I rotate a JPEG in Windows Photo Viewer, will it avoid adding more compression loss, or does it recompress the image? Does this depend on the image dimensions?
Originally by user5306. Source · Licensed CC BY-SA 4.0
user5306
15y ago
2 Answers
67
If the dimensions of the image are multiples of 8 (or 16 if chroma subsampling is used) then the rotations are lossless. Otherwise it is not possible to rotate the image without recomputing the blocks i.e. recompressing the image, which is lossy.
The reason for this is that jpeg images are broken up into a series of 8x8 or 16x16 blocks which are compressed individually. Incomplete blocks are only allowed on the right edge and bottom edge. Thus is your image is not an exact multiple of 8/16 it will contain incomplete blocks, which will end up on the wrong edge after rotation.
I verified the above assertion using the version of Windows Photo Viewer that ships with Windows 7. I used two images of colour noise. One image was 256x256 i.e. both sizes multiples of 8. The other image was the same but cropped to 253x253 i.e. neither size was a multiple of 8. Here are the images:
I then performed four anti-clockwise rotations, closing photo viewer after each rotation to ensure the image was saved in it's rotated state.
There's no need to perform a subtraction to see the difference with the 253 pixel image, it's noticeably darker and muddier!
A diff on the other image looks like this:
i.e. the images are identical, the rotations were lossless.
Originally by user1375. Source · Licensed CC BY-SA 4.0
user1375
15y ago
0
Generated from our catalog & community — verify before relying on it.
JPEG rotation can be lossless, but only under certain conditions. JPEGs are stored in compressed blocks, typically 8×8 pixels, or effectively 16×16 in some chroma-subsampled files. A lossless rotation is only possible when the image dimensions are exact multiples of those block sizes.
If the width and height line up with the JPEG block grid, Windows Photo Viewer can rotate the image without recompressing it. If not, the image has partial blocks at the right or bottom edge, and after rotation those blocks would end up in invalid positions, so the file must be recompressed and some quality can be lost.
So the practical answer is: rotating in Windows Photo Viewer is lossless for some JPEGs, but not all. It depends on the JPEG’s dimensions and block structure.
Recommended products
UniqueBot
AI15y ago
Your Answer
Related Questions
Why can a lossless JPEG rotation change the file size?
Does rotating a JPEG reduce image quality?
Why do JPEGs get smaller after rating or rotating them in Windows Photo Viewer, and why won't my camera display them properly?
Does resizing and resaving a JPEG add noise or just compression artifacts?
Can JPEG 2000 images be rotated losslessly, and what tool can do it?




