将现有图像(8位,32位等)转换为php

时间:2015-07-27 17:09:56

标签: php imagemagick png

如何将现有的png图像转换为24位png图像。

现有图像可以是8位,16位,32位,48位或64位。我想用24位png图像转换它们。

我使用php在我的localhost(Window 7)上尝试了imagemagick 以下是我试过的命令。

shell_exec('C:\\imagemagick\\convert -depth 24 sentences.png sentences2.png');

shell_exec('C:\\imagemagick\\convert sentences.png -transparent white png24:sentences2.png');

以上都不适合我。以上脚本以随机位深度转换图像。例如,如果sentences.png是8位深度,则在转换后它变为32位。类似地,对于其他图像,它变为32位,有时48位等。

如何正确实现从任何png到24位png的转换?

1 个答案:

答案 0 :(得分:0)

您可以像这样使用Imagick PHP函数:

$imagick_image = new Imagick($image_filename);
$imagick_image->writeImage("png24:$image_filename");
相关问题