Search code examples
phpimagickimage-size

PHP imagick convert svg to image issue


I was not able to figure out why I am not able to do the conversion from svg to image.

System:

Windows 2008 Server
II7
PHP 5.3.10-      Imagick is installed 

Code

$command = 'C:\imagemagick\convert.exe d:\path-to-svg-file\sample.svg d:\path-to-output-folder\sample.png 2>&1';

exec($command, $output);

ERROR

array(2) {
    [0]=> string(102) "convert.exe: Must specify image size `C:/Windows/TEMP/magick-PY5hNkFu' @ error/mvg.c/ReadMVGImage/185."
    [1]=> string(126) "convert.exe: no images defined `d:\inetpub\...\output\sample.png' @ error/convert.c/ConvertImageCommand/3044."
} 

Solution

  • You have to Specify Size :

    convert -size 568x604 d:\tiger.svg d:\tiger.jpg
    

    What about SVG to other image formats

     convert file.svg file.png
    

    I tried converting to a PNG but had the same problem as with JPGs