| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/plot.R |
| 3 |
\name{download_image} |
| 4 |
\alias{download_image} |
| 5 |
\title{Download an image from the web and include it in a document} |
| 6 |
\usage{ |
| 7 |
download_image( |
| 8 |
url, |
| 9 |
path = xfun::url_filename(url), |
| 10 |
use_file = !pandoc_to("html"), |
| 11 |
... |
| 12 |
) |
| 13 |
} |
| 14 |
\arguments{ |
| 15 |
\item{url}{The URL of an image.} |
| 16 |
|
| 17 |
\item{path}{The download path (inferred from the URL by default). If the file |
| 18 |
exists, it will not be downloaded (downloading can take time and requires |
| 19 |
Internet connection). If you are sure the file needs to be downloaded |
| 20 |
again, delete it beforehand.} |
| 21 |
|
| 22 |
\item{use_file}{Whether to use the URL or the download path to include the |
| 23 |
image. By default, the URL is used for HTML output formats, and the file |
| 24 |
path is used for other output formats.} |
| 25 |
|
| 26 |
\item{...}{Other arguments to be passed to \code{\link{include_graphics}()}.} |
| 27 |
} |
| 28 |
\description{ |
| 29 |
When including images in non-HTML output formats such as LaTeX/PDF, URLs will |
| 30 |
not work as image paths. In this case, we have to download the images. This |
| 31 |
function is a wrapper of \code{xfun::\link[xfun]{download_file}()} and |
| 32 |
\code{\link{include_graphics}()}. |
| 33 |
} |
| 34 |
\examples{\dontshow{if (interactive()) \{} |
| 35 |
knitr::download_image("https://www.r-project.org/Rlogo.png") |
| 36 |
\dontshow{\}} |
| 37 |
} |