PHP | ImagickPixelIterator __construct() function Last Updated : 02 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickPixelIterator::__construct() function is an inbuilt function in PHP which is used create a instance of ImagickPixelIterator object. This object is used to iterate through the pixels. Syntax: bool ImagickPixelIterator::__construct( Imagick $wand ) Parameters:This function accepts a single parameter $wand which holds the image. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the ImagickPixelIterator::__construct() function in PHP: Program 1: php <?php // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick->newImage(800, 250, 'black'); // Create a new imagickPixelIterator object $imageIterator = new ImagickPixelIterator($imagick); // Loop through pixel rows foreach ($imageIterator as $row => $pixels) { foreach ($pixels as $column => $pixel) { // Set the color of each pixel to blue $pixel->setColor('blue'); } // Sync the iterator after each iteration $imageIterator->syncIterator(); } // Show the output $imagick->setImageFormat('png'); header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Create a new imagickPixelIterator object $imageIterator = new ImagickPixelIterator($imagick); $i = 0; // Loop through pixel rows foreach ($imageIterator as $row => $pixels) { foreach ($pixels as $column => $pixel) { $i++; } // Sync the iterator after each iteration $imageIterator->syncIterator(); } echo 'Total number of pixels: ' . $i; ?> Output: Total number of pixels: 122728 Reference: https://www.php.net/manual/en/imagickpixeliterator.construct.php Comment More infoAdvertise with us Next Article PHP | ImagickPixelIterator syncIterator() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | ImagickPixel __construct() Function The ImagickPixel::__construct() function is an inbuilt function in PHP which is used to construct an ImagickPixel object. If a color is specified, the object is constructed and then initialized with that color. Syntax: bool ImagickPixel::__construct( void ) Parameters: This function accepts a single 2 min read PHP | ImagickDraw __construct() Function The ImagickDraw::__construct() function is an inbuilt function in PHP which is used to initialize a ImagickDraw object. Syntax: bool ImagickDraw::__construct( void ) Parameters: This function doesnât accept any parameter. Return Value: This function returns TRUE on success. Exceptions: This function 1 min read PHP | Imagick __construct() Function The Imagick::__construct() function is an Imagick class constructor which takes the image path or image URL as parameter to instantiate the Imagick object for a specific image or a set of images. Syntax: Imagick::__construct( $files ) Parameters: This function accepts single parameter $files which h 1 min read PHP | ImagickPixelIterator syncIterator() Function The ImagickPixelIterator::syncIterator() function is an inbuilt function in PHP which is used to sync the pixel iterator. Syntax: bool ImagickPixelIterator::syncIterator( void ) Parameters:This function doesnât accepts any parameter. Return Value: This function returns TRUE on success. Exceptions: T 2 min read 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 ) Par 2 min read PHP | ImagickPixelIterator setIteratorRow() function The ImagickPixelIterator::setIteratorRow() function is an inbuilt function in PHP which is used to set the pixel iterator row. This function is used to move to any row in the current image pixels. Syntax: bool ImagickPixelIterator::setIteratorRow( int $row ) Parameters:This function accepts a single 2 min read Like