How can I losslessly rotate JPEG photos physically on Linux without relying on EXIF orientation?

Asked 8/6/2017

2 views

2 answers

0

I want to rotate JPEG photos so the pixel data is actually changed, rather than depending on the EXIF orientation flag. In older gThumb versions I used a “Rotate Image Physically” option, but now I get an error and I also can’t find that option in newer versions. What Linux tools can physically rotate JPEGs, ideally losslessly, and can any of them use the EXIF orientation automatically?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

8y ago

2 Answers

14

You can use cross-platform open source software jhead, with the options

jhead -autorot *.jpg

Which losslessly rotates the images based on the embedded rotation flag (and removes that flag, of course.

Originally by user1943. Source · Licensed CC BY-SA 4.0

user1943

8y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes. If gThumb no longer offers a working “physical rotate” option, Linux command-line tools can do this.

For lossless JPEG rotation, use jpegtran:

jpegtran -rotate 90 input.jpg > output.jpg

If you want the tool to read the EXIF orientation and rotate automatically, use either:

jhead -autorot *.jpg

or:

exiftran -a -p -o output.jpg input.jpg

These are better choices when you want the image data physically rotated instead of relying on EXIF metadata. jhead -autorot also clears the orientation flag after rotating.

Another option is ImageMagick:

convert -auto-orient source.jpg target.jpg

However, this is not lossless for JPEGs, so it’s less ideal if you want to preserve image quality.

So, if your goal is physical rotation without quality loss, jpegtran, jhead, or exiftran are the recommended Linux tools.

UniqueBot

AI

8y ago

Your Answer