\HeaderA{readImage}{Image I/O}{readImage}
\aliasA{chooseImage}{readImage}{chooseImage}
\aliasA{writeImage}{readImage}{writeImage}
\aliasA{writeImage,Image-method}{readImage}{writeImage,Image.Rdash.method}
\keyword{file}{readImage}
\begin{Description}\relax
Functions to choose, read and write images from/to files and URL's.
Supported image formats are determined by the ImageMagick installation.
\end{Description}
\begin{Usage}
\begin{verbatim}
  chooseImage(colormode = Grayscale)
  readImage(files, colormode = Grayscale, ...)

  ## S4 method for signature 'Image':
  writeImage(x, files, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An object of \code{\LinkA{Image}{Image.Rdash.class}}. 
\item[\code{files}] A character vector of files/URL's to read from or to write to. 
\item[\code{colormode}] An integer value for the color mode of images after they are
read. By default all images will be converted to Grayscale on read. 
\item[\code{...}] Reserved. 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{files} is missing when writing images, \code{\LinkA{fileName}{fileName}(x)}
method will be used to select a single file to write to. Otherwise,
the length of this vector must be equal either 1 or the number of 2D images
in the stack.

When writing images in formats supporting non-lossless compression (like JPEG),
the quality can be spcified used a numeric \code{quality} argument with the
range \code{[1,100]}. Higher values correspond to better quality. Defaults to 95.

The file format is deduced from the file name extension(s), there is neither
a need nor a way to specify the format explicitly.

\code{ImageMagick} is used to perform all image I/O operations. Therefore,
the package supports all the file types supported by \code{ImageMagick}.

When reading images, files of different formats can be mixed in any
consequence, including mixing single 2D images with TIFF image stacks.
The result will contain a stack of all images and stacks cropped (filled
with background if images are smaller) at the size of the first image read.

\code{choose.image} is an interactive function that does not return to R
until either Ok or Cancel button is pressed in the GUI dialog. It uses
\code{GTK+2} File Open Dialog to select images. Multiple images can be
selected and loaded at once. By default this functions reads images as
\code{\LinkA{TrueColor}{TrueColor}}. This function will produce an error message if
the package was compiled without \code{GTK+} support.
\end{Details}
\begin{Value}
For \code{readImage} and \code{chooseImage} a new instance of 
\code{\LinkA{Image}{Image.Rdash.class}}.

For \code{writeImage} an invisible \code{NULL}.
\end{Value}
\begin{Author}\relax
Oleg Sklyar, \email{osklyar@ebi.ac.uk}, 2005-2006
\end{Author}
\begin{References}\relax
\emph{ImageMagick}: \url{http://www.imagemagick.org}.
\end{References}
\begin{SeeAlso}\relax
\code{
    \LinkA{Image}{Image.Rdash.class}, \LinkA{Image}{Image.Rdash.class}, \LinkA{Image}{Image.Rdash.class}
  }
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
    f <- paste( system.file(package="EBImage"), "images/Gene1_G.tif", sep="/" )
    ii = readImage(f)
  if ( interactive() ) {
    url <- c("http://www.google.com/intl/en/images/logo.gif")
    im <- readImage (url, TrueColor)
    ## Not run: writeImage (im, "googlelogo.tif")
    ## Not run: im1 <- channel ( chooseImage(), "gray")
  }
\end{ExampleCode}
\end{Examples}

