Assemble DjVu files.
Synopsis% djvumake <djvufile> [Sjbz=<maskfile>] [FG44=<fgfile>] [BG44=<bgfile>]Description
This program assembles the DjVu file djvufile using the JB2 data contained in file maskfile and the IW44 data contained in files bgfile and fgfile. Although this is slightly beyond the scope of the DjVu Reference Library, the following description explains how to prepare the input files required for assembling DjVu files.
Recipe for creating a Photo DjVu File
You should first use program c44 and produce an IW44 file "my.iw4". Assuming that this image is 640 pixels wide and 480 pixels high, you can assemble file "my.djvu" using djvumake with the following arguments.
% djvumake my.djvu INFO=640,480 BG44=my.iw4Recipe for creating a Bilevel DjVu File
The first step consists in creating a JB2Image object according to the guidelines specified in section JB2Image.h. Then use function encode in class JB2Image to save the JB2 data into a file named "myjb2.q" for instance. You can then assemble file "my.djvu" using djvumake with the following arguments:
% djvumake my.djvu Sjbz=myjb2.qRecipe for creating a Compound DjVu File
Let us assume that you use a program like Gimp http://www.gimp.org or Photoshop. You have created your image using two layers. The background layer contains all pictures and background details. The foreground layer contains the text and the drawings. Transparency is controlled by a layer mask attached to the foreground layer. The layer mask contains the shape of the text and drawings in black and white. The actual foreground layer contains large patches of color which are only displayed where the layer mask is black. You can see a Gimp example in file "@Samples/layers.xcf.gz".
This layered model is very close to the Compound DjVu Image model. In the DjVu model however, the three images (the background layer, the foreground layer mask, and the actual foreground layer) can have different resolutions.
- The size of the foreground layer mask is always equal to the size of the DjVu image. You must create a JB2 file containing the foreground mask as explained in the Recipe for Creating a Bilevel DjVu File. Each zero pixel in the mask means that the corresponding pixel in the raw image belongs to the background. Each non zero pixel means that the corresponding pixel in the raw image belongs to the foreground. Let us call this file "myjb2.q".
- The size of the background image is computed by rounding up the ratio between the size of the mask and an integer background sub-sampling ratio in range 1 to 12. Choosing a sub-sampling ratio of 3 is usually a good starting point. You must then subsample the background layer image and save it into a PPM file named "mybg.ppm".
- The size of the foreground color image is computed by rounding up the ratio between the size of the mask and an integer background sub-sampling ratio in range 1 to 12. Choosing a sub-sampling ratio of 12 is usually adequate. You must then subsample the background layer image and save it into a PPM file named "myfg.ppm".
When you subsample these images, you should consider some refinements. The color of each pixel of the subsampled image is an average of the colors of a couple of pixels in the original image. When you compute this average, you eliminate the original pixels which are not visible, such as pixels of the background layer which are masked by the foreground, or pixels of the foreground color layer which are not visible because of the mask transparency.
It sometimes happens that you cannot compute the color of a pixel in the subsampled image because none of the pixels in the corresponding image are visible. That means that we do not really care about the color of the subsampled pixel because it is not visible at all. It is not desirable of course to encode the color value of such pixels. This is possible using the masking feature of the wavelet encoder. You must first save two PBM images named "mybg.pbm" and "myfg.pbm". These images have the same size as the corresponding PPM images. A black pixel in these images mean that we should not code the color of the corresponding pixel in the PPM image.
We must then encode both images using the c44 wavelet encoder. The following commands to the trick:
% c44 -slice 74+10+9+4 -mask mybg.msk mybg.ppm mybg.iw4 % c44 -slice 100 -crcbfull -mask myfg.msk myfg.ppm myfg.iw4Note that we use different options. The background wavelet file "mybg.iw4" contains four refinement chunks specified by option -slice. The foreground wavelet file "myfg.iw4" contains a single chunk (option -slice) and allocated more bits for encoding the colors (option -crcbfull).The last step consists of assembling the DjVu file using djvumake.
djvumake my.djvu Sjbz=myjb2.q FG44=myfg.iw4 BG44=mybg.iw4
Alphabetic index Hierarchy of classes