Dont refuse to process images that are already quantized

This commit is contained in:
Kovid Goyal 2016-05-09 19:39:36 +05:30
parent e8ea227733
commit 4303db417a
2 changed files with 1 additions and 4 deletions

View File

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

View File

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