\Header{savepng}{Save the contents of the current graphics device to a PDF or PNG file}
\alias{savepdf}{savepng}
\keyword{programming}{savepng}
\keyword{error}{savepng}
\begin{Description}\relax
Save the contents of the current graphics device to a PDF or PNG file
\end{Description}
\begin{Usage}
\begin{verbatim}
  savepng(fn, dir, width=480, asp=1)
  savepdf(fn, dir, width=6, asp=1)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{fn}] character: name of the output file (without extension .png or .pdf)
\item[\code{dir}] character: directory to which the file should be
written. If \code{NULL}, use the filename in \code{fn} only.
\item[\code{width}] numeric: width of the image in pixels (png) or inches (pdf)
\item[\code{asp}] numeric: aspect ratio; height=width*asp
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\end{Details}
\begin{Value}
Character: name of the written file.
\end{Value}
\begin{Author}\relax
Wolfgang Huber \url{http://www.dkfz.de/mga/whuber}
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{dev.copy}},\code{\Link{pdf}},\code{\Link{png}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  x = seq(0, 20*pi, len=1000)
  plot(x*sin(x), x*cos(x), type="l")

  try({   ## on some machines, png or pdf may not be available
  savepdf("spiral", dir=tempdir())
  ## Not run: 
  savepng("spiral", dir=tempdir())
  
## End(Not run)
  })    
\end{ExampleCode}
\end{Examples}

