我已经为此挣扎了一段时间,似乎在任何地方都找不到一个(有效的)答案。我有一个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)。如果我手动删除转换,图像将压缩到屏幕的另一部分(正如预期的那样),但我需要完全删除转换,同时让图像保持在我想要的位置。是否有一种方法可以移除/平展转换到路径坐标本身?(我唯一需要处理的变换是平移和缩放,没有矩阵。)


当前回答

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

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

其他回答

在方法绘制中加载SVG http://editor.method.ac(文件>打开图像) 取消元素组(Object > Ungroup elements),你可能需要做不止一次。 选择你的路径 重定向路径(对象>重定向路径)。 保存你的图像(文件>保存图像)如果它出现在一个新的窗口,你可以右键单击并“另存图像为…”

我找到了问题所在。我希望不必求助于罗伯特的回答,尽管我很高兴确认它会起作用!Duopixel的答案实际上是最接近的,尽管事实证明还有其他原因。

When you're working with different paths in Inkscape documents, I believe its default behaviour is to group them together under an <svg:g.../> tag. When modifying paths in a group, Inkscape will automatically add a transform to the group to represent these changes. However, if you open the XML editor and drag your path outside the <svg:g.../> tag and make it its own <svg:path.../> tag, Inkscape is free to edit the individual points at will. In the end it did turn out to be a grouping problem even though I was only working with one path! Hope this helps others in similar situations.

不知怎的,我没有任何一种方法的运气。如果有<defs>节在你的svg和用法如下:

<g transform="matrix( *** ) "><use xlink:href="#***"/></g>

您可能必须删除所有用法,并从defs节中取出所有内容。然后,你可以使用inkscape以正确的方式放置它,然后使用上面提到的插件应用转换。 希望它能帮助到别人。

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

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

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

这似乎是默认开启的。

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

如果你正在使用Inkscape,这是有效的:

选择所有内容并取消分组 另存为“优化Svg (*.svg)”

在我尝试过的所有情况下,这已经删除了任何转换属性。不确定它是否适用于更复杂的SVG。