The Imagick::setImageCompose() function is an inbuilt function in PHP which is used to set the composite operator associated with the image. This function is used to specify how to composite the image thumbnail when using the Imagick::montageImage() method.
Syntax:
bool Imagick::setImageCompose( int $compose )
Parameters: This function accepts a single parameter $compose which holds the image composite operator.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::setImageCompose() function in PHP:
Program 1:
<?php // Create new Imagick Object $imagick = new Imagick( // Set the Compose $imagick->setImageCompose(70); // Get the Compose $compose = $imagick->getImageCompose(); echo $compose; ?> |
Output:
70
Program 2:
<?php // Create new Imagick Object $imagick = new Imagick( // Add label for first image $imagick->labelImage('Image 1'); // Set the Compose for first image $imagick->setImageCompose(10); $imagick->addImage(new Imagick( // Add label for second image $imagick->labelImage('Image 2'); // Set the Compose for second image $imagick->setImageCompose(30); // Create a Montage of Images $draw = new ImagickDraw(); $draw->setStrokeColor('black'); $draw->setFillColor('white'); $draw->setStrokeWidth(1); $draw->setFontSize(24); $montage = $imagick->montageImage($draw, "3x2+0+0", "200x160+3+3>", Imagick::MONTAGEMODE_CONCATENATE, "10x10+2+2"); // Display the output $montage->setImageFormat('png'); header("Content-Type: image/png"); echo $montage->getImageBlob(); ?> |
Output:

Reference: https://www.php.net/manual/en/imagick.setimagecompose.php
Recommended Posts:
- PHP | Imagick floodFillPaintImage() Function
- PHP | Imagick adaptiveSharpenImage() Function
- PHP | Imagick flopImage() Function
- PHP | Imagick setImageExtent() Function
- PHP | Imagick getImageWhitePoint() Function
- PHP | Imagick getCompressionQuality() Function
- PHP | Imagick clear() Function
- PHP | Imagick annotateImage() Function
- PHP | Imagick adaptiveResizeImage() Function
- PHP | Imagick adaptiveBlurImage() Function
- PHP | Imagick adaptiveThresholdImage() Function
- PHP | Imagick addNoiseImage() Function
- PHP | Imagick colorizeImage() Function
- PHP | Imagick addImage() Function
- PHP | Imagick setImageDispose() Function
- PHP | Imagick borderImage() Function
- PHP | Imagick getImageMatte() Function
- PHP | Imagick getImageMimeType() Function
- PHP | Imagick getImageRenderingIntent() Function
- PHP | imagick getImageDispose() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

