php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71524 Produces only black image
Submitted: 2016-02-04 18:22 UTC Modified: 2016-02-07 02:15 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: lee dot traynor at skeptic dot de Assigned: danack (profile)
Status: Assigned Package: imagick (PECL)
PHP Version: 5.5.32 OS: Windows XP/7/8/10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-02-04 18:22 UTC] lee dot traynor at skeptic dot de
Description:
------------
---
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 

Test script:
---------------
$im1 = new Imagick (realpath ("Waikare.jpg"));
$im2 = clone $im1;
$im1->setImageVirtualPixelMethod (Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$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\">";


Expected result:
----------------
Using the values 0,1,-1,0.5 a grey image should be produced.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-05 20:56 UTC] danack@php.net
-Assigned To: +Assigned To: danack
 [2016-02-05 20:56 UTC] danack@php.net
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.
 [2016-02-05 21:05 UTC] lee dot traynor at skeptic dot de
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).
 [2016-02-06 12:53 UTC] danack@php.net
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?
 [2016-02-06 18:43 UTC] lee dot traynor at skeptic dot de
-Type: Bug +Type: Documentation Problem
 [2016-02-06 18:43 UTC] lee dot traynor at skeptic dot de
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.

Best, Lee
 [2016-02-07 02:15 UTC] danack@php.net
> 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.

http://php.net/manual/en/language.namespaces.basics.php

It seems I prefer to use slashes for classes for this case.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC