Open In App
Related Articles

PHP ImagickDraw Functions Complete Reference

Improve Article
Improve
Save Article
Save
Like Article
Like

The ImagickDraw class is used to draw the vector-based image using ImageMagick. The vector-based generated image can be saved into the file.

Syntax:

bool ImagickDraw::s()
 

Example: Below program illustrates the ImagickDraw::point() Function in PHP:

PHP




<?php
 
// Create an ImagickDraw object
$draw = new \ImagickDraw();
 
// Set the filled color
$draw->setFillColor('red');
 
// Use loop to draw 10000 points in given area
for ($x = 0; $x < 10000; $x++) {
    $draw->point(rand(0, 300), rand(0, 300));
}
 
// Create an Imagick object
$imagick = new \Imagick();
 
// Set the new image size
$imagick->newImage(300, 300, 'white');
 
// Set the image format
$imagick->setImageFormat("png");
 
// Function to draw the image
$imagick->drawImage($draw);
 
header("Content-Type: image/png");
 
// Display the output image
echo $imagick->getImageBlob();
?>

Output:

 

The list of complete ImagickDraw functions are given below:

Functions

Description

ImagickDraw::annotation()Draw the text on the image.
ImagickDraw::arc()It is used to draw an arc.
ImagickDraw::bezier()It is used to draw bezier curves.
ImagickDraw::circle()It is used to draw a circle.
ImagickDraw::getStrokeOpacity()Return the opacity of stroked object outlines.
ImagickDraw::getStrokeWidth()Return the width of the stroke used to draw object outlines.
ImagickDraw::line()It is used to draw a line.
ImagickDraw::point()It is used to draw a point.
ImagickDraw::polygon()Draw a polygon using the specified array of coordinates.
ImagickDraw::polyline()Draw a polyline using the current stroke, stroke width, and fill color or texture, using the specified array of coordinates.
ImagickDraw::rectangle()It is used to draw a rectangle.
ImagickDraw::rotate()Apply the specified rotation to the current coordinate space.
ImagickDraw::roundRectangle()Draw a rounded rectangle.
ImagickDraw::scale()Adjust the scaling factor to apply in the horizontal and vertical directions to the current coordinate space.
ImagickDraw::setFillColor()Set the fill color to be used for drawing.
ImagickDraw::setFillOpacity()Set the opacity to use when drawing using the fill color or fill texture.
ImagickDraw::setFont()Set the fully-specified font to use when annotating with text.
ImagickDraw::setFontFamily()Set the font family to use when annotating with text.
ImagickDraw::setFontSize()Set the font point size. It is used when annotating text.
ImagickDraw::setFontStyle()Set the font style to use when annotating with text.
ImagickDraw::setFontWeight()It is used to set the font weight.
ImagickDraw::setGravity()Set the text placement gravity when annotating with text.
ImagickDraw::setStrokeAlpha()Specify the opacity of stroked object outlines.
ImagickDraw::setStrokeColor()Set the color used for stroking object outlines.
ImagickDraw::setStrokeLineJoin()The corners of paths when they are stroked.
ImagickDraw::setStrokeMiterLimit()Specify the miter limit of the stroke
ImagickDraw::setStrokeOpacity()The value of opacity lies between 0 to 1.
ImagickDraw::setStrokeWidth()Set the width of the stroke used to draw object outlines.
ImagickDraw::setTextAlignment()Specify a text alignment that can be left, center or right.
ImagickDraw::setTextAntialias()Control whether the text is antialiased. The text is antialiased by default.
ImagickDraw::setTextDecoration()Decoration is to be applied when annotating with text.
ImagickDraw::setTextUnderColor()Set the color of a background rectangle to place under text annotations.
ImagickDraw::setViewbox()Set the overall canvas size.
ImagickDraw::skewX()Skews the current coordinate system in the horizontal direction.
ImagickDraw::skewY()Skews the current coordinate system in the vertical direction.
ImagickDraw::translate()Apply a translation to the current coordinate system.

Last Updated : 01 Feb, 2023
Like Article
Save Article
Similar Reads
Related Tutorials