I am trying to convert SVG file (./svgtmp/designsvg.svg) and save as a Png Image (./svgtmp/designsvg.png) with ImageMagick 6.9.3-8 Q16 version. But its not work. after execution convert command $arr returns blank array and $return_var returns 1
$svg ='<svg xmlns="http://www.w3.org/2000/svg" id="vgroovFrame" width="95" height="95"><polyline id="topLeft" points="0,5 10,5 10,10 5,10 5,0 90,0 90,10 85,10 85,5 95,5 95,90 85,90 85,85 90,85 90,95 5,95 5,85 10,85 10,90 0,90 0,5 " style="fill:#044B9466;stroke:red;stroke-width:1"/></svg>';
file_put_contents('./svgtmp/designsvg.svg', $svg);
$thumbImg = './svgtmp/designsvg.svg';
$final_img = './svgtmp/designsvg1.png';
$command= "convert -density 500 -resize 128x128 ".$thumbImg." ".$final_img;
exec("convert -version" ,$arr, $return_var);
I have solved using passing path otherwise ImageMagick 6.9.3-8 Q16 version not allowed to read .SVG
file
$thumbImage = "./actions/tmpsvg/vrgroov_".$_GET['orderId'].".png";
$command= 'convert -size "'.$boundWidth.'"x"'.$boundHeight.'" xc:none -fill none -stroke "'.$vgroovCoreColor.'" -draw "'.$path.'" '.$thumbImage;
exec($command ,$arr, $return_var);
If you want to convert .svg
to .png
then use ImageMagick version 6.9.9 or upgraded