mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Quantize transparent images by blending with white
This commit is contained in:
parent
41ee48fe53
commit
dbf7afa084
@ -282,7 +282,10 @@ def normalize(img):
|
|||||||
def quantize(img, num_of_colors=256, dither=True):
|
def quantize(img, num_of_colors=256, dither=True):
|
||||||
if imageops is None:
|
if imageops is None:
|
||||||
raise RuntimeError(imageops_err)
|
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):
|
def run_optimizer(file_path, cmd, as_filter=False, input_data=None):
|
||||||
file_path = os.path.abspath(file_path)
|
file_path = os.path.abspath(file_path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user