delete_images
Delete images
Usage
pdftl
<input>delete_images[[spec](params)...]output<output>
Details
The delete_images operation permanently overwrites images matching specific criteria
with a 1x1 transparent pixel. This safely crushes large graphical bloat (like full-page ads)
while maintaining strict PDF structural validity.
Global vs. Page-Based:
Global (Default): If you omit the page selector or use
-, the operation scans the entire internal PDF object table. It will aggressively find and destroy matching images no matter where they hide (including inside annotations, patterns, and background forms).Page-Based: If you provide a specific page range (e.g.,
1-5), it will only scan those specific pages and the forms located on them. (Note: Because the underlying data is overwritten, if a deleted image on page 1 is also shared on page 10, it will visually disappear from page 10 as well).
The syntax is [selector](Key=Value, ...), where:
selectoris an optional page range (1-5,odd,-). If omitted, acts globally.Key=Valuepairs define the filter criteria an image must meet to be deleted.
If you only have one such selector block, you can replace it with separate arguments without parentheses or commas, as a convenient shorthand.
Filter Parameters
Parameter |
Description |
Example |
|---|---|---|
|
Min stream size in bytes. Supports |
|
|
Max stream size in bytes. Supports |
|
|
Min dimensions ( |
|
|
Max dimensions ( |
|
|
Substring match against the image filter. |
|
Note: If multiple parameters are provided, an image must meet ALL criteria to be replaced.
Examples
Globally scan and destroy any image larger than 500KB anywhere in the document.
pdftl in.pdf delete_images minbytes=500k output out.pdf
On even pages from 1 to 10, destroy images > 100KB with a minimum dimension of 20x400.
pdftl in.pdf delete_images 1-10even minbytes=100k minpixels=20x400 output out.pdf
On pages 1 to 3, delete images > 100KB, and all images on remaining pages
pdftl in.pdf delete_images '1-3(minbytes=100k)' 4-end output out.pdf
Globally destroy all JPEG (DCTDecode) images.
pdftl in.pdf delete_images format=dct output out.pdf
Tags: in_place, images, optimization, delete
Source: pdftl.operations.delete_images
Read online: https://pdftl.readthedocs.io/en/latest/operations/delete_images.html
Type: Operation