The ImagickPixelIterator::getPreviousIteratorRow() function is an inbuilt function in PHP which is used to get the previous row as an array of pixel wands from the pixel iterator.
Syntax:
array ImagickPixelIterator::getPreviousIteratorRow( void )
Parameters: This function doesn’t accepts any parameters.
Return Value: This function returns an array value containing ImagickPixel objects.
Below programs illustrate the ImagickPixelIterator::getPreviousIteratorRow() function in PHP:
Program 1:
<?php // Create a new imagick object $imagick = new Imagick( // Get the pixel iterator $pixelIterator = $imagick->getPixelIterator(); // Set the pixel iterator to 50 $pixelIterator->setIteratorRow(50); // Move one step to previous row $pixelIterator->getPreviousIteratorRow(); // Get the current iterator row echo "Current row is " . $pixelIterator->getIteratorRow(); ?> |
Output:
Current row is 49
Program 2:
<?php // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick->newImage(800, 250, 'black'); $imageIterator = $imagick->getPixelIterator(); $x = 0; // Set the iterator row to last row $imageIterator->setIteratorRow(249); while ($x < 250) { // Get the previous row $pixels = $imageIterator->getPreviousIteratorRow(); foreach ($pixels as $pixel) { if ($x % 4) { // Set the color of pixel $pixel->setColor('green'); } else { // Set the color of pixel $pixel->setColor('red'); } } // Sync the iterator $imageIterator->syncIterator(); $x++; } // Show the output $imagick->setImageFormat('png'); header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> |
Output:
![]()
Reference: https://www.php.net/manual/en/imagickpixeliterator.getpreviousiteratorrow.php
Recommended Posts:
- PHP | ImagickPixelIterator syncIterator() Function
- PHP | ImagickPixelIterator setIteratorFirstRow() Function
- PHP | ImagickPixelIterator __construct() function
- PHP | ImagickPixelIterator getCurrentIteratorRow() function
- PHP | ImagickPixelIterator setIteratorRow() function
- PHP | ImagickPixelIterator getIteratorRow() function
- PHP | ImagickPixelIterator newPixelRegionIterator() Function
- PHP | ImagickPixelIterator resetIterator() Function
- PHP | ImagickPixelIterator resetIterator() Function
- PHP | ImagickPixelIterator setIteratorLastRow() Function
- PHP | ImagickPixelIterator newPixelIterator() Function
- PHP | ImagickPixelIterator getNextIteratorRow() Function
- How to Check a Function is a Generator Function or not using JavaScript ?
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- CSS min() Function
- D3.js arc() Function
- D3.js zip() Function
- PHP Ds\Set get() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

