mahadazad
mahadazad

Reputation: 551

Imagemagick svg conversion

I have a svg file which I want to be converted into jpg/png. Probem is that conversion is fine if there is no background image. But when I try to put some background image its not being rendered in the converted image and showing plain background color.

content of svg:

<svg height="370" version="1.1" width="350" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative; left: -0.5px;">
    <defs>
        <pattern id="38A07B9C-47E8-4E02-A005-E6E4443FE5D0" x="0" y="0" patternUnits="userSpaceOnUse" height="300" width="300" patternTransform="matrix(1,0,0,1,0,0) translate(0,20)">
            <image x="0" y="0" href="/home/mahad/public_html/svg/user-backgrounds/4f41f6a2a75dc_back.png" width="300" height="300"/>
        </pattern>
    </defs>
    <rect x="0" y="0" width="350" height="370" r="0" rx="0" ry="0" fill="#ffffff" stroke="none" style=""/>
    <rect x="0" y="20" width="350" height="350" r="0" rx="0" ry="0" fill="url(#38A07B9C-47E8-4E02-A005-E6E4443FE5D0)" stroke="none" style="fill: url(&quot;#38A07B9C-47E8-4E02-A005-E6E4443FE5D0&quot;) rgb(0, 0, 0); opacity: 0.38;" opacity="0.38"/>
    <rect x="0" y="20" width="14" height="14" r="0" rx="0" ry="0" fill="#000000" stroke="none" style=""/>
    <text style="text-anchor: middle; font: 12px &quot;Arial&quot;; opacity: 1;" x="100" y="100" text-anchor="middle" font="10px &quot;Arial&quot;" stroke="none" fill="#ff0000" font-size="12px" opacity="1" transform="matrix(1,0,0,1,73,92)">
        <tspan dy="4.5">helllloooo...</tspan>
    </text>
</svg>

conversion command: echo exec("/usr/bin/convert /home/public_html/qr.svg /home/public_html/qr.png");

please help

Upvotes: 1

Views: 900

Answers (1)

Ivan Krasin
Ivan Krasin

Reputation: 21

In my case, installing librsvg2-bin fixed the problem:

sudo apt-get install librsvg2-bin

Upvotes: 2

Related Questions