PHP | ImagickDraw __construct() Function
Last Updated :
23 Dec, 2019
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 throws ImagickException on error.
Below given programs illustrate the ImagickDraw::__construct() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'blue' );
$draw = new ImagickDraw();
$draw ->rectangle(200, 50, 600, 200);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'green' );
$draw = new ImagickDraw();
$draw ->line(0, 0, 800, 250);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.construct.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...