12

I have tried many different solutions, but cannot use Imagick::readImageBlob, any help would be appreciated.

Error message:

Caught exception: no decode delegate for this image format `' @ error/blob.c/BlobToImage/364

Code:

$svg = file_get_contents($this->svg);
$image = new Imagick();
$image->readImageBlob($svg);
//...

SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" width="928" height="933" id="parent">

        <image width="928" height="933" xlink:href="image.jpg" ></image>

        <path id="path1" fill="none" d="M100,656.5c-105.1-200.5-28.1-448,172-553s447.5-27.5,552.6,173s28.1,448-172,553 S205.1,856.9,100,656.5z"/>
        <text text-anchor="middle">
            <textPath xlink:href="#path1" startOffset="33.3333%">
                <tspan>top</tspan>
            </textPath>
        </text>

        <path id="path2" fill="none" d="M121.8,264.8C10.2,453.3,72.2,696.3,260.3,807.7s431,48.9,542.6-139.5 s49.5-431.5-138.5-542.8S233.3,76.4,121.8,264.8z"/>
        <text text-anchor="middle">
        <textPath xlink:href="#path2" startOffset="33.3333%">
            <tspan>bund</tspan></textPath>
        </text>
    </svg>
thegingerdk
  • 151
  • 1
  • 1
  • 7
  • Is SVG a listed format in `\Imagick::queryformats();` ? You probably don't have an appropriate library to read SVG images installed such as RSVG. – Danack Oct 05 '15 at 14:23
  • I see that SVG is not on the list, where can I find the right install files for RSVG – thegingerdk Oct 06 '15 at 10:45
  • You haven't said what your system is. On centos it would be `yum install rsvg` probably. – Danack Oct 06 '15 at 18:56
  • sorry about that, it's an ubuntu server, but I find that if I added the missing items to imagick it worked, – thegingerdk Oct 07 '15 at 07:20
  • What was missing? I'm having this exact issue. Trying to base64 decdoe an svg to I can convert it to png – Native Coder Oct 24 '16 at 21:30

7 Answers7

9

For me these deps were missing (ubuntu 16.04):

sudo apt-get install libgraphicsmagick1-dev libmagickcore-dev libmagickcore-6.q16-2 libmagickcore-6.q16-2-extra

The expected output:

identify -list format | grep SVG
     MSVG  SVG       rw+   ImageMagick's own SVG internal renderer
      SVG  SVG       rw+   Scalable Vector Graphics (RSVG 2.40.13)
     SVGZ  SVG       rw+   Compressed Scalable Vector Graphics (RSVG 2.40.13)
karser
  • 1,625
  • 2
  • 20
  • 24
  • 1
    The shell renders the correct output from `identify -list format | grep SVG`, however I still received the `no decode delegate for this image format`... thoughts? – Shmack Oct 27 '20 at 21:58
7

After having tried by @Native Coder and @karser answers my SVG was still generating the same no decode delegate error. It worked after I added <?xml version="1.0" encoding="UTF-8" standalone="no"?> as the opening line of my SVG content. Worth checking your XML is valid as well.

Antony
  • 3,875
  • 30
  • 32
2

I was able to fix this issue by installing inkscape.

apt-get install inkscape

See my comment here: https://stackoverflow.com/a/63175979/751202

Aurel
  • 405
  • 5
  • 8
1

Using Ubuntu 20.04, I ran the below command that installed the libmagickcore-6 package.

This package adds support for SVG, WMF, OpenEXR, DjVu and Graphviz to MagickCore. There are a few different versions, for instance, one of the versions is compiled for a channel depth of 16 bits with high dynamic range (Q16HDRI).

 sudo apt install libmagickcore-6*

With the above command, it seems like I installed all the different versions. Not sure if that's the best slash most efficient way, but it did take care of the issue.

dearsina
  • 4,774
  • 2
  • 28
  • 34
1

Docker image alpine, work for me:

RUN apk add --update imagemagick imagemagick-libs imagemagick-dev \
    && pecl install imagick \
    && docker-php-ext-enable imagick
UKRman
  • 404
  • 3
  • 16
0

To anyone reading this in the future, I had this exact same issue. The problem was that I was missing libxml2 and librsvg2-bin.

Native Coder
  • 1,792
  • 3
  • 16
  • 34
0

For me, I tried all solution above without result and i finally installed inkscape (which is used by imagemagick) and it works perfectly now !

sudo apt-get install inkscape