Privacy redaction toolkit using PPStructureV3 OCR for text detection and replacement.
ScriptFormatCommandread.pyImages / PDF / Word / PowerPointread.py <input> [--info] [--mode json]``redact-image.pyImages (png, jpg, etc.)redact-image.py <input> <rules.csv> <output>``redact-pdf.pyPDFredact-pdf.py <input> <rules.csv> <output>``redact-document.pyWord (docx, doc)redact-document.py <input> <rules.csv> <output>``redact-presentation.pyPowerPoint (pptx, ppt)redact-presentation.py <input> <rules.csv> <output>
csv
target_text,replacement_text
张三,李四
手机号,
身份证号,
RuleEffect原文本,新文本Replace with new text原文本,Empty = mask with █ (documents) or solid color block (images/PDF)
FormatEmpty ReplacementImages, PDFSolid color block overlayWord, PowerPoint█ characters (same length as target)
read.py supports:
Reading text from images, PDF, Word, and PowerPoint files
OCR for image files and embedded images
Page-aware output for PDF / Word / PowerPoint
--info structured output:
<page index="..."><image format='markdown' type='ocr'>...</image> for OCR text extracted from imagesDocument-like files ( pdf, docx, doc, pptx) output:
json
{
"type": "pptx",
"pages": [
{
"page_index": 1,
"content": [
{ "type": "text", "text": "..." },
{ "type": "image", "text": "ocr text..." }
]
}
]
}
Image files output:
json
{
"type": "image",
"content": "..."
}
FeatureImagePDFDocumentPresentationRead text✅✅✅✅JSON output✅✅✅✅Text replacement✅✅✅✅Solid color mask✅✅--█ character mask--✅✅OCR detection✅✅✅ (images)✅ (images)Tables-✅✅✅Headers/Footers-✅✅-Embedded images-✅✅✅
使用 uv 安装依赖:
bash
# 进入 skill 目录
cd skills/redact
# 同步依赖(自动创建虚拟环境并安装)
uv sync