How to detect animated GIFs per second?

I am looking for a way to determine the average frame rate of an animated GIF using Linux. The Imagick PHP class seems to provide this functionality, but I prefer not to install a ton of libraries to make it work.

http://www.php.net/manual/en/function.imagick-getimagetickspersecond.php

Is there an easy way to do this?

+6
linux php imagemagick gif
source share
2 answers

I think ImageMagick is really the best choice.

Here is what identify filename.gif looks like in an animated GIF:

 gif.gif[1] GIF 350x350 350x350+0+0 8-bit PseudoClass 256c 145KB 0.000u 0:00.003 gif.gif[2] GIF 350x350 350x350+0+0 8-bit PseudoClass 256c 145KB 0.000u 0:00.006 gif.gif[3] GIF 350x350 350x350+0+0 8-bit PseudoClass 256c 145KB 0.000u 0:00.010 

this does not give you a frame rate - this is good because animated GIF files do not have a global frame rate, they have an individual between frames.

+8
source share

You can configure ImageMagick identify information display format:

 identify \ -format "%T ticks: %f: Frame[%s] %m %wx%h %P%O %r %z-bit\n" \ anim.gif 

That should do the trick.

Output Example:

  50 ticks: anim.gif: Frame[0] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[1] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[2] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[3] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[4] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 50 ticks: anim.gif: Frame[5] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[6] GIF 1x1 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[7] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[8] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[9] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 10 ticks: anim.gif: Frame[10] GIF 128x128 128x128+0+0 PseudoClass sRGB Matte 8-bit 
+5
source share

All Articles