The MIFF header is composed entirely of LATIN-1 characters. The fields in the header are keyword and value combination in the keyword=value format, with each keyword and value separated by an equal sign (=). Each keyword=value combination is delimited by at least one control or whitespace character. Comments may appear in the header section and are always delimited by braces. The MIFF header always ends with a colon (:) character, followed by a newline character. It is also common for a formfeed and a newline character to appear before the colon. You can then list the image keywords with more(1), without printing the binary image that follows the colon separator.
The following is a list of keyword=value combinations that may be found in a MIFF file:
Use this keyword when the image is a composite of a number of different tiles. A tile consists of an image and optionally a border and a label. <width> is the size in pixels of each individual tile in the horizontal direction and <height> is the size in the vertical direction. Each tile must have an equal number of pixels in width and equal in height. However, the width can differ from the height. <x offset> is the offset in number of pixels from the vertical edge of the composite image where the first tile of a row begins and <y offset> is the offset from the horizontal edge where the first tile of a column begins.
If this keyword is specified, a directory of tile names must follow the image header. The format of the directory is explained below.
The following is a sample MIFF header. In this example, <FF> is a formfeed character:
id=ImageMagick
class=PseudoClass colors=256 signature=d79e1c308aa5bbcdeea8ed63df412da9
compression=RunlengthEncoded packets=27601
columns=1280 rows=1024
scene=1
{
Rendered via Dore by Sandi Tennyson.
}
<FF>
:
Note that keyword=value combinations may be separated by newlines or spaces and may occur in any order within the header. Comments (within braces) may appear anywhere before the colon.
If you specify the montage keyword in the header, follow the header with a directory of image tiles. This directory consists of a name for each tile of the composite image separated by a newline character. The list is terminated with a NULL character.
Following the header (or image directory if the montage keyword is in the header) is the binary image data itself. How the image data is formatted depends upon the class of the image as specified (or not specified) by the value of the class keyword in the header.
DirectClass images (class=DirectClass) are continuous-tone, RGB images stored as intensity values in red-green-blue order. Each color value is one byte in size for an image depth of 8 and there are three bytes per pixel (four with an optional matte value). If the depth is 16, each color value is two bytes with the most significant byte being first. The total number of pixels in a DirectClass image is calculates by multiplying the rows value by the column value in the header.
PseudoClass images (class=PseudoClass) are colormapped RGB images. The colormap is stored as a series of red-green-blue pixel values, each value being a byte in size. If the image depth is 16, each colormap entry is two bytes with the most significant byte being first. The number of colormap entries is indicated by the colors keyword in the header, with a maximum of 65,535 total entries allowed. The colormap data occurs immediately following the header (or image directory if the montage keyword is in the header).
PseudoClass image data is an array of index values into the color map. If there are 256 or fewer colors in the image, each byte of image data contains an index value. If the image contains more than 256 colors or the depth is 16, the index value is stored as two contiguous bytes with the most significant byte being first. The total number of pixels in a PseudoClass image is calculated by multiplying the rows value by the columns value in the header.
The image data in a MIFF file may be uncompressed or may be compressed using one of two algorithms. The compression keyword in the header indicates how the image data is compressed. The run-length encoding (RLE) algorithm may be used to encode image data into packets of compressed data. For DirectClass images, runs of identical pixels values (not BYTE values) are encoded into a series of four-byte packets (five bytes if a matte value is included). The first three bytes of the packet contain the red, green, and blue values of the pixel in the run. The fourth byte contains the number of pixels in the run. This value is in the range of 0 to 255 and is one less than the actual number of pixels in the run. For example, a value of 127 indicates that there are 128 pixels in the run.
For PseudoClass images, the same RLE algorithm is used. Runs of identical index values are encoded into packets. Each packet contains the colormap index value followed by the number of index values in the run. The number of bytes in a PseudoClass RLE packet will be either two or three, depending upon the size of the index values. The number of RLE packets stored in the file is specified by the packets keyword in the header, but is not required.
Use Zip compression to achieve a greater compression ratio than run-length encoding. The number of compressed packets stored in the file is specified by the packets keyword in the header.
MIFF files may contain more than one image. Simply concatenate each individual image (composed of a header and image data) into one file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files ("ImageMagick"), to deal in ImageMagick without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ImageMagick, and to permit persons to whom the ImageMagick is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of ImageMagick.
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall E. I. du Pont de Nemours and Company be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with ImageMagick or the use or other dealings in ImageMagick.
Except as contained in this notice, the name of the E. I. du Pont de Nemours and Company shall not be used in advertising or otherwise to promote the sale, use or other dealings in ImageMagick without prior written authorization from the E. I. du Pont de Nemours and Company.