Extract Lens Data from EXIF
Posted: Thu May 18, 2006 12:22 pm
I am using Regit Youngs Photoshop script (based on Shaun Ivory original) for adding a border & exif data to a JPG.
RY's version adds the lens data, which I like, BUT, the D2H does not seem to handle the EXIF data in the same format. Or maybe it is CS2?
For instance, in RY's script, he is able to "read" the focal length and use this snippet to get lens data (note: focLength is WITH the 1.5x mag):
Code: Select allif(focLength=="127"){
var Lens = "Nikkor 85mm 1:1.4";
}
However, I have to change it to this snippet to have CS2 read the lens data correctly (focLength WITHOUT 1.5x and adding "mm"):
Code: Select allif(focLength=="300.0 mm"){
var Lens = "Nikon 300mm f4 AF-S";
}
Here is the challenge:
For a Nikon 12-24mm he uses:
Code: Select allif(focLength>=18 && focLength<=36){
var Lens = "Nikon 12-24mm";
}
How do I modify this so I can have the script pick up when I am using my Nikon 80-200mm f2.8? I cannot (I dont think) use the numbers since it needs the "mm" to correctly read the info - thus eliminating the use of greater than/lessor than.
Can anyone help?
Thanks in advance.
--- orig RY script here ---
Code: Select all//---------
displayDialogs = DialogModes.NO;
var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
function explodeArray(item,delimiter) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0) {
tempArray=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
}
tempArray=tempString;
return tempArray;
}
var AD = activeDocument;
var resRatio = AD.resolution/72;
if(resRatio!=1){
AD.resizeImage(AD.width.value,AD.height.value,72);
}
var heightVar = AD.height.value+2;
var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;
var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;
backgroundColor = black;
AD.resizeCanvas(AD.width.value+8,AD.height.value+8,
AnchorPosition.MIDDLECENTER);
AD.resizeCanvas(AD.width.value,AD.height.value+60,AnchorPosition.TOPCENTER);
var exifData = AD.info.exif.toString();
explodeArray(exifData,",");
for(n = 0; n < tempArray.length; n = n + 2 ) {
var stringTemp=tempArray
if(stringTemp.indexOf("Exposure Time")!=-1){
var expTime = tempArray;
}
if(stringTemp.indexOf("Focal Length")!=-1){
var focLength = tempArray;
}
if(stringTemp.indexOf("F-Stop")!=-1){
var aptNum = tempArray;
}
if(stringTemp.indexOf("ISO Speed Ratings")!=-1){
var ISONum = tempArray;
}
//Use this to note the lens use.
//Basically, just calculate the 35mm equi of the lens and plug in the
figure.
//Or simply look at the EXIF info from PS CS
//For zoom, just use a range.
if(focLength>=18 && focLength<=36){
var Lens = "Nikkor 12-24mm 1:4";
}
if(focLength=="42"){
var Lens = "Nikkor 28mm 1:2.0";
}
if(focLength=="82"){
var Lens = "Micro-Nikkor 55mm 1:3.5";
}
if(focLength=="87"){
var Lens = "Noct-Nikkor 58mm 1:1.2";
}
if(focLength=="127"){
var Lens = "Nikkor 85mm 1:1.4";
}
if(focLength=="157"){
var Lens = "UV-Nikkor 105mm 1:1.4.5";
}
if(focLength=="72"){
var Lens = "Macro-Nikkor 65mm 1:4.5";
}
if(stringTemp.indexOf("Date Time Original")!=-1){
var phoTime = tempArray;
var dateArray1 = phoTime.split(" ", 1);
phoTime = dateArray1<0>;
var dateArray2 = phoTime.split(":");
var monthsArray =<"January",[BR> "February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"];
phoTime = monthsArray-1]+" "+dateArray2<2>+"
"+dateArray2<0>;
}
if(stringTemp.indexOf("Model")!=-1){
var cameraModel = tempArray;
}
}
//change the name here!!!
var nameLayer = AD.artLayers.add();
nameLayer.kind = LayerKind.TEXT;
var TI = nameLayer.textItem;
TI.position = <5,heightVar+16>;
TI.contents = "© Regit Young 2005";
TI.font = "Arial";
TI.size = 14;
TI.color = white;
TI.fauxBold = true;
var infoLayer = AD.artLayers.add();
infoLayer.kind = LayerKind.TEXT;
var TI = infoLayer.textItem;
TI.position = <5,heightVar+30>;
TI.contents = cameraModel+" with "+Lens+" @ "+focLength+"mm (35mm
equiv), "+expTime+", "+aptNum+", ISO: "+ISONum+"\u000DDate photo taken:
"+phoTime;
TI.font = "Arial";
TI.size = 11;
TI.color = white;
AD.flatten();
//-----
RY's version adds the lens data, which I like, BUT, the D2H does not seem to handle the EXIF data in the same format. Or maybe it is CS2?
For instance, in RY's script, he is able to "read" the focal length and use this snippet to get lens data (note: focLength is WITH the 1.5x mag):
Code: Select allif(focLength=="127"){
var Lens = "Nikkor 85mm 1:1.4";
}
However, I have to change it to this snippet to have CS2 read the lens data correctly (focLength WITHOUT 1.5x and adding "mm"):
Code: Select allif(focLength=="300.0 mm"){
var Lens = "Nikon 300mm f4 AF-S";
}
Here is the challenge:
For a Nikon 12-24mm he uses:
Code: Select allif(focLength>=18 && focLength<=36){
var Lens = "Nikon 12-24mm";
}
How do I modify this so I can have the script pick up when I am using my Nikon 80-200mm f2.8? I cannot (I dont think) use the numbers since it needs the "mm" to correctly read the info - thus eliminating the use of greater than/lessor than.
Can anyone help?
Thanks in advance.
--- orig RY script here ---
Code: Select all//---------
displayDialogs = DialogModes.NO;
var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
function explodeArray(item,delimiter) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0) {
tempArray=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
}
tempArray=tempString;
return tempArray;
}
var AD = activeDocument;
var resRatio = AD.resolution/72;
if(resRatio!=1){
AD.resizeImage(AD.width.value,AD.height.value,72);
}
var heightVar = AD.height.value+2;
var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;
var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;
backgroundColor = black;
AD.resizeCanvas(AD.width.value+8,AD.height.value+8,
AnchorPosition.MIDDLECENTER);
AD.resizeCanvas(AD.width.value,AD.height.value+60,AnchorPosition.TOPCENTER);
var exifData = AD.info.exif.toString();
explodeArray(exifData,",");
for(n = 0; n < tempArray.length; n = n + 2 ) {
var stringTemp=tempArray
if(stringTemp.indexOf("Exposure Time")!=-1){
var expTime = tempArray;
}
if(stringTemp.indexOf("Focal Length")!=-1){
var focLength = tempArray;
}
if(stringTemp.indexOf("F-Stop")!=-1){
var aptNum = tempArray;
}
if(stringTemp.indexOf("ISO Speed Ratings")!=-1){
var ISONum = tempArray;
}
//Use this to note the lens use.
//Basically, just calculate the 35mm equi of the lens and plug in the
figure.
//Or simply look at the EXIF info from PS CS
//For zoom, just use a range.
if(focLength>=18 && focLength<=36){
var Lens = "Nikkor 12-24mm 1:4";
}
if(focLength=="42"){
var Lens = "Nikkor 28mm 1:2.0";
}
if(focLength=="82"){
var Lens = "Micro-Nikkor 55mm 1:3.5";
}
if(focLength=="87"){
var Lens = "Noct-Nikkor 58mm 1:1.2";
}
if(focLength=="127"){
var Lens = "Nikkor 85mm 1:1.4";
}
if(focLength=="157"){
var Lens = "UV-Nikkor 105mm 1:1.4.5";
}
if(focLength=="72"){
var Lens = "Macro-Nikkor 65mm 1:4.5";
}
if(stringTemp.indexOf("Date Time Original")!=-1){
var phoTime = tempArray;
var dateArray1 = phoTime.split(" ", 1);
phoTime = dateArray1<0>;
var dateArray2 = phoTime.split(":");
var monthsArray =<"January",[BR> "February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"];
phoTime = monthsArray-1]+" "+dateArray2<2>+"
"+dateArray2<0>;
}
if(stringTemp.indexOf("Model")!=-1){
var cameraModel = tempArray;
}
}
//change the name here!!!
var nameLayer = AD.artLayers.add();
nameLayer.kind = LayerKind.TEXT;
var TI = nameLayer.textItem;
TI.position = <5,heightVar+16>;
TI.contents = "© Regit Young 2005";
TI.font = "Arial";
TI.size = 14;
TI.color = white;
TI.fauxBold = true;
var infoLayer = AD.artLayers.add();
infoLayer.kind = LayerKind.TEXT;
var TI = infoLayer.textItem;
TI.position = <5,heightVar+30>;
TI.contents = cameraModel+" with "+Lens+" @ "+focLength+"mm (35mm
equiv), "+expTime+", "+aptNum+", ISO: "+ISONum+"\u000DDate photo taken:
"+phoTime;
TI.font = "Arial";
TI.size = 11;
TI.color = white;
AD.flatten();
//-----