summaryrefslogtreecommitdiffstats
path: root/Doc/libimghdr.tex
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-19 22:58:03 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-19 22:58:03 (GMT)
commit40006cfd9b59ba45e77d763ac14a67eb14f6a8bb (patch)
tree25f6cbbb49fbc067ae99580c0002b2c869c61dbb /Doc/libimghdr.tex
parent72fba794d61abfe5e1fc9b9412b2f7b48dd7acfd (diff)
downloadcpython-40006cfd9b59ba45e77d763ac14a67eb14f6a8bb.zip
cpython-40006cfd9b59ba45e77d763ac14a67eb14f6a8bb.tar.gz
cpython-40006cfd9b59ba45e77d763ac14a67eb14f6a8bb.tar.bz2
Added imghdr,xdrlib; reformatted Makefile somewhat
Diffstat (limited to 'Doc/libimghdr.tex')
-rw-r--r--Doc/libimghdr.tex60
1 files changed, 60 insertions, 0 deletions
diff --git a/Doc/libimghdr.tex b/Doc/libimghdr.tex
new file mode 100644
index 0000000..22d4d0d
--- /dev/null
+++ b/Doc/libimghdr.tex
@@ -0,0 +1,60 @@
+\section{Standard module \sectcode{imghdr}}
+\stmodindex{imghdr}
+
+The \code{imghdr} module determines the type of image contained in a
+file or byte stream.
+
+The \code{imghdr} module defines the following function:
+
+\renewcommand{\indexsubitem}{(in module imghdr)}
+
+\begin{funcdesc}{what}{filename\optional{\, h}}
+Tests the image data contained in the file named by \var{filename},
+and returns a string describing the image type. If optional \var{h}
+is provided, the \var{filename} is ignored and \var{h} is assumed to
+contain the byte stream to test.
+\end{funcdesc}
+
+The following image types are recognized, as listed below with the
+return value from \code{what}:
+
+\begin{enumerate}
+\item[``rgb''] SGI ImgLib Files
+
+\item[``gif''] GIF 87a and 89a Files
+
+\item[``pbm''] Portable Bitmap Files
+
+\item[``pgm''] Portable Graymap Files
+
+\item[``ppm''] Portable Pixmap Files
+
+\item[``tiff''] TIFF Files
+
+\item[``rast''] Sun Raster Files
+
+\item[``xbm''] X Bitmap Files
+
+\item[``jpeg''] JPEG data in JIFF format
+\end{enumerate}
+
+You can extend the list of file types \code{imghdr} can recognize by
+appending to this variable:
+
+\begin{datadesc}{tests}
+A list of functions performing the individual tests. Each function
+takes two arguments: the byte-stream and an open file-like object.
+When \code{what()} is called with a byte-stream, the file-like
+object will be \code{None}.
+
+The test function should return a string describing the image type if
+the test succeeded, or \code{None} if it failed.
+\end{datadesc}
+
+Example:
+
+\begin{verbatim}
+>>> import imghdr
+>>> imghdr.what('/tmp/bass.gif')
+'gif'
+\end{verbatim}