PHP | ImagickDraw composite() Function
Last Updated :
07 Mar, 2024
The ImagickDraw::compose() function is an inbuilt function in PHP which is used to composite an image into the current image, using the specified composition operator, specified position, and at the specified size. Syntax:
bool ImagickDraw::compose( int $compose, float $x, float $y,
float $width, float $height, Imagick $compositeWand )
Parameters: This function accepts six parameters as mentioned above and described below:
- $compose: It specifies the composition operator which corresponds one of COMPOSITE constants.
- $x: It specifies y-coordinate of the top left corner.
- $y: It specifies x-coordinate of the top left corner.
- $width: It specifies width of the composition image.
- $height: It specifies height of the composition image.
- $compositeWand: It specifies the Imagick object where composition image is taken from.
Return Value: This function returns TRUE on success. Below programs illustrate the ImagickDraw::compose() function in PHP: Program 1:
php
<?php
$imagick = new Imagick(
$draw = new ImagickDraw();
$draw ->composite(imagick::COMPOSITE_COLORIZE,
100, 100, 200, 200, $imagick );
$imagick2 = new Imagick();
$imagick2 ->newImage(800, 250, 'white' );
$imagick2 ->drawImage( $draw );
$imagick ->borderImage( 'green' , 1, 1);
$imagick2 ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick2 ->getImageBlob();
?>
|
Output: Program 2:
php
<?php
$imagick = new Imagick(
$draw = new ImagickDraw();
$draw ->composite(4, 200, 20, 400, 200, $imagick );
$imagick2 = new Imagick();
$imagick2 ->newImage(800, 250, 'orange' );
$imagick2 ->drawImage( $draw );
$imagick2 ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick2 ->getImageBlob();
?>
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...