Need help porting IM docs mask example command to Imagick

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
SkipperMcNally

Need help porting IM docs mask example command to Imagick

Post by SkipperMcNally »

I am trying to use a variant of the second masking example cited in the ImageMagick docs: http://www.imagemagick.org/Usage/channels/#masks.

The command I'm using is:

Code: Select all

convert input.jpg -negate -background White -channel A -combine output.png
which basically creates sort of a transparent white solarized image when a photograph is used as input.

I have tried the following with no luck, it just creates a negative:

Code: Select all

$src = new Imagick("input.jpg");
$src->setImageFormat("png");
$src->negateImage(false);
$src->setBackgroundColor(new ImagickPixel("White"));
$src->combineImages(Imagick::CHANNEL_ALPHA);
$src->writeImage(output.png);
Any help would be greatly appreciated.
Post Reply