0

So far I created several pngs in R and used ani.options and im.convert from the animation package to create a gif animation (ImageMagick is installed on Windows). It works without any problems:

`ani.options(nmax = 100, loop = 1, interval = 0.1)
 for(i in 1:100){
    name = rename(i)
    png(name)
    plot(...)
    dev.off()
 }
 im.convert("*.png", output ="animation.gif", convert = c("convert"), 
       cmd.fun = if (.Platform$OS.type == "windows") shell else system, 
       extra.opts = "",clean = TRUE)` 

Insead of png-files I would like to convert pdfs to a gif animation. Again I generated and saved several pdfs in a for-loop without any problems. The challenge is now to convert these pdfs to a gif-animation. I tried different approaches but I can't figure out how to modify the im.convert command and how to set ani.options parameters to combine the pdfs in a gif-animation.

So far, I tried setting ani.type and ani.dev to pdf and changed ".png" in im.convert to ".pdf".

I am gratefull for any suggestions.

Eva
  • 1
  • For me it worked to first convert all the pdf files to png files with `im.convert` and then to use `im.convert` to convert all those png files into a GIF. – Vincent Guillemot Jan 21 '19 at 13:08
  • When reading PDF file, you should specify a density before reading the PDF files. Since PDFs are vector (an may contain images), they must have a density to rasterize into some other format. If you leave off the density, then it defaults to density 72. You can read the PDF with some larger density and then resize to the desired raster file size that you want. – fmw42 Jan 21 '19 at 17:56

1 Answers1

0

I found the answer here: Error using magick R to import PDF

After installing the 64-bit version of GhostScript it worked.

Eva
  • 1