When IFD is missing, connect get_ifd() dictionary to Exif

This commit is contained in:
Andrew Murray 2024-07-13 12:46:15 +10:00
parent 6a9acfa5ca
commit 42bfcaa2d4
2 changed files with 9 additions and 1 deletions

View File

@ -769,6 +769,14 @@ class TestImage:
exif.load(b"Exif\x00\x00")
assert not dict(exif)
def test_empty_get_ifd(self) -> None:
exif = Image.Exif()
ifd = exif.get_ifd(0x8769)
assert ifd == {}
ifd[36864] = b"0220"
assert exif.get_ifd(0x8769) == {36864: b"0220"}
@mark_if_feature_version(
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
)

View File

@ -4073,7 +4073,7 @@ class Exif(_ExifBase):
else:
# Interop
self._ifds[tag] = self._get_ifd_dict(tag_data, tag)
ifd = self._ifds.get(tag, {})
ifd = self._ifds.setdefault(tag, {})
if tag == ExifTags.IFD.Exif and self._hidden_data:
ifd = {
k: v