Manuscript Scan Orient Crop
Use this skill for batch cleanup of manuscript/book scan folders like numbered subfolders 1 to 22 containing Image_00001.jpg style scans.
Workflow
- Preserve originals. Never overwrite the source folder. Write processed files to a sibling folder, usually
<source>_处理后or<source>_processed. - Inspect before processing. Count folders/files, group by extension, and create a small contact sheet comparing sample originals and processed outputs. Use
00007-style user-provided examples as the ground truth for correct orientation. - Determine rotation policy.
- Default for this collection style: odd pages remain as scanned; even pages rotate 180 degrees.
- If the user says a folder is wrong, re-check that folder only. Do not assume all folders share the same exception.
- If the user gives a sample such as "00007is correct; top blank margin is larger than bottom blank margin", use that visual rule to validate adjacent pages before applying changes. - Crop after orientation. Crop to the book/page/manuscript surface, not the entire scan bed. Remove black background, labels, paper scraps, and obvious foreign objects where possible. Keep a small safety margin so page edges are not cut off.
- Validate. Confirm source and output file counts match for every subfolder. Generate a contact sheet for visual QA. Run an abnormal-size scan and inspect outliers before declaring done.
- Iterate narrowly. If a folder is reported wrong, reprocess that folder only and update the log for those files.
Reusable Script
Use scripts/process_manuscript_scans.py for the batch operation. It requires Python packages:
python -m pip install pillow opencv-python numpy
Typical run from the scan root:
python C:\Users\64533\.codex\skills\manuscript-scan-orient-crop\scripts\process_manuscript_scans.py --root . --rotate-policy even
Useful options:
--root <path>: source folder containing numbered subfolders.--output <path>: output folder. Default is sibling<root>_处理后.--folders 1 2 3: process only selected subfolders.--rotate-policy even|none: rotate even-numbered files 180 degrees, or rotate none.--preview-only: create contact sheets without writing processed output.--contact-sheet: write a visual QA contact sheet after processing.
For a folder-specific correction like “only folder 1, make it like 00007”, run only that folder with the chosen policy:
python C:\Users\64533\.codex\skills\manuscript-scan-orient-crop\scripts\process_manuscript_scans.py --root . --folders 1 --rotate-policy even --contact-sheet
QA Checklist
After processing, report:
- Output folder path.
- Total processed JPG count.
- Per-folder source/output count mismatch count.
- Error log status, if any.
- Contact sheet path.
- Any files manually inspected or left unchanged because they were already correct.
Keep temporary contact sheets only if they help the user verify the result; remove noisy test artifacts.