[
About ImageMagick
Command-line Tools
Program Interfaces
] [ Install from Source Binary Releases Resources ] [ Download ] [ Links ] [ Sponsors Trips to Argentina ] |
The Magick Image File Format (MIFF) is ImageMagick's own platform-independent format for storing bitmap images. It has an advantage over other image formats in that it stores all metadata known to ImageMagick (e.g. image color profiles, comments, author, copyright, etc.), whereas, other formats may only support a small portion of available metadata or none at all. A MIFF image file consist of two sections. The first section is a header composed of keys describing the image in text form. The next section is the binary image data. We discuss these sections in detail below. The MIFF header is composed entirely of LATIN-1 characters. The fields in the header are key and value combination in the key = value format, with each key and value separated by an equal sign (=). Each key = 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 ctrl-Z character. It is also common to proceed the colon with a formfeed and a newline character. The formfeed prevents the listing of binary data when using the more Unix program, whereas, the ctrl-Z has the same effect with the type command on the Windows command line.
The following is a partial list of key = value combinations that are typically be found in a MIFF file:
Other key value pairs are permitted. If a value contains whitespace it must be enclosed with braces as illustrated here: id=ImageMagick classseudoClass colors=256 compression=RunlengthEncoded packets=27601 columns=1280 rows=1024 signature=d79e1c308aa5bbcdeea8ed63df412da9 copyright={Copyright (c) 1999-2005 ImageMagick Studio LLC} Note that key = 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 key 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. If you specify the color-profile key in the header, follow the header (or montage directory if the montage key is in the header) with the binary color profile. The header is separated from the image data by a : character immediately followed by a newline.
Next comes 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 key in the header. DirectClass images are continuous-tone, images stored as RGB (red, green, blue), RGBA (red, green, blue, alpha), CMYK (cyan, yellow, magenta, black), or CMYKA (cyan, yellow, magenta, black, alpha) intensity values as defined by the colorspace key. Each intensity value is one byte in length for images of depth 8 (0..255), two bytes for a depth of 16 (0..65535), and images of depth 32 (0..4294967295) require four bytes in most significant byte first order.
PseudoClass images are colormapped RGB images. The colormap is stored as a series of red, green, and blue pixel values, each value being a byte in size. If the image depth is 16, each colormap entry consumes two bytes with the most significant byte being first. The number of colormap entries is defined by the colors key. The colormap data occurs immediately following the header (or image directory if the montage key 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 image depth is 16, the index value is stored as two contiguous bytes with the most significant byte being first. If matte is true, each colormap index is followed by a 1 or 2-byte alpha value. The image pixel data in a MIFF file may be uncompressed, runlength encoded, Zip compressed, or BZip compressed. The compression key in the header defines how the image data is compressed. Uncompressed pixels are stored one scanline at a time in row order. Runlength-encoded compression counts runs of identical adjacent pixels and stores the pixels followed by a length byte (the number of identical pixels minus 1). Zip and BZip compression compresses each row of an image and precedes the compressed row with the length of compressed pixel bytes as a word in most significant byte first order. MIFF files may contain more than one image. Simply concatenate each individual image (composed of a header and image data) into one file. |