Quantize transparent images by blending with white

This commit is contained in:
Kovid Goyal 2016-05-08 15:51:20 +05:30
parent 41ee48fe53
commit dbf7afa084

View File

@ -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)