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)

This commit is contained in:
Kovid Goyal 2012-03-15 20:03:46 +05:30
parent 46f9a5b04a
commit 817f7aba60

View File

@ -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 to JPEG. Ensure the resultant image has a byte size less than
maxsizeb. 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 Returns the image as a bytestring
''' '''
if dimen is not None: 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] compression_quality=90)[-1]
else: else:
# Replace transparent pixels with white pixels and convert to JPEG # Replace transparent pixels with white pixels and convert to JPEG