Image file formats
Mini-course at ICERM
Arnaud Chéritat
Page *
File structure
Open crop.png with a hex viewer, then with TweakPNG
NOTE: on other systems ImageMagick provides a command line tool:
identify -verbose image.png
Structure of a PNG:
PNG signature | IHDR chunk | … | chunks | … | IEND chunk |
8B (bytes) | 25B | 12B |
Length of data section |
Name | Data section | Checksum |
4 bytes | 4 bytes | from 0 to 231-1 bytes |
4 bytes |
Encoding 10000 = 39*256+16 as a four byte int gives
first byte: 00, second byte: 00, third byte: 39, last byte: 16
first byte: 00, second byte: 00, third byte: 39, last byte: 16
IHDR chunk : Header
00 00 00 0D | 49 48 44 52 | 4B | 4B | 1B | 1B | 1B | 1B | 1B | ** ** ** ** |
data len=13 | I H D R | width | height | bit depth | color type | compr. meth. | filter meth. | interlace method | checksum |
00 00 00 00 | 49 45 4E 44 | AE 42 60 82 |
[length=0] | I E N D | [checksum] |
Header:
- Max width or height = 231-1 ≈ 2×109
- 5 color types possible:
Color
typeAllowed
bit depthschannels 0 1, 2, 4, 8, 16 Grayscale 2 8, 16 R,G,B 3 1, 2, 4, 8 Palette index 4 8, 16 Grayscale, Alpha 6 8, 16 R,G,B,A
I strongly recommend reading part or all of the PNG specification.
More metadata
Open a3.png with TweakPNG
Open P1030418.JPG with XnView