Reconstruct non-editable bitmap graphics into high-fidelity, maintainable, further-editable SVG and native PPTX packages.
**Main flow: survey → preparation → assembly → acceptance.**Judge first, then execute. The judgment phase does not touch coordinates or run scripts; it only answers "where does each part come from"; only in the execution phase are tools invoked according to the already-decided route.
Core principles
Every pixel block in the output image can only come from four sources:
- Drawn in SVG — structure, text, formulas
- Cut from the source image ——
crop - AI-generated — region clean-plate background, chroma-key regenerated foreground objects
- Kept as a whole, as-is ——
preserve-raster
Routing is assigning a source to each part, and each part has exactly one. Once assignment is complete, work can begin; an incomplete assignment means something was missed.
Redraw threshold
Only graphics that "can be drawn convincingly with three to five basic primitives" are allowed redraw: plain arrows, boxes, dividers, dots, plus/minus signs, checkmarks, simple node circles. Objects with custom contours, gradients, shadows, multicolor details, or brand or character identity are always treated as assets (cut, regenerated, or flattened), even if they look simple. When in doubt, treat as an asset; do not redraw. The redrawn result must be shape-comparable to the source graphic; if it does not look similar, it is a routing error, not a drawing skill issue.
Working location
All commands run in the user's project directory, with a task directory created for each image (figure-task/work evidence,figure-task/out deliverables), and are never written back to the skill directory. Use forward slashes for Windows paths; verify non-ASCII paths through the filesystem first.
1 Survey
Look once at a sufficiently clear source image and produce areconstruction route summary. This is the only deliverable of this phase, plain text,zero coordinates, within twenty lines, written for humans. Slots are fixed; write "none" for missing items:
图型与分区 每个区域一行:这是什么、底子从哪来
需要生成的 清版底张数 + 色键版张数 = 计费调用总数,或“无”
不可重画的对象 可直接裁的一堆、需再生的一堆,按名字和位置点出来,或“无”
公式 有无、大致数量 → 验证档位
工作量重心 这张图的时间主要花在哪
需要用户定 具体问题,或“无”
Identify objects by name and spatial relationship ("the globe to the right of the title, straddling the panel border"), without writing bbox. Coordinates belong to the preparation phase.
Once the summary is written, the route is locked and not reopened later. If you cannot write the "workload focus", you have not understood the image; if you cannot separate the "non-redrawable objects" into two piles, the contamination scan has not been done.
Image type quick-reference table (look up by region, not by whole image)
| What you see | Where the base comes from | Where the objects inside come from |
|---|---|---|
| Flowcharts, architecture diagrams, paper figures on a white or flat-color background | Drawn in SVG | Draw with generic primitives; proprietary icons are cut or regenerated depending on whether the window is clean |
| Composite images made of multiple stitched panels | Look up each panel separately | Same as above, scan in batches by panel |
| Screenshots, chart bodies, thumbnail grids, whose internals do not need changes | Keep the whole block | Do not decompose |
| Maps, photos, or illustrations overlaid with annotations to be changed | Regional AI clean-up | Those that need to move independently get regenerated; those that do not need to move get flattened into the base layer |
| Posters, covers, scene images, with text overlaid on continuous imagery | AI clean-up | Same as above |
| Formula-dense paper figures | Look up the base according to the rows above | Formulas are always math, verification profiles lock pptx-triggered |
Different regions of one image are checked separately; do not cover the whole image with a single label. When uncertain, go back to the four-source assignment.
Two piles of assets
Objects that cannot pass the regeneration threshold are split into only two piles and scanned in one pass, without going through the process one by one:
- Clean window → cut. Complete outline, no foreign objects around, bounding rectangle does not contain anyone else's pixels.
- Overlapped → borders, text, arrows, connecting lines, or neighbors crossing or covering it. If it needs to move independently, regenerate it; if it does not need to move independently and falls within the clean-up area, flatten it into the base layer. Deterministic SVG areas have no base layer to flatten into; contaminated objects there can only be regenerated.
For detailed criteria see references/routing.md, for element semantics see references/element_decision_matrix.md。
Editing depth and questions
The user's own words take priority: if they say "only text editable", lock text-only(continuous fields are flattened directly); if they name objects, lock selective-assets; if they require everything movable, lock full-extract; when formulas are detected and the user has not stated a preference, default to text+structure and lock pptx-triggered。
**Ask all questions in one go.** After the summary is written, if there are pending items, combine the foreground depth options, generation budget, and PPTX attachment pre-authorization (including when formulas are present) into a single question. Only ask when different choices would significantly change cost or delivery capability; do not ask what you can decide yourself. After obtaining attachment pre-authorization, use --allow-attachdirectly in the acceptance stage, without asking a second time.
**Do not initiate any billable generation calls, and do not crop or composite before user confirmation.** OCR is not included in this; see below.
2 Preparation
Produce the assets according to the sources assigned in the summary. At the beginning, unconditionally run forensics once first — it is not billable, and its output must be used regardless of which path is taken; it can run in parallel with asking questions. For new tasks, use --init to create the directories as well:
python scripts/prepare_measurements.py input.png --init figure-task
Run OCR, style sampling, and structural evidence in one pass (work/geometry.json: panel bbox and colors, slot and font size/color values for each line of text). Canvas size, OCR line count, panel and text slot counts, and the low-confidence text list are printed directly on screen,do not write more code to read these JSONs. Look at work/diagnostics/geometry_overlay.png once for an overall check, do not open each box individually.
**After that, all pixel questions go through measure.py, asked all at once.** Tight bounds, regional colors, four-side clearances, transparent image boundaries, back-calculated font sizes, alignment residuals between two images, and "I want to see what this area looks like" are all its query types. Asking ten questions at once takes the same time as asking one; when done, you get a table of numbers plus an enlarged composite image.Do not hand-write python -c to count pixels, and do not crop images and save them to disk to open and look at yourself.
python scripts/measure.py input.png --exclude-text figure-task/work/ocr_results.json --q "logo:bbox@1850,1600,300,240" "hdr:color@0,0,2400,180" "t1:fontfit@340,881,275,31" "card:zoom@1290,1550,360,300" --sheet figure-task/work/measure_sheet.png
Icon measurements always include --exclude-text. A coarse window will almost always include the adjacent title text; if not excluded, it will be measured as the bounding rectangle of "icon plus title". Measurement results are drawn with red boxes on the composite image, so you can see at a glance whether the measurement was correct.
**Structural evidence is a candidate, not a conclusion, and it does not change routing.** Routes locked during reconnaissance are not overturned just because an overlay is seen. Non-graphic-design images such as photos, illustrations, and posters will be marked abstained: true and only very few candidates are given; this is designed behavior: there was never a panel to find there, and it should be measured manually or handled via clean plate. For the credibility of each candidate, see references/scripts.md。
The following branches are executed according to the summary; they are independent of each other, so parallelize wherever possible.Branches not assigned by the summary are skipped directly—pure SVG images do not run any generation, and pure clean-plate flattened images do not run any cropping.
For deterministic SVG images (white-background flowcharts, architecture diagrams, paper illustrations, no crop and no generation), none of the three branches is entered: preparation is just the evidence-gathering command above plus several measure.py queries, and after running them you go directly to assembly. The time for such images should be measured in minutes.
Has crop assets
Only at this point draw rough boxes for these objects (one-glance precision, 10–20px deviation allowed), and write them into work/inventory.json, containing only objects that go through cropping or regeneration; text boxes come from OCR, structural boxes are determined during assembly, and none of them are included here. The route is already locked, so drawing boxes is an execution action.
python scripts/snap_boxes.py input.png --inventory figure-task/work/inventory.json --exclude-text figure-task/work/ocr_results.json --out figure-task/work/snap_report.json --sheet figure-task/work/snap_sheet.png
Look once at the snap_sheet.png overview. Write the judgment into each asset's crop_window, and manually recheck only the items named by the script:contaminated change the route (switch to regeneration or flattening),snap-failed, those with warnings, and those the summary names as unclear should be locally magnified using inspect_regions.py . Three-value semantics—clean window margin is the canvas background color;clean-on-fill margin is a single uniform solid color with clearance on all four sides, and the manifest redraws the carrier surface with the same color;contaminated must not continue to be cropped.quality_audit.py post hoc verification is the fallback. Image cropping is performed by crop_assets.py during assembly.
Has clean-plate regions
prepare_clean_plate_mask.py prepare a mask, generate a region base plate,check_plate_registration.py verify registration (scale ≈ 1.00 / offset ≈ 0). The base plate must be an edit of the source region—remove the foreground to be reconstructed and inpaint the pixels behind it, keeping everything else aligned and identity-consistent, not a new scene. For details, see references/background_reconstruction.md and references/image_generation.md。
Has regeneration objects
probe_palette.py --boxes determine key colors and sheet count, generate a chroma-key version,chroma_key.py cut out,slice_grid.py split. Merge all candidates onto as few sheets as possible, generate repeated elements only once, and place them in multiple positions by shared id. For details, see references/chroma_regeneration.md. Improvised substitutes such as rembg, GrabCut, and threshold matting are prohibited.
If no image backend is available or the base plate is unqualified, stop and report; do not silently degrade.
**Generation is the long pole; do not wait idly.** Immediately after the call is issued, advance the text list, connectors, and manifest draft in parallel.
3 Assembly
Required reading references/manifest_spec.md、references/svg_authoring.md、references/quality_checklist.md, for script interfaces see references/scripts.md, and load the rest according to the route (each file has applicable notes at the beginning). Formula-dense images require reading references/formula-reconstruction.md. Record the reconnaissance conclusions into the manifest top-level reconstruction_plan, write text retype, formula split math, structure redraw, and place assets according to the preparation results in decision and crop_window。
The first version may be written out with a one-off generator, and this is a legitimate approach when there are many elements. After the generator finishes writing the manifest to disk, immediately rename it *.py.retired and exit; all subsequent modifications must go through manifest_edit.py—leaving the generator around will overwrite manual fixes.
Text and panels can first adopt the draft and then be modified; this is faster than writing from scratch:
python scripts/draft_elements.py figure-task/work/geometry.json --out figure-task/work/draft_elements.json
python scripts/manifest_edit.py manifest.json --adopt figure-task/work/draft_elements.json
python scripts/compose_svg_package.py manifest.json --out figure-task/out --stage svg
**Adoption means responsibility; after adoption you must immediately compose once and look at the difference heatmap.** This is the only review path: reading draft JSON item by item is slower than writing by hand, while looking at a composite image makes the wrong places surface on their own. The draft's font_size and fill are estimates, rely on fit_text.py When converging with visual comparison, it must be changed just like handwritten values. After review, clear provenance or set review_status, otherwise the quality gate will block it.
Fixes go through the batch channel; do not hand-edit large JSON or write temporary patch scripts:
python scripts/manifest_edit.py manifest.json --apply-snap figure-task/work/snap_report.json
python scripts/manifest_edit.py manifest.json --set "label-3,label-4:y+=4" --apply-fit figure-task/work/fit_report.json
python scripts/manifest_edit.py manifest.json --patch figure-task/work/patch.json
Collect all warnings, fix a batch, then compose again. After the SVG is frozen, --stage pptx export, only supplement metadata with --stage package。
4 Acceptance
compose prints the difference work order every time— sorted by error, named down to the element id, with the defect type attached (position off, font size too large, color mismatch, not drawn at all), plus a diagnostics/fix_sheet.png that puts the twelve elements with the largest errors into a top-and-bottom comparison of source image/finished product.
Fix according to the work order; do not compare block by block yourself to find differences again. One round is the three steps of "look at the work order and comparison image → modify manifest → rerun compose".
Each round, look at preview.png and each report; after a report names something, only recheck the affected area. At the end, look at the overall SVG at least once.
- Tier 0 /
svg-primary: nomathandpptx_text_fit.pyno line break, overflow, missing character, misalignment reports. The SVG is the acceptance; do not open PowerPoint. - Tier 1 /
pptx-triggered: containsmathor the static audit reports structural risk. Before delivery, render natively once, checking only for formulas out of slot, unexpected line breaks, content truncation, element misalignment. - Tier 2: Tier 1 found structural defects; after batch fixing, render at most once more; if problems remain, write them into the delivery notes and do not loop endlessly.
Not counted as defects: anti-aliasing, stroke thickness, punctuation subpixel differences, baseline ±1px, letter spacing ±0.5px, overall color management differences. Counted as defects: missing content, line break changes, overflow, formulas out of slot, element misalignment over 3px.
Attach a reconstruction path summary to the delivery notes, and explain whether actual execution matches the summary and the reasons for any mismatch.
PowerPoint Safety Rules
PPTX native rendering can only call python scripts/render_pptx.py figure-task/out/editable.pptx --out figure-task/out/pptx_render。
- Handwriting is prohibited
PowerPoint.Applicationautomation; attached-state calls toQuit()are prohibited;taskkill /IM POWERPNT.EXE、Stop-Process POWERPNT。 - When it detects that the user is using PowerPoint, the script refuses by default; only with user consent (including pre-authorization during reconnaissance) add
--allow-attach。 - Attached state only closes Presentations that it opened read-only itself. When native rendering in the requirements is not completed, write "native rendering deferred" in the delivery notes, and do not falsely claim completion.
Output package
editable.svg、editable_embedded.svg、editable.pptx、preview.png、manifest.json、contact_sheet.png(when there is material),quality_report.md、editability_report.md、assets/、diagnostics/、timings.json. PPTX semantic-level top-level ungrouping: text, shapes, connectors, and materials can be directly selected; formulas, masks, rotation, etc. remain grouped as needed for fidelity.
Authority and Responsibilities
| Concern | Sole authority |
|---|---|
| Four stages, four sources, redraw threshold, verification tiers, PowerPoint safety | This SKILL.md |
reconnaissance protocol, path summary slots,reconstruction_plan |
references/routing.md |
manifest fields,reconstruction_mode vocabulary |
references/manifest_spec.md |
| Background, foreground depth, text layer strategy | references/background_reconstruction.md |
| Element semantics, redraw or preserve material | references/element_decision_matrix.md |
| crop execution semantics, contaminated material recovery | references/asset_extraction.md |
| chroma regeneration | references/chroma_regeneration.md |
| Generate brief and image backend | references/image_generation.md |
| Formula reconstruction and editability | references/formula-reconstruction.md |
| Script interface and candidate credibility | references/scripts.md |
| Final release conditions, fix priority | references/quality_checklist.md |
Entry script
| Stage | Script |
|---|---|
| End-to-end | measure.py — the single entry point for all pixel issues, batch questions |
| Preparation·Evidence | prepare_measurements.py(including --init scaffolding),probe_geometry.py |
| Preparation·Cropping | snap_boxes.py、inspect_regions.py、crop_assets.py |
| Preparation·Generation | prepare_clean_plate_mask.py、generate_clean_plate.py、check_plate_registration.py、probe_palette.py、chroma_key.py、slice_grid.py |
| Assembly | draft_elements.py、manifest_edit.py、compose_svg_package.py |
| Acceptance | fit_text.py、pptx_text_fit.py、render_pptx.py; differential work order fix_worklist.py is run automatically by compose |
| Audit | validate_manifest.py、quality_audit.py、audit_editability.py |
For command line, input/output formats, and notes, see references/scripts.md. Out-of-table scripts are compose_svg_package.py called internally and are not run directly.
Quality baseline
Preserve all important information, reading relationships, and proprietary visuals of the source image; ordinary text and every detected formula remain editable; no detection noise, formula text leakage, dirty cropping, source image patch collage, or silent route degradation. For complete release conditions, see references/quality_checklist.md。