note 116956 added to imagick.flattenimages
| From: | A.Ross | Date: | Thu, 26 Mar 2015 13:44:53 +0000 |
| Subject: | note 116956 added to imagick.flattenimages | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202045@lists.php.net to get a copy of this message | ||
Replying to Francois:
<?php
$im->setImageBackgroundColor('white');
$im->setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE);
$im->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
?>
Imagick::ALPHACHANNEL_REMOVE has been added in 3.2.0b2 (before the RC): http://pecl.php.net/package-info.php?package=imagick&version=3.2.0b2
The problem is with people who want to implement this, but are stuck with an Imagick version <
3.2.0b2. They can't use this constant. However, all is not lost. I've found a reference
where someone got this to work using an integer: http://stackoverflow.com/q/28154179/1000608
The number he used is 11, which seems to suggest that the value of Imagick::ALPHACHANNEL_REMOVE is
11, and the function worked correctly in this usecase even before the constant was implemented. So
if you're stuck with <3.2.0b2 this is the code you need:
<?php
$im->setImageBackgroundColor('white');
$im->setImageAlphaChannel(11);
$im->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
?>
This works at least as far back as version 3.1.0~rc1-1 (current version of the php5-imagick package
in Debian 7).
----
Server IP: 72.52.91.14
Probable Submitter: 37.153.219.193
----
Manual Page -- http://php.net/manual/en/imagick.flattenimages.php
Edit -- https://master.php.net/note/edit/116956
Del: integrated -- https://master.php.net/note/delete/116956/integrated
Del: useless -- https://master.php.net/note/delete/116956/useless
Del: bad code -- https://master.php.net/note/delete/116956/bad+code
Del: spam -- https://master.php.net/note/delete/116956/spam
Del: non-english -- https://master.php.net/note/delete/116956/non-english
Del: in docs -- https://master.php.net/note/delete/116956/in+docs
Del: other reasons-- https://master.php.net/note/delete/116956
Reject -- https://master.php.net/note/reject/116956
Search -- https://master.php.net/manage/user-notes.php