PHP | Imagick getImagesBlob() Function

The Imagick::getImageBlob() function is an inbuilt function in PHP which is used to get the all the image sequences as a blob. This function is useful for animated gifs as doing getImageBlob() on them won’t work. This function implements direct to memory image formats.

Syntax:

string Imagick::getImagesBlob( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns a string containing the images.

Exceptions: This function throws ImagickException on error.



Below programs illustrate the Imagick::getImagesBlob() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagickAnimation = new Imagick(
  
// Show the output
header("Content-Type: image/gif");
  
echo $imagickAnimation->getImagesBlob();
?>

chevron_right


Output:

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagickAnimation = new Imagick(
  
foreach ($imagickAnimation as $frame) {
  
    // Apply blur to each frame
    $frame->blurImage(5, 3);
}
  
// Show the output
header("Content-Type: image/gif");
  
echo $imagickAnimation->getImagesBlob();
?>

chevron_right


Output:

Reference: https://www.php.net/manual/en/imagick.getimagesblob.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.