Exif.GPSInfo.{GPSLongitude,Latitude} are not decoded

Bug #183618 reported by dr who
8
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
Medium
Olivier Tilloy

Bug Description

the GPS latitude and longitude data is not decoded: use the example picture at http://d2h.net/gallery/d/20568-4/DSCF1390.JPG

exiv2 -Pkyctv /downloads/DSCF1390.JPG | grep GPS
Exif.Image.GPSTag Long 1 1313 1313
Exif.GPSInfo.GPSVersionID Byte 4 2 0 0 0 2 0 0 0
Exif.GPSInfo.GPSLatitudeRef Ascii 2 N North
Exif.GPSInfo.GPSLatitude Rational 3 47/1 3817443/1000000 0/1 47deg 3.81744'
Exif.GPSInfo.GPSLongitudeRef Ascii 2 E East
Exif.GPSInfo.GPSLongitude Rational 3 8/1 41359940/1000000 0/1 8deg 41.35994'
Exif.GPSInfo.GPSAltitudeRef Byte 1 0 Above sea level
Exif.GPSInfo.GPSAltitude Rational 1 1908629/1250 1526.9 m
Exif.GPSInfo.GPSMapDatum Ascii 7 WGS-84 WGS-84

pyexiv2 however returns:

import pyexiv2
image = pyexiv2.Image('/downloads/DSCF1390.JPG')
image.readMetadata()
print image['Exif.GPSInfo.GPSLongitude']
(8L, 1L)
print image['Exif.GPSInfo.GPSLatitude']
(47L, 1L)

the value for altitude is correct, though:

print image['Exif.GPSInfo.GPSAltitude']
(1908629L, 1250L)

which comes out as:
1908629/float(1250)
1526.9032

Revision history for this message
Olivier Tilloy (osomon) wrote :

Successfully reproduced with the given example file.
Unfortunately, multiple value fields for EXIF tags are currently not correctly dealt with: only the first value is extracted and returned.

Changed in pyexiv2:
assignee: nobody → osomon
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Olivier Tilloy (osomon) wrote :

In fact this bug conflicts with the fix provided for bug #146323. pyexiv2 should always return all the values held in a given field even if it is not supposed to hold more than one value.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Fix committed with revision 79.
Multiple value fields for EXIF tags are now fully decoded and returned as a tuple of values.
Here is an example script and its output for the attached image:

image = pyexiv2.Image('DSCF1390.JPG')
image.readMetadata()
for key in image.exifKeys():
    if key.find('GPS') != -1:
        print key, ':', image[key], ':', image.interpretedExifValue(key)

Exif.Image.GPSTag : 1313 : 1313
Exif.GPSInfo.GPSVersionID : 2 0 0 0 : 2 0 0 0
Exif.GPSInfo.GPSLatitudeRef : N : North
Exif.GPSInfo.GPSLatitude : ((47L, 1L), (3817443L, 1000000L), (0L, 1L)) : 47deg 3.81744'
Exif.GPSInfo.GPSLongitudeRef : E : East
Exif.GPSInfo.GPSLongitude : ((8L, 1L), (41359940L, 1000000L), (0L, 1L)) : 8deg 41.35994'
Exif.GPSInfo.GPSAltitudeRef : 0 : Above sea level
Exif.GPSInfo.GPSAltitude : (1908629L, 1250L) : 1526.9 m
Exif.GPSInfo.GPSMapDatum : WGS-84 : WGS-84

This fix reverts the behaviour implemented with revision 70 to fix bug #146323.

Changed in pyexiv2:
status: Confirmed → Fix Committed
Revision history for this message
dr who (dr-who) wrote :

excellent! works as advertized :-) thx!

Revision history for this message
Ian Barton (ian-manor-farm) wrote :

There still seems to be a problem with this in revision 103:

>>> image = pyexiv2.Image('29052008409.jpg')
>>> image.readMetadata()
>>> for key in image.exifKeys():
... if key.find('GPS') != -1:
... print key, ':', image[key], ':', image.interpretedExifValue(key)
...
Exif.Image.GPSTag :
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib/python2.5/site-packages/pyexiv2.py", line 594, in __getitem__
    value = self.__getExifTagValue(key)
  File "/usr/lib/python2.5/site-packages/pyexiv2.py", line 467, in __getExifTagValue
    tagType, tagValue = self.__getExifTag(key)
ValueError: too many values to unpack

Ian.

Revision history for this message
Ian Barton (ian-manor-farm) wrote :

Sorry forgot to add that you can download the image I used from: http://www.ian-barton.com/ian-barton/wiki/uploads/Ireland/29052008409.jpg

Ian.

Olivier Tilloy (osomon)
Changed in pyexiv2:
milestone: none → 0.2
status: Fix Committed → New
importance: High → Medium
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: New → Confirmed
Revision history for this message
dmoore (damien-moore) wrote :

Attached is the patch i'm using for this issue in phraymd (I use a local copy of the pyexiv2.py source inside phraymd)

Revision history for this message
Olivier Tilloy (osomon) wrote :

Fixed in the 0.2 branch. The expected syntax for the original example would now look like this:

    import pyexiv2
    metadata = pyexiv2.ImageMetadata('/downloads/DSCF1390.JPG')
    metadata.read()
    for key in ('Exif.GPSInfo.GPSLongitude',
                'Exif.GPSInfo.GPSLatitude',
                'Exif.GPSInfo.GPSAltitude'):
        tag = metadata[key]
        print key, ':', tag, '|', tag.human_value

The expected output is:

Exif.GPSInfo.GPSLongitude : 8/1, 41359940/1000000, 0/1 | 8deg 41.35994'
Exif.GPSInfo.GPSLatitude : 47/1, 3817443/1000000, 0/1 | 47deg 3.81744'
Exif.GPSInfo.GPSAltitude : 1908629/1250 | 1526.9 m

Changed in pyexiv2:
status: Confirmed → Fix Committed
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.