Skip to content

Commit

Permalink
drop imager dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
wdwatkins committed Oct 29, 2018
1 parent e8efc84 commit 7ee7fc2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Suggests:
sbtools (>= 0.19.3),
secret,
testthat
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions R/publish.R
Original file line number Diff line number Diff line change
Expand Up @@ -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']])
},
Expand Down Expand Up @@ -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")))
Expand Down

0 comments on commit 7ee7fc2

Please sign in to comment.