Skill Tracer
Skills › Scientific Agent Skills › scientific-slides › script_reference.md

script_reference.md

199 lines · skills/scientific-slides/references/script_reference.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Bundled Script Reference
2
3Arguments, options, and usage for `generate_slide_image.py`, `slides_to_pdf.py`,
4`validate_presentation.py`, and `pdf_to_images.py`, plus the pptx-skill scripts and
5external tools this skill relies on.
6

Bundled Script Reference

Arguments, options, and usage for generate_slide_image.py, slides_to_pdf.py, validate_presentation.py, and pdf_to_images.py, plus the pptx-skill scripts and external tools this skill relies on.

Raw lines 1 to 6
7## Current runtime and API contracts
8
9Reviewed 2026-09-30. Local tests use PyMuPDF 1.28.2, Pillow 12.3.0,
10python-pptx 1.0.2 and pypdf 6.19.0. Install packages in a dedicated environment;
11for a single command, for example:
13```bash
14uv run --isolated --with pymupdf==1.28.2 python scripts/pdf_to_images.py presentation.pdf review/slide --format png
15```
17Generation needs `requests` and `OPENROUTER_API_KEY`; it sends prompts and attached
18images to OpenRouter and the selected model provider. Prefer the environment or
19`.env` over putting a credential in shell history with `--api-key`.
21- `POST https://openrouter.ai/api/v1/images`: Bearer authentication, JSON
22 `model`, `prompt`, `n: 1`, `aspect_ratio: "16:9"`, optional `input_references`
23 containing `image_url` data URLs. The model is `google/gemini-3.1-flash-image`
24 (Nano Banana 2). Its current endpoints accept up to 14 references, PNG/JPEG/GIF/WebP
25 inputs, and no `output_format` capability; the helper checks returned PNG MIME/signature.
26- Response: `data[0].b64_json` with optional `media_type`, rather than a chat message.
27 Output filenames must end in `.png`. This does not promise vector/editable output,
28 transparency, exact typography, or unchanged attached figures.
29- `POST https://openrouter.ai/api/v1/chat/completions`: the review uses
30 `google/gemini-3.7-flash`, multipart text plus `image_url`, and reads
31 `choices[0].message.content`. Its 6.5/10 threshold is a local heuristic,
32 not validation of scientific accuracy or accessibility.
33- `GET /api/v1/images/models` and `GET /api/v1/images/models/{model-id}/endpoints`
34 discover image capabilities; `GET /api/v1/models` verifies the review model's image
35 input and text output. These public catalog responses have no page loop here.
36- The helper makes one generation call and one review per draft, at most two drafts.
37 A generation failure stops without replay; a failed refinement keeps the earlier draft.
38 `<stem>_review_log.json` separates `success` (image saved), `quality_met`,
39 `final_reviewed`, model IDs, and `termination_reason`. Missing reviews never invent scores.
41Official sources: [Image API](https://openrouter.ai/docs/guides/overview/multimodal/image-generation),
42[model endpoints](https://openrouter.ai/api/v1/images/models/google/gemini-3.1-flash-image/endpoints),
43[image inputs for review](https://openrouter.ai/docs/guides/overview/multimodal/image-understanding).
44The current contracts were checked against documentation/public catalogs and offline
45mock responses. No authenticated image/review request was made during this refresh.

Current runtime and API contracts

Reviewed 2026-09-30. Local tests use PyMuPDF 1.28.2, Pillow 12.3.0, python-pptx 1.0.2 and pypdf 6.19.0. Install packages in a dedicated environment; for a single command, for example:

uv run --isolated --with pymupdf==1.28.2 python scripts/pdf_to_images.py presentation.pdf review/slide --format png

Generation needs requests and OPENROUTER_API_KEY; it sends prompts and attached images to OpenRouter and the selected model provider. Prefer the environment or .env over putting a credential in shell history with --api-key.

  • POST https://openrouter.ai/api/v1/images: Bearer authentication, JSON model, prompt, n: 1, aspect_ratio: "16:9", optional input_references containing image_url data URLs. The model is google/gemini-3.1-flash-image (Nano Banana 2). Its current endpoints accept up to 14 references, PNG/JPEG/GIF/WebP inputs, and no output_format capability; the helper checks returned PNG MIME/signature.
  • Response: data[0].b64_json with optional media_type, rather than a chat message. Output filenames must end in .png. This does not promise vector/editable output, transparency, exact typography, or unchanged attached figures.
  • POST https://openrouter.ai/api/v1/chat/completions: the review uses google/gemini-3.7-flash, multipart text plus image_url, and reads choices[0].message.content. Its 6.5/10 threshold is a local heuristic, not validation of scientific accuracy or accessibility.
  • GET /api/v1/images/models and GET /api/v1/images/models/{model-id}/endpoints discover image capabilities; GET /api/v1/models verifies the review model's image input and text output. These public catalog responses have no page loop here.
  • The helper makes one generation call and one review per draft, at most two drafts. A generation failure stops without replay; a failed refinement keeps the earlier draft. <stem>_review_log.json separates success (image saved), quality_met, final_reviewed, model IDs, and termination_reason. Missing reviews never invent scores.

Official sources: Image API, model endpoints, image inputs for review. The current contracts were checked against documentation/public catalogs and offline mock responses. No authenticated image/review request was made during this refresh.

Raw lines 7 to 46
Runs code python scripts/pdf_to_images.py :14
47## Nano Banana 2 Script Reference

Nano Banana 2 Script Reference

Raw lines 47 to 48
49### generate_slide_image.py
51Generate presentation slides or visuals using Nano Banana 2 AI.
53```bash
54# Full slide (default) - generates complete slide as image
55python scripts/generate_slide_image.py "slide description" -o output.png
57# Visual only - generates just the image/figure for embedding in PPT
58python scripts/generate_slide_image.py "visual description" -o output.png --visual-only
60# With reference images attached (Nano Banana 2 will see these)
61python scripts/generate_slide_image.py "Create a conceptual overview matching this style" -o slide.png --attach style_reference.png
62python scripts/generate_slide_image.py "Draft a conceptual comparison of these designs" -o compare.png --attach concept_a.png --attach concept_b.png
63```
65**Options:**
66- `-o, --output`: Output PNG path with `.png` suffix (required)
67- `--attach IMAGE`: Attach image file(s) as context for generation (can use multiple times)
68- `--visual-only`: Generate just the visual/figure, not a complete slide
69- `--iterations`: Maximum drafts, 1 or 2 (default: 2)
70- `--api-key`: OpenRouter API key (or set OPENROUTER_API_KEY env var)
71- `-v, --verbose`: Verbose output
73**Attaching Reference Images:**
75Use `--attach` for conceptual context or style drafts. It may redraw every pixel,
76including labels, logos, axes and measurements. For final quantitative results,
77embed the original figure with native PowerPoint or Beamer geometry; do not ask
78the image model to combine or preserve it. Verify conceptual diagrams against the
79source before presenting them.
81**Environment Setup:**
82```bash
83export OPENROUTER_API_KEY='your_api_key_here'
84# Get key at: https://openrouter.ai/keys
85```

generate_slide_image.py

Generate presentation slides or visuals using Nano Banana 2 AI.

# Full slide (default) - generates complete slide as image
python scripts/generate_slide_image.py "slide description" -o output.png

# Visual only - generates just the image/figure for embedding in PPT
python scripts/generate_slide_image.py "visual description" -o output.png --visual-only

# With reference images attached (Nano Banana 2 will see these)
python scripts/generate_slide_image.py "Create a conceptual overview matching this style" -o slide.png --attach style_reference.png
python scripts/generate_slide_image.py "Draft a conceptual comparison of these designs" -o compare.png --attach concept_a.png --attach concept_b.png

Options:

  • -o, --output: Output PNG path with .png suffix (required)
  • --attach IMAGE: Attach image file(s) as context for generation (can use multiple times)
  • --visual-only: Generate just the visual/figure, not a complete slide
  • --iterations: Maximum drafts, 1 or 2 (default: 2)
  • --api-key: OpenRouter API key (or set OPENROUTER_API_KEY env var)
  • -v, --verbose: Verbose output

Attaching Reference Images:

Use --attach for conceptual context or style drafts. It may redraw every pixel, including labels, logos, axes and measurements. For final quantitative results, embed the original figure with native PowerPoint or Beamer geometry; do not ask the image model to combine or preserve it. Verify conceptual diagrams against the source before presenting them.

Environment Setup:

export OPENROUTER_API_KEY='your_api_key_here'
# Get key at: https://openrouter.ai/keys
Raw lines 49 to 86
Runs code python scripts/generate_slide_image.py :55
87### slides_to_pdf.py
89Combine multiple slide images into a single PDF.
91```bash
92# Combine PNG files
93python scripts/slides_to_pdf.py slides/*.png -o presentation.pdf
95# Combine specific files in order
96python scripts/slides_to_pdf.py title.png intro.png methods.png -o talk.pdf
98# From directory (sorted by filename)
99python scripts/slides_to_pdf.py slides/ -o presentation.pdf
100```
102**Options:**
103- `-o, --output`: Output PDF path (required)
104- `--dpi`: PDF resolution (default: 150)
105- `-v, --verbose`: Verbose output
107**Ordering:** Explicit file arguments retain their given order. Each directory/glob expands in filename order; duplicates are removed at their first occurrence.
109**Tip:** Name slides with numbers for correct ordering: `01_title.png`, `02_intro.png`, etc.
111---

slides_to_pdf.py

Combine multiple slide images into a single PDF.

# Combine PNG files
python scripts/slides_to_pdf.py slides/*.png -o presentation.pdf

# Combine specific files in order
python scripts/slides_to_pdf.py title.png intro.png methods.png -o talk.pdf

# From directory (sorted by filename)
python scripts/slides_to_pdf.py slides/ -o presentation.pdf

Options:

  • -o, --output: Output PDF path (required)
  • --dpi: PDF resolution (default: 150)
  • -v, --verbose: Verbose output

Ordering: Explicit file arguments retain their given order. Each directory/glob expands in filename order; duplicates are removed at their first occurrence.

Tip: Name slides with numbers for correct ordering: 01_title.png, 02_intro.png, etc.


Raw lines 87 to 112
Runs code python scripts/slides_to_pdf.py :93
113## Tools and Scripts

Tools and Scripts

Raw lines 113 to 114
115### Nano Banana 2 Scripts
117**generate_slide_image.py** - Generate slides or visuals with AI:
118```bash
119# Full slide (for PDF workflow)
120python scripts/generate_slide_image.py "Title: Introduction\nContent: Key points" -o slide.png
122# Visual only (for PPT workflow)
123python scripts/generate_slide_image.py "Diagram description" -o figure.png --visual-only
125# Options:
126# -o, --output Output PNG path with `.png` suffix (required)
127# --visual-only Generate just the visual, not complete slide
128# --iterations N Maximum drafts, 1 or 2 (default: 2)
129# -v, --verbose Verbose output
130```
132**slides_to_pdf.py** - Combine slide images into PDF:
133```bash
134# From glob pattern
135python scripts/slides_to_pdf.py slides/*.png -o presentation.pdf
137# From directory (sorted by filename)
138python scripts/slides_to_pdf.py slides/ -o presentation.pdf
140# Options:
141# -o, --output Output PDF path (required)
142# --dpi N PDF resolution (default: 150)
143# -v, --verbose Verbose output
144```

Nano Banana 2 Scripts

generate_slide_image.py - Generate slides or visuals with AI:

# Full slide (for PDF workflow)
python scripts/generate_slide_image.py "Title: Introduction\nContent: Key points" -o slide.png

# Visual only (for PPT workflow)
python scripts/generate_slide_image.py "Diagram description" -o figure.png --visual-only

# Options:
# -o, --output       Output PNG path with `.png` suffix (required)
# --visual-only      Generate just the visual, not complete slide
# --iterations N     Maximum drafts, 1 or 2 (default: 2)
# -v, --verbose      Verbose output

slides_to_pdf.py - Combine slide images into PDF:

# From glob pattern
python scripts/slides_to_pdf.py slides/*.png -o presentation.pdf

# From directory (sorted by filename)
python scripts/slides_to_pdf.py slides/ -o presentation.pdf

# Options:
# -o, --output    Output PDF path (required)
# --dpi N         PDF resolution (default: 150)
# -v, --verbose   Verbose output
Raw lines 115 to 145
Runs code python scripts/generate_slide_image.py :120
Runs code python scripts/slides_to_pdf.py :135
146### Validation Scripts
148**validate_presentation.py**:
149```bash
150python scripts/validate_presentation.py presentation.pdf --duration 15
152# Checks:
153# - Slide count vs. recommended range
154# - File size warnings
155# - Slide dimensions
156# - Font sizes (PowerPoint)
157# - Compilation (Beamer)
158```
160**pdf_to_images.py**:
161```bash
162python scripts/pdf_to_images.py presentation.pdf output/slide --dpi 150
164# Converts PDF to images for visual inspection
165# Supports: JPG, PNG
166# Adjustable DPI
167# Page range selection
168```

Validation Scripts

validate_presentation.py:

python scripts/validate_presentation.py presentation.pdf --duration 15

# Checks:
# - Slide count vs. recommended range
# - File size warnings
# - Slide dimensions
# - Font sizes (PowerPoint)
# - Compilation (Beamer)

pdf_to_images.py:

python scripts/pdf_to_images.py presentation.pdf output/slide --dpi 150

# Converts PDF to images for visual inspection
# Supports: JPG, PNG
# Adjustable DPI
# Page range selection
Raw lines 146 to 169
Runs code python scripts/validate_presentation.py :150
Runs code python scripts/pdf_to_images.py :162
170### Validation limits and external PowerPoint tools
172`validate_presentation.py` supports PDF, PPTX and TEX. Convert legacy PPT to PPTX/PDF
173first. It counts PDF pages (including Beamer overlays/appendices), not conceptual frames;
174its timing guidance is only a rehearsal aid. Font checks inspect explicit text-run sizes,
175not inherited theme sizes, tables, groups, reading order or text overflow. TEX validation
176runs one `pdflatex -no-shell-escape` pass; resolve citations and navigation with `latexmk`
177or the full bibliography build before delivery.
179`pdf_to_images.py` uses the current `pymupdf` import and `get_pixmap(dpi=...)`;
180`--first`/`--last` are inclusive and 1-based. Invalid ranges and nonpositive DPI fail.
181`slides_to_pdf.py` uses Pillow's `save_all`/`append_images`; DPI controls page dimensions,
182not new image detail. All input slides should share an aspect ratio and pixel size.
184To review a PPTX deck, export it to PDF in PowerPoint or LibreOffice
185(`soffice --headless --convert-to pdf deck.pptx`) and use the bundled PDF renderer.
187Sources: [PyMuPDF rendering](https://pymupdf.readthedocs.io/en/latest/recipes-images.html),
188[Pillow PDF](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#pdf),
189[python-pptx presentations](https://python-pptx.readthedocs.io/en/latest/user/presentations.html),
190[pypdf reader](https://pypdf.readthedocs.io/en/latest/modules/PdfReader.html).

Validation limits and external PowerPoint tools

validate_presentation.py supports PDF, PPTX and TEX. Convert legacy PPT to PPTX/PDF first. It counts PDF pages (including Beamer overlays/appendices), not conceptual frames; its timing guidance is only a rehearsal aid. Font checks inspect explicit text-run sizes, not inherited theme sizes, tables, groups, reading order or text overflow. TEX validation runs one pdflatex -no-shell-escape pass; resolve citations and navigation with latexmk or the full bibliography build before delivery.

pdf_to_images.py uses the current pymupdf import and get_pixmap(dpi=...); --first/--last are inclusive and 1-based. Invalid ranges and nonpositive DPI fail. slides_to_pdf.py uses Pillow's save_all/append_images; DPI controls page dimensions, not new image detail. All input slides should share an aspect ratio and pixel size.

To review a PPTX deck, export it to PDF in PowerPoint or LibreOffice (soffice --headless --convert-to pdf deck.pptx) and use the bundled PDF renderer.

Sources: PyMuPDF rendering, Pillow PDF, python-pptx presentations, pypdf reader.

Raw lines 170 to 191
192### External Tools
194**Recommended**:
195- PDF viewer: For reviewing presentations
196- Color contrast checker: WebAIM Contrast Checker
197- Color blindness simulator: Coblis
198- Timer app: For practice sessions
199- Screen recorder: For self-review

External Tools

Recommended:

  • PDF viewer: For reviewing presentations
  • Color contrast checker: WebAIM Contrast Checker
  • Color blindness simulator: Coblis
  • Timer app: For practice sessions
  • Screen recorder: For self-review
Raw lines 192 to 199