I'm looking for a way to detect the (average) frame rate of an animated GIF using Linux. PHP's I开发者_JAVA技巧magick class seems to provide this functionality but I rather avoid installing a ton of libraries to get it to work.
http://www.php.net/manual/en/function.imagick-getimagetickspersecond.php
Is there a simple way to do this?
I think ImageMagick really is your best bet.
This is what a identify filename.gif
on an animated GIF looks like:
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 doesn't give you the frame rate - which is good, because animated GIFs don't have a global frame rate, they have an individual one between frames.
You can customize the info format of what ImageMagick's identify
should display to you:
identify \
-format "%T ticks: %f: Frame[%s] %m %wx%h %P%O %r %z-bit\n" \
anim.gif
That should do the trick.
Example output:
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
精彩评论