Quickly retrieve Exif metadata
I've got a script for Photoshop CC 2014 that makes some exposure value (EV) calculations based on Exif metadata in camera raw files and then adjusts the image exposure to the target EV. I know that this information is quickly available in Bridge, but when I try to get the metadata in Photoshop, I have to use the Document.open() command, and that opens the file (which takes a long time) instead of just grabbing the Exif metadata. I can get it quickly in a Bridge script, but I'm having a hard time embedding that stuff in a Photoshop-targeted script (the BridgeTalk stuff is a bit confusing to me, or it isn't working on my computer).
I've also attempted to use "bridge.executeScript()", but the bridge object apparently is not available to scripts targeting Photoshop (or else something is messed up with my installation). Bridge is available in bridge-targeted scripts only.
Here's how it's working in Photoshop scripting (I include only the relevant part).
| for (var nfile = nstart; nfile < nstop; nfile++){ | |
| var Name = File(testListing[nfile]).name.replace(/\.[^\.]+$/, ''); | |
| var file = File(testListing[nfile].path + "/" + Name + ".JPG"); | |
| if (file.exists){ | |
| app.open(file); | |
| } | |
| else{ | |
| app.open(testListing[nfile]); | |
| } | |
| var DocInfo = app.activeDocument.info; | |
| var docRef = app.activeDocument | |
| EV[nfile] = CalcEV (DocInfo, BaseISO); | |
| app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); | |
| } |
(FYI, I use the jpeg file if it's there because Photoshop reads the exif from that file more quickly than it does from the raw file)
Here's how it's working in Bridge scripting:
firstfile = '7A7A5842.CR2';
lastfile = '7A7A5843.CR2';
var ExifProperty = 'exif:DateTimeOriginal';
var ExifNamespace = 'http://ns.adobe.com/exif/1.0/';
app.document.deselectAll();
app.document.selectAll();
var myThumbs = app.document.getSelection("cr2");
var fstart = -999;
var fend = -999;
for (var n = 0; n < myThumbs.length; n++){
if (myThumbs
if (myThumbs
}
var NumFiles = myThumbs.length;
var fileThumbs = myThumbs.slice(fstart,fend);
flen = fend-fstart+1;
var EVarray = new Array(flen);
for (var n = 0; n < fileThumbs.length; n++){
var md = fileThumbs
ISO = md.read(ExifNamespace,'exif:ISOSpeedRatings');
SS_string = md.read(ExifNamespace,'exif:ExposureTime');
var test = SS_string.split("/");
ShutterSpeed = test[0]/test[1];
var Aperture_string = md.read(ExifNamespace,'exif:FNumber');
if (Aperture_string == '') {
var Aperture = Number(1.4); // assume Samyang set at f1.4
}
else {
var test = Aperture_string.split("/");
Aperture = test[0]/test[1];
}
var ISOadjust = Number(1.);
EVarray
$.writeln('ISO ',ISO,' SS ',SS,' Av ',Aperture, ' EV=',EVarray
}
app.document.deselectAll();
"Done...";
