PHP | Imagick removeImage() Function

The Imagick::removeImage() function is an inbuilt function in PHP which is used to remove an image from the image list. This function removes the current image which is pointed by the cursor.

Syntax:

bool Imagick::removeImage( void )

Parameters: This function doesn’t accepts any parameters.

Return Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.



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

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Imagick object
$imagick = new Imagick(
  
// Count the image
echo 'Number of images before removing: '. $imagick->count() . '<br>';
  
// Remove the Image
$imagick->removeImage();
  
// Count the image
echo 'Number of images after removing: '. $imagick->count();;
?>

chevron_right


Output:

Number of images before removing: 1
Number of images after removing: 0

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Imagick object
$imagick = new Imagick(
  
// Add a new image to Imagick object
$imagick->addImage(new Imagick(
  
// Count the image
echo 'Number of images before removing: '. $imagick->count() . '<br>';
  
// Remove the Image
$imagick->removeImage();
  
// Count the image
echo 'Number of images after removing: '. $imagick->count();;
?>

chevron_right


Output:

Number of images before removing: 2
Number of images after removing: 1

Reference: https://www.php.net/manual/en/imagick.removeimage.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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.