mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-25 22:54:46 +03:00
Read Interop EXIF subdirectory
This commit is contained in:
parent
8e4d547195
commit
ce915162ab
|
@ -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"))
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user