R/parseImage.R

Defines functions parseImage

Documented in parseImage

#### PARSE IMAGE ####
#' This function parses a HE image to use as the background for plots
#' @param imgFile Path to the image file
#' @return A rasterized grob
#' @export
#' @examples
#' imgFile <- file.path(system.file(package = "Spaniel"),
#'                     "HE_Rep1_resized.jpg")
#' img <- parseImage(imgFile)
parseImage <-  function(imgFile) {
    img <- jpeg::readJPEG(imgFile)
    g <-grid::rasterGrob(
        img,
        interpolate = FALSE,
        width = grid::unit(1, "npc"),
        height = grid::unit(1, "npc")
    )
    return(g)
}

Try the Spaniel package in your browser

Any scripts or data that you put into this service are public.

Spaniel documentation built on Nov. 8, 2020, 5:54 p.m.