trimImages: Remove Whitespace from Images

View source: R/trimImages.R

trimImagesR Documentation

Remove Whitespace from Images

Description

This is a wrapper function around convert -trim to automatically remove any whitespace from locally saved images. Note that 'ImageMagick' must be installed on your local system, see Source.

Usage

trimImages(path = ".", pattern = c(".png$", ".tiff$"))

Arguments

path

File path leading to image files as character, defaults to the current working directory.

pattern

A regular expression as character accepted by list.files(), defaults to c(".png$", ".tiff$").

Value

A character vector containing the names of the processed images.

Author(s)

Florian Detsch

Source

Ooms J (2018) The magick package: Advanced Image-Processing in R. Available online: https://cran.r-project.org/package=magick/vignettes/intro.html.

See Also

system()

Examples

## Not run: 
## trim image of bart simpson
download.file("http://pngimg.com/uploads/simpsons/simpsons_PNG93.png?i=1"
              , destfile = (ofl <- file.path(tempdir(), "bart.png", fsep = "\\"))
              , mode = "wb")

par(mfrow = c(1, 2))

img = brick(ofl)
plotRGB(img)

jnk = trimImages(tempdir(), "bart.png")
trm = brick(jnk)
plotRGB(trm)

dev.off()

## End(Not run)


Orcs documentation built on Jan. 6, 2023, 5:14 p.m.