Page 1 of 1

Detecting Photo Image Orientation

Posted: September 27th, 2009, 12:50 pm
by lloydalvarez
Is there a way to detect the orientation of a photo? Recent cameras seem to be able to flag the orientation of a photo even though it is always recorded in landscape. In other words the image file is 1600x1200 but when you open it in preview it will auto rotate to 1200x1600. However when I import images into AE they alway come in at 1600x1200 and don't auto rotate, is there a way to detect the orientation? Even if it is through the command line?

Thanks

Re: Detecting Photo Image Orientation

Posted: September 28th, 2009, 2:09 pm
by nab
If the Orientation info is tagged in the photo file, you can retrieve its value using XMP metadata.

Code: Select all

. import AdobeXMPScript lib
. new XMPFile()				
. getXMP()				
. closeFile(0)
. xmpObj.iterator()
. while (next = it.next())
. orientation test
. retrieve tag value
example of orientation tag value
1:normal
6:rotate(90)

-> see the javascript tools guide for more info on xmpscript
-> http://www.exif.org/Exif2-2.PDF - page 18

Re: Detecting Photo Image Orientation

Posted: September 28th, 2009, 2:32 pm
by lloydalvarez
awesome, thanks nab.

Re: Detecting Photo Image Orientation

Posted: November 19th, 2009, 4:15 pm
by lloydalvarez
Hey Nab,

I am successfully reading and updating the orientation but I am not able to change the image width and height tags so that the image's orientation is changed by swapping height and width. Is it just not possible to do that through XMP?

-Lloyd

Re: Detecting Photo Image Orientation

Posted: November 21st, 2009, 5:05 am
by nab
I would say it's not possible but I'm no xmp expert at all.
You could apply the rotation in AE, or use command line tool to rotate the image (e.g. 'convert -rotate' from ImageMagick, look at the doc here)

Re: Detecting Photo Image Orientation

Posted: November 21st, 2009, 7:40 am
by lloydalvarez
Yes, I am coming to the same conclusion. I can't use image magick since the install is so geeky I can't expect users to want to do it so I might just do the rotation in AE or Bridge.

Thanks

Re: Detecting Photo Image Orientation

Posted: February 27th, 2014, 9:16 am
by lloydalvarez
This script will fix the orientation: http://aescripts.com/photoorientationfixer/