Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looping parameter is missing from write_gif_with_image_io() #629

Closed
tjdawson opened this issue Aug 9, 2017 · 2 comments
Closed

Looping parameter is missing from write_gif_with_image_io() #629

tjdawson opened this issue Aug 9, 2017 · 2 comments

Comments

@tjdawson
Copy link

tjdawson commented Aug 9, 2017

I couldn't get my gif to play once or loop a fixed amount of times, after looking at the declaration for this function on line 282 the parameter is missing from imageio.save() so the the variable is never passed through. Modifying it to the following fixed the issue:

def write_gif_with_image_io(clip, filename, fps=None, opt=0, loop=0,
                            colors=None, verbose=True):
    """
    Writes the gif with the Python library ImageIO (calls FreeImage).
    
    For the moment ImageIO is not installed with MoviePy. You need to install
    imageio (pip install imageio) to use this.

    Parameters
    -----------
    opt

    """

    if colors is None:
        colors=256

    if not IMAGEIO_FOUND:
      raise ImportError("Writing a gif with imageio requires ImageIO installed,"
                         " with e.g. 'pip install imageio'")

    if fps is None:
        fps = clip.fps

    quantizer = 0 if opt!= 0 else 'nq'
    writer = imageio.save(filename, duration=1.0/fps,
                          quantizer=quantizer, palettesize=colors, loop=loop)

    verbose_print(verbose, "\n[MoviePy] Building file %s with imageio\n"%filename)
    
    for frame in clip.iter_frames(fps=fps, progress_bar=True, dtype='uint8'):

        writer.append_data(frame)
@Julian-O
Copy link
Contributor

I am looking at turning this into a pull request (or you could do so yourself). Are you able to provide a test case that works now and didn't work before (and doesn't require someone to manually view the gif?)

@Julian-O Julian-O mentioned this issue Aug 10, 2017
@keikoro
Copy link
Collaborator

keikoro commented Nov 25, 2017

Looks like the linked PR was merged, so I'm closing this issue. Please reopen or create a new issue if the problems persist.

@keikoro keikoro closed this as completed Nov 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants