Calculate with a tag

Started by Birdman, November 30, 2022, 11:39:27 AM

Previous topic - Next topic

Birdman

Hello,

I would like to show the correct focal length in the metadata when using the digital zoom with my smartphone. There is a tag called "DigitalZoomRatio" with a value like "2.98" for example. Is there a way to use exiftool to calculate the new focallength, something like "DigitalZoomRatio * 60" for a 60mm lens? Unfortunately I am not quite firm using perl, so if there is an easy way to let this work in exiftool directly would be perfect.

Best regards,
Birdman
Best regards,

Martin (Birdman)

Phil Harvey

Hi Martin,

Try this command with the attached config file:

exiftool -config digitalfocallength.config -digitalfocallength FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

And I'm too slow with my config file :D

Though yours is nicer with the sprintf added.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Yeah.  We've had a lot of bad weather lately so I've been sitting indoors more, hence quicker with the responses. :)

On the plus side, I did find a Red-throated Loon yesterday during a break in the weather.  :D  (Hmmm.  I just noticed the "Unknown" lens in the metadata of that picture.  DreamHost needs to update their version of ExifTool for my new lens, the Nikkor 500mm F5.6 PF.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Birdman

Thanks a lot so far. I will get back soon, kids and dog are very hungry.  ;)  (Its dinner-time here)
Best regards,

Martin (Birdman)

Birdman

Hello again,

for the calculation the config file is working quite well, thanks again! Only it will not store the new variable "digitalfocallength" in the exifs, it just shows the value while exiftool is running.
Best regards,

Martin (Birdman)

Phil Harvey

If you want to write this value into the file you first have to decide where to write it.  Maybe into the XMP description?  There are various ways to do this, here is one:

exiftool -config digitalfocallength.config "-xmp:description<Digital Focal Length: $digitalfocallength" FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: Birdman on November 30, 2022, 01:27:29 PMOnly it will not store the new variable "digitalfocallength" in the exifs, it just shows the value while exiftool is running.

You should also realize that you can't just make up a new tag so simply.  And even if you do write a definition for a new tag, no program other that exiftool will be able to read it.  Metadata is much more complex than that.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Birdman

Hi Phil and StarGeek,

thanks again for your help and the useful advice. I solved it by writing the new variable together with other information into the headline tag right away. So even the new "tag" is not stored I have the information where I wanted it. The modified lines read like this now:
exiftool -config digitalfocallength.config -digitalfocallength "-headline<${digitalfocallength} | ${shutterspeed} | f ${fnumber} | ISO $exif:iso" -if "$flash ne 'On, Fired' and $flash ne 'Auto, Fired' and $make eq 'Sony'" -overwrite_original D:\Bilder\0_Bearbeitung\1_Einlesen\*.JPGexiftool -config digitalfocallength.config -digitalfocallength "-headline<${digitalfocallength} | ${shutterspeed} | f ${fnumber} | ISO $exif:iso | Blitz" -if "($flash eq 'On, Fired' or $flash eq 'Auto, Fired') and $make eq 'Sony'" -overwrite_original D:\Bilder\0_Bearbeitung\1_Einlesen\*.JPG
Best regards,

Martin (Birdman)

Phil Harvey

Hi Martin,

Great.

You can do this with a single command using the advanced-formatting feature.  Also the -digitalfocallength argument was doing nothing, and I'm using the -ext option instead of *.JPG.

exiftool -config digitalfocallength.config "-headline<${digitalfocallength} | ${shutterspeed} | f ${fnumber} | ISO $exif:iso${flash;$_=/Fired/ ? ' | Blitz' : ''}" -if "$make eq 'Sony'" -overwrite_original -ext jpg D:\Bilder\0_Bearbeitung\1_Einlesen
- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).