Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[0.3.3] Started producing SVG without width, height and viewBox

See original GitHub issue

Hi @btel ,

due to my rendering regression tests in xiangqi-setup I noticed that things broke when trying to upgrade to svgutils 0.3.3. What happens is that the width, height, and viewBox parameters are no longer included in the written SVG file. Here’s what that looks like in Inkscape: The dotted line is where the viewbox was with svgutils 0.3.2, the solid frame is where the new defacto viewbox is:


Here’s a diff of before and after, with regard to the SVG output.

--- tests/actual-board-a4_blank_2cm_margin_BEFORE.svg   2021-02-10 11:22:04.300605915 +0100
+++ tests/actual-board-a4_blank_2cm_margin_AFTER.svg    2021-02-10 11:21:49.446494230 +0100
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='ASCII' standalone='yes'?>
-<svg xmlns="" xmlns:xlink="" version="1.1" width="248.03149580999997px" viewBox="0 0 248.03149580999997 350.78740120838086" height="350.78740120838086px">
+<svg xmlns="" xmlns:xlink="" version="1.1">
     <g transform="translate(0, 0) scale(0.33333333299287476 0.33333333299287476) "><defs id="defs4"/>
   <sodipodi:namedview xmlns:sodipodi="" xmlns:inkscape="" id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.7" inkscape:cx="359.38222" inkscape:cy="512.51453" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="1920" inkscape:window-height="1024" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1"/>

I have a feeling that #58 is causing this: .width and .height (with no underscores) are no longer set? Is that a bug or a feature? How can I make svgutils 0.3.3 put width, height and viewBox into SVG output again?

Thanks and best, Sebastian

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

hartworkcommented, Feb 10, 2021

Awesome! I confirm that my regression tests are happy green with 0.3.4 now as well.

btelcommented, Feb 10, 2021

i just released v0.3.4 with your fix, thanks for reporting/fixing

Read more comments on GitHub >

github_iconTop Results From Across the Web

viewBox - SVG: Scalable Vector Graphics - MDN Web Docs
The viewBox attribute defines the position and dimension, in user space, ... is a list of four numbers: min-x , min-y , width...
Read more >
Shrinking SVG to size - css - Stack Overflow
I've tried viewbox, tried setting setting width/height, but can't seem to figure it out. In chrome, the below code produces a 24x24 container ......
Read more >
Document Structure - SVG 1.1 - 20030114 - W3C
If attributes width and/or height are not specified, the generated 'svg' element will use values of 100% for these attributes. If the 'use' ......
Read more >
SVG Viewport and viewBox (For Complete Beginners)
The viewport size is set by adding width and height attributes to the svg element ... We'll start by looking at “zooming”, which...
Read more >
SVG symbol a Good Choice for Icons - CSS-Tricks
Looking for a better way to do SVG icons? Inline SVG might be your best bet, which you can learn about in this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found