• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Disable (or detect) automatic orientation rotation

New Here ,
Feb 27, 2010 Feb 27, 2010

Copy link to clipboard

Copied

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!

TOPICS
Actions and scripting

Views

3.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
Feb 27, 2010 Feb 27, 2010

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

Although it's overkill, you can go the XMP route in PSCS4.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

Unfortunately, I'm still on CS3 (I usually only upgrade every other version unless there's something I really need from the new one, so I'll go to CS5 when it comes out).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 28, 2010 Feb 28, 2010

Copy link to clipboard

Copied

This is code that I've used in the past.

EXIF = function EXIF(obj) {
  if (obj.typename == "Document") {
    this.exif = obj.info.exif;
  } else {
    this.exif = obj;
  }
  this.caseSensitive = false; // if needed
};
EXIF.prototype.get = function(tag) {
  var exif = this.exif;

  for (var i = 0; i < exif.length; i++) {
    var name = exif[0];
    if (name == tag) {
      return exif[1];
    }
  }

  if (!this.caseSensitive) {
    tag = tag.toLowerCase().replace(/\s/g, '');

    for (var i = 0; i < exif.length; i++) {
      var name = exif[0];
      name = name.toLowerCase().replace(/\s/g, '');
      if (name == tag) {
        return exif[1];
      }
    }
  }

  return '';
};

// Usage

var exif  = new EXIF(app.activeDocument);

var orientation = exif.get('Orientation');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2010 Mar 01, 2010

Copy link to clipboard

Copied

LATEST

Thanks a lot for sharing, but how do we get to know if Tiff::Orientation is the only tag photoshop uses? I think I'll make a little study and apply all the different tags I know to one image and look how Photoshop treats the different ones individually and in combination.

I need it for a workflow where lots of images from lots of apps (ps, lightroom, gimp, camera jpg) go through a preprocessing in ps before beeing printed out.

Regards,

markus

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines