Page 1 of 1
Problem reading svg files
Posted: 2011-05-23T12:21:13-07:00
by kareed
Hi,
I am having trouble reading svg files in a php script. I am trying the following
$img = new Imagick($svgFile);
$canvas->compositeImage( $img, imagick::COMPOSITE_OVER, 0, 0 );
and I am getting the following error
PHP Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `/var/folders/1Z/1ZOs3r15HKGGDQfu54uHyE+++TI/-Tmp-/magick-xUb7ZeaQ' @ error/constitute.c/ReadImage/532' in
The weird part is if I try this in the script
exec("convert -background none $svgFile $pngFile");
it will convert the file and I can then read in the png file and use it.
I am using ImageMagick 6.6.5 and php 5.2.13
Any help would be appreciated.
Thanks
Re: Problem reading svg files
Posted: 2011-05-23T12:30:42-07:00
by fmw42
try setting the background and especially the density for the svg file before compositing
Re: Problem reading svg files
Posted: 2011-05-23T14:46:33-07:00
by kareed
I'm not entirely sure what you mean. The error is actually being thrown when it is being read in. Are you saying I should set the Imagick instance up first and adding some parameters before I try reading in the file?
Thanks
Re: Problem reading svg files
Posted: 2011-05-23T14:53:41-07:00
by fmw42
Does your version of IM and also Imagick support SVG format? You may need to install the RSVG package.
You can check what you have using
convert -list configure
and see if the line starting with DELEGATES contains either svg or rsvg. On mine I have
DELEGATES bzlib fftw fontconfig freetype gs jpeg jng jp2 lcms2 lqr lzma mpeg openexr png rsvg tiff x11 xml zlib
Alternately, look at
convert -list format
and see what you have for SVG. On mine I have
SVG SVG rw+ Scalable Vector Graphics (RSVG 2.32.1)
Re: Problem reading svg files
Posted: 2011-05-23T15:04:08-07:00
by kareed
I figured imagick had the same svg capabilites as convert. I am not sure how imagemagick is different from imagick.
The past few days I was trying to install the rsvg package to fix a problem where the original convert of a svg image with a rotation was screwed up. I installed the rsvg and I couldn't get it work properly with an image either. The image wouldn't show up. So I uninstalled the rsvg library. Should I reinstall it?
Thanks
Re: Problem reading svg files
Posted: 2011-05-23T16:11:33-07:00
by fmw42
I am not an expert on svg, vs rsvg except the latter is better nor do I use Imagick (only command line). If you install rsvg, then perhaps PHP needs to also know where it its. Also then you must install IM and presumably Imagick again afterwards.
Re: Problem reading svg files
Posted: 2011-05-23T22:22:31-07:00
by kareed
I tried upgrading to rsvg 2.32, reinstalled ImageMagick and it still threw the same error when I tried reading a svg file. So I am still stumped, I can't figure out why the convert works but not Imagick. I can't find any settings that I would need to put in the php config.
Thanks