Here's the input image: .
In the test program, BlobToImage returns NULL and does not set any values in the exception structure. If I store "ICO" in the image_info->magick field, BlobToImage returns a correct image. Please let me know if you need any other information.
Code: Select all
/*
Call BlobToImage on a .ICO file
gcc `Magick-config --cflags --cppflags` icoblob.c `Magick-config --ldflags --libs` -o icoblob
*/
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include "magick/MagickCore.h"
int main()
{
Image *image;
ImageInfo *image_info;
FILE *img;
char blob[4000];
size_t length;
ExceptionInfo exception;
MagickCoreGenesis("icoblob" ,MagickFalse);
image_info = CloneImageInfo(NULL);
if (!image_info)
{
puts("CloneImageInfo failed.");
exit(1);
}
img = fopen("favicon.ico", "r");
length = fread(blob, 1, sizeof(blob), img);
if (ferror(img))
{
puts("ferror");
exit(1);
}
GetExceptionInfo(&exception);
// strcpy(image_info->magick, "ico");
image = BlobToImage(image_info, blob, (size_t)length, &exception);
DestroyImageInfo(image_info);
if (!image)
{
puts("No image returned.");
if (exception.severity > UndefinedException)
{
printf("%s: %s", exception.reason, exception.description);
}
}
else
{
puts("Got an image");
DestroyImage(image);
}
DestroyMagick();
exit(0);
}