HEM*_*MAN 6 php svg png inkscape rsvg
我用这段代码转换svg成png图像
<?php
exec('/usr/bin/rsvg-convert -w 1000 -h 1000 tshirt.svg -o tshirt.png');
?>
Run Code Online (Sandbox Code Playgroud)
这适用于单个svg图像.
实际上我有一个svg包含多层图像的图像,如:
第1层 - :这是透明的背景T恤图像
第二层 - :这是另一个包含颜色的T恤图像
第3层 - :这是应该放在T恤上的小贴纸图片
我的svg代码是 - :
<?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="http://dothejob.in/teerrific/img/front/unnamed.png"/>
</g>
</g>
<g class="canvas_mockups">
<g class="canvas_styles">
<g class="canvas_style">
<g style="opacity: 1;">
<image xlink:href="http://dothejob.in/teerrific/img/front/test.png" x="0" y="0" width="1000" height="1000" />
</g>
</g>
</g>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
现在我希望将所有svg图像层组合在一起并制作单个png图像.
现在我转换后的png图像只显示背景颜色.T恤和贴纸图片没有显示.
| 归档时间: |
|
| 查看次数: |
871 次 |
| 最近记录: |