A Codex skill for high-fidelity text editing inside screenshots embedded in legacy Word .doc files.
This skill is designed for fragile document-editing tasks where visible screenshot text must be changed without leaving obvious artifacts. It was built around network-lab style Word reports that contain terminal screenshots, Wi-Fi/Phone UI screenshots, and mixed PNG/JPEG images stored inside OLE Data streams.
- Replace visible text inside embedded screenshots.
- Handle legacy binary Word
.docfiles. - Extract and write back embedded PNG and JPEG images.
- Use character-level OCR boxes for terminal-style screenshots.
- Redraw small UI text fields when glyph patching would look fake.
- Validate the final
.docafter write-back, not only intermediate images.
Typical targets include:
- terminal prompts
- SSIDs
- device names
- command output labels
- numeric identifiers
- MAC-like or IP-like strings
- small UI table text
Naive screenshot patching usually fails in subtle ways:
- OCR word boxes are too coarse for per-character edits.
- Pasting full rectangles creates visible background blocks.
- Small proportional UI fonts look fake when edited digit-by-digit.
- Legacy
.docfiles may contain both PNG and JPEG screenshots. - A final Word document can differ from intermediate extracted images after compression and write-back.
This skill captures a stricter workflow: inspect all image formats, use character-level OCR where possible, choose the right repair method for the image type, and validate the final artifact.
Clone or copy this folder into your Codex skills directory:
mkdir -p ~/.codex/skills
git clone https://github.com/wangdada8208/embedded-screenshot-text-editor.git \
~/.codex/skills/embedded-screenshot-text-editorThen invoke it in Codex with:
$embedded-screenshot-text-editor
The workflow may use:
- Python 3
- Pillow
- olefile
- Tesseract OCR
- macOS
qlmanagefor Quick Look validation
Install Python dependencies when needed:
python3 -m pip install Pillow olefileInstall Tesseract separately, for example on macOS:
brew install tesseractFor Chinese/English screenshots, make sure the needed OCR language data is available, such as eng and chi_sim.
embedded-screenshot-text-editor/
├── SKILL.md
├── agents/
│ └── openai.yaml
├── references/
│ └── pitfalls.md
└── scripts/
└── ole_image_text_editor.py
The bundled script is a conservative starting point. It supports equal-length text replacement in extracted OLE images.
Extract images:
python3 scripts/ole_image_text_editor.py extract \
--docs input.doc \
--work work/screenshot_text_editEdit equal-length text:
python3 scripts/ole_image_text_editor.py edit \
--work work/screenshot_text_edit \
--old-text OLD_TEXT \
--new-text NEW_TEXTWrite edited images back to .doc copies:
python3 scripts/ole_image_text_editor.py write-back \
--docs input.doc \
--work work/screenshot_text_editOutputs are written under:
work/screenshot_text_edit/output/
- The script is not a blind one-command solution.
- It only handles equal-length text replacement.
- It is best suited to terminal-like glyph edits.
- UI screenshots often need full-field redraw rather than per-character replacement.
- Some documents require document-specific coordinates or manual visual review.
- Always inspect changed samples before delivery.
Before considering a result complete:
- Backup originals.
- Extract every embedded image format, including PNG and JPEG.
- Apply edits only to intended occurrences.
- Write images back without changing original span lengths.
- Re-extract images from the final
.doc. - OCR the final images for old text, new text, and malformed remnants.
- Inspect visual samples for artifacts.
- Confirm the final document opens or previews correctly.
MIT License. See LICENSE.