From 8e167914cde0d95853dd6ec53724cf2bb78628e1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 May 2024 09:27:48 +0530 Subject: [PATCH] Kindle output: Fix cover images that contain EXIF data but not an EXIF rotation not displaying on the Kindle lockscreen The code to strip EXIF would only do so if the EXIF actually had a rotation. Now we always strip the EXIF data. Fixes #1943495 [Lockscreen covers not shown on Kindle for JPEGs with EXIF information](https://bugs.launchpad.net/calibre/+bug/1943495) --- src/calibre/ebooks/mobi/writer2/resources.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/writer2/resources.py b/src/calibre/ebooks/mobi/writer2/resources.py index 592c1e6077..52c44e1f09 100644 --- a/src/calibre/ebooks/mobi/writer2/resources.py +++ b/src/calibre/ebooks/mobi/writer2/resources.py @@ -27,12 +27,14 @@ def process_jpegs_for_amazon(data: bytes) -> bytes: # Amazon's MOBI renderer can't render JPEG images without JFIF metadata # and images with EXIF data dont get displayed on the cover screen changed = not img.info + has_exif = False if hasattr(img, 'getexif'): exif = img.getexif() + has_exif = bool(exif) if exif.get(0x0112) in (2,3,4,5,6,7,8): changed = True img = ImageOps.exif_transpose(img) - if changed: + if changed or has_exif: out = BytesIO() img.save(out, 'JPEG') data = out.getvalue()