algorithmic modeling for Rhino

Animated gif encoding within grasshopper

Despite the age of the format, gifs remain a popular and very widely supported way to share small animations. The slider animation function in Grasshopper makes it easy to turn definitions into a sequence of images, but until now you still needed some additional software to actually turn them into playable animations. I used to use VirtualDub for this, but felt it would be nice to be able to do this quicker and without leaving Grasshopper.

The attached component lets you simply specify the filepath of the first frame in a sequence, choose a framerate, then it automatically finds the consecutive images and compiles them into an animated gif.

...and since I'd hate for this to lead to a flood of oversized files - remember, one of the things that makes animated gifs so nice is that they can load and play quickly almost anywhere, but this advantage is lost if the files are too large. When creating your slider animation frames, choose a small resolution, and don't make too many frames. 50 frames at 400x300 pixels is often plenty. If you do want to make something epic and hi-res, stick to a proper modern compressed video format.


Views: 7247


You need to be a member of Grasshopper to add comments!

Join Grasshopper

Comment by Daniel Piker on October 18, 2016 at 10:11am

Hi AJ - do you have your still images saved with names like "name_001.png","name_002.png" and so on?

Also - don't use numbers in the first part of the file name like "animation4name_001.png" or it will get confused trying to find the sequential files.

Comment by AJ on October 18, 2016 at 8:38am

not working for me

any ideas why?

i get 1kb gif file from the compiled images (from some reason it take a micro sec and say its done)


Comment by Vicente Soler on March 30, 2016 at 4:21am

It becomes disabled on purpose. To run it again you just have to enable it and it will disable itself again at the end. I prefer this method for scripts I want to run manually over having a boolean input. If you use a boolean toggle you might forget to turn it off, if you use a button it's not guaranteed it will only run once with the input as true.

Comment by Daniel González Abalde on March 30, 2016 at 3:53am

Awesome Vicent,

I had to look up the references anyway. They are (.net 4.6) WindowsBase.dll, PresentationCore.dll and System.Xaml.dll. For some reason the script remains blocked and there are not changes in the viewport, but generates the gif! Really fast! Thank you.

Comment by Vicente Soler on March 30, 2016 at 2:20am

Based on this idea, to make things even quicker, attached is a scripting component that replaces the slider + animation function and saves a gif directly without generating the intermediate frames (they are only stored in memory).

Rather than adding the code to generate the gif (as in Daniel's script) I used a built in C# class for this, but it's probably worse. First, you can't set a custom delay between frames for some reason (the WinRT analog of this does support it). Second, you'll have reference the required assemblies. If you have the latest .NET framework, hopefully they are in the same folder path as in my computer so you shouldn't have to relink them.

Comment by Igor Mitrić Lavovski on March 26, 2016 at 5:15pm
Great! Thanks!
Comment by I_M_F [Iker Mugarra Flores] on March 24, 2016 at 2:08pm

super cool!

Comment by Pieter Segeren on March 24, 2016 at 1:41pm

Very handy :) Thank you Daniel.

Comment by Daniel González Abalde on March 24, 2016 at 1:12pm


I had this in my pending tasks. With quality/sample of 1 took me 3 minutes to 9 images. But it's great anyway.
Thank you :)





  • Add Photos
  • View All


  • Add Videos
  • View All

© 2022   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service