更新时间:2023-11-10 20:40:16
请安装 inkscape 扩展.
然后将图像(在svg中使用的图像)放在保存svg文件的同一文件夹中.
then put your images (which you used in svg) on same folder where you save your svg file.
然后像这样更改svg文件中的图像路径.
then change image path in svg file like that.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg crossOrigin="anonymous" width="1000px" height="1000px" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g class="canvas_background">
<rect class="canvas_variant_color" width="998" height="998" x="0" y="0" style="" fill="#008080"/>
<rect real_size="16,22" height="547" class="canvas_border" width="343" y="160" x="335" fill="#008080" />
</g>
<g class="canvas_objects" style="" mask="url('#Sibnip5tjg')">
<g style="display: block;" transform="matrix(1,0,0,1,-146.5,-236.3909)">
<image style="display: block; opacity: 1;" height="175" width="308" y="461" x="501" crossOrigin="anonymous" xlink:href="unnamed.png"/>
</g>
</g>
<g class="canvas_mockups">
<g class="canvas_styles">
<g class="canvas_style">
<g style="opacity: 1;">
<image xlink:href="test.png" x="0" y="0" width="1000" height="1000" />
</g>
</g>
</g>
</g>
</svg>
在运行inkscape命令之后
after that run inkscape command
exec( 'inkscape --without-gui --export-png=all.png tshirt.svg' );
然后您将在同一文件夹中获得png文件.
then you will get png file in same folder.