I'm trying to automate adding my signature to my photos using the magick package - but I'm having problems saving them.
Here's my code:
file_list <- dir(".", pattern = "*.png")
mySig <- image_read("~/Desktop/sig1.png")
mySig <- mySig %>% image_resize("300x300")
newPhotos <-
for (i in 1:length(file_list)) {
img <- image_read(file_list)
photoSig <- img %>%
image_composite(mySig, gravity = "southeast", offset = "+20+20")
newName <- as.character(paste0("New_", file_list))
image_write(photoSig, newName, format = "png")
}
And I get the following error regardless of the script being in or out of a loop:
Error in file(con, "wb") : invalid 'description' argument
On top of this - even when I don't automate the name and just have the output called "test"
or something - it only saves one of the photos and not all of them. What am I doing wrong? Thanks!