1--TEST--
2Test Imagick, getPixelIterator
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7?>
8--FILE--
9<?php
10
11
12function getPixelIterator() {
13    $imagick = new \Imagick();
14    $imagick->newPseudoImage(640, 480, "magick:logo");
15    $imageIterator = $imagick->getPixelIterator();
16
17    /** @noinspection PhpUnusedLocalVariableInspection */
18    foreach ($imageIterator as $row => $pixels) { /* Loop trough pixel rows */
19        foreach ($pixels as $column => $pixel) { /* Loop through the pixels in the row (columns) */
20            /** @var $pixel \ImagickPixel */
21            if ($column % 2) {
22                $pixel->setColor("rgba(0, 0, 0, 0)"); /* Paint every second pixel black*/
23            }
24        }
25        $imageIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
26    }
27
28    $bytes = $imagick;
29    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
30}
31
32getPixelIterator() ;
33echo "Ok";
34?>
35--EXPECTF--
36Ok