From 7ee7fc2e54d894e4bee8f6bd23b85ed7683bb6e6 Mon Sep 17 00:00:00 2001 From: wdwatkins Date: Mon, 29 Oct 2018 15:48:45 -0500 Subject: [PATCH] drop imager dependency --- DESCRIPTION | 2 +- NAMESPACE | 5 ++--- R/publish.R | 13 ++++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8b90bc1..147e841 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,4 +42,4 @@ Suggests: sbtools (>= 0.19.3), secret, testthat -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.0 diff --git a/NAMESPACE b/NAMESPACE index b8de3f7..b31a4fc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -159,14 +159,13 @@ importFrom(grithub,interactive.login) importFrom(httr,HEAD) importFrom(httr,headers) importFrom(httr,parse_http_date) -importFrom(imager,height) -importFrom(imager,load.image) -importFrom(imager,width) importFrom(markdown,markdownToHTML) importFrom(methods,getPackageName) +importFrom(png,readPNG) importFrom(remotes,install_github) importFrom(stats,runif) importFrom(stats,setNames) +importFrom(tools,file_ext) importFrom(tools,file_path_sans_ext) importFrom(utils,URLencode) importFrom(utils,download.file) diff --git a/R/publish.R b/R/publish.R index 4a91994..2f8eb07 100644 --- a/R/publish.R +++ b/R/publish.R @@ -506,16 +506,17 @@ publish.thumbnail <- function(viz){ required <- c("relpath", "title", "alttext") viz <- NextMethod() checkRequired(viz, required) + stopifnot(tools::file_ext(viz[['location']]) == "png") im <- tryCatch({ - imager::load.image(viz[['location']]) + png::readPNG(viz[['location']]) }, error=function(cond){ - return(imager::load.image(system.file("testviz/images/landing-thumb.png", package = "vizlab"))) + return(png::readPNG(system.file("testviz/images/landing-thumb.png", package = "vizlab"))) }) - width <- imager::width(im) - height <- imager::height(im) + width <- dim(im)[2] + height <- dim(im)[1] file_size <- tryCatch({ file.info(viz[['location']]) }, @@ -550,11 +551,13 @@ convb <- function(x){ } #' helper to check thumbnail compliance -#' @importFrom imager load.image width height +#' @importFrom png readPNG +#' @importFrom tools file_ext #' @param width numeric pixal width of image #' @param height numeric pixal height of image #' @param size numeric file size in bytes #' @param thumbType char Type of thumbnail, could be "facebook", "twitter", "landing", "main" + checkThumbCompliance <- function(width, height, size, thumbType){ stopifnot(all(thumbType %in% c("facebook","twitter","main","landing")))