Added section on passing contextual information to logging and documentation for...
[python.git] / Doc / library / imgfile.rst
blobb0c67bf21f6489f010c3900c52d099bdc9a6239f
2 :mod:`imgfile` --- Support for SGI imglib files
3 ===============================================
5 .. module:: imgfile
6    :platform: IRIX
7    :synopsis: Support for SGI imglib files.
10 The :mod:`imgfile` module allows Python programs to access SGI imglib image
11 files (also known as :file:`.rgb` files).  The module is far from complete, but
12 is provided anyway since the functionality that there is enough in some cases.
13 Currently, colormap files are not supported.
15 The module defines the following variables and functions:
18 .. exception:: error
20    This exception is raised on all errors, such as unsupported file type, etc.
23 .. function:: getsizes(file)
25    This function returns a tuple ``(x, y, z)`` where *x* and *y* are the size of
26    the image in pixels and *z* is the number of bytes per pixel. Only 3 byte RGB
27    pixels and 1 byte greyscale pixels are currently supported.
30 .. function:: read(file)
32    This function reads and decodes the image on the specified file, and returns it
33    as a Python string. The string has either 1 byte greyscale pixels or 4 byte RGBA
34    pixels. The bottom left pixel is the first in the string. This format is
35    suitable to pass to :func:`gl.lrectwrite`, for instance.
38 .. function:: readscaled(file, x, y, filter[, blur])
40    This function is identical to read but it returns an image that is scaled to the
41    given *x* and *y* sizes. If the *filter* and *blur* parameters are omitted
42    scaling is done by simply dropping or duplicating pixels, so the result will be
43    less than perfect, especially for computer-generated images.
45    Alternatively, you can specify a filter to use to smooth the image after
46    scaling. The filter forms supported are ``'impulse'``, ``'box'``,
47    ``'triangle'``, ``'quadratic'`` and ``'gaussian'``. If a filter is specified
48    *blur* is an optional parameter specifying the blurriness of the filter. It
49    defaults to ``1.0``.
51    :func:`readscaled` makes no attempt to keep the aspect ratio correct, so that is
52    the users' responsibility.
55 .. function:: ttob(flag)
57    This function sets a global flag which defines whether the scan lines of the
58    image are read or written from bottom to top (flag is zero, compatible with SGI
59    GL) or from top to bottom(flag is one, compatible with X).  The default is zero.
62 .. function:: write(file, data, x, y, z)
64    This function writes the RGB or greyscale data in *data* to image file *file*.
65    *x* and *y* give the size of the image, *z* is 1 for 1 byte greyscale images or
66    3 for RGB images (which are stored as 4 byte values of which only the lower
67    three bytes are used). These are the formats returned by :func:`gl.lrectread`.