I am looking some kind method to get gif frames number. i am looking on google, stackoverflow and any outher sites and i find only rubbish!! Someone know how to do it? i need only simple number of gif frames.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Which method are you using to load/manipulate the frame? Are you using PIL? If not, I suggest checking it out: Python Imaging Library and specifically the PIL gif page.
Now, assuming you are using PIL to read in the gif, it's a pretty simple matter to determine which frame you are looking at. seek will go to a specific frame and tell will return which frame you are looking at.
Otherwise, I believe you can only find the number of frames in the gif by seeking until an exception (EOFError) is raised.
Just parse the file, gifs are pretty simple: