@dickpy/dsh-oil-slide 0.0.0-stage → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +89 -2
- package/bundled-assets/brand/empty-deck-cobalt.webp +0 -0
- package/bundled-assets/brand/oil-slide-mark-512.png +0 -0
- package/bundled-assets/skill/LICENSE +21 -0
- package/bundled-assets/skill/README.md +61 -0
- package/bundled-assets/skill/SKILL.md +185 -0
- package/bundled-assets/skill/references/art-directions.md +99 -0
- package/bundled-assets/skill/references/brand-and-canvas.md +72 -0
- package/bundled-assets/skill/references/design-baseline.txt +1 -0
- package/bundled-assets/skill/references/prompt-compiler.md +99 -0
- package/bundled-assets/skill/references/restore-and-pptx.md +178 -0
- package/bundled-assets/skill/references/staged-pptx.md +71 -0
- package/bundled-assets/skill/scripts/_runtime_utils.py +351 -0
- package/bundled-assets/skill/scripts/asset_sheet.py +528 -0
- package/bundled-assets/skill/scripts/brand_ref.py +776 -0
- package/bundled-assets/skill/scripts/crop_asset.py +1709 -0
- package/bundled-assets/skill/scripts/deck_shell.py +2322 -0
- package/bundled-assets/skill/scripts/export_images.py +280 -0
- package/bundled-assets/skill/scripts/extract_pptx.py +360 -0
- package/bundled-assets/skill/scripts/extract_slide_dom.js +1640 -0
- package/bundled-assets/skill/scripts/html_to_pptx.py +4042 -0
- package/bundled-assets/skill/scripts/measure_slide_layout.py +952 -0
- package/bundled-assets/skill/scripts/oiloil-connect.mjs +1493 -0
- package/bundled-assets/skill/scripts/oiloil-image.mjs +492 -0
- package/bundled-assets/skill/scripts/prepare_plate.py +412 -0
- package/bundled-assets/skill/scripts/render_gradient.py +258 -0
- package/bundled-assets/skill/scripts/slide_brand.py +111 -0
- package/bundled-assets/skill/scripts/slide_incremental.py +122 -0
- package/bundled-assets/skill/scripts/slide_workflow.py +711 -0
- package/bundled-assets/skill/scripts/verify_deck.py +3483 -0
- package/bundled-assets/skill/vendor/README.md +4 -0
- package/bundled-assets/skill/vendor/codex-ppt/LICENSE +21 -0
- package/bundled-assets/skill/vendor/codex-ppt/assemble_ppt.py +435 -0
- package/bundled-assets/skill/vendor/codex-ppt/codex_ppt_runtime.py +284 -0
- package/bundled-assets/skill/vendor/codex-ppt/image_gen.py +972 -0
- package/bundled-assets/skill/vendor/codex-ppt/image_providers/__init__.py +6 -0
- package/bundled-assets/skill/vendor/codex-ppt/image_providers/atlascloud.py +222 -0
- package/bundled-assets/skill/vendor/codex-ppt/image_providers/base.py +32 -0
- package/bundled-assets/skill/vendor/codex-ppt/image_providers/factory.py +21 -0
- package/bundled-assets/skill/vendor/codex-ppt/image_providers/openai_compatible.py +238 -0
- package/bundled-assets/skill/vendor/codex-ppt/requirements.txt +5 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//345/205/232/346/224/277/347/272/242/351/243/216/346/240/274.md +98 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//345/210/233/346/204/217/346/235/202/345/277/227/351/243/216.md +72 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//345/244/215/345/217/244/346/211/201/345/271/263/346/217/222/347/224/273/351/243/216.md +72 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//346/211/213/347/273/230/346/212/200/346/234/257/350/247/243/351/207/212/351/243/216.md +86 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//346/211/213/347/273/230/347/231/275/346/235/277/351/243/216.md +72 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//346/225/231/345/255/246/350/257/276/344/273/266/351/243/216.md +107 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//346/225/260/346/215/256/344/273/252/350/241/250/347/233/230/351/243/216.md +73 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//346/270/205/347/210/275/344/270/223/344/270/232/351/243/216.md +87 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//346/270/251/346/232/226/346/211/213/345/267/245/351/243/216.md +72 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//347/224/265/345/255/220/345/242/250/346/260/264/346/235/202/345/277/227/351/243/216.md +86 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//347/247/221/347/240/224/347/255/224/350/276/251/351/243/216.md +138 -0
- package/bundled-assets/skill/vendor/codex-ppt/styles//351/272/246/350/202/257/351/224/241/351/243/216/346/240/274.md +119 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/LICENSE +21 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/SKILL.md +171 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/agents/openai.yaml +4 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/__init__.py +1 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/cli.py +25 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/__init__.py +1 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/_input_normalization.py +355 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/_page_artifacts.py +132 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/build_pptx_from_manifest.py +1029 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/configure_image_backend.py +52 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/deck_run_state.py +214 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/deck_text_hints.py +179 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/finalize_deck_run.py +96 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/formula_renderer.py +254 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/image_gen.py +206 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/main.py +795 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/make_page_contact_sheet.py +28 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/native_tables.py +140 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/paddle_text_hints.py +212 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/page_job_status.py +54 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/page_text_metrics.py +334 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/path_geometry.py +174 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/prepare_deck_run.py +209 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/process_asset_sheet.py +104 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/record_imagegen_result.py +118 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/record_page_dispatch.py +83 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/record_page_result.py +130 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/remove_chroma_key.py +441 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/reset_page_job.py +74 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/runtime_env.py +283 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/split_alpha_components.py +323 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/text_hints.py +309 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/editppt/runtime/validate_pptx.py +873 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/cli/pyproject.toml +29 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/prompts/page-worker.md +47 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/references/cli-helper.md +282 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/references/manifest-schema.md +423 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/references/page-decision-tree.md +301 -0
- package/bundled-assets/skill/vendor/image-to-editable-ppt/scripts/build-page-worker-prompt.py +134 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +11282 -0
- package/lib/index.js +2638 -0
- package/package.json +140 -4
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: image-to-editable-ppt
|
|
3
|
+
description: Rebuild slide images, scanned or image-based PPT/PPTX files, and PDF decks into object-level editable PowerPoint (.pptx), preserving speaker notes when supplied. Use for making visual slides editable or reconstructing slides from screenshots; not for authoring new presentations from scratch.
|
|
4
|
+
---
|
|
5
|
+
# Image to Editable PPT
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Use the `editppt` runtime to decompose, reconstruct, validate, and assemble visual slides as editable `.pptx`. Inputs may be single or multiple images, PDF, or image-based PPT/PPTX.
|
|
10
|
+
|
|
11
|
+
## References
|
|
12
|
+
|
|
13
|
+
Each rule in this skill has exactly one authoritative home; the other files point to it instead of restating it.
|
|
14
|
+
|
|
15
|
+
- `prompts/page-worker.md`: execution template for page workers — ownership boundary, execution order, required outputs, and return format. The parent agent uses it when generating page-worker prompts.
|
|
16
|
+
- `scripts/build-page-worker-prompt.py`: skill-local prompt builder. It reads `prompts/page-worker.md`, fills run/page paths, writes `worker-prompt.md`, and prints the dispatch command template.
|
|
17
|
+
- `references/cli-helper.md`: CLI install check (Pre-Run Check), command tree, and command syntax examples. Read it when deciding which `editppt` command to call.
|
|
18
|
+
- `references/manifest-schema.md`: the single home for JSON field contracts of deck/page/image artifacts — required manifest fields, positioned-object coordinates, `validation.json`, and `page_result.json` shapes. Read it when writing or validating any run/page file.
|
|
19
|
+
- `references/page-decision-tree.md`: the single source of truth for page object decisions — background handling, foreground asset separation, native shapes, formulas, text-hints usage, the final self-check, and the fix-versus-warning split. Read its common decision boundaries first, then the sections relevant to the page inventory; the page prompt provides the reading route.
|
|
20
|
+
|
|
21
|
+
## Entry Contract
|
|
22
|
+
|
|
23
|
+
These parent-level rules are stated once here; page-level rules live in the references above and are not restated in this file.
|
|
24
|
+
|
|
25
|
+
- The `editppt` CLI is a required runtime surface. If `editppt --help` fails, install it first by following the Pre-Run Check in `references/cli-helper.md` before doing anything else.
|
|
26
|
+
- First run `editppt prepare <input...>` to create a run directory. After that, all key state transitions are advanced only through `editppt` commands; never hand-write run/page state JSON. This keeps run state deterministic and resumable.
|
|
27
|
+
- For Oil Slide's `prepare --serial-local` runs, the current agent reconstructs one page at a time, for any deck length. For other multi-page runs, dispatch page workers. A one-page run uses the local reconstructor.
|
|
28
|
+
- Only the assigned reconstructor may write a page's reconstruction artifacts. In local mode, claim the page with `run dispatch --local`, follow its generated prompt, validate and record, then repeat. After interruption, use `run status` to identify and resume an existing local claim.
|
|
29
|
+
- All image generation, image editing, background repair, transparent bitmap assets, and asset sheets follow the serial per-page backend order in "Image Backend Selection" below.
|
|
30
|
+
- A user request to convert visual slides into editable PPT authorizes the required OCR and image-backend calls for that conversion, unless the user explicitly requests local-only processing or marks the input as confidential/no-external-processing. Do not refuse solely because the workflow calls configured OCR or the user-configured image API; those calls are necessary to the skill.
|
|
31
|
+
- Only send task-local page images, prompts, masks, and reference images required for the current conversion. Never send unrelated local files, API keys, auth tokens, credentials, or generated artifacts that are not needed by the current OCR/image operation. Third-party API endpoints are allowed only when already configured by the user or explicitly specified for this run.
|
|
32
|
+
- In network-restricted environments, request any approval required by the current runtime before external OCR/image calls, including `editppt prepare` or `editppt run hints` when `PADDLE_OCR_TOKEN` is set and every CLI fallback `editppt image generate/edit` call. The approval justification must say this is a user-requested `image-to-editable-ppt` conversion, that the upload is limited to task-local page images/prompts/masks/references, and that OCR/image-backend calls are part of this skill's required workflow. Do not present the required call as unsafe or ask the user to re-approve it unless they requested local-only/confidential handling or the approval system explicitly rejects the request.
|
|
33
|
+
- Execute routine reconstruction, configured image calls, and local repairs autonomously. Do not add confirmation gates; retain the OCR choices in Phase 1 and any approval required by the runtime. A missing prerequisite that only the user can supply is a concrete blocker, not a request to debug the workflow.
|
|
34
|
+
- All page object decisions follow `references/page-decision-tree.md`, including its no-fallback rule for foreground visual objects and its rule that deterministic validation is a structure gate that never waives an object-source decision.
|
|
35
|
+
- `manifest.json` is the authoritative page build source: `editppt run record` validates `page.pptx` against it, and `editppt run finalize` rebuilds the final deck from recorded page manifests. Required fields and coordinate contracts are defined in `references/manifest-schema.md`.
|
|
36
|
+
- `editppt prepare` writes per-page text measurements (`text_hints.json`/`text_hints.png`). How page reconstructors consume them is defined in `references/page-decision-tree.md` section 3.1.
|
|
37
|
+
- Page reconstructors — either page workers or the parent agent in local mode — are driven by prompts generated from `prompts/page-worker.md`.
|
|
38
|
+
|
|
39
|
+
### Image Backend Selection
|
|
40
|
+
|
|
41
|
+
Run `editppt image generate/edit` for image assets with the Oil Slide image channel. Open the sidebar’s 生图设置 to configure the channel. Use `editppt image import --backend openai-compatible-api` for its results. The CLI tries user-configured backup models in order when the default is unavailable. Keep the current page pending if all configured models fail.
|
|
42
|
+
|
|
43
|
+
## Roles
|
|
44
|
+
|
|
45
|
+
The parent owns orchestration and user interaction under the Entry Contract and Workflow below. Report progress, the final PPTX path, and validation results. Do not repeat completed page-level visual QA; `record` and `finalize` enforce their deterministic handoff checks.
|
|
46
|
+
|
|
47
|
+
Each page reconstructor owns exactly one `pages/page_NNN/` directory. Its full contract — ownership boundary, decision order, required outputs, and return format — is the prompt generated from `prompts/page-worker.md`; the rules it follows live in `references/page-decision-tree.md` and `references/manifest-schema.md`.
|
|
48
|
+
|
|
49
|
+
## Workflow
|
|
50
|
+
|
|
51
|
+
### Phase 1: Prepare
|
|
52
|
+
|
|
53
|
+
Read the prepare examples in `references/cli-helper.md` and the run/page file descriptions in `references/manifest-schema.md`.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
editppt prepare <input...>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
After this completes, there must be a run directory, `deck_manifest.json`, `page_jobs.json`, `notes_manifest.json`, and each page must have `source.png` plus `page_request.json`.
|
|
60
|
+
|
|
61
|
+
Prepare also writes per-page text hints. Whenever `editppt doctor` or prepare reports that no PaddleOCR token is configured (offline fallback), ask the user once before dispatching any page: a free token from https://aistudio.baidu.com/account/accessToken stored via `editppt config --paddle-ocr-token <token>` makes the hints content-aware and noticeably improves text fidelity, and `editppt run hints <run>` regenerates the current run's hints in place. Tell the user the free personal quota is currently more than enough for this skill — applying is risk-free with no extra cost. Wait for their choice; if they decline or want to proceed, continue with the offline hints and do not ask again.
|
|
62
|
+
|
|
63
|
+
If a PaddleOCR token is already configured but `prepare` falls back because network access, DNS, or sandbox approval blocked the OCR request, that fallback is not the preferred quality path. Request network approval with the justification described in the Entry Contract and rerun `editppt run hints <run>` before page reconstruction. If the approval system rejects the OCR request, ask the user for explicit authorization before continuing: explain that PaddleOCR is used to correct text boxes, font sizes, and size groups, and that using it makes reconstructed PPT text sizing much more stable. Continue with `builtin-ink` only after the user declines OCR, after an approved OCR attempt fails for a real service/tool reason, or when the user asked for local-only/confidential handling.
|
|
64
|
+
|
|
65
|
+
### Phase 2: Rebuild Or Dispatch Pages
|
|
66
|
+
|
|
67
|
+
Read the run/dispatch examples in `references/cli-helper.md` and call repeatedly:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
editppt run next <run>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
When `stage=rebuild_page_locally` is returned, the run is single-page or serial-local. The parent agent must claim local execution before writing page artifacts:
|
|
74
|
+
|
|
75
|
+
1. `python3 <skill-root>/scripts/build-page-worker-prompt.py <run> --page <page_id> --out <absolute-run-dir>/pages/<page_id>/worker-prompt.md`
|
|
76
|
+
2. `editppt run dispatch <run> --page <page_id> --agent-id main --prompt-file <absolute-run-dir>/pages/<page_id>/worker-prompt.md --local`
|
|
77
|
+
3. Read the generated prompt and rebuild the page inside that page directory yourself, producing the same required outputs a page worker would produce.
|
|
78
|
+
|
|
79
|
+
When `stage=dispatch_pages` is returned, the following steps are mandatory for each suggested page:
|
|
80
|
+
|
|
81
|
+
1. `python3 <skill-root>/scripts/build-page-worker-prompt.py <run> --page <page_id> --out <absolute-run-dir>/pages/<page_id>/worker-prompt.md`
|
|
82
|
+
2. Spawn a page worker using the current environment's available subagent/multi-agent tool.
|
|
83
|
+
3. `editppt run dispatch <run> --page <page_id> --agent-id <id> --prompt-file <absolute-run-dir>/pages/<page_id>/worker-prompt.md`
|
|
84
|
+
|
|
85
|
+
`--out` and `--prompt-file` must be absolute paths to avoid the page directory being prepended again to relative paths. The prompt builder only writes the prompt and prints a dispatch command template; it does not create the worker, so run `editppt run dispatch` only after a real spawn succeeds.
|
|
86
|
+
|
|
87
|
+
Concurrency slots come from `page_jobs.json.max_concurrent_pages` (default 6). In the normal flow prefer `editppt run next`; `editppt run status` is only for debugging or manual inspection.
|
|
88
|
+
|
|
89
|
+
Dispatched page executions are active leases, not idle slots. When `editppt run next` returns `stage=wait`, wait for dispatched workers or inspect status without modifying state. Do not terminate, archive, reset, or replace a page worker because it is slow, has not sent recent messages, or still occupies a concurrency slot; complex pages may legitimately run for a long time.
|
|
90
|
+
|
|
91
|
+
### Phase 3: Record
|
|
92
|
+
|
|
93
|
+
Read the record examples in `references/cli-helper.md` and the `page_result.json` description in `references/manifest-schema.md`.
|
|
94
|
+
|
|
95
|
+
After a worker returns, run:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
editppt run record <run> --page <page_id> --agent-id <id>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This command validates `page.pptx` against `manifest.json` before recording. It fails if positioned objects are missing source-pixel coordinates, if the manifest cannot independently rebuild the page, or if `validation.json` does not contain top-level `passed: true` — a failed page is never recorded.
|
|
102
|
+
|
|
103
|
+
For a rejected record or page-local validation issue, read the failure evidence and have the current page owner repair only the affected artifacts, then refresh the validation report using the page validation example in `references/cli-helper.md` and record again. In local mode the parent is that owner; in worker mode send the repair to the existing worker. Do not reset a reachable owner merely because validation failed, and do not regenerate compliant assets to fix an unrelated manifest or table error.
|
|
104
|
+
|
|
105
|
+
Reset is for a page that needs a replacement execution: explicit terminal-state evidence (`terminated`, `failed`, `archived`, or `not found`), user cancellation, or repeated failed reachability checks with no page-local progress. A long-running worker is not lost. After fixing the prerequisite that prevented execution, use:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
editppt run reset <run> --page <page_id> --agent-id <id> --confirm-lost
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For recorded pages, `editppt run reset <run> --page <page_id>` is allowed. For dispatched pages, the matching agent id and `--confirm-lost` protect the active lease. Reset returns the page to `pending`; resume through Phase 2 with a new prompt and execution. Keep existing artifacts for provenance checks and selective reuse under the page prompt's recovery contract. Never hand-edit state or rebuild a page assigned to another owner.
|
|
112
|
+
|
|
113
|
+
Retry only after changing the relevant input or condition. Diagnose repeated failures from validation and command evidence; do not repeat an unchanged failing tool call or re-dispatch under identical conditions. If a real prerequisite is unavailable, preserve progress and report the concrete blocker instead of fabricating success or asking the user to debug. Once the current outputs pass their required checks, advance to finalize; do not repeat unchanged visual QA.
|
|
114
|
+
|
|
115
|
+
### Phase 4: Finalize
|
|
116
|
+
|
|
117
|
+
Read the finalize examples in `references/cli-helper.md`.
|
|
118
|
+
|
|
119
|
+
When `editppt run next <run>` returns the finalize stage:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
editppt run finalize <run>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`finalize` treats each recorded `pages/page_NNN/manifest.json` as the authoritative source: it rebuilds the final deck from page manifests in page order, then validates the resulting PPTX. `page.pptx` remains a page-level deliverability artifact for record-time checks.
|
|
126
|
+
|
|
127
|
+
Deck-level structural QA at this stage:
|
|
128
|
+
|
|
129
|
+
- The PPTX is a valid zip/package.
|
|
130
|
+
- Slide count matches the input page count.
|
|
131
|
+
- PDF/PPTX page mapping is correct.
|
|
132
|
+
- Media relationships are complete.
|
|
133
|
+
- All asset files referenced by the manifests exist.
|
|
134
|
+
- Media hashes match manifest provenance.
|
|
135
|
+
- Speaker notes hashes match.
|
|
136
|
+
- There is no invalid full-slide source raster plus editable text overlay pattern.
|
|
137
|
+
|
|
138
|
+
The final reply must report the final PPTX path and validation result.
|
|
139
|
+
|
|
140
|
+
## State Principles
|
|
141
|
+
|
|
142
|
+
Agents continue only from file facts and `editppt run next`. Required states:
|
|
143
|
+
|
|
144
|
+
- `pending`: created by `editppt prepare`; restored by `editppt run reset` when a page must be re-dispatched.
|
|
145
|
+
- `dispatched`: `editppt run dispatch` records a real spawned worker or a `--local` main-agent claim. This status is an active lease and must not be reset or replaced just because the worker is slow.
|
|
146
|
+
- `recorded`: `editppt run record` validates required outputs and writes the result; only deliverable pages (`validation.json` top-level `passed: true`) reach this state.
|
|
147
|
+
- `accepted` / `complete`: written by `editppt run finalize`.
|
|
148
|
+
|
|
149
|
+
`imagegen-jobs.json` is the page-local provenance/job record. Only these forced file states are kept:
|
|
150
|
+
|
|
151
|
+
- `recorded`: `editppt image import` has copied the selected output and written hash/metadata.
|
|
152
|
+
- `processed`: `editppt image process-sheet` has completed background removal and splitting.
|
|
153
|
+
|
|
154
|
+
## Delivery Principles
|
|
155
|
+
|
|
156
|
+
- Each page is self-checked once by the page reconstructor; the evidence is written into structured fields in `manifest.json` and into `validation.json`.
|
|
157
|
+
- The final output must be a currently openable, structurally valid `.pptx`. A full-slide `source.png` with editable text overlaid on top is not an acceptable fallback.
|
|
158
|
+
- Whether an imperfection must be fixed inside its page or may ship as a recorded warning is governed by the "Fix versus Warning" section of `references/page-decision-tree.md`. A warning may never replace a missing required workflow step.
|
|
159
|
+
|
|
160
|
+
## Updating This Skill
|
|
161
|
+
|
|
162
|
+
Reinstall through the installation channel, refresh the CLI from the updated skill directory, then restart the agent session and verify:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npx -y skills@latest add ningzimu/image-to-editable-ppt-skill \
|
|
166
|
+
--skill image-to-editable-ppt \
|
|
167
|
+
--agent <agent-id> \
|
|
168
|
+
--global
|
|
169
|
+
pipx install --force --editable <skill-root>/cli
|
|
170
|
+
editppt doctor
|
|
171
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import runpy
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> None:
|
|
10
|
+
command_name = Path(sys.argv[0]).name or "editppt"
|
|
11
|
+
if command_name in {"cli.py", "__main__.py"}:
|
|
12
|
+
command_name = "editppt"
|
|
13
|
+
runtime_dir = Path(__file__).resolve().parent / "runtime"
|
|
14
|
+
script = runtime_dir / "main.py"
|
|
15
|
+
if not script.exists():
|
|
16
|
+
raise RuntimeError(f"runtime entrypoint not found: {script}")
|
|
17
|
+
|
|
18
|
+
os.environ.setdefault("IMAGE_TO_EDITABLE_PPT_CLI_PROG", command_name)
|
|
19
|
+
sys.path.insert(0, str(runtime_dir))
|
|
20
|
+
sys.argv = [command_name, *sys.argv[1:]]
|
|
21
|
+
runpy.run_path(str(script), run_name="__main__")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Deterministic runtime modules behind the public editppt CLI."""
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import io
|
|
3
|
+
import json
|
|
4
|
+
import posixpath
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
import tempfile
|
|
8
|
+
import zipfile
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from xml.etree import ElementTree as ET
|
|
12
|
+
|
|
13
|
+
from PIL import Image
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
IMG_EXTS = {".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif", ".tif", ".tiff"}
|
|
17
|
+
PPT_EXTS = {".ppt", ".pptx"}
|
|
18
|
+
REL_NS = "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
19
|
+
NS = {
|
|
20
|
+
"a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
21
|
+
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
22
|
+
"r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
23
|
+
"rel": REL_NS,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def sha256_text(value):
|
|
28
|
+
return hashlib.sha256(value.encode("utf-8")).hexdigest()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def collect_paragraph_text(root):
|
|
32
|
+
paragraphs = []
|
|
33
|
+
for paragraph in root.findall(".//a:p", NS):
|
|
34
|
+
text = "".join(node.text or "" for node in paragraph.findall(".//a:t", NS))
|
|
35
|
+
if text:
|
|
36
|
+
paragraphs.append(text)
|
|
37
|
+
return "\n".join(paragraphs)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def copy_input(src, input_dir):
|
|
41
|
+
src = Path(src).resolve()
|
|
42
|
+
dest = input_dir / src.name
|
|
43
|
+
counter = 2
|
|
44
|
+
while dest.exists() and dest.resolve() != src:
|
|
45
|
+
dest = input_dir / f"{src.stem}-{counter}{src.suffix}"
|
|
46
|
+
counter += 1
|
|
47
|
+
if src != dest:
|
|
48
|
+
shutil.copy2(src, dest)
|
|
49
|
+
return dest
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def save_image_page(src, page_dir):
|
|
53
|
+
page_dir.mkdir(parents=True, exist_ok=True)
|
|
54
|
+
out = page_dir / "source.png"
|
|
55
|
+
with Image.open(src) as image:
|
|
56
|
+
image.convert("RGB").save(out)
|
|
57
|
+
return out
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def render_pdf_pages(pdf_path, pages_dir, dpi):
|
|
61
|
+
import fitz
|
|
62
|
+
|
|
63
|
+
doc = fitz.open(pdf_path)
|
|
64
|
+
outputs = []
|
|
65
|
+
matrix = fitz.Matrix(dpi / 72, dpi / 72)
|
|
66
|
+
for index, page in enumerate(doc, start=1):
|
|
67
|
+
page_dir = pages_dir / f"page_{index:03d}"
|
|
68
|
+
page_dir.mkdir(parents=True, exist_ok=True)
|
|
69
|
+
pix = page.get_pixmap(matrix=matrix, alpha=False)
|
|
70
|
+
out = page_dir / "source.png"
|
|
71
|
+
pix.save(out)
|
|
72
|
+
outputs.append(out)
|
|
73
|
+
return outputs
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def rel_source_part(rels_name):
|
|
77
|
+
directory = posixpath.dirname(rels_name)
|
|
78
|
+
if directory.endswith("/_rels"):
|
|
79
|
+
directory = posixpath.dirname(directory)
|
|
80
|
+
source = posixpath.basename(rels_name)[:-5]
|
|
81
|
+
return posixpath.normpath(posixpath.join(directory, source))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def resolve_target(rels_name, target):
|
|
85
|
+
source = rel_source_part(rels_name)
|
|
86
|
+
return posixpath.normpath(posixpath.join(posixpath.dirname(source), target))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def collect_notes_from_pptx(pptx_path, notes_dir=None):
|
|
90
|
+
notes = []
|
|
91
|
+
if notes_dir:
|
|
92
|
+
notes_dir = Path(notes_dir)
|
|
93
|
+
with zipfile.ZipFile(pptx_path) as z:
|
|
94
|
+
names = set(z.namelist())
|
|
95
|
+
if "ppt/presentation.xml" not in names or "ppt/_rels/presentation.xml.rels" not in names:
|
|
96
|
+
return notes
|
|
97
|
+
pres = ET.fromstring(z.read("ppt/presentation.xml"))
|
|
98
|
+
pres_rels = ET.fromstring(z.read("ppt/_rels/presentation.xml.rels"))
|
|
99
|
+
rels_by_id = {rel.attrib.get("Id"): rel.attrib.get("Target") for rel in pres_rels.findall("rel:Relationship", NS)}
|
|
100
|
+
slide_parts = []
|
|
101
|
+
for sld_id in pres.findall(".//p:sldId", NS):
|
|
102
|
+
rel_id = sld_id.attrib.get(f"{{{NS['r']}}}id")
|
|
103
|
+
target = rels_by_id.get(rel_id)
|
|
104
|
+
if target:
|
|
105
|
+
slide_parts.append(posixpath.normpath(posixpath.join("ppt", target)))
|
|
106
|
+
for page_index, slide_part in enumerate(slide_parts, start=1):
|
|
107
|
+
rels_name = f"{posixpath.dirname(slide_part)}/_rels/{posixpath.basename(slide_part)}.rels"
|
|
108
|
+
note = {"page_index": page_index, "text": "", "text_sha256": sha256_text(""), "source_slide": slide_part}
|
|
109
|
+
if rels_name in names:
|
|
110
|
+
root = ET.fromstring(z.read(rels_name))
|
|
111
|
+
for rel in root.findall("rel:Relationship", NS):
|
|
112
|
+
if rel.attrib.get("Type", "").endswith("/notesSlide"):
|
|
113
|
+
notes_part = resolve_target(rels_name, rel.attrib.get("Target", ""))
|
|
114
|
+
if notes_part in names:
|
|
115
|
+
notes_bytes = z.read(notes_part)
|
|
116
|
+
notes_root = ET.fromstring(notes_bytes)
|
|
117
|
+
text = collect_paragraph_text(notes_root)
|
|
118
|
+
update = {
|
|
119
|
+
"text": text,
|
|
120
|
+
"text_sha256": sha256_text(text),
|
|
121
|
+
"source_notes_part": notes_part,
|
|
122
|
+
}
|
|
123
|
+
if notes_dir:
|
|
124
|
+
out_dir = notes_dir / f"page_{page_index:03d}"
|
|
125
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
126
|
+
notes_xml = out_dir / "notesSlide.xml"
|
|
127
|
+
notes_xml.write_bytes(notes_bytes)
|
|
128
|
+
update["notes_xml"] = str(notes_xml)
|
|
129
|
+
note.update(update)
|
|
130
|
+
if note["text"]:
|
|
131
|
+
notes.append(note)
|
|
132
|
+
return notes
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def slide_parts_from_pptx(zip_file):
|
|
136
|
+
names = set(zip_file.namelist())
|
|
137
|
+
if "ppt/presentation.xml" not in names or "ppt/_rels/presentation.xml.rels" not in names:
|
|
138
|
+
raise ValueError("PPTX is missing presentation relationships.")
|
|
139
|
+
pres = ET.fromstring(zip_file.read("ppt/presentation.xml"))
|
|
140
|
+
pres_rels = ET.fromstring(zip_file.read("ppt/_rels/presentation.xml.rels"))
|
|
141
|
+
rels_by_id = {rel.attrib.get("Id"): rel.attrib.get("Target") for rel in pres_rels.findall("rel:Relationship", NS)}
|
|
142
|
+
slide_parts = []
|
|
143
|
+
for sld_id in pres.findall(".//p:sldId", NS):
|
|
144
|
+
rel_id = sld_id.attrib.get(f"{{{NS['r']}}}id")
|
|
145
|
+
target = rels_by_id.get(rel_id)
|
|
146
|
+
if target:
|
|
147
|
+
slide_parts.append(posixpath.normpath(posixpath.join("ppt", target)))
|
|
148
|
+
if not slide_parts:
|
|
149
|
+
raise ValueError("PPTX has no slides.")
|
|
150
|
+
return slide_parts
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def slide_size_from_pptx(zip_file):
|
|
154
|
+
pres = ET.fromstring(zip_file.read("ppt/presentation.xml"))
|
|
155
|
+
size = pres.find(".//p:sldSz", NS)
|
|
156
|
+
if size is None:
|
|
157
|
+
raise ValueError("PPTX is missing slide size.")
|
|
158
|
+
return int(size.attrib["cx"]), int(size.attrib["cy"])
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def slide_relationships(zip_file, slide_part):
|
|
162
|
+
rels_name = f"{posixpath.dirname(slide_part)}/_rels/{posixpath.basename(slide_part)}.rels"
|
|
163
|
+
if rels_name not in zip_file.namelist():
|
|
164
|
+
return {}
|
|
165
|
+
root = ET.fromstring(zip_file.read(rels_name))
|
|
166
|
+
return {rel.attrib.get("Id"): rel for rel in root.findall("rel:Relationship", NS)}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def full_slide_picture_target(zip_file, slide_part, slide_cx, slide_cy):
|
|
170
|
+
slide_root = ET.fromstring(zip_file.read(slide_part))
|
|
171
|
+
if collect_paragraph_text(slide_root):
|
|
172
|
+
raise ValueError(f"{slide_part} contains native text and is not an image-based slide.")
|
|
173
|
+
pictures = slide_root.findall(".//p:pic", NS)
|
|
174
|
+
if len(pictures) != 1:
|
|
175
|
+
raise ValueError(f"{slide_part} must contain exactly one full-slide picture; found {len(pictures)}.")
|
|
176
|
+
picture = pictures[0]
|
|
177
|
+
blip = picture.find(".//a:blip", NS)
|
|
178
|
+
if blip is None:
|
|
179
|
+
raise ValueError(f"{slide_part} picture has no embedded image.")
|
|
180
|
+
rel_id = blip.attrib.get(f"{{{NS['r']}}}embed")
|
|
181
|
+
relationships = slide_relationships(zip_file, slide_part)
|
|
182
|
+
rel = relationships.get(rel_id)
|
|
183
|
+
if rel is None or not rel.attrib.get("Type", "").endswith("/image"):
|
|
184
|
+
raise ValueError(f"{slide_part} picture relationship is not an embedded image.")
|
|
185
|
+
|
|
186
|
+
off = picture.find(".//a:xfrm/a:off", NS)
|
|
187
|
+
ext = picture.find(".//a:xfrm/a:ext", NS)
|
|
188
|
+
if off is None or ext is None:
|
|
189
|
+
raise ValueError(f"{slide_part} picture has no placement transform.")
|
|
190
|
+
x, y = int(off.attrib.get("x", 0)), int(off.attrib.get("y", 0))
|
|
191
|
+
cx, cy = int(ext.attrib.get("cx", 0)), int(ext.attrib.get("cy", 0))
|
|
192
|
+
tolerance = 2
|
|
193
|
+
if abs(x) > tolerance or abs(y) > tolerance or abs(cx - slide_cx) > tolerance or abs(cy - slide_cy) > tolerance:
|
|
194
|
+
raise ValueError(f"{slide_part} picture is not full-slide.")
|
|
195
|
+
|
|
196
|
+
return resolve_target(f"{posixpath.dirname(slide_part)}/_rels/{posixpath.basename(slide_part)}.rels", rel.attrib["Target"])
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def extract_image_based_pptx_pages(pptx_path, pages_dir):
|
|
200
|
+
outputs = []
|
|
201
|
+
with zipfile.ZipFile(pptx_path) as z:
|
|
202
|
+
names = set(z.namelist())
|
|
203
|
+
slide_cx, slide_cy = slide_size_from_pptx(z)
|
|
204
|
+
for index, slide_part in enumerate(slide_parts_from_pptx(z), start=1):
|
|
205
|
+
image_part = full_slide_picture_target(z, slide_part, slide_cx, slide_cy)
|
|
206
|
+
if image_part not in names:
|
|
207
|
+
raise ValueError(f"{slide_part} references missing image part: {image_part}")
|
|
208
|
+
page_dir = pages_dir / f"page_{index:03d}"
|
|
209
|
+
page_dir.mkdir(parents=True, exist_ok=True)
|
|
210
|
+
out = page_dir / "source.png"
|
|
211
|
+
with Image.open(io.BytesIO(z.read(image_part))) as image:
|
|
212
|
+
image.convert("RGB").save(out)
|
|
213
|
+
outputs.append(out)
|
|
214
|
+
return outputs
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def find_soffice():
|
|
218
|
+
return shutil.which("soffice") or shutil.which("libreoffice")
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def convert_office_to_pdf(input_path, out_dir):
|
|
222
|
+
soffice = find_soffice()
|
|
223
|
+
if not soffice:
|
|
224
|
+
raise RuntimeError("No local Office converter is available for this input.")
|
|
225
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
226
|
+
subprocess.run(
|
|
227
|
+
[soffice, "--headless", "--convert-to", "pdf", "--outdir", str(out_dir), str(input_path)],
|
|
228
|
+
check=True,
|
|
229
|
+
stdout=subprocess.PIPE,
|
|
230
|
+
stderr=subprocess.PIPE,
|
|
231
|
+
text=True,
|
|
232
|
+
)
|
|
233
|
+
pdfs = sorted(out_dir.glob("*.pdf"))
|
|
234
|
+
if not pdfs:
|
|
235
|
+
raise RuntimeError(f"Office conversion did not produce a PDF in {out_dir}")
|
|
236
|
+
return pdfs[0]
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def convert_ppt_to_pptx(input_path, out_dir):
|
|
240
|
+
if input_path.suffix.lower() == ".pptx":
|
|
241
|
+
return input_path
|
|
242
|
+
soffice = find_soffice()
|
|
243
|
+
if not soffice:
|
|
244
|
+
raise RuntimeError("No local Office converter is available to normalize .ppt input.")
|
|
245
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
246
|
+
subprocess.run(
|
|
247
|
+
[soffice, "--headless", "--convert-to", "pptx", "--outdir", str(out_dir), str(input_path)],
|
|
248
|
+
check=True,
|
|
249
|
+
stdout=subprocess.PIPE,
|
|
250
|
+
stderr=subprocess.PIPE,
|
|
251
|
+
text=True,
|
|
252
|
+
)
|
|
253
|
+
pptxs = sorted(out_dir.glob("*.pptx"))
|
|
254
|
+
if not pptxs:
|
|
255
|
+
raise RuntimeError(f"Office conversion did not produce a PPTX in {out_dir}")
|
|
256
|
+
return pptxs[0]
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def page_record(job_dir, page_index, source, input_path, source_page):
|
|
260
|
+
page_dir = source.parent
|
|
261
|
+
rel_page_dir = page_dir.relative_to(job_dir).as_posix()
|
|
262
|
+
return {
|
|
263
|
+
"page_index": page_index,
|
|
264
|
+
"source_page": source_page,
|
|
265
|
+
"source_image": source.relative_to(job_dir).as_posix(),
|
|
266
|
+
"page_dir": rel_page_dir,
|
|
267
|
+
"manifest": f"{rel_page_dir}/manifest.json",
|
|
268
|
+
"validation": f"{rel_page_dir}/validation.json",
|
|
269
|
+
"input": Path(input_path).name,
|
|
270
|
+
"agent_status": "pending",
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def default_job_dir(out_root, input_paths):
|
|
275
|
+
stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
276
|
+
stem = Path(input_paths[0]).stem if input_paths else "job"
|
|
277
|
+
return Path(out_root) / f"{stamp}-{stem}"
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def default_output_name(input_paths):
|
|
281
|
+
stem = Path(input_paths[0]).stem if input_paths else "deck"
|
|
282
|
+
return f"{stem}_edited.pptx"
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def normalize_inputs(inputs, out_root="output/image-to-editable-ppt", job_dir=None, dpi=180):
|
|
286
|
+
input_paths = [Path(path).resolve() for path in inputs]
|
|
287
|
+
job_dir = Path(job_dir).resolve() if job_dir else default_job_dir(out_root, input_paths).resolve()
|
|
288
|
+
input_dir = job_dir / "input"
|
|
289
|
+
pages_dir = job_dir / "pages"
|
|
290
|
+
input_dir.mkdir(parents=True, exist_ok=True)
|
|
291
|
+
pages_dir.mkdir(parents=True, exist_ok=True)
|
|
292
|
+
|
|
293
|
+
copied = [copy_input(path, input_dir) for path in input_paths]
|
|
294
|
+
suffixes = {path.suffix.lower() for path in copied}
|
|
295
|
+
pages = []
|
|
296
|
+
notes = []
|
|
297
|
+
input_type = "images"
|
|
298
|
+
|
|
299
|
+
if len(copied) == 1 and copied[0].suffix.lower() == ".pdf":
|
|
300
|
+
input_type = "pdf"
|
|
301
|
+
sources = render_pdf_pages(copied[0], pages_dir, dpi)
|
|
302
|
+
pages = [page_record(job_dir, i, source, copied[0], i) for i, source in enumerate(sources, start=1)]
|
|
303
|
+
elif len(copied) == 1 and copied[0].suffix.lower() in PPT_EXTS:
|
|
304
|
+
if copied[0].suffix.lower() == ".pptx":
|
|
305
|
+
input_type = "pptx"
|
|
306
|
+
notes = collect_notes_from_pptx(copied[0], input_dir / "notes")
|
|
307
|
+
try:
|
|
308
|
+
sources = extract_image_based_pptx_pages(copied[0], pages_dir)
|
|
309
|
+
except ValueError as exc:
|
|
310
|
+
raise SystemExit(
|
|
311
|
+
"Unsupported PPTX for the lightweight path: "
|
|
312
|
+
f"{exc} This skill accepts image-based PPTX files through lightweight extraction. "
|
|
313
|
+
"Convert native/complex PPTX slides to PDF or page images first."
|
|
314
|
+
) from exc
|
|
315
|
+
else:
|
|
316
|
+
input_type = "ppt"
|
|
317
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
318
|
+
tmp_dir = Path(tmp)
|
|
319
|
+
source_pptx = convert_ppt_to_pptx(copied[0], tmp_dir)
|
|
320
|
+
notes = collect_notes_from_pptx(source_pptx, input_dir / "notes")
|
|
321
|
+
if source_pptx != copied[0]:
|
|
322
|
+
shutil.copy2(source_pptx, input_dir / source_pptx.name)
|
|
323
|
+
rendered_pdf = convert_office_to_pdf(copied[0], tmp_dir)
|
|
324
|
+
sources = render_pdf_pages(rendered_pdf, pages_dir, args.dpi)
|
|
325
|
+
pages = [page_record(job_dir, i, source, copied[0], i) for i, source in enumerate(sources, start=1)]
|
|
326
|
+
elif suffixes <= IMG_EXTS:
|
|
327
|
+
input_type = "image" if len(copied) == 1 else "images"
|
|
328
|
+
for i, src in enumerate(copied, start=1):
|
|
329
|
+
source = save_image_page(src, pages_dir / f"page_{i:03d}")
|
|
330
|
+
pages.append(page_record(job_dir, i, source, src, i))
|
|
331
|
+
else:
|
|
332
|
+
raise SystemExit(f"Unsupported input combination: {', '.join(str(path) for path in input_paths)}")
|
|
333
|
+
|
|
334
|
+
for note in notes:
|
|
335
|
+
notes_xml = note.get("notes_xml")
|
|
336
|
+
if notes_xml:
|
|
337
|
+
note["notes_xml"] = Path(notes_xml).relative_to(job_dir).as_posix()
|
|
338
|
+
|
|
339
|
+
notes_manifest_path = job_dir / "notes_manifest.json"
|
|
340
|
+
notes_manifest = {"source": copied[0].relative_to(job_dir).as_posix() if len(copied) == 1 else None, "notes": notes}
|
|
341
|
+
notes_manifest_path.write_text(json.dumps(notes_manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
342
|
+
|
|
343
|
+
deck_manifest = {
|
|
344
|
+
"input_type": input_type,
|
|
345
|
+
"job_dir": str(job_dir),
|
|
346
|
+
"page_count": len(pages),
|
|
347
|
+
"inputs": [path.relative_to(job_dir).as_posix() for path in copied],
|
|
348
|
+
"pages": pages,
|
|
349
|
+
"notes_manifest": notes_manifest_path.relative_to(job_dir).as_posix(),
|
|
350
|
+
"output": default_output_name(copied),
|
|
351
|
+
"validation": "validation.json",
|
|
352
|
+
}
|
|
353
|
+
deck_manifest_path = job_dir / "deck_manifest.json"
|
|
354
|
+
deck_manifest_path.write_text(json.dumps(deck_manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
355
|
+
return deck_manifest_path
|