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