Exif tag shows always e.g.:
exiftool -H -G:0:1 -Orientation IMG_6071.JPG
[EXIF:IFD0] 0x0112 Orientation : Horizontal (normal)
even when camera was rotated.Then all default programs for pictures presentation are unable to recognize proper orientation (picture is rotated).
The reason is additional tag (Canon specific) e.g.:
exiftool -H -G:0:1 -*Orientation IMG_6071.JPG
[EXIF:IFD0] 0x0112 Orientation : Horizontal (normal)
[MakerNotes:Canon] 0x0030 Camera Orientation : Rotate 270 CW
and in numerical form:
exiftool -H -G:0:1 -*Orientation# IMG_6071.JPG
[EXIF:IFD0] 0x0112 Orientation : 1
[MakerNotes:Canon] 0x0030 Camera Orientation : 2
Therefore what is needed is mapping to move orientation from camera to EXIF Orientation tag.
For example when "Camera Orientation" is 2 (Rotate 270CW) then "Orientation" should be 8 (also Rotate 270CW):
exiftool -Orientation#=8 IMG_6071.JPG
After changing "Orientation" it is necessary to reset "Camera Orientation" to 0 (Horizontal (normal)).
exiftool -CameraOrientation#=0 IMG_6071.JPG
Allowed values for Canon's "Camera Orientation":
- 0 - Horizontal (normal)
- 1 - Rotate 90 CW
- 2 - Rotate 270 CW
seems there is no more values defined for "Camera Orientation".
Unfortunately I was unable to find specification for Canon's specific tags.
These should be mapped onto standard EXIF "Orientation":
- 1 - Horizontal (normal)
- 6 - Rotate 90 CW
- 8 - Rotate 270 CW
Here is simple bash script (sure it can be sorter) which moves rotation form Camera to EXIF tag. It changes file only when original EXIF Orienation is normal and "Camera Orientation" is 90 or 270 (of course image data are not changed, only metadata).
#!/bin/bash
orientation=$(exiftool -p '${Orientation#} ${CameraOrientation#}' "$1")
orient_array=($orientation)
if [ ${orient_array[0]} -eq 1 ] ; then
if [ ${orient_array[1]} -eq 1 ] ; then
echo "$1 - Camera Orientation - Rotate 90 CW - will be moved to EXIF Orientation";
# also reset Camera Orientation
exiftool -Orientation#=6 -CameraOrientation#=0 -overwrite_original $1
elif [ ${orient_array[1]} -eq 2 ] ; then
echo "$1 - Camera Orientation - Rotate 270 CW - will be moved to EXIF Orientation";
# also reset Camera Orientation
exiftool -Orientation#=8 -CameraOrientation#=0 -overwrite_original $1
fi
fi
convert -auto-orient -strip -resize x1080 file.jpg file_resized.jpg