You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a suggestion for a plugin and request for issues which might arise.
SVG is most often used in a scalable context, so ultimately the actual units, width/height values, and scale don't matter. I'm proposing 2-3 passes: First, rescale everything in the SVG by the largest precision (this may make the file bigger if one outlier with high precision exists alongside lots of low-precision values, so something slightly less naive would be ideal, maybe find the median precision) such that all values are integers. Second, rescale the integer values again using GCD and rounding (eg gcd(100, 101) to gcd(100, 100)) until the rounding amount of any value is larger than a certain threshold in percent-changed. Third, further reduce by division by allowing the values to be real again (optional step since this won't usually have benefits)
This won't always produce a smaller file, but I think it'd be useful enough for certain cases. The purpose of this plugin would essentially be optimizing out the decimal points in paths and sizes and then reducing the lengths by fuzzy gcd to avoid degenerate cases like "21000".
Is there something I'm missing? Otherwise I could start working on it
The text was updated successfully, but these errors were encountered:
I have personally written scripts that do something very similar to this and I can attest that they work in reducing the size of SVG images. If done correctly removing the decimal dot is a lossless way of reducing svg file sizes, as the decimal point in every number contains no information and only bloats the markup.
Until this is implemented by someone, there exists a work-around if you want to do this without writing your own script. Just scale up the svg file to be at pixel resolution or higher and then optimize it with a zero precision, i.e:
svgo -p 0 filename
Last time I did this, it net me a 35.1% size reduction on the already svgo optimized image with zero pixel diff versus the previous image
This is a suggestion for a plugin and request for issues which might arise.
SVG is most often used in a scalable context, so ultimately the actual units, width/height values, and scale don't matter. I'm proposing 2-3 passes: First, rescale everything in the SVG by the largest precision (this may make the file bigger if one outlier with high precision exists alongside lots of low-precision values, so something slightly less naive would be ideal, maybe find the median precision) such that all values are integers. Second, rescale the integer values again using GCD and rounding (eg gcd(100, 101) to gcd(100, 100)) until the rounding amount of any value is larger than a certain threshold in percent-changed. Third, further reduce by division by allowing the values to be real again (optional step since this won't usually have benefits)
This won't always produce a smaller file, but I think it'd be useful enough for certain cases. The purpose of this plugin would essentially be optimizing out the decimal points in paths and sizes and then reducing the lengths by fuzzy gcd to avoid degenerate cases like "21000".
Is there something I'm missing? Otherwise I could start working on it
The text was updated successfully, but these errors were encountered: