Help:Creating a DjVu file

From Wikimedia Commons, the free media repository

Jump to: navigation, search

This page explains how to create a DjVu file. The format can be used in galleries or categories like any supported image format, and reduces the size and number of the files that need to be copied.

If you have difficulties, you can ask for help at the Commons:Help desk.

Example: [[File:Alice in Wonderland.djvu|thumb|Alice in Wonderland, page 9|page=9]].

Alice in Wonderland, page 9

.

Contents

[edit] Introduction

The aim is to create a DjVu file from bitmap versions (jpg, tif, etc.) found on Internet or scanned. This is favorable because:

  • all pages of a book are available on a single file
  • all pages can be seen from the file page of the DjVu file
  • every page can be used in the "page" space
  • DjVu files are small
  • only one single file needs to be copied, compared to hundreds of pages in bitmap format.
  • creating a DjVu file is quicker than uploading hundreds of bitmap files.

Drawbacks:

  • The numbering of the pages does not seem to be freely configurable
  • Loss of quality can occur

[edit] Creating a DjVu file

[edit] MS Windows

Install DjVu Solo. It is also possible to use LizardTech Virtual Printer, which is available for no charge and can convert documents through a printing process.

[edit] Conversion through DjVu Solo

Procedure is more or less the same for all conversion programmes: load the bitmap files into the programme, check their order and launch the conversion process.

[edit] Conversion through DjVuLibre

DjVuLibre doesn't have a GUI for converting files, but with an appropriate script you can do it automatically with next to no user input. The scripts on this page perform this conversion, resulting in a single, collated DjVu file.

[edit] Acquiring bitmap files

If you have a scanner, DjVu can use it to import bitmap files.

[edit] Page numbering

The DjVu format created a default page numbering which is displayed in a drop-down menu (see Image:Wind in the Willows.djvu). It is advisable to have the page numbering match that of the original book, for easier use. This can be problematic when some pages (like in introductions) are numbered in Roman numbers. In this case, one solution is to create a second DjVu file for these pages.

[edit] Resolution

By default, DjVu Solo is set to convert pages with a 300 dpi resolution. This is usually a good value.

[edit] Converting a pdf file

Any2DjVu Server allows to directly convert a pdf file.

Pdf files from Gallica can be fetched simply by giving their FTP address to Any2DjVu Server. However, it is often advisable to edit the pdf file to have a better placement of the page in the frame. This can be done by extracting all pages and cropping them with software like XnView, and by loading them into DjVu Solo.

Google Books files cannot be converted directly because of their compression. Pages should be extracted and converted in a bitmap format in order to create the DjVu file. Several method have been tested:

  • opening the file in FineReader
  • utilising PdfCreator, which can export PDF is several bitmap formats.
  • utilising pdf to jpg or tiff programme. These are often proprietary software. (ImageMagick's convert can split a PDF into single images of pages; it's free.)

[edit] Other formats

Tiff files from Gallica can be opened in FineReader (even after the evaluation period is over). By exporting the pages into tiff (same format), it is possible to crop the margins with XnView, and to load the pages into DjVu Solo. Page numbering is automatic.

[edit] On Linux, FreeBSD, etc.

You need the DjVuLibre software, a collection of command-line tools for creating, modifying, and viewing DjVu files. You will probably also need the ImageMagick or GraphicsMagick software if you need to convert page scans from bitmap formats.

[edit] Converting page scans

The tool cjb2 is used to creating a DjVu file from a PBM or TIFF file. Therefore you need to convert your scans if they are not already in one of these formats. (The examples below use the convert tool from ImageMagick, but they will also work with GraphicsMagick's gm convert command.)

  • Conversion from PNG format to PBM format with convert:
 convert rig_veda-000.png rig_veda-000.pbm
  • Depending on the quality of the original scans, you may find it useful to process them with the unpaper utility, which deletes black borders around the pages and aligns the scanned text squarely on the page. Unpaper is also capable of extracting two separate page images where facing pages of a book have been scanned into a single image.
  • Creation of a DjVu file from a PBM file
 cjb2 -clean rig_veda-000.pbm rig_veda-000.djvu
  • Adding the DjVu file to the final document
 djvm -i rig_veda.djvu rig_veda-000.djvu

You need to repeat these steps with a script for each page of the book. Example:

#!/bin/bash
for n in `seq 1 9`
do
        i="rig_veda-$n.png"
        j=`basename $i .png`
        convert $i $j.pbm
        cjb2 -clean $j.pbm $j.djvu
        djvm -i rig_veda.djvu $j.djvu
done

[edit] Converting PostScript files (PDF, PS, EPS)

DjvuLibre includes djvudigital, a tool that uses Ghostscript to directly convert PDF and other PostScript files to DjVu format. However, it requires rebuilding Ghostscript from source code to include a special driver needed by djvudigital (it's part of the DjvuLibre distribution, but because of conflicting open-source licenses, it cannot be distributed legally as a binary). Once built, though, it is a very convenient tool to use; it can even convert PDF files from Google Books without any extra work. It's as easy as:

 djvudigital --words some_book.pdf

The --words option should be included to copy any searchable text that exists in the PDF file over to the final DjVu file. This also allows words to be highlighted in searches. (To eke out a little savings in file size, you could use --lines instead of --words, which would record the position of each line instead of each individual word; text could still be searched by word, but entire lines would be highlighted in search results instead of the individual words. This probably won't matter in maps, illustrations, etc. where words are scattered all over the page.)

[edit] DjVu format use in page mode

(This only works if you have the ProofreadPage extension installed, like all Wikisources.)

Once a DjVu file is uploaded to Commons, an index page needs to be created. Navigation in the "page" space is done by using the name of the file prefixed by "page:" and followed by "/X", with "X" is the page number.

[edit] Resources

In Wikipedia