dtwknzk3764 2019-04-12 11:18
浏览 264

如何使用Imagick :: quantizeImage将300,000色PNG图像减少到100,000种颜色?

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();
  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?