Mobile app version of vmapp.org
Login or Join
Cody3331749

: Why does photoshop auto-rotate images when opening? I am using scripting in Photoshop to process jpg files that are uploaded through a website. I occasionally get images that are rotated differently

@Cody3331749

Posted in: #AdobePhotoshop #Jpg #PhotoshopScripting

I am using scripting in Photoshop to process jpg files that are uploaded through a website. I occasionally get images that are rotated differently when you open them in Photoshop vs. Windows Previewer (or any other basic graphics program). And today I just came across one that was rotated 90 degrees and mirrored horizontally when you open it with Photoshop. This throws off the scripting b/c the image is not the expected size and orientation.

Is there a setting in Photoshop preferences to stop it from automatically rotating and mirroring these images? Or a way to strip this extra data that Photoshop is reading?

I am using Photoshop CS4 and in preferences, under Camera Raw Settings, I have it set to "disable JPEG support".

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Cody3331749

3 Comments

Sorted by latest first Latest Oldest Best

 

@Kevin459

I was able to fix the auto-rotation due to the exif data with this script. (thanks to this adobe forum post) I'm sure there are more cases that need to be fixed, but this solves the ones I have run into...

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[i][0];
if (name == tag) {
return exif[i][1];
}
}

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

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

return '';
};

var exif = new EXIF(docRef);
var orientation = exif.get('Orientation');
if(orientation.substring(0,7) == 'Rotate '){
// compensate for auto-orientation
var rotate = parseFloat(orientation.substring(7,orientation.length));
if(! isNaN(rotate))
docRef.rotateCanvas(rotate*-1);
}

if(orientation == "Flip Horizontal")
docRef.flipCanvas(Direction.HORIZONTAL);

10% popularity Vote Up Vote Down


 

@Barnes313

Photoshop Supports the EXIF Orientation Value and the Windows Photo Viewer does not!

You can ignore the EXIF Profile Tag in Photoshop Preferences - File Handling

More info:


Beware of Rotating Photos in Windows Picture / Photo Viewer!
Another surprising detail is that if you decide to perform lossless image rotation (by using the Rotate Clockwise or Rotate CounterClockwise buttons), the EXIF Orientation flag is removed! As the flag is removed/reset, if you do a rotation followed by its reverse rotation on a portrait photo (eg. rotate clockwise, then rotate counter-clockwise), the resulting orientation observed by other viewers such as Photoshop will be wrong!

www.impulseadventure.com/photo/exif-orientation.html

10% popularity Vote Up Vote Down


 

@Murray976

Unfortunately the easiest path is not available to you in CS4... that of a conditional that tests for aspect ratio and rotates in response to the wrong, before continuing.
You can see that here: helpx.adobe.com/photoshop/using/conditional-actions-creative-cloud.html
The only other alternative I can think of, that's easy and quick, is to use a naive image processor to open all images without seeing the rotation data, that then exports them without it. Setting this app up to batch process all files will give you the result you need with minimal effort.

If Windows Previewer is giving you the right result, then I'd suggest using that to do the batch processing. There's a multitude of scripting tools and macro makers for Windows as a whole that can help you configure an automated process. Including good old fashioned batch files that's now morphed into cmd.exe files.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme