---
name: "didjvu"
section: "1"
platform: "linux"
package: "didjvu"
version: "0.8.2-2+deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/didjvu"
---

# didjvu(1)

DjVu encoder with foreground/background separation

## NAME

didjvu - DjVu encoder with foreground/background separation

## SYNOPSIS

**didjvu separate** \[{**-o** \| **--output**} *output-mask*\] \[*option*...\] *input-image*

**didjvu separate** **--output-template** *name-template*  \[*option*...\] *input-image*...

**didjvu encode** \[{**-o** \| **--output**} *output-djvu*\] \[*option*...\] *input-image*

**didjvu encode** **--output-template** *name-template*  \[*option*...\] *input-image*...

**didjvu bundle** \[{**-o** \| **--output**} *output-djvu*\] \[*option*...\] *input-image*...

**didjvu** {**--version** \| **--help** \| **-h**}

## DESCRIPTION

**didjvu** uses the *Gamera*\[1\] framework to separate foreground/background layers, which can be then encoded into a DjVu file.

**didjvu separate** generates images mask(s) for the supplied input image(s). Masks are saved in the PNG format.

**didjvu encode** converts the supplied input image(s) to single-page DjVu documents(s).

**didjvu bundle** converts the supplied input image(s) to a bundled multi-page DjVu document.

## OPTIONS

**didjvu** accepts the following options:

### Input, output

- **-o**, **--output=***output-djvu*

  Generate a bundled multi-page document. Write the file into *output-djvu* file instead of standard output.

  For **separate** and **encode** commands, this option is allowed only if there is exactly one input file (i.e. exactly one output file).

- **--output-template=***template*

  Specifies the naming scheme for output files for the **separate** and **encode** commands. Please consult the “TEMPLATE LANGUAGE” section for the template language description.

  This option is mandatory if there is more than one input file (i.e. more than one output file).

- **--page-id-template=***template*

  Specifies the naming scheme for page identifiers for the **bundle** command. Please consult the “TEMPLATE LANGUAGE” section for the template language description. The default template is “{base-ext}.djvu”.

  For portability reasons, page identifiers:

  • must consist only of lowercase ASCII letters, digits, \_, +, - and dot,

  • cannot start with a +, - or a dot,

  • cannot contain two consecutive dots,

  • must end with the .djvu extension.

### Masks

- **--loss-level=***n*

  Specifies the aggressiveness of the lossy compression for the **separate** and **encode** commands. The default is 0 (lossless). Valid values are integers between 0 and 200, inclusive.

  This option is similar to the **-losslevel** option of **cjb2**; please consult the [**cjb2**(1)](/cjb2/1.md) manual page for details.

- **--lossless**

  Synonym for **--loss-level=0**.

- **--clean**

  Synonym for **--loss-level=1**.

- **--lossy**

  Synonym for **--loss-level=100**.

- **-m**, **--method=***method*

  Use the selected method to generate image mask (i.e. separate foreground from background). The following methods should be available:

  abutaleb

  Abutaleb locally-adaptive thresholding algorithm

  bernsen

  Bernsen thresholding algorithm

  brink

  Brink and Pendock's minimum-cross entropy method

  **Note**\
   this method requires Gamera ≥ 3.4.0

  djvu

  DjVu thresholding algorithm

  global

  splitting along a global threshold value

  niblack

  Niblack adaptive thresholding algorithm

  otsu

  Otsu thresholding algorithm

  sauvola

  Sauvola adaptive thresholding algorithm

  shading-subtraction

  thresholds an image after subtracting a possibly shaded background

  **Note**\
   this method requires Gamera ≥ 3.3.1

  tsai

  splitting along a threshold value determined using the Tsai Moment Preserving Threshold algorithm

  white-rohrer

  White and Rohrer dynamic thresholding algorithm

  The default is ‘djvu’.

  Please consult the *Gamera documentation*\[2\] for details.

- **-x**, **--param=***name***=***value*

  Set parameter for the binarization method.

  This option can be used more than once.

  Please consult the *Gamera documentation*\[2\] for details.

- **-p**, **--pages-per-dict=***n*

  For **bundle** command: if *n* \> 1, compress masks with **minidjvu** using *n* pages in one pass. The default is 1.

- **--masks**, **--mask=***input-mask*

  Use the pre-generated image masks for the **encode** and **bundle** commands.

### Foreground/background quality, resolution

(These options apply to **encode** and **bundle** commands only.)

- **-d**, **--dpi=***resolution*

  Specifies the desired resolution to *resolution* dots per inch. The default is to preserve the input file resolution, or 300 dpi if resolution metadata is missing. The allowed range is: 72 ≤ *resolution* ≤ 6000.

- **--fg-slices=***n*

  Specifies the encoding quality of the IW44 foreground layer. The default is 100.

  This option is similar to the **-slice** option of **c44**; please consult the [**c44**(1)](/c44/1.md) manual page for details.

- **--fg-crcb=normal**

  Select normal chrominance encoding of the foreground layer.

- **--fg-crcb=half**

  Select half resolution chrominance encoding of the foreground layer.

- **--fg-crcb=full**

  Select the highest possible quality for encoding the chrominance information of the foreground layer. This is the default.

- **--fg-crcb=none**

  Disable the encoding of the chrominance of the foreground layer.

- **--fg-subsample=***n*

  Specifies the foreground subsampling ratio. The default is 6. Valid values are integers between 1 and 12, inclusive.

 **--bg-slices=***n***+***...***+***n* ,  **--bg-slices=***n***,***...***,***n*

Specifies the encoding quality of the IW44 background layer. The default is 74+10+6+7.

This option is similar to the **-slice** option of **c44**; please consult the [**c44**(1)](/c44/1.md) manual page for details.

- **--bg-crcb=normal**

  Select normal chrominance encoding of the background layer. This is the default.

- **--bg-crcb=half**

  Select half resolution chrominance encoding of the background layer.

- **--bg-crcb=full**

  Select the highest possible quality for encoding the chrominance information of the background layer.

- **--bg-crcb=none**

  Disable the encoding of the chrominance of the background layer.

- **--bg-subsample=***n*

  Specifies the background subsampling ratio. The default is 3. Valid values are integers between 1 and 12, inclusive.

### XMP support

(These options apply to **encode** and **bundle** commands only.)

- **--xmp**

  Create sidecar *XMP*\[3\] metadata.

  **Note**\
   This option is experimental!

### Verbosity, help

- **-v**, **--verbose**

  Display more informational messages while converting the file.

- **-q**, **--quiet**

  Don't display informational messages while converting the file.

- **--version**

  Output version information and exit.

- **-h**, **--help**

  Display help and exit.

## ENVIRONMENT

The following environment variables affects **didjvu**:

*TMPDIR*

**didjvu** makes heavy use of temporary files. It will store them in a directory specified by this variable. The default is /tmp.

## TEMPLATE LANGUAGE

### Template syntax

The template language uses the *Python string formatting syntax*\[4\].

### Available field names

*name*

input file path

*name-ext*

input file path without file extension

*base*

input file name without directory components

*base-ext*

input file name without directory components and without file extension

*page*, *page+N*, *page-N*

page number, optionally shifted by a number *N*

## SEE ALSO

[**djvu**(1)](/djvu/1.md), [**djvumake**(1)](/djvumake/1.md), [**c44**(1)](/c44/1.md), [**cjb2**(1)](/cjb2/1.md), [**minidjvu**(1)](/minidjvu/1.md),

## NOTES

- 1\.

  Gamera

  *http://gamera.informatik.hsnr.de/*

- 2\.

  Gamera documentation

  *http://gamera.informatik.hsnr.de/docs/gamera-docs/binarization.html*

- 3\.

  XMP

  *https://www.adobe.com/devnet/xmp.html*

- 4\.

  Python string formatting syntax

  *https://docs.python.org/library/string.html#format-string-syntax*
