A ValueError raised in that case is intended, because the conversion fails.
The real issue is the root cause of this failure: the faulty tag is 'Exif.Pentax.PreviewResolution', and pyexiv2 thinks its type is 'Undefined', as advertised by the documentation (see http://exiv2.org/tags-pentax.html), where in fact it should be 'Short'.
It seems that exiv2 itself knows how to fix the type, because the command line tool returns the correct type:
A ValueError raised in that case is intended, because the conversion fails.
The real issue is the root cause of this failure: the faulty tag is 'Exif.Pentax. PreviewResoluti on', and pyexiv2 thinks its type is 'Undefined', as advertised by the documentation (see http:// exiv2.org/ tags-pentax. html), where in fact it should be 'Short'.
It seems that exiv2 itself knows how to fix the type, because the command line tool returns the correct type:
$ exiv2 -PEkyvt IMGP1118sm.JPG | grep PreviewResolution PreviewResoluti on Short 640 480 640x480
Exif.Pentax.
This may very well be an issue with the way pyexiv2 queries libexiv2 for the type of a tag.