Search code examples
rpdfmagick

Error using magick R to import PDF


I have hundreds of PDFs that I want to crop. For each PDF, I have a unique set of coordinates around which to crop. I am trying to use the R's magick package (version ImageMagick 6.9.9.14), but I receive an error when importing a PDF.

This example from the magick documentation throws an error:

 library(magick)
 manual <- image_read('https://cran.r-project.org/web/packages/magick/magick.pdf', density = "72x72")

The error I receive is "Error in magick_image_readpath(path, density, depth, strip) : Magick: PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/809"

When I check the config settings:

magick_config

I find that ghostscript is true. I am not sure if there are other settings required for reading in a PDF.

Has anyone else encountered a similar problem with magick? I am open to alternative packages with the ability to crop PDFs, if there are any.


Solution

  • I had the same problem on Windows. It was no R problem. In my case, I used ImageMagick 64-bit but had GhostScript 32-bit installed. After installing the 64-bit version of GhostScript it worked without any issues.