extract_images: Extract and save images

View source: R/extract_images.R

extract_imagesR Documentation

Extract and save images

Description

Work through an rtweet timeline object to extract and save images in specific folders. If multiple images were posted in a grid, this extracts each and puts them into a grid format. If 2 images, a 1x1, if more than 2 it automatically gets put into a 2x2 tile using magick::image_montage(). A helper function reads and scales images so that we can montage without needing to map, per https://stackoverflow.com/questions/52833932/pass-a-list-of-image-objects-to-a-r-magick-function-instead-of-a-vector

Usage

extract_images(year, index, img_ct, img)

Arguments

year

Year of the Twitter post

index

Image number; each tweet/image is numbered

img_ct

How many images were used in the Tweet

img

url of the image(s)

Examples

## Not run: 
tmp <- tibble(status_id = 1144617178710388737,
ext_media_url = "http://pbs.twimg.com/media/D-J_QYPXoAAWw2d.jpg",
creaated_at = 2019-06-28 07:42:56, year =2019, index = 01, img_ct = 1)
purrr::pwalk(list(tmp$year, tmp$index, tmp$img_ct, tmp$ext_media_url), extract_images)

## End(Not run)

taylorgrant/twAccount documentation built on March 20, 2022, 7:33 p.m.