PHP Imagick无法设置图像背景色 [英] PHP Imagick cannot set image background color
本文介绍了PHP Imagick无法设置图像背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我加载透明的png图像,每次我尝试使用setimagebackgroundcolor()
设置bg颜色时,它仍然是透明的
I load transparent png image and i every time i try to set bg color using setimagebackgroundcolor()
it still transparent
$input_img = new Imagick();
$input_img->setBackgroundColor("#ff0000");
$input_img->readImage("transparent.png");
$input_img->setimagebackgroundcolor("#00ff00");
$input_img->setImageFormat("png");
$input_img->setimagebackgroundcolor("#ff00ff");
$input_img->writeimage("image.png");
推荐答案
该技巧正在使用:$im = $im->flattenImages();
:
<?php
$im = new Imagick($filename);
$im->setImageBackgroundColor('#ffffff');
$im = $im->flattenImages();
$im->setImageFormat("jpeg");
$im->setImageCompressionQuality(95);
$im->writeImage($filename);
这篇关于PHP Imagick无法设置图像背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文