Learn R Programming

Orcs (version 1.2.3)

trimImages: 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$"))

Value

A character vector containing the names of the processed images.

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

Author

Florian Detsch

See Also

Examples

Run this code
if (FALSE) {
## 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()
}

Run the code above in your browser using DataLab