Copy link to clipboard
Copied
I have a large collection of images that are oriented in various rotations, normal (0°), CW (90°), CCW (-90°), and 180°. I want to sort the images by rotation so that I can unrotate them as a batch without going through each image, right-clicking "File Info > Camera Data", reading the Orientation value, and manually unrotating the image. The desired end result is for all the images to be unrotated to the same orientation. I've tried using "Find" in "metadata" but without success (searches for CW, CCW, 90°, 180°, etc., all produce null results). Can anyone advise how to sort the images by rotation (not just landscape vs portrait, which is an easy filter to apply) so I can unrotate them as a batch?
Copy link to clipboard
Copied
Perhaps you could create a Camera Raw preset which sets rotation to zero and leaves all else unchanged. Then open all of your images in Camera Raw and apply the preset. Sorting is then unnecessary.
Copy link to clipboard
Copied
Makes perfect sense--better than turning off auto-rotate in my iPhone and other cameras and much better than manually rotating the images (as I've already done). I've saved a couple of custom presets in Camera Raw previously (I don't use it that often), but I don't see where I can set the rotation to zero in the preset. Is it under Geometry>Upright Mode Off? I have Camera Raw 14.2. I've searched many pages of support articles but haven't found anything specific to Geometry>Upright Mode and the ACR help menu provides nada, which is frustrating. Many thanks for your help.
Copy link to clipboard
Copied
Set all relevant adjustments to zero in the Geometry Panel. Rotation should be under manual section. Save preset, tick just Geometry in save dialogue.
Test on a single image.
If it achieves the desired result then you can open almost a limitless number of images at the same time in Camera Raw, select them all then apply your preset to all.
Copy link to clipboard
Copied
There are multiple ways that an image can be rotated. First of all, the actual pixels can be rotated in which case you'd need Photoshop to edit them. There is also rotation metadata which can be present or applied.
This is a sample script to flip an image, look at the orientation setting to see how it works.
/*
Utility Pack Scripts created by David M. Converse ©2018-21
This script adds a flip vertical/horizontal palette
Last modifed 6/7/2021
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
//create menu
var flipCmd = MenuElement.create('command', 'Flip...', 'at the end of Tools'); //create new menu command
}
flipCmd.onSelect = function (){
flip();
}
function flip(){
var fPalette = new Window('palette', 'Flip', undefined, {closeButton:true});
fPalette.preferredSize = [200, 160];
fPalette.frameLocation = [100, 100];
var fpnl = fPalette.add('panel', [10,10,150,120]);
fpnl.fBtn = fpnl.add('button', [15, 25, 130, 45], 'Vertical');
fpnl.fBtn2 = fpnl.add('button', [15, 70, 130, 90], 'Horizontal');
var dir = "v"
fPalette.show();
fpnl.fBtn.onClick = function(){
dir = "v";
meta();
}
fpnl.fBtn2.onClick = function(){
dir = "h";
meta();
}
function meta(){
var thumbs = app.document.selections;
var counter = '';
if(thumbs.length != 0){
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
for(var i = 0;i < thumbs.length;i++){
try{
if(thumbs[i].spec instanceof File && thumbs[i].hasMetadata){
var thumb = thumbs[i];
var xmp = new XMPMeta(thumb.synchronousMetadata.serialize());
var oldOr = xmp.getProperty(XMPConst.NS_TIFF, 'Orientation');
var newor = 1;
if(dir == 'v'){
switch(oldOr.value){
case '1':
newor = 2;
break;
case '2':
newor = 1;
break;
case '3':
newor = 4;
break;
case '4':
newor = 3;
break;
case '5':
newor = 6;
break;
case '6':
newor = 5;
break;
case '7':
newor = 8;
break;
case '8':
newor = 7;
}
}
if(dir == 'h'){
switch(oldOr.value){
case '1':
newor = 4;
break;
case '2':
newor = 3;
break;
case '3':
newor = 2;
break;
case '4':
newor = 1;
break;
case '5':
newor = 8;
break;
case '6':
newor = 7;
break;
case '7':
newor = 6;
break;
case '8':
newor = 5;
}
}
xmp.setProperty(XMPConst.NS_TIFF, 'Orientation', newor);
var updatedPacket = xmp.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
thumb.metadata = new Metadata(updatedPacket);
}
}
catch(e){
}
}
}
}
}
Copy link to clipboard
Copied
Sadly Bridge's Find command in All Metadata chokes on the < > special characters, which is poorly designed in my opinion.
So it isn't possible to create a useful search with the various rotation metadata entries:
<tiff:Orientation>1</tiff:Orientation> = Normal
<tiff:Orientation>8</tiff:Orientation> = Rotated 90° CCW
<tiff:Orientation>6</tiff:Orientation> = Rotated 90° CW
etc.
Copy link to clipboard
Copied
You would have to use a script to look for specific rotation metadata. Note that this isn't the only way to rotate an image, though.
Copy link to clipboard
Copied
I'd personally use ExifTool as it is faster/easier for me to get a usable result if there was metadata that could be used.
The following examples are a brute force approach, simply remove all rotation metadata, so no need to sort, filter etc.
To remove Bridge rotations on Mac, regardless of the current rotation value:
exiftool -XMP-tiff:Orientation= 'path/to/folder/or file'
Windows:
exiftool -XMP-tiff:Orientation= "path\to\folder\or file"
Bridge JavaSctipt hacked from another script:
/*
Remove Rotation Metadata.jsx
Based on:
https://forums.adobe.com/thread/290238
https://forums.adobe.com/message/1115698#1115698
*/
#target bridge
removeRotationMeta = {}; // create an object
removeRotationMeta.execute = function () { // create a method for that object
var sels = app.document.selections; // store the array of selected files
for (var i = 0; i < sels.length; i++) { // loop though that array
var md = sels[i].synchronousMetadata; // get the metadata for the file
md.namespace = "http://ns.adobe.com/tiff/1.0/"; // set the namespace
md.Orientation = ""; // clear the rotation property
}
}
// this script only works in bridge
if (BridgeTalk.appName == "bridge") {
//create the munu item
var menu = MenuElement.create("command", "Remove Rotation Metadata", "at the end of Tools");
menu.onSelect = removeRotationMeta.execute;
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html