PHP | ImagickPixelIterator getIteratorRow() function
The ImagickPixelIterator::getIteratorRow() function is an inbuilt function in PHP which is used to get the current pixel iterator row. This function is used to check in which row we are currently at while traversing the pixels of an image.
Syntax:
int ImagickPixelIterator::getIteratorRow( void )
Parameters:This function doesn’t accept any parameter.
Return Value: This function returns an integer value containing the current pixel iterator row.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickPixelIterator::getIteratorRow() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$pixelIterator = $imagick ->getPixelIterator();
echo "Current row is " . $pixelIterator ->getIteratorRow();
?>
|
Output:
Current row is 0 // which is the default row from where we start
Program 2:
<?php
$imagick = new Imagick(
$pixelIterator = $imagick ->getPixelIterator();
$pixelIterator ->setIteratorRow(30);
echo "Current row is " . $pixelIterator ->getIteratorRow();
?>
|
Output:
Current row is 30
Program 3:
<?php
$imagick = new Imagick();
$imagick ->newImage(10, 10, 'black' );
$imageIterator = $imagick ->getPixelIterator();
foreach ( $imageIterator as $row => $pixels ) {
echo "Current row is " . $imageIterator ->getIteratorRow() . '<br>' ;
}
?>
|
Output:
Current row is 0
Current row is 1
Current row is 2
Current row is 3
Current row is 4
Current row is 5
Current row is 6
Current row is 7
Current row is 8
Current row is 9
Reference: https://www.php.net/manual/en/imagickpixeliterator.getiteratorrow.php
Last Updated :
02 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...