Repository navigation
SVG picture fallback: restate the root's size with ooxml-common's svgimage - #16
Merged
Merged
Conversation
…image rasterise() rewrote the SVG's root width and height through lxml itself, because resvg-py draws nothing for width="72pt". ooxml-common 0.12.0's svgimage.with_pixel_size does the same as PowerPoint reads it, for the page pptx2svg rasterises as well: the same pixels for px, pt, pc, in, cm and mm, and now PowerPoint's for an em (12 px or the root's font-size), a percentage or no size (the viewBox's size; 500 px without one, where the placed size was used). It rewrites those attributes in place instead of re-serialising the SVG, and re-encodes a Latin-1 or UTF-16 SVG instead of refusing it. Requires ooxml-common 0.12.0; CI installs it from its gaps-svg-units branch until that pull request merges (TEMPORARY (gaps)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WCxhY1fvWQPiWCwz7SYUVh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WCxhY1fvWQPiWCwz7SYUVh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
edit/svgpicture.rasteriseused its own workaround for resvg-py's "SVG has an invalid size". It parsed the SVG with lxml, setwidth/heighttonative_size(or to the placed size when the SVG stated none), and re-serialised the whole tree. It now calls the sharedooxml_common.svgimage.with_pixel_size(ooxml-common 0.12.0, uvrt/ooxml-common#23). pptx2svg now uses the same function for the SVG pictures inside a page (uvrt/pptx2svg#25).Behaviour
viewBox's size, or 500 px when there is noviewBox, where the placed size was used before. All measured on PowerPoint 16's PDF export: 30 of 30 probes match (see pptx2svg'stools/make_svg_size_probe.py). The fallback PNG now matches what PowerPoint draws from the vector.native_size, which sizes the frame when the picture is inserted.Tests
6emSVG is drawn with PowerPoint's 12 px em. This one fails before the change.Merge order
.github/workflows/ci.ymlback at@main(the# TEMPORARY (gaps)line) and merge this. It does not depend on Draw an SVG picture in PNG output whatever unit its root's size is in pptx2svg#25.🤖 Generated with Claude Code
https://claude.ai/code/session_01WCxhY1fvWQPiWCwz7SYUVh