douleng3463 2015-12-31 21:30
浏览 103

使用Imagick重新调整大小的PNG是黑色的... PHP中缺少的步骤是什么?

When I use Imagick in PHP to resize PNG images, the output images are black. This is not the case when I resize JPGs; the PHP procedure (provided below) works perfectly for JPGs, so I suspect there's a missing step when processing PNG files.

I've first tested the conversion using ImageMagick on my local computer using this command:

convert x.png -resize 528 -filter Lanczos x-resized.png

...and it works; the resulting PNG file displays and is resized appropriately.

However, when I attempt to do the same on my server (both localhost and live), the result is a black image.

The PHP code I'm using is:

$source = "x.png" // I provide the complete path in my routine, etc.
$destination = "x-resized.png" // likewise.

$im = new Imagick();
$im->readImage($source);
$im->setImageFormat("png");
$im->resizeImage(528, null, Imagick::FILTER_LANCZOS, 1);
$im->writeImage($destination);
$im->clear();

What am I doing incorrectly?

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 用visual studi code完成html页面
    • ¥15 聚类分析或者python进行数据分析
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?