Skip to content

Commit

Permalink
Use quantization method attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Mar 22, 2021
1 parent aa35f6b commit 5623afc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/PIL/Image.py
Expand Up @@ -1074,11 +1074,14 @@ def quantize(self, colors=256, method=None, kmeans=0, palette=None, dither=1):

if method is None:
# defaults:
method = 0
method = Image.MEDIANCUT
if self.mode == "RGBA":
method = 2
method = Image.FASTOCTREE

if self.mode == "RGBA" and method not in (2, 3):
if self.mode == "RGBA" and method not in (
Image.FASTOCTREE,
Image.LIBIMAGEQUANT,
):
# Caller specified an invalid mode.
raise ValueError(
"Fast Octree (method == 2) and libimagequant (method == 3) "
Expand Down

0 comments on commit 5623afc

Please sign in to comment.