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 // Create a new imagick object $imagick= newImagick(  Â// Get the pixel iterator $pixelIterator= $imagick->getPixelIterator();  Â// Get the current iterator row echo"Current row is ". $pixelIterator->getIteratorRow(); ?>  | 
Output:
Current row is 0 // which is the default row from where we start
Program 2:
| <?php // Create a new imagick object $imagick= newImagick(  Â Â// Get the pixel iterator $pixelIterator= $imagick->getPixelIterator();  Â// Set the pixel iterator to 30 $pixelIterator->setIteratorRow(30);  Â// Get the current iterator row echo"Current row is ". $pixelIterator->getIteratorRow(); ?>  | 
Output:
Current row is 30
Program 3:
| <?php // Create a new imagick object $imagick= newImagick();  Â// Create a image on imagick object with size of 10x10 pixels $imagick->newImage(10, 10, 'black');  Â// Get the pixel iterator $imageIterator= $imagick->getPixelIterator();  Â// Loop through pixel rows foreach($imageIteratoras$row=> $pixels) {  Â   // Get the current iterator row    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
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
 
				 
					


