Imagick - 将 PNG 转换为 JPG,透明背景变成黑色
我希望我的背景最终变成白色。我查看了其他问题,但似乎没有一个答案能够真正解决这个问题。
我正在使用 Imagick 2.3 版,这就是我所拥有的:
$this->_object = new Imagick();
$this->_object->setResolution(300, 300);
$this->_object->readImage($fileRead);
$this->_object->setImageMatte(true);
$this->_object->setImageMatteColor("white");
$this->_object->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);
我已经尝试过了
setBackgroundColor, setImageBackgroundColor, composite over a white image
,但这些似乎都不起作用。有什么建议吗?
And I want my background to end up white instead. I've taken a look at the other questions and none of the answers seemed to really solve this problem.
I'm using Imagick version 2.3, and here's what I have:
$this->_object = new Imagick();
$this->_object->setResolution(300, 300);
$this->_object->readImage($fileRead);
$this->_object->setImageMatte(true);
$this->_object->setImageMatteColor("white");
$this->_object->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);
I've tried
setBackgroundColor, setImageBackgroundColor, composite over a white image
And none of these seem to work. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jpg 扩展名不支持背景透明,您需要使用 png。对于其他网站,如果您有一个带有写入背景的 img,您可以使用以下代码将此颜色设置为透明:
The jpg extension doesn't support transparency in background, you will need use png. For other site if you have for example one img with write background you could set this color in transparent with this code: