Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created January 25, 2016 10:54
Show Gist options
  • Select an option

  • Save mdsumner/fede4a8c02b9e6547fed to your computer and use it in GitHub Desktop.

Select an option

Save mdsumner/fede4a8c02b9e6547fed to your computer and use it in GitHub Desktop.
library(webp)
library(png)
library(curl)
u <- "http://oceancolor.gsfc.nasa.gov/cgi/l3/V20160202016022.L3m_R3QL_NPP_CHL_chlor_a_9km.nc.png?sub=img"
f <- gsub("\\?sub=img", "", basename(u))
curl_download(u, f)
bm <- readPNG(f)
newfile <- gsub("png", "webp", f)
write_webp(bm, newfile)
## only works in Google Chrome
browseURL(newfile)
sizes <- file.info(c(f, newfile))$size
sizes[1]/sizes[2]
## [1] 2.059234
Copy link

ghost commented Jan 25, 2016

username and your personal access token when prompted for a username and password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment