mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Allow "exif" to also accept bytestring
This commit is contained in:
parent
c0f619384c
commit
9707d33ed9
|
@ -444,10 +444,17 @@ class TestFileTiff:
|
||||||
|
|
||||||
im.save(outfile, exif=exif)
|
im.save(outfile, exif=exif)
|
||||||
|
|
||||||
|
outfile2 = str(tmp_path / "temp2.tif")
|
||||||
with Image.open(outfile) as im:
|
with Image.open(outfile) as im:
|
||||||
exif = im.getexif()
|
exif = im.getexif()
|
||||||
check_exif(exif)
|
check_exif(exif)
|
||||||
|
|
||||||
|
im.save(outfile2, exif=exif.tobytes())
|
||||||
|
|
||||||
|
with Image.open(outfile2) as im:
|
||||||
|
exif = im.getexif()
|
||||||
|
check_exif(exif)
|
||||||
|
|
||||||
def test_exif_frames(self):
|
def test_exif_frames(self):
|
||||||
# Test that EXIF data can change across frames
|
# Test that EXIF data can change across frames
|
||||||
with Image.open("Tests/images/g4-multi.tiff") as im:
|
with Image.open("Tests/images/g4-multi.tiff") as im:
|
||||||
|
|
|
@ -1515,7 +1515,16 @@ def _save(im, fp, filename):
|
||||||
ifd[IMAGELENGTH] = im.size[1]
|
ifd[IMAGELENGTH] = im.size[1]
|
||||||
|
|
||||||
# write any arbitrary tags passed in as an ImageFileDirectory
|
# write any arbitrary tags passed in as an ImageFileDirectory
|
||||||
info = im.encoderinfo.get("tiffinfo", im.encoderinfo.get("exif", {}))
|
if "tiffinfo" in im.encoderinfo:
|
||||||
|
info = im.encoderinfo["tiffinfo"]
|
||||||
|
elif "exif" in im.encoderinfo:
|
||||||
|
info = im.encoderinfo["exif"]
|
||||||
|
if isinstance(info, bytes):
|
||||||
|
exif = Image.Exif()
|
||||||
|
exif.load(info)
|
||||||
|
info = exif
|
||||||
|
else:
|
||||||
|
info = {}
|
||||||
logger.debug("Tiffinfo Keys: %s" % list(info))
|
logger.debug("Tiffinfo Keys: %s" % list(info))
|
||||||
if isinstance(info, ImageFileDirectory_v1):
|
if isinstance(info, ImageFileDirectory_v1):
|
||||||
info = info.to_v2()
|
info = info.to_v2()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user