mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Handle EXIF data truncated to just the header
This commit is contained in:
parent
5c1221f070
commit
07210e9425
|
@ -666,6 +666,19 @@ class TestImage:
|
|||
|
||||
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"
|
||||
)
|
||||
|
|
|
@ -3478,12 +3478,12 @@ class Exif(MutableMapping):
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user