hwriteImage {hwriter} | R Documentation |
Insert an HTML image
Description
Inserts one or several images in an HTML document. The images can be either external ones specified by URL or file path, or captured from the current graphic device.
Usage
hwriteImage(image.url, page=NULL, ..., image.border=0, width=NULL,
height=NULL, capture=FALSE)
Arguments
image.url |
a character vector or matrix containing the URL or the file path of images. |
page |
an optional connection, a character string naming the file to write
to or a page object returned by |
image.border |
an optional numeric value specifiying the width of the image border. Default is 0. |
width , height |
an optional HTML length unit (in pixels) specifiying the width (resp. height) at which the image should be rendered. If missing, the default image width (resp. height) will be used. |
capture |
a logical. If |
... |
optional arguments that will be dispatched to the
underlying |
Details
hwriteImage
constructs an HTML <img> tag to insert one or several images. This function can be seamlessly in conjuction with hwrite
to position an image. The capture
argument enables to capture
easily a current plot and to insert it in a web page.
By default, if image.url
is a vector the output value will be a
character string containing the HTML code of a table containing the
images. This behaviour is dictated by the underlying hwrite
call
made by hwriteImage
. The argument table
can be set to
TRUE
to obtain a vector of HTML image tags instead.
Value
A character vector containing the output HTML code.
Author(s)
Gregoire Pau, gpau@ebi.ac.uk, 2008
See Also
Examples
## Creates a new web page 'test.html'
tmpdir <- tempdir()
p <- openPage('test.html', dirname=tmpdir)
## Insert an external image
img <- hwriteImage('http://www.ebi.ac.uk/~gpau/hwriter/iris1.jpg', center=TRUE)
hwrite(c(img,caption='Iris'), p, dim=c(2,1),
row.style=list(caption='text-align:center;background-color:#fac'),
row.names=FALSE, br=TRUE)
## Closes the web page
closePage(p)
## Opens a web browser to see the result
if (interactive()) try(browseURL(file.path(tmpdir, 'test.html')))