trimImages: Remove whitespace from images

Description Usage Arguments Value Author(s) Source See Also Examples

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

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

Arguments

path

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

pattern

Character. 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.

See Also

list.files, system

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## 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 May 2, 2019, 2:37 a.m.