utils_image: Import and export images

utils_imageR Documentation

Import and export images


Import images from files and URLs and write images to files, possibly with batch processing.


  which = 1,
  pattern = NULL,
  path = NULL,
  resize = FALSE,
  plot = FALSE,
  nrow = NULL,
  ncol = NULL

image_export(img, name, prefix = "", extension = NULL, subfolder = NULL, ...)

image_pliman(img, plot = FALSE)


  • For image_import(), a character vector of file names or URLs.

  • For image_export(), an Image object, an array or a list of images.

  • For image_pliman(), a charactere value specifying the image example. See ?pliman_images for more details.


Alternative arguments passed to the corresponding functions from the jpeg, png, and tiff packages.


logical scalar or integer vector to indicate which image are imported if a TIFF files is informed. Defaults to 1 (the first image is returned).


A pattern of file name used to identify images to be imported. For example, if pattern = "im" all images in the current working directory that the name matches the pattern (e.g., img1.-, image1.-, im2.-) will be imported as a list. Providing any number as pattern (e.g., pattern = "1") will select images that are named as 1.-, 2.-, and so on. An error will be returned if the pattern matches any file that is not supported (e.g., img1.pdf).


A character vector of full path names; the default corresponds to the working directory, getwd(). It will overwrite (if given) the path informed in image argument.


Resize the image after importation? Defaults to FALSE. Use a numeric value of range 0-100 (proportion of the size of the original image).


Plots the image after importing? Defaults to FALSE.

nrow, ncol

Passed on to image_combine(). The number of rows and columns to use in the composite image when plot = TRUE.


An string specifying the name of the image. It can be either a character with the image name (e.g., "img1") or name and extension (e.g., "img1.jpg"). If none file extension is provided, the image will be saved as a *.jpg file.


A prefix to include in the image name when exporting a list of images. Defaults to "", i.e., no prefix.


When image is a list, extension can be used to define the extension of exported files. This will overwrite the file extensions given in image.


Optional character string indicating a subfolder within the current working directory to save the image(s). If the folder doesn't exist, it will be created.


  • image_import() returns a new Image object.

  • image_export() returns an invisible vector of file names.

  • image_pliman() returns a new Image object with the example image required. If an empty call is used, the path to the tmp_images directory installed with the package is returned.


Tiago Olivoto tiagoolivoto@gmail.com


folder <- image_pliman()
full_path <- paste0(folder, "/sev_leaf.jpg")
(path <- file_dir(full_path))
(file <- basename(full_path))
image_import(img = full_path)
image_import(img = file, path = path)

pliman documentation built on Oct. 15, 2023, 1:06 a.m.

Related to utils_image in pliman...