Repository navigation
Conversation
An inserted SVG and an icon's svgBlip rasterize for the slide. The PPTX writer stores that SVG plus a PNG fallback, and the SVG cannot read files from the machine. Co-authored-by: Cursor <cursoragent@cursor.com>
Both progress logs landed on 2026-10-13; keep each row. Co-authored-by: Cursor <cursoragent@cursor.com>
A doctype or comment before the root is still an SVG, a large picture keeps its aspect, and SVGZ cannot inflate past the byte cap. The saved part is markup, which is what PowerPoint reads as an icon. Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts: # crates/pptx/src/write/dml.rs # crates/pptx/tests/fills.rs # docs/gaps.md # docs/parity-checklist.md
# Conflicts: # ROADMAP.md # crates/pptx/src/write/dml.rs # crates/render/src/images.rs # docs/file-format-parity.md # docs/gaps.md # docs/parity-checklist.md # docs/roadmap.md
|
Thanks for this. Rasterizing SVG pictures and keeping a PowerPoint icon's SVG (with a PNG beside it) when saving still looks valuable. I checked just now: the PR is open, GitHub reports it conflicts with |
|
Comparison of the two open PRs that rasterize SVG pictures: this one and #1328. Neither is closed or preferred here; this is a list of what I checked. (#1195 is related: its three commits are also inside #1328.)
Head of #1328 does not build as it stands. I extracted the PR head and ran PowerPoint check (real PowerPoint 16.0.20527 through COM, new temporary presentation, saved to a scratch folder, PowerPoint quit): Not run: tests for either PR, a build of #380, a render of either. Everything above about code is from reading the diffs at the heads fetched on 27 Oct. |
|
I tested this PR locally against the SVG-only decks from #297: the one-slide sample-svg-no-fallback.pptx from my comment there, and the original 20-slide corporate deck it was cut from. That deck can't be shared. It has 8 pictures that carry only an I built
So this PR fixes the SVG-only case from #297 on real files. It is based on This is functional testing only, not a code review. |
aiongg
left a comment
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
Changes needed:
SVG pictures now rasterize through a new crate built on resvg. Inserting an .svg uses its own size, and an icon's asvg:svgBlip is read as the picture and written back with a PNG beside it. File and URL hrefs are refused, and data-URL images and .svgz are capped.
- crates/pptx/src/read/dml.rs: picture_media makes the SVG the only media and never keeps the blip's own PNG. crates/pptx/src/write/mod.rs svg_png_rel then writes a new 512 px PNG, so a large icon's fallback loses resolution for readers that ignore the extension. Keeping the original fallback part alongside the SVG would avoid that.
- crates/svg/src/lib.rs:4 and options(): no fonts are loaded, so text in an SVG is not drawn. The description says text is drawn from fonts embedded in the file, but no code does that. The resvg 'text' feature is enabled in crates/svg/Cargo.toml without any fonts to use.
- crates/svg/Cargo.toml adds resvg 0.48.1 and a direct flate2 dependency. The resvg tree brings in about a dozen new packages (usvg, tiny-skia, svgtypes, roxmltree, simplecss, rustybuzz and others).
- crates/engine/src/cmd/insert.rs:749: the photo album path still skips decoding for image/svg+xml. Insert Picture now refuses an SVG that can't be read, so the album should check the same way.
- crates/engine/src/cmd/insert.rs:366: is_svgz only checks the gzip magic, so any gzip file (for example .emz or .wmz) is typed as image/svg+xml.
- crates/engine/src/cmd/insert.rs and crates/pptx/src/write/mod.rs have since been split on the main branch (insert/picture.rs, insert/album.rs, write.rs), so the change has to be moved onto the new layout.
- The PR text gives the Pictures score as 48% to 52%, but the changed lines in docs/parity-checklist.md and ROADMAP.md move it from 60% to 64%.
Claims checked:
- verified: SVG pictures rasterize for the slide, the thumbnail and export (crates/render/src/images.rs:133-140 routes SVG and svgz bytes through deckcraft_svg::rasterize inside decode_at, which every decode goes through)
- verified: Inserting an .svg uses its own size, and a broken SVG is refused like any other picture that cannot be read (crates/engine/src/cmd/insert.rs:377 uses svg_pixel_size first; crates/engine/src/cmd/insert.rs:398 now requires decode_image for every type. The album path at crates/engine/src/cmd/insert.rs…
- unverified: a claim of the description (crates/pptx/src/read/dml.rs picture_media returns the svgBlip media when svg_xml accepts it, else the blip's r:embed)
- unverified: Saving writes the SVG back and a PNG beside it (crates/pptx/src/write/dml.rs blip_fill puts the svg_png_rel PNG in r:embed and the SVG in an a:ext with asvg:svgBlip. The PNG is a fresh 512 px raster from crates/pptx/src/write/mod.rs svg_png_rel, not the file's original fallback)
- unverified: An SVG is not allowed to open a file or a URL (crates/svg/src/lib.rs options() sets image_href_resolver.resolve_string to return None; only data URLs go through resolve_embedded)
- contradicted: Text is drawn only from fonts embedded in the file (crates/svg/src/lib.rs:4 says text is not drawn because no fonts are loaded; options() keeps usvg's default empty font database and nothing reads embedded fonts)
- contradicted: Pictures breadth on the checklist moves from 48% to 52% (docs/parity-checklist.md and ROADMAP.md change Pictures from 60% to 64%)
Recommendation: update the pull request; it will be reviewed again.
Reviewed at cdfa6a5.
Player: draw SVG pictures (upstream PR storytold#380), version 0.7.0
Summary
.svguses its own size, and a broken SVG is refused like any other picture that cannot be read.asvg:svgBlipis the picture that is kept. Saving writes that SVG back and a PNG beside it, so a reader that ignores the extension still has an image.Fixes #297
Test plan
<image href>to a real PNG is not drawndecodeturns an SVG into pixelssvgBlipand a PNG; replacing that PNG and reopening still returns the SVGcargo clippy -p deckcraft-svg -p deckcraft-render -p deckcraft-pptx -p deckcraft-engine --all-targets -- -D warningscargo checkof those crates forwasm32-unknown-unknownMade with Cursor