1--TEST--
2Test Imagick, colorMatrixImage
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7checkFormatPresent('png');
8?>
9--FILE--
10<?php
11
12$colorMatrix = array (
13  0 => 1.5,
14  1 => 0,
15  2 => 0,
16  3 => 0,
17  4 => -0.157,
18  5 => 0,
19  6 => 1,
20  7 => 0.5,
21  8 => 0,
22  9 => -0.157,
23  10 => 0,
24  11 => 0,
25  12 => 0.5,
26  13 => 0,
27  14 => 0.5,
28  15 => 0,
29  16 => 0,
30  17 => 0,
31  18 => 1,
32  19 => 0,
33  20 => 0,
34  21 => 0,
35  22 => 0,
36  23 => 0,
37  24 => 1,
38);
39
40function colorMatrixImage($colorMatrix) {
41    $imagick = new \Imagick();
42    $imagick->newPseudoImage(640, 480, "magick:logo");
43    //$imagick->setImageOpacity(1);
44
45    //A color matrix should look like:
46    //    $colorMatrix = [
47    //        1.5, 0.0, 0.0, 0.0, 0.0, -0.157,
48    //        0.0, 1.0, 0.5, 0.0, 0.0, -0.157,
49    //        0.0, 0.0, 1.5, 0.0, 0.0, -0.157,
50    //        0.0, 0.0, 0.0, 1.0, 0.0,  0.0,
51    //        0.0, 0.0, 0.0, 0.0, 1.0,  0.0,
52    //        0.0, 0.0, 0.0, 0.0, 0.0,  1.0
53    //    ];
54
55    $background = new \Imagick();
56    $background->newPseudoImage($imagick->getImageWidth(), $imagick->getImageHeight(),  "pattern:checkerboard");
57
58    $background->setImageFormat('png');
59
60    $imagick->setImageFormat('png');
61    $imagick->colorMatrixImage($colorMatrix);
62
63    $background->compositeImage($imagick, \Imagick::COMPOSITE_ATOP, 0, 0);
64
65    $bytes = $background->getImageBlob();
66    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
67}
68
69colorMatrixImage($colorMatrix) ;
70echo "Ok";
71?>
72--EXPECTF--
73Ok