delete_blank

Delete blank or near-blank pages

Usage

pdftl <input> delete_blank '[spec](params)' output <output>

Details

The delete_blank operation removes pages that are blank or visually uniform by rendering each candidate page at low resolution and analysing its pixels.

Detection methods:

Two complementary methods are available. If both are specified, a page must satisfy both criteria to be deleted.

  • threshold — ink coverage: the fraction of pixels that differ from pure white (0.0–1.0, default 0.005). Use threshold=0 for pure-white-only detection.

  • stddev — pixel standard deviation: how uniform the page is regardless of its base colour. A solid white or solid coloured page both score near zero (default 5.0, on a 0–255 scale). Useful for detecting pages with coloured backgrounds.

  • mode — colour space for analysis: grey (default) or rgb. rgb is more accurate for coloured backgrounds; grey is faster.

If neither threshold nor stddev is specified, both defaults are applied.

DPI:

The dpi parameter controls the render resolution used for detection (default: 30). Higher values catch finer marks but are slower.

Selector:

An optional page selector (e.g. 1-5, odd) restricts which pages are candidates for deletion. Non-candidate pages are always kept.

The syntax is [selector](Key=Value, ...), where all parameters are optional.

Parameters

Parameter

Description

Default

Example

threshold

Max ink coverage fraction to consider blank (0.0–1.0)

0.005

threshold=0

stddev

Max pixel stddev to consider uniform (0–255)

5.0

stddev=2.5

mode

Colour space: grey or rgb

grey

mode=rgb

dpi

Render resolution for detection

30

dpi=72

Examples

Delete blank pages using default threshold and stddev detection.

pdftl in.pdf delete_blank output out.pdf

Delete only perfectly white pages (zero ink coverage).

pdftl in.pdf delete_blank '(threshold=0)' output out.pdf

Delete pages that are visually uniform in any colour, using RGB analysis.

pdftl in.pdf delete_blank '(stddev=3,mode=rgb)' output out.pdf

On even pages only, delete near-blank pages rendered at 72 dpi.

pdftl in.pdf delete_blank 'even(threshold=0.01,dpi=72)' output out.pdf

Tags: in_place, pages, optimization, delete

Source: pdftl.operations.delete_blank

Read online: https://pdftl.readthedocs.io/en/stable/operations/delete_blank.html

Type: Operation