| | 404 | def quantize(self, colors, colorspace=None, tree_depth=1, dither=False, measure_error=False): |
|---|
| | 405 | ''' Limit the colours present in an image to a fixed amount. |
|---|
| | 406 | |
|---|
| | 407 | colors - The number of colors in the new image. |
|---|
| | 408 | colorspace - Perform color reduction in this colorspace, defaults to the image's colorspace. |
|---|
| | 409 | tree_depth - Default is to choose an optimal tree depth of |
|---|
| | 410 | Log4(colors). A tree of this depth generally allows |
|---|
| | 411 | the best representation of the reference image with |
|---|
| | 412 | the least amount of memory and the fastest |
|---|
| | 413 | computational speed. In some cases, such as an image |
|---|
| | 414 | with low color dispersion (a few number of colors), a |
|---|
| | 415 | value other than Log4(number_colors) is required. To |
|---|
| | 416 | expand the color tree completely, use a value of 8. |
|---|
| | 417 | dither - If True, the image is dithered. Defaults to False. |
|---|
| | 418 | measure_error - If True, measures the difference between the |
|---|
| | 419 | original and quantized images as an error. |
|---|
| | 420 | Defaults to False.''' |
|---|
| | 421 | |
|---|
| | 422 | if not colorspace: |
|---|
| | 423 | colorspace = self.colorspace |
|---|
| | 424 | |
|---|
| | 425 | self._check_wand_error(api.MagickQuantizeImage(self._wand, colors, colorspace, tree_depth, dither, measure_error)) |
|---|