no decode delegate for this image format `' @ error/blob

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.
Mahir
Posts: 47
Joined: 2016-10-22T06:58:23-07:00
Authentication code: 1151

no decode delegate for this image format `' @ error/blob

Post by Mahir »

I have tried many different solutions, but cannot use Imagick::readImageBlob, any help would be appreciated.
Error message: no decode delegate for this image format `' @ error/blob

can you help me please.

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: no decode delegate for this image format `' @ error/blob

Post by snibgo »

As this doesn't seem to be for paid consultncy, and is for IMagick, I've moved it to the IMagick forum.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: no decode delegate for this image format `' @ error/blob

Post by fmw42 »

What do you get from running

convert -version

and what is your full set of code regarding what image type you are trying to read and write.
Mahir
Posts: 47
Joined: 2016-10-22T06:58:23-07:00
Authentication code: 1151

Re: no decode delegate for this image format `' @ error/blob

Post by Mahir »

I have formats :
ImageMagick number of supported formats:234 but when i try to use Imagick::readImageBlob I get eror,
example:

<?php

$usmap = 'mahir.svg';
$im = new Imagick();
$svg = file_get_contents($usmap);

/*loop to color each state as needed, something like*/
$idColorArray = array(
"AL" => "339966"
,"AK" => "0099FF"
,"WI" => "FF4B00"
,"WY" => "A3609B"
);

foreach($idColorArray as $state => $color){
//Where $color is a RRGGBB hex value
$svg = preg_replace(
'/id="'.$state.'" style="fill:#([0-9a-f]{6})/'
, 'id="'.$state.'" style="fill:#'.$color
, $svg
);
}

$im->readImageBlob($svg);

/*png settings*/
$im->setImageFormat("png24");
$im->resizeImage(720, 445, imagick::FILTER_LANCZOS, 1); /*Optional, if you need to resize*/

/*jpeg*/
$im->setImageFormat("jpeg");
$im->adaptiveResizeImage(720, 445); /*Optional, if you need to resize*/

$im->writeImage('/path/to/colored/us-map.png');/*(or .jpg)*/
$im->clear();
$im->destroy();
?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: no decode delegate for this image format `' @ error/blob

Post by fmw42 »

You did not answer my question. What do you get from

convert -version

You also have:
$im->setImageFormat("jpeg");
$im->adaptiveResizeImage(720, 445); /*Optional, if you need to resize*/

$im->writeImage('/path/to/colored/us-map.png');/*(or .jpg)*/
Which seems to say you want to write to jpeg, but you are using a suffix of .png
Mahir
Posts: 47
Joined: 2016-10-22T06:58:23-07:00
Authentication code: 1151

Re: no decode delegate for this image format `' @ error/blob

Post by Mahir »

sorry,I do not understand what you mean by convert-version,
exactly I am trying make web editor ,so I can resize and change color in svg format and save in png format,
can you please make some simple code wher I can include some svg format ,and than for example resize and save in png format?

thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: no decode delegate for this image format `' @ error/blob

Post by fmw42 »

I am trying to find out what delegates you have installed with imagemagick.

Try either:

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

or

<?php
exec("/usr/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

And let us know what you get.

Sorry, I do not know Imagick. But I do not see any conditional to switch between your JPEG and PNG code.
/*png settings*/
$im->setImageFormat("png24");
$im->resizeImage(720, 445, imagick::FILTER_LANCZOS, 1); /*Optional, if you need to resize*/

/*jpeg*/
$im->setImageFormat("jpeg");
$im->adaptiveResizeImage(720, 445); /*Optional, if you need to resize*/

$im->writeImage('/path/to/colored/us-map.png');/*(or .jpg)*/
$im->clear();
$im->destroy();
?>
Mahir
Posts: 47
Joined: 2016-10-22T06:58:23-07:00
Authentication code: 1151

Re: no decode delegate for this image format `' @ error/blob

Post by Mahir »

when I try this code:

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

or

<?php
exec("/usr/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>

I get this error:
Notice: Undefined offset: 0 in C:\wamp64\www\logoeditor\index.php on line 3
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: no decode delegate for this image format `' @ error/blob

Post by fmw42 »

Sorry, I do not know how to help further. I do not know what that error means unless you are forbidden to use exec() on your server. Do you know what version of Imagemagick you are using and where it is located?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: no decode delegate for this image format `' @ error/blob

Post by Bonzo »

Notice: Undefined offset: 0 in C:\wamp64\www\logoeditor\index.php on line 3
I would guess your Imagemagick version is not located at /usr/local/bin/convert so you are not getting an array to read.

Searching the web I found some answers including this one:
svg file text structure needs to be specified for readImageBlob to decode the file. Prepend <?xml version="1.0" encoding="UTF-8" standalone="no"?> to your variable having svg text.
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$svg;
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: no decode delegate for this image format `' @ error/blob

Post by Bonzo »

Also as fmw42 said it looks as though you are setting the image file output format as a png then changing it to a jpg and saving as a png.
Mahir
Posts: 47
Joined: 2016-10-22T06:58:23-07:00
Authentication code: 1151

Re: no decode delegate for this image format `' @ error/blob

Post by Mahir »

Imagemagick is located in C:\imagemagick directory
and verson of imagemagick is 7.0.3-5
Mahir
Posts: 47
Joined: 2016-10-22T06:58:23-07:00
Authentication code: 1151

Re: no decode delegate for this image format `' @ error/blob

Post by Mahir »

Bonzo, I need resize SVG format and save in png or jpg,
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: no decode delegate for this image format `' @ error/blob

Post by fmw42 »

Can you do

<?php
exec("C:\imagemagick\convert -version",$out,$returnval);
print_r($out[0]);
?>

Or put in the actual name of the directory in place of "imagemagick" in the above and tell us what you get.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: no decode delegate for this image format `' @ error/blob

Post by fmw42 »

Try some simple Imagick to read the Imagemagick internal image "logo:" and write to JPG and also write to PNG. Do those work?

Basically test something simple and then try to do the same with and SVG file. Get rid of all your other code besides reading and writing. What fails if anything?
Post Reply