# Exporting animation created with animate package

Consider the following minimal working example. It's great to have an animation in pdf format. But sometimes it would be good to be able to export it into an animated gif or something else (swf, video file, svg?). How do I achieve this? I often have animations together with pgfplots.

\documentclass{article}

\usepackage{animate}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{animateinline}

\begin{document}

\begin{center}
\fboxsep1mm
\begin{animateinline}[autoplay,loop]{2}
a
\newframe
b
\newframe
c
\end{animateinline}
\end{center}

\end{document}


Remark:

The animation is not visible in all pdf viewers. It surely works with a current Adobe Reader.

-
See my answer that can produce many output format in one click. –  kiss my armpit Oct 12 '13 at 15:14

After redefinition of some animate macros, LaTeX produces a multipage document which can be converted to SWF using pdf2swf or to bitmapped formats using other tools, e. g. dvipng.

\documentclass{article}

\usepackage{animate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[active,tightpage]{preview}
\makeatletter
\renewenvironment{animateinline}[2][]{%
\setboolean{@anim@inside}{true}\begin{preview}}{%
\end{preview}\setboolean{@anim@inside}{false}}
\renewcommand{\newframe}[1][]{\end{preview}\begin{preview}}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{center}
\begin{animateinline}[autoplay,loop]{2}
a
\newframe
b
\newframe
c
\newframe
\multiframe{3}{i=0+1}{\i}
\end{animateinline}
\end{center}

\end{document}

-
Thanks! Is was hoping for a way that doesn't include changing the internal code of the animate package. –  Manuel Kuehner Oct 8 '13 at 20:55
Apparently there is no 'easy' alternative to your approach. Thanks for the answer! –  Manuel Kuehner Oct 16 '13 at 11:38
I might add some code to animate in the future that detects whether preview was loaded and which then takes the necessary actions. –  AlexG Oct 16 '13 at 11:45
Thanks. Looking forward to it. Animate is a great package - I use it a lot. –  Manuel Kuehner Oct 16 '13 at 12:11