Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate card backs for user logins
#setup
library(magick)
windowsFont("Roboto")
# inputs
setwd("c:/Users/steph/Dropbox/Locke Data/LoginCards/")
myfile <- "MiniBack.pdf"
n<-100
# write.csv(data.frame(usernames=paste0("u",stringr::str_pad(1:n,pad = "0",width = 3))
# ,pwords=random::randomStrings(n,len = 6,digits = FALSE,loweralpha = FALSE))
# ,"users100.csv",row.names = FALSE)
up<- read.csv("users100.csv",stringsAsFactors = up$usernames[i])
# derivations
basename <- tools::file_path_sans_ext(myfile)
baseext <- tools::file_ext(myfile)
# process
myimage <- magick::image_read(myfile,density = 500)
relinfo <- paste("lockedata.biz", up$usernames, up$V1, sep = "\n")
for (i in 1:nrow(up)) {
myimage2 <- magick::image_annotate(
myimage,
"lockedata.biz",
font = "Roboto",
size = 90,
location = "+350+75"
)
myimage2 <- magick::image_annotate(
myimage2,
up$usernames[i],
font = "Roboto",
size = 90,
location = "+350+200"
)
myimage2 <- magick::image_annotate(
myimage2,
up$V1[i],
font = "Roboto",
size = 90,
location = "+350+330"
)
magick::image_write(myimage2, paste0("GeneratedBacks/",basename, up[i,"usernames"], ".", baseext))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment