Easy SVG Optimization - Sacrificing Accuracy

Over at the other post I mentioned a few possible optimization strategies. Reducing accuracy is one of the more obvious ones. It's a pretty well known technique, but so far I didn't really like that idea.

The problem is specifying the amount of digits is awfully indirect and lacks any context. As a user you don't really want this or that many digits, but pixel accuracy up to a specific size. Eg for web usage (with viewBox attribute) you may want something like pixel accuracy up to a width of 1600 pixels or the size of your canvas.

A dialog with 3 fields (width, height and digits), which updates the other values on change (similar to Inkscape's export as bitmap dialog), would solve this pretty elegantly. You can enter some width you have in mind, then you can try one digit less and maybe that accurate-up-to width is still alright, and you can go with that value. If it isn't, increase the digits by one (old value). Also if viewBox is used, one could get rid of the decimal places completely by scaling it up (and rounding it) accordingly.

It's not all that difficult to implement, but it's still really worth it. Some quick tests have shown that it can easily reduce the file size by about 30% (compressed or uncompressed) if there are some hefty paths.

Another idea is using that kind of thing as an effects extension, which allows you to reduce the number of digits on a path by path basis. You won't need much accuracy for heavy blurred things such as clouds for example and those paths can become really huge easily.

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options