The ImagickPixelIterator::getNextIteratorRow() function is an inbuilt function in PHP which is used to get the next row as an array of pixel wands from the pixel iterator.
Syntax:
array ImagickPixelIterator::getNextIteratorRow( void )
Parameters:This function doesn’t accepts any parameter.
Return Value: This function returns an array value containing the ImagickPixel objects.
Below programs illustrate the ImagickPixelIterator::getNextIteratorRow() function in PHP:
Program 1:
<?php // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object // with 10x10 pixels $imagick ->newImage(10, 10, 'black' ); // Get the pixel iterator $imageIterator = $imagick ->getPixelIterator(); // Rows counter variable $rows = 0; // Count the number of rows while ( $pixels = $imageIterator ->getNextIteratorRow()) { $rows ++; } echo 'The number of rows are ' . $rows ; ?> |
Output:
The number of rows are 10
Program 2:
<?php // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick ->newImage(800, 250, 'black' ); // Get the pixel iterator $imageIterator = $imagick ->getPixelIterator(); while ( $pixels = $imageIterator ->getNextIteratorRow()) { foreach ( $pixels as $column => $pixel ) { if ( $column % 20) { // Paint every 20th pixel black in each row $pixel ->setColor( "white" ); } } // Sync the iterator $imageIterator ->syncIterator(); } // Show the output $imagick ->setImageFormat( 'png' ); header( "Content-Type: image/png" ); echo $imagick ->getImageBlob(); ?> |
Output:
Reference: https://www.php.net/manual/en/imagickpixeliterator.getnextiteratorrow.php