Skip to content

Commit

Permalink
Merge pull request #393 from wdwatkins/master
Browse files Browse the repository at this point in the history
drop imager from publish/thumbnail
  • Loading branch information
aappling-usgs authored Oct 29, 2018
2 parents 0b34348 + ed3424b commit d8fb5b6
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 @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions R/publish.R
Original file line number Diff line number Diff line change
Expand Up @@ -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']])
},
Expand Down Expand Up @@ -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")))
Expand Down

0 comments on commit d8fb5b6

Please sign in to comment.