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 » 2016-11-04T06:48:41-07:00

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: 9403
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 » 2016-11-04T07:56:26-07:00

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: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2016-11-04T09:32:56-07:00

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 » 2016-11-05T08:02:16-07:00

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: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2016-11-05T09:30:29-07:00

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 » 2016-11-05T10:05:21-07:00

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: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2016-11-05T10:19:28-07:00

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 » 2016-11-05T10:42:52-07:00

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: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2016-11-05T10:55:18-07:00

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: 2851
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post by Bonzo » 2016-11-05T10:59:30-07:00

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: 2851
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post by Bonzo » 2016-11-05T11:01:45-07:00

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 » 2016-11-05T11:09:28-07:00

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 » 2016-11-05T11:11:13-07:00

Bonzo, I need resize SVG format and save in png or jpg,

User avatar
fmw42
Posts: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2016-11-05T11:17:50-07:00

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: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2016-11-05T11:20:54-07:00

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