drewnoakes / metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Apache License 2.0
2.57k stars 481 forks source link

GPS height information reading #617

Open yw19841107 opened 1 year ago

yw19841107 commented 1 year ago

I am using JAVA version 2.18.0,When writing a code to read the GPS height, the height result obtained is not the same as the original value stored in the photo. At present, it is rounded to retain the last two Decimal separator of the GPS height value. Please improve it

StefanOltmann commented 8 months ago

The GPS data is of the TIFF rational type, which means it’s a floating number that can’t have an exact representation. See the docs.

Google Photos rounds two 3 digits after the dot. Rounding to the last 6 decimal places is the most common thing I see.

GeoLocation.toString() gives you the double numbers without any rounding: https://github.com/drewnoakes/metadata-extractor/blob/753cf1f514dff829af2782a60c81720ab161aa83/Source/com/drew/lang/GeoLocation.java#L150-L153

So I assume you want to see a different format for the DMS here: https://github.com/drewnoakes/metadata-extractor/blob/753cf1f514dff829af2782a60c81720ab161aa83/Source/com/drew/lang/GeoLocation.java#L85-L86

Two decimal places for DMS seems to be a very common representation.

How many do you want?