R/plot.r

Defines functions plot.imgur_gallery_image

Documented in plot.imgur_gallery_image

plot.imgur_image <-
plot.imgur_gallery_image <-
function(x, ...) {
    ext <- tolower(file_ext(x$link))
    if(ext == 'gif') {
        stop("plot method for GIF images not currently suported")
    } else {
        readfun <- switch(ext, 'jpg' = readJPEG, 
                               'jpeg' = readJPEG, 
                               'png' = readPNG,
                               stop('Unrecognized file extension.'))
        contents <- GET(x$link)
        out <- do.call(readfun, list(contents))
        plot(NULL, xlim=c(0,1), ylim=c(0,1), xaxt='n', yaxt='n', 
             xlab = "", ylab = "", main = "",
             xaxs='i', yaxs='i', mar=rep(0,4), mgp=rep(0,3), ...)
        rasterImage(out, 0,0,1,1)
    }
    invisible(x)
}

Try the imguR package in your browser

Any scripts or data that you put into this service are public.

imguR documentation built on May 2, 2019, 4:02 p.m.