Auto-Detect Should Not Auto-Apply: Building Reviewable Redaction Overlays
Source: Dev.to
The Problem with Auto‑Applying Redaction
Automatic redaction can feel unsafe when the review step is skipped. OCR, barcode detection, license‑plate heuristics, and signature detection all make mistakes. If the product silently bakes those guesses into the exported image, users cannot tell whether the result is cautious, incomplete, or simply wrong.
A Reviewable Architecture
Normalized Detection Output
Different detectors start from very different internals (OCR text blocks, barcode APIs, plate‑specific filters, connected‑component image analysis). The editor should not need to know about any of that once a candidate region exists.
The useful boundary is a single normalized shape:
lefttopwidthheight
When every detector emits this region format, the editor can stay consistent even while the detection engines remain totally different.
Editable Overlays in the Markup Editor
In the markup editor, automatic suggestions are inserted as ordinary objects:
- Text detections → redact rectangles
- Blur / pixelation detections → effect patches
These objects are editable: moveable, resizable, deletable, and visible before export. This interaction model is far better than “the detector already changed your image.”
Tagging Auto‑Generated Objects
Auto‑generated objects are tagged with a source identifier:
redact.data = {
objectType: "shape",
filled: true,
autoGenerated: options?.autoGenerated,
};
The tag lets the editor distinguish OCR‑generated regions from QR‑generated regions and from manual user edits. Without it, every new scan could wipe out the user’s manual cleanup.
Safe Re‑Detection
replaceAutoRedacts(regions: RedactRegion[], sourceTag: string) {
this.clearAutoGenerated(sourceTag);
regions.forEach((region) =>
this.addRedact(region, {
autoGenerated: sourceTag,
select: false,
})
);
}
This approach provides a clean behavior model:
- Detector reruns replace only their own old suggestions.
- Manual edits stay intact.
- The user retains control of the final reviewed state.
Honest Export Path
Instead of baking detection results in immediately, the editor rebuilds the final image from the source plus the current object set. The saved file therefore always reflects the reviewed state, not the detector’s first guess.
Detectors propose. Users decide. Export serializes the decision.
If an automatic detector can be wrong, it should create editable overlays rather than an irreversible export. This rule applies to OCR, QR codes, signatures, license plates, and essentially any privacy‑sensitive suggestion pipeline.
Why It Matters
- Turns a demo‑like auto‑detection feature into a trustworthy tool.
- Small code decisions (source tagging, normalized shapes) have huge product consequences.
Further Reading
- Full companion guide:
- Additional implementation details: