I tried to reduce a 300,000 color PNG image to 100,000 with Imagick::quantizeImage
, but it becomes about 65,000 colors.
Can't you get more than 65,000 colors?
PHP version: 7.1.27
Imagick module version: 3.4.3
reference: https://www.php.net/manual/en/imagick.quantizeimage.php
I tried to put various values for $colorspace
and $treedepth
as arguments, but it was only about 65,000 colors at most.
$img = new \Imagick('/path/to/300000-colors-image.png');
$img->quantizeImage(100000, \Imagick::COLORSPACE_SRGB, 0, false, false);
$img->writeImage('/path/to/result.png');
$img->clear();
$img->destroy();
// Confirm the result
$img = new \Imagick('/path/to/result.png');
// Expected: 100,000
// Actual: 65,000
echo $img->getImageColors();
$img->clear();
$img->destroy();