/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a i n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ int main(int argc,char **argv) { char *metadata, *option; double elapsed_time, user_time; ExceptionInfo *exception; ImageInfo *image_info; MagickBooleanType regard_warnings, status; register long i; TimerInfo *timer; unsigned long iterations; MagickCoreGenesis(*argv,MagickTrue); exception=AcquireExceptionInfo(); iterations=1; status=MagickFalse; regard_warnings=MagickFalse; for (i=1; i < (long) (argc-1); i++) { option=argv[i]; if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) continue; if (LocaleCompare("bench",option+1) == 0) iterations=(unsigned long) atol(argv[++i]); if (LocaleCompare("debug",option+1) == 0) (void) SetLogEventMask(argv[++i]); if (LocaleCompare("regard-warnings",option+1) == 0) regard_warnings=MagickTrue; } timer=(TimerInfo *) NULL; if (iterations > 1) timer=AcquireTimerInfo(); for (i=0; i < (long) iterations; i++) { image_info=AcquireImageInfo(); metadata=(char *) NULL; status=CompareImageCommand(image_info,argc,argv,&metadata,exception); if (exception->severity != UndefinedException) { if ((exception->severity > ErrorException) || (regard_warnings != MagickFalse)) status=MagickTrue; CatchException(exception); } if (metadata != (char *) NULL) { (void) fputs(metadata,stdout); (void) fputc('\n',stdout); metadata=DestroyString(metadata); } image_info=DestroyImageInfo(image_info); } if (iterations > 1) { elapsed_time=GetElapsedTime(timer); user_time=GetUserTime(timer); (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n", iterations,1.0*iterations/elapsed_time,user_time,(long) (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)), (long) (1000.0*(elapsed_time-floor(elapsed_time)))); timer=DestroyTimerInfo(timer); } exception=DestroyExceptionInfo(exception); MagickCoreTerminus(); return(status == MagickFalse ? 0 : 1); }
static Read * read_new( const char *filename, VipsImage *im, gboolean all_frames, const char *density, int page ) { Read *read; static int inited = 0; if( !inited ) { #ifdef HAVE_MAGICKCOREGENESIS MagickCoreGenesis( vips_get_argv0(), MagickFalse ); #else /*!HAVE_MAGICKCOREGENESIS*/ InitializeMagick( "" ); #endif /*HAVE_MAGICKCOREGENESIS*/ inited = 1; } if( !(read = VIPS_NEW( im, Read )) ) return( NULL ); read->filename = filename ? g_strdup( filename ) : NULL; read->all_frames = all_frames; read->page = page; read->im = im; read->image = NULL; read->image_info = CloneImageInfo( NULL ); GetExceptionInfo( &read->exception ); read->n_frames = 0; read->frames = NULL; read->frame_height = 0; read->lock = vips_g_mutex_new(); g_signal_connect( im, "close", G_CALLBACK( read_close ), read ); if( !read->image_info ) return( NULL ); if( filename ) vips_strncpy( read->image_info->filename, filename, MaxTextExtent ); /* Canvas resolution for rendering vector formats like SVG. */ VIPS_SETSTR( read->image_info->density, density ); #ifdef HAVE_SETIMAGEOPTION /* When reading DICOM images, we want to ignore any * window_center/_width setting, since it may put pixels outside the * 0-65535 range and lose data. * * These window settings are attached as vips metadata, so our caller * can interpret them if it wants. */ SetImageOption( read->image_info, "dcm:display-range", "reset" ); #endif /*HAVE_SETIMAGEOPTION*/ if( !all_frames ) { char page[256]; /* Just pick a specific page. * * I can't find docs for these fields, but this seems to work. */ read->image_info->scene = read->page; read->image_info->number_scenes = 1; vips_snprintf( page, 256, "%d", read->page ); read->image_info->scenes = strdup( page ); } #ifdef DEBUG printf( "magick2vips: read_new: %s\n", read->filename ); #endif /*DEBUG*/ return( read ); }