i cant use flatternImages() function becouse it's deprecated.
I must use
$im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE);
$im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
But ALPHACHANNEL_REMOVE constant is undefined.
How can i solve this issue?
P.S. I tried to use 11 instead \Imagick::ALPHACHANNEL_REMOVE and get error:
"Unable to set image alpha channel"
According to this answer on php.net you must be using an ImageMagick version prior to 3.2.0b2.
At this point, you can either upgrade to the latest version of the library or use the value assigned to the constant Imagick::ALPHACHANNEL_REMOVE
(which is 11
):
$im->setImageBackgroundColor('white');
$im->setImageAlphaChannel(11); // Imagick::ALPHACHANNEL_REMOVE
$im->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With