Problem reading svg files

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
kareed
Posts: 11
Joined: 2010-05-17T08:06:36-07:00
Authentication code: 8675308

Problem reading svg files

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem reading svg files

Post by fmw42 »

try setting the background and especially the density for the svg file before compositing
kareed
Posts: 11
Joined: 2010-05-17T08:06:36-07:00
Authentication code: 8675308

Re: Problem reading svg files

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem reading svg files

Post 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)
kareed
Posts: 11
Joined: 2010-05-17T08:06:36-07:00
Authentication code: 8675308

Re: Problem reading svg files

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem reading svg files

Post 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.
kareed
Posts: 11
Joined: 2010-05-17T08:06:36-07:00
Authentication code: 8675308

Re: Problem reading svg files

Post 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
Post Reply