By default uses magic bytes at the start of the file to identify the image type (rather than the file extension). Currently uses readers in bmp, jpeg, png, and tiff packages.

read.bitmap(f, channel, IdentifyByExtension = FALSE, ...)

Arguments

f

Path to image file

channel

Integer identifying channel to return for an RGB image

IdentifyByExtension

Identify by file extension only (Default FALSE)

...

Additional parameters passed to underlying image readers

Value

Objects returned by readJPEG, readPNG, read.bmp, or readTIFF. See their documentation for details.

See also

Examples

img1=read.bitmap(system.file("img", "Rlogo.jpg", package="jpeg")) str(img1)
#> num [1:76, 1:100, 1:3] 1 1 1 1 1 1 1 1 1 1 ...
img2 <- read.bitmap(system.file("img", "Rlogo.png", package="png")) # nb the PNG image has an alpha channel str(img2)
#> num [1:76, 1:100, 1:4] 0 0 0 0 0 0 0 0 0 0 ...