base64 (version 2.0)

img: Encode a png file as a img data uri

Description

This creates html code to embed a png file into an html document.

pngfile <- tempfile() png(pngfile, width = 600, height = 400 ) plot(1:100, rnorm(100), pch = 21, bg = "red", cex = 2 ) dev.off() base64::img( pngfile, Rd = TRUE )

Usage

img(file, Rd = FALSE, alt = "image")

Arguments

file

png file to translate into a data uri

Rd

if TRUE, extra markup is added to facilitate inclusion of the image in an Rd file

alt

alternate text

Examples

Run this code
pngfile <- tempfile()
png(pngfile, width = 600, height = 400)
plot(1:100, rnorm(100), pch = 21, bg = "red", cex = 2 )
dev.off()
img(pngfile, Rd = TRUE)

Run the code above in your browser using DataLab