| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/utils.R |
| 3 |
\name{image_uri} |
| 4 |
\alias{image_uri} |
| 5 |
\title{Encode an image file to a data URI} |
| 6 |
\usage{ |
| 7 |
image_uri(f) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{f}{Path to the image file.} |
| 11 |
} |
| 12 |
\value{ |
| 13 |
The data URI as a character string. |
| 14 |
} |
| 15 |
\description{ |
| 16 |
This function is the same as \code{xfun::\link[xfun]{base64_uri}()} (only with a |
| 17 |
different function name). It can encode an image file as a base64 string, |
| 18 |
which can be used in the \code{img} tag in HTML. |
| 19 |
} |
| 20 |
\examples{ |
| 21 |
uri = image_uri(file.path(R.home("doc"), "html", "logo.jpg")) |
| 22 |
if (interactive()) { |
| 23 |
cat(sprintf("<img src=\"\%s\" />", uri), file = "logo.html") |
| 24 |
browseURL("logo.html") # you can check its HTML source |
| 25 |
} |
| 26 |
} |
| 27 |
\references{ |
| 28 |
\url{https://en.wikipedia.org/wiki/Data_URI_scheme} |
| 29 |
} |
| 30 |
\author{ |
| 31 |
Wush Wu and Yihui Xie |
| 32 |
} |