Page 1 of 1

The run time error of ImageToFile in MagickCore

Posted: 2011-04-28T01:24:38-07:00
by shiengchyi
I use the ConstituteImage function to generate a GRAY Level image, then use the ImageToFile function to save the image file in JPEG format.
The version of ImageMagick is 6.5.4-8 2009-10-24 Q16 OpenMP.
Here is the code.

ExceptionInfo *exception;
exception = AcquireExceptionInfo();

Image *img;
img = ConstituteImage(height, width, "I", CharPixel, imgBlobBuffer, exception); //imgBlobBuffer is an Unsigned Char array, and one byte per pixel
ImageToFile(img, Path, exception); //Path is file path like this "./test.jpeg"

I get a run time error at ImageToFile function:
magick/blob.c:1523: ImageToFile: Assertion `image->blob->type != UndefinedStream' failed. Aborted

Does anybody could tell me what wrong is it?

Re: The run time error of ImageToFile in MagickCore

Posted: 2011-04-28T05:55:59-07:00
by magick
Use WriteImage() rather than ImageToFile(). ImageToFile() reads bytes from disk and writes them to the specified file whereas WriteImage() writes the image pixels to disk in the format you specify.

Re: The run time error of ImageToFile in MagickCore

Posted: 2011-04-28T18:41:25-07:00
by shiengchyi
Yeah~ It is wording now!! Thank you very much~!!