Skip to content

Commit

Permalink
Merge pull request #6124 from radarhere/exif
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Mar 23, 2022
2 parents a921fcb + 07210e9 commit 3cce863
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Tests/test_image.py
Expand Up @@ -666,6 +666,19 @@ def act(fp):

assert not fp.closed

def test_empty_exif(self):
with Image.open("Tests/images/exif.png") as im:
exif = im.getexif()
assert dict(exif) != {}

# Test that exif data is cleared after another load
exif.load(None)
assert dict(exif) == {}

# Test loading just the EXIF header
exif.load(b"Exif\x00\x00")
assert dict(exif) == {}

@mark_if_feature_version(
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
)
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/Image.py
Expand Up @@ -3485,12 +3485,12 @@ def load(self, data):
self._loaded_exif = data
self._data.clear()
self._ifds.clear()
if data and data.startswith(b"Exif\x00\x00"):
data = data[6:]
if not data:
self._info = None
return

if data.startswith(b"Exif\x00\x00"):
data = data[6:]
self.fp = io.BytesIO(data)
self.head = self.fp.read(8)
# process dictionary
Expand Down

0 comments on commit 3cce863

Please sign in to comment.