Open wamslers opened 5 years ago
The AsShotNeutral seems to be part of the .dng raw image format, and kept when converting to .jpg.
a workaround seems to be:
del exif_dict["0th"][piexif.ImageIFD.AsShotNeutral] # <---- ADD THIS LINE
I believe this is because _exif.py
has
50728: {'name': 'AsShotNeutral', 'type': TYPES.Short},
but it should be
50728: {'name': 'AsShotNeutral', 'type': TYPES.Rational},
(let me know if I should make a PR for this)
The parsing of tag 50728 AsShotNeutral fails in my images. An example image is posted here:
('0th', 'AsShotNeutral', ((1000, 1693), (1000, 990), (1000, 1442)))
def test(): exif_dict = piexif.load("ImageName.jpg") exif_bytes = piexif.dump(exif_dict)
Traceback (most recent call last): File "meta.py", line 60, in
test()
File "meta.py", line 56, in test
exif_bytes = piexif.dump(exif_dict)
File "/usr/lib/python2.7/site-packages/piexif/_dump.py", line 63, in dump
zeroth_set = _dict_to_bytes(zeroth_ifd, "0th", 0)
File "/usr/lib/python2.7/site-packages/piexif/_dump.py", line 337, in _dict_to_bytes
offset)
File "/usr/lib/python2.7/site-packages/piexif/_dump.py", line 205, in _value_to_bytes
four_bytes_over = _pack_short(raw_value)
File "/usr/lib/python2.7/site-packages/piexif/_dump.py", line 168, in _pack_short
return struct.pack(">" + "H" len(args), *args)
struct.error: cannot convert argument to integer