Imagick::getIteratorIndex

(PECL imagick 2, PECL imagick 3)

Imagick::getIteratorIndex β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ индСкс Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠ³ΠΎ изобраТСния

ОписаниС

public function Imagick::getIteratorIndex(): int

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ индСкс Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠ³ΠΎ изобраТСния Π² ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π΅ Imagick. ΠœΠ΅Ρ‚ΠΎΠ΄ доступСн, Ссли ΠΌΠΎΠ΄ΡƒΠ»ΡŒ Imagick скомпилировали с вСрсиСй ImageMagick 6.2.9 ΠΈΠ»ΠΈ ΡΡ‚Π°Ρ€ΡˆΠ΅.

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

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

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

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Ρ†Π΅Π»ΠΎΠ΅ число, содСрТащСС индСкс изобраТСния Π² стСкС.

Ошибки

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

ΠŸΡ€ΠΈΠΌΠ΅Ρ€Ρ‹

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ #1 ΠŸΡ€ΠΈΠΌΠ΅Ρ€ использования Imagick::getIteratorIndex():

Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ изобраТСния, установка ΠΈ ΠΏΠΎΠ»ΡƒΡ‡Π΅Π½ΠΈΠ΅ индСкса ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€Π°

<?php
$im
= new Imagick();
$im->newImage(100, 100, new ImagickPixel("red"));
$im->newImage(100, 100, new ImagickPixel("green"));
$im->newImage(100, 100, new ImagickPixel("blue"));

$im->setIteratorIndex(1);
echo
$im->getIteratorIndex();
?>

Π‘ΠΌΠΎΡ‚Ρ€ΠΈΡ‚Π΅ Ρ‚Π°ΠΊΠΆΠ΅

  • Imagick::setIteratorIndex() - УстанавливаСт ΠΏΠΎΠ·ΠΈΡ†ΠΈΡŽ ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€Π°
  • Imagick::getImageIndex() - Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ индСкс Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠ³ΠΎ изобраТСния
  • Imagick::setImageIndex() - УстанавливаСт ΠΏΠΎΠ·ΠΈΡ†ΠΈΡŽ ΠΈΡ‚Π΅Ρ€Π°Ρ‚ΠΎΡ€Π°
οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

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

up
1
Michael O&#39;Connell ΒΆ
10 years ago
This will also retrieve which page number of a multipage document (i.e. PDF, PS) file the Imagick instance is currently on.  By default for a PDF it seems to be set to the last page.
up
0
holdoffhunger at gmail dot com ΒΆ
14 years ago
The getIteratorIndex function of the ImageMagick function works on any type of image, but it is built for measuring the number of frames in an animated .gif file.  For non-animated image files, like regular .bmp or .jpg files, this function will always return the number '0', meaning that there is only one frame.  Counting starts from zero with this function, so a .gif file with five different frames will return a value of '4' on this.  Highly repetitive, but psychedelic animated GIF's are often anywhere between 10 and 30 frames, but a .gif file that is nothing more than video footage converted to a datafile may have hundreds of frames.

According to Wikipedia (in the article for "Graphics Interchange Format"), an animated GIf image is a uses the GIF standard "which allows various images (frames) in the file to be painted with time delays."  This function won't get you the amount of time that delays between each frame, but it will give you the number of unique frames in a .gif file.  This will tell you how complicated or simple the animation may be.

Is the 'getIteratorIndex' function not working for you?  Try the 'getImageIndex' function, which produces the same exact result.

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 Type Value
        // ---------------------------------------------
        
    $image_iterator_index = $imagick_type->getIteratorIndex();
    
        // Print Image Type Value
        // ---------------------------------------------
        
    print("Number of Unique Frames in the .GIF File: $image_iterator_index");

?>