6

Is there a way to view animated GIFs demonstrations step-by-step? Example of an animated image produced with Blender screencast which is way too fast:

enter image description here
Source: What is the fastest way to create a curved plane? on Blender.SE.

My own search was not successful: - An existing answer on Blender.SE suggests to view animated images in GIMP. Like the OP, I don't think is a convenient method! - There is an addon for Chrome (GIF Scrubber), but I didn't find one for Firefox. - There is a service online which take a GIF and add appropriate controls: This same GIF converted.

Question: Is there:

  • A Firefox addon which add playback controls to an animated image?
  • Or a stand alone tool?
Community
  • 1
  • 1
mins
  • 6,478
  • 12
  • 56
  • 75

4 Answers4

7

Finally I wrote a bit of Python code to display Gifs in a Jupyter notebook.

I use these libraries:

  • IpyWidgets and IPython.display.HTML for UI
  • Matplotlib.Pyplot to display frames as images
  • Matplotlib.animation to animate
  • os to read the file
  • NumPy to read a frame in an array
  • PIL to process image pixels

The code can be easily adapted to work without Jupyter, but notebooks are a great tool for interacting:

import os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation, rc
from PIL import Image
import ipywidgets as widgets
from IPython.display import HTML

reader = GifReader('Muybridge_cavall_animat.gif')
fig,ax = plt.subplots()
ax.axis('off')
data = reader.seek(0)
h = ax.imshow(data)
plt.close()

def make_frame(n):
    data = reader.seek(n)
    h.set_data(data)
    return [h]

anim = animation.FuncAnimation(fig, make_frame,
                               frames=reader.get_length()-1,
                               blit=True)
HTML(anim.to_jshtml())

enter image description here
Original gif image

The Reader class:

class GifReader:
    pil_image = None
    length = -1

    def __init__(self, file_path):
        self._open(file_path)

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.close()

    def _open(self, file_path):
        if self.pil_image != None:
            raise ValueError(f'File is already open')

        if os.path.isfile(file_path) == False:
            raise ValueError(f'File {file_path} doesn\'t exist')

        with open(file_path, 'rb') as f:
            if f.read(6) not in (b'GIF87a', b'GIF89a'):
                raise ValueError('Not a valid GIF file')

        self.pil_image = Image.open(file_path)        
        self.length = self.pil_image.n_frames

    def close(self):
        if self.pil_image == None: return
        self.pil_image.close()
        self.pil_image = None

    def get_length(self):
        if self.pil_image == None:
            raise ValueError('File is closed')
        return self.length

    def seek(self, n):
        if self.pil_image == None:
            raise ValueError('File is closed')
        if n >= self.length:
            raise ValueError(f'Seeking frame {n} while maximum is {self.length-1}')

        self.pil_image.seek(n)
        a = self.pil_image.convert ('RGB')
        return a
mins
  • 6,478
  • 12
  • 56
  • 75
5

How about this?

ffmpeg -f gif -i infile.gif outfile.mp4

You may wanna tweak it a bit. Source: unix.stackexchange.com: How to do I convert an animated gif to an mp4 or mv4 on the command line?

Community
  • 1
  • 1
Behrooz
  • 1,696
  • 2
  • 32
  • 54
4

You could use the free and open source tool ScreenToGif

It contains a very neat editor which allows you to view the frames separately. Navigate them using arrows, and even change the duration of individual frames (or all frames at once), if you'd like.

Stefan
  • 919
  • 2
  • 13
  • 24
3

If you want to view a gif frame by frame -

This website lets you upload an image or paste an image url https://ezgif.com/split

It was helpful for me when trying to build tests for Conway's game of life.

danst3in
  • 69
  • 4