How to include animated GIF in LaTeX / PDF

pablgonz shared this question 7 years ago
Answered

GeoGebra allows exporting animated GIF images but does not export the Protocols of Construction, the ide of this post is how to include GIF and animated Construction Protocols in LaTeX.

[size=150]Animated GIF[/size]

For include animated GIFs Need ImageMagick program and one GIF animated, for this example we use the picture hypo_hypotrochoid_001.gif

hypo_hypotrochoid_001

from http://www.geogebra.org/for...

Now follow steps

1. Create a directory called test and copy hypo_hypotrochoid_001.gif

2.The following is convert the image into separate files, we have two cases

a) For Latex users (latex>dvisps>ps2pdf) open a command prompt, move to the test directory and enter the following line

    convert hypo_hypotrochoid_001.gif -coalesce animate_%d.eps

then create the directory imgeps and copy ALL pictures in this.

b) For pdfLatex users (xelatex,lualatex) open a command prompt, move to the test directory and enter the following line

    convert hypo_hypotrochoid_001.gif -coalesce animate_%d.pdf

then create the directory imgpdf and copy ALL pictures in this.

With this we have completed the process of conversion of images, we can now create your TEX file

3.We create a tex file and add the following lines into the preamble

    \usepackage{graphicx}

    \usepackage{animate}

4. And the body of the document add the line

a)For LaTeX

    \animategraphics[height=2.8in,autoplay,controls]{12}{imgeps/animate_}{0}{120}

v)For pdfLaTeX

    \animategraphics[height=2.8in,autoplay,controls]{12}{imgpdf/animate_}{0}{120}

Compiled and finish, we have a PDF with an animated image.


[size=150]Construction[/size]

To animated construction step we use the environment animateinline, this environment allows separate figure for steps, this will use the \newframe, the idea goes like this, we create our figure with GeoGebra and export, depending on the situation we have to add different lines.

1. Pstricks

    \begin{animateinline}[

    begin={\begin{pspicture*}(...,...)(...,...)},

    end={\end{pspicture*}},

    controls,autoplay,timeline=time1.txt]{1}

    \psset{...}

    \code

    \newframe

    \code

    \newframe

    ...

    \end{animateinline}

2. PGF/TiKZ

    \begin{animateinline}[

    begin={

    \begin{tikzpicture}[...]

    \clip(...,...) rectangle (...,...);

    },

    end={\end{tikzpicture}},

    controls,timeline=time2.txt]{1}

    \code

    \newframe

    \code

    \newframe

    ...

    \end{animateinline}

Now we must create the "timeline", this is a file containing the order and time of the transparencies, the amount of overhead this ity in the amount of \newframe which is used, this file has the following form

    ::0x0

    ::1x0

    ::2x0

    ::3x0

    ::4x0

    ::5x0

To fully understand how it works you should read the documentation of animate (texdoc animate for TeXLive)

Compressed file attached two examples pstanimate.pdf and tikzanimate.pdf

Hope this helps for users of GeoGebra and LaTeX

Saludos

Pablo1fe385aa9882b88f7cf1296b053b5526

Comments (12)

photo
1

The idea behind this post is simple, to create animations geogebra need the basic knowledge of construction using ruler and compass.


GeoGebra is a powerful software in many ways, and one of its strengths is the ability to export in Pstricks and PGF / TiKZ.


The idea of ​​using animate for construction is quite comfortable, easy to insert the code in a beamer presentation or a PDF document.

(maybe in the future developers implement by default, is just a dream).


Anyway, here is another example of the use of animate, First circle of Pappus, of course created with pstricks (try to create code with TiKZ but was exported many mistakes and I am no expert in TiKZ)

915e47b835e7cb95d71a0e886f191073


https://ggbm.at/553373


With my compliments, Pablo.

Please, let me add the att'd 2-figure screenshot in order to specify latex compiling instructions.

--------

Besides, I'm pleased to notice this forum that Pablo is the author of a perl script (tikzimg), actually under CTAN investigation, which performs high rendering geometrical figures with the following multiplatform command:

    I follow your instruction but I don't know where to get all the softwares you mention in the post four years ago.


    When I click on Export Menu, I see "Graphic View as Animated Gif (or other program you mentioned in this post.) Will the animated GIF do the wonderful animation as you posted?


    Anyway I choose "Graphic View as Animated GIF" and see a small screen appear. However, I cannot interact with this screen.


    Could you please help?

    Thank you so much for your response.

photo
4

Hi,

Hi everyone!

I like to create an animate ggb file to post on my website in the way that viewers don't have to have ggb software to view it.

I follow your instruction but I don't know where to get all the softwares you mention in the post four years ago.


When I click on Export Menu, I see "Graphic View as Animated Gif (or other program you mentioned in this post.) Will the animated GIF do the wonderful animation as you posted?


Anyway I choose "Graphic View as Animated GIF" and see a small screen appear. However, I cannot interact with this screen.


Could you please help?

The protocol proposed above concerns the inclusion of the gif images in Latex texts.

Include GIF images in a website is simpler: see some examples below, :)

https://lphwikispace.wikisp...


Anyway, GGB exports the GIF images animated with a chosen parameter, in the format of the graphic window (GV). This last point is important on websites because of the weight of the image must be reasonable (~250 ko) so that the load remains fast. The protocol is the following: :D :D

1. Choose the graphic view (GV) format,

2. Go to : File>Export> GV as animated GIF,

3. Choose the slider, and adjust the time between two frames (~200 ms, perhaps some tries could be necessary) and export,

4. A GIF viewer (firefox or internet explorer, for example) is necessary to admire your work,

5. Import the image in your website.


Remind you that a GIF image remains… an image! :anguished:

And a way to interact with an image is to attach a link towards a GGB animation for example (see some examples in the link above). :D


Cheers, :wink:

Phil

photo
1

Hi Phil,

Thank you for your reply. I got it.

Now I have another question.

How do I resize the animated GIF file?

My file now is 12MB.


Thank again for your help.

photo
1

Hi tphanyamada,

How do I resize the animated GIF file?

My file now is 12MB.

Whaoo! That’s a very fat one! :anguished:


Anyway, the weight of your image depends upon several parameters. A GIF image is a sequence of images for which you have to adjust the size of each one and the number of images for the sequence. You have to change each parameter one by one and try: :)


a. The size of the graphic view (GV): for a small web size (314x235px), medium web size (448x336px), wider size (640x480px),

b. Choose the slider and its increment,

c. Adjust the time between two frames (~250ms generally or 100ms for the fast movements).


Several tries are necessary to obtain a satisfactory result.


Cheers, :wink:

Phil

photo
1

Works in Adobe Reader and Adobe Professional. DOESN'T work in Foxit Reader.

photo
1

I have problems with the 2nd step. I use WinEdt 6.0 + MikTeX 2.9.


My steps:

1) Accessories - WinEdt Console... (it appears)

e76d34a49d275cc32c24fc99813c94cf

2) Try "Command Prompt" (left chosen button)

>CD C:\Users\Stranger\Documents\test

>convert hypo_hypotrochoid_001.gif -coalesce animate_%d.pdf


Error! "convert" is not recognised as an internal or external command, operable program or batch file.

3) The same if I use "Windows CP"


Could you help me, please? :)

P.S. I tried "convert hypo_hypotrochoid_001.gif -coalesce animate_%d.eps"

P.P.S. I have doubts about using filter "convert". As far as I know this filter is used for changing the file system of a hard disk.

Files: LTX.png
photo
1

I find a way out - VirtualDub [1.62MB] (Little free program, which doesn't need any installation).


We will use the smile as an example.

8905219


1) Run VirtualDub, File - Open Video File - Choose and open our animation.

3e7fba3697f1055caabd5e1d21fc2a11

2) File - Export - Image Sequence


Choose necessary features, format, file numeration:

8e347ba987597875e4fd0dd0e3fd1e3668901746f290db0453be543ec99e5d42

3) Ready!


9274595


Via pcforum.com.ua


!Attention

Latex code for this example.

    or
    I have problems with the 2nd step. I use WinEdt 6.0 + MikTeX 2.9.
    I think there is a mistake or confusion on how to use GeoGebra to create animated GIF or how to create them. :confused:


    There is a lot of free (or not) software capable to create animated GIF but here is not the purpose, and it is necessary to go on one of the numerous specialized websites to find of assistance. :?


    Here we are only talking about GeoGebra who gives the possibility of making educational GIF animations, see some examples below (and above):

    https://lphwikispace.wikisp...

    The steps to create educational GIF animations are detailed in the posts above. :D


    Cheers, :wink:

    Phil

photo
1

Dear, LPH.

We speak about different things ;) I don't have any problems with making an animation file. I had problems with embedding it in PDF/LaTeX and as far as I understand the topic is devoted to this problem, not

GeoGebra who gives the possibility of making educational GIF animations

photo
2

My apologies for not clarifying, the command "convert" in win$ is a command to convert formats drives (NTFS to FAT32) the custom of having made ​​me forget linux to be installed "ImageMagick", and "media9+ pdfTeX + Animate" to create fabulous files (media9 to embed videos and many thing more) and only using free tools...

my apologies for forgetting

Saludos

Pablo

photo
1

I created an animiated PDF of the drawing today;

it looks so cool.


thank you pablo.

© 2019 International GeoGebra Institute