how to write into filehandle

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dheeraj

how to write into filehandle

Post by dheeraj »

Hi,

I want to write image into a FILE * fp from ImageInfo structure where FILE *file containd the image stram ;
I tried like
size_t size;
char * output;

FILE *output_file = open_memstream(output, &size);

images->file = output_file;
WriteImage(image_info,images);

but i got compilation error like there is Image does no have any member named as file

could you plz suggest how would I write image to a filehandle

Thanks in advance
Dheeraj
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: how to write into filehandle

Post by magick »

Assign your file descriptor to the ImageInfo structure rather than the Image structure (e.g. image_info->file = file).
dheeraj

Re: how to write into filehandle

Post by dheeraj »

I think in WriteImage function it reads from ImageInfo structure and wtites to Image stucture
please suggest if I am wrong
so the problem is i want to write to file discriptor and Image stucture does not have any member of "FILE *" type,
Are there some other APIs where I can write to file descriptor or can I modify this WriteImage function?
dheeraj

Re: how to write into filehandle

Post by dheeraj »

magick wrote:Assign your file descriptor to the ImageInfo structure rather than the Image structure (e.g. image_info->file = file).
As ImageInfo->file member has been initialised with input file
wont it overwrite the same ?

Pls see the code below - and confim if this is what you suggest:

image_info->file = fmemopen(input, input_len, "r");
images=ReadImage(image_info,exception);

FILE *output_file = open_memstream(output, &size);
image_info->file = output_file;
WriteImage(image_info,thumbnails);

In this case what is the sigbnificance of 2nd paramter -thumbnails?
Post Reply