photomoe

A simple package for downloading and collaging photos from online sources. magick does all the heavy lifting. You can download the development version from GitHub with:

devtools::install_github("jaytimm/photomoe")

Download images

library(tidyverse)
tweet_pics <- rtweet::search_tweets("#standwithukraine", 
                                    n = 1000, 
                                    include_rts = F) %>%
  filter(!is.na(media_url)) 
photomoe::img_download_images(link = unlist(tweet_pics$media_url)[1:49], 
                              dir = tempdir(), 
                              prefix = 'uk', 
                              scale_border = T)

Build collage

The img_build_collage function builds a collage per a user specified directory of images -- based on the magick package and this very nice post.

#standwithukraine

photomoe::img_build_collage(dir = tempdir(), 
                            dimx = 7, 
                            dimy = 7, 
                            prefix = 'uk')

Google image links

search1 <- 'pointing at rainbows'
search2 <- 'piano keys'
links <- lapply(list(search1, search2), 
                photomoe::img_get_gurls)

head(links[[1]])

pointing at rainbows

photomoe::img_download_images(link = links[[1]], 
                              dir = tempdir(), 
                              prefix = search1, 
                              scale_border = T)

photomoe::img_build_collage(dir = tempdir(), 
                            dimx = 5, 
                            dimy = 4, 
                            prefix = search1)

piano keys

photomoe::img_download_images(link = links[[2]], 
                              dir = tempdir(), 
                              prefix = search2, 
                              scale_border = T)

photomoe::img_build_collage(dir = tempdir(), 
                            dimx = 5, 
                            dimy = 4, 
                            prefix = search2)


jaytimm/photomoe documentation built on Aug. 13, 2022, 9:43 p.m.