From 817f7aba605f3b045a356375a85feb76e3e37674 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 15 Mar 2012 20:03:46 +0530 Subject: [PATCH] MOBI Output: Fix a regression that caused the generated thumbnail embedded in calibre produced MOBI files to be a large, low quality image instead of a small, high quality image. Fixes #954254 (No book covers in Kindle for Android 3.4.2) --- src/calibre/ebooks/mobi/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/utils.py b/src/calibre/ebooks/mobi/utils.py index 108c79b5fd..6ec86f77ee 100644 --- a/src/calibre/ebooks/mobi/utils.py +++ b/src/calibre/ebooks/mobi/utils.py @@ -124,12 +124,18 @@ def rescale_image(data, maxsizeb=IMAGE_MAX_SIZE, dimen=None): to JPEG. Ensure the resultant image has a byte size less than maxsizeb. - If dimen is not None, generate a thumbnail of width=dimen, height=dimen + If dimen is not None, generate a thumbnail of + width=dimen, height=dimen or width, height = dimen (depending on the type + of dimen) Returns the image as a bytestring ''' if dimen is not None: - data = thumbnail(data, width=dimen, height=dimen, + if hasattr(dimen, '__len__'): + width, height = dimen + else: + width = height = dimen + data = thumbnail(data, width=width, height=height, compression_quality=90)[-1] else: # Replace transparent pixels with white pixels and convert to JPEG