Skip to main content
Participant
February 28, 2010
Question

Disable (or detect) automatic orientation rotation

  • February 28, 2010
  • 1 reply
  • 4243 views

When I open a JPEG image in Photoshop (CS3, Mac), Photoshop automatically rotates it based on the camera orientation sensor data, if available. Very nice. However, this is causing a headache for me in a set of Javascript scripts I'm working on.

Very briefly, I have one script in InDesign that exports a list of all of the images used in the document, their sizes and the size and location of their containing box (i.e. the crop area). I have a second script in Photoshop that reads this list and crops and resizes the images to exact size. This works great except when the Photoshop helpfully rotates an image's orientation for me. Because InDesign doesn't also rotate the image automatically, the two disagree on the image's orientation ("0 rotation" to InDesign is landscape, while Photoshop opens it in portrait). Then all the sizes and coordinates are wrong, obviously.

Is there a way to prevent Photoshop from doing that automatic rotation, or at least to detect that it has happened (including the direction of rotation) from within my script? If I can tell that it has happened, at least I can adjust my coordinates accordingly. But disabling it competely (ideally from within the script, so it would continue to work for normal interactive use) would be a lot nicer.

Thanks!

This topic has been closed for replies.

1 reply

sch980Author
Participant
February 28, 2010

Never fails, I figure out a workaround minutes after posting...

I realized I can grab the EXIF data and figure out the rotation from that. Would still be nicer to just avoid it altogether, but this will work for now...

Participant
February 28, 2010

I'm struggling with the same problem. Reading the exif information and "correcting" the rotation would be an idea, but which Rotation-Flag do you use. If I look at the metadata in Exiftool I see a lot of different one (if the image went through a lot of apps) and all are not synchronized.

Do you know which one Photoshop reads? Could you share your solution?

Regards,

Markus

sch980Author
Participant
February 28, 2010

I don't know for sure which one Photoshop reads, and I haven't tested my solution with a wide variety of files yet, so I'm not sure how solid it is. I'm using the "Orientation" tag, and so far it seems to work.

One thing I haven't figured out (and I think I must be missing something obvious) is a way to directly access exif data by key. It seems like doc.info.exif is just a big array of arrays, and I have to iterate through them doing a string match to find the one I'm looking for. Surely that can't be the only way to get at it?