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 use current stroke color and stroke thickness at the specified coordinates.


bool ImagickDraw::point( $x, $y )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $x: This parameter is used to hold the value of x coordinate.
  • $y: This parameter is used to hold the value of y coordinate.

Return Value: This function returns TRUE on success.

Below program illustrates the ImagickDraw::point() function in PHP:

// Create an ImagickDraw object
$draw = new ImagickDraw();
// Set the filled color
// 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
// Function to draw the image
header("Content-Type: image/png");
// Display the output image
echo $imagick->getImageBlob();



Reference: http://php.net/manual/en/imagickdraw.point.php

This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment



load comments

Subscribe to Our Newsletter