web2fb2.net

What Is a DjVu File?

An old textbook turns up as a download, scanned page by page, and the file is called something.djvu. It is far smaller than you expected, and you are not sure what opens it.

Nothing is wrong with the file. DjVu is a format built for scanned pages, and it keeps them much smaller than a PDF would.

Why the file is so small

DjVu.org describes it as a way to distribute very high resolution images of scanned documents, digital documents and photographs. The name is pronounced “déjà vu”, and the file extension is .djvu, or sometimes .djv.

The MobileRead wiki, a wiki about e-readers and their file formats, gives the size advantage as about 10 times better compression than PDF at the same quality. Any one book may differ from that figure.

The saving comes from splitting each page into two layers:

  • Background: paper texture and pictures. It is compressed at a lower resolution.
  • Foreground: text and line drawings. It stays at high resolution, so the edges of the letters stay sharp.

Repeated shapes help too. A letter that repeats across the page is stored once and referenced after that. A scanned page is mostly paper, and paper does not need much detail.

Can you search the text?

Not always. A DjVu file of a scanned textbook is made of pictures of pages. The format can carry a hidden OCR text layer.

OCR (optical character recognition) is software that reads the letters on a scan and turns them into text.

If whoever made the file added that layer, you can search the book and select words. If not, you can only look at the pages.

To check, open the .djvu file in a reader and try to search for a word, or select a line with the cursor.

If you can, the file has a text layer. If you cannot, it is most likely only page images.

What opens a DjVu file

You need a reader that supports DjVu. Two that do:

  1. SumatraPDF. It supports DjVu next to PDF, ePub, MOBI, CBZ and CBR. It is free and open source.
  2. KOReader. This open-source reader app for e-readers and Android handles DjVu among its fixed page formats. It can also reflow scanned PDF and DjVu documents with its built-in K2pdfopt library.

“Fixed page” means each page keeps its layout, as in a PDF, which keeps the page the way it was printed.

A CBZ or CBR comic is also a stack of page images.

Converting to PDF with Calibre

The e-book program Calibre takes DjVu as an input format and writes PDF as an output format, according to its FAQ. It converts only DjVu files that contain embedded text, which usually comes from OCR.

So Calibre can take a .djvu file that has a text layer and produce a PDF. Without a text layer, it will not convert the file, so use the search test above before you convert.

Open the PDF and check a few pages before you delete the original.

Converting to PDF also does not turn the book into a reflowing one. For text that adapts to the screen you would want an ePub file, and a scan with no text layer has no text to adapt.