Hacker News new | ask | show | jobs
by justincormack 215 days ago
JPEG allows for lossless 90 degree rotation, not sure about other formats
2 comments

Pretty sure that any software from after ~2005 that supports image rotation, isn’t doing so at decoding time, but rather is decoding the image into a GPU texture buffer and then rotating the quad that texture gets applied to. Which should always be lossless for multiple-of-90-degree rotations. (Presuming that the image doesn’t depend on sub-pixel rendering tricks.)
Even without a GPU, the JPEG format itself allows for totally lossless rotation. It is also quite fast, and doesn't require reading and writing every pixel in the image.
Isn't this only true for images where the resolution is divisible by the block size or something like that?

IIRC in other cases you have to cut the edge of the image off (rounded to the nearest block) or recompress those edge blocks

Is that still true if the image dimensions aren't a multiple of the block size?