Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have found placing animations in a .pdf (Portable Document Format) file beginning with a .gif animation challenging. At this stage my result in having animations in a .pdf file appears quite primitive compared to putting the animations in a .html file using the programs LaTeX and LaTeX2HTML using the advice kindly provided to me by Nasser M. Abbasi. Nevertheless here I will describe some of what I have done so far in that direction and present some problems I encountered.

From a "javalatex" Web page within wikipedia on the WorldWide Web I learned that pdflatex does not support the use of .gif images. From what I have read on the Internet at least one way to deal with this matter is to convert the .gif images in an animated .gif file to a series of .png (Portable Network Graphics) images, one for each frame in the .gif file containing an animation. Following the advice on the Web page. I installed the free program ImageMagick in a Windows XP Home Edition operating system and subsequently used a command in a command-prompt of the following form to effect the conversion from an animated .gif file to a series of .png files:

convert MyFile.gif MyFile%05d.png

The result was that gratefully many .png images were produced with names of the form MyFile00000.png, MyFile00001.png, MyFile00002.png, et cetera (Previously I had downloaded something from ImagicMagick's Web site which appeared to provide online conversion of a file from the .gif to the .png format in my Mozilla Firefox Web browser. By clicking on "File Tools" right on my Firefox Web browser and then selecting "Image Converter" among the subsequent choices I could have access to that capability. But that conversion did not work for me.).

Previously I had installed Alexander Grahn's animate software package for TeX Live in an openSUSE-12.2, Linux operating system. I think I obtained it via the Comprehensive TeX Archive Network (CTAN) Web site http://tug.ctan.org/tex-archive/macros/latex/contrib/animate/doc/animate.pdf. Following some of probably his or else Jim Hefferon's advice I had downloaded the file animate.zip and in my case extracted its contents in the directory /usr/share/texmf. Fortunately most, if not all of the software requirements for the animate software package appear to be contained in a modern version of TeX Live.---Unless this was done for me in the process of updating openSUSE-12.2 software, at least I haven't knowingly and especially downloaded and installed any new software packages other than the animate package to add to my installation of TeX Live lately.

For the purpose of making the .pdf output file containing animated figures I followed much of Alexander Grahn's advice and input or else already had commands of the following form into my .tex file:

\documentstyle[a4paper,12pt]{article}
\usepackage{animate,graphicx}

\begin{document}
In \hyperref[ref]{Figure (Fig. 1)}{Figure (Fig. 1)}{}{MyFigure}

\begin{figure}

\begin{center}
\animategraphics{30}{MyFile}{00000}{00097}
%for 30 frames/second each with a name of the form MyFile00000.png, 
MyFile00001.png,     ........, MyFile00097.png
%Figure caption here
\label{MyFigure}
\end{center}
\end{figure}
.....
.....
\end{document}

Then I executed the command of the form pdflatex MyFile.tex. Following that execution I eventually opened the output file with a name of the form MyFile.pdf in Acrobat Reader 9.5.1 and Adobe Reader X 10.1.4. I think in each case I had to click on an animated image in the .pdf file to start its animation after seeing the image of I think a small, white, right hand with an upward-pointing index finger on it. But after that first clicking a popup window appeared containing the message "Please Note: Click 'sign' to fill out and sign this form," a message which did not apply to my .pdf file. After closing that window by perhaps clicking on an "X" in its upper-right-hand corner, I think the animation began. I think the animation was executed once for each click on an animated figure in the .pdf file. (It seems like I might have seen somebody else's .pdf file containing an animated figure which did not require my clicking on it to get that animation started. That animation might have only been the drawing of a colored curve. And that animation might have continued in a repetitive fashion. If so, I think I like those behaviors better for a reader of a .pdf document than the ones I obtained which I report here.). There were some problems:

  1. The vertical dimension appeared to be compressed compared to the horizontal dimension. The animations each proceeded from left to right. By the time the final frame was reached in the animation the vertical dimension was obviously highly compressed compared to the horizontal dimension. And I think the horizontal dimension of an object in the animation may have been horizontally stretched in the course of the animation so that the last image showed an object or objects which were much more horizontally stretched than at the beginning of the animation. Right now I suppose I can't rule out the possibility that what I saw could be explained by just the horizontal stretching alone without any vertical compression.---The result of either stretching in the horizontal dimension or compression in the vertical dimension makes a circle appear as an ellipse that is longer in the horizontal than in the vertical direction.
  2. Although one to-be animated image initially had good color and proportions between its vertical and horizontal components before starting the animation with a click on it, I think parts of the frame images could not be seen at all during the course of the animation.---That is during the animation I think parts of the image could be seen; and parts of them could not be seen.

I suppose that if by me doing things more correctly than I have up to now that better results could imaginably be obtained for animated figures in a .pdf file produced from an animation originally contained in a .gif file. Please advise me on how to eliminate the problems 1 and 2 and, if possible, how to make continuously running animated figures which do not require clicking on them to start them in an output, .pdf file produced using the program pdflatex executing on a .tex file.

Edit 2012-11-02:

Removing the \begin{figure}[h], \end{figure} environment and the \begin{center}, \end{center} commands around my \animategraphics..... command and the \parbox.... figure-caption command below the \animategraphics.... command unfortunately did not eliminate the distortion. I left a \label{...} command in place under the \animategraphics.... command. Looking at some of the .png (Portable Network Graphics) files in the program GIMP [Gnu's Not Unix (GNU) Image Manipulation Program], they did not appear distorted; only in my output, .pdf file did I notice their distortion. From my inspection using GIMP I did notice an offset which increased in the images from left to right in the animation. But that might be normal to make the objects in the animation appear to be moving from left to right. When opening the .png files in GIMP I clicked on a button to ignore such offsets, which made the images displayable within the GIMP window area.

One concern I probably haven't fully explored is that the software package animate's producer Alexander Grahn wrote that his package animate requires the program pdftex, whereas I have been using the program pdflatex on my .tex file, which uses the graphicx and animate among other software packages. The version of the program pdflatex that I have been using handled my command \documentstyle[a4paper,12pt]{article} in my .tex file better than the version of the program pdftex that I used. Alexander Grahn also wrote, "Package animate supports the usual PDF making workflows, i. e. pdfLATEX, LATEX -->dvips-->ps2pdf/Distiller and (X E)LATEX ---> (x)dvipdfmx." So that looks at least encouraging regarding whether the program pdflatex can also work well with the animate package or not.

I request that no one take any of my comments here in a personally critical way.---My goal here is to get a procedure working for myself to produce animated figures in a .pdf file when the figures were originally .gif (Graphic Interchange Format) files, before converting those files containing animations to a series of .png file using the free program ImageMagick. I appreciate Alexander Grahn kindly producing his probably free software package called animate for use in an installation of the TeX Live group of computer programs.

share|improve this question

migrated from stackoverflow.com Nov 5 '12 at 12:32

This question came from our site for professional and enthusiast programmers.

    
Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Martin Schröder Nov 5 '12 at 20:17

1 Answer 1

Some animated GIFs are optimized for size. That is, only differences between frames are stored in the file. In order to produce self-contained PNGs that are amenable to embedding with the animate package, the given GIF must be un-optimized before exploding it into the constituent single-frame files. You can use gifsicle for this purpose:

gifsicle --unoptimize orig.gif > unopt.gif

Now, the numbered PNG sequence can be produced from unopt.gif using convert from ImageMagick.

To start animations automatically without click, use the autoplay option of \animategraphics. Option loop continuously repeats the animation.

The AdobeReader message you have cited can be suppressed once and for all by checkmarking something like 'Do not show again' in the message box that pops up.

The pdflatex command just invokes the pdftex binary with the LaTeX format preloaded. And yes, animate is a LaTeX package. Thus (pdf)latex must be run on the LaTeX input file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.