Batch resize images for plotting in BotanizeR_quiz() or BotanizeR Shiny app maintaining aspect ratio.

BotanizeR_imageresize(
  image_folders = NULL,
  image_width = NA,
  max_height = NA,
  int_type = 1,
  quality = 1
)

Arguments

image_folders

character vector defining folders where images that shall be resized are stored.

image_width

number defining the width of the resized images as number of pixels.

max_height

number defining the maximum height of the resized images. If NA, max_height is ignored and all images are resized to a width of image_width. If max_height is defined images are resized to a width of image_width only if a height of max_height is not exceeded. Otherwise they will be resized to a height of max_height.

int_type

number indicating the method of interpolation used in imager::resize(): -1 = no interpolation: raw memory resizing. 0 = no interpolation: additional space is filled according to boundary_conditions. 1 = nearest-neighbor interpolation. 2 = moving average interpolation. 3 = linear interpolation. 4 = grid interpolation. 5 = cubic interpolation. 6 = lanczos interpolation.

quality

numeric > 0 and <= 1 defining the quality of the images when saved as *.jpg by imager::save.image(). Higher quality means less compression.

Value

Resized images will be saved at the same location where the input folders are located but folder names will be expanded about paste("_",image_width,sep="").

Details

Resizing images to make them fit and load faster in the BotanizeR Shiny application and BotanizeR_quiz().

References

Weigelt, P., Denelle, P., Brambach, F. & Kreft, H. (2021) A flexible
R package with Shiny app to practice plant identification for 
online teaching and beyond. PLANTS, PEOPLE, PLANET, 
https://doi.org/10.1002/ppp3.10226.

See also

Examples

# Example if (FALSE) { BotanizeR_imageresize(image_folders = "inst/WWW/images_to_resize", image_width = 560, max_height = 700, quality = 1) BotanizeR_imageresize(image_folders = c("inst/WWW/images_to_resize_1", "inst/WWW/images_to_resize_2"), image_width = 560, max_height = 700, quality = 1, int_type = 5) }