Redact Skill
Privacy redaction toolkit using PPStructureV3 OCR for text detection and replacement.
Scripts
| Script |
Format |
Command |
read.py |
Images / PDF / Word / PowerPoint |
read.py <input> [--info] [--mode json] |
redact-image.py |
Images (png, jpg, etc.) |
redact-image.py <input> <rules.csv> <output> |
redact-pdf.py |
PDF |
redact-pdf.py <input> <rules.csv> <output> |
redact-document.py |
Word (docx, doc) |
redact-document.py <input> <rules.csv> <output> |
redact-presentation.py |
PowerPoint (pptx, ppt) |
redact-presentation.py <input> <rules.csv> <output> |
CSV Rules Format
target_text,replacement_text
张三,李四
手机号,
身份证号,
| Rule |
Effect |
原文本,新文本 |
Replace with new text |
原文本, |
Empty = mask with █ (documents) or solid color block (images/PDF) |
Masking Behavior
| Format |
Empty Replacement |
| Images, PDF |
Solid color block overlay |
| Word, PowerPoint |
█ characters (same length as target) |
Read Features
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 images
JSON Output
Document-like files (pdf, docx, doc, pptx) output:
{
"type": "pptx",
"pages": [
{
"page_index": 1,
"content": [
{ "type": "text", "text": "..." },
{ "type": "image", "text": "ocr text..." }
]
}
]
}
Image files output:
{
"type": "image",
"content": "..."
}
Features
| Feature |
Image |
PDF |
Document |
Presentation |
| Read text |
✅ |
✅ |
✅ |
✅ |
| JSON output |
✅ |
✅ |
✅ |
✅ |
| Text replacement |
✅ |
✅ |
✅ |
✅ |
| Solid color mask |
✅ |
✅ |
- |
- |
| █ character mask |
- |
- |
✅ |
✅ |
| OCR detection |
✅ |
✅ |
✅ (images) |
✅ (images) |
| Tables |
- |
✅ |
✅ |
✅ |
| Headers/Footers |
- |
✅ |
✅ |
- |
| Embedded images |
- |
✅ |
✅ |
✅ |
Environment Setup
使用 uv 安装依赖:
# 进入 skill 目录
cd skills/redact
# 同步依赖(自动创建虚拟环境并安装)
uv sync
Dependencies
- Python 3.10+
- PaddleOCR / PPStructureV3
- python-docx, python-pptx, PyMuPDF, Pillow
1---2name: redact3description: Privacy redaction toolkit for images, PDFs, Word documents, and PowerPoint presentations. Use when the user needs to redact, mask, or replace sensitive/private information in files. Triggers: - Redacting or masking sensitive text in images, PDFs, documents, or presentations - Replacing names, phone numbers, IDs, or other PII in files - Processing privacy compliance for documents before sharing - Anonymizing content in visual files Supported formats: png/jpg images, PDF, docx/doc, pptx/ppt4---56# Redact Skill78Privacy redaction toolkit using PPStructureV3 OCR for text detection and replacement.910## Scripts1112| Script | Format | Command |13|--------|--------|---------|14| `read.py` | Images / PDF / Word / PowerPoint | `read.py <input> [--info] [--mode json]` |15| `redact-image.py` | Images (png, jpg, etc.) | `redact-image.py <input> <rules.csv> <output>` |16| `redact-pdf.py` | PDF | `redact-pdf.py <input> <rules.csv> <output>` |17| `redact-document.py` | Word (docx, doc) | `redact-document.py <input> <rules.csv> <output>` |18| `redact-presentation.py` | PowerPoint (pptx, ppt) | `redact-presentation.py <input> <rules.csv> <output>` |1920## CSV Rules Format2122```csv23target_text,replacement_text24张三,李四25手机号,26身份证号,27```2829| Rule | Effect |30|------|--------|31| `原文本,新文本` | Replace with new text |32| `原文本,` | Empty = mask with █ (documents) or solid color block (images/PDF) |3334## Masking Behavior3536| Format | Empty Replacement |37|--------|-------------------|38| Images, PDF | Solid color block overlay |39| Word, PowerPoint | `█` characters (same length as target) |4041## Read Features4243`read.py` supports:4445- Reading text from images, PDF, Word, and PowerPoint files46- OCR for image files and embedded images47- Page-aware output for PDF / Word / PowerPoint48- `--info` structured output:49 - `<page index="...">`50 - `<image format='markdown' type='ocr'>...</image>` for OCR text extracted from images5152### JSON Output5354Document-like files (`pdf`, `docx`, `doc`, `pptx`) output:5556```json57{58 "type": "pptx",59 "pages": [60 {61 "page_index": 1,62 "content": [63 { "type": "text", "text": "..." },64 { "type": "image", "text": "ocr text..." }65 ]66 }67 ]68}69```7071Image files output:7273```json74{75 "type": "image",76 "content": "..."77}78```7980## Features8182| Feature | Image | PDF | Document | Presentation |83|---------|:-----:|:---:|:--------:|:------------:|84| Read text | ✅ | ✅ | ✅ | ✅ |85| JSON output | ✅ | ✅ | ✅ | ✅ |86| Text replacement | ✅ | ✅ | ✅ | ✅ |87| Solid color mask | ✅ | ✅ | - | - |88| █ character mask | - | - | ✅ | ✅ |89| OCR detection | ✅ | ✅ | ✅ (images) | ✅ (images) |90| Tables | - | ✅ | ✅ | ✅ |91| Headers/Footers | - | ✅ | ✅ | - |92| Embedded images | - | ✅ | ✅ | ✅ |9394## Environment Setup9596使用 [uv](https://docs.astral.sh/uv/) 安装依赖:9798```bash99# 进入 skill 目录100cd skills/redact101102# 同步依赖(自动创建虚拟环境并安装)103uv sync104```105106## Dependencies107108- Python 3.10+109- PaddleOCR / PPStructureV3110- python-docx, python-pptx, PyMuPDF, Pillow