PHP | ImagickDraw color() Function Last Updated : 07 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The ImagickDraw::color() function is an inbuilt function in PHP which is used to draw color on the image using the current fill color, starting at the specified position, and using specified paint method. Syntax: bool ImagickDraw::color( float $x, float $y, int $paintMethod ) Parameters: This function accepts three parameters as mentioned above and described below: $x: It specifies the x-coordinate of the paint. $y: It specifies the y-coordinate of the paint. $paintMethod: It specifies an integer corresponding to one of PAINT constants. List of PAINT constants are given below: imagick::PAINT_POINT (1) imagick::PAINT_REPLACE (2) imagick::PAINT_FLOODFILL (3) imagick::PAINT_FILLTOBORDER (4) imagick::PAINT_RESET (5) Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the ImagickDraw::color() 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, 'white'); // Create a new ImagickDraw object $draw = new ImagickDraw(); $x = 0; while ($x < 900) { // Draw lines using imagick::PAINT_POINT $draw->color($x, 0, 1); $draw->color($x, 30, 1); $draw->color($x, 60, 1); $draw->color($x, 90, 1); $draw->color($x, 120, 1); $draw->color($x, 150, 1); $draw->color($x, 180, 1); $draw->color($x, 210, 1); $draw->color($x, 240, 1); $x++; } // Render the draw commands $imagick->drawImage($draw); // 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(); // Create a image on imagick object $imagick->newImage(800, 250, 'white'); // Create a new ImagickDraw object $draw = new ImagickDraw(); // Set the fill color $draw->setFillColor('green'); // Color the image using Imagick::PAINTFILL $draw->color(1, 1, Imagick::PAINT_FLOODFILL); // Render the draw commands $imagick->drawImage($draw); // Show the output $imagick->setImageFormat("png"); header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Comment More infoAdvertise with us Next Article PHP | ImagickDraw color() Function gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | ImagickDraw circle() Function The ImagickDraw::circle() function is an inbuilt function in Imagick library of PHP which is used to draw a circle. Syntax: bool ImagickDraw::circle( $ox, $oy, $px, $py ) Parameters: This function accepts four parameters as mentioned above and described below: $ox: This parameter takes the value of 1 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 | ImagickDraw composite() Function The ImagickDraw::compose() function is an inbuilt function in PHP which is used to composite an image into the current image, using the specified composition operator, specified position, and at the specified size. Syntax: bool ImagickDraw::compose( int $compose, float $x, float $y, float $width, fl 2 min read PHP | ImagickDraw annotation() Function The ImagickDraw::annotation() function is an inbuilt function in PHP which is used to draw the text on the image. Syntax: bool ImagickDraw::annotation( $x, $y, $text ) Parameters: This function accepts three parameters as mentioned above and described below: $x: This parameter is used to hold the va 3 min read PHP | ImagickDraw pop() Function The ImagickDraw::pop() function is an inbuilt function in PHP which is used to destroy the current ImagickDraw in the stack and returns the previously pushed ImagickDraw. For every pop() function there must have already been an equivalent push() function. Syntax: bool ImagickDraw::pop( void ) Parame 2 min read PHP | Imagick colorizeImage() Function The Imagick::colorizeImage() function is an inbuilt function in PHP which is used to blends the fill color with each pixel in the image with a specified opacity. Syntax: bool Imagick::colorizeImage( mixed $colorize, mixed $opacity, bool $legacy = FALSE ) Parameters: This function accepts three param 2 min read PHP | ImagickDraw line() Function The ImagickDraw::line() function is an inbuilt function in Imagick library of PHP which is used to draw a line. This function draw the line using the current stroke color, stroke opacity, and stroke width. Syntax:  bool ImagickDraw::line( $sx, $sy, $ex, $ey ) Parameters: This function accepts four 1 min read PHP | ImagickDraw point() Function The ImagickDraw::point() function is an inbuilt function in Imagick library of PHP which is used to draw a point. This function uses current stroke color and stroke thickness at the specified coordinates. Syntax: bool ImagickDraw::point( $x, $y ) Parameters: This function accepts two parameters as m 1 min read PHP | Imagick colorMatrixImage() Function The Imagick::colorMatrixImage() function is an inbuilt function in PHP which is used to apply color transformation to the images. This function induces saturation changes, hue rotation, luminance to alpha, and various other effects. This function uses variable-size transformation matrices i.e. 5x5 m 2 min read PHP | Imagick clutImage() Function The Imagick::clutImage() function is an inbuilt function in PHP which is used to replace the colors in the image. The second parameter of this function replaces the color in a specific channel. Syntax: bool Imagick::clutImage( $lookup_table, $channel = Imagick::CHANNEL_DEFAULT ) Parameters: This f 1 min read Like