Removed automatic retrieval of GPS IFD

This commit is contained in:
Andrew Murray 2021-03-15 12:32:42 +11:00
parent e763f8f2be
commit c52b45df62
2 changed files with 7 additions and 5 deletions

View File

@ -264,11 +264,11 @@ class TestFileJpeg:
assert exif[0x0112] == Image.TRANSVERSE assert exif[0x0112] == Image.TRANSVERSE
# Assert that the GPS IFD is present and empty # Assert that the GPS IFD is present and empty
assert exif[0x8825] == {} assert exif.get_ifd(0x8825) == {}
transposed = ImageOps.exif_transpose(im) transposed = ImageOps.exif_transpose(im)
exif = transposed.getexif() exif = transposed.getexif()
assert exif[0x8825] == {} assert exif.get_ifd(0x8825) == {}
# Assert that it was transposed # Assert that it was transposed
assert 0x0112 not in exif assert 0x0112 not in exif

View File

@ -3360,6 +3360,10 @@ class Exif(MutableMapping):
if ifd: if ifd:
merged_dict.update(ifd) merged_dict.update(ifd)
# GPS
if 0x8825 in self:
merged_dict[0x8825] = self._get_ifd_dict(self[0x8825])
return merged_dict return merged_dict
def tobytes(self, offset=8): def tobytes(self, offset=8):
@ -3371,7 +3375,7 @@ class Exif(MutableMapping):
head = b"MM\x00\x2A\x00\x00\x00\x08" head = b"MM\x00\x2A\x00\x00\x00\x08"
ifd = TiffImagePlugin.ImageFileDirectory_v2(ifh=head) ifd = TiffImagePlugin.ImageFileDirectory_v2(ifh=head)
for tag, value in self.items(): for tag, value in self.items():
if tag in [0x8769, 0x8225] and not isinstance(value, dict): if tag in [0x8769, 0x8225, 0x8825] and not isinstance(value, dict):
value = self.get_ifd(tag) value = self.get_ifd(tag)
if ( if (
tag == 0x8769 tag == 0x8769
@ -3491,8 +3495,6 @@ class Exif(MutableMapping):
def __getitem__(self, tag): def __getitem__(self, tag):
if self._info is not None and tag not in self._data and tag in self._info: if self._info is not None and tag not in self._data and tag in self._info:
self._data[tag] = self._fixup(self._info[tag]) self._data[tag] = self._fixup(self._info[tag])
if tag == 0x8825:
self._data[tag] = self.get_ifd(tag)
del self._info[tag] del self._info[tag]
return self._data[tag] return self._data[tag]