The Image3 Script
by Zachary X. Reiter and Clifford A. Reiter
October 2002

The image3 addon script, image3.ijs, contains the main functions used for reading, writing and converting image files. While the emphasis is on 24 bit images, there is some support for movies and 8-bit images. File extensions of *.bmp, *.jpg, *.jpeg, *.png, *.pnm, *.tga, *.pgm, and *.ppm are the listed image types which may be read (although not every variant of the image formats is necessarily supported). Movie *.mov and *.avi support requires loading the script movie3.ijs.

The Data Forms for Images are:

  1. h by w by 3 array of integers (range 0-255): this is the main data form
  2. h by w by 3 array of bytes (characters): compact data form
  3. h by w by 1 array of integers (range 0-255) or bytes: Grayscale image
  4. (p;B) where p is an integer palette of RGB values (0-255) and B is an h by w array of indices into the palette.
The left argument (adverb) of write_image may be data in any of those forms. The grayscale format is primarily intended for access to Jpeg grayscale images. Paletted images are promoted to 24 bit images before being saved except for *.bmp and *.png files which are saved as 8-bit images.

The Main Functions

The syntax for using the main functions follows. The filename extension is used to determine the image file type both for reading and writing images. See the Image3 lab for active illustrations and the script itself for many utilities which are used indirectly.
See also the section on Palette Utilities for reading paletted images.

General and File List Utilities

Pathnames are assumed to always end with a directory seperator.

Palette Utilities

The script also contains some utilities for working with paletted images:

The jpeg Options

The jpeg options are, in order, jpeg_quality, progressive, grayscaling; their default values are:

jpeg_quality=: 75  Range (1-100), default is 75
progressive=:      Default is 0 (false), 1 is true
gray_scaling=:  0  NB.  _1 never (promote to rgb) 
                   NB.   0 preserve;ie, use trailing axis; (default)
                   NB.   1 always (make gray)
                   NB.   2 when gray, save as gray scale

Using jpeg_quality near 100 results in large, high quality image files; values near 75 are average quality and much smaller. Values near 0 result in very small images, but the quality is extremely poor.

The png Options

Png options allow improvements in file size (usually only small changes occur) in exchange for longer processing.

png_compression=: _1  NB. default (seems to be 6)
                      NB. 0 best speed
                      NB. 9 best compression

Link to:
Image3 Main Help