Group Abstract Group Abstract

Message Boards Message Boards

How to export GIFs

GROUPS:
Hello everyone!
I thought I'd share a quick tutorial for exporting GIFs in Mathematica, since I get asked that a lot, and I think it's a great way of sharing interesting visualisations with a large audience on the web.
First define a function frame:
frame[t_] :=
Show[
Graphics[{Circle[{-1, 0}, 1], PointSize[Large],
   Point[{Sin[t] - 1, Cos[t]}], Red,
   Line[{{-1, 0}, {Sin[t] - 1, Cos[t]}, {0, Cos[t]}}]}],
Plot[Cos[x + t], {x, 0, 2 Pi}, PlotRange -> {-1, 1}],
ImageSize -> 300];

Then generate a list of the frames (not including the last frame here, as frame[2 Pi] is the same as frame[0]):
frames = Table[frame[t], {t, 0, 2 Pi, (2 Pi)/50}][[;; -2]];

Now you can export this as a gif:
Export["animation.gif", frames]

POSTED BY: Matt Henderson
Answer
1 year ago
This is very nice, Matt, thank you! I am actually too a big fan of gifs and trying to use them as much as possible. For example I just made one in this post walks on Pi. GIFs, despite some shortcomings, are still a very cheap and neat media to deliver animations. I like a lot, btw, your gif-blog and am wondering if you aware of a similar in nature blog called ARCHERY ?

Anyway, I'd just wanted to say to everyone else that GIFs are pretty cool - because they are so easily embeddable in posts! And One doesn't have to make animations only. You can convert short videos into GIFs and even represent 3D objects differently. For example, this is a 3D image of scan from a real car engine:
engine = ExampleData[{"TestImage3D", "CTengine"}]



And this is how you can swap through its layers with a GIF:
Export["test.gif", Image3DSlices[engine]]

POSTED BY: Vitaliy Kaurov
Answer
1 year ago
Hi Matt! I am a long-time fan of your blog. Last week I published some animated GIFs using the same steps as you, thank you for sharing this quick tutorial.
Vitaliy, that's great. I've just explained the inverse operation of what you did, the process of taking an animated GIF to obtain a 3D object emoticon  

Visualizing Animated GIFs Along The Time Dimension With Image3D
.


Answer
11 months ago
Hello, guys.
Thank you very much for the information. Examples are very complete and easy to perform.

It has long sought.
POSTED BY: marife cuauro
Answer
11 months ago