Hi,
I used readImages to read the frames into a container and got the frame count by querying the container's size.
However, this method consumes a lot of memory, especially when the frame count is large.
Is there any better way?
Thanks
[c++] how to count frames in an animated gif
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: [c++] how to count frames in an animated gif
Use something more specific to GIF.
Look at giftrans from my software export (I did not write it, though I did make a minor patch)
http://www.ict.griffith.edu.au/anthony/ ... /#giftrans
It should be fast because it does not actually do a lot of processing of the image, just reading.
Look at giftrans from my software export (I did not write it, though I did make a minor patch)
http://www.ict.griffith.edu.au/anthony/ ... /#giftrans
It should be fast because it does not actually do a lot of processing of the image, just reading.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: [c++] how to count frames in an animated gif
Thanks
This information is very helpful
This information is very helpful
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: [c++] how to count frames in an animated gif
Note that I am not putting ImageMagick down by suggesting a alternative bit of software.
The IM "identify" command can generate a summary of the images, or even more.
One such application is "gif2anim" which converts a GIF image into a fiel of IM options, that can re-create the GIF animation from seperate frames (whcih it can also create).
http://www.imagemagick.org/Usage/scripts/gif2anim
See Animation Basics, List Information
http://www.imagemagick.org/Usage/anim_basics/#list_info
However programs designed for a specific format will generally beat a general image processor like ImageMagick....
The IM "identify" command can generate a summary of the images, or even more.
One such application is "gif2anim" which converts a GIF image into a fiel of IM options, that can re-create the GIF animation from seperate frames (whcih it can also create).
http://www.imagemagick.org/Usage/scripts/gif2anim
See Animation Basics, List Information
http://www.imagemagick.org/Usage/anim_basics/#list_info
However programs designed for a specific format will generally beat a general image processor like ImageMagick....
Shells are a tool, and we are its carpenters.
Sometimes we need a hammer and sometimes a screwdriver.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: [c++] how to count frames in an animated gif
Hello,
Im searching an trying now the whole day, to get an integer with the number of the frames that are in a gif file.
Im using libmagick++ 6 on a Beagleboneblack with Ubuntu 14.
My c++ code reads different pictures and displays it on a huge DIY LED Matrix, with FPGA.
I want to loop the GIFs of coure, so i want to know what to write to the for loop.
Thanks for your help!
crx
Im searching an trying now the whole day, to get an integer with the number of the frames that are in a gif file.
Im using libmagick++ 6 on a Beagleboneblack with Ubuntu 14.
My c++ code reads different pictures and displays it on a huge DIY LED Matrix, with FPGA.
I want to loop the GIFs of coure, so i want to know what to write to the for loop.
Code: Select all
Image image(pfad); //when I know the number of frames, I want to change to the next frame via the path.
//I tryed this (stringofpath[n] - where n is the frame) and it works, but does anyone know a
//better way or is this a legit way?
int delay;
delay=image.animationDelay()*10; // I read in the dokumentation the value here is in 1/100S so
//it is delay*1 mS between two frames - in praxis i saw it is delay*10mS
//... Had anyone seen this too? (cout is 4 - the GIF has 40ms)
PixelPacket *pixels = image.getPixels(0, 0, w, h); //Get the pixels for the matrix
/* a lot of black magic to get the Pixels into the Matrix B) */
crx