Is there an easy way to figure out approximately how long a .gif image takes to play one time in Javascript?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to get the background from multiple images by
- void before promise syntax
The
identify
command from ImageMagick can give this information:...
The last line printed should be the total length of the animation.
I tried ImageMagick
identify
but it didn't give me the correct duration.I found another reliable way using ExifTool
exiftool -Duration image.gif
It will print out the duration in seconds:
Duration : 0.48 s
The accepted answer doesn't give the exact result.
Elapsed time
is like a real world clock while ImageMagick runs the animation. What you want is theDelay
field for each frame and sum them up.Where
33x100
is a delay of 330ms.Edited by Mark Setchell
You can actually extract the delay parameter somewhat more surgically (than by using
grep
) with the%T
escape:And get the total with
awk
like this: