2D Animation/Shell script

From Wikiversity
Jump to navigation Jump to search

This learning resource is about creating a GIF animation from the command line from several images.

Learning Task[edit | edit source]

  • Create a sequence of images with a red circle that is bouncing on the ground.
  • You can use also LibreOffice Draw file with ab image as background and a red disk is bouncing with that image background.
  • Move the red disc or circle downwards and export the altered image to img01.png, img02.png, img03.png, img04.png, ... Keep in mind, that the second bounce is not as high as the first one.
  • After you have the sequence in a folder we will create an animated GIF from image from the shell with image magick.

Generation with a Script[edit | edit source]

The generation of the GIF-animation can be trigger with a script:

  • Change to the directory where the images are stored.
  • It might want to resize the images prior to backing the GIF-animation. You can do this with:
    mogrify -resize 320 *.png

After the optional step of resizing the images you back the GIF-animation. with

    convert -delay 100 -loop 0 img*.png myanimation.gif

Delay time is 100 milliseconds between each frame. Higher number make the animation run much slower. 25-30 frames per seconds is an frame rate for movies. Delay time 100 milliseconds is equivalent to 10 frames per second.

See also[edit | edit source]