Would something like this be possible? If you look at the octicons on github, they are cropped to fit the artwork bounds.
I know that illustrator and inkscape have these options, but I was wondering if such a task could be automated using npm scripts.
It's totally possible. Actually ātransformsWithOnePathā plugin computes BBox of the path (but for scaling). You need only to translate and resize the image (can be done jusy by amending viewBox). However, the plugin supports only relative coordinates commands (e.g. ālā but not āLā) and the task itself is not a SVGOs purpose.
Yea, it's not really in SVGOs domain. What would be the best way to go about the problem in your opinion?
Developing own SVGO plugin is totally fine I think.
I'll try. Still trying to understand how this all works :) Could use some help.
General information is in āHow it worksā doc.
That would be nice addition :+1:
I agree it's indeed seems to be a bit out of scope for svgo, however, from another perspective, it can be named as kind of optimization too.
There is a https://github.com/cncf/svg-autocrop project which does exactly this. It is used a lot in a cloud native computer foundation projects like landscape.cncf.io to automatically crop all svg files via calculating an ideal viewbox.
Most helpful comment
That would be nice addition :+1:
I agree it's indeed seems to be a bit out of scope for svgo, however, from another perspective, it can be named as kind of optimization too.