File: hwriteImage.Rd

package info (click to toggle)
r-cran-hwriter 1.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 292 kB
  • sloc: sh: 25; makefile: 2
file content (82 lines) | stat: -rw-r--r-- 2,668 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
\name{hwriteImage}

\alias{hwriteImage}

\title{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{
  \item{image.url}{a character vector or matrix containing the URL or the file path of images.}
  
  \item{page}{an optional connection, a character string naming the file to write
    to or a page object returned by \code{openPage}.}

  \item{image.border}{an optional numeric value specifiying the width of the image border. 
Default is 0.}

  \item{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.}

  \item{capture}{a logical. If \code{TRUE} the image from the current
    graphic device is captured and written as a PNG file to the filename specified by
    \code{image.url}. Capture resolution is controlled by \code{width}
    and \code{height}, which have a default value of 400 pixels. Default is \code{FALSE}.}
  
  \item{...}{optional arguments that will be dispatched to the
    underlying \code{hwrite} call.}
}

\value{
  A character vector containing the output HTML code.
}

\details{
 \code{hwriteImage} constructs an HTML <img> tag to insert one or several images. This function can be seamlessly in conjuction with \code{hwrite}
to position an image. The \code{capture} argument enables to capture
easily a current plot and to insert it in a web page.

By default, if \code{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 \code{hwrite} call
made by \code{hwriteImage}. The argument \code{table} can be set to
\code{TRUE} to obtain a vector of HTML image tags instead.
}

\seealso{
  \code{\link{hwrite}}.
}

\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')))
}

\author{
  Gregoire Pau, \email{gpau@ebi.ac.uk}, 2008
}

\keyword{interface}