Upload an image to imgur.com
This function uses the
imgur_upload(file, key = "9f3460e67f308f6")
- the path to the image file to be uploaded
- the client id for Imgur (by default uses a client id registered by Yihui Xie)
When the output format from
knit() is HTML or Markdown, this
function can be used to upload local image files to Imgur, e.g. set the
opts_knit$set(upload.fun = imgur_upload), so the output
document is completely self-contained, i.e. it does not need external image
files any more, and it is ready to be published online.
- A character string of the link to the image; this string carries an
XMLwhich is a list converted from the response XML file; see Imgur API in the references.
Please register your own Imgur application to get your client id; you can certainly use mine, but this id is in the public domain so everyone has access to all images associated to it.
Imgur API version 3:
f = tempfile(fileext = ".png") png(f) plot(rnorm(100), main = R.version.string) dev.off() res = imgur_upload(f) res # link to original URL of the image attr(res, "XML") # all information if (interactive()) browseURL(res) # to use your own key opts_knit$set(upload.fun = function(file) imgur_upload(file, key = "your imgur key"))