note 108749 added to imagick.getiteratorindex
| From: | holdoffhunger at gmail dot com | Date: | Tue, 22 May 2012 23:42:53 +0000 |
| Subject: | note 108749 added to imagick.getiteratorindex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188142@lists.php.net to get a copy of this message | ||
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");
?>
----
Server IP: 69.147.83.197
Probable Submitter: 68.9.137.178
----
Manual Page -- http://www.php.net/manual/en/imagick.getiteratorindex.php
Edit -- https://master.php.net/note/edit/108749
Del: integrated -- https://master.php.net/note/delete/108749/integrated
Del: useless -- https://master.php.net/note/delete/108749/useless
Del: bad code -- https://master.php.net/note/delete/108749/bad+code
Del: spam -- https://master.php.net/note/delete/108749/spam
Del: non-english -- https://master.php.net/note/delete/108749/non-english
Del: in docs -- https://master.php.net/note/delete/108749/in+docs
Del: other reasons-- https://master.php.net/note/delete/108749
Reject -- https://master.php.net/note/reject/108749
Search -- https://master.php.net/manage/user-notes.php