PHP | Imagick getPixelIterator() Function Last Updated : 26 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Imagick::getPixelIterator() function is an inbuilt function in PHP which is used to return the image MagickPixelIterator. Syntax: ImagickPixelIterator Imagick::getPixelIterator( void ) Parameters:This function does not accept any parameter. Return Value: This function returns an ImagickPixelIterator value. Errors/Exceptions: This function throws ImagickException on error. Below programs illustrate the Imagick::getPixelIterator() function in PHP: Program 1: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); $imageIterator = $imagick->getPixelIterator(); // Change the color of every second pixel to green foreach ($imageIterator as $row => $pixels) { foreach ($pixels as $column => $pixel) { if ($column % 2) { $pixel->setColor("green"); } } $imageIterator->syncIterator(); } // Display the output header("Content-Type:image/png"); echo $imagick; ?> Output: Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); $imageIterator = $imagick->getPixelIterator(); // Change the color of every second pixel to green foreach ($imageIterator as $row => $pixels) { foreach ($pixels as $column => $pixel) { if ($row % 2) { $pixel->setColor("blue"); } } $imageIterator->syncIterator(); } // Display the output header("Content-Type:image/png"); echo $imagick; ?> Output: Reference: https://www.php.net/manual/en/imagick.getpixeliterator.php Comment More infoAdvertise with us Next Article PHP | Imagick getImageInterations() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick getPixelRegionIterator() Function The Imagick::getPixelRegionIterator() function is an inbuilt function in PHP which is used to get an ImagickPixelIterator for an image section. Syntax: ImagickPixelIterator Imagick::getPixelRegionIterator( int $x, int $y, int $columns, int $rows ) Parameters:This function accepts four parameters as 2 min read PHP | Imagick getImageInterations() Function The Imagick::getImageIterations() function is an inbuilt function in PHP which is used to get the image iterations. The iteration means how many times the frames should repeat themselves. Syntax: int Imagick::getImageIterations( void ) Parameters: This function doesn't accepts any parameter. Return 1 min read PHP | Imagick getIteratorIndex() Function The Imagick::getIteratorIndex() function is an inbuilt function in PHP which is used to get the index of the current active image. This is a alternate for getImageIndex() function. Syntax: int Imagick::getIteratorIndex( void ) Parameters: This function doesnât accepts any parameter. Return Value: Th 1 min read PHP | Imagick getImagePixelColor() Function The Imagick::getImagePixelColor() function is an inbuilt function in PHP which is used to returns the color of a specified pixel. Syntax: ImagickPixel Imagick::getImagePixelColor( int $x, int $y ) Parameters:This function accepts two parameters as mentioned above and described below: $x: It specifie 1 min read PHP | Imagick getSamplingFactors() Function The Imagick::getSamplingFactors() function is an inbuilt function in PHP which is used to get the horizontal and vertical sampling factor. Syntax: array Imagick::getSamplingFactors( void ) Parameters: This function doesnât accepts any parameter. Return Value: This function returns an associative arr 1 min read PHP | Imagick getImageLength() Function The Imagick::getImageLength() function is an inbuilt function in PHP which is used to get the length of an image object in bytes. Syntax: bool Imagick::getImageLength( void) Parameters: This function does not accept any parameter. Return Value: This function returns the image length in bytes. Below 1 min read Like