mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-27 20:43:43 +03:00
Merge pull request #6819 from radarhere/png_exif
Resolves https://github.com/python-pillow/Pillow/issues/6804
This commit is contained in:
commit
54eb83557f
|
@ -706,10 +706,18 @@ class TestFilePng:
|
||||||
assert exif[274] == 3
|
assert exif[274] == 3
|
||||||
|
|
||||||
def test_exif_save(self, tmp_path):
|
def test_exif_save(self, tmp_path):
|
||||||
|
# Test exif is not saved from info
|
||||||
|
test_file = str(tmp_path / "temp.png")
|
||||||
with Image.open("Tests/images/exif.png") as im:
|
with Image.open("Tests/images/exif.png") as im:
|
||||||
test_file = str(tmp_path / "temp.png")
|
|
||||||
im.save(test_file)
|
im.save(test_file)
|
||||||
|
|
||||||
|
with Image.open(test_file) as reloaded:
|
||||||
|
assert reloaded._getexif() is None
|
||||||
|
|
||||||
|
# Test passing in exif
|
||||||
|
with Image.open("Tests/images/exif.png") as im:
|
||||||
|
im.save(test_file, exif=im.getexif())
|
||||||
|
|
||||||
with Image.open(test_file) as reloaded:
|
with Image.open(test_file) as reloaded:
|
||||||
exif = reloaded._getexif()
|
exif = reloaded._getexif()
|
||||||
assert exif[274] == 1
|
assert exif[274] == 1
|
||||||
|
@ -720,7 +728,7 @@ class TestFilePng:
|
||||||
def test_exif_from_jpg(self, tmp_path):
|
def test_exif_from_jpg(self, tmp_path):
|
||||||
with Image.open("Tests/images/pil_sample_rgb.jpg") as im:
|
with Image.open("Tests/images/pil_sample_rgb.jpg") as im:
|
||||||
test_file = str(tmp_path / "temp.png")
|
test_file = str(tmp_path / "temp.png")
|
||||||
im.save(test_file)
|
im.save(test_file, exif=im.getexif())
|
||||||
|
|
||||||
with Image.open(test_file) as reloaded:
|
with Image.open(test_file) as reloaded:
|
||||||
exif = reloaded._getexif()
|
exif = reloaded._getexif()
|
||||||
|
|
|
@ -1383,7 +1383,7 @@ def _save(im, fp, filename, chunk=putchunk, save_all=False):
|
||||||
chunks.remove(cid)
|
chunks.remove(cid)
|
||||||
chunk(fp, cid, data)
|
chunk(fp, cid, data)
|
||||||
|
|
||||||
exif = im.encoderinfo.get("exif", im.info.get("exif"))
|
exif = im.encoderinfo.get("exif")
|
||||||
if exif:
|
if exif:
|
||||||
if isinstance(exif, Image.Exif):
|
if isinstance(exif, Image.Exif):
|
||||||
exif = exif.tobytes(8)
|
exif = exif.tobytes(8)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user