Sometimes, software is irritating. I take photos with a digital camera from time to time and some are in landscape mode, other are in portrait mode. I import photos to my computer by mounting the camera, usually /dev/sdc1, and copying the files. Then I view them using gpicview. The photos in portrait mode are displayed in lanscape mode, so I rotate them 90° counter-clockwise. However, the rotation is not actually made, the program has only modified the EXIF Orientation tag. This leads to some programs displaying the portrait photos correctly and other incorrectly. Even worse, the version of Firefox I am currently using displays correctly a picture file in portrait mode, but the same picture, if embedded inside a html page is displayed in landscape mode. To get rid of this, I have to reset the EXIF Orientation tag first and then actually rotate the picture I want to see in portrait mode.
I use exiftool to reset the EXIF Orientation tag.
To see the value of the tag of all the pictures in the current folder:
exiftool -Orientation -S -n *.jpg
With my camera, Orientation tag value is 1 by default in landscape mode and, after having been rotated by gpicview, a portrait mode picture has an Orientation tag value of 8.
To force the Orientation tag value to 1 for every picture in the current folder:
exiftool -Orientation=1 -n *.jpg
After this, all pictures will be displayed in landscape mode, in every program.
To actually rotate a picture to portrait mode, I use ImageMagick.
The command is:
cp picture.jpg picture.jpg.orig convert picture.jpg.orig -rotate 90 picture.jpg
If the result is satisfactory, I remove te original: