Image Rotation Chaos – My Ultimate Fix

I’m sure you’ve been at this point before: There’s an image shown in a wrong orientation on your screen because the camera’s orientation sensor got it wrong, or your computer got it wrong, or something in between got it wrong, and you had trouble rotating it into the right orientation. If it’s a single image you can try until you succeed with various programs just to find out that the next image viewer again shows it in the wrong orientation. It might be a nuisance for a few images but when you deal with hundreds of images at a time that should all be in portrait orientation with many of them marked as landscape, it becomes more than just a frustrating exercise to manually re-orient the images. At some point I became so frustrated that I spent some time to find the ultimate fix for this.

And the ultimate fix is to completely purge the EXIF information contained in the images and then rotate them into the desired orientation. Only purging the EXIF information from the file and leaving other information intact didn’t always help. I’m not sure why but at some point I stopped caring. Throw in a third command to automatically downsize the images and you’ve got a set of three great commands to pre-process images. The following three commands go through all jpg files in the current directory and apply their magic:

# Remove Exif Info
exiftool -all= -overwrite_original *.jpg

# Resize - optional...
## for file in *.jpg; do convert $file -resize 50% $file; echo $file; done

# Rotate 90 deg. right
for file in *.jpg; do convert $file -rotate 90 $file; echo $file; done