Learn R Programming

flextable (version 0.10.4)

image_raster: Read an image as a native raster, with a cache

Description

Read an image file as a native raster, which is much faster to draw than a raster object with grid::rasterGrob(). The raster is kept for the R session, so that an image used many times is only decoded once. The file is read again if it has changed, and the least recently used rasters are dropped when the cache becomes too large.

This function is used by gen_grob() and is exported for packages that draw the same images with 'grid'. Package 'magick' is required.

Usage

image_raster(path, width = NULL, height = NULL)

Value

An object of class nativeRaster. An error is raised if the file can not be read.

Arguments

path

path to the image file.

width, height

size in inches at which an SVG file is rendered, they are ignored with other formats.