go to bug id or search bugs for
From manual page: http://www.php.net/imagick.compositeimage
The script produces only black images regardless of the values passed by setImageArtifact.
imagick module version 3.4.0RC6
Imagick compiled with ImageMagick version ImageMagick 6.8.9-1 Q16 x86 2014-05-08 http://www.imagemagick.org
$im1 = new Imagick (realpath ("Waikare.jpg"));
$im2 = clone $im1;
$im1->setImageArtifact ("compose:args", "1,0,-0.5,0.5");
$im1->compositeImage ($im2, Imagick::COMPOSITE_MATHEMATICS, 0, 0);
$im1->writeImage (getcwd () . "/test.png");
echo "<img src=\"test.png\">";
Using the values 0,1,-1,0.5 a grey image should be produced.
Add a Patch
Add a Pull Request
Could you do me a favour and give the equivalent `convert` command?
this is going to be an issue that I'll need to report upstream to the ImageMagick guys.
The command as given on the man page:
convert src1.png src2.png -compose mathematics -define compose:args="1,0,-0.5,0.5" -composite output.png
works perfectly well with said version of Imagemagick (using two identical images, a somewhat brighter but greyed out image is obtained).
I think setting the compose:args on the second image, gives the expected result:
$im2->setImageArtifact ("compose:args", "1,0,-0.5,0.5");
Can you confirm?
That seems to work fine as in this script to emulate grain extract layer mode:
$im = new Imagick (realpath ("Paihia_Sunset.jpg"));
$ge = clone $im;
$ge->modulateImage (100, 0, 100);
$ge->blurImage (0, 15);
$ge->setImageArtifact ("compose:args", "0,-1,1,0.5");
$im->compositeImage ($ge, Imagick::COMPOSITE_MATHEMATICS, 0, 0);
Note that the two values in the middle apply to $ge (-1) and $im (+1) respectively. This is difficult to see from the imagemagick command line because the images have to be swapped.
If you were correcting the documentation, then the line about the virtual pixels can be removed. Perhaps that will make it clearer that the artifact has to be set on the composited object.
Finally why in a lot of the Imagick examples is Imagick written with a backslash in front of it? I've never found it necessary to escape "i" and "\i" has no particular significance. It just makes the examples harder to follow.
> Finally why in a lot of the Imagick examples is Imagick written with a backslash in front of it?
The 'Imagick' class exists in the global namespace. When used in a different namespace, you either need to do "use Imagick;" at the top of the file, or use `\Imagick` to escape from that namespace to the global one.
It seems I prefer to use slashes for classes for this case.