script automation from the focal length metadata

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Anorak
Posts: 1
Joined: Fri Sep 23, 2016 12:06 pm

script automation from the focal length metadata

Post by Anorak »

Hello everybody,
I am looking to apply a script on my pictures, wich one is able to recognize the focal lenght in the metadatas.
I've made a specific series of photo with 3 focal lenght: 50mm;70mm and 105 mm and i wish apply a specific script on my pictures in function of the focal lenght...

I hope you can help me
Best regards
User avatar
Dormeur74
Posts: 36
Joined: Mon Oct 03, 2016 4:56 am

Re: script automation from the focal length metadata

Post by Dormeur74 »

Some information.
Number of Exifs depend on your camera. Example : Nikon Df and Nikon D3x have different Exif numbers.
But Exif codes are constant : 37386 gives the focal length.

I think the following code could help you.

Code: Select all


#target photoshop
app.bringToFront();

var nbExifs = app.activeDocument.info.exif.length;

for (var i = 0; i < nbExifs; i++)
{
var lensFocal= app.activeDocument.info.exif[i][1];
if (app.activeDocument.info.exif[i][2]==37386) // Code for lens focal
{
alert(lensFocal);
}
}