These chunks describe pages and documents rather than holding image data. Field
layouts follow the DjVu Reference version 3 and DjVuLibre’s source code, which the
reference defers to for INFO.
INFO
The first chunk of every page. It is normally 10 bytes; DjVuLibre accepts 5 or more and uses defaults for the rest. Note the mixed byte order.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
0 | 2 | UInt16 BE | width | Page width in pixels. |
2 | 2 | UInt16 BE | height | Page height in pixels. |
4 | 1 | UInt8 | minorVersion | Low byte of the format version. |
5 | 1 | UInt8 | majorVersion | High byte of the version; 0 in practice, so the version is the minor byte. 0xFF means “not set”, and only the minor byte is used. |
6 | 2 | UInt16 LE | dpi | Resolution in dots per inch, little-endian. Default 300; DjVuLibre treats values below 25 or above 6,000 as 300, and a high byte of 0xFF as unset. |
8 | 1 | UInt8 | gamma | The display gamma × 10, so 22 is 2.2 (the default). Clamped to 0.3–5.0. |
9 | 1 | UInt8 | flags | Bits 0–2: rotation, see below. Other bits unused. |
flags & 7 | Rotation to apply when displaying |
|---|---|
| 1 | None (written for no rotation; any value not listed here also means none) |
| 6 | 90° counter-clockwise |
| 2 | 180° |
| 5 | 90° clockwise (270° counter-clockwise) |
Versions
| Version | Meaning (from DjVuLibre) |
|---|---|
| 15 and below | Too old for DjVuLibre to decode completely (early DjVu 1 files). |
| 22 | The version that introduced rotation. |
| 24 | Written by DjVuLibre, kept low for older viewers. |
| 26 | The current format version. |
| up to 50 | Newer files DjVuLibre will still try to read. |
INCL
The ID of a shared component (a FORM:DJVI), as plain text with no
terminator, such as dict0001.iff. The page uses the shape dictionary or
annotations in that component as if they were its own. A page may have several.
BZZ compression
DIRM (in part), NAVM, ANTz and
TXTz are compressed with BZZ, DjVu’s own general-purpose method: the data
is cut into blocks of up to 4 MB, each block goes through a Burrows–Wheeler transform
and move-to-front coding, and the result is coded with the ZP adaptive binary
arithmetic coder (262 contexts, kept from block to block). A block size of 0 ends the
stream. The algorithm is in an appendix of the DjVu Reference and in DjVuLibre’s
BSByteStream.cpp.
DIRM
The first chunk of a FORM:DJVM: a list of every component file of the
document, in order. Pages appear in the order of their entries.
| Part | Size | Type | Name | Description |
|---|---|---|---|---|
| plain | 1 | UInt8 | flags | Bit 7: 1 bundled, 0 indirect. Bits 0–6: directory version, currently 1. |
| 2 | UInt16 | nfiles | The number of components, n. | |
| 4 × n | UInt32[] | offsets | Bundled only: where each component’s FORM starts, from the start of the file. | |
| BZZ-compressed | 3 × n | UInt24[] | sizes | Each component’s size in bytes; may be 0 in indirect documents. |
| n | UInt8[] | flags | One per component: bit 7 a name follows, bit 6 a title follows, bits 0–5 the type (below). | |
| varies | strings | ids | Per component: the ID, then the name and the title if their flags are set, each ended by a zero byte. |
| Type | Component |
|---|---|
| 0 | Included file: a FORM:DJVI shared by pages. |
| 1 | Page: a FORM:DJVU. |
| 2 | Thumbnails: a FORM:THUM. |
| 3 | Shared annotations: a FORM:DJVI whose annotations apply to every page (a DjVuLibre addition). |
The ID is the component’s file name in an indirect document and its key in a bundled
one; INCL chunks and links (#name) refer to it. The name, if
different, is a file name to use when the document is split. The title is the page
title shown to readers, such as a printed page number.