Introduction
DjVu (said “déjà vu”) is a format for scanned documents, developed at AT&T Labs from 1996. It splits each scanned page into layers: a sharp black-and-white mask for the text and line art, and a low-resolution background and foreground for colour and pictures. Each layer is compressed with a method suited to it, so a scanned page is often much smaller than the same page as a JPEG or a PDF of images.
It is used mostly for scanned books and papers in online libraries and archives.
The extension is .djvu or .djv.
Structure
A DjVu file uses the IFF chunk
layout, big-endian. It starts with the four bytes AT&T, then a
FORM chunk whose type is DJVU for a single page or
DJVM for a multi-page document. A page holds an
INFO chunk
with its size, resolution and rotation, an
Sjbz chunk
with the text mask compressed by JB2,
BG44 and
FG44 chunks with the wavelet-compressed background and foreground, and
optionally annotations and
hidden text from OCR in ANTz and TXTz chunks. A multi-page
file starts with a DIRM
directory of its pages and an optional NAVM outline; shape dictionaries
shared between pages sit in FORM:DJVI components.
0AT&T magic bytes4 bytes4FORM chunk ID, length, form typeDJVU12 bytes
Not described
The DjVu v3 reference is public. The pages give the chunk and header layouts but not the coding algorithms, so a decoder cannot yet be written from them alone.
Known, not yet covered
- Reference: the ZP arithmetic coder (reference section 11.2), the JB2 record coding with its contexts and the four coding phases, see JB2.
- Reference: the IW44 band and quantisation tables and the coefficient coding (reference sections 10.3 and 10.4), see IW44.
- Reference: the bit-level BZZ coding used for DIRM, NAVM, ANTz and TXTz, see BZZ.
- Viewer: there is no DjVu viewer; the file is not recognised, so the explorer shows it as unidentified bytes.
Unknown
- Reference: the
CIDachunk found in some files, which the specification does not describe. - Reference: the colour byte order of the FGbz palette (stated from DjVuLibre’s pixel layout, not from the specification) and the usual 1/12 resolution of FG44, which is common practice, not specified.
Links
Software
- DjVuLibre – free DjVu tools and the DjView viewer (Windows, macOS, Linux)
- SumatraPDF – small, fast free viewer that opens DjVu (Windows)
- Okular – KDE’s document viewer, which opens DjVu (Linux, Windows)
Developers
- DjVuLibre – library and command-line tools that decode and encode DjVu (C++)
Reference
- DjVu Reference, version 3 – a web transcription of LizardTech’s 2005 specification
- djvused – DjVuLibre’s manual page, which documents the annotation, hidden text and outline syntax