saveSWF: Convert images to Flash animations

Description Usage Arguments Value Note Author(s) See Also

View source: R/saveSWF.R


This function opens a graphical device first to generate a sequence of images based on expr, then makes use of the commands in SWFTools (png2swf, jpeg2swf, pdf2swf) to convert these images to a single Flash animation.


saveSWF(expr, = "animation.swf", = "Rplot", swftools = NULL, ...)



an expression to generate animations; use either the animation functions (e.g. brownian.motion()) in this package or a custom expression (e.g. for(i in 1:10) plot(runif(10), ylim = 0:1)).

file name of the Flash file

the base file name of the sequence of images (without any format or extension)


the path of SWFTools, e.g. ‘C:/swftools’. This argument is to make sure that png2swf, jpeg2swf and pdf2swf can be executed correctly. If it is NULL, it should be guaranteed that these commands can be executed without the path; anyway, this function will try to find SWFTools from Windows registry even if it is not in the PATH variable.


other arguments passed to ani.options, e.g. ani.height and ani.width, ...


An integer indicating failure (-1) or success (0) of the converting (refer to system).


Please download and install the SWFTools before using this function:

We can also set the path to SWF Tools by ani.options(swftools = 'path/to/swftools').

ani.options('ani.type') can only be one of png, pdf and jpeg.

Also note that PDF graphics can be compressed using qpdf or Pdftk (if either one is installed and ani.options('qpdf') or ani.options('pdftk') has been set); see qpdf or pdftk.


Yihui Xie

See Also

Other utilities: im.convert, saveGIF, saveHTML, saveLatex, saveVideo

animation documentation built on May 29, 2017, 10:59 a.m.