/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % V a l i d a t e C o n v e r t C o m m a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ValidateConvertCommand() validates the ImageMagick convert command line % program and returns the number of validation tests that passed and failed. % % The format of the ValidateConvertCommand method is: % % unsigned long ValidateConvertCommand(ImageInfo *image_info, % const char *reference_filename,const char *output_filename, % unsigned long *fail,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o reference_filename: the reference image filename. % % o output_filename: the output image filename. % % o fail: return the number of validation tests that pass. % % o exception: return any errors or warnings in this structure. % */ static unsigned long ValidateConvertCommand(ImageInfo *image_info, const char *reference_filename,const char *output_filename, unsigned long *fail,ExceptionInfo *exception) { char **arguments, command[MaxTextExtent]; int number_arguments; MagickBooleanType status; register long i, j; unsigned long test; test=0; (void) fprintf(stdout,"validate convert command line program:\n"); for (i=0; convert_options[i] != (char *) NULL; i++) { CatchException(exception); (void) fprintf(stdout," test %lu: %s",test++,convert_options[i]); (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s", reference_filename,convert_options[i],reference_filename,output_filename); arguments=StringToArgv(command,&number_arguments); if (arguments == (char **) NULL) { (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule()); (*fail)++; continue; } status=ConvertImageCommand(image_info,number_arguments,arguments, (char **) NULL,exception); for (j=0; j < number_arguments; j++) arguments[j]=DestroyString(arguments[j]); arguments=(char **) RelinquishMagickMemory(arguments); if (status != MagickFalse) { (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule()); (*fail)++; continue; } (void) fprintf(stdout,"... pass.\n"); } (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n", test,test-(*fail),*fail); return(test); }
static unsigned int ngx_http_graphicsmagick_convert(char **argv, size_t argc) { // GraphicsMagick stuff ngx_uint_t i; char *option; ExceptionInfo exception; ImageInfo *image_info; MagickBool regard_warnings, status; // DO GraphicsMagick converting InitializeMagick((char *) NULL); GetExceptionInfo(&exception); regard_warnings = 0; for (i = 1; i < argc; i++) { option = argv[i]; if ((ngx_strlen(option) == 1) || ((*option != '-') && (*option != '+'))) { continue; } if (LocaleCompare("debug", option + 1) == 0) { (void) SetLogEventMask(argv[++i]); } if (LocaleCompare("regard-warnings",option+1) == 0) { regard_warnings = MagickTrue; } } image_info = CloneImageInfo(0); status = ConvertImageCommand(image_info, argc, argv, NULL, &exception); if ((status == MagickFalse) || (exception.severity != UndefinedException)) { if ((exception.severity < ErrorException) && (regard_warnings == MagickFalse)) { status = MagickTrue; } CatchException(&exception); } DestroyImageInfo(image_info); DestroyExceptionInfo(&exception); return status; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a i n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ int main(int argc,char **argv) { char *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; } GetTimerInfo(&timer); for (i=0; i < (long) iterations; i++) { image_info=AcquireImageInfo(); status=ConvertImageCommand(image_info,argc,argv,(char **) NULL,exception); if (exception->severity != UndefinedException) { if ((exception->severity > ErrorException) || (regard_warnings != MagickFalse)) status=MagickTrue; CatchException(exception); } 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\n", iterations,1.0*iterations/elapsed_time,user_time,(long) (elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0))); } exception=DestroyExceptionInfo(exception); MagickCoreTerminus(); return(status == MagickFalse ? 0 : 1); }