我有一个 xml 文件,它是验证码图像的 xml 代码。如何在 bash 脚本中将其转换为常规图像。
<svg xmlns="http://www.w3.org/2000/svg\" width="150\" height="50\" viewBox="0,0,150,50\">
<path d="M17 25 C70 44,69 26,142 37\" stroke="#666\" fill="none\" />
<path d="M14 33 C83 29,85 27,144 9\" stroke="#333\" fill="none\" />
<path d="M6 17 C79 22,85 41,142 44\" stroke="#666\" fill="none\" />
<path fill="#333\" d="M117.70 40.31L117.85 40.45L117.81 40.41Q113.74 40.64 112.75 38.32L112.72 38.29L112.64 38.22Q113.37 37.23 114.93 35.45L115.04 35.55L115.09 35.60Q115.62 37.65 118.63 37.77L118.44 37.58L118.58 37.72Q121.85 37.68 123.49 36.35L123.55 36.41L123.59 36.45Q124.87 34.72 124.80 32.02L124.99 32.22L124.97 32.20Q124.67 26.99 119.87 27.21L119.86 27.20L119.95 27.29Q117.16 27.46 115.40 28.72L115.43 28.75L115.12 28.59L114.78 28.32L114.82 28.37Q115.10 25.15 114.99 22.40L115.16 22.57L115.07 22.48Q114.91 19.82 114.57 16.50L114.64 16.58L114.55 16.48Q118.30 17.53 122.11 17.42L122.03 17.34L122.07 17.38Q125.81 17.24 129.39 15.98L129.40 15.99L128.99 17.67L128.90 17.59Q128.60 18.35 128.41 19.19L128.32 19.10L128.45 19.23Q125.26 20.19 121.38 20.19L121.48 20.29L121.42 20.23Q119.93 20.19 118.45 20.04L118.38 19.97L118.41 20.00Q118.32 20.67 117.97 25.12L118.00 25.15L118.03 25.18Q118.85 24.70 120.91 24.55L120.93 24.58L120.94 24.59Q124.62 24.77 126.07 26.44L126.06 26.43L126.17 26.54Q127.46 27.98 127.72 31.83L127.71 31.81L127.74 31.85Q127.94 35.97 126.72 37.98L126.85 38.11L126.70 37.96Q124.82 40.01 121.51 40.23L121.43 40.15L121.43 40.15Q120.38 40.16 117.71 40.32ZM123.91 42.74L123.82 42.66L123.83 42.66Q127.32 42.81 129.23 41.71L129.14 41.62L129.22 41.70Q130.07 40.04 130.07 37.95L130.05 37.92L130.22 38.09Q130.08 34.87 129.13 30.76L129.12 30.75L129.28 30.91Q128.74 29.00 127.52 27.59L127.69 27.76L127.73 27.84L127.32 27.35L127.04 27.22L127.08 27.26Q126.68 26.45 126.04 25.76L126.05 25.77L126.02 25.78L126.14 25.90Q124.49 24.10 120.80 24.10L120.97 24.27L120.66 24.23L120.61 24.18Q120.72 23.64 120.91 22.53L120.92 22.55L120.87 22.50Q125.80 22.55 129.83 20.91L129.99 21.07L129.90 20.98Q130.34 19.60 131.29 16.78L131.30 16.79L129.16 17.70L129.28 17.82Q129.63 16.64 130.12 15.50L130.07 15.45L130.03 15.40Q126.29 16.95 122.18 17.03L122.12 16.97L122.18 17.03Q118.09 17.17 114.13 16.06L114.10 16.03L114.12 16.05Q114.72 20.39 114.72 24.80L114.74 24.82L114.79 24.87Q114.64 26.63 114.53 28.53L114.60 28.60L114.61 28.61Q114.88 28.80 115.45 29.11L115.43 29.09L115.52 29.18Q115.83 28.92 116.48 28.57L116.39 28.49L116.42 28.52Q116.43 29.32 116.20 30.85L116.12 30.77L116.09 30.74Q116.64 31.06 117.06 31.29L117.11 31.34L117.06 31.29Q119.77 29.47 121.64 29.47L121.67 29.50L121.61 29.44Q123.04 29.54 124.22 30.19L124.07 30.04L124.22 30.19Q124.51 31.17 124.55 32.12L124.64 32.21L124.62 32.19Q124.67 34.75 123.64 35.85L123.61 35.82L123.63 35.84Q122.32 37.12 120.08 37.35L119.99 37.27L120.07 37.34Q119.06 37.36 118.38 37.29L118.41 37.32L118.44 37.35Q117.58 37.22 116.82 36.87L116.69 36.74L116.72 36.58L116.56 36.65L116.62 36.71Q115.84 36.23 115.30 34.90L115.18 34.78L115.30 34.90Q114.01 36.35 112.34 38.48L112.22 38.37L112.23 38.38Q112.49 38.97 113.32 39.93L113.35 39.95L113.37 39.97Q114.45 41.81 117.26 42.30L117.24 42.28L117.29 42.33Q118.45 42.54 123.82 42.65Z\" />
<path fill="#333\" d="M95.00 28.68L94.97 28.65L94.93 28.61Q92.19 28.69 91.43 30.93L91.28 30.78L91.32 30.83Q91.04 31.50 90.93 32.15L91.08 32.30L90.93 32.15Q93.66 32.48 95.30 32.48L95.17 32.35L95.16 32.34Q96.89 32.43 99.47 32.32L99.42 32.27L99.41 32.25Q99.42 30.67 98.01 29.60L98.05 29.64L98.00 29.58Q96.73 28.62 94.94 28.62ZM94.99 41.16L95.09 41.25L94.93 41.10Q90.74 41.13 89.45 39.73L89.50 39.78L89.46 39.74Q88.56 38.34 88.41 35.07L88.32 34.98L88.38 35.05Q88.33 34.76 88.25 33.39L88.40 33.54L88.36 33.50Q88.14 31.11 88.14 30.39L88.12 30.36L88.19 30.44Q88.13 28.51 88.86 27.41L88.82 27.37L88.86 27.41Q90.22 25.96 93.19 25.96L93.34 26.11L94.83 26.04L94.90 26.10Q96.82 25.97 98.35 26.28L98.46 26.39L98.40 26.34Q100.50 26.84 101.49 28.05L101.39 27.96L101.47 28.03Q102.03 29.04 102.10 31.14L102.25 31.28L102.27 31.31Q102.16 32.34 102.20 34.51L102.26 34.57L102.26 34.57Q99.40 34.60 96.62 34.60L96.62 34.60L91.01 34.59L91.03 34.60Q91.00 38.85 95.08 38.62L95.21 38.75L95.07 38.61Q98.91 38.49 100.13 36.66L100.08 36.61L100.25 36.78Q101.11 37.30 102.71 38.48L102.62 38.39L102.71 38.49Q101.35 40.90 97.20 41.16L97.08 41.04L97.09 41.05Q96.38 41.10 95.01 41.18ZM97.24 43.44L97.32 43.52L97.33 43.53Q98.40 43.46 99.61 43.53L99.66 43.58L99.69 43.61Q104.67 43.80 105.59 41.02L105.48 40.92L105.53 40.96Q103.94 39.75 102.84 38.99L102.91 39.07L102.73 38.88Q102.99 38.57 103.18 38.35L103.22 38.38L103.09 38.25Q102.52 37.95 101.15 37.00L100.97 36.82L101.07 36.92Q102.16 36.98 104.22 37.29L104.21 37.28L104.12 37.19Q104.00 35.89 103.92 35.21L103.92 35.20L103.76 33.25L103.77 33.26Q103.59 30.87 102.94 29.39L103.08 29.53L103.06 29.51Q102.83 29.20 102.26 28.59L102.15 28.48L102.20 28.54Q102.00 28.18 101.77 27.61L101.72 27.56L101.86 27.69Q99.79 25.48 94.73 25.48L94.86 25.61L93.14 25.57L93.05 25.48Q89.88 25.54 88.44 27.03L88.41 27.00L88.42 27.01Q87.73 28.11 87.77 30.17L87.76 30.15L87.83 30.23Q87.96 31.27 88.07 33.52L88.00 33.45L88.00 33.44Q88.16 35.12 88.27 37.18L88.28 37.19L88.21 37.12Q88.44 39.33 89.32 40.40L89.31 40.39L89.31 40.38Q89.59 40.67 89.78 40.78L89.77 40.77L89.89 41.24L89.89 41.23Q90.69 43.10 97.28 43.49ZM95.18 38.30L95.16 38.29L95.12 38.25Q93.96 38.34 93.04 37.88L93.03 37.87L93.14 37.98Q93.03 37.53 92.84 36.84L92.93 36.93L92.83 36.82Q94.60 36.81 96.20 36.81L96.24 36.85L96.14 36.74Q97.90 36.83 99.57 36.94L99.46 36.83L99.55 36.92Q98.17 38.17 95.16 38.29ZM96.84 30.98L96.84 30.98L96.77 30.91Q97.49 31.02 98.82 31.40L98.85 31.43L98.93 31.70L99.01 31.97L99.04 32.00Q97.60 32.04 96.68 32.00L96.69 32.01L96.67 31.98Q94.41 31.98 94.38 31.98L94.31 31.91L94.37 31.97Q95.07 31.00 96.74 30.88Z\" />
<path fill="#333\" d="M21.52 29.75L21.47 29.70L21.53 29.77Q17.26 29.49 16.69 32.54L16.69 32.54L16.67 32.52Q16.60 33.70 16.79 34.58L16.75 34.54L16.76 34.55Q16.71 35.26 17.16 36.66L17.19 36.69L17.16 36.66Q18.26 39.86 21.58 39.71L21.61 39.74L21.52 39.65Q23.61 39.80 24.94 38.24L24.93 38.23L24.91 38.20Q26.08 36.67 26.08 34.62L26.20 34.74L26.07 34.61Q26.41 34.22 26.26 33.16L26.20 33.10L26.25 33.15Q26.07 32.14 25.65 31.45L25.59 31.39L25.62 31.42Q24.11 29.86 21.52 29.75ZM26.28 48.14L26.30 48.16L26.44 48.30Q24.57 48.83 16.50 49.21L16.52 49.23L16.46 49.18Q14.80 49.27 13.17 48.43L13.20 48.47L13.18 48.44Q13.96 47.43 15.78 45.64L15.74 45.60L15.69 45.55Q18.18 46.67 20.28 46.48L20.33 46.53L20.20 46.40Q23.12 46.16 23.96 45.89L23.99 45.93L24.03 45.96Q26.31 45.31 26.31 43.52L26.26 43.48L26.29 43.51Q26.16 43.15 26.09 42.92L26.16 43.00L26.11 41.47L26.05 41.40Q26.13 40.72 26.13 39.92L26.00 39.79L26.06 39.85Q24.60 42.01 21.21 42.01L21.31 42.10L21.27 42.06Q17.44 42.12 15.80 39.91L15.82 39.93L15.87 39.97Q14.77 38.45 13.97 34.04L13.95 34.02L13.94 34.01Q13.53 32.39 13.53 30.98L13.54 30.98L13.54 30.98Q13.58 29.24 14.50 28.25L14.48 28.24L14.46 28.22Q16.23 26.90 20.87 26.90L20.86 26.89L22.62 27.08L22.47 26.94Q25.79 27.40 27.12 29.34L27.08 29.30L27.13 29.35Q27.29 28.48 27.71 26.85L27.69 26.82L27.78 26.91Q29.60 26.53 31.35 25.80L31.25 25.70L31.27 25.73Q28.63 31.84 28.63 39.07L28.55 38.99L28.57 39.01Q28.51 41.62 28.89 44.24L28.92 44.28L28.96 44.31Q29.24 45.09 29.16 45.77L29.11 45.72L29.07 45.68Q28.89 47.06 27.67 47.82L27.72 47.86L27.62 47.77Q27.19 48.10 26.35 48.22ZM29.23 51.05L29.42 51.24L29.25 51.07Q30.73 51.15 31.49 50.20L31.59 50.29L31.67 50.37Q32.00 49.41 31.89 48.69L31.87 48.67L31.73 48.53Q31.59 47.86 31.40 47.10L31.45 47.15L31.53 47.23Q30.22 41.92 30.56 36.66L30.54 36.64L30.60 36.70Q30.98 31.29 33.11 26.45L33.03 26.37L30.93 27.33L31.06 27.45Q31.33 26.88 31.56 26.31L31.51 26.27L31.91 25.02L32.04 25.16Q29.56 25.99 27.35 26.41L27.45 26.51L27.38 26.43Q27.15 27.39 27.00 28.42L26.90 28.32L27.00 28.41Q24.70 26.31 20.67 26.31L20.71 26.35L18.97 26.37L19.06 26.46Q15.86 26.49 14.19 27.90L14.07 27.79L14.19 27.91Q13.28 28.90 13.32 30.80L13.33 30.81L13.23 30.71Q13.35 33.27 14.38 37.54L14.39 37.55L14.23 37.39Q14.81 39.41 16.02 40.82L16.02 40.82L16.33 41.12L16.30 41.09L16.40 41.19Q17.57 43.54 20.16 44.08L20.05 43.96L20.03 43.95Q21.58 44.39 23.02 44.43L22.99 44.40L23.00 44.40Q24.75 44.45 25.82 44.07L25.67 43.91L25.70 43.95Q25.07 45.49 22.41 45.83L22.47 45.89L22.48 45.90Q21.44 46.08 20.75 46.08L20.77 46.09L20.38 46.09L20.35 46.06Q17.58 46.11 15.91 45.16L15.90 45.15L14.13 46.81L14.23 46.90Q13.30 47.65 12.46 48.60L12.47 48.61L12.44 48.58Q13.48 49.16 14.47 49.35L14.51 49.40L13.59 50.22L13.62 50.26Q16.33 51.33 21.97 51.33L21.97 51.33L22.18 51.31L22.11 51.24Q25.74 51.26 29.32 51.14ZM23.36 32.01L23.30 31.96L23.43 32.08Q24.76 32.04 25.67 32.46L25.60 32.38L25.55 32.34Q25.84 32.93 25.91 33.61L25.79 33.49L25.91 33.61Q25.97 33.93 25.93 34.85L25.90 34.82L25.96 34.88Q25.72 36.62 24.62 37.91L24.75 38.04L24.73 38.03Q23.57 39.45 21.67 39.42L21.66 39.41L21.54 39.29Q20.14 39.26 19.30 38.84L19.40 38.94L19.40 38.94Q18.98 37.76 18.94 36.73L18.89 36.67L18.96 36.75Q18.88 32.44 23.49 32.14Z\" />
<path fill="#222\" d="M50.58 29.40L50.72 29.55L50.57 29.40Q49.40 28.65 48.76 28.69L48.90 28.83L48.75 28.68Q47.40 28.78 46.35 29.79L46.39 29.82L46.32 29.76Q45.40 30.89 45.52 32.26L45.49 32.23L45.40 32.14Q45.88 36.66 45.00 41.19L45.00 41.18L44.85 41.03Q42.80 41.65 41.70 42.19L41.61 42.10L41.59 42.08Q43.09 37.91 42.87 33.46L42.83 33.42L42.91 33.50Q42.71 29.03 41.00 24.96L40.86 24.83L40.88 24.84Q42.03 25.54 44.31 26.18L44.31 26.19L44.88 28.88L44.98 28.99Q45.68 26.10 49.94 26.10L49.85 26.01L49.82 25.98Q50.34 26.04 50.64 26.04L50.51 25.91L50.57 25.97Q51.87 25.98 53.13 26.66L53.14 26.67L53.08 26.61Q51.81 28.01 50.67 29.49ZM52.23 31.43L52.32 31.38L52.47 31.53Q53.26 30.26 54.94 27.82L54.98 27.87L54.84 27.72Q54.43 27.44 52.91 27.17L52.88 27.14L53.00 27.26Q53.20 26.81 53.66 26.20L53.66 26.20L53.69 26.23Q51.84 25.37 49.90 25.56L49.95 25.62L49.94 25.60Q47.97 25.77 47.25 26.04L47.25 26.04L47.17 25.95Q45.90 26.52 45.10 27.62L45.03 27.55L44.79 26.66L44.60 25.82L44.56 25.78Q42.28 25.48 40.30 24.15L40.31 24.16L40.35 24.20Q42.47 28.57 42.70 33.44L42.58 33.32L42.73 33.47Q42.88 38.31 41.13 42.84L41.18 42.89L41.10 42.80Q42.19 42.33 43.06 42.03L43.15 42.11L43.01 41.97Q42.70 43.04 42.21 44.10L42.35 44.25L42.35 44.25Q45.10 43.30 47.23 43.19L47.19 43.15L47.42 38.66L47.47 38.71Q47.50 36.37 47.50 34.13L47.67 34.30L47.52 34.15Q47.67 33.12 48.58 32.15L48.43 32.00L48.43 32.00Q49.46 31.14 50.60 31.06L50.61 31.07L50.51 30.97Q51.18 30.88 51.90 31.57L51.83 31.49L52.17 31.38ZM47.36 29.77L47.41 29.73L47.37 29.82L47.22 29.62Z\" />
<path fill="#222\" d="M65.28 49.59L65.40 49.71L65.27 49.58Q68.25 45.78 71.14 39.58L71.20 39.63L71.06 39.49Q68.04 33.05 61.95 24.98L61.86 24.89L61.92 24.95Q63.80 26.07 66.58 26.71L66.55 26.68L66.52 26.66Q70.15 31.42 72.58 36.64L72.61 36.66L72.63 36.69Q74.69 31.29 77.77 26.87L77.75 26.85L77.88 26.98Q80.07 26.62 82.16 25.82L82.16 25.81L82.07 25.72Q78.68 29.56 75.21 36.99L75.18 36.96L72.34 42.95L72.41 43.01Q70.98 46.16 69.23 48.79L69.29 48.85L69.26 48.81Q66.75 49.08 65.30 49.62ZM71.56 51.04L71.54 51.02L71.43 50.91Q73.16 48.03 74.61 44.75L74.66 44.81L77.42 38.51L77.30 38.39Q80.87 30.43 84.19 26.43L84.15 26.40L84.13 26.38Q82.79 27.05 80.89 27.74L80.92 27.77L81.99 26.41L82.01 26.43Q82.55 25.71 83.16 25.02L83.23 25.09L83.16 25.02Q80.54 26.13 77.68 26.59L77.64 26.55L77.55 26.46Q74.92 30.48 72.97 34.94L72.96 34.92L72.93 34.89Q71.22 31.50 69.43 28.69L69.54 28.80L69.47 28.73Q69.37 28.83 69.01 28.79L69.04 28.81L68.87 28.64Q68.64 28.74 68.45 28.74L68.45 28.74L68.39 28.68Q67.72 27.51 66.76 26.37L66.73 26.33L66.61 26.21Q63.53 25.64 60.78 23.93L60.85 23.99L60.85 23.99Q67.03 31.93 70.73 39.54L70.78 39.60L70.66 39.47Q68.61 44.66 64.54 50.29L64.56 50.31L64.42 50.17Q65.23 49.89 66.03 49.73L66.13 49.83L67.76 49.49L67.67 49.39Q67.07 50.12 65.89 51.76L65.86 51.74L65.96 51.83Q68.30 51.28 71.58 51.05Z\" />
</svg>
答案1
基于这个答案你可以inkscape
使用svg
png
# Inkscape v1.0+
inkscape -w 1024 -h 1024 input.svg -o output.png
# Inkscape older than v1.0
inkscape -z -w 1024 -h 1024 input.svg -e output.png
还有imagemagick
:
convert -background none -size 1024x1024 input.svg output.png