PHP Imagick CompositeImage () Function

PHP

Syntax:
bool Imagick::compositeImage ($composite_object, $composite, $x, $y, $channel = Imagick::CHANNEL_DEFAULT)
Parameters:This function takes five parameters as above and described below:
  • $Composite_object :is an Imagick object that contains a composite image or can be a real path to an image to create.
  • $Composite :these are compound statement constants such as Imagick::COMPOSITE_DEFAULT , Imagick::COMPOSITE_MATHEMATICS , etc.
  • x: contains the column offset of the composite image. The value xwill be numeric.
  • y:holds the line offset of the composite image. The yvalue will be numeric.
  • $channel:it has Imagick channel constants that provide any channel constant that suits your channel mode. To apply more than one channel, concatenate the channel type constants using bitwise operators.
    Return Value:Returns Boolean True on success and false on error.The following program illustrates the Imagick::Compositimage() function in PHP:Program :  
    // Declare Imagick objects $image1 = new Imagick ( " https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-9.png " ); $image2 = new Imagick ( " https://media.engineerforengineer.org/wp- content / uploads / negateImage.png " );  
    // Resize the image $image1 -> resizeimage ( $image2 -> getImageWidth(), $image2 -> getImageHeight(), Imagick::FILTER_LANCZOS, 1);  
    // Create a new Imagick object $new_image = new Imagick();  
    // Create a new image using ImageMagick pseudo-formats $new_image -> newPseudoImage ( $image1 -> getImageHeight(), $image1 -> getImageWidth(), "gradient: gray (10%) - gray (90%)" );  
    // Rotate the image $new_image -> rotateimage ( `black` , 90);  
    // Use a composite function to combine the image $image2 -> compositeImage ( $new_image , Imagick::COMPOSITE_COPYOPACITY, 0, 0);  
    // Use a composite function to combine the image $image1 -> compositeImage ( $image2 , Imagick::COMPOSITE_ATOP, 0, 0); header ( " Content-Type: image / jpg " );  
    // Show output echo $image1 -> getImageBlob();  
    ?>
    Output: Link: https://www.php.net/manual/en/imagick.compositeimage.php



Get Solution for free from DataCamp guru