# Can I use an image located on the web in a LaTeX document?

I have tried

\includegraphics{http://www.site.com/path/to/figure.png}


But this returns the error

ERROR: Package pdftex.def Error: File
http://www.website.com/path/to/figure.png'


Are there other options?

-
ConTeXt supports this natively. \externalfigure[http://www.site.com/path/to/figure.png] just works. Behind the scenes, ConTeXt downloads the file to the luatex cache once, and from then on just reuses the figure. –  Aditya Nov 16 '10 at 4:36
do you want to add this as an answer? That way, I can select it. –  David Nov 16 '10 at 5:07

you could use \write18 and a curl or wget script to grab the image from the web and download it to your directory.

\documentclass{article}
\usepackage{graphicx} % includegraphics command is implemented here
\begin{document}

\write18{wget http://www.some-site.com/path/to/image.png}
\includegraphics{image.png}

\end{document}


note however, that recent versions of miktex and texlive come with restricted versions of \write18, and it some cases you must pass an option to latex to enable it, as in:

pdflatex --shell-escape test.tex

-
could you please provide example code in your answer? I did not realize that it was possible to use bash code within latex, although I do use Sweave so I can understand the principle. –  David Nov 15 '10 at 22:04
nice! I guess that this underscores the point that I only need to download the image once in any case. But this approach seems like it would help with portability. –  David Nov 16 '10 at 3:09
\IfFileExists{image.png}{}{\write18{...}} would help with the only-downloading-once problem. –  Will Robertson Nov 16 '10 at 9:06
Could this be done programmatically somehow, maybe with a \renewcommand such that includegraphics can just take the url as an argument? –  cboettig Oct 9 '12 at 1:23

Short answer: no. You will need to download the image and use it locally if you want to include it in your document. pdfTeX and XeTeX do not include the necessary code to grab an image from an arbitrary location.

Of course, you can link to an image at at remote location. You can make use of the hyperref package to include a suitable link. You might do this using a bit of text:

\href{http://somewhere.com/someplace/some.jpg}{picture here}


\href{http://somewhere.com/someplace/some.jpg}{\incudegraphics{some.jpg}}
`