Skip to contents

zip_extract_bm_pixmap() extracts/renders an image from a zipfile into a bittermelon::bm_pixmap() object.

Usage

zip_extract_bm_pixmap(zipfile, filename, ...)

Arguments

zipfile

Path to a zip file

filename

Filename within zip file

...

If filename is a pdf file then passed to pdf_render_bm_pixmap()

Value

A bittermelon::bm_pixmap() object.

Examples

# Typically used with a print-and-play zip archive downloaded from
# e.g. <https://boardgamegeek.com/> but here we create our own zip file
if (requireNamespace("bittermelon", quietly = TRUE) &&
    nzchar(Sys.which(Sys.getenv("R_ZIPCMD", "zip")))) {
  input <- pdf_create_blank(bg = "blue")
  zipfile <- tempfile(fileext = ".zip")
  utils::zip(zipfile, input, flags = "-qj")

  bm <- zip_extract_bm_pixmap(zipfile, basename(input), dpi = 75)
  grid::grid.raster(bm)

  unlink(c(input, zipfile))
}