From ab56edb49f30557eb684256a1e3064936b737ecf Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 22 Mar 2021 19:18:36 +1100 Subject: [PATCH 1/2] Documented default quantization method --- docs/reference/Image.rst | 6 +++--- src/PIL/Image.py | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index c4e8f37a3..bf173ace9 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -486,15 +486,15 @@ Used to specify the quantization method to use for the :meth:`~Image.quantize` m .. data:: MEDIANCUT - Median cut + Median cut. Default method, except for RGBA images. .. data:: MAXCOVERAGE - Maximum coverage + Maximum coverage. .. data:: FASTOCTREE - Fast octree + Fast octree. Default method for RGBA images. .. data:: LIBIMAGEQUANT diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 2e7abfb68..bec6f3f64 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1059,6 +1059,11 @@ class Image: :data:`LIBIMAGEQUANT` (libimagequant; check support using :py:func:`PIL.features.check_feature` with ``feature="libimagequant"``). + + By default, :data:`MEDIANCUT` will be used. + + The exception to this is RGBA images. RGBA images use + :data:`FASTOCTREE` by default instead. :param kmeans: Integer :param palette: Quantize to the palette of given :py:class:`PIL.Image.Image`. From 0ff987917116d5b859959b1dc80092f7fdffac0f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 22 Mar 2021 19:21:31 +1100 Subject: [PATCH 2/2] Document supported quantization methods for RGBA images --- docs/reference/Image.rst | 5 +++-- src/PIL/Image.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index bf173ace9..2f4c9af99 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -486,11 +486,12 @@ Used to specify the quantization method to use for the :meth:`~Image.quantize` m .. data:: MEDIANCUT - Median cut. Default method, except for RGBA images. + Median cut. Default method, except for RGBA images. This method does not support + RGBA images. .. data:: MAXCOVERAGE - Maximum coverage. + Maximum coverage. This method does not support RGBA images. .. data:: FASTOCTREE diff --git a/src/PIL/Image.py b/src/PIL/Image.py index bec6f3f64..0bfd1da80 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1062,8 +1062,9 @@ class Image: By default, :data:`MEDIANCUT` will be used. - The exception to this is RGBA images. RGBA images use - :data:`FASTOCTREE` by default instead. + The exception to this is RGBA images. :data:`MEDIANCUT` and + :data:`MAXCOVERAGE` do not support RGBA images, so + :data:`FASTOCTREE` is used by default instead. :param kmeans: Integer :param palette: Quantize to the palette of given :py:class:`PIL.Image.Image`.