47

How can I easily split an animated .gif file? I want to see each frame.

I would really prefer to not to export every frame to a directory. I'd like to view them individually in one application if possible.

Is this possible on Linux?

59

Try opening them with The Gimp; I believe it will open animated gifs with one layer per frame.

You say you don't want to dump all frames to files on a directory, but I'll tell you how to do it anyway :) install either ImageMagick or graphicsmagick, then:

for ImageMagick:

convert animation.gif target.png

for graphicsmagick:

gm convert animation.gif target.png

it'll write frames to target0.png,target1.png,... and so on. You can then enter the directory and run eog, it'll show you all the frames on the same application. When you no longer need the frames, just rm target*.png.

| improve this answer | |
  • 1
    imagemagick is just awesome!! – fccoelho Jul 21 '13 at 23:24
  • 1
    imagemagic convert failed for me, since it seems that each image of the gif was represented as a new transparent backgrounds layer, and convert gave those transparent layers: upload.wikimedia.org/wikipedia/commons/5/5d/AstarExample.gif – Ciro Santilli 郝海东冠状病六四事件法轮功 Jul 25 '13 at 18:25
  • I opened my gif in gimp, but I still don't know how to view each frame individually - I just see the last frame. I'm working with this animation: /tmp/Non-Native-American-Nations-Territorial-Claims-over-NAFTA-countries-1750-2008.gif – nealmcb Mar 21 '15 at 15:53
  • 3
    GraphicsMagick needs to be of the form gm convert some-image.gif +adjoin some-image%d.png to work. Or, gm convert some-image.gif -coalesce +adjoin some-image%d.png for varied sized subframes with varying offsets. – l --marc l Jun 23 '16 at 19:54
  • 1
    The specified convert misses the -coalesce option, which is required for what a user would expect. – Marcus Mar 8 '18 at 20:44
46

If the various frames have transparent areas and build upon each other, you can use the convert command with the "-coalesce" option to produce a set of files target-0.png, target-1.png etc, each of which merges the sequence of previous images:

convert -coalesce animation.gif target.png
| improve this answer | |
  • 1
    Great comment but needs explanation. Basically it solves the problem @cirosantilli had with ImageMagick returning what looked liked updates to specific screen areas. -coalesce merges those updates to give you a finished rendering. – AnthonyVO Jul 1 '14 at 12:18
  • 3
    It should be noted that (as of ImageMagick version 6.7.7) there seems to be some memory leak: do not attempt -coalesce with long .gif screencasts, it would probably consume all available memory and possibly hang your entire system. – leftaroundabout Aug 29 '15 at 22:55
  • 4
    you can specify the output file names via something like: convert -coalesce animation.gif target.%04d.png – Trevor Boyd Smith May 29 '16 at 15:35
2

for me, with ImageMagick (version info: 6.8.9-9 Q16 x86_64 2017-07-31)

convert gif.gif gif.pdf

makes a pdf with each page being a frame of the input gif, then you can just page through the frames in the pdf viewing application of your choosing

| improve this answer | |
  • That seems overly complicated and unlike what OP wants. – David Foerster Nov 16 '17 at 21:57
  • To get each frame as a page in a .pdf is a great idea, just take into consideration that this method might be buggy, and you need to tweak the application. – loved.by.Jesus Nov 7 '18 at 18:19
2

Use mpv . Open it on desktop . Drag gif into it. Take a screenshot of your desired/single frame with s key. You may even pause if your gif is fast. Very Quick way.

===========

you may want to use these settings first [once set you do not have to do again]:

gedit ~/.config/mpv/mpv.conf

and enter and save:

--screenshot-format Choices: jpg jpeg png (default: jpg)

for highest png quality:

--screenshot-format=png
--screenshot-png-compression=9

or if you want jpg

--screenshot-jpeg-quality Integer (0 to 100) (default: 90)

Use mpv --list-options for other details

| improve this answer | |
  • Hi :) back andrew.46. tried Gimp and got frustrated. there is not much that mpv cannot do :] – shantiq Jul 7 '18 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.