| genRandImg | R Documentation |
Generate n number of high-definition images by category from the web
genRandImg( fp, cat = imageCategories, n = 1, w.px = 500, h.px = 500, ext = "jpg" )
fp |
CHARACTER. storage directory |
cat |
CHARACTER. category of image to download |
n |
NUMERIC. number of images to download, maximum n is 99 |
w.px |
NUMERIC. width in pixels |
h.px |
NUMERIC. height in pixels |
ext |
CHARACTER. file extension eg jpg, png |
downloaded image from a select image category
The random images are downloaded from www.unsplash.com
Categories for 'cat' argument include
"3D", "animals", "architecture", "backgrounds", "beauty", "experimental",
"fashion", "film", "food", "interior", "nature", "people", "renders",
"school", "sports", "travel", "unsplash", "wallpapers".
Image categories can be captured in a separate vector as a cross-reference made available to the cat argument.
For example:
imgcat= c("3D", "animals", "architecture", "backgrounds", "beauty", "experimental", "fashion", "film", "food", "interior", "nature", "people", "renders", "school", "sports", "travel", "unsplash", "wallpapers")
genRandImg(fp, cat = imgcat[9], n = 5)
This functionality is great for developers trying to obtain one or more images for use in displays/analysis or simply to build robust web applications.
# download 2 image from the nature category genRandImg(fp = tempdir(),cat = "nature", n = 2) # download 4 random images with width = 600px and hight 100px genRandImg( fp = tempdir(), cat = "fashion", w.px = 600, h.px = 100) # download 10 random images with extension png genRandImg(fp = tempdir(),cat = "food", n = 10, ext = "png") # download 200 random images from category of school # Note that maximum download is 99, so the function will only download 99 genRandImg(fp = tempdir(),cat = "school", n = 200)