# install quickcode if not available
# install.packages(quickcode)
# load quickcode library
library(quickcode)
#clean() #clear the environment
# let's load the r2resize to provide toolbars for the image resizing
library(r2resize)
add.resizer(line.color = "brown", line.height = "3", default.image.width = "30%")
For this example, we will download 3 random png images from the web in the category of ‘school’ to a temp directory and then display it. The r2resize package provides the image resizer that lets us view the images nicely below.
storlocation <- tempdir()
genRandImg(fp = storlocation, n = 3, cat = "school", ext = "png")
## Downloaded 3 files to C:\Users\in198\AppData\Local\Temp\Rtmp04myXm
getdownloadedfiles = list.files(path = storlocation, pattern = ".png", full.names = TRUE)
Display the images:
For this example, we will download 6 random jpg images from the web in the category of ‘school’ to a temp directory and then display it.
storlocation2 <- tempdir()
genRandImg(fp = storlocation2, n = 6, cat = "animals", ext = "jpg")
## Downloaded 6 files to C:\Users\in198\AppData\Local\Temp\Rtmp04myXm
getdownloadedfiles = list.files(path = storlocation2, pattern = ".jpg", full.names = TRUE)
Display the images: