Cut off digits after decimal point automatically?
Hi,
Is it possible to reduce the size of a SVG file by cutting off (some or all of) the digits of numbers behind the decimal point automatically? Can this be done within Inkscape or is it possible to write a script to extend Inkscape? (With regular expressions and a scripting laanguage it would be possible but I would like to know if a feature like this already exists.
It should work like this:
Before:
<path d="M 197.50906,180.93358 C 208.42611,171.19005 243.09749,175.25444 255.13174,160.93358 C 258.56906,156.84315 258.33300,147.20836 258.33300,140.93358" style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0585089px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000" id="path1310" />
After:
<path d="M 197,180 C 208,171 243,175 255,160 C 258,156 258,147 258,140"
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0585089px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000" id="path1310" />
Thanks in advance!
Best regards, Henning
Quoting Henning Pingel <henning.pingel@...26...>:
It should work like this:
Before:
<path d="M 197.50906,180.93358 C 208.42611,171.19005
243.09749,175.25444 255.13174,160.93358 C 258.56906,156.84315 258.33300,147.20836 258.33300,140.93358"
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0585089px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
id="path1310" />
After:
<path d="M 197,180 C 208,171 243,175 255,160 C 258,156 258,147
258,140"
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0585089px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
id="path1310" />
Thanks in advance!
It seems like the numbers like 0.75000000 would be better candidates for throwing out digits (as those zeroes are not significant).
For paths, throwing out the fractional part of all coordinates is likely to cause visible distortions.
-mental
On 11/17/05, mental@...32... <mental@...32...> wrote:
It seems like the numbers like 0.75000000 would be better candidates for throwing out digits (as those zeroes are not significant).
This is already done, and even mentioned in 0.43 release notes.
-- bulia byak Inkscape. Draw Freely. http://www.inkscape.org
On Thu, 17 Nov 2005, Henning Pingel wrote:
Date: Thu, 17 Nov 2005 15:46:25 +0100 (MET) From: Henning Pingel <henning.pingel@...26...> Reply-To: inkscape-user@lists.sourceforge.net To: inkscape-user@lists.sourceforge.net Subject: [Inkscape-user] Cut off digits after decimal point automatically?
Hi,
Is it possible to reduce the size
If you are really concerned about size then you should be using SVGZ, that is Gzip compressed SVG files. XML has a tendency to be verbose but Gzip compression is an ideal way to compensate for that and is an integral part of the SVG standard.
of a SVG file by cutting off (some or all of) the digits of numbers behind the decimal point automatically?
Now if you want cleaner more readable SVG that is another issue but knowing your real motivations will make it easier for developers to fix the real problem rather than treating the symptoms.
AFAIK work has already been committed to reduce this issue and at least trim the trailing zeros (I vaguely recall a bug report) and I strongly encourage you to try out a nightly build or even the testing prereleases for 0.43 (or check the RFE tracker).
With careful use of a Grid and Snap to Grid you might be able to futher reduce the complex decimals output in your SVG (or maybe not, but I'd at least try it).
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0585089px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000" id="path1310" />
Part of the reason I asked above if you are not only concerned about file size but are also interesed in issues like clarity of markup was because then there are other changes you might be interested in.
I previously asked about support for SVG tags like circle and rect rather than using paths for everything as it would produce much more readable code but it seems the techinical infrastructure required to allow this would be a lot of work and not practical at this time. (And I should clarifly that while I think it would be nice to have there are many other features which would be more important, nicer to have and easier to do.)
Another thing which might be helpful would be including some whitespace and more linebreaks to the style information (which gzip will do a fine job of compressing) because not only could this make the markup more readable it and would be a big help to anyone committing Inkscape SVG into a Version Control System like CVS or Subversion (which I assume is why Sodipodi added so many line breaks into the markup in the past).
(I'll try and remember to file a request, it is something I've been pondering but it isn't a big deal because most people dont tinker with the markup quite as obsessively as I like to do.)
Thanks in advance!
Sincerely
Alan Horkan
Inkscape http://inkscape.org Abiword http://www.abisource.com Dia http://gnome.org/projects/dia/ Open Clip Art http://OpenClipArt.org
Alan's Diary http://advogato.org/person/AlanHorkan/
participants (4)
-
unknown@example.com
-
Alan Horkan
-
bulia byak
-
Henning Pingel