我已经为此挣扎了一段时间,似乎在任何地方都找不到一个(有效的)答案。我有一个SVG文件,看起来像这样:

<svg

   xmlns:dc="http://purl.org/dc/elements/1.1/"
   ...
   width="72.9375"
   height="58.21875"
   ...>
   ...
   <g
     ...
     transform="translate(10.75,-308.96875)"
     style="...">
     <path
       inkscape:connector-curvature="0"
       d="m -10.254587,345.43597 c 0,-1.41732 0.17692,-2.85384 0.5312502,-3.5625 0.70866,-1.41733 2.14518,-2.82259 3.5625,-3.53125 1.41733,-0.70866 2.11392,-0.70867 3.53125,0 1.41732,0.70866 ... z"
       ... />
  </g>
</svg>

我想删除transform="…"行,但仍然有我的图像留在我已经放置它(在InkScape)。如果我手动删除转换,图像将压缩到屏幕的另一部分(正如预期的那样),但我需要完全删除转换,同时让图像保持在我想要的位置。是否有一种方法可以移除/平展转换到路径坐标本身?(我唯一需要处理的变换是平移和缩放,没有矩阵。)


当前回答

发现:

Set your desired page size* If your current layer has a transform (check with the XML editor, it's the top group under the SVG element) then create a new layer and move all objects to it Ungroup any groups (this may not be needed, YMMV) Select all objects and apply a null transform (such as scale by 100% 100%, or arrow right + arrow left) while having Store transformation: Optimized in Preferences / Transforms If you had to undo any groups, you can now regroup them Save a copy as Optimized SVG and set your desired numeric precision

*:或者至少把对象放在你需要它们的地方,相对于页面的左上角。不幸的是,SVG坐标引用左上角,而Inkscape则根据左下角调整页面大小!

其他回答

我的具体问题是在页面外定义的符号,因此需要在页面上显示转换。

为了在不需要转换的情况下将符号移动到页面上,我必须在Inkscape中执行以下步骤:

打开符号窗口(Shift+Ctrl+Y) 从文档库中删除该符号。(窗口里有个按钮。) 现在图形显示在文档中,在页面边界之外。 取消图形分组。(这是至关重要的一步!) 将图形移动到页面边界内。 将图形添加回符号库。

发现:

Set your desired page size* If your current layer has a transform (check with the XML editor, it's the top group under the SVG element) then create a new layer and move all objects to it Ungroup any groups (this may not be needed, YMMV) Select all objects and apply a null transform (such as scale by 100% 100%, or arrow right + arrow left) while having Store transformation: Optimized in Preferences / Transforms If you had to undo any groups, you can now regroup them Save a copy as Optimized SVG and set your desired numeric precision

*:或者至少把对象放在你需要它们的地方,相对于页面的左上角。不幸的是,SVG坐标引用左上角,而Inkscape则根据左下角调整页面大小!

在我的例子中,保存为优化的SVG解决了这个问题。所以在Inkscape的使用中:

File ->另存为…->优化SVG。

Inkscape可以清除转换数据,但仍然保留对象的值不被修改。

在Inkscape中,选择对象和“路径”菜单,“简化”。 现在,您将删除转换。

需要提到的是,在首选项中有“优化”模式:

Inkscape首选项>转换>存储转换>优化

这应该尽可能地减少transform属性的出现(但没有)。

这似乎是默认开启的。

根据讨论,这种优化模式缺乏热情的一个实例是页面调整大小时。这将导致翻译转换应用于<g>层元素。目前看来,把孩子们疏散到另一层是最好的解决办法。