Non optimal SVG

Bug #390549 reported by xtempore on 2009-06-22
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Inkscape
Low
Unassigned

Bug Description

I love InkScape, but have noticed that the SVG produced is a lot fatter than it needs to be. At present I am using a custom script to trim down my files to more optimal values, but it is limited in how much it can do.

Some of the excess size is due to a lack of optimizations (which is more a feature request than a bug), but some of the excess I would consider to be a bug.

Here are some of my suggestions. Some of these could be done on the fly, others might be more suited to an "optimize function", where parameters could be entered. I hope they may be of use...

1. Don't define attributes if they are the default.
From the SVG spec - "Use default values whenever possible rather than defining all attributes and properties explicitly".

2. Remove text related attributes when converting to path.
It appears that even after converting text to a path, and even breaking up the path, the text attributes relating to font-size, etc remain in the attributes for the path (bug?).

3. Reduce number of decimals stored.
I've noticed that a lot of values are stored to a decimals precision far greater than is likely to be needed, especially after a transformation has occurred. For example a line width of "4.00000013" would probably be okay just as "4".
In some cases I have even seen values that use scientific notation for points. E.g. "4.10324234e-13" which would probably be better off as just "0".

4. Resolve transformations.
It would be nice to be able to force a transformation to be resolved down to the path level. I.e. If I have a group with paths in it, and the path has a transform on it then the transformation could be applied to every point in the path and then removed from the group. This would be straightforward for an x and y move, but would also be good to do for scaling.

5. Remove excess.
I'd love to see a function that could go one step further and remove all the inkscape/sovipodi specific tags/attributes, and also remove all unnecessary whitespace, to create a really tight SVG file.

Mon, 22 Jun 2009 07:24:41 -0000
xtempore <email address hidden> kirjoitti:

> 4. Resolve transformations.
> It would be nice to be able to force a transformation to be resolved
> down to the path level. I.e. If I have a group with paths in it,
> and the path has a transform on it then the transformation could be
> applied to every point in the path and then removed from the group.
> This would be straightforward for an x and y move, but would also be
> good to do for scaling.

Inkscape does this to some extent, but a transformed path and path with
resolved transformation aren't exactly the same thing. For example,
with filter effects applied, they can look completely different.

> 5. Remove excess.
> I'd love to see a function that could go one step further and remove
> all the inkscape/sovipodi specific tags/attributes, and also remove
> all unnecessary whitespace, to create a really tight SVG file.

inkscape and sodipodi specific attributes are removed when saving as
Plain SVG.

--
Niko Kiirala
<email address hidden>

Both existing stable version and prerelease of 0.47 some of the things you want:

(5) is handled for ages by saving to Plain SVG
(3) is handled in upcoming 0.47

Also, make sure you've seen http://www.codedread.com/scour/

Changed in inkscape:
importance: Undecided → Low
status: New → Confirmed
xtempore (jbriden) wrote :

Thanks Alexandre, especially for the link to SVG Scour. It looks like it does a lot of what I am already doing, but maybe can do even more.

tags: added: svg
su_v (suv-lp) on 2010-01-02
tags: added: saving
su_v (suv-lp) wrote :

> 2. Remove text related attributes when converting to path.

See also:
Bug #168720 “Text styles remain in type objects converted to paths.”

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers