Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've downloaded some files from the Internet Archive. They come in different file formats and most of the time I use PDF. However, sometimes the scans are saved in colour instead of black & white. This makes it difficult (or impossible) to read on a dedicated e-book reader. In that case I downloaded the DjVu files, as on the PC you can select which layer (colour, bw, foreground, background) one would like to see.

Selecting black & white gives excellent results. However, the e-book reader does not have this option.

The question is, how can I remove or extract a layer from the DjVu file and save only this layer?

So far I've tried the following two approaches:

  1. Select black & white in the DjVu viewer on the PC and print to a PostScript file. Followed by a ps2pdf conversion. This works, but generates a fairly large PDF file. Sure, I can again upload it to any2DjVu but it just seems to much manual work for each file.

  2. I tried the shared annotation feature and said "mode bw". This works on the PC as desired but is ignored on the e-book reader as the other layers are still present.

share|improve this question

3 Answers 3

up vote 1 down vote accepted
  1. Unbundle djvu file: djvuextract g.djvu BG44=g.c44 ; djvuextract t.djvu Sjbz=t.cjb2
  2. Bundle it again: djvumake q.djvu INFO=1662,1840 BGbz=\#white Sjbz=t.cjb2 FGbz=\#black

(commands are ad-hoc, I haven't verified them)

share|improve this answer
    
Thank you for pointing me in the right direction. It looks promising but I get an error. I will read the man pages to the commands you've provided and will see what I've done wrong. –  Jon Jan 11 '11 at 18:14

The program you want is djvups. Just like its name suggests, it'll convert from DjVu to PostScript, with the bonus of letting you select which layers to retain (all, foreground, background, or foreground mask). Try this:

djvups -mode=foreground -gray input.djvu output.ps

or, to just output the foreground mask:

djvups -mode=black input.djvu output.ps

Following this conversion, ps2pdf should get you what you want.

share|improve this answer

There is a method, that does not involve inflating the file. I'll assume a single page file for simplicity. Maybe the method can be adapted to multiple pages as well. First list the chunks in your file using djvudump. A typical output will look like this:

FORM:DJVU [72422] 
  INFO [10]         DjVu 2443x3471, v24, 300 dpi, gamma=2.2
  Sjbz [47781]      JB2 bilevel data
  FG44 [3393]       IW4 data #1, 100 slices, v1.2 (color), 408x579
  BG44 [2611]       IW4 data #1, 74 slices, v1.2 (color), 815x1157
  BG44 [3307]       IW4 data #2, 10 slices
  BG44 [1208]       IW4 data #3, 6 slices
  BG44 [8543]       IW4 data #4, 7 slices

You can then extract the non-background chunks.

djvuextract input.djvu Sjbz=tmp1
djvuextract input.djvu FG44=tmp2

When you create a new file without giving any background, it will default to being white. The numbers passed to INFO are the dimensions and the DPI from the djvudump output.

djvumake output.djvu INFO=2443,3471,300 Sjbz=tmp1 FG44=tmp2

Some scripting is likely needed to make this useful in practice.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.