Skip to content

Add SVG and PPTX renderers#16

Merged
sjquant merged 8 commits into
mainfrom
claude/html-svg-ppt-renderer-f3zqmr
Jun 13, 2026
Merged

Add SVG and PPTX renderers#16
sjquant merged 8 commits into
mainfrom
claude/html-svg-ppt-renderer-f3zqmr

Conversation

@sjquant

@sjquant sjquant commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Why

quickthumb currently focuses on raster image output. SVG and PPTX exports let the same canvas specs produce vector documents and editable slides without rebuilding designs elsewhere.

Changes

  • Add .svg and .pptx output detection in canvas.render(), plus canvas.to_svg() and canvas.to_pptx().
  • Export supported layers as native SVG/PPTX primitives, with raster fallback for images, blend/custom layers, image-filled text, and PPTX radial text fills.
  • Preserve SVG effect alpha, avoid CairoSVG for plain vector SVG-layer export, and report PPTX slide-size limits with a quickthumb RenderingError.
  • Apply PPTX layer opacity consistently to shape/text fills, strokes, backgrounds, glows, and shadows.
  • Configure source type checking for ty and Pyright, and tighten typing around JSON parsing, SVG/PPTX helpers, and exporter tests.
  • Add black-box exporter tests and make optional CairoSVG/LibreOffice visual checks skip cleanly when unavailable.
  • Document SVG/PPTX export usage and the quickthumb[pptx] extra.

claude and others added 6 commits June 12, 2026 11:48
Render canvases to vector and document formats alongside PNG/JPEG/WEBP:

- canvas.render() detects .svg/.html/.pptx extensions; new to_svg(),
  to_html(), and to_pptx() methods
- Backgrounds, gradients, outlines, shapes, and text (wrapping, rich
  parts, letter spacing, effects, rotation) export as native, editable
  primitives using the same layout math as the raster pipeline
- Raster images, image glyph fills, blend modes, and custom layers are
  embedded as pixel-exact PNG fragments; layers below the last
  blend/custom layer are flattened so blending sees its backdrop
- Optional embed_fonts inlines used fonts as @font-face data URLs
- PPTX export maps text to editable text boxes and shapes to autoshapes
  via the new optional quickthumb[pptx] extra (python-pptx)

https://claude.ai/code/session_01XRy5d1z14AgR3caayjjATH
Each snapshot stacks the PIL raster render (top) against the export
rasterized back to pixels (bottom) with a magenta divider, so export
fidelity can be judged visually like the existing rendering snapshots.

- Five SVG comparison scenes: shapes/gradients/outline, text styles and
  effects, rich text and gradient fills, auto-layout groups, and
  blend-mode flattening with embedded images
- PPTX comparisons rasterize through LibreOffice and skip when it is
  unavailable; regenerate with --inline-snapshot=create
- conftest pins fontconfig to the repo fonts so cairosvg resolves the
  same font files as the PIL pipeline on any machine

https://claude.ai/code/session_01XRy5d1z14AgR3caayjjATH
Review follow-up. No behavior change for rendered pixels:

- Consolidate _export_svg imports to module top (compute_text_layout,
  parse_padding, Align) instead of per-method local imports
- Skip the wrapping <g> for non-rotated, fully opaque text so the SVG
  carries no empty groups
- Add regression tests for two verified-but-fragile cases: a PPTX text
  run with both a gradient fill and a stroke keeps valid DrawingML rPr
  child order (ln → fill → latin), and right/bottom-aligned percentage
  text matches the raster render within anti-aliasing noise

https://claude.ai/code/session_01XRy5d1z14AgR3caayjjATH
The HTML renderer was only wrapping the SVG export in a page shell, not a
distinct output format, so drop it until it earns its place.

- Remove Canvas.to_html(), the .html/.htm render dispatch, and
  quickthumb/_export_html.py
- Drop the HTML tests and trim docs (exports page, canvas API,
  installation, README, CLI help) back to SVG + PPTX

.svg and .pptx still render by extension; .html now falls through to the
normal unsupported-format error.

https://claude.ai/code/session_01XRy5d1z14AgR3caayjjATH
@sjquant sjquant changed the title ✨ Add SVG, HTML, and PPTX renderers ✨ Add SVG and PPTX renderers Jun 13, 2026
@sjquant sjquant changed the title ✨ Add SVG and PPTX renderers Add SVG and PPTX renderers Jun 13, 2026
@sjquant sjquant self-assigned this Jun 13, 2026
@sjquant sjquant merged commit 8d0c237 into main Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants