image_load: Load PNG, JPG, BMP or GIF

Description Usage Arguments Details Value Examples

View source: R/load.R

Description

Load PNG, JPG, BMP or GIF from disk or URL.

Usage

1

Arguments

file

character, file name. A local file or URL. Extension must be one of png, jpg, jpeg, bmp or gif.

Details

The function will prompt you of the need to install a format-specific package if not installed and needed for the given file extension; png, bmp, magick (for GIF). jpeg is already imported for purpose of running examples.

Value

an RBG array

Examples

1
2
3
4
5
6
x <- paste0(system.file(package = "imgpalr"), "/blue-yellow.",
  c("jpg", "png", "bmp", "gif"))
str(image_load(x[1]))
if(require(png)) str(image_load(x[2]))
if(require(bmp)) str(image_load(x[3]))
if(require(magick)) str(image_load(x[4]))

Example output

sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
 num [1:317, 1:400, 1:3] 0.208 0.149 0.125 0.153 0.157 ...
Loading required package: png
 num [1:158, 1:200, 1:3] 0.153 0.122 0.137 0.133 0.208 ...
Loading required package: bmp
 num [1:158, 1:200, 1:3] 0.153 0.122 0.137 0.133 0.208 ...
 - attr(*, "header")=List of 13
  ..$ filesize     : num 94854
  ..$ offset       : num 54
  ..$ header_sz    : num 40
  ..$ width        : num 200
  ..$ height       : num 158
  ..$ nplanes      : int 1
  ..$ depth        : int 24
  ..$ compress_type: num 0
  ..$ bmp_bytesz   : num 94800
  ..$ hres         : num 2835
  ..$ vres         : num 2835
  ..$ ncolors      : num 0
  ..$ nimpcolors   : num 0
Loading required package: magick
Linking to ImageMagick 6.9.10.23
Enabled features: fontconfig, freetype, fftw, lcms, pango, webp, x11
Disabled features: cairo, ghostscript, rsvg
 num [1:158, 1:200, 1:3] 0.129 0.102 0.114 0.129 0.196 ...

imgpalr documentation built on Feb. 22, 2021, 9:08 a.m.