PHP | Gmagick getimageiterations() Function

The Gmagick::getimageiterations() function is an inbuilt function in PHP which is used to get the image iterations. Iterations actually mean the number of times frames are shown in an image which is 0 in case of a still image and 1 in case of animation.
Syntax:
int Gmagick::getimageiterations( void )
Parameters: This function doesn’t accept any parameters.
Return Value: This function returns an integer value containing the image iterations which is 0 in case of a still image and 1 in case of animations.
Exceptions: This function throws GmagickException on error.
Below given programs illustrate the Gmagick::getimageiterations() function in PHP:
Program 1:
<?php // Create a new Gmagick object $gmagick = new Gmagick('./zambiatek.png'); // Set the iterations $iterations = $gmagick->getimageiterations(); echo $iterations; ?> |
Output:
0 // Because this is a still image.
Program 2:
<?php // Create a new Gmagick object $gmagickAnimation = new Gmagick('g4gnanimation1.gif'); // Set the iterations $iterations = $gmagickAnimation->getimageiterations(); echo $iterations; ?> |
Output:
1 // Because this is a animation.
Reference: https://www.php.net/manual/en/gmagick.getimageiterations.php



