Auto-rotate rotated images with mogrify

Posted by Frank Presencia Fandos on Super User See other posts from Super User or by Frank Presencia Fandos
Published on 2012-10-22T10:33:02Z Indexed on 2012/10/22 11:05 UTC
Read the original article Hit count: 287

Some of my images have been taken rotated but kept this data. The problem is that, when using mogrify to convert them from JPG to png, that data seems to dissapear. For showing this problem, I think the best is to show the script and an screenshot.

Script with the code. Put it in a text file, give it execution permission, double click, run (from terminal if you wish) and wait a while. All the JPGs in that folder will be converted to png.

#! /bin/bash
echo "Converting JPG to png. Please don't close this window."
mogrify -alpha on -format png *.JPG
mogrify -alpha on -format -alpha on png *.jpg

It works great and adds an alpha channel. This is personally useful when I edit them later, not to add the channel individually.

Now the screenshot that illustrates the problem:

Showing the rotating problem

As you can see, the original ones' (JPGs) preview is right, the modified preview is wrong, the Shotwell rendering is right and the GIMP edit is wrong and didn't even say the image was rotated, as it uses to do with other images.

How can I edit my script to preserve the orientation?

© Super User or respective owner

Related posts about linux

Related posts about conversion