Learn R Programming

animation (version 2.7)

im.convert: A wrapper for the `convert' utility of ImageMagick or GraphicsMagick

Description

The main purpose of these two functions is to create GIF animations.

Usage

im.convert(
  files,
  output = "animation.gif",
  convert = c("magick", "convert", "gm convert"),
  cmd.fun = if (.Platform$OS.type == "windows") shell else system,
  extra.opts = "",
  clean = FALSE
)

gm.convert(..., convert = "gm convert")

Arguments

files

either a character vector of file names, or a single string containing wildcards (e.g. Rplot*.png)

output

the file name of the output (with proper extensions, e.g. gif)

convert

the convert command; it must be 'magick', 'convert' or 'gm convert'; and it can be pre-specified as an option in ani.options('convert'), e.g. (Windows users) ani.options(convert = 'c:/program files/imagemagick/convert.exe'), or (Mac users) ani.options(convert = '/opt/local/bin/convert'); see the Note section for more details

cmd.fun

a function to invoke the OS command; by default system

extra.opts

additional options to be passed to convert (or gm convert)

clean

logical: delete the input files or not

...

arguments to be passed to im.convert

Value

The command for the conversion.

If ani.options('autobrowse') == TRUE, this function will also try to open the output automatically.

Details

The function im.convert simply wraps the arguments of the convert utility of ImageMagick to make it easier to call ImageMagick in R;

The function gm.convert is a wrapper for the command gm convert of GraphicsMagick.

References

Examples at https://yihui.org/animation/example/im-convert/

ImageMagick: http://www.imagemagick.org/script/convert.php

GraphicsMagick: http://www.graphicsmagick.org

See Also

Other utilities: saveGIF(), saveHTML(), saveLatex(), saveSWF(), saveVideo()