-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pretty printer for GPSImgDirection & GPSTrack #1541
Comments
Hi @John-N-G, thanks for the report.
I agree that it would be nicer to format this differently, eg. As far as I can tell, this would be a change that impacts every consumer of exiv2, and thus I'm not sure if it's something that can be done in a minor release. To be fair, given that all info is available, this seems like a trivial thing to fix on the DigiKam side. |
Thank You @John-N-G for your generous words of praise for Exiv2. And thank you @hassec for your correct analysis. Your issue is a presentation issue in digiKam. The data in your file is Exif Rational which are integers pairs. You have 3 pairs which represent degrees, minutes and seconds. https://exiv2.org/tags.html The exiv2 command-line program provides two presentation styles. Value style '-pv' is the value and is an ascii formatted version of the "raw" values in the image: 506 rmills@rmillsm1:~ $ exiv2 -pv -g Latitude -g Longitude ~/Downloads/114268738-a429ab00-99fa-11eb-9fe8-73c1f372d5b4.jpg
0x0001 GPSInfo GPSLatitudeRef Ascii 2 N
0x0002 GPSInfo GPSLatitude Rational 3 51/1 20029833/1000000 0/1
0x0003 GPSInfo GPSLongitudeRef Ascii 2 W
0x0004 GPSInfo GPSLongitude Rational 3 0/1 4863667/1000000 0/1 Translated style '-pt' is a human friendly formatted string. I chose to express it as 507 rmills@rmillsm1:~ $ exiv2 -pt -g Latitude -g Longitude ~/Downloads/114268738-a429ab00-99fa-11eb-9fe8-73c1f372d5b4.jpg
Exif.GPSInfo.GPSLatitudeRef Ascii 2 North
Exif.GPSInfo.GPSLatitude Rational 3 51deg 20' 0"
Exif.GPSInfo.GPSLongitudeRef Ascii 2 West
Exif.GPSInfo.GPSLongitude Rational 3 0deg 5' 0"
508 rmills@rmillsm1:~ $ The people at DigiKam blame everything involving metadata on Exiv2. In this case, I can say with certainty that Exiv2 is not to blame. |
Just for completeness I'm including the DigiKam bug: https://bugs.kde.org/show_bug.cgi?id=435317 @John-N-G Thanks for already updating the bug there with our response. I hope you don't mind, I renamed the issue to make it more clear for us. |
Yup. I got a little confused. I had totally forgotten about adding the Direction and Track tags in v0.27.4. I think they are specified in the Exif 2.32 spec. The "translated" values are performed in Exiv2 by providing a "pretty printer" function such as printDegrees() which I added to handle Latitude and Longitude. We should add a pretty printer for Track and Direction for use by the Exiv2 command-line program. When no "pretty printer" is available, the code prints the value. I can't remember if the pretty printers can be called via the Exiv2 API. 516 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pv -g Track -g Direction ~/Downloads/114268738-a429ab00-99fa-11eb-9fe8-73c1f372d5b4.jpg
0x000e GPSInfo GPSTrackRef Ascii 2 T
0x000f GPSInfo GPSTrack Rational 1 27093/100
0x0010 GPSInfo GPSImgDirectionRef Ascii 2 T
0x0011 GPSInfo GPSImgDirection Rational 1 32098/100
517 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pt -g Track -g Direction ~/Downloads/114268738-a429ab00-99fa-11eb-9fe8-73c1f372d5b4.jpg
Exif.GPSInfo.GPSTrackRef Ascii 2 True direction
Exif.GPSInfo.GPSTrack Rational 1 27093/100
Exif.GPSInfo.GPSImgDirectionRef Ascii 2 True direction
Exif.GPSInfo.GPSImgDirection Rational 1 32098/100
518 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance $ None-the-less, this is a presentation matter which is DigiKam's domain and responsibility. |
Exiv2 provide an API to use the pretty printers from an application. See https://exiv2.org/doc/classExiv2_1_1Exifdatum.html So there are two similar functions:
Here's additional information concerning print() Exiv2::Exifdatum::write The method takes an optional pointer to a metadata container. Pretty-print functions may use that to refer to other metadata as it is sometimes not sufficient to know only the value of the metadatum that should be interpreted. Thus, it is advisable to always call this method with a pointer to the metadata container if possible. This functionality is currently only implemented for Exif tags. The pointer is ignored when used to write IPTC datasets or XMP properties. Without the optional metadata pointer, you do not usually have to use this function; it is used for the implementation of the output operator for Metadatum, operator<<(std::ostream &os, const Metadatum &md). See also print(), which prints the interpreted value to a string. |
The Exif 2.32 Spec is here: https://fotomagazin.hu/wp-content/uploads/2020/05/CIPA_DC_008_EXIF_2019.pdf Table 15 (page 77) lists 32 GPS tags. Let's make sure all those tags are in Exiv2 (I believe they are) and with appropriate "pretty Printers". |
I believe we reviewed the tag coverage, but it might be the case we didn't focus on pretty printing. I'll take another pass as well. In any case, apps have full acces to rationals through the API so they can choose to present the data in any format they want, I don't think our convenience functions for console output should be used universally... |
Thanks, @kmilos. There's such a myriad of details in the metadata mountain. The only viable way to deal with everything is "step-wise refinement". He's not as ugly as his cousin "trial and error". |
Ok, so it turns out there are a few places where we just use the default
0x013e, WhitePoint
0xc61a, BlackLevel ... and all the color profile matrices
9400,Temperature,SRATIONAL,1
B,GPSDOP,RATIONAL,1 We're also missing the Exif 0xa500 Gamma tag. (PR created for main branch) Any preference on how to proceed, and whether we want to change something for 0.27.4? Simply replacing everywhere is risky, as a couple of tags assign special meaning to values 0/0 or 1/0... |
ExifTool output for the attached image:
So no units for |
IMHO |
663 rmills@rmillsm1:~/gnu/github/exiv2/main $ exiv2 -g GPSInfo ~/Downloads/114268738-a429ab00-99fa-11eb-9fe8-73c1f372d5b4.jpg
Exif.GPSInfo.GPSVersionID Byte 4 2.3.0.0
Exif.GPSInfo.GPSLatitudeRef Ascii 2 North
Exif.GPSInfo.GPSLatitude Rational 3 51deg 20' 0"
Exif.GPSInfo.GPSLongitudeRef Ascii 2 West
Exif.GPSInfo.GPSLongitude Rational 3 0deg 5' 0"
Exif.GPSInfo.GPSAltitudeRef Byte 1 Above sea level
Exif.GPSInfo.GPSAltitude Rational 1 155.6 m
Exif.GPSInfo.GPSTimeStamp Rational 3 14:03:31
Exif.GPSInfo.GPSSatellites Ascii 3 09
Exif.GPSInfo.GPSStatus Ascii 2 Measurement in progress
Exif.GPSInfo.GPSMeasureMode Ascii 2 Three-dimensional measurement
Exif.GPSInfo.GPSSpeedRef Ascii 2 km/h
Exif.GPSInfo.GPSSpeed Rational 1 2/100
Exif.GPSInfo.GPSTrackRef Ascii 2 True direction
Exif.GPSInfo.GPSTrack Rational 1 27093/100
Exif.GPSInfo.GPSImgDirectionRef Ascii 2 True direction
Exif.GPSInfo.GPSImgDirection Rational 1 32098/100
Exif.GPSInfo.GPSMapDatum Ascii 7 WGS-84
Exif.GPSInfo.GPSProcessingMethod Undefined 11 charset=Ascii GPS
Exif.GPSInfo.GPSDateStamp Ascii 11 2021:02:18
664 rmills@rmillsm1:~/gnu/github/exiv2/main $ I see that ExifTool says xx deg yy' zz" (space) and exiv2 says xxdeg yy' zz" (no space). Let's change printDegrees() to be consistent with ExifTool. (no man page changes necessary for this) There are cosmetic differences with Status and MeasureMode, Speed and Direction Let's fix them. Please look at man/man1/exiv2.1 when changing prettyPrinters. I see ExifTool doesn't provide a unit for Track and Direction. Let's be consistent and do likewise. |
Btw, there seems to be something more going on w/ the way we print the long/lat, check the seconds. I guess this is related to the second available Exif spec option where the minute value is a true rational (MMMM/100) and second is (0/1)...
|
I think this now resolved by #1551, but feel free to reopen if different behaviour is expected. |
Hi,
I recently reported a bug to DigiKam who have identified that the issue lies within the Exiv2 libraries. Specifically, GPS image direction is displayed as, for example, "26819/100" when it should be showing "268.19 deg".
I've attached an image with GPS/compass EXIF data so you can verify this for yourselves.
I'd be very grateful if you could look into this - I imagine it's a simple formatting error in the code. DigiKam is a great product and so, by extension, is your contribution to it - thank you.
Best regards,
John Gass
The text was updated successfully, but these errors were encountered: