svg / svgo

⚙️ Node.js tool for optimizing SVG files
https://svgo.dev/
MIT License
21.02k stars 1.39k forks source link

convertTransform moves object till -p 9 #988

Open JoKalliauer opened 6 years ago

JoKalliauer commented 6 years ago

Prozessing File:Pereslavl_narrow_gauge_railway_1990.svg with

svgo -i ${file} -o output.svg --pretty --indent=1 -p 9

leads to moving of an text

transform="matrix(.9988 .0485 -.0485 .9988 2224.9 64.96)" is changed to transform="rotate(2.807 -204.22400571 45879.279769213)"


input.svg.txt

<svg viewBox="2100 0 300 100" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" font-family="MS Shell Dlg 2" stroke-linecap="square" stroke-linejoin="bevel" font-weight="400" font-size="38">
    <text transform="matrix(.9989 .0469 -.0469 .9989 2327.7 60.77)">5</text>
    <text transform="matrix(.9984 -.0561 .0561 .9984 2307.9 61.94)">2</text>
    <text transform="matrix(.9968 -.0791 .0791 .9968 2287.2 63.58)">5</text>
    <text transform="matrix(.9968 -.0791 .0791 .9968 2266.3 65.24)">0</text>
    <text transform="matrix(.9976 -.0681 .0681 .9976 2252.2 66.21)">-</text>
    <text transform="matrix(.9988 .0485 -.0485 .9988 2224.9 64.96)">Н</text>
    <text transform="matrix(.9951 .0986 -.0986 .9951 2203.5 62.85)">8</text>
    <text transform="matrix(.9961 .0884 -.0884 .9961 2182.7 61)">7</text>
</svg>

input


output.svg.txt

<svg viewBox="2100 0 300 100" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" font-family="MS Shell Dlg 2" stroke-linecap="square" stroke-linejoin="bevel" font-weight="400" font-size="38">
 <text transform="rotate(2.688 -131.606855627 49634.216791923)">
  5
 </text>
 <text transform="matrix(.9984 -.0561 .0561 .9984 2307.9 61.94)">
  2
 </text>
 <text transform="matrix(.9968 -.0791 .0791 .9968 2287.2 63.58)">
  5
 </text>
 <text transform="matrix(.9968 -.0791 .0791 .9968 2266.3 65.24)">
  0
 </text>
 <text transform="matrix(.9976 -.0681 .0681 .9976 2252.2 66.21)">
  -
 </text>
 <text transform="rotate(2.807 -204.22400571 45879.279769213)">
  Н
 </text>
 <text transform="matrix(.9951 .0986 -.0986 .9951 2203.5 62.85)">
  8
 </text>
 <text transform="matrix(.9961 .0884 -.0884 .9961 2182.7 61)">
  7
 </text>
</svg>

output

JoKalliauer commented 1 year ago

The best result is obtained by using "Transform precission"=2 much better than with "Transform precission"=8. (tested with SVGomg using svgo 3.0.0)