Silicon Graphics Image

From HandWiki
Revision as of 14:36, 3 August 2023 by Unex (talk | contribs) (linkage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Raster graphics file format
Silicon Graphics Image
Filename extension.sgi (among others)
Internet media typeimage/sgi[1]
Type code'.SGI'
Uniform Type Identifier (UTI)com.sgi.sgi-image[2]
Magic number01 DA
Developed byPaul Haeberli
Latest release
1.00
(1996; 28 years ago (1996))
Websiteftp://ftp.sgi.com/graphics/SGIIMAGESPEC

</ref>

| genre = image file | container for = | contained by = | extended from = | extended to = }}

Silicon Graphics Image (SGI) or the RGB file format is the native raster graphics file format for Silicon Graphics workstations.[3] The format was invented by Paul Haeberli.[3] It can be run-length encoded (RLE). FFmpeg and ImageMagick, among others, support this format.

Background

Common file extensions are:

.sgi or .rgb
3 colour channels
.rgba
3 colour channels and alpha
.bw or .int
black and white
.inta
black and white and alpha

This format was originally developed for IRIX. The master files of the SVT High Definition Multi Format Test Set are SGIs.[4][5][6] Frame 200 of the ParkJoy sequence in this set (15722.sgi, 3840×2160, 47.4 MB) was used in WebP comparisons.

Technical Details

SGI image format use big endian order. Image data scan from left to right from bottom to top.

Header

Field number Hex offset Length Field name Description
1 0x00 2 byte File signature/magic number For show file is SGI file
2 0x02 1 byte Compression 0 = uncompressed, 1 = RLE compressed
3 0x03 1 byte Bytes per pixel 1 = 8 bit, 2 = 16 bit
4 0x04 2 bytes Dimension Image dimension, equal 3 for RGBA image
5 0x06 2 bytes X size Image width
6 0x08 2 bytes Y size Image height
7 0x0A 2 bytes Number of channels Number channel in image, equal 4 for RGBA image
8 0x0C 4 bytes Minimum pixel value Smallest pixel value in image
9 0x10 4 bytes Maximum pixel value Largest pixel value in image
10 0x14 4 bytes Reserved No use, ignore
11 0x18 80 bytes Image name C string name have last byte equal 0x00
12 0x68 4 bytes Color map ID Only for color map image
13 0x6C 404 bytes Dummy For make head 512 bytes long. Ignore

File Signature/Magic Number

Should equal 0x01 0xda for SGI file.

Compression

If no compression equal 0; 1 for RLE compression.

Bytes Per Pixel Channel

Value is 1 for 8 bit per channel (most image); 2 for 16 bits per channel.

Dimension

Value equal 1 for 1 channel, 1 scanline image ; 2 for 1 channel, many scanline image (); 3 for many channel, many scanline image (most image).

X Size

Scanline width of image.

Y Size

Number of scanlines in image.

Number Of Channels

Number channels in image. Grey scale image is 1; RGB is 3; RGBA is 4. SGI can have more than 4 channels.

Minimum Pixel Value

Smallest pixel value in all channels. Because SGI use unsigned char or short for channels, smallest value can have is zero.

Maximum pixel value

Largest pixel value in all channels. Because SGI use unsigned char or short for channels, largest value can have for 8 bit/channel is 0xff; 16 bit/channel image is 0xffff.

Dummy

4 bytes not use.

Image name

Image name is 80 bytes (maximum 79 characters ≠ 0x00) C string. If name is shorter than 79 characters, all bytes after equal 0x00 for fill all 80 bytes.

Color Map ID Have 4 types:

  1. 0x00 normal: image have 1 channel is grey scale; 3 channels is RGB, 4 channels is RGBA
  2. 0x01 dithered: image is packed RGB. First 3 bits for R, next 3 bits G channel, and last 2 bits for B channel
  3. 0x02 screen: image use colormap. Pixel data is index in color map and image only have 1 channel.
  4. 0x03 colormap: file only have data for one color map (can use for different image file). This file no have image data.

Dummy 404 bytes for header 512 bytes long.

Image Data

No Compression

Image data start at byte 512 in file. Data length equal (x size) × (y size) × (number of channels) × (bytes per channel). Data for each channel is separate. If image have RGBA channels, then all scanlines for channel R first, scanlines for channel G next, scanlines for channel B next, scanlines for channel A last.

RLE Compression

Offset table start at byte 512 and is (y size) × (number of channels) × 4 bytes long. Each unsigned int in table is offset (from file start) for start of compressed data of each scanline in each channel. Data for each channel's scanline is separate. If image have RGBA channels, order for channel data is R, G, B and A.

Next have data length table also (y size) × (number of channels) × 4 bytes long. This table tell size of compressed data (unsigned int) of each scanline. This size should equal difference of numbers in offset table.

Last is RLE compressed image data. If bytes per channel equal 1, compressed data is unsigned char. Else if equal 2, compressed data is unsigned short. End of compressed scanline data have value zero.

For both case have unsigned char or unsigned short data, lowest 7 bits tell count. If bit 8 is zero, count is number times copy value after count. If bit 8 is one, count is number times copy series of values after count byte. For 2 bytes/channel image, count and value is unsigned short and top byte of count always equal zero.

See also

References