diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py index 6d2634c257..739f7cd225 100644 --- a/src/calibre/utils/img.py +++ b/src/calibre/utils/img.py @@ -282,7 +282,10 @@ def normalize(img): def quantize(img, num_of_colors=256, dither=True): if imageops is None: raise RuntimeError(imageops_err) - return imageops.quantize(image_from_data(img), num_of_colors, dither) + img = image_from_data(img) + if img.hasAlphaChannel(): + img = blend_image(img) + return imageops.quantize(img, num_of_colors, dither) def run_optimizer(file_path, cmd, as_filter=False, input_data=None): file_path = os.path.abspath(file_path)