Image Redaction
Agent Mask extracts text from image files with OCR, detects configured PII entities in the OCR text, and can return visually redacted image bytes from the same mask() call.
Visual redaction is based on OCR-detected text regions. Text that OCR does not detect is not changed in the returned image.
Supported formats
Section titled “Supported formats”- PNG
- JPEG
- TIFF
Image bytes must be base64-encoded and zlib-compressed before passing them to mask().
Quick example
Section titled “Quick example”-- Image bytes must be base64-encoded and zlib-compressed.SELECT app_public.mask( '<compressed_base64_image>', OBJECT_CONSTRUCT( 'include_redacted_document', TRUE ));The response includes:
columns[0].deidentified_text- OCR text after PII replacement.columns[0].original_text- OCR text before replacement.columns[0].document_metadata- file type, dimensions, and OCR confidence.columns[0].redacted_document- base64-encoded, zlib-compressed redacted image bytes when visual redaction is requested and entities are found.
OCR language
Section titled “OCR language”Use the same language parameter used for text detection. It is also passed to the OCR engine for supported OCR languages.
OBJECT_CONSTRUCT( 'language', 'es', 'include_redacted_document', TRUE)Redaction colors
Section titled “Redaction colors”OBJECT_CONSTRUCT( 'include_redacted_document', TRUE, 'redaction_fill_color', ARRAY_CONSTRUCT(0, 0, 0), 'redaction_text_color', ARRAY_CONSTRUCT(255, 255, 255))Detected text regions are filled with the configured color and overlaid with the replacement text when it fits.
Redaction metadata
Section titled “Redaction metadata”OBJECT_CONSTRUCT( 'include_redacted_document', TRUE, 'include_redaction_metadata', TRUE)The response gains redaction_metadata with an entities_redacted count and pixel bounding_boxes. Single images use page 0.
Review and limitations
Section titled “Review and limitations”Image redaction applies to entities Agent Mask detects in OCR text. Detection quality depends on image resolution, contrast, rotation, compression artifacts, language, handwriting, unusual fonts, overlapping graphics, entity coverage, and any custom entities you configure.
The returned image redacts detected text regions only. Non-text image content is not changed, and text missed by OCR remains visible.
Treat the returned image and metadata as reviewable redaction output, not as proof that every possible identifier has been removed. For external sharing, regulated disclosure, or public release, visually review representative outputs and use redaction_metadata, analyzer results, and your own QA process to confirm the output is appropriate for the workflow.