From 071bc7ca82d745ff2b8ce6deb67a7323ecb2647d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kerbiriou?= Date: Fri, 11 Oct 2024 05:12:01 +0200 Subject: [PATCH] don't store empty exif profiles (forcing the use of JXL container) (#77) Image.getexif().tobytes() always returns a non empty string. The truth value of the Exif object should be used instead. --- pillow_jxl/JpegXLImagePlugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pillow_jxl/JpegXLImagePlugin.py b/pillow_jxl/JpegXLImagePlugin.py index 705f557..3579c13 100644 --- a/pillow_jxl/JpegXLImagePlugin.py +++ b/pillow_jxl/JpegXLImagePlugin.py @@ -130,7 +130,10 @@ def _save(im, fp, filename, save_all=False): with open(im.filename, "rb") as f: data = enc(f.read(), im.width, im.height, jpeg_encode=True) else: - exif = info.get("exif", im.getexif().tobytes()) + exif = info.get("exif") + if exif is None: + exif = im.getexif() + exif = exif.tobytes() if exif else None if exif and exif.startswith(b"Exif\x00\x00"): exif = exif[6:] metadata = {