oslllo / svg-fixer

Converts SVG Strokes To Fill.
https://docs.oslllo.com/svg-fixer/master/
MIT License
208 stars 16 forks source link

Doesn't work with dimensions in mm #53

Closed LeoBound closed 3 years ago

LeoBound commented 3 years ago

Hi,

I have a large batch of SVGs but they have their widths and heights in mm.

When I try to process them with .fix() I get the following error:

C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg2\src\error.js:13
        return new TypeError(
               ^

TypeError: Expected <a valid dimension i.e 20px, 20rem, 20em or 20> for [input] but received 147.26401mm of type <string>
    at Object.invalidParameterError (C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg2\src\error.js:13:9)
    at Svg.dimensionToPx (C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg2\src\svg.js:115:16)
    at Svg.dimensions (C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg2\src\svg.js:155:45)
    at Svg.getOriginal (C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg-fixer\src\svg.js:38:36)
    at new Svg (C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg-fixer\src\svg.js:14:24)
    at C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg-fixer\src\processor.js:74:19
    at new Promise (<anonymous>)
    at Processor.instance (C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg-fixer\src\processor.js:72:12)
    at C:\Users\LBound\Desktop\Test\node_modules\oslllo-svg-fixer\src\processor.js:43:22
    at new Promise (<anonymous>)

Is there a way to either allow processing of these files or batch convert them to one of the allowed size formats?

Thanks

Ghustavh97 commented 3 years ago

@LeoBound Hi, thanks for the issue.

I had no idea mm was unit used in svgs TIL. Could you please provide me with one or two samples for my test cases please.

Ghustavh97 commented 3 years ago

Also to answer the question, no the package only supports px rem and em since all dimesions need to be converted to px in order for them to be processed without distorting the proportions, but I think I can add support for mm too.

LeoBound commented 3 years ago

Here's a couple of examples: ICONS.zip This is what the inkscape wiki has to say about possible units: https://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape#Generic_SVG

Ghustavh97 commented 3 years ago

@LeoBound please try v1.4.0

LeoBound commented 3 years ago

@Ghustavh97 Works perfectly, thanks!