Reduce the number of decimal digits in ${gpslatitude#}

Started by Manard, February 22, 2025, 12:59:15 PM

Previous topic - Next topic

Manard

Hello,

I use exiftool to extract and format various data using fmt files.
I'm looking for a way to reduce the number of decimal places to the values displayed by $gpslatitude# and $gpslongitude# for example in this type of fmt file:

[HEAD]N° Dalle,N° Photo+date,lat,lng,date
${gpslatitude#}&${gpslongitude#},${BaseName}_${gpsdatetime#;DateFmt("%Y-%m-%d");},$gpslatitude#,$gpslongitude#,${gpsdatetime#;DateFmt("%Y-%m-%d");}
#

With my thanks for your help

Bernard

StarGeek

#1
Add the -c (-coordFormat) option to your command. For example, adding
-c %.5f
will limit the GPSLatitude/GPSLongitude to 5 decimal places.

You would have to remove the hashtags from the FMT file though. This also does not affect the GPSAltitude.

The other option would be to edit the FMT file and use the Perl sprintf function
${gpslatitude#;$_=sprintf("%.5f",$_)}&${gpslongitude#;$_=sprintf("%.5f",$_)},${BaseName}_${gpsdatetime#;DateFmt("%Y-%m-%d");},${gpslatitude#;$_=sprintf("%.5f",$_)},${gpslongitude#;$_=sprintf("%.5f",$_)},${gpsdatetime#;DateFmt("%Y-%m-%d");}
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Manard

Thank you very much StarGeek for your help, both solutions work, I just had to add in the fmt file a ";" between gpslongitude# and $_=sprintf("%.5f",$_)

Good afternoon

Bernard

StarGeek

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype