PHP | ImagickPixelIterator getPreviousIteratorRow() Function
Last Updated :
14 Jan, 2020
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
$imagick = new Imagick(
$pixelIterator = $imagick ->getPixelIterator();
$pixelIterator ->setIteratorRow(50);
$pixelIterator ->getPreviousIteratorRow();
echo "Current row is " . $pixelIterator ->getIteratorRow();
?>
|
Output:
Current row is 49
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$imageIterator = $imagick ->getPixelIterator();
$x = 0;
$imageIterator ->setIteratorRow(249);
while ( $x < 250) {
$pixels = $imageIterator ->getPreviousIteratorRow();
foreach ( $pixels as $pixel ) {
if ( $x % 4) {
$pixel ->setColor( 'green' );
} else {
$pixel ->setColor( 'red' );
}
}
$imageIterator ->syncIterator();
$x ++;
}
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickpixeliterator.getpreviousiteratorrow.php
Share your thoughts in the comments
Please Login to comment...