Hello,
I am attempting to use the MagickGetImagesBlob function to get a buffer of the image output using ImageMagick version 7.0.10-10 Q16. I've adapted some code from the MagickWand main page to print the output to stdout:
However, when trying to run the program with any image (e.g. ./wand image.jpg), it outputs a buffer containing only the header:This is the case for every image I try. Attempting to use a PNG results in this:As with GIF:The same also occurs when I try to use MagickGetImageBlob instead of MagickGetImagesBlob. This is very strange since the original example on the page that writes to a file works just fine for me. Is there something I'm missing or is this a bug in MagickWand? Thanks in advance.
I am attempting to use the MagickGetImagesBlob function to get a buffer of the image output using ImageMagick version 7.0.10-10 Q16. I've adapted some code from the MagickWand main page to print the output to stdout:
CODE:
#include <stdio.h>#include <stdlib.h>#include <MagickWand/MagickWand.h>int main(int argc,char **argv){#define ThrowWandException(wand) \{ \ char \ *description; \ \ ExceptionType \ severity; \ \ description=MagickGetException(wand,&severity); \ (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \ description=(char *) MagickRelinquishMemory(description); \ exit(-1); \} MagickBooleanType status; MagickWand *magick_wand; if (argc != 2) { (void) fprintf(stdout,"Usage: %s image\n",argv[0]); exit(0); } /* Read an image. */ MagickWandGenesis(); magick_wand=NewMagickWand(); status=MagickReadImage(magick_wand,argv[1]); if (status == MagickFalse) ThrowWandException(magick_wand); /* Turn the images into a thumbnail sequence. */ MagickResetIterator(magick_wand); while (MagickNextImage(magick_wand) != MagickFalse) MagickResizeImage(magick_wand,106,80,LanczosFilter); /* Write the image then destroy it. */ size_t my_size; unsigned char * my_image = MagickGetImagesBlob(magick_wand, &my_size); fprintf(stdout, "%s\n", my_image); magick_wand = DestroyMagickWand(magick_wand); MagickWandTerminus(); return(0);}
CODE:
$ ./wand image.jpg����
CODE:
$ ./wand image.png�PNG�
CODE:
$ ./wand image.gifGIF89aj
Statistics: Posted by Essem — 2020-05-16T18:13:23-07:00