views:

127

answers:

1

I'm using MagickCore to generate images from scratch. I'm trying to save my Image as a PNG file, but whenever I call WriteImage, it outputs to standard out rather than to the filename that I specified. For example:

Image *image = ImageGenerator(...); // generates valid image

ImageInfo *info = CloneImageInfo (NULL);
info->file = NULL;
strcpy (info->filename, "test.png");
strcpy (info->magick, "png");

WriteImage (info, image);

When this code is used, it outputs PNG data to standard out rather than to test.png. Is there something else that I am missing?

A: 

The trick was to use the FILE * provided by the ImageInfo struct.

...
info->file = fopen ("test.png", "w+b");
strcpy (info->filename, "test.png");
strcpy (info->magick, "png");
...
dreamlax