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:
我正在使用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);
I've tried
我试过了
setBackgroundColor, setImageBackgroundColor, composite over a white image
And none of these seem to work. Any suggestions?
这些似乎都不起作用。有什么建议么?
1 个解决方案
#1
0
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:
jpg扩展名不支持后台透明度,您需要使用png。对于其他网站,如果您有一个带有写入背景的img,您可以使用以下代码将此颜色设置为透明:
$route = "MiOldJpgWriteBackground.jpg";
$salida = 'MiNewTransparentFile.png';
exec("convert $route $salida");
exec("convert $salida -bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 10% \
-fill none -floodfill +0+0 white \
-shave 1x1 $salida");
exec("rm $route");
#1
0
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:
jpg扩展名不支持后台透明度,您需要使用png。对于其他网站,如果您有一个带有写入背景的img,您可以使用以下代码将此颜色设置为透明:
$route = "MiOldJpgWriteBackground.jpg";
$salida = 'MiNewTransparentFile.png';
exec("convert $route $salida");
exec("convert $salida -bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 10% \
-fill none -floodfill +0+0 white \
-shave 1x1 $salida");
exec("rm $route");