Guys. I didn't mean to offend anybody. This is Imagick section of the forum. This is why I asked here.
Maybe I misunderstood, but combine.exe command was replaced with composite.exe. Am I right?
Those commands I would like to convert to Imagick.
composite.exe -compose over input.jpg over.
gif black&white_mask.gif output.jpg
and
composite.exe -compose over input.jpg over.
jpg black&white_mask.gif output.jpg
Images are the same geometry. In both cases I would like to transform input and over images through b&w mask.
Black color from the mask should be replaced with the same part from over image.
White color from the mask should be replaced withthe same part from input image.
I'm trying to write equivalent code in Imagick.
Code: Select all
try {
$baseObj = new Imagick($input);
$overObj = new Imagick($overlay);
$maskObj = new Imagick($mask);
$maskObj->setImageColorspace(imagick::COLORSPACE_GRAY);
$baseObj->compositeImage($maskObj, Imagick::COMPOSITE_SCREEN, 0, 0);
$maskObj->negateImage(1);
if ($baseObj->getImageFormat() == 'GIF') {
$overObj->compositeImage($maskObj, Imagick::COMPOSITE_SCREEN, 0, 0);
}
$baseObj->compositeImage($overObj, Imagick::COMPOSITE_MULTIPLY, 0, 0);
$baseObj->writeImage($output);
$baseObj->destroy();
$maskObj->destroy();
$overObj->destroy();
}
catch(Exception $e) {
echo "Caught Imagick exception: " . $e->getMessage() . ".\n";
}
This is result of my today's struggling. It looks it does almost what I need. Could anybody suggest what can be done in better way?
I use ImageMagick 6.7.9-4 Q8 and Imagick 3.1.0RC2 and RC1.