diff --git a/DESCRIPTION b/DESCRIPTION index 157e98f..8b67263 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 3ee4f09..c713e70 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -161,14 +161,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 6a69273..48eaa20 100644 --- a/R/publish.R +++ b/R/publish.R @@ -521,16 +521,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']]) }, @@ -565,11 +566,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")))