PHP | ImagickPixel setColor() function Last Updated : 02 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The ImagickPixel::setColor() function is an inbuilt function in PHP which is used to set the color of the ImagickPixel object. Syntax: bool ImagickPixel::setColor( string $color ) Parameters:This function accepts a single parameter $color which holds the color. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the ImagickPixel::setColor() function in PHP: Program 1: php <?php // Create a new imagickPixel object $imagickPixel = new ImagickPixel(); // Set the color $imagickPixel->setColor('#428554'); // Get the color $color = $imagickPixel->getColor(); print("<pre>".print_r($color, true)."</pre>"); ?> Output: Array ( [r] => 66 [g] => 133 [b] => 84 [a] => 1 ) Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Get the pixel iterator to iterate through each pixel $imageIterator = $imagick->getPixelIterator(); // Loop through pixel rows foreach ($imageIterator as $row => $pixels) { // Loop through the pixels in the row if ($row % 5) { foreach ($pixels as $column => $pixel) { if ($column % 5) { // Set the color $pixel->setColor("green"); } } } // Sync the iterator after each iteration $imageIterator->syncIterator(); } header("Content-Type: image/jpg"); echo $imagick; ?> Output: Reference: https://www.php.net/manual/en/imagickpixel.setcolor.php Comment More infoAdvertise with us Next Article PHP | ImagickPixel setHSL() function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | GmagickPixel setcolor() function The GmagickPixel::setcolor() function is an inbuilt function in PHP which is used to set the color of the GmagickPixel object. Syntax: GmagickPixel GmagickPixel::setcolor( string $color ) Parameters:This function accepts a single parameter $color which holds the color. Return Value: This function re 1 min read PHP | ImagickPixel setColorValue() function The ImagickPixel::setColorValue() function is an inbuilt function in PHP which is used to set the normalized value of the provided color channel for a given ImagickPixel's color. The normalized value is a floating-point number between 0 and 1. Syntax: bool ImagickPixel::setColorValue( int $color, fl 2 min read PHP | ImagickPixel setHSL() function The ImagickPixel::setHSL() function is an inbuilt function in PHP which is used to set the color described by the ImagickPixel object using normalized values for hue, saturation and luminosity. Syntax: bool ImagickPixel::setHSL( float $hue, float $saturation, float $luminosity ) Parameters:This func 2 min read PHP | GmagickPixel setcolorvalue() Function The GmagickPixel::setcolorvalue() function is an inbuilt function in PHP which is used to set the normalized value of the provided color channel for a given GmagickPixelâs color. The normalized value is a floating-point number between 0 and 1.Syntax:Â GmagickPixel GmagickPixel::setcolorvalue( int $co 2 min read PHP | ImagickPixel setColorValueQuantum() function The ImagickPixel::setColorValueQuantum() function is an inbuilt function in PHP which is used to set the value of the provided color channel for a given ImagickPixel's color. The value can be in a range from 0 to 65535. Syntax: bool ImagickPixel::setColorValueQuantum( int $color, float $value ) Para 2 min read PHP | Imagick setColorspace() Function The Imagick::setColorspace() function is an inbuilt function in PHP which is used to set the global colorspace value of an image. Syntax: bool Imagick::setColorspace( int $colorspace ) Parameters: This function accepts a single parameter $colorspace which holds an integer value corresponding to one 1 min read Like