mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #6939 from radarhere/exif
Resolves https://github.com/python-pillow/Pillow/issues/6932
This commit is contained in:
commit
79765d5b9c
|
@ -270,7 +270,10 @@ class TestFileJpeg:
|
|||
# https://github.com/python-pillow/Pillow/issues/148
|
||||
f = str(tmp_path / "temp.jpg")
|
||||
im = hopper()
|
||||
im.save(f, "JPEG", quality=90, exif=b"1" * 65532)
|
||||
im.save(f, "JPEG", quality=90, exif=b"1" * 65533)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
im.save(f, "JPEG", quality=90, exif=b"1" * 65534)
|
||||
|
||||
def test_exif_typeerror(self):
|
||||
with Image.open("Tests/images/exif_typeerror.jpg") as im:
|
||||
|
|
|
@ -730,10 +730,10 @@ def _save(im, fp, filename):
|
|||
|
||||
extra = info.get("extra", b"")
|
||||
|
||||
MAX_BYTES_IN_MARKER = 65533
|
||||
icc_profile = info.get("icc_profile")
|
||||
if icc_profile:
|
||||
ICC_OVERHEAD_LEN = 14
|
||||
MAX_BYTES_IN_MARKER = 65533
|
||||
MAX_DATA_BYTES_IN_MARKER = MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN
|
||||
markers = []
|
||||
while icc_profile:
|
||||
|
@ -764,6 +764,9 @@ def _save(im, fp, filename):
|
|||
exif = info.get("exif", b"")
|
||||
if isinstance(exif, Image.Exif):
|
||||
exif = exif.tobytes()
|
||||
if len(exif) > MAX_BYTES_IN_MARKER:
|
||||
msg = "EXIF data is too long"
|
||||
raise ValueError(msg)
|
||||
|
||||
# get keyword arguments
|
||||
im.encoderconfig = (
|
||||
|
|
Loading…
Reference in New Issue
Block a user