# Getting Gif and/or moving images into a LaTeX presentation

Im very new to presentations in Latex (ive been using powerpoint for years but have finally converted) and am wondering how to get a gif into a section. If needs be, can one not convert a gif into lots of pictures and have them overlay to give the impression of movement. Thanks!

• Yeah, if you mange to convert into "normal" pictures, than it is quite easy to include them with \multiinclude – user36296 Apr 23 '15 at 19:20
• I am in the process of doing this. How does one – iluvLatex Apr 23 '15 at 19:29
• How does one split my gif into images? – iluvLatex Apr 23 '15 at 19:34

1. Convert and split animated GIF into PNG sequence

convert -coalesce something.gif something.png


or

magick convert -coalesce something.gif something.png


convert/magick convert is a command line tool from the ImageMagick.org software package. The command name depends on the software version.

This produces a set of numbered PNG files something-0.png, ..., something-16.png (Here, the original GIF http://i.stack.imgur.com/VHJmL.gif, renamed to something.gif consists of 17 frames.) Option -coalesce is necessary to undo a possible optimization of the original GIF file.

2. Get original animation speed

magick identify -verbose something.gif | grep 'Delay'


Users of Windows may want to run

magick identify -verbose something.gif | sls -Pattern 'Delay'


in the PowerShell.

This outputs lines (one for every frame) like:

Delay: 10x100
Delay: 10x100
Delay: 10x100
...


The frame rate (frames per second), to be passed as an argument to the \animategraphics command below, is found by dividing the number after x by the number in front of it:

frame rate = 100 (tics/s) / 10 (tics/frame) = 10 frames/s

3. Embed PNG sequence as an embedded looping animation in the final PDF

(This kind of animation requires a JavaScript-supporting PDF viewer, such as Acrobat Reader.)

\documentclass{beamer}
\usepackage{animate}

\begin{document}
\begin{frame}{Embedded Animation}
\animategraphics[loop,controls,width=\linewidth]{10}{something-}{0}{16}
\end{frame}
\end{document}


Argument {10} sets the desired frame rate (frames per second), {0} and {16} set the first and last file numbers of the PNG series to be included in the animation. Note that frame rates above 30 FPS, if at all achieved by the PDF viewer, do not make much sense. 30 FPS is a typical value in video encoding. Use command option measure and the + button to see which frame rates are possible. They may depend on the image size and of course on the hardware on which the PDF viewer is running.

• @user4417 You need Acrobat Reader. – AlexG Mar 22 '16 at 7:28
• @user4417 You will also need the most recent animate package version 2016/03/15 . – AlexG Mar 22 '16 at 11:11
• @Royi The question is rather: Does the PDF standard support APNG? The answer is 'No'. You must convert it into a series of images and use one of the suggested methods (multipage PDF or animate-based animation). – AlexG Aug 28 '17 at 15:55
• The PDF format and its viewer are Adobe inventions. I think they still define and extend the standard, although PDF is now an ISO standard. – AlexG Aug 28 '17 at 16:07
• For someone else who stumbles upon this: The {0}{16} describes the first and last frame of the animation. You'll need to identify something.gif to determine how many frames are in the gif – inspectorG4dget Sep 18 '17 at 17:45

Ok, let's start with the .gif from @SeanAllred comment.

First Step: Converting

There are probably many methods to do so. To be independent of the operation system, there are online converter, like http://gifmaker.me/exploder/

or if you prefer using the command line use convert from ImageMagick:

convert -coalesce VHJmL.gif something.png


Make sure you resulting images are named something-0 and so on.

Second Step: multiinclude

\documentclass{beamer}
\usepackage{xmpmulti}
\begin{document}

%asuming you images are called "something-0.png" up to "something-16.png"
\begin{frame}
\transduration<0-16>{0}
\multiinclude[<+->][format=png, graphics={width=\textwidth}]{something}
\end{frame}

\end{document}


• i.stack.imgur.com/VHJmL.gif – Sean Allred Apr 23 '15 at 22:18
• It (the PDF) doesn't loop :-( – AlexG Apr 24 '15 at 14:38
• I get a slide per png file, but no animation. I can advance the "animation" myself, but then there are pauses and white screens. – user4417 Mar 22 '16 at 2:35
• @Dr.ManuelKuehner The animate approach is very smooth on Linux. Static, in fact. :( – cfr Jun 10 '18 at 21:48
• @Dr.ManuelKuehner On the other hand, this method is also static - there's just more that is static. :( – cfr Jun 10 '18 at 21:52

Have a look at pdfpc they have an example how to embed videos. pdfpc is a tool for displaying your beamer presentations.

It doesn't work with gifs but you can still convert something.gif something.avi. To get a preview picture run convert something.gif something.png

Example

\documentclass{beamer}
\usepackage{pdfpc-commands}

\begin{document}
\frame{\inlineMovie[loop&autostart&start=1]{something.avi}{something-0.png}{height=0.7\textheight}}
\end{document}


Display your presentation with pdfpc my-presentation.pdf

It doesn't seem to work if your video is in another directory set by \graphicspath.