ropensci / magick

Magic, madness, heaven, sin
https://docs.ropensci.org/magick
Other
459 stars 64 forks source link

`density` option when reading PDFs with `image_read` #22

Closed pboesu closed 8 years ago

pboesu commented 8 years ago

PDFs appear to be down sampled quite badly when you read them in currently. Is there a way to add a density argument to specify the resolution of a PDF when using image_read()? Something analogous to command line statements like convert -density 300 file.pdf file.png

jeroen commented 8 years ago

Right I noticed this as well. I'll try to figure this out. If you're on linux or mac, you can render pdf via pdftools:

library(pdftools)
library(magick)
bitmap <- pdf_render_page("https://cran.r-project.org/web/packages/magick/magick.pdf", 1)
img <- image_read(bitmap)
jeroen commented 8 years ago

I have added a desnity paramamter to image_read:

download.file("https://cran.r-project.org/web/packages/magick/magick.pdf", "magick.pdf")
page <- image_read("magick.pdf[1]", density = "300x300")
pboesu commented 8 years ago

Brilliant! Thank you.