Imagick::getImageIterations

(PECL imagick 2, PECL imagick 3)

Imagick::getImageIterations β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠΈ изобраТСния

ОписаниС

public function Imagick::getImageIterations(): int

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠΈ изобраТСния.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

Π‘ΠΈΠ³Π½Π°Ρ‚ΡƒΡ€Π° Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ Π½Π΅ содСрТит ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ².

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠΈ изобраТСния Π² Π²ΠΈΠ΄Π΅ Ρ†Π΅Π»ΠΎΠ³ΠΎ числа.

Ошибки

Ѐункция выбрасываСт ΠΈΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ImagickException, Ссли Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка.

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 2 notes

up
3
admin at zasmeshi dot ru ΒΆ
9 years ago
If you want get the number of the animation (GIF) frames you need to use Imagick::getNumberImages()
up
2
holdoffhunger at gmail dot com ΒΆ
14 years ago
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: http://studio.imagemagick.org/pipermail/magick-users/2002-October/005814.html

And some sample code :

<?php

            // Author: holdoffhunger@gmail.com
    
        // 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
        // ---------------------------------------------

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

?>