diff --git a/src/calibre/utils/imageops/imageops.sip b/src/calibre/utils/imageops/imageops.sip index d76c6b2a99..4bfc05a11a 100644 --- a/src/calibre/utils/imageops/imageops.sip +++ b/src/calibre/utils/imageops/imageops.sip @@ -73,10 +73,12 @@ QImage oil_paint(const QImage &image, const float radius=-1, const bool high_qua sipRes = new QImage(oil_paint(*a0, a1, a2)); IMAGEOPS_SUFFIX %End -QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, const QVector &palette); +QImage quantize(const QImage &image, unsigned int maximum_colors, bool dither, SIP_PYTUPLE); %MethodCode + QVector palette(PyTuple_GET_SIZE(a3)); + for (int i = 0; i < PyTuple_GET_SIZE(a3); i++) palette[i] = PyLong_AsUnsignedLong(PyTuple_GET_ITEM(a3, i)); IMAGEOPS_PREFIX - sipRes = new QImage(quantize(*a0, a1, a2, *a3)); + sipRes = new QImage(quantize(*a0, a1, a2, palette)); IMAGEOPS_SUFFIX %End diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py index 85049d99bb..e4b5d54123 100644 --- a/src/calibre/utils/img.py +++ b/src/calibre/utils/img.py @@ -503,7 +503,7 @@ def quantize_image(img, max_colors=256, dither=True, palette=''): img = blend_image(img) if palette and isinstance(palette, string_or_bytes): palette = palette.split() - return imageops.quantize(img, max_colors, dither, [QColor(x).rgb() for x in palette]) + return imageops.quantize(img, int(max_colors), dither, tuple(QColor(x).rgb() for x in palette)) def eink_dither_image(img):