Answer the question
In order to leave comments, you need to log in
How can I determine the height/width of an svg sprite and write it to a file (via CLI on Mac or Linux)?
I'm actually trying to create an svg sprite using the svg-sprite npm package . As a result, I get something like this sprite (for 2 pictures):
…
<svg viewBox="0 0 <b>108 54</b>" …>
<svg height="54" width="54" viewBox="-2 -2 54 54" …>
<path d=“…”>
</svg>
<svg height="54" width="54" viewBox="-2 -2 54 54" …>
<path d=“…”>
</svg>
</svg>
identify -format '%w' icons-test.svg
echo "\$spriteWidth = $(identify -format ‘%w’ icons-test.svg)px" >> styles.styl
Answer the question
In order to leave comments, you need to log in
Presumably imagemagick's SVG decoder doesn't understand some internal SVG tags.
It was advised to first convert the file to another format, for example like this:
For me it worked. Sometimes, though, errors like this are thrown:
But all the same width/height are defined correctly.
So I'll mark it as a solution. But if someone knows what caused / how to get rid of errors - write. Or if someone knows alternative solutions - too.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question