如何将 SVG 图像裁剪到矢量图形元素的边界框
我这里有一个 SVG 图像是用“空白”生成的,即只有左上角是图片内容,其余都是空白。我认为完全可能有一种自动方式将图像大小裁剪到对象的边界框 - 至少对于像 rsvg 这样的一些 svg 工具来说是这样。但是我无法找到“命令行技巧”,等等。
我想在命令行上执行此操作(即作为构建脚本的一部分)
原则上我会对同一问题的解决方案感兴趣,但是也适用于基于像素的格式,例如 PNG。
I have a SVG image herewhich is generated with 'empty space', i.e. only in the top-left corner is image content, whereas the rest is blank. I think it should be trivially possible to have an automated way to crop the image size to the bounding box of the objects - at least for some svg tooling like rsvg. However I am unable to find the 'command line trick' for this, etc.
I would like to do this on the command line (i.e. as part of a build script)
In principle I would be interested in a solution to the same problem but for pixel-based formats such as PNG as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
rsvg 没有解决此问题的命令行实用程序,但 Inkscape 在其非 GUI 模式下具有:
将文件裁剪为文档所有对象的边界框。有关 inkscape 命令行选项的完整文档,请参阅 手册页。特别注意用于批量处理多个图像的
--shell
模式。对于基于像素的格式,有 imagemagick
-trim
选项:rsvg does not have command line utilities for this problem, but Inkscape in its non-GUI mode has:
will crop the file to the bounding box of all objects of the document. See the man page for a full documentation of the inkscape command line options. Especially note the
--shell
mode for batch processing multiple images.For pixel-based formats there is the imagemagick
-trim
option: