Error trying to save Optimized SVG (no 'width' attribute for SVGRoot)

Bug #1463623 reported by Marlon Marcello
82
This bug affects 11 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
Aurium

Bug Description

Clicking Save As, choosing Optimized SVG, with the following options:

Options
Shorten color values
Group collapsing
Remove metadata
Remove comments
Work around renderer bugs
Enable viewboxing
Remove the xml declaration
Significant digits cords : 5
XML identaton: space

IDS Tab
Removed unused ids
Shorten ids
Preserve manually added ids

Inkscape return the following error:

Traceback (most recent call last):
  File "scour.inkscape.py", line 78, in <module>
    e.affect(output=False)
  File "/usr/share/inkscape/extensions/inkex.py", line 265, in affect
    self.getposinlayer()
  File "/usr/share/inkscape/extensions/inkex.py", line 207, in getposinlayer
    x = self.unittouu( xattr[0] + 'px' )
  File "/usr/share/inkscape/extensions/inkex.py", line 351, in unittouu
    return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()])
  File "/usr/share/inkscape/extensions/inkex.py", line 304, in getDocumentUnit
    p = param.match(svgwidth)
TypeError: expected string or buffer

Related branches

Revision history for this message
su_v (suv-lp) wrote :

Please add information about OS/platform and Inkscape version to the bug description, thank you.

To allow further investigation, please attach a test case to the bug report which consistently fails to save as Optimized SVG file as reported.

Changed in inkscape:
status: New → Incomplete
Revision history for this message
Thomas (iam2noob4u) wrote :

Windows 7 SP1 x64 (judging from paths in OP, not limited to Windows)
Inkscape 0.91 r13725

Options turned on:
- Shorten color values
- Convert CSS attributes to XML attributes
- Group collapsing
- Create groups for similar attributes
- Embed rasters
- Remove metadata
- Remove comments
- Work around renderer bugs
- Enable viewboxing
Number of significant digits for coords: 5
XML indentation: Tab

Id options turned on:
Remove unused ID names for elements
Shorten IDs

Have tried (w/o success):
- Playing around with the options (invert every single option, changed digits for coords to 3 and to 0, tried indentation with space or none, also once inverted all options with 0 coords and space indentation)
- Running as administrator
- Running in Vista compatibility mode
- Using the downloaded extension from http://www.codedread.com/scour/#download_inkscape_extension (version 0.26)

Output shown:
Traceback (most recent call last):
  File "scour.inkscape.py", line 78, in <module>
    e.affect(output=False)
  File "D:\Inkscape\share\extensions\inkex.py", line 265, in affect
    self.getposinlayer()
  File "D:\Inkscape\share\extensions\inkex.py", line 207, in getposinlayer
    x = self.unittouu( xattr[0] + 'px' )
  File "D:\Inkscape\share\extensions\inkex.py", line 351, in unittouu
    return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()])
  File "D:\Inkscape\share\extensions\inkex.py", line 304, in getDocumentUnit
    p = param.match(svgwidth)
TypeError: expected string or buffer

(which is, apart from the paths, the same as in the OP as far as I can tell from a quick comparison)

For anyone interested, my current solution is to use https://compressor.io/compress, which also uses Scour. Perhaps using the CL script version of Scour also works.

Revision history for this message
Alvin Penner (apenner) wrote :

- confirmed on Windows 7, 32 bit, Inkscape 0.91 r13725 (Jan 30 2015)
- confirmed on Windows XP, Inkscape rev 14129

Changed in inkscape:
status: Incomplete → Confirmed
Revision history for this message
Alvin Penner (apenner) wrote :

may be related to the fact that in this particular file, the 'width' parameter that specifies the page size is not defined

Revision history for this message
su_v (suv-lp) wrote :

On 2015-06-15 01:37 (+0200), Alvin Penner wrote:
> may be related to the fact that in this particular file, the 'width'
> parameter that specifies the page size is not defined

Related earlier report (see comment 3):
Bug #1461346 “getposinlayer fails if height attribute is missing”
https://bugs.launchpad.net/inkscape/+bug/1461346

Changed in inkscape:
importance: Undecided → Medium
milestone: none → 0.92
tags: added: extensions-plugins regression
su_v (suv-lp)
summary: - Error trying to save Optimized SVG
+ Error trying to save Optimized SVG (missing <width> attribute for
+ SVGRoot)
su_v (suv-lp)
summary: - Error trying to save Optimized SVG (missing <width> attribute for
- SVGRoot)
+ Error trying to save Optimized SVG (no <width> attribute for SVGRoot)
summary: - Error trying to save Optimized SVG (no <width> attribute for SVGRoot)
+ Error trying to save Optimized SVG (no 'width' attribute for SVGRoot)
Revision history for this message
Alvin Penner (apenner) wrote :

fwiw, the same file from comment 2 also fails with the following Python extensions:
Visualize Path -> 'Dimensions' and 'Draw Handles' and 'Measure Path' and 'Number Nodes'.
Save As -> 'hpgl' and 'html 5' and 'Desktop Cutting Plotter dxf'.
possibly others, I stopped testing at this point

Revision history for this message
Thomas (iam2noob4u) wrote :

I wanted to be sure that I did not manually edit the file (or used an external program that would be to blame), I've searched for a way to reproduce this with only Inkscape and a file that originally works.

Download http://upload.wikimedia.org/wikipedia/commons/2/20/Text-x-generic.svg, open it in Inkscape, save an optimized version (same options I listed before). The optimized version does not have the width and height parameters.

Editing the file and saving as a normal svg does not restore the parameters (I did not expect it to).

Revision history for this message
su_v (suv-lp) wrote :

Proposed fix attached - please review and test (best in combination with patch for bug #1461346).

su_v (suv-lp)
tags: added: backport-proposed
Revision history for this message
jazzynico (jazzynico) wrote :

Patch tested successfully on Windows XP (32 bit), with Inkscape trunk rev. 14237.

Changed in inkscape:
assignee: nobody → ~suv (suv-lp)
status: Confirmed → Triaged
jazzynico (jazzynico)
Changed in inkscape:
status: Triaged → In Progress
Revision history for this message
su_v (suv-lp) wrote :

Fix committed to trunk in rev 14240.

Changed in inkscape:
status: In Progress → Fix Committed
Revision history for this message
Roul P. (perhelion1) wrote :

Is this not also a fix for the scour extension? bug 1393197

Revision history for this message
Roul P. (perhelion1) wrote :

Hey guys, this bug is not fixed, you need possible the same for the height. I get this error now (there is no beta / dev Inkscape anymore downable, so I edited my version manually )

Traceback (most recent call last):
  File "scour.inkscape.py", line 78, in <module>
    e.affect(output=False)
  File "C:\Program Files\inkscape\share\extensions\inkex.py", line 265, in affect
    self.getposinlayer()
  File "C:\Program Files\inkscape\share\extensions\inkex.py", line 209, in getposinlayer
    doc_height = self.unittouu(self.document.getroot().get('height'))
  File "C:\Program Files\inkscape\share\extensions\inkex.py", line 343, in unittouu
    p = param.match(string)
TypeError: expected string or buffer

Revision history for this message
su_v (suv-lp) wrote :

@Roul - we know (see comment 5, and bug #1461346).

Revision history for this message
Roul P. (perhelion1) wrote :

@~suv - Patches tested successfully on Windows 7 (64 bit).

Revision history for this message
Marlon Marcello (marlon-marcello) wrote :

This is also happening on linux.
Ubuntu Gnome 15.10.

Revision history for this message
Ken Yee (kenkyee) wrote :

Also affects me...any idea when this might make it to a released version of Inkscape? Or whether an older version does not have this bug?

Revision history for this message
Ken Yee (kenkyee) wrote :

Looks like a workaround is to edit the text SVG file and add
  width="100%" height="100%"
to the svg root xml tag before loading it into Inkscape?

Revision history for this message
su_v (suv-lp) wrote :

Fix backported to 0.91.1 in rev 13804.

Changed in inkscape:
milestone: 0.92 → 0.91.1
tags: removed: backport-proposed
Revision history for this message
su_v (suv-lp) wrote :

Rev 14240 reverted in trunk - obsoleted by fix committed in rev 14564.

TODO: revert rev 13804 in 0.91.x, and backport rev 14564 to 0.91.x.

Changed in inkscape:
assignee: ~suv (suv-lp) → Aurium (aurium)
milestone: 0.91.1 → 0.92
tags: added: backport-proposed
Revision history for this message
Jon Bailey (hobart) wrote :

Same problem (Windows, 0.91). Workaround specified by Alvin (making sure document has width + height in the XML of the SVG tag) worked, thanks!

Revision history for this message
Martin Owens (doctormo) wrote :

Also can not be applied to 0.92.x branch.

tags: removed: backport-proposed
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.