Skip to content

Commit

Permalink
gif has fps param
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Jan 30, 2015
1 parent 52e1bf6 commit d14fe0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions imageio/plugins/freeimagemulti.py
Expand Up @@ -154,7 +154,9 @@ class GifFormat(FreeimageMulti):
duration : {float, list}
The duration (in seconds) of each frame. Either specify one value
that is used for all frames, or one value for each frame.
Default 0.1
fps : float
The number of frames per second. If duration is not given, the
duration for each frame is set to 1/fps. Default 10.
palettesize : int
The number of colors to quantize the image to. Is rounded to
the nearest power of two. Default 256.
Expand Down Expand Up @@ -195,8 +197,8 @@ class Writer(FreeimageMulti.Writer):
# todo: subrectangles
# todo: global palette

def _open(self, flags=0, loop=0, duration=0.1, palettesize=256,
quantizer='Wu', subrectangles=False):
def _open(self, flags=0, loop=0, duration=None, fps=10,
palettesize=256, quantizer='Wu', subrectangles=False):
# Check palettesize
if palettesize < 2 or palettesize > 256:
raise ValueError('PNG quantize param must be 2..256')
Expand All @@ -210,7 +212,9 @@ def _open(self, flags=0, loop=0, duration=0.1, palettesize=256,
if self._quantizer is None:
raise ValueError('Invalid quantizer, must be "wu" or "nq".')
# Check frametime
if isinstance(duration, list):
if duration is None:
self._frametime = [int(1000 / float(fps))]
elif isinstance(duration, list):
self._frametime = [int(1000 * d) for d in duration]
elif isinstance(duration, (float, int)):
self._frametime = [int(1000 * duration)]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_freeimage.py
Expand Up @@ -383,7 +383,7 @@ def test_animated_gif():
imageio.mimsave(fnamebase + '.animated_irr.gif', ims, duration=duration)

# Other parameters
imageio.mimsave(fnamebase + '.animated.loop2.gif', ims, loop=2)
imageio.mimsave(fnamebase + '.animated.loop2.gif', ims, loop=2, fps=20)
R = imageio.read(fnamebase + '.animated.loop2.gif')
W = imageio.save(fnamebase + '.animated.palettes100.gif', palettesize=100)
assert W._palettesize == 128
Expand Down

0 comments on commit d14fe0d

Please sign in to comment.