| width, height, mode, data, compressed=None) |
"L", "
RGB" or "CMYK" for
grayscale, rgb, or cmyk colours, respectively. data is the
bitmap data as a string, where each single character represents a
colour value with ordinal range 0 to 255. Each pixel
is described by the appropriate number of colour components
according to mode. The pixels are listed row by row one after
the other starting at the upper left corner of the image.
compressed might be set to "
Flate" or "DCT" to
provide already compressed data. Note that those data will be passed
to PostScript without further checks, i.e. this option is for
experts only.
| file) |
The contents of the file is checked for some JPEG/JFIF format markers in order to identify the size and dpi resolution of the image for further usage. These checks will typically fail for invalid data. The data are not uncompressed, but directly inserted into the output stream (for invalid data the result will be invalid PostScript). Thus there is no quality loss by recompressing the data as it would occur when recompressing the uncompressed stream with the lossy jpeg compression method.
| xpos, ypos, image, width=None, height=None, ratio=None, storedata=0, maxstrlen=4093, compressmode="Flate", flatecompresslevel=6, dctquality=75, dctoptimize=1, dctprogression=0) |
width, height, and ratio adjust the size of the image. At least width or height needs to be given, when no dpi information is available from image.
storedata is a flag indicating, that the (still compressed) image data should be put into the printers memory instead of writing it as a stream into the PostScript file. While this feature consumes memory of the PostScript interpreter, it allows for multiple usage of the image without including the image data several times in the PostScript file.
maxstrlen defines a maximal string length when storedata is enabled. Since the data must be kept in the PostScript interpreters memory, it is stored in strings. While most interpreters do not allow for an arbitrary string length (a common limit is 65535 characters), a limit for the string length is set. When more data need to be stored, a list of strings will be used. Note that lists are also subject to some implementation limits. Since a typical value is 65535 entries, in combination a huge amount of memory can be used.
Valid values for compressmode currently are
"Flate" (zlib compression),
"DCT" (jpeg compression), or
None (disabling the compression). The zlib compression makes
use of the zlib module as it is part of the standard Python
distribution. The jpeg compression is available for those
image instances only, which support the creation of a
jpeg-compressed stream, e.g. images from the ``Python Image
Library'' with jpeg support installed. The compression must be
disabled when the image data is already compressed.
flatecompresslevel is a parameter of the zlib compression. dctquality, dctoptimize, and dctprogression are parameters of the jpeg compression. Note, that the progression feature of the jpeg compression should be turned off in order to produce valid PostScript. Also the optimization feature is known to produce errors on certain printers.