PHP | Imagick morphImages() Function
The Imagick::morphImages function is an inbuilt function in PHP which is used to morph a set of images. The image pixels and size of image are linearly interpolated to give the appearance of a metamorphoses from one image to the next.
Syntax:
Imagick Imagick::morphImages( $number_frames )
Parameters: This function accepts single parameter $number_frames which is used to store the number of in-between images to generate.
Return Value: This function returns new Imagick object on success.
Original Images:





Program:
<?php // Set of images $images = [ "img/geeksforgeeks.png", "img/charcoalImage.png", "img/colorMatrix.png", "img/adaptiveThresholdImage.png", "img/recolorImage.png", ]; // Create new Imagick object $imagick = new \Imagick(realpath($images[count($images) - 1])); foreach ($images as $image) { $nextImage = new \Imagick(realpath($image)); $imagick->addImage($nextImage); } $imagick->resetIterator(); // Use morphImages function $morphed = $imagick->morphImages(5); $morphed->setImageTicksPerSecond(10); header("Content-Type: image/gif"); // Set the image format $morphed->setImageFormat('gif'); // Display the output image echo $morphed->getImagesBlob(); ?> |
Output:

Reference: http://php.net/manual/en/imagick.morphimages.php
Recommended Posts:
- PHP | Imagick setImageMatte() Function
- PHP | imagick getImageDispose() Function
- PHP | Imagick getImageRenderingIntent() Function
- PHP | Imagick getImageMimeType() Function
- PHP | Imagick transposeImage() Function
- PHP | Imagick getPackageName() Function
- PHP | Imagick identifyImage() Function
- PHP | Imagick autoLevelImage() Function
- PHP | Imagick appendImages() Function
- PHP | Imagick setImageRenderingIntent() Function
- PHP | Imagick setImageOpacity() Function
- PHP | Imagick getImageScene() Function
- PHP | Imagick getQuantumDepth() Function
- PHP | Imagick getImageMatte() Function
- PHP | Imagick getImageChannelDepth() 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.



