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
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.