Skip to content

[imagick] Document Imagick::quantizeImage() and Imagick::quantizeImages() - #61

Merged
jordikroon merged 1 commit into
php:mainfrom
officialasishkumar:docs/imagick-quantize-image
Nov 28, 2026
Merged

jordikroon merged 1 commit into
php:mainfrom
officialasishkumar:docs/imagick-quantize-image

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

The Imagick::quantizeImage() and Imagick::quantizeImages() pages said these methods "analyze the colors" of an image. That's misleading, because nothing is returned: they reduce the number of colors in the image(s). All of the parameter descriptions were empty too.

Based on the MagickQuantizeImage()/QuantizeImage() implementation in ImageMagick, this change:

  • fixes the purpose line of both methods and adds a description. It explains that quantizeImages() picks one set of colors shared by every image in the sequence, while quantizeImage() only works on the current image;
  • documents numberColors: 0, or a value above the maximum colormap size, means the maximum colormap size;
  • documents colorspace, with a link to the COLORSPACE constants;
  • documents treedepth: 0 computes an optimal depth, and other values are clamped to 2–8;
  • documents dither and measureError;
  • adds a caution about dither with ImageMagick 7. Imagick passes the boolean straight through as the DitherMethod argument, so true becomes NoDitherMethod and false becomes UndefinedDitherMethod, which ImageMagick handles as Floyd-Steinberg dithering. In other words, the flag works the opposite way, as pointed out in the issue.

Fixes #30

…es()

The pages described these methods as "analyzing the colors" of an image,
which is misleading since nothing is returned: the methods reduce the
number of colors of the image(s). All parameter descriptions were also
empty.

Based on the MagickQuantizeImage()/QuantizeImage() implementation in
ImageMagick:

- fix the purpose of both methods, and add a description explaining
  that quantizeImages() chooses a single set of colors shared by all
  the images of the sequence, unlike quantizeImage();
- document numberColors (0 means the maximum colormap size),
  colorspace, treedepth (0 computes an optimal depth, other values are
  clamped to 2-8), dither and measureError;
- add a caution that with ImageMagick 7 the dither flag is passed as a
  DitherMethod, so true maps to NoDitherMethod and false to
  UndefinedDitherMethod, which results in Floyd-Steinberg dithering,
  i.e. the meaning of the flag is inverted.

Fixes php#30

@jordikroon jordikroon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jordikroon
jordikroon merged commit fa2cffa into php:main Nov 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quantizeImage/quantizeImages details incorrect/lacking

2 participants