Restore photo orientation
I needed to restore the orientation to a bunch of photos, and I couldn't find anything about this (admittedly, with a brief search). So here is recipe in case others need to do it.
Ingredients:
Lightroom Classic
Jeffrey's Data Explorer Plugin
John Ellis' AnyFilter Plugin (optional)
When you import photos into Lightroom, they are oriented according to metadata that the camera adds to the photo. One place this is recorded is the Orientation EXIF field. I am using Canon cameras, and some of my cameras, but not all, also record this data in the Camera Orientation field. (Confusingly, the Camera Orientation doesn't have a "Rotate 180" value.)
Values for the Orientation Field are:
1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW
The data explorer plugin can be used to restore a photo to "sensor orientation", but it can't be used to figure out the original camera orientation.
The first thing is to restore all of the photos to "sensor orientation." Use Data Explorer to break your photos up into collections depending on the "Orientation with Respect to Image Sensor", and then rotate the photos in each collection appropriately (if they are rotated 90° CW, apply a 90° CCW rotation, etc.)
The next thing to do is to find the original orientation. If all of your photos have the "Camera Orientation" metadata, it seems that you can use the Any Filter plugin to find them, which is quite straightforward. E.g., do a search for "Aggregate Text" "Searchable EXIF" "contains" "Rotate 90 CW". However, my photos from my old Canon 1Ds don't have the "Camera Orientation" metadata, and it seems that Any Filter can't search on the "Orientation" metadata (probably because the values of Orientation are integers, not strings).
So I used the following command in exiftool to set a subject keyword according to the original orientation:
% cd <the folder with all your photos in it>
% exiftool '-subject+<$orientation' -ext xmp -overwriteoriginalinplace .
This sets a keyword that is derived from the value of the orientation field for the sidecar files in the directory. (Replace "xmp" with "TIFF", "psd", etc to change those file types). Be careful, the "-overwriteoriginalinplace" flag will do exactly that -- make sure you have a backup before doing this command.
Now you just need to read the metadata in Lightroom, and sort by the keyword values and restore the camera's suggested orientation.
Hope this helps.
A
