Page 1 of 1

MagickReadImageBlob failure with .ico files

Posted: 2007-02-06T07:37:56-07:00
by smugsotemp
I'm using PHP 5.2.0 with ImageMagick-6.3.2-3-Q8 for windows.

I've noticed a problem with MagickReadImageBlob().

The following code works fine:
$image = file_get_contents("c:\image.gif");
print_r($image);
$resource = NewMagickWand();
MagickReadImageBlob($resource,$image);


While the following code crashes with "Fatal error: magickreadimageblob(): An unknown C API exception occurred [on C source line 7670] in ..."

$image = file_get_contents("c:\image.ico");
print_r($image);
$resource = NewMagickWand();
MagickReadImageBlob($resource,$image);


I've tried it with several .ico files and all produce the same result.

Re: MagickReadImageBlob failure with .ico files

Posted: 2007-02-06T08:45:00-07:00
by magick
Add
  • MagickSetFilename($resource,"ico:favicon.ico");

just before the MagickReadImageBlob() statement. This ico: assists ImageMagick in determining your image is in the ICO image format.

Re: MagickReadImageBlob failure with .ico files

Posted: 2007-02-07T07:43:35-07:00
by smugsotemp
Hey, magick.
I did what you suggested and it removed the error in MagickReadImageBlob.
However, I still cannot get a php buffer of the image.

Once I do the following:

Code: Select all

$image = file_get_contents("c:\image.ico");
$resource = NewMagickWand();
MagickSetFormat($resource,"ico");
MagickSetFilename($resource,"ico:favicon.ico");
MagickReadImageBlob($resource,$image);
$newIcoImage = MagickGetImagesBlob($resource);
I get nothing in $newIcoImage (not false, just empty). If I try to write it to a file (using fwrite) I get a file with size of 0.

Thanks,

Re: MagickReadImageBlob failure with .ico files

Posted: 2007-02-07T09:18:37-07:00
by magick
You found a bug. The blob is not created if it begins with a NULL character. You can write to other formats other than ICO such as MIFF or you can dowload the patch at ftp://ftp.imagemagick.org/pub/php/betasometime tommorrow. Thanks for the problem report.

Re: MagickReadImageBlob failure with .ico files

Posted: 2007-10-14T05:49:08-07:00
by magickchina
magick wrote:You found a bug. The blob is not created if it begins with a NULL character. You can write to other formats other than ICO such as MIFF or you can dowload the patch at ftp://ftp.imagemagick.org/pub/php/betasometime tommorrow. Thanks for the problem report.
The bug is still exists, I met it , with the latest version of imageMagick AND MagickWand

My env:
winxp + ImageMagick-6.3.6-Q16 + MagicWand 1.0.5 + PHP5.2.4

My test code

Code: Select all

$image = file_get_contents("c:\favicon.ico");
$resource = NewMagickWand();
MagickSetFormat($resource,"ico");
MagickSetFilename($resource,"ico:favicon.ico");
MagickReadImageBlob($resource,$image);
$newIcoImage = MagickGetImagesBlob($resource);
echo $newIcoImage;
die;
it output nothing

Re: MagickReadImageBlob failure with .ico files

Posted: 2007-10-15T07:28:08-07:00
by magick
We tried your script with ImageMagick 6.3.6-2 and MagickWand 1.0.5 and it output an ICO image as expected. Not sure why it failed for you.

Re: MagickReadImageBlob failure with .ico files

Posted: 2007-10-15T19:10:59-07:00
by magickchina
magick wrote:We tried your script with ImageMagick 6.3.6-2 and MagickWand 1.0.5 and it output an ICO image as expected. Not sure why it failed for you.
Are you test it in windows xp ?
My php version: 5.2.4

I download php-5.2.4_magickwand_q16_st.dll from here.

http://www.dirk.sh/dirk/magickwand/

Re: MagickReadImageBlob failure with .ico files

Posted: 2008-01-07T23:15:53-07:00
by aireys
I have the same problem.
I work with C API.
My code:

FILE *f = fopen("bomb.jpg", "rb");
size_t fsize = getfilesize(f);
void *content = malloc(fsize);
read(content, 1, fsize, f);

//I'm sure above is ok

MagicKWand *wand = NewMagickWand();
MagickSetFormat(wand, "jpg");
MagickSetFilename(wand, "jpg:out.jpg");
status = MagickReadImageBlob(wand, content, fsize);

status is MagickFalse
why ?please help me. My email: aireys@126.com