From 4303db417a2a1a4beb19d6a7f6bb1fff87afed3e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 9 May 2016 19:39:36 +0530 Subject: [PATCH] Dont refuse to process images that are already quantized --- src/calibre/utils/imageops/quantize.cpp | 1 - src/calibre/utils/img.py | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/calibre/utils/imageops/quantize.cpp b/src/calibre/utils/imageops/quantize.cpp index e9e211568f..c42ee0d8d4 100644 --- a/src/calibre/utils/imageops/quantize.cpp +++ b/src/calibre/utils/imageops/quantize.cpp @@ -370,7 +370,6 @@ QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, c root.check_compiler(); maximum_colors = MAX(2, MIN(MAX_COLORS, maximum_colors)); - if (img.colorCount() > 0 && (size_t)img.colorCount() <= maximum_colors) return img; // Image is already quantized if (img.hasAlphaChannel()) throw std::out_of_range("Cannot quantize image with transparency"); if (fmt != QImage::Format_RGB32 && fmt != QImage::Format_Indexed8) { img = img.convertToFormat(QImage::Format_RGB32); diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py index 4f2c8d9fe3..0afd0371a3 100644 --- a/src/calibre/utils/img.py +++ b/src/calibre/utils/img.py @@ -282,9 +282,7 @@ def quantize(img, max_colors=256, dither=True, palette=''): default a palette is chosen automatically, if you want to use a fixed palette, then pass in a list of color names in the `palette` variable. If you, specify a palette `max_colors` is ignored. Note that it is possible - for the actual number of colors used to be less than max_colors. Also, if - the input image is already indexed and has fewer than max_colors, this function - will do nothing. + for the actual number of colors used to be less than max_colors. :param max_colors: Max. number of colors in the auto-generated palette. Must be between 2 and 256. :param dither: Whether to use dithering or not. dithering is almost always a good thing.