File Formats


File Formats

Graphics Interchange Format - GIF
Little-Endian (Intel)
Following the Signature and Logical Screen Descriptor, a GIF file is divided into blocks.

Extension Block Layout
SentinelExtensionDataBlock Terminator
01 Byte (21)01 Byte 01 Byte (00)

File Structure
BlockBytesDescription (ASCII)Value
Signature06"GIF89a"4749 4638 3961
LSD02Screen Width
02Screen Height
01Mask
MSB :1GCT FlagTRUE or FALSE
:3Colour Resolution bpp -1
:1Sort FlagTRUE or FALSE
:3GCT Size0 or 2^(n+1)
01Background Colour Index
01Pixel Aspect Ratio
GCT Global Colour Table
IID0AImage Descriptor
Image Data
TRAIL0159 (Image End)3B

Image Descriptor   [44]
BytesPropertiesValues
01Sentinel2C
02Image Left
02Image Top
02Image Width
02Image Height
01Mask
:3LCT Size0 or 2^(n+1)
:2Reserved
:1Sort FlagTRUE or FALSE
:1Interlace FlagTRUE or FALSE
LSB :1Local Colour Table FlagTRUE or FALSE
Local Colour Table

Application Extension   [33 255]
BytesPropertiesValues
01Sentinel21
01ExtensionFF
01Block Size0B
08Application Identifier
03Authentication Code
01Data Size
Data
01Block Terminator00

Comment Extension   [33 254]
BytesPropertiesValues
01Sentinel21
01ExtensionFE
01Block Size
Data
01Block Terminator00

Graphics Control Extension   [33 249]
BytesPropertiesValues
01Sentinel21
01ExtensionF9
01Block Size04
01Mask
:3Reserved0 or 2^(n+1)
:3Disposal Method
:1User Input FlagTRUE or FALSE
LSB :1Transparent Colour FlagTRUE or FALSE
02Delay Time
01Transparent Colour Index
01Block Terminator00

Plain Text Extension   [33 1]
BytesPropertiesValues
01Sentinel21
01Extension01
01Block Size0C
02Grid Left
02Grid Top
02Grid Width
02Grid Height
01Cell Width
01Cell Height
01Foreground Color Index
01Background Color Index
01Data Size
Data
01Block Terminator00

§


Joint Photographic Experts Group - JPEG (JFIF)
Big-Endian (Motorola/MIPS)

Segment Layout
MarkerSegmentSizeData
01 Byte (255)01 Byte02 BytesSize-2 Bytes

File Structure
SegmentBytesDescription (ASCII)Value
SOI02255 216 (Start Of Image)FFD8
APP0See below255 224 (JPEG Application)FFE0
EOI02255 217 (End Of Image)FFD9

JPEG Application   [255 224]
BytesPropertiesValues
02MarkerFFE0
02Segment Size16 + n
05Identifier (JFIF)4A46 4946 00
02Version0102
01Pixel Density Units00-02
02Horizontal Pixel Density
02Vertical Pixel Density
01Thumbnail X-Pixelsx
01Thumbnail Y-Pixelsy
3 * x * yThumbnail RGB Valuesn

§


Portable Network Graphics - PNG
Big-Endian (Motorola/MIPS)
Following the Signature, a PNG file consists of a minimum of 3 Chunks.

Chunk Layout
SizeChunk NameDataCRC
04 Bytes04 BytesSize Bytes04 Bytes

File Structure
ChunkData BytesDescription (ASCII)Value
Signature08137  "PNG"  13 10 26 108950 4E47 0D0A 1A0A
IHDR0D73 72 68 82  (Image Header)4948 4452
IDAT 73 68 65 84  (Image Data)4944 4154
IEND0073 69 78 68  (Image End)4945 4E44

Image Header   [73 72 68 82 "IHDR"]
BytesPropertiesValues
04Chunk Size (13 bytes)n0000 000D
04Chunk Name4948 4452
04Image Width> 00
04Image Height> 00
01Bit depth01, 02, 04, 08 or 10
01Colour Type00, 02, 03, 04, or 06
01Compression00
01Filter00
01Interlace00 or 01
04CRC

Palette   [80 76 84 69 "PLTE"]
Required For Colour Type 3. May be present for Types 2 and 6.
BytesPropertiesValues
04Chunk Size (Data)n * 3
04Chunk Name504C 5445
n * 3Datan Colours (0001-0100)
04CRC

Ancillary Chunks
Transparency   [116 82 78 83 "tRNS"]
Not Present For Colour Type 4 or 6.
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name7452 4E53
Data
04CRC

Colour Space
Primary Chromaticities   [99 72 82 77 "cHRM"]
BytesPropertiesValues
04Chunk Size (20 bytes)0000 0014
04Chunk Name6348 524D
04White Point x
04White Point y
04Red x
04Red y
04Green x
04Green y
04Blue x
04Blue y
04CRC

Gamma   [103 65 77 65 "gAMA"]
BytesPropertiesValues
04Chunk Size (04 bytes)0000 0004
04Chunk Name6741 4D41
04Image Gamma
04CRC

ICC Profile   [105 67 67 80 "iCCP"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name6943 4350
02-50Profile NameNull-Terminated
01Zlib Compression00
Compressed Profilen
04CRC

Significant Bits   [115 66 73 84 "sBIT"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name7342 4954
01-04Data> 00
04CRC

Standard RGB Colour Space   [115 82 71 66 "sRGB"]
BytesPropertiesValues
04Chunk Size (01 byte)0000 0001
04Chunk Name7352 4742
01Rendering Intent00-03
04CRC

Text
TimeStamp   [116 73 77 69 "tIME"]
BytesPropertiesValues
04Chunk Size (07 bytes)0000 0007
04Chunk Name7449 4D45
02Yearyyyy
01Month01-0C
01Day01-1F
01Hour00-17
01Minute00-3B
01Second00-3C
04CRC

International Text   [105 84 88 116 "iTXt"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name6954 5874
02-50KeywordNull-Terminated
01Compression Flag00 or 01
01Zlib Compression00
Language TagNull-Terminated
Translated KeywordNull-Terminated
Text
04CRC

Textual Data   [116 69 88 116 "tEXt"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name7445 5874
02-50KeywordNull-Terminated
Text
04CRC

Compressed Text   [122 84 88 116 "zTXt"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name7A54 5874
02-50KeywordNull-Terminated
01Zlib Compression00
Text
04CRC

Animation Chunks
Animation Control   [97 99 84 76 "acTL"]
BytesPropertiesValues
04Chunk Size (8 bytes)0000 0008
04Chunk Name6163 544C
04num_frames
04num_plays
04CRC

Frame Control   [102 99 84 76 "fcTL"]
BytesPropertiesValues
04Chunk Size (26 bytes)0000 001A
04Chunk Name6663 544C
04sequence_number
04Frame Width
04Frame Height
04x_offset
04y_offset
02delay_numerator
02delay_denominator
01dispose_op
01blend_op
04CRC

Frame Data   [102 100 64 84 "fdAT"]
BytesPropertiesValues
04Chunk Size (Data - 4)
04Chunk Name6664 4154
04sequence_number
Data
04CRC

Miscellaneous Information
Background Colour   [98 75 71 68 "bKGD"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name624B 4744
01-06Index or Colour
04CRC

Histogram   [104 73 83 84 "hIST"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name6849 5354
Colour Frequencies
04CRC

Physical Pixel Dimensions   [112 72 89 115 "pHYs"]
BytesPropertiesValues
04Chunk Size (Data)0000 0009
04Chunk Name7048 5973
04X Pixels per Unit
04Y Pixels per Unit
01Units00 or 01
04CRC

Suggested Palette   [115 80 76 84 "sPLT"]
BytesPropertiesValues
04Chunk Size (Data)
04Chunk Name7350 4C54
02-50Palette NameNull-Terminated
01Sample Depth08 or 10
01 or 021st Red
01 or 021st Green
01 or 021st Blue
01 or 021st Alpha
021st Frequency
01 or 022nd Red
01 or 022nd Green
etc.
04CRC

§