Hacker News new | ask | show | jobs
by nithinbekal 4905 days ago
I ran into the exact same problem a few days ago. Luckily, ImageMagick, which I'm using for processing uploaded images, has an auto-orient [1] option that allows you to do this automatically.

Unfortunately, with JPEG this would cause some loss of quality, so we're probably going to have to keep the original quality image as well as the auto-orient'ed image to display on the site. Has anyone here worked on something similar? Any ideas on a better way to handle this would be extremely helpful.

[1] http://www.imagemagick.org/script/command-line-options.php#a...

1 comments

Because of math, the JPEG format does support lossless rotation, as long as the dimensions of the image are multiples of 16 pixels (or 8 depending on the file). But this requires working directly with the JPEG image data, so a package like ImageMagick that reads a formatted file into a pixel buffer, then transforms it and writes it from that buffer to a new formatted file can't support the feature.