php - Imagick - Make black background white -


i using following code mask 1 image on image.on output gives me image black backgroung.

but need white background or transparent background.

following code using mask 1 image on another.

<?php $destination_path = getcwd().directory_separator; $im1="image1.png"; $im2="image2.png";  $i1="$destination_path$im1"; $i2="$destination_path$im2";  $base = new imagick($i1); $mask = new imagick($i2);  // setting same size images $base->resizeimage(274, 275, imagick::filter_lanczos, 1);  // copy opacity mask $base->compositeimage($mask, imagick::composite_dstin, 0, 0, imagick::channel_alpha);  $base->writeimage('output.png'); header("content-type: image/png");  echo $base; ?> 

the trick using: $im = $im->flattenimages();:

<?php $im = new imagick($filename);  $im->setimagebackgroundcolor('#ffffff'); $im = $im->flattenimages();  $im->setimageformat("jpeg"); $im->setimagecompressionquality(95); $im->writeimage($filename); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -