Dimensions on saving as Optimized SVG

Bug #1656663 reported by carmen fierro
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
New
Undecided
Unassigned

Bug Description

Running Inkscape 0.91 on Windows7 64x:
On saving as Optimized SVG for includinding in .epub (as <img />), I keep checked the option to "set viewBox AND establish width/height to 100%"--BUT although I get the viewBox, I also get height="84.949mm" width="84.102mm" (or other measures--always mm, although my selection is for px as unit at document level).
I find it rather annoying, for of course the image (usually a map) fails to strech in the viewer until--after some heartburning--I DO remember the issue and edit the dimensions by hand...
Thanks!

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

Please attach a test case (original Inkscape SVG file, optimized SVG saved with Inkscape 0.91) to the bug report to allow further investigation, thank you.

Does the issue persist with latest release Inkscape 0.92?
The Windows packages of Inkscape 0.92 include a copy of latest upstream version of scour (the python module which saves the optimized version of the SVG file).

Changed in inkscape:
status: New → Incomplete
Revision history for this message
carmen fierro (cfierrob) wrote : Re: [Bug 1656663] Re: Dimensions on saving as Optimized SVG

I hsve just installed version 0.92, and--yes: saving as Optimizad SVG,
option "viewBox" DOESN'T default width/height to 100%. Result: no
stertching when put into an html <img />, as shown in the atttachments:
HerringsPMap.svg is the Inkscape SVG (made with version 0.91, opened and
re-saved from version 0.92); HerringsPMapO.svg comes from 'save a copy as
Optimized SVG".
Note: changing from the new version, at document level, default units to
px, has resulted in height/width with no units (px being the html default)
BUT they are set, nevertheless.
Many thanks.

Carmen

2017-01-15 18:06 GMT+01:00 su_v <email address hidden>:

> Please attach a test case (original Inkscape SVG file, optimized SVG
> saved with Inkscape 0.91) to the bug report to allow further
> investigation, thank you.
>
> Does the issue persist with latest release Inkscape 0.92?
> The Windows packages of Inkscape 0.92 include a copy of latest upstream
> version of scour (the python module which saves the optimized version of
> the SVG file).
>
> ** Changed in: inkscape
> Status: New => Incomplete
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1656663
>
> Title:
> Dimensions on saving as Optimized SVG
>
> Status in Inkscape:
> Incomplete
>
> Bug description:
> Running Inkscape 0.91 on Windows7 64x:
> On saving as Optimized SVG for includinding in .epub (as <img />), I
> keep checked the option to "set viewBox AND establish width/height to
> 100%"--BUT although I get the viewBox, I also get height="84.949mm"
> width="84.102mm" (or other measures--always mm, although my selection is
> for px as unit at document level).
> I find it rather annoying, for of course the image (usually a map) fails
> to strech in the viewer until--after some heartburning--I DO remember the
> issue and edit the dimensions by hand...
> Thanks!
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/1656663/+subscriptions
>

su_v (suv-lp)
Changed in inkscape:
status: Incomplete → New
tags: added: exporting extensions-plugins svg
Revision history for this message
Patrick Storz (ede123) wrote :

First of all the option was initially intended to add a viewbox if it was not present. Since Inkscape always adds a viewbox nowadays Scour can not freely rewrite it and additional care has to be taken not to rewrite the "viewBox" attribute in a way that might not be expected.

Therefore Scour will only remove the "width"/"height" attributes if they exactly match the values given in an already present "viewBox".

With that in mind there are multiple things to consider:
1. As the viewBox is always specified in "px", width and height must be specified in "px", too, otherwise the numbers will always differ and Scour will preserve them.
2. Inkscape 0.91 had a behavior that differed from what is done in 0.92 and it was important that the "standard units" were also specified in "px". Otherwise, as before, width/height would differ from the numbers in the viewbox.
3. When opening the SVG in Inkscape 0.92 you rescaled your image to account for the change in default DPI. That's fine but there's a discrepancy in width/height and viewbox attributes now (that's how the scaling is implemented). As a result Scour will never remove width/height attributes from your example file.
4. Even if all other points are considered rounding errors (both in Inkscape as well as in Scour) can result in discrepancies between the numbers in width/height and viewbox which will again prevent Scour from removing the viewBox attribute.

Maybe you can again attach the sample file from 0.91 so I can check what your original issue was. Now you're surely experiencing what I described in 3.

Revision history for this message
carmen fierro (cfierrob) wrote :

The attached pair are previous versions of the same drawing, all from
version 0.91.

Carmen

2017-01-15 20:12 GMT+01:00 Eduard Braun <email address hidden>:

> First of all the option was initially intended to add a viewbox if it
> was not present. Since Inkscape always adds a viewbox nowadays Scour can
> not freely rewrite it and additional care has to be taken not to rewrite
> the "viewBox" attribute in a way that might not be expected.
>
> Therefore Scour will only remove the "width"/"height" attributes if they
> exactly match the values given in an already present "viewBox".
>
> With that in mind there are multiple things to consider:
> 1. As the viewBox is always specified in "px", width and height must be
> specified in "px", too, otherwise the numbers will always differ and Scour
> will preserve them.
> 2. Inkscape 0.91 had a behavior that differed from what is done in 0.92
> and it was important that the "standard units" were also specified in "px".
> Otherwise, as before, width/height would differ from the numbers in the
> viewbox.
> 3. When opening the SVG in Inkscape 0.92 you rescaled your image to
> account for the change in default DPI. That's fine but there's a
> discrepancy in width/height and viewbox attributes now (that's how the
> scaling is implemented). As a result Scour will never remove width/height
> attributes from your example file.
> 4. Even if all other points are considered rounding errors (both in
> Inkscape as well as in Scour) can result in discrepancies between the
> numbers in width/height and viewbox which will again prevent Scour from
> removing the viewBox attribute.
>
> Maybe you can again attach the sample file from 0.91 so I can check what
> your original issue was. Now you're surely experiencing what I described
> in 3.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1656663
>
> Title:
> Dimensions on saving as Optimized SVG
>
> Status in Inkscape:
> New
>
> Bug description:
> Running Inkscape 0.91 on Windows7 64x:
> On saving as Optimized SVG for includinding in .epub (as <img />), I
> keep checked the option to "set viewBox AND establish width/height to
> 100%"--BUT although I get the viewBox, I also get height="84.949mm"
> width="84.102mm" (or other measures--always mm, although my selection is
> for px as unit at document level).
> I find it rather annoying, for of course the image (usually a map) fails
> to strech in the viewer until--after some heartburning--I DO remember the
> issue and edit the dimensions by hand...
> Thanks!
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/1656663/+subscriptions
>

Revision history for this message
Patrick Storz (ede123) wrote :

As for the Scour part of 4. I just filed
https://github.com/scour-project/scour/issues/127

As for the more general question if Scour should be more lenient with scaling (even a new option might be reasonable) see
https://github.com/scour-project/scour/issues/128
(Input by the community is always welcome as the available options should follow real world usage scenarios; not the other way round)

Revision history for this message
Patrick Storz (ede123) wrote :

Regarding sample file from comment #4:
- First of all you have to set the document units to "px" (otherwise you'll always hit number 1 above)
- Even then Scour will not yet remove width/height attributes as your sample file suffers from rounding errors in Inkscape: Original width="155.22223mm" which is 550.00002px (rounded to 8 significant digits) and this is the exact number set in the viewBox attribute. However if you change your document's units back to "px" Inkscape will round the 550.00002px down to 550px which differs from the value in the viewbox and therefore will be kept by Scour.

Revision history for this message
carmen fierro (cfierrob) wrote :

In view of your comments, I suspect that the present Scour will NEVER unset
width/height in my files. Reason: I don´t usually make original work, but
copy a map or a diagram from an existing illustration, Thus, I begin by
importing into a layer the original (usually a scanned file, more or less
edited with GIMP) AND asking Inkscape to resize to drawing.
As a matter of fact, I never look at dpi or page size (I usually unset
print resolution of pictures from Irfanview, as I never print): thus, the
only dimensions that make sense to me are the screen pixels, and those vary
with each picture.
As the final SVG is intented for an EPUB, the sensible approach (at least
for old people with failing eyesight) is to let maps strech as fully as can
be contrived without losing the proportions. And, if one doesn't want the
image full-screen, a DIV with "height=50%" or whatever, does the trick very
nicely for SVGs with viewBox AND height/width 100%.
Of couse, people targetting printers, instead of screens, have very
different needs--I dare say that's why Inkscape always tries to begin in a
page with some standard dimension or other...
Many thanks for your explanation.

Carmen

2017-01-15 20:50 GMT+01:00 Eduard Braun <email address hidden>:

> Regarding sample file from comment #4:
> - First of all you have to set the document units to "px" (otherwise
> you'll always hit number 1 above)
> - Even then Scour will not yet remove width/height attributes as your
> sample file suffers from rounding errors in Inkscape: Original
> width="155.22223mm" which is 550.00002px (rounded to 8 significant digits)
> and this is the exact number set in the viewBox attribute. However if you
> change your document's units back to "px" Inkscape will round the
> 550.00002px down to 550px which differs from the value in the viewbox and
> therefore will be kept by Scour.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1656663
>
> Title:
> Dimensions on saving as Optimized SVG
>
> Status in Inkscape:
> New
>
> Bug description:
> Running Inkscape 0.91 on Windows7 64x:
> On saving as Optimized SVG for includinding in .epub (as <img />), I
> keep checked the option to "set viewBox AND establish width/height to
> 100%"--BUT although I get the viewBox, I also get height="84.949mm"
> width="84.102mm" (or other measures--always mm, although my selection is
> for px as unit at document level).
> I find it rather annoying, for of course the image (usually a map) fails
> to strech in the viewer until--after some heartburning--I DO remember the
> issue and edit the dimensions by hand...
> Thanks!
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/1656663/+subscriptions
>

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.