(PECL imagick 2.0.0)

Imagick::getImageIterationsGets the image iterations


int Imagick::getImageIterations ( void )

Gets the image iterations.

Возвращаемые значения

Returns the image iterations as an integer.


Вызывает ImagickException при ошибке.


By using the PHP function getImageIterations, you'll receive back a value indicating the animated nature of the image.  You'll get back a '0' for a still image that is not animated (like a .BMP or a .JPEG file) and a '1' for an animated image (like an animated .GIF file).

I have been unable to get any other results from this function, after extensive use.  There is some discussion among the ImageMagick user's group saying that the Iterations should indicate the number of times an animated .Gif file repeats itself.  However, it's possible that either modern browsers default the value to infinity or that this ImageMagick functionality is only available at the Linux command-line.  See more at the discussion group here:

And some sample code :


// Author:
        // Imagick Type
        // ---------------------------------------------

$imagick_type = new Imagick();
// Open File
        // ---------------------------------------------
$file_to_grab "image_workshop_directory/test.gif";
$file_handle_for_viewing_image_file fopen($file_to_grab'a+');
// Grab File
        // ---------------------------------------------

// Get Image Iterations
        //    (Detect Animated Image Versus Non-Animated Image)
        // ---------------------------------------------
$image_iterations $imagick_type->getImageIterations();
// Print Iteration Value Interpreted
        // ---------------------------------------------
if($image_iterations == 1)
"$file_to_grab *IS* an animated image.");
"$file_to_grab *IS NOT* an animated image.");

2012-05-27 02:22:36
If you want get the number of the animation (GIF) frames you need to use Imagick::getNumberImages()
2016-12-14 14:57:35

    Поддержать сайт на родительском проекте КГБ