Precision 0 not removing assumed-to-be-removable decimal places
burntcustard opened this issue · comments
I threw an SVG into SVGOMG and expected to be able to remove some decimal places by reducing the precision slider to 0, but got unexpected results, with precision 0 being almost identical to precision 1, in that it had removed some but not all of the decimal places:
Precision 2
<linearGradient id="d" x1="429.25" x2="2060.11" y1="1381.38" y2="1949.74" gradientUnits="userSpaceOnUse">
...
</linearGradient>
Precision 1
<linearGradient id="d" x1="429.3" x2="2060.1" y1="1381.4" y2="1949.7" gradientUnits="userSpaceOnUse">
...
</linearGradient>
Precision 0
<linearGradient id="d" x1="429.3" x2="2060.1" y1="1381.4" y2="1949.7" gradientUnits="userSpaceOnUse">
...
</linearGradient>
I had perhaps incorrectly assumed that 0
meant "as un-precise as possible". I'm not sure if this is specifically an SVGOMG or an SVGO issue, and I'm not 100% sure what the desired solution would be. Either there's something going wrong, which is resulting in the lower precision values incorrectly not being rounded, or it is intended behaviour, but then a) it's not clear what 0
means, and b) maybe an even lower (-1
?) option would be helpful for situations like mine?
Entire SVG code
Click to view
<svg xmlns="http://www.w3.org/2000/svg" width="1400" height="564" fill="none">
<path fill="url(#a)" fill-rule="evenodd" d="M0 .00006104h1400V564L0 563.995V.00006104Z" clip-rule="evenodd"/>
<mask id="c" width="1400" height="565" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha">
<path fill="url(#b)" fill-rule="evenodd" d="M0 .00006104h1400V564L0 563.995V.00006104Z" clip-rule="evenodd"/>
</mask>
<g mask="url(#c)">
<circle cx="1452.37" cy="1009.37" r="891.917" fill="url(#d)" opacity=".3" style="mix-blend-mode:luminosity" transform="rotate(-165 1452.37 1009.37)"/>
<path fill="url(#e)" d="M1633.16-41h894v894h-894z" opacity=".2" style="mix-blend-mode:luminosity" transform="rotate(45 1633.16 -41)"/>
<path fill="url(#f)" d="M1591.3 962.153h894v894h-894z" opacity=".4" style="mix-blend-mode:luminosity" transform="rotate(135 1591.3 962.153)"/>
<circle cx="85" cy="-62" r="485" fill="url(#g)" opacity=".2" style="mix-blend-mode:luminosity"/>
</g>
<defs>
<linearGradient id="a" x1="-708.046" x2="-346.963" y1="266" y2="1207.52" gradientUnits="userSpaceOnUse">
<stop stop-color="#FC895B"/>
<stop offset="1" stop-color="#FF268B"/>
</linearGradient>
<linearGradient id="b" x1="-708.046" x2="-346.963" y1="266" y2="1207.52" gradientUnits="userSpaceOnUse">
<stop stop-color="#FC895B"/>
<stop offset="1" stop-color="#FF268B"/>
</linearGradient>
<linearGradient id="d" x1="429.251" x2="2060.11" y1="1381.38" y2="1949.74" gradientUnits="userSpaceOnUse">
<stop stop-color="#fff"/>
<stop offset="1" stop-color="#fff" stop-opacity=".01"/>
</linearGradient>
<linearGradient id="e" x1="1673.61" x2="1673.61" y1="1.89055" y2="814.975" gradientUnits="userSpaceOnUse">
<stop stop-color="#fff"/>
<stop offset="1" stop-color="#fff" stop-opacity=".01"/>
</linearGradient>
<linearGradient id="f" x1="1631.76" x2="1631.76" y1="1005.04" y2="1818.13" gradientUnits="userSpaceOnUse">
<stop stop-color="#fff"/>
<stop offset="1" stop-color="#fff" stop-opacity=".01"/>
</linearGradient>
<linearGradient id="g" x1="-471.344" x2="415.472" y1="140.288" y2="449.345" gradientUnits="userSpaceOnUse">
<stop stop-color="#fff"/>
<stop offset="1" stop-color="#fff" stop-opacity=".01"/>
</linearGradient>
</defs>
</svg>
After a little investigating I found this snippet:
svgomg/src/js/svgo-worker/index.js
Lines 48 to 54 in b925d7a
Which I suspect has something to do with my issue. I could attempt to look into the root cause of
cleanupNumbericValues
with a value of 0
breaking images in SVGO? Or perhaps adding a -1
to the precision slider, or yet another feature toggle of "Allow potentially breaking rounding" would be more likely to be helpful?