logoalt Hacker News

ralferooyesterday at 10:30 AM4 repliesview on HN

One interesting thing about JPEG is that you can rotate an image with no quality loss. You don't need to convert each 8x8 square to pixels, rotate and convert back, instead you can transform them in the encoded form. So, rotating each 8x8 square is easy, and then rotating the image is just re-ordering the rotated squares.


Replies

DidYaWipeyesterday at 11:17 PM

Indeed. Whenever I'm using an image browser/manager application that supports rotating images, I wonder if it's doing JPEG rotation properly (as you describe) or just flipping the dumb flag.

pwdisswordfishzyesterday at 2:05 PM

That doesn't seem to apply to images that aren't multiples of 8 in size, does it?

show 2 replies
meindnochyesterday at 6:26 PM

Only if the image width/height is a multiple of 8. See: the manpage of jpegtran, especially the -p flag.

dylan604yesterday at 3:31 PM

Slight nitpicking, but you can rotate in 90° increments without loss.