ben-eb/gulp-svgmin

Should cleanupNumericValues clean up viewBox and paths?

terryupton opened this issue · 2 comments

I wanted to check if cleanupNumericValues should actually cleanup viewBox and paths?
I have used it like so;
.pipe($.svgmin({ plugins: [{ removeDimensions: true }, { cleanupNumericValues: { floatPrecision: 1 } }] }))

But the output SVG files come out like;
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 456.814 456.814"><path d="M441.11 252.677c10.468-11.99 15.704-26.169 15.704-42.54 0-14.846-5.432-27.692-16.259-38.547-10.849-10.854-23.695-16.278-38.541-16.278h-79.082c.76-2.664 1.522-4.948 2.282-6.851.753-1.903 1.811-3.999 3.138-6.283 1.328-2.285 2.283-3.999 2.852-5.139 3.425-6.468 6.047-11.801 7.857-15.985 1.807-4.192 3.606-9.9 5.42-17.133 1.811-7.229 2.711-14.465 2.711-21.698 0-4.566-.055-8.281-.145-11.134-.089-2.855-.574-7.139-1.423-12.85-.862-5.708-2.006-10.467-3.43-14.272-1.43-3.806-3.716-8.092-6.851-12.847-3.142-4.764-6.947-8.613-11.424-11.565-4.476-2.95-10.184-5.424-17.131-7.421-6.954-1.999-14.801-2.998-23.562-2.998-4.948 0-9.227 1.809-12.847 5.426-3.806 3.806-7.047 8.564-9.709 14.272-2.666 5.711-4.523 10.66-5.571 14.849-1.047 4.187-2.238 9.994-3.565 17.415-1.719 7.998-2.998 13.752-3.86 17.273-.855 3.521-2.525 8.136-4.997 13.845-2.477 5.713-5.424 10.278-8.851 13.706-6.28 6.28-15.891 17.701-28.837 34.259-9.329 12.18-18.94 23.695-28.837 34.545-9.899 10.852-17.131 16.466-21.698 16.847-4.755.38-8.848 2.331-12.275 5.854-3.427 3.521-5.14 7.662-5.14 12.419v183.01c0 4.949 1.807 9.182 5.424 12.703 3.615 3.525 7.898 5.38 12.847 5.571 6.661.191 21.698 4.374 45.111 12.566 14.654 4.941 26.12 8.706 34.4 11.272 8.278 2.566 19.849 5.328 34.684 8.282 14.849 2.949 28.551 4.428 41.11 4.428h36.831c25.321-.38 44.061-7.806 56.247-22.268 11.036-13.135 15.697-30.361 13.99-51.679 7.422-7.042 12.565-15.984 15.416-26.836 3.231-11.604 3.231-22.74 0-33.397 8.754-11.611 12.847-24.649 12.272-39.115.024-6.097-1.4-13.328-4.261-21.706zM100.5 191.864H18.276c-4.952 0-9.235 1.809-12.851 5.426C1.809 200.905 0 205.188 0 210.137v182.732c0 4.942 1.809 9.227 5.426 12.847 3.619 3.611 7.902 5.421 12.851 5.421H100.5c4.948 0 9.229-1.81 12.847-5.421 3.616-3.62 5.424-7.904 5.424-12.847V210.137c0-4.949-1.809-9.231-5.424-12.847-3.617-3.618-7.898-5.426-12.847-5.426zM67.665 369.308c-3.616 3.521-7.898 5.281-12.847 5.281-5.14 0-9.471-1.76-12.99-5.281-3.521-3.521-5.281-7.85-5.281-12.99 0-4.948 1.759-9.232 5.281-12.847 3.52-3.617 7.85-5.428 12.99-5.428 4.949 0 9.231 1.811 12.847 5.428 3.617 3.614 5.426 7.898 5.426 12.847 0 5.14-1.805 9.468-5.426 12.99z"/></svg>

Is this a bug or have I misunderstood what cleanupNumericValues does or how to use it?

Thanks.

cleanupNumericValues does not alter paths, but it does apply to the viewBox since v1.0.0 of svgo. However, this plugin still relies on an older version of the package.

This seems to round viewBox and path numbers:

plugins: [
    {
      convertPathData: {
        floatPrecision: 1
      }
    },
    {
      cleanupListOfValues: {
        floatPrecision: 1
      }
    }
  ]

Hey @terryupton, please could you report this to https://github.com/svg/svgo if you are still having this issue? This plugin is a thin wrapper on top of svgo to use it with gulp, and so this is better reported upstream. Thanks. 👍