Page 1 of 3
no decode delegate for this image format `' @ error/blob
Posted: 2016-11-04T06:48:41-07:00
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
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-04T07:56:26-07:00
by snibgo
As this doesn't seem to be for paid consultncy, and is for IMagick, I've moved it to the IMagick forum.
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-04T09:32:56-07:00
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.
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T08:02:16-07:00
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();
?>
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T09:30:29-07:00
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
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T10:05:21-07:00
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
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T10:19:28-07:00
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();
?>
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T10:42:52-07:00
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
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T10:55:18-07:00
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?
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T10:59:30-07:00
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;
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T11:01:45-07:00
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.
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T11:09:28-07:00
by Mahir
Imagemagick is located in C:\imagemagick directory
and verson of imagemagick is 7.0.3-5
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T11:11:13-07:00
by Mahir
Bonzo, I need resize SVG format and save in png or jpg,
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T11:17:50-07:00
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.
Re: no decode delegate for this image format `' @ error/blob
Posted: 2016-11-05T11:20:54-07:00
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?