Transparent to white in Imagick for PHP

后端 未结 10 1647
暗喜
暗喜 2020-12-16 11:58

I have a png image with a transparent background and I want to convert it to a jpg image with a white background.

The code is basically this:

$image          


        
10条回答
  •  独厮守ぢ
    2020-12-16 12:46

    Try the following, it works for me:

    $im = new Imagick('trans.png');
    $im->setimagebackgroundcolor('white');
    $im = $im->flattenimages();
    
    $im->writeimage('transToWhite.jpg');
    

    Hope that helps!

提交回复
热议问题