I have a directory full of 100 .png images I'd like to convert to pdf.
The images are exactly the size I want the pdf to be.
I can create a multi-page pdf using magick
"manually" like this:
library(magick)
img1 <- image_read("image1.png")
img2 <- image_read("image2.png")
image_write(c(img1, img2), format = "pdf", "check.pdf")
But I'm having trouble getting the image_write command to accept a vector of filenames to automate this process. For example, I'd like to make a 100-page pdf from the .png images in my directory "test":
all_images <- list.files("test")
I thought that purrr
might help but no luck:
library(purrr)
image_write(map(all_images, image_read), format = "pdf", "check.pdf")
Any ideas?