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)
This commit is contained in:
Kovid Goyal 2024-05-28 09:27:48 +05:30
parent 6d47a9760e
commit 8e167914cd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -27,12 +27,14 @@ def process_jpegs_for_amazon(data: bytes) -> bytes:
# Amazon's MOBI renderer can't render JPEG images without JFIF metadata # Amazon's MOBI renderer can't render JPEG images without JFIF metadata
# and images with EXIF data dont get displayed on the cover screen # and images with EXIF data dont get displayed on the cover screen
changed = not img.info changed = not img.info
has_exif = False
if hasattr(img, 'getexif'): if hasattr(img, 'getexif'):
exif = img.getexif() exif = img.getexif()
has_exif = bool(exif)
if exif.get(0x0112) in (2,3,4,5,6,7,8): if exif.get(0x0112) in (2,3,4,5,6,7,8):
changed = True changed = True
img = ImageOps.exif_transpose(img) img = ImageOps.exif_transpose(img)
if changed: if changed or has_exif:
out = BytesIO() out = BytesIO()
img.save(out, 'JPEG') img.save(out, 'JPEG')
data = out.getvalue() data = out.getvalue()