我用这段代码将 svg
转换为 png
图像:
<?php
exec('/usr/bin/rsvg-convert -w 1000 -h 1000 tshirt.svg -o tshirt.png');
?>
这适用于单个svg图像。
实际上,我有一个包含多层图像的svg
图像,如下:
第一层 -:这是背景T恤图像,其为透明的
第二层 -:这是另一个带有颜色的T恤图像
第三层 -:这是小贴纸图像,应该放在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>
现在我想将所有的
svg
图像层合并成一个单独的png
图像。现在我的转换后的
png
图像仅显示背景色,T恤和贴纸图像未显示。