How to set the trimming color in Imagick?

巧了我就是萌 提交于 2019-11-30 21:37:58

Matt Gibsons Hint led me to the right solution: http://www.imagemagick.org/Usage/crop/#trim_color

As Matt already explained the trim method takes the corner colors to trim the image. The given solution from the documentation is a workaround: They draw a border around the image before they call the trim method.

$img = new Imagick("stripes.gif"); 
// Set the color to trim:
$img->borderImage("#FF0000", 1, 1); 
$img->trimImage(0); 
$img->setImagePage(0, 0, 0, 0);
$img->writeImage("test.jpg");'

Have you tried specifying your background color as a hex code, rather than instantiating an ImagickPixel for it?

$im->setImageBackgroundColor( #D5D5D5 );
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!