Multi value fields are broken (Exif.Image.Orientation)

Bug #146323 reported by Olivier Tilloy
4
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
Medium
Olivier Tilloy

Bug Description

This bug was reported by Michal Čihař <email address hidden>:

$ exiv2 -Pkyctv /tmp/xmptest.jpg | grep Image.Orientation
Exif.Image.Orientation Short 4 2 3 4 5 top, right

But this fails:
import pyexiv2

tags = pyexiv2.Image('/tmp/xmptest.jpg')
tags.readMetadata()
print tags.exifKeys()
print tags['Exif.Image.Orientation']

['Exif.Image.ImageDescription', 'Exif.Image.Make', 'Exif.Image.Model', 'Exif.Image.Orientation', 'Exif.Image.DateTime', 'Exif.Image.Artist', 'Exif.Image.Copyright', 'Exif.Image.ExifTag', 'Exif.Photo.ExposureTime', 'Exif.Photo.FNumber', 'Exif.Photo.ExposureProgram', 'Exif.Photo.ISOSpeedRatings', 'Exif.Photo.ExifVersion', 'Exif.Photo.DateTimeOriginal', 'Exif.Photo.DateTimeDigitized', 'Exif.Photo.ShutterSpeedValue', 'Exif.Photo.ApertureValue', 'Exif.Photo.ExposureBiasValue', 'Exif.Photo.MeteringMode', 'Exif.Photo.Flash', 'Exif.Photo.FocalLength', 'Exif.Photo.InteroperabilityTag', 'Exif.Photo.FocalPlaneXResolution', 'Exif.Photo.FocalPlaneYResolution', 'Exif.Photo.FocalPlaneResolutionUnit', 'Exif.Photo.CustomRendered', 'Exif.Photo.ExposureMode', 'Exif.Photo.WhiteBalance', 'Exif.Photo.SceneCaptureType', 'Exif.Iop.InteroperabilityIndex', 'Exif.Thumbnail.Orientation']
Traceback (most recent call last):
  File "/tmp/exif-test.py", line 7, in ?
    print tags['Exif.Image.Orientation']
  File "/usr/lib/python2.4/site-packages/pyexiv2.py", line 480, in __getitem__
    value = self.__getExifTagValue(key)
  File "/usr/lib/python2.4/site-packages/pyexiv2.py", line 312, in __getExifTagValue
    return int(tagValue)
ValueError: invalid literal for int(): 2 3 4 5

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

According to the EXIF 2.2 specification, the image orientation tag is not supposed to hold multiple values (count = 1).
However, considering the many incomplete and buggy implementations in the wild (and the fact that the specification itself is not so clear), pyexiv2 should be able to handle this case smoothly.

Waiting for the sample faulty image to reproduce and confirm the bug.

Revision history for this message
Michal Čihař (nijel) wrote :

The mentioned image is available here: http://www.ivan-herman.net/Photos/xmptest.jpg

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

This image does not seem to be the one originally mentioned: tag "Image.Orientation" is not set in this one:

 $ exiv2 -Pkyctv xmptest.jpg |grep Image.Orientation
 (nothing)

And indeed in pyexiv2:

>>> i=pyexiv2.Image('xmptest.jpg')
>>> i.readMetadata()
>>> i.exifKeys()
['Exif.Image.ImageDescription', 'Exif.Image.Make', 'Exif.Image.Model', 'Exif.Image.DateTime', 'Exif.Image.Artist', 'Exif.Image.Copyright', 'Exif.Image.ExifTag', 'Exif.Photo.ExposureTime', 'Exif.Photo.FNumber', 'Exif.Photo.ExposureProgram', 'Exif.Photo.ISOSpeedRatings', 'Exif.Photo.ExifVersion', 'Exif.Photo.DateTimeOriginal', 'Exif.Photo.DateTimeDigitized', 'Exif.Photo.ShutterSpeedValue', 'Exif.Photo.ApertureValue', 'Exif.Photo.ExposureBiasValue', 'Exif.Photo.MeteringMode', 'Exif.Photo.Flash', 'Exif.Photo.FocalLength', 'Exif.Photo.FocalPlaneXResolution', 'Exif.Photo.FocalPlaneYResolution', 'Exif.Photo.FocalPlaneResolutionUnit', 'Exif.Photo.CustomRendered', 'Exif.Photo.ExposureMode', 'Exif.Photo.WhiteBalance', 'Exif.Photo.SceneCaptureType']

Can you please provide the (real) faulty image? Thanks :)

Revision history for this message
Michal Čihař (nijel) wrote :

Sorry, I thought I downloaded it from this location. The mine file is attached now.

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

Fix committed with revision 70.

Changed in pyexiv2:
importance: Undecided → Medium
status: New → Fix Committed
assignee: nobody → osomon
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
Revision history for this message
Olivier Tilloy (osomon) wrote :

Behaviour modified in revision 79 to fix bug #183618.

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.