standardize_photos: A function to standardize photos for RICH economic games or...

View source: R/standardize_photos.R

standardize_photosR Documentation

A function to standardize photos for RICH economic games or roster-based social network approaches

Description

This function allows you to speed up photo standardization. Simply set a path to the main folder. The filenames of all raw photos should have same string length. These should be the IDs of the respondents. Then run the function. Photos can be croped, rotated, and resized to a constant aspect ratio. This function relies on 'imager'. First, if spin=TRUE click a quadrant of the photo to determine how it should be spun (See details below). Then drag a box to crop. Eyeball the aspect ratio you want, then the program will find the closest box with the legal aspect ratio. Files are saved to the StandardizedPhotos subfolder.

Usage

standardize_photos(
  path,
  pattern = ".jpg",
  start = 1,
  stop = 3,
  size_out = 1000,
  border_size = 10,
  asr = 1.618,
  id_range = NULL,
  id_names = NULL,
  spin = FALSE
)

Arguments

path

Full path to main folder.

pattern

File extension. Should be ".jpg" or ".JPG".

start

Location of start of PID in file name. If files are saved as "XXX.jpg" for example, this is 1.

stop

Location of end of PID in file name. If files are saved as "XXX.jpg" for example, this is 3.

size_out

Pixel width of outputted JPGs.

border_size

Add a black border of X pixels.

asr

Aspect ratio of outputted JPGs.

id_range

If a value is provided here OR in id_names, then not all photos will be processed. Use a vector of numbers here to indicate which IDs to process: i.e., c(1:13) to run on only the first 13 photos.

id_names

Or, just give the IDs themselves: i.e., c("XX1","XX2","XY1").

spin

If spin is set to TRUE, then a two step process is opened. First the user selects a spin, then the user crops. On the first pop-up, by clicking in the upper-left corner, the photo is not spun. If one clicks on the upper-right a 90 clockwise spin is done before opening the cropping window. Bottom-right, 180. Bottom-left, 270.

Examples

## Not run: 
standardize_photos(path=path, pattern=".jpg", start=1, stop=3, 
                   size_out=1000, border_size=10, asr=1.6180, 
                   id_range=1, id_names=NULL, spin=TRUE)
                   
## End(Not run)

ctross/DieTryin documentation built on Sept. 8, 2024, 8:07 p.m.