1

我在 INKSCAPE 中创建 SVG 绘图时使用mm作为单位,对于我正在处理的程序,我需要将所有形状的单位转换为pts

有什么方法可以将 SVG 中每个 xml 标签的单位从mm转换为pt最好使用Python3 else Inkscape 命令行

(ie) 转换下面的 SVG

<svg
   width="108mm"
   height="108mm"
   viewBox="0 0 108 108"
   version="1.1"
   id="svg5"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
    @@ -38,46 +38,46 @@
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-52.715782,-77.867737)">
    <g
       id="g738">
      <circle
         style="fill:#000000;stroke-width:0"
         id="path53"
         cx="106.71578"
         cy="131.86774"
         r="54" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="path179"
         cx="106.71578"
         cy="131.86774"
         r="17.5" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle261"
         cx="106.71578"
         cy="92.367737"
         r="8" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle263"
         cx="106.71578"
         cy="171.36774"
         r="8" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle722"
         cx="131.86774"
         cy="-146.21579"
         r="8"
         transform="rotate(90)" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle724"
         cx="131.86774"
         cy="-67.215782"
         r="8"
         transform="rotate(90)" />
    </g>
  </g>

<svg
   width="306.1422pt"
   height="306.1422pt"
   viewBox="0 0 306.1422 306.1422"
   version="1.1"
   id="svg5"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
    @@ -38,46 +38,46 @@
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-149.4307914463,-220.72778068705)">
    <g
       id="g738">
      <circle
         style="fill:#000000;stroke-width:0"
         id="path53"
         cx="302.501885777"
         cy="373.798889191"
         r="153.0711" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="path179"
         cx="302.501885777"
         cy="373.798889191"
         r="49.606375" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle261"
         cx="302.501885777"
         cy="261.83020568705"
         r="22.6772" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle263"
         cx="302.501885777"
         cy="485.76756419099996"
         r="22.6772" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle722"
         cx="373.798889191"
         cy="-414.47058912349996"
         r="22.6772"
         transform="rotate(90)" />
      <circle
         style="fill:#ffffff;stroke-width:0"
         id="circle724"
         cx="373.798889191"
         cy="-190.5332164463"
         r="22.6772"
         transform="rotate(90)" />
    </g>
  </g>

请注意,在给定的示例(仅由圆圈组成)中,转换发生在以下属性

宽度、高度、viewBox、transform()、r、cx 和 cy

需要适用于所有形状和路径 xml 标记的通用解决方案

编辑:请注意,这里没有进行缩放。(即)108mm = 306.1422pt 等等。

提前致谢

4

0 回答 0