"no decode delegate" for 1 SVG, while all others work fine

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
charlie1234
Posts: 16
Joined: 2011-07-27T21:24:03-07:00
Authentication code: 8675308

"no decode delegate" for 1 SVG, while all others work fine

Post by charlie1234 »

I wrote a script which parses SVGs and breaks them down into layers, saving the individual layers as PNGs as well as the 1 original SVG as a PNG.

Ran through hundreds of SVGs without a problem, but this current file is being troublesome. I'm getting the good ol' "no decode delegate" error when I perform $image->readImageBlob() on the contents of the SVG file:

Code: Select all

magickException: no decode delegate for this image format `' @ error/blob.c/BlobToImage/349 in Imagick->readimageblob()
The line in my PHP script that is throwing the error is:

Code: Select all

$im->readImageBlob($svg_blob);
where $svg_blob is simply the result of file_get_contents('path/to/svg').

I can probably work with the content of this SVG (attached to this post) in a graphics program to get it working within the canvas of another (known working) SVG, but I am very curious what the actual problem with this file is as it's virtually identical to what I've already been using. Anyone have a clue?
Attachments
FemaleSymbol_1.svg.zip
(1.66 KiB) Downloaded 1303 times
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: "no decode delegate" for 1 SVG, while all others work fi

Post by magick »

That particular SVG image is prefixed with a couple of binary characters which throws off ImageMagick such that it does not recognize the image as SVG. To fix, set the format explicitly with
  • $im->setFormat('SVG');
charlie1234
Posts: 16
Joined: 2011-07-27T21:24:03-07:00
Authentication code: 8675308

Re: "no decode delegate" for 1 SVG, while all others work fi

Post by charlie1234 »

Thanks for your help magick! How were you able to see the prefixed binary characters?
Post Reply