All formats

DjVu

Full nameDjVu ("déjà vu")
Extensions.djvu, .djv
MIME typeimage/vnd.djvu (also image/x-djvu)
Typedocument format for scanned pages, layered (mixed raster content) compression
Starts with41 54 26 54 46 4F 52 4D (AT&TFORM)
SpecificationDjVu Reference, version 3 (transcription of the Lizardtech 2005 spec)
Reference implementationDjVuLibre
Maintained byno active standards body; DjVuLibre is the de facto reference
Licenseopen specification, royalty-free; DjVuLibre is GPL

DjVu stores scanned pages: books, journals, manuals, maps and old documents. It splits each page into layers and compresses each with a method suited to it: text and line art as a sharp black-and-white mask, and paper texture, photos and colors as a low-resolution wavelet image. A scanned 300 dpi book page often takes 20-60 KB, several times smaller than the same page as a JPEG in a PDF.

A DjVu file can have a hidden text layer from OCR (so you can search and copy text), hyperlinks, a table of contents and thumbnails. Most digital libraries of old books moved to PDF, but large DjVu collections remain, especially of scanned science and math books.

When to use DjVu#

File structure#

DjVu uses the EA IFF 85 container, the same chunk structure as AIFF and the old Amiga formats. The file starts with the 4-byte magic AT&T, followed by one FORM chunk. Each chunk has a 4-character ID, a 4-byte big-endian length and the data. Chunk data is padded to an even length.

41 54 26 54               "AT&T" magic
46 4F 52 4D               "FORM"
00 00 2E 1A               length of the FORM
44 4A 56 55               "DJVU" (single page)
49 4E 46 4F               "INFO" chunk
00 00 00 0A               length: 10
08 9A 03 C7               width 2202, height 967 (big-endian)
1A 00                     version: minor 26, major 0
2C 01                     300 dpi (little-endian!)
16                        gamma 2.2 (x10)
01                        flags: rotation 0
53 6A 62 7A ...           "Sjbz" chunk: JB2 mask
...                       BG44, FG44, TXTz, ANTz chunks

Document types#

FORM type Contents
FORM:DJVU one page. A single-page file is just this form
FORM:DJVM multi-page document. Starts with a DIRM directory chunk, then optional NAVM (outline), then the page forms
FORM:DJVI shared data used by several pages (shape dictionary, annotations), referenced with INCL
FORM:THUM page thumbnails (TH44 chunks)

A multi-page document is either bundled (one .djvu file with all pages inside) or indirect (an index file whose DIRM lists separate per-page files). Indirect documents let a web server send one page at a time; bundled files are easier to handle.

Page chunks#

Chunk Contents
INFO page width and height in pixels, version, resolution in dpi, gamma, rotation. Must be first
Sjbz foreground mask: bitonal image (text, lines) compressed with JB2
Smmr alternative mask compressed with fax G4 (MMR)
Djbz shared JB2 shape dictionary (usually in a FORM:DJVI shared by many pages)
INCL ID of a shared FORM:DJVI component used by this page
BG44 background image compressed with IW44 wavelets, often in several chunks that refine the image progressively
FG44 foreground colors as an IW44 image
FGbz foreground colors as a palette, one color per JB2 shape
BGjp, FGjp background or foreground stored as JPEG (rare)
TXTz hidden text and its layout: page, column, region, paragraph, line, word and character zones with coordinates. BZZ-compressed (TXTa is the uncompressed form)
ANTz annotations: hyperlinks, highlighted areas, background color, initial zoom and metadata. BZZ-compressed (ANTa uncompressed)

How a page is rendered#

The page image is a combination of 3 layers, the mixed raster content (MRC) model:

  1. Background (BG44): paper texture and pictures, usually at 1/3 of the full resolution (100 dpi for a 300 dpi scan).
  2. Mask (Sjbz): a full-resolution black-and-white image that says which pixels belong to the foreground.
  3. Foreground colors (FG44 or FGbz): the color of the masked pixels, usually very low resolution.

A pure black-and-white page has only INFO and Sjbz. A photo page has only BG44.

The compression methods are specific to DjVu:

Creating and converting DjVu files#

The DjVuLibre command-line tools are the standard way to work with DjVu files:

Shell
c44 -dpi 300 photo.ppm photo.djvu        # color or grayscale image -> IW44 page
cjb2 -dpi 300 -lossy page.pbm page.djvu  # black-and-white image -> JB2 page
djvm -c book.djvu p1.djvu p2.djvu        # bundle pages into one document
ddjvu -format=tiff book.djvu book.tiff   # render to TIFF (also pnm, pdf)
djvutxt book.djvu book.txt               # extract the text layer
djvused book.djvu -e 'print-outline'     # show the table of contents
djvudump book.djvu                       # list the chunks

Specifications and documentation#

Software that opens DjVu files#

SoftwareWindowsmacOSLinuxWebCanNotes
SumatraPDF✓viewfree, open source; fast viewer for DjVu, PDF, EPUB and comic books
WinDjView✓view, convertfree, open source; tabs, thumbnails, export pages to images
DjView4✓✓✓view, convertDjVuLibre's viewer, free, open source; exports pages to other formats
Okular✓✓✓viewKDE document viewer, free, open source
GNOME Papers✓viewGNOME document viewer, successor of Evince
Evince✓viewolder GNOME document viewer
Zathura✓viewkeyboard-driven viewer, DjVu through the zathura-djvu plugin
KOReader✓✓viewe-reader app for Kindle, Kobo, PocketBook and Android. Also on Android
DjVu.js Viewer✓viewin the browser, also a browser extension
STDU Viewer✓viewfree for non-commercial use
DjVuLibre tools✓✓✓create, convertc44, cjb2, djvm, ddjvu, djvused; command line, GPL
pdf2djvu✓✓convertPDF to DjVu, keeps text and links
djvu-rs CLI✓✓✓create, convertDjVu to PDF, EPUB, PNG; images to DjVu; MIT
ABBYY FineReader PDF✓create, convertcommercial OCR; saves scans as DjVu

Libraries#

Open-source libraries that read and write DjVu. See all DjVu libraries for a comparison.

C/C++DjVuLibre
Pythondjvu-rs, python-djvulibre
Rustdjvu-rs