Read Interop EXIF subdirectory

This commit is contained in:
Andrew Murray 2019-01-19 15:00:06 +11:00
parent 8e4d547195
commit ce915162ab
2 changed files with 27 additions and 0 deletions

View File

@ -255,6 +255,21 @@ class TestFileJpeg(PillowTestCase):
# Should not raise a TypeError # Should not raise a TypeError
im._getexif() im._getexif()
def test_interop(self):
# Arrange
im = Image.open('Tests/images/flower.jpg')
# Act
exif = im._getexif()
# Assert
self.assertEqual(exif["interop"], {
1: 'R98',
2: b'0100',
4097: 2272,
4098: 1704
})
def test_progressive_compat(self): def test_progressive_compat(self):
im1 = self.roundtrip(hopper()) im1 = self.roundtrip(hopper())
self.assertFalse(im1.info.get("progressive")) self.assertFalse(im1.info.get("progressive"))

View File

@ -489,6 +489,18 @@ def _getexif(self):
info = TiffImagePlugin.ImageFileDirectory_v1(head) info = TiffImagePlugin.ImageFileDirectory_v1(head)
info.load(file) info.load(file)
exif[0x8825] = _fixup_dict(info) exif[0x8825] = _fixup_dict(info)
# get interop
try:
# exif field 0xa005 is an offset pointer to the location
# of the nested embedded interop exif ifd.
# It should be a long, but may be corrupted.
file.seek(exif[0xa005])
except (KeyError, TypeError):
pass
else:
info = TiffImagePlugin.ImageFileDirectory_v1(head)
info.load(file)
exif["interop"] = _fixup_dict(info)
return exif return exif