1--TEST--
2Test ImagickPixelIterator, resetIterator
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7?>
8--FILE--
9<?php
10
11
12function resetIterator() {
13
14    $imagick = new \Imagick();
15    $imagick->newPseudoImage(640, 480, "magick:logo");
16
17    $imageIterator = $imagick->getPixelIterator();
18
19    /* Loop trough pixel rows */
20    foreach ($imageIterator as $pixels) {
21        /* Loop through the pixels in the row (columns) */
22        foreach ($pixels as $column => $pixel) {
23            /** @var $pixel \ImagickPixel */
24            if ($column % 2) {
25
26                /* Make every second pixel 25% red*/
27                $pixel->setColorValue(\Imagick::COLOR_RED, 64);
28            }
29        }
30        /* Sync the iterator, this is important to do on each iteration */
31        $imageIterator->syncIterator();
32    }
33
34    $imageIterator->resetiterator();
35
36    /* Loop trough pixel rows */
37    foreach ($imageIterator as $pixels) {
38        /* Loop through the pixels in the row (columns) */
39        foreach ($pixels as $column => $pixel) {
40            /** @var $pixel \ImagickPixel */
41            if ($column % 3) {
42                $pixel->setColorValue(\Imagick::COLOR_BLUE, 64); /* Make every second pixel a little blue*/
43                //$pixel->setColor("rgba(0, 0, 128, 0)"); /* Paint every second pixel black*/
44            }
45        }
46        $imageIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
47    }
48
49    $imageIterator->clear();
50
51    $bytes = $imagick;
52    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
53}
54
55resetIterator() ;
56echo "Ok";
57?>
58--EXPECTF--
59Ok