BotanizeR_imageresize: Batch resize images

Description Usage Arguments Details Value References See Also Examples

View source: R/BotanizeR_imageresize.R

Description

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

Usage

1
2
3
4
5
6
7
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.

Details

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

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="").

References

1
2
3
4
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

imager::resize()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Example

## Not run: 
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)

## End(Not run)

li-lam/BotanizeR_Reference documentation built on Dec. 21, 2021, 10:45 a.m.