Sunday, September 22, 2024
Google search engine
HomeLanguagesPHP | Gmagick getimageiterations() Function

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('./neveropen.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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments