Skip to content

Feat: Add ignore-areas - #95

Open
damblatt wants to merge 4 commits into
vslavik:masterfrom
damblatt:feat/add-ignore-area
Open

Feat: Add ignore-areas#95
damblatt wants to merge 4 commits into
vslavik:masterfrom
damblatt:feat/add-ignore-area

Conversation

@damblatt

Copy link
Copy Markdown

Added an --ignore-area feature that allows users to define one or more rectangular regions to be excluded from PDF comparisons. Multiple rectangles can be specified as a ;-separated list (e.g. --ignore-area="10,10,50,100;20,20,50,100).

This is useful for documents that contain dynamic content such as serial numbers, timestamps, or unique identifiers reoccurring on every page at the same position. In my use case, each generated document contained one or more unique codes (data matrix codes) at fixed positions on the page, causing otherwise identical PDFs to be reported as different.

Pixels within an ignored area are excluded from the pixel-diff count and don't trigger the page-differs flag, but are still rendered using the original (unmodified) page content rather than the diff color overlay. In the output diff PDF, ignored areas are additionally marked with a dashed gray outline so it's clear they were excluded intentionally rather than simply matching.

damblatt added 3 commits June 24, 2026 11:09
Ignored area is defined by passing position (from the upper left corner), width and length of the rectangle.
separated by semicolon
@vslavik

vslavik commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Thanks! This looks well-written to me.

Can you please clarify these parts?

Pixels within an ignored area are [...] still rendered using the original (unmodified) page content rather than the diff color overlay.

Color from one of the documents, I take it?

In the output diff PDF, ignored areas are additionally marked with a dashed gray outline so it's clear they were excluded intentionally rather than simply matching.

Is this PDF output only or in the GUI viewer too? Makes sense to have it in both I think...

Negative coordinates are now causing an error, just like negative height/width did
@damblatt

Copy link
Copy Markdown
Author

Can you please clarify these parts?

Pixels within an ignored area are [...] still rendered using the original (unmodified) page content rather than the diff color overlay.

Currently, differing pixels are displayed in a red/cyan overlay. Since pages that have modified pixels inside the ignore area are not shown as different, I thought it would only make sense to also remove the color overlay inside the ignored area. This screenshot further illustrates what I mean:
image

In the output diff PDF, ignored areas are additionally marked with a dashed gray outline so it's clear they were excluded intentionally rather than simply matching.

Is this PDF output only or in the GUI viewer too? Makes sense to have it in both I think...

If by GUI viewer you mean the --view option, then yes, it works there too.

@damblatt

Copy link
Copy Markdown
Author

While testing with the --view option again, I also noticed a small bug: the preview is not shown when --output-diff is also specified.

@vslavik

vslavik commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Since pages that have modified pixels inside the ignore area are not shown as different, I thought it would only make sense to also remove the color overlay inside the ignored area.

Yes, that is clear (and reasonable). But my question was which of the two possibly different pixels do you choose? Left or right? This is an area where the 2 documents may differ without the diff being rendered. You say that the "original (unmodified) page content" is used, but that can't be — because there are two of them. So which do you pick?

While testing with the --view option again, I also noticed a small bug: the preview is not shown when --output-diff is also specified.

IIRC these are mutually exclusive modes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants