[Magick-bugs] problem reading GRAY images in 6.2.4
Christophe Beauregard
chris.beauregard at ec.gc.ca
Wed Jan 17 11:01:54 CST 2007
On Wednesday 17 January 2007 16:53, Christophe Beauregard wrote:
> In a nutshell, it appears that something (recent) is causing ReadImage
> on GRAY (and possibly other) files to try reading from standard input.
> The attached program (hopefully this list doesn't filter attachments?)
> illustrates the problem:
It does, doesn't it? Okay, graybug-256x256 is an arbitrary 8bpp GRAY image,
65536 bytes. graybug.c is:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
#include <limits.h>
#include <magick/api.h>
/***************************************************************************/
static MagickBooleanType progress_cb(const char * msg,
const MagickOffsetType offset,
const MagickSizeType size, void * data
) {
fprintf( stderr, "progress: %s\n", msg );
}
int main( int ac, char* av[] ) {
ExceptionInfo exception;
ImageInfo* image_info = NULL;
Image* image = NULL;
FILE* in = NULL;
fprintf( stderr, "loading %s\n", av[1] );
if( access(av[1],R_OK) ) {
perror(av[1]);
exit(1);
}
GetExceptionInfo( &exception );
image_info = CloneImageInfo( (ImageInfo *) NULL );
if( image_info == NULL ) goto fail;
image_info->depth = 8;
in = fopen(av[1],"r");
if( in == NULL ) goto fail;
SetImageInfoFile(image_info, in);
image_info->progress_monitor = progress_cb;
image_info->size = AcquireMagickMemory(256);
if( image_info->size == NULL ) goto fail;
snprintf(image_info->size,256,"%dx%d", 256,256);
fprintf( stderr, "image dimensions '%s'\n", image_info->size);
strncpy( image_info->magick, "GRAY", sizeof(image_info->magick) );
image = ReadImage( image_info, &exception );
CatchException(&exception);
fclose(in);
in = NULL;
if( image_info ) DestroyImageInfo( image_info );
fprintf(stderr, "finished loading image %s\n", av[1]);
if( image ) DestroyImage( image );
exit(0);
fail:
if( image ) DestroyImage( image );
if( image_info ) DestroyImageInfo( image_info );
fprintf(stderr, "failed to load image %s\n", av[1]);
exit(1);
}
EOF
c.
--
Christophe Beauregard <chris.beauregard at ec.gc.ca>
Informatics Specialist, Software
Chief Information Officer Branch, Trenton
Environment Canada
(613) 965-2762
I telework most Tuesday and Thursdays. Please use e-mail on those days.
More information about the Magick-bugs
mailing list