PHP | Imagick drawImage() Function
Last Updated :
26 Jul, 2019
The Imagick::drawImage() function is an inbuilt function in PHP which is used to render the ImagickDraw object on the Imagick object. It is used to draw the image on the Imagick instance. We set an image matrix, parameters and the borders of the drawn image with the help of ImagickDraw methods and then render it using Imagick::drawImage() function.
Syntax:
bool Imagick::drawImage( ImagickDraw $draw )
Parameters: This function accepts single parameter $draw which holds the ImagickDraw instance to get the details about the image that is to be rendered on the screen.
Return Value: It returns True value when it is executed successfully.
Program: This program creates an image, set its dimensions and border properties and then render it on the screen.
<?php
$geek = "GeeksforGeeks" ;
$image = new Imagick();
$draw = new ImagickDraw();
$draw ->setFillColor( new ImagickPixel( 'Green' ));
$draw ->setFontSize(120);
$metrix = $image ->queryFontMetrics( $draw , $geek );
$draw ->annotation(0, 100, $geek );
$image ->newImage(875, 150, new ImagickPixel( 'white' ));
$image ->drawImage( $draw );
$image ->borderImage( new ImagickPixel( 'green' ), 5, 5);
$image ->setImageFormat( 'png' );
header( 'Content-type: image/png' );
echo $image ;
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.drawimage.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...