PHP | ImagickDraw clone() Function
Last Updated :
20 Dec, 2019
The ImagickDraw::clone() function is an inbuilt function in PHP which is used to make an exact copy of the specified ImagickDraw object.
Syntax:
ImagickDraw ImagickDraw::clone( void )
Parameters: This function doesn’t accepts any parameter.
Return Value: This function returns the exact copy of the specified ImagickDraw object on success or error on failure.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the ImagickDraw::clone() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->setFontSize(100);
$draw ->setFillColor( 'blue' );
$draw ->annotation(50, 150, 'GeeksforGeeks' );
$copied = new ImagickDraw();
$copied = $draw -> clone ();
$imagick ->drawImage( $copied );
$imagick ->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->circle(200, 100, 100, 100);
$copied = new ImagickDraw();
$copied = $draw -> clone ();
$imagick ->drawImage( $copied );
$imagick ->borderImage( 'black' , 1, 1);
$imagick ->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.clone.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...