Skip to content

Commit

Permalink
When IFD is missing, connect get_ifd() dictionary to Exif
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jul 13, 2024
1 parent 6a9acfa commit 9a3d4a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,14 @@ def test_empty_exif(self) -> None:
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"
)
Expand Down
4 changes: 3 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4073,7 +4073,9 @@ def get_ifd(self, tag):
else:
# Interop
self._ifds[tag] = self._get_ifd_dict(tag_data, tag)
ifd = self._ifds.get(tag, {})
if tag not in self._ifds:
self._ifds[tag] = {}
ifd = self._ifds[tag]
if tag == ExifTags.IFD.Exif and self._hidden_data:
ifd = {
k: v
Expand Down

0 comments on commit 9a3d4a6

Please sign in to comment.