3 ms·
Smart quantization of SVG paths sounds like a neat problem. Is there no existing tool for it already? Along the lines of pngcrush or similar. This may be too-s
by jhgb 5y ago
Smart quantization of SVG paths sounds like a neat problem. Is there no existing tool for it already? Along the lines of pngcrush or similar.
This may be too-stupid-to-work but what immediately comes to my mind is normalizing all coordinates into an [0,1]x[0,1] interval and then finding an optimal N so that the maximum rounding error for quantizing all coordinates to the nearest K/N (where K is a non-negative integer up to N) is minimal (for some definition of "optimal", since you have two criteria now - resulting path string length AND maximum rounding error achieved for a given N). Then all your coordinate components should be integers in the range of [0,N].
- pilaf 5y agoThere's SVGO (https://github.com/svg/svgo https://github.com/svg/svgo).
- jhgb 5y agoI knew there was something I forgot about; SVGO was probably it. Thanks!
- zuzun 5y agoThe problem is that the designers of small icons already work with pixel-snapping and for complex graphics, dumb quantization will look and compress no worse. If you want to work on path optimization, improve Inkscape's path simplification, because why bother with the alignment of a control point that isn't necessary in the first place!?
- jhgb 5y agoThis algorithm should find that very pixel snapping if it exists. Path simplification seems like a more complicated issue, but also promising of course.