Skip to content
Related Articles
Open in App
Not now

Related Articles

PHP | GmagickPixel setcolor() function

Improve Article
Save Article
  • Last Updated : 23 Jan, 2020
Improve Article
Save Article

The GmagickPixel::setcolor() function is an inbuilt function in PHP which is used to set the color of the GmagickPixel object.


GmagickPixel GmagickPixel::setcolor( string $color )

Parameters:This function accepts a single parameter $color which holds the color.

Return Value: This function returns GmagickPixel object on success.

Exceptions: This function throws GmagickPixelException on error.

Below given programs illustrate the GmagickPixel::setcolor() function in PHP:
Program 1:

// Create a new gmagickPixel object 
$gmagickPixel = new GmagickPixel(); 
// Set the color 
// Get the color 
$color = $gmagickPixel->getColor(); 
print("<pre>".print_r($color, true)."</pre>"); 


rgb(16962, 34181, 21588)

Program 2:

// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
// Create a new GmagickPixel object
$gmagickPixel = new GmagickPixel();
// Set the color
// Create a GmagickDraw object
$draw = new GmagickDraw();
// Set fill color using gmagickpixel
// Set the font size
// Annotate a text
$draw->annotate(50, 180, 'GeeksforGeeks');
// Use of drawimage function
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!