ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Birdman on November 30, 2022, 11:39:27 AM

Title: Calculate with a tag
Post by: Birdman on November 30, 2022, 11:39:27 AM
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
Title: Re: Calculate with a tag
Post by: Phil Harvey on November 30, 2022, 11:53:29 AM
Hi Martin,

Try this command with the attached config file:

exiftool -config digitalfocallength.config -digitalfocallength FILE

- Phil
Title: Re: Calculate with a tag
Post by: StarGeek on November 30, 2022, 11:57:26 AM
And I'm too slow with my config file :D

Though yours is nicer with the sprintf added.
Title: Re: Calculate with a tag
Post by: Phil Harvey on November 30, 2022, 11:58:56 AM
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 (https://exiftool.org/birds/) 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
Title: Re: Calculate with a tag
Post by: Birdman on November 30, 2022, 12:14:42 PM
Thanks a lot so far. I will get back soon, kids and dog are very hungry.  ;)  (Its dinner-time here)
Title: Re: Calculate with a tag
Post by: Birdman on November 30, 2022, 01:27:29 PM
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.
Title: Re: Calculate with a tag
Post by: Phil Harvey on November 30, 2022, 02:02:32 PM
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
Title: Re: Calculate with a tag
Post by: StarGeek on November 30, 2022, 09:39:28 PM
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.
Title: Re: Calculate with a tag
Post by: Birdman on December 01, 2022, 05:01:36 AM
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
Title: Re: Calculate with a tag
Post by: Phil Harvey on December 01, 2022, 07:56:12 AM
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