/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t C o n f i g u r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListConfigureInfo() lists the configure info to a file. % % The format of the ListConfigureInfo method is: % % MagickBooleanType ListConfigureInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListConfigureInfo(FILE *file, ExceptionInfo *exception) { const char *name, *path, *value; const ConfigureInfo **configure_info; register ssize_t i; size_t number_options; ssize_t j; if (file == (const FILE *) NULL) file=stdout; configure_info=GetConfigureInfoList("*",&number_options,exception); if (configure_info == (const ConfigureInfo **) NULL) return(MagickFalse); path=(const char *) NULL; for (i=0; i < (ssize_t) number_options; i++) { if (configure_info[i]->stealth != MagickFalse) continue; if ((path == (const char *) NULL) || (LocaleCompare(path,configure_info[i]->path) != 0)) { if (configure_info[i]->path != (char *) NULL) (void) FormatLocaleFile(file,"\nPath: %s\n\n", configure_info[i]->path); (void) FormatLocaleFile(file,"Name Value\n"); (void) FormatLocaleFile(file, "-------------------------------------------------" "------------------------------\n"); } path=configure_info[i]->path; name="unknown"; if (configure_info[i]->name != (char *) NULL) name=configure_info[i]->name; (void) FormatLocaleFile(file,"%s",name); for (j=(ssize_t) strlen(name); j <= 13; j++) (void) FormatLocaleFile(file," "); (void) FormatLocaleFile(file," "); value="unknown"; if (configure_info[i]->value != (char *) NULL) value=configure_info[i]->value; (void) FormatLocaleFile(file,"%s",value); (void) FormatLocaleFile(file,"\n"); } (void) fflush(file); configure_info=(const ConfigureInfo **) RelinquishMagickMemory((void *) configure_info); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + D e f a u l t F a t a l E r r o r H a n d l e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DefaultFatalErrorHandler() displays an error reason and then terminates the % program. % % The format of the DefaultFatalErrorHandler method is: % % void MagickFatalError(const ExceptionType severity,const char *reason, % const char *description) % % A description of each parameter follows: % % o severity: Specifies the numeric error category. % % o reason: Specifies the reason to display before terminating the % program. % % o description: Specifies any description to the reason. % */ static void DefaultFatalErrorHandler( const ExceptionType magick_unused(severity), const char *reason,const char *description) { if (reason == (char *) NULL) return; (void) FormatLocaleFile(stderr,"%s: %s",GetClientName(),reason); if (description != (char *) NULL) (void) FormatLocaleFile(stderr," (%s)",description); (void) FormatLocaleFile(stderr,".\n"); (void) fflush(stderr); MagickCoreTerminus(); exit(1); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L o c k S e m a p h o r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % LockSemaphoreInfo() locks a semaphore. % % The format of the LockSemaphoreInfo method is: % % void LockSemaphoreInfo(SemaphoreInfo *semaphore_info) % % A description of each parameter follows: % % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure. % */ MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info) { assert(semaphore_info != (SemaphoreInfo *) NULL); assert(semaphore_info->signature == MagickSignature); #if defined(MAGICKCORE_THREAD_SUPPORT) { int status; status=pthread_mutex_lock(&semaphore_info->mutex); if (status != 0) { errno=status; ThrowFatalException(ResourceLimitFatalError,"UnableToLockSemaphore"); } } #elif defined(MAGICKCORE_HAVE_WINTHREADS) EnterCriticalSection(&semaphore_info->mutex); #endif #if defined(MAGICKCORE_DEBUG) if ((semaphore_info->reference_count > 0) && (IsMagickThreadEqual(semaphore_info->id) != MagickFalse)) { (void) FormatLocaleFile(stderr,"Warning: unexpected recursive lock!\n"); (void) fflush(stderr); } #endif semaphore_info->id=GetMagickThreadId(); semaphore_info->reference_count++; }
static void OutputArtifacts(Image *image) { const char *artifact, *value; (void) FormatLocaleFile(stdout," Image Artifacts:\n"); ResetImageArtifactIterator(image); while ((artifact=GetNextImageArtifact(image)) != (const char *) NULL ) { (void) FormatLocaleFile(stdout," %s: ",artifact); value=GetImageArtifact(image,artifact); if (value != (const char *) NULL) (void) FormatLocaleFile(stdout,"%s\n",value); } ResetImageArtifactIterator(image); }
/* Temporary Debugging Information FUTURE: these should be able to be printed out using 'percent escapes' Actually 'Properities' can already be output with "%[*]" */ static void OutputOptions(ImageInfo *image_info) { const char *option, *value; (void) FormatLocaleFile(stdout," Global Options:\n"); ResetImageOptionIterator(image_info); while ((option=GetNextImageOption(image_info)) != (const char *) NULL ) { (void) FormatLocaleFile(stdout," %s: ",option); value=GetImageOption(image_info,option); if (value != (const char *) NULL) (void) FormatLocaleFile(stdout,"%s\n",value); } ResetImageOptionIterator(image_info); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % U n l o c k S e m a p h o r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % UnlockSemaphoreInfo() unlocks a semaphore. % % The format of the UnlockSemaphoreInfo method is: % % void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info) % % A description of each parameter follows: % % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure. % */ MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info) { assert(semaphore_info != (SemaphoreInfo *) NULL); assert(semaphore_info->signature == MagickSignature); #if defined(MAGICKCORE_DEBUG) assert(IsMagickThreadEqual(semaphore_info->id) != MagickFalse); if (semaphore_info->reference_count == 0) { (void) FormatLocaleFile(stderr, "Warning: semaphore lock already unlocked!\n"); (void) fflush(stderr); return; } semaphore_info->reference_count--; #endif #if defined(MAGICKCORE_THREAD_SUPPORT) { int status; status=pthread_mutex_unlock(&semaphore_info->mutex); if (status != 0) { errno=status; ThrowFatalException(ResourceLimitFatalError,"UnableToUnlockSemaphore"); } } #elif defined(MAGICKCORE_HAVE_WINTHREADS) LeaveCriticalSection(&semaphore_info->mutex); #endif }
static ssize_t PrintChannelFeatures(FILE *file,const PixelChannel channel, const char *name,const ChannelFeatures *channel_features) { #define PrintFeature(feature) \ GetMagickPrecision(),(feature)[0], \ GetMagickPrecision(),(feature)[1], \ GetMagickPrecision(),(feature)[2], \ GetMagickPrecision(),(feature)[3], \ GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \ #define FeaturesFormat " %s:\n" \ " Angular Second Moment:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Contrast:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Correlation:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Sum of Squares: Variance:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Inverse Difference Moment:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Sum Average:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Sum Variance:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Sum Entropy:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Entropy:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Difference Variance:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Difference Entropy:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Information Measure of Correlation 1:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Information Measure of Correlation 2:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ " Maximum Correlation Coefficient:\n" \ " %.*g, %.*g, %.*g, %.*g, %.*g\n" ssize_t n; n=FormatLocaleFile(file,FeaturesFormat,name, PrintFeature(channel_features[channel].angular_second_moment), PrintFeature(channel_features[channel].contrast), PrintFeature(channel_features[channel].correlation), PrintFeature(channel_features[channel].variance_sum_of_squares), PrintFeature(channel_features[channel].inverse_difference_moment), PrintFeature(channel_features[channel].sum_average), PrintFeature(channel_features[channel].sum_variance), PrintFeature(channel_features[channel].sum_entropy), PrintFeature(channel_features[channel].entropy), PrintFeature(channel_features[channel].difference_variance), PrintFeature(channel_features[channel].difference_entropy), PrintFeature(channel_features[channel].measure_of_correlation_1), PrintFeature(channel_features[channel].measure_of_correlation_2), PrintFeature(channel_features[channel].maximum_correlation_coefficient)); return(n); }
static void OutputProperties(Image *image,ExceptionInfo *exception) { const char *property, *value; (void) FormatLocaleFile(stdout," Image Properity:\n"); ResetImagePropertyIterator(image); while ((property=GetNextImageProperty(image)) != (const char *) NULL ) { (void) FormatLocaleFile(stdout," %s: ",property); value=GetImageProperty(image,property,exception); if (value != (const char *) NULL) (void) FormatLocaleFile(stdout,"%s\n",value); } ResetImagePropertyIterator(image); }
static void MagickUsage(MagickBooleanType verbose) { const char *name; size_t len; name=GetClientName(); len=strlen(name); if (len>=7 && LocaleCompare("convert",name+len-7) == 0) { /* convert usage */ (void) FormatLocaleFile(stdout, "Usage: %s [ {option} | {image} ... ] {output_image}\n",name); (void) FormatLocaleFile(stdout, " %s -help | -version | -usage | -list {option}\n\n",name); return; } else if (len>=6 && LocaleCompare("script",name+len-6) == 0) { /* magick-script usage */ (void) FormatLocaleFile(stdout, "Usage: %s {filename} [ {script_args} ... ]\n",name); } else { /* magick usage */ (void) FormatLocaleFile(stdout, "Usage: %s [ {option} | {image} ... ] {output_image}\n",name); (void) FormatLocaleFile(stdout, " %s [ {option} | {image} ... ] -script {filename} [ {script_args} ...]\n", name); } (void) FormatLocaleFile(stdout, " %s -help | -version | -usage | -list {option}\n\n",name); if (verbose == MagickFalse) return; (void) FormatLocaleFile(stdout,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "All options are performed in a strict 'as you see them' order\n", "You must read-in images before you can operate on them.\n", "\n", "Magick Script files can use any of the following forms...\n", " #!/path/to/magick -script\n", "or\n", " #!/bin/sh\n", " :; exec magick -script \"$0\" \"$@\"; exit 10\n", " # Magick script from here...\n", "or\n", " #!/usr/bin/env magick-script\n", "The latter two forms do not require the path to the command hard coded.\n", "Note: \"magick-script\" needs to be linked to the \"magick\" command.\n", "\n", "For more information on usage, options, examples, and techniques\n", "see the ImageMagick website at ", MagickAuthoritativeURL); return; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t M a g i c k R e s o u r c e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListMagickResourceInfo() lists the resource info to a file. % % The format of the ListMagickResourceInfo method is: % % MagickBooleanType ListMagickResourceInfo(FILE *file, % ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ExceptionInfo *magick_unused(exception)) { char area_limit[MaxTextExtent], disk_limit[MaxTextExtent], map_limit[MaxTextExtent], memory_limit[MaxTextExtent], time_limit[MaxTextExtent]; if (file == (const FILE *) NULL) file=stdout; if (resource_semaphore == (SemaphoreInfo *) NULL) AcquireSemaphoreInfo(&resource_semaphore); LockSemaphoreInfo(resource_semaphore); (void) FormatMagickSize(resource_info.area_limit,MagickFalse,area_limit); (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,memory_limit); (void) FormatMagickSize(resource_info.map_limit,MagickTrue,map_limit); (void) CopyMagickString(disk_limit,"unlimited",MaxTextExtent); if (resource_info.disk_limit != MagickResourceInfinity) (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,disk_limit); (void) CopyMagickString(time_limit,"unlimited",MaxTextExtent); if (resource_info.time_limit != MagickResourceInfinity) (void) FormatLocaleString(time_limit,MaxTextExtent,"%.20g",(double) ((MagickOffsetType) resource_info.time_limit)); (void) FormatLocaleFile(file," File Area Memory Map" " Disk Thread Throttle Time\n"); (void) FormatLocaleFile(file, "--------------------------------------------------------" "------------------------\n"); (void) FormatLocaleFile(file,"%6g %10s %10s %10s %10s %8g %8g %10s\n", (double) ((MagickOffsetType) resource_info.file_limit),area_limit, memory_limit,map_limit,disk_limit,(double) ((MagickOffsetType) resource_info.thread_limit),(double) ((MagickOffsetType) resource_info.throttle_limit),time_limit); (void) fflush(file); UnlockSemaphoreInfo(resource_semaphore); return(MagickTrue); }
static int PrintChannelStatistics(FILE *file,const ChannelType channel, const char *name,const double scale, const ChannelStatistics *channel_statistics) { #define StatisticsFormat " %s:\n min: " QuantumFormat \ " (%g)\n max: " QuantumFormat " (%g)\n" \ " mean: %g (%g)\n standard deviation: %g (%g)\n" \ " kurtosis: %g\n skewness: %g\n" int status; if (channel == AlphaChannel) { status=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale* (QuantumRange-channel_statistics[channel].maxima)), (QuantumRange-channel_statistics[channel].maxima)/(double) QuantumRange, ClampToQuantum(scale*(QuantumRange-channel_statistics[channel].minima)), (QuantumRange-channel_statistics[channel].minima)/(double) QuantumRange, scale*(QuantumRange-channel_statistics[channel].mean),(QuantumRange- channel_statistics[channel].mean)/(double) QuantumRange,scale* channel_statistics[channel].standard_deviation, channel_statistics[channel].standard_deviation/(double) QuantumRange, channel_statistics[channel].kurtosis, channel_statistics[channel].skewness); return(status); } status=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale* channel_statistics[channel].minima),channel_statistics[channel].minima/ (double) QuantumRange,ClampToQuantum(scale* channel_statistics[channel].maxima),channel_statistics[channel].maxima/ (double) QuantumRange,scale*channel_statistics[channel].mean, channel_statistics[channel].mean/(double) QuantumRange,scale* channel_statistics[channel].standard_deviation, channel_statistics[channel].standard_deviation/(double) QuantumRange, channel_statistics[channel].kurtosis,channel_statistics[channel].skewness); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t C o d e r I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListCoderInfo() lists the coder info to a file. % % The format of the ListCoderInfo coder is: % % MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListCoderInfo(FILE *file, ExceptionInfo *exception) { const char *path; const CoderInfo **coder_info; register ssize_t i; size_t number_coders; ssize_t j; if (file == (const FILE *) NULL) file=stdout; coder_info=GetCoderInfoList("*",&number_coders,exception); if (coder_info == (const CoderInfo **) NULL) return(MagickFalse); path=(const char *) NULL; for (i=0; i < (ssize_t) number_coders; i++) { if (coder_info[i]->stealth != MagickFalse) continue; if ((path == (const char *) NULL) || (LocaleCompare(path,coder_info[i]->path) != 0)) { if (coder_info[i]->path != (char *) NULL) (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path); (void) FormatLocaleFile(file,"Magick Coder\n"); (void) FormatLocaleFile(file, "-------------------------------------------------" "------------------------------\n"); } path=coder_info[i]->path; (void) FormatLocaleFile(file,"%s",coder_info[i]->magick); for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++) (void) FormatLocaleFile(file," "); if (coder_info[i]->name != (char *) NULL) (void) FormatLocaleFile(file,"%s",coder_info[i]->name); (void) FormatLocaleFile(file,"\n"); } coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info); (void) fflush(file); return(MagickTrue); }
static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel, const char *name,const double scale, const ChannelStatistics *channel_statistics) { #define StatisticsFormat " %s:\n min: " QuantumFormat \ " (%g)\n max: " QuantumFormat " (%g)\n" \ " mean: %g (%g)\n standard deviation: %g (%g)\n" \ " kurtosis: %g\n skewness: %g\n" ssize_t n; n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale* channel_statistics[channel].minima),channel_statistics[channel].minima/ (double) QuantumRange,ClampToQuantum(scale* channel_statistics[channel].maxima),channel_statistics[channel].maxima/ (double) QuantumRange,scale*channel_statistics[channel].mean, channel_statistics[channel].mean/(double) QuantumRange,scale* channel_statistics[channel].standard_deviation, channel_statistics[channel].standard_deviation/(double) QuantumRange, channel_statistics[channel].kurtosis,channel_statistics[channel].skewness); return(n); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t T y p e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListTypeInfo() lists the fonts to a file. % % The format of the ListTypeInfo method is: % % MagickBooleanType ListTypeInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListTypeInfo(FILE *file,ExceptionInfo *exception) { char weight[MaxTextExtent]; const char *family, *glyphs, *name, *path, *stretch, *style; const TypeInfo **type_info; register ssize_t i; size_t number_fonts; if (file == (FILE *) NULL) file=stdout; number_fonts=0; type_info=GetTypeInfoList("*",&number_fonts,exception); if (type_info == (const TypeInfo **) NULL) return(MagickFalse); *weight='\0'; path=(const char *) NULL; for (i=0; i < (ssize_t) number_fonts; i++) { if (type_info[i]->stealth != MagickFalse) continue; if (((path == (const char *) NULL) || (LocaleCompare(path,type_info[i]->path) != 0)) && (type_info[i]->path != (char *) NULL)) (void) FormatLocaleFile(file,"\nPath: %s\n",type_info[i]->path); path=type_info[i]->path; name="unknown"; if (type_info[i]->name != (char *) NULL) name=type_info[i]->name; family="unknown"; if (type_info[i]->family != (char *) NULL) family=type_info[i]->family; style=CommandOptionToMnemonic(MagickStyleOptions,type_info[i]->style); stretch=CommandOptionToMnemonic(MagickStretchOptions,type_info[i]->stretch); glyphs="unknown"; if (type_info[i]->glyphs != (char *) NULL) glyphs=type_info[i]->glyphs; (void) FormatLocaleString(weight,MaxTextExtent,"%.20g",(double) type_info[i]->weight); (void) FormatLocaleFile(file," Font: %s\n",name); (void) FormatLocaleFile(file," family: %s\n",family); (void) FormatLocaleFile(file," style: %s\n",style); (void) FormatLocaleFile(file," stretch: %s\n",stretch); (void) FormatLocaleFile(file," weight: %s\n",weight); (void) FormatLocaleFile(file," glyphs: %s\n",glyphs); } (void) fflush(file); type_info=(const TypeInfo **) RelinquishMagickMemory((void *) type_info); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t M a g i c I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListMagicInfo() lists the magic info to a file. % % The format of the ListMagicInfo method is: % % MagickBooleanType ListMagicInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListMagicInfo(FILE *file, ExceptionInfo *exception) { const char *path; const MagicInfo **magic_info; register ssize_t i; size_t number_aliases; ssize_t j; if (file == (const FILE *) NULL) file=stdout; magic_info=GetMagicInfoList("*",&number_aliases,exception); if (magic_info == (const MagicInfo **) NULL) return(MagickFalse); j=0; path=(const char *) NULL; for (i=0; i < (ssize_t) number_aliases; i++) { if (magic_info[i]->stealth != MagickFalse) continue; if ((path == (const char *) NULL) || (LocaleCompare(path,magic_info[i]->path) != 0)) { if (magic_info[i]->path != (char *) NULL) (void) FormatLocaleFile(file,"\nPath: %s\n\n",magic_info[i]->path); (void) FormatLocaleFile(file,"Name Offset Target\n"); (void) FormatLocaleFile(file, "-------------------------------------------------" "------------------------------\n"); } path=magic_info[i]->path; (void) FormatLocaleFile(file,"%s",magic_info[i]->name); for (j=(ssize_t) strlen(magic_info[i]->name); j <= 9; j++) (void) FormatLocaleFile(file," "); (void) FormatLocaleFile(file,"%6ld ",(long) magic_info[i]->offset); if (magic_info[i]->target != (char *) NULL) { register ssize_t j; for (j=0; magic_info[i]->target[j] != '\0'; j++) if (isprint((int) ((unsigned char) magic_info[i]->target[j])) != 0) (void) FormatLocaleFile(file,"%c",magic_info[i]->target[j]); else (void) FormatLocaleFile(file,"\\%03o",(unsigned int) ((unsigned char) magic_info[i]->target[j])); } (void) FormatLocaleFile(file,"\n"); } (void) fflush(file); magic_info=(const MagicInfo **) RelinquishMagickMemory((void *) magic_info); return(MagickTrue); }
WandExport MagickBooleanType ImportImageCommand(ImageInfo *image_info, int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) { #if defined(MAGICKCORE_X11_DELEGATE) #define DestroyImport() \ { \ XDestroyResourceInfo(&resource_info); \ if (display != (Display *) NULL) \ { \ XCloseDisplay(display); \ display=(Display *) NULL; \ } \ DestroyImageStack(); \ if (target_window != (char *) NULL) \ target_window=DestroyString(target_window); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowImportException(asperity,tag,option) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ option); \ DestroyImport(); \ return(MagickFalse); \ } #define ThrowImportInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","`%s': %s",option,argument); \ DestroyImport(); \ return(MagickFalse); \ } char *filename, *option, *resource_value, *server_name, *target_window; Display *display; Image *image; ImageStack image_stack[MaxImageStackDepth+1]; MagickBooleanType fire, pend, respect_parenthesis; MagickStatusType status; QuantizeInfo *quantize_info; register ssize_t i; ssize_t j, k, snapshots; XImportInfo ximage_info; XResourceInfo resource_info; XrmDatabase resource_database; /* Set defaults. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(exception != (ExceptionInfo *) NULL); if (argc == 2) { option=argv[1]; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); return(MagickFalse); } } display=(Display *) NULL; j=1; k=0; NewImageStack(); option=(char *) NULL; pend=MagickFalse; resource_database=(XrmDatabase) NULL; respect_parenthesis=MagickFalse; (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info)); server_name=(char *) NULL; status=MagickTrue; SetNotifyHandlers; target_window=(char *) NULL; /* Check for server name specified on the command line. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowImportException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); for (i=1; i < (ssize_t) argc; i++) { /* Check command line for server name. */ option=argv[i]; if (LocaleCompare("display",option+1) == 0) { /* User specified server name. */ i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); server_name=argv[i]; } if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) return(ImportUsage()); } /* Get user defaults from X resource database. */ display=XOpenDisplay(server_name); if (display == (Display *) NULL) ThrowImportException(XServerError,"UnableToOpenXServer", XDisplayName(server_name)); (void) XSetErrorHandler(XError); resource_database=XGetResourceDatabase(display,GetClientName()); XGetImportInfo(&ximage_info); XGetResourceInfo(image_info,resource_database,GetClientName(), &resource_info); quantize_info=resource_info.quantize_info; resource_value=XGetResourceInstance(resource_database,GetClientName(), "border","False"); ximage_info.borders=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "delay","0"); resource_info.delay=(unsigned int) StringToUnsignedLong(resource_value); image_info->density=XGetResourceInstance(resource_database,GetClientName(), "density",(char *) NULL); resource_value=XGetResourceInstance(resource_database,GetClientName(), "descend","True"); ximage_info.descend=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "frame","False"); ximage_info.frame=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "interlace","none"); image_info->interlace=UndefinedInterlace; if (LocaleCompare("None",resource_value) == 0) image_info->interlace=NoInterlace; if (LocaleCompare("Line",resource_value) == 0) image_info->interlace=LineInterlace; if (LocaleCompare("Plane",resource_value) == 0) image_info->interlace=PlaneInterlace; if (LocaleCompare("Partition",resource_value) == 0) image_info->interlace=PartitionInterlace; if (image_info->interlace == UndefinedInterlace) ThrowImportException(OptionError,"Unrecognized interlace type", resource_value); image_info->page=XGetResourceInstance(resource_database,GetClientName(), "pageGeometry",(char *) NULL); resource_value=XGetResourceInstance(resource_database,GetClientName(), "pause","0"); resource_info.pause=(unsigned int) StringToUnsignedLong(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "quality","85"); image_info->quality=StringToUnsignedLong(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "screen","False"); ximage_info.screen=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "silent","False"); ximage_info.silent=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "verbose","False"); image_info->verbose=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "dither","True"); quantize_info->dither=IsMagickTrue(resource_value); snapshots=1; status=MagickTrue; filename=(char *) NULL; /* Check command syntax. */ for (i=1; i < (ssize_t) argc; i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { FireImageStack(MagickFalse,MagickTrue,pend); if (k == MaxImageStackDepth) ThrowImportException(OptionError,"ParenthesisNestedTooDeeply", option); PushImageStack(); continue; } if (LocaleCompare(option,")") == 0) { FireImageStack(MagickFalse,MagickTrue,MagickTrue); if (k == 0) ThrowImportException(OptionError,"UnableToParseExpression",option); PopImageStack(); continue; } if (IsCommandOption(option) == MagickFalse) { Image *images; size_t scene; /* Read image from X server. */ FireImageStack(MagickFalse,MagickFalse,pend); filename=argv[i]; if (target_window != (char *) NULL) (void) CopyMagickString(image_info->filename,target_window, MaxTextExtent); for (scene=0; scene < (size_t) MagickMax(snapshots,1); scene++) { (void) sleep(resource_info.pause); images=XImportImage(image_info,&ximage_info); status&=(images != (Image *) NULL) && (exception->severity < ErrorException); if (images == (Image *) NULL) continue; (void) CopyMagickString(images->filename,filename,MaxTextExtent); (void) CopyMagickString(images->magick,"PS",MaxTextExtent); images->scene=scene; AppendImageStack(images); } continue; } pend=image != (Image *) NULL ? MagickTrue : MagickFalse; switch(*(option+1)) { case 'a': { if (LocaleCompare("adjoin",option+1) == 0) break; if (LocaleCompare("annotate",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); i++; break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'b': { if (LocaleCompare("border",option+1) == 0) { (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); ximage_info.borders=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("bordercolor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { ssize_t channel; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowImportException(OptionError,"UnrecognizedChannelType", argv[i]); break; } if (LocaleCompare("colors",option+1) == 0) { quantize_info->number_colors=0; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); quantize_info->number_colors=StringToUnsignedLong(argv[i]); break; } if (LocaleCompare("colorspace",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, argv[i]); if (colorspace < 0) ThrowImportException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("comment",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"comment",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("compress",option+1) == 0) { ssize_t compress; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); compress=ParseCommandOption(MagickCompressOptions,MagickFalse, argv[i]); if (compress < 0) ThrowImportException(OptionError,"UnrecognizedImageCompression", argv[i]); break; } if (LocaleCompare("concurrent",option+1) == 0) break; if (LocaleCompare("crop",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'd': { if (LocaleCompare("debug",option+1) == 0) { ssize_t event; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); if (event < 0) ThrowImportException(OptionError,"UnrecognizedEventType",argv[i]); (void) SetLogEventMask(argv[i]); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (char *) NULL) ThrowImportException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("delay",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); status=SetImageOption(image_info,"delay",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("descend",option+1) == 0) { ximage_info.descend=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("display",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("dispose",option+1) == 0) { ssize_t dispose; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); if (dispose < 0) ThrowImportException(OptionError,"UnrecognizedDisposeMethod", argv[i]); break; } if (LocaleCompare("dither",option+1) == 0) { ssize_t method; quantize_info->dither=MagickFalse; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); if (method < 0) ThrowImportException(OptionError,"UnrecognizedDitherMethod", argv[i]); quantize_info->dither=MagickTrue; quantize_info->dither_method=(DitherMethod) method; break; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'e': { if (LocaleCompare("encipher",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("encoding",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("endian",option+1) == 0) { ssize_t endian; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); endian=ParseCommandOption(MagickEndianOptions,MagickFalse, argv[i]); if (endian < 0) ThrowImportException(OptionError,"UnrecognizedEndianType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'f': { if (LocaleCompare("filter",option+1) == 0) { ssize_t filter; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); if (filter < 0) ThrowImportException(OptionError,"UnrecognizedImageFilter", argv[i]); break; } if (LocaleCompare("frame",option+1) == 0) { (void) CopyMagickString(argv[i]+1,"sans0",MaxTextExtent); ximage_info.frame=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("format",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'g': { if (LocaleCompare("geometry",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("gravity",option+1) == 0) { ssize_t gravity; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); if (gravity < 0) ThrowImportException(OptionError,"UnrecognizedGravityType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'h': { if (LocaleCompare("help",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'i': { if (LocaleCompare("identify",option+1) == 0) break; if (LocaleCompare("interlace",option+1) == 0) { ssize_t interlace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowImportException(OptionError,"UnrecognizedInterlaceType", argv[i]); break; } if (LocaleCompare("interpolate",option+1) == 0) { ssize_t interpolate; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, argv[i]); if (interpolate < 0) ThrowImportException(OptionError,"UnrecognizedInterpolateMethod", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'l': { if (LocaleCompare("label",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"label",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("limit",option+1) == 0) { char *p; double value; ssize_t resource; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); resource=ParseCommandOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowImportException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); value=InterpretLocaleValue(argv[i],&p); (void) value; if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("list",option+1) == 0) { ssize_t list; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); if (list < 0) ThrowImportException(OptionError,"UnrecognizedListType",argv[i]); status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) argv+j,exception); DestroyImport(); return(status != 0 ? MagickFalse : MagickTrue); } if (LocaleCompare("log",option+1) == 0) { if (*option == '+') break; i++; if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'm': { if (LocaleCompare("monitor",option+1) == 0) break; if (LocaleCompare("monochrome",option+1) == 0) { if (*option == '+') break; quantize_info->number_colors=2; quantize_info->colorspace=GRAYColorspace; break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'n': { if (LocaleCompare("negate",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'p': { if (LocaleCompare("page",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"page",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("pause",option+1) == 0) { resource_info.pause=0; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]); break; } if (LocaleCompare("ping",option+1) == 0) break; /* deprecated option */ if (LocaleCompare("pointsize",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'q': { if (LocaleCompare("quality",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("quantize",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions, MagickFalse,argv[i]); if (colorspace < 0) ThrowImportException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("quiet",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'r': { if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleCompare("repage",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("resize",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleNCompare("respect-parentheses",option+1,17) == 0) { respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("rotate",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("scene",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("screen",option+1) == 0) { ximage_info.screen=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("silent",option+1) == 0) { ximage_info.silent=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("snaps",option+1) == 0) { (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); snapshots=(ssize_t) StringToLong(argv[i]); break; } if (LocaleCompare("strip",option+1) == 0) break; if (LocaleCompare("support",option+1) == 0) { i++; /* deprecated */ break; } if (LocaleCompare("synchronize",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 't': { if (LocaleCompare("taint",option+1) == 0) break; if (LocaleCompare("thumbnail",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("transparent",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("transparent-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("treedepth",option+1) == 0) { quantize_info->tree_depth=0; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); quantize_info->tree_depth=StringToUnsignedLong(argv[i]); break; } if (LocaleCompare("trim",option+1) == 0) break; if (LocaleCompare("type",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); if (type < 0) ThrowImportException(OptionError,"UnrecognizedImageType",argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'w': { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); (void) CloneString(&target_window,argv[i]); break; } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case '?': break; default: ThrowImportException(OptionError,"UnrecognizedOption",option); } fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & FireOptionFlag) == 0 ? MagickFalse : MagickTrue; if (fire != MagickFalse) FireImageStack(MagickFalse,MagickTrue,MagickTrue); } if (k != 0) ThrowImportException(OptionError,"UnbalancedParenthesis",argv[i]); if (i-- != (ssize_t) argc) ThrowImportException(OptionError,"MissingAnImageFilename",argv[i]); if (image == (Image *) NULL) ThrowImportException(OptionError,"MissingAnImageFilename",argv[argc-1]); FinalizeImageSettings(image_info,image,MagickTrue); status&=WriteImages(image_info,image,filename,exception); DestroyImport(); return(status != 0 ? MagickTrue : MagickFalse); #else (void) argc; (void) argv; (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError, "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename); return(ImportUsage()); #endif }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t P o l i c y I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListPolicyInfo() lists policies to the specified file. % % The format of the ListPolicyInfo method is: % % MagickBooleanType ListPolicyInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: List policy names to this file handle. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListPolicyInfo(FILE *file, ExceptionInfo *exception) { const char *path, *domain; const PolicyInfo **policy_info; register ssize_t i; size_t number_policies; /* List name and attributes of each policy in the list. */ if (file == (const FILE *) NULL) file=stdout; policy_info=GetPolicyInfoList("*",&number_policies,exception); if (policy_info == (const PolicyInfo **) NULL) return(MagickFalse); path=(const char *) NULL; for (i=0; i < (ssize_t) number_policies; i++) { if (policy_info[i]->stealth != MagickFalse) continue; if (((path == (const char *) NULL) || (LocaleCompare(path,policy_info[i]->path) != 0)) && (policy_info[i]->path != (char *) NULL)) (void) FormatLocaleFile(file,"\nPath: %s\n",policy_info[i]->path); path=policy_info[i]->path; domain=CommandOptionToMnemonic(MagickPolicyDomainOptions, policy_info[i]->domain); (void) FormatLocaleFile(file," Policy: %s\n",domain); if ((policy_info[i]->domain == ResourcePolicyDomain) || (policy_info[i]->domain == SystemPolicyDomain)) { if (policy_info[i]->name != (char *) NULL) (void) FormatLocaleFile(file," name: %s\n",policy_info[i]->name); if (policy_info[i]->value != (char *) NULL) (void) FormatLocaleFile(file," value: %s\n",policy_info[i]->value); } else { (void) FormatLocaleFile(file," rights: "); if (policy_info[i]->rights == NoPolicyRights) (void) FormatLocaleFile(file,"None "); if ((policy_info[i]->rights & ReadPolicyRights) != 0) (void) FormatLocaleFile(file,"Read "); if ((policy_info[i]->rights & WritePolicyRights) != 0) (void) FormatLocaleFile(file,"Write "); if ((policy_info[i]->rights & ExecutePolicyRights) != 0) (void) FormatLocaleFile(file,"Execute "); (void) FormatLocaleFile(file,"\n"); if (policy_info[i]->pattern != (char *) NULL) (void) FormatLocaleFile(file," pattern: %s\n", policy_info[i]->pattern); } } policy_info=(const PolicyInfo **) RelinquishMagickMemory((void *) policy_info); (void) fflush(file); return(MagickTrue); }
int main(int argc,char **argv) { #define ThrowAPIException(wand) \ { \ description=MagickGetException(wand,&severity); \ (void) FormatLocaleFile(stderr,"%s %s %lu %s\n",GetMagickModule(), \ description); \ description=(char *) MagickRelinquishMemory(description); \ exit(-1); \ } static char CustomOption[] = "custom option", CustomProperty[] = "custom profile"; static unsigned char sRGBProfile[] = { 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00, 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00, 0x31, 0x00, 0x00, 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x33, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x84, 0x00, 0x00, 0x00, 0x6c, 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x14, 0x62, 0x6b, 0x70, 0x74, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x14, 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x02, 0x18, 0x00, 0x00, 0x00, 0x14, 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x00, 0x14, 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x14, 0x64, 0x6d, 0x6e, 0x64, 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00, 0x70, 0x64, 0x6d, 0x64, 0x64, 0x00, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x00, 0x88, 0x76, 0x75, 0x65, 0x64, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x86, 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x03, 0xd4, 0x00, 0x00, 0x00, 0x24, 0x6c, 0x75, 0x6d, 0x69, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x14, 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x24, 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x00, 0x0c, 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x3c, 0x00, 0x00, 0x08, 0x0c, 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x3c, 0x00, 0x00, 0x08, 0x0c, 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x3c, 0x00, 0x00, 0x08, 0x0c, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x65, 0x77, 0x6c, 0x65, 0x74, 0x74, 0x2d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x72, 0x64, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa2, 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x99, 0x00, 0x00, 0xb7, 0x85, 0x00, 0x00, 0x18, 0xda, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0xa0, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xcf, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x65, 0x63, 0x2e, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x65, 0x63, 0x2e, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x56, 0x69, 0x65, 0x77, 0x69, 0x6e, 0x67, 0x20, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x56, 0x69, 0x65, 0x77, 0x69, 0x6e, 0x67, 0x20, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xa4, 0xfe, 0x00, 0x14, 0x5f, 0x2e, 0x00, 0x10, 0xcf, 0x14, 0x00, 0x03, 0xed, 0xcc, 0x00, 0x04, 0x13, 0x0b, 0x00, 0x03, 0x5c, 0x9e, 0x00, 0x00, 0x00, 0x01, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x09, 0x56, 0x00, 0x50, 0x00, 0x00, 0x00, 0x57, 0x1f, 0xe7, 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x8f, 0x00, 0x00, 0x00, 0x02, 0x73, 0x69, 0x67, 0x20, 0x00, 0x00, 0x00, 0x00, 0x43, 0x52, 0x54, 0x20, 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19, 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37, 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54, 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72, 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90, 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae, 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb, 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb, 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d, 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32, 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59, 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83, 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1, 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1, 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14, 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b, 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84, 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1, 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00, 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43, 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a, 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3, 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20, 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71, 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4, 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c, 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77, 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5, 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37, 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d, 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07, 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74, 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5, 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a, 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2, 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f, 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf, 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54, 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc, 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69, 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9, 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e, 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26, 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3, 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64, 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09, 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3, 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61, 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13, 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9, 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84, 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43, 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06, 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce, 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b, 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c, 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41, 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b, 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa, 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd, 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5, 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2, 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3, 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99, 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94, 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94, 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98, 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1, 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf, 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2, 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda, 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7, 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18, 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f, 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b, 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b, 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1, 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c, 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c, 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91, 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb, 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a, 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f, 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8, 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37, 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c, 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05, 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74, 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8, 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61, 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0, 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64, 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee, 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d, 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12, 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab, 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b, 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0, 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a, 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a, 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00, 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb, 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c, 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42, 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f, 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0, 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8, 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95, 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78, 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61, 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f, 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43, 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d, 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d, 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43, 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f, 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60, 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78, 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95, 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8, 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1, 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11, 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46, 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81, 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2, 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a, 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57, 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab, 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04, 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64, 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca, 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36, 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8, 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20, 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f, 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24, 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf, 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40, 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8, 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76, 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a, 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4, 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75, 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d, 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea, 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae, 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79, 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a, 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21, 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff, 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3, 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce, 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf, 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7, 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5, 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba, 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6, 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8, 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1, 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10, 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36, 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63, 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96, 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0, 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11, 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58, 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7, 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb, 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57, 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba, 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff }; char *description, **options, **profiles, **properties; const char *option, *property; DrawingWand *drawing_wand; ExceptionType severity; MagickWand *clone_wand, *magick_wand; PixelIterator *iterator; PixelWand *background, *border, *fill, **pixels; register ssize_t i; unsigned char *profile; unsigned int status; size_t columns, delay, length, number_options, number_profiles, number_properties, number_wands, rows; (void) argc; (void) argv; MagickWandGenesis(); magick_wand=NewMagickWand(); (void) MagickSetSize(magick_wand,640,480); (void) MagickGetSize(magick_wand,&columns,&rows); if ((columns != 640) || (rows != 480)) { (void) FormatLocaleFile(stderr,"Unexpected magick wand size\n"); exit(1); } (void) FormatLocaleFile(stdout,"Reading images...\n"); { char *p, path[MaxTextExtent]; path[0]=0; p=getenv("SRCDIR"); if (p != (char *) NULL) { (void) strcpy(path,p); if (path[strlen(path)-1] != '/') (void) strcat(path,"/"); } (void) strcat(path,"sequence.miff"); status=MagickReadImage(magick_wand,path); } if (status == MagickFalse) ThrowAPIException(magick_wand); if (MagickGetNumberImages(magick_wand) != 5) (void) FormatLocaleFile(stderr,"read %.20g images; expected 5\n", (double) MagickGetNumberImages(magick_wand)); (void) FormatLocaleFile(stdout,"Iterate forward...\n"); MagickResetIterator(magick_wand); while (MagickNextImage(magick_wand) != MagickFalse) (void) FormatLocaleFile(stdout,"index %.20g scene %.20g\n",(double) MagickGetIteratorIndex(magick_wand),(double) MagickGetImageScene(magick_wand)); (void) FormatLocaleFile(stdout,"Iterate reverse...\n"); while (MagickPreviousImage(magick_wand) != MagickFalse) (void) FormatLocaleFile(stdout,"index %.20g scene %.20g\n",(double) MagickGetIteratorIndex(magick_wand),(double) MagickGetImageScene(magick_wand)); (void) FormatLocaleFile(stdout,"Remove scene 1...\n"); (void) MagickSetIteratorIndex(magick_wand,1); clone_wand=MagickGetImage(magick_wand); status=MagickRemoveImage(magick_wand); if (status == MagickFalse) ThrowAPIException(magick_wand); MagickResetIterator(magick_wand); while (MagickNextImage(magick_wand) != MagickFalse) (void) FormatLocaleFile(stdout,"index %.20g scene %.20g\n",(double) MagickGetIteratorIndex(magick_wand),(double) MagickGetImageScene(magick_wand)); (void) FormatLocaleFile(stdout,"Insert scene 1 back in sequence...\n"); (void) MagickSetIteratorIndex(magick_wand,0); status=MagickAddImage(magick_wand,clone_wand); if (status == MagickFalse) ThrowAPIException(magick_wand); MagickResetIterator(magick_wand); while (MagickNextImage(magick_wand) != MagickFalse) (void) FormatLocaleFile(stdout,"index %.20g scene %.20g\n",(double) MagickGetIteratorIndex(magick_wand),(double) MagickGetImageScene(magick_wand)); (void) FormatLocaleFile(stdout,"Set scene 2 to scene 1...\n"); (void) MagickSetIteratorIndex(magick_wand,2); status=MagickSetImage(magick_wand,clone_wand); clone_wand=DestroyMagickWand(clone_wand); if (status == MagickFalse) ThrowAPIException(magick_wand); MagickResetIterator(magick_wand); while (MagickNextImage(magick_wand) != MagickFalse) (void) FormatLocaleFile(stdout,"index %.20g scene %.20g\n",(double) MagickGetIteratorIndex(magick_wand),(double) MagickGetImageScene(magick_wand)); (void) FormatLocaleFile(stdout,"Apply image processing options...\n"); status=MagickCropImage(magick_wand,60,60,10,10); if (status == MagickFalse) ThrowAPIException(magick_wand); MagickResetIterator(magick_wand); background=NewPixelWand(); status=PixelSetColor(background,"#000000"); if (status == MagickFalse) ThrowAPIException(magick_wand); status=MagickRotateImage(magick_wand,background,90.0); if (status == MagickFalse) ThrowAPIException(magick_wand); border=NewPixelWand(); (void) PixelSetColor(background,"green"); (void) PixelSetColor(border,"black"); status=MagickFloodfillPaintImage(magick_wand,CompositeChannels,background, 0.01*QuantumRange,border,0,0,MagickFalse); if (status == MagickFalse) ThrowAPIException(magick_wand); background=DestroyPixelWand(background); border=DestroyPixelWand(border); drawing_wand=NewDrawingWand(); (void) PushDrawingWand(drawing_wand); (void) DrawRotate(drawing_wand,45); (void) DrawSetFontSize(drawing_wand,18); fill=NewPixelWand(); (void) PixelSetColor(fill,"green"); (void) DrawSetFillColor(drawing_wand,fill); fill=DestroyPixelWand(fill); (void) DrawAnnotation(drawing_wand,15,5,(const unsigned char *) "Magick"); (void) PopDrawingWand(drawing_wand); (void) MagickSetIteratorIndex(magick_wand,1); status=MagickDrawImage(magick_wand,drawing_wand); if (status == MagickFalse) ThrowAPIException(magick_wand); status=MagickAnnotateImage(magick_wand,drawing_wand,70,5,90,"Image"); if (status == MagickFalse) ThrowAPIException(magick_wand); drawing_wand=DestroyDrawingWand(drawing_wand); { unsigned char pixels[27], primary_colors[27] = { 0, 0, 0, 0, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 128, 128, 128, }; (void) MagickSetIteratorIndex(magick_wand,2); status=MagickImportImagePixels(magick_wand,10,10,3,3,"RGB",CharPixel, primary_colors); if (status == MagickFalse) ThrowAPIException(magick_wand); status=MagickExportImagePixels(magick_wand,10,10,3,3,"RGB",CharPixel, pixels); if (status == MagickFalse) ThrowAPIException(magick_wand); for (i=0; i < 9; i++) if (pixels[i] != primary_colors[i]) { (void) FormatLocaleFile(stderr, "Get pixels does not match set pixels\n"); exit(1); } } (void) MagickSetIteratorIndex(magick_wand,3); status=MagickResizeImage(magick_wand,50,50,UndefinedFilter,1.0); if (status == MagickFalse) ThrowAPIException(magick_wand); MagickResetIterator(magick_wand); while (MagickNextImage(magick_wand) != MagickFalse) { (void) MagickSetImageDepth(magick_wand,8); (void) MagickSetImageCompression(magick_wand,RLECompression); } MagickResetIterator(magick_wand); (void) MagickSetIteratorIndex(magick_wand,4); (void) FormatLocaleFile(stdout, "Utilitize pixel iterator to draw diagonal...\n"); iterator=NewPixelIterator(magick_wand); if (iterator == (PixelIterator *) NULL) ThrowAPIException(magick_wand); pixels=PixelGetNextIteratorRow(iterator,&number_wands); for (i=0; pixels != (PixelWand **) NULL; i++) { (void) PixelSetColor(pixels[i],"#224466"); (void) PixelSyncIterator(iterator); pixels=PixelGetNextIteratorRow(iterator,&number_wands); } (void) PixelSyncIterator(iterator); iterator=DestroyPixelIterator(iterator); (void) FormatLocaleFile(stdout,"Write to wandtest_out.miff...\n"); status=MagickWriteImages(magick_wand,"wandtest_out.miff",MagickTrue); if (status == MagickFalse) ThrowAPIException(magick_wand); (void) FormatLocaleFile(stdout, "Change image format from \"MIFF\" to \"GIF\"...\n"); status=MagickSetImageFormat(magick_wand,"GIF"); if (status == MagickFalse) ThrowAPIException(magick_wand); (void) FormatLocaleFile(stdout,"Set delay between frames to %d seconds...\n", WandDelay); status=MagickSetImageDelay(magick_wand,100*WandDelay); if (status == MagickFalse) ThrowAPIException(magick_wand); delay=MagickGetImageDelay(magick_wand); if (delay != (100*WandDelay)) { (void) FormatLocaleFile(stderr,"Get delay does not match set delay\n"); exit(1); } (void) FormatLocaleFile(stdout,"Write to wandtest_out_0.gif...\n"); status=MagickWriteImages(magick_wand,"wandtest_out.gif",MagickTrue); if (status == MagickFalse) ThrowAPIException(magick_wand); (void) FormatLocaleFile(stdout,"Set, list, get, and delete wand option...\n"); status=MagickSetOption(magick_wand,"wand:custom-option",CustomOption); if (status == MagickFalse) ThrowAPIException(magick_wand); option=MagickGetOption(magick_wand,"wand:custom-option"); if ((option == (const char *) NULL) || (strlen(option) != strlen(CustomOption)) || (memcmp(option,CustomOption,strlen(option)) != 0)) { (void) FormatLocaleFile(stderr,"Option does not match\n"); exit(1); } options=MagickGetOptions(magick_wand,"*",&number_options); if (options != (char **) NULL) { for (i=0; i < (ssize_t) number_options; i++) { (void) FormatLocaleFile(stdout," %s\n",options[i]); options[i]=(char *) MagickRelinquishMemory(options[i]); } options=(char **) MagickRelinquishMemory(options); } status=MagickDeleteOption(magick_wand,"wand:custom-option"); if (status == MagickFalse) ThrowAPIException(magick_wand); (void) FormatLocaleFile(stdout, "Set, list, get, and delete wand property...\n"); status=MagickSetImageProperty(magick_wand,"wand:custom-property", CustomProperty); if (status == MagickFalse) ThrowAPIException(magick_wand); property=MagickGetImageProperty(magick_wand,"wand:custom-property"); if ((property == (const char *) NULL) || (strlen(property) != strlen(CustomProperty)) || (memcmp(property,CustomProperty,strlen(property)) != 0)) { (void) FormatLocaleFile(stderr,"Property does not match\n"); exit(1); } properties=MagickGetImageProperties(magick_wand,"*",&number_properties); if (properties != (char **) NULL) { for (i=0; i < (ssize_t) number_properties; i++) { (void) FormatLocaleFile(stdout," %s\n",properties[i]); properties[i]=(char *) MagickRelinquishMemory(properties[i]); } properties=(char **) MagickRelinquishMemory(properties); } status=MagickDeleteImageProperty(magick_wand,"wand:custom-property"); if (status == MagickFalse) ThrowAPIException(magick_wand); (void) FormatLocaleFile(stdout, "Set, list, get, and remove sRGB color profile...\n"); status=MagickSetImageProfile(magick_wand,"sRGB",sRGBProfile, sizeof(sRGBProfile)); if (status == MagickFalse) ThrowAPIException(magick_wand); profile=(unsigned char *) MagickGetImageProfile(magick_wand,"sRGB",&length); if ((profile == (unsigned char *) NULL) || (length != sizeof(sRGBProfile)) || (memcmp(profile,sRGBProfile,length) != 0)) { (void) FormatLocaleFile(stderr,"Profile does not match\n"); exit(1); } profile=(unsigned char *) MagickRelinquishMemory(profile); profiles=MagickGetImageProfiles(magick_wand,"*",&number_profiles); if (profiles != (char **) NULL) { for (i=0; i < (ssize_t) number_profiles; i++) { (void) FormatLocaleFile(stdout," %s\n",profiles[i]); profiles[i]=(char *) MagickRelinquishMemory(profiles[i]); } profiles=(char **) MagickRelinquishMemory(profiles); } profile=(unsigned char *) MagickRemoveImageProfile(magick_wand,"sRGB", &length); if ((profile == (unsigned char *) NULL) || (length != sizeof(sRGBProfile)) || (memcmp(profile,sRGBProfile,length) != 0)) { (void) FormatLocaleFile(stderr,"Profile does not match\n"); exit(1); } profile=(unsigned char *) MagickRelinquishMemory(profile); magick_wand=DestroyMagickWand(magick_wand); (void) FormatLocaleFile(stdout,"Wand tests pass.\n"); return(0); }
WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, int argc,char **argv,char **metadata,ExceptionInfo *exception) { #define DestroyIdentify() \ { \ DestroyImageStack(); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowIdentifyException(asperity,tag,option) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \ option); \ DestroyIdentify(); \ return(MagickFalse); \ } #define ThrowIdentifyInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","'%s': %s",option,argument); \ DestroyIdentify(); \ return(MagickFalse); \ } const char *format, *option; Image *image; ImageStack image_stack[MaxImageStackDepth+1]; MagickBooleanType fire, pend, respect_parenthesis; MagickStatusType status; register ssize_t i; size_t count; ssize_t j, k; /* Set defaults. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(exception != (ExceptionInfo *) NULL); if (argc == 2) { option=argv[1]; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); return(MagickFalse); } } if (argc < 2) return(IdentifyUsage()); count=0; format=NULL; j=1; k=0; NewImageStack(); option=(char *) NULL; pend=MagickFalse; respect_parenthesis=MagickFalse; status=MagickTrue; /* Identify an image. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); image_info->ping=MagickTrue; for (i=1; i < (ssize_t) argc; i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { FireImageStack(MagickFalse,MagickTrue,pend); if (k == MaxImageStackDepth) ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply", option); PushImageStack(); continue; } if (LocaleCompare(option,")") == 0) { FireImageStack(MagickFalse,MagickTrue,MagickTrue); if (k == 0) ThrowIdentifyException(OptionError,"UnableToParseExpression",option); PopImageStack(); continue; } if (IsCommandOption(option) == MagickFalse) { char *filename; Image *images; ImageInfo *identify_info; /* Read input image. */ FireImageStack(MagickFalse,MagickFalse,pend); identify_info=CloneImageInfo(image_info); identify_info->verbose=MagickFalse; filename=argv[i]; if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) filename=argv[++i]; if (identify_info->ping != MagickFalse) images=PingImages(identify_info,filename,exception); else images=ReadImages(identify_info,filename,exception); identify_info=DestroyImageInfo(identify_info); status&=(images != (Image *) NULL) && (exception->severity < ErrorException); if (images == (Image *) NULL) continue; AppendImageStack(images); FinalizeImageSettings(image_info,image,MagickFalse); for ( ; image != (Image *) NULL; image=GetNextImageInList(image)) { if (image->scene == 0) image->scene=count++; if (format == (char *) NULL) { (void) IdentifyImage(image,stdout,image_info->verbose,exception); continue; } if (metadata != (char **) NULL) { char *text; text=InterpretImageProperties(image_info,image,format,exception); if (text == (char *) NULL) ThrowIdentifyException(ResourceLimitError, "MemoryAllocationFailed",GetExceptionMessage(errno)); (void) ConcatenateString(&(*metadata),text); text=DestroyString(text); if (LocaleCompare(format,"%n") == 0) break; } } RemoveAllImageStack(); continue; } pend=image != (Image *) NULL ? MagickTrue : MagickFalse; switch (*(option+1)) { case 'a': { if (LocaleCompare("alpha",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse, argv[i]); if (type < 0) ThrowIdentifyException(OptionError, "UnrecognizedAlphaChannelOption",argv[i]); break; } if (LocaleCompare("antialias",option+1) == 0) break; if (LocaleCompare("authenticate",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { ssize_t channel; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowIdentifyException(OptionError,"UnrecognizedChannelType", argv[i]); break; } if (LocaleCompare("colorspace",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions, MagickFalse,argv[i]); if (colorspace < 0) ThrowIdentifyException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("crop",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); image_info->ping=MagickFalse; break; } if (LocaleCompare("concurrent",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'd': { if (LocaleCompare("debug",option+1) == 0) { ssize_t event; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); if (event < 0) ThrowIdentifyException(OptionError,"UnrecognizedEventType", argv[i]); (void) SetLogEventMask(argv[i]); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (const char *) NULL) ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case '3': { if (LocaleCompare("endian",option+1) == 0) { ssize_t endian; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); endian=ParseCommandOption(MagickEndianOptions,MagickFalse, argv[i]); if (endian < 0) ThrowIdentifyException(OptionError,"UnrecognizedEndianType", argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'f': { if (LocaleCompare("features",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("format",option+1) == 0) { format=(char *) NULL; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); format=argv[i]; break; } if (LocaleCompare("fuzz",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'g': { if (LocaleCompare("gamma",option+1) == 0) { i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'h': { if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) return(IdentifyUsage()); ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'i': { if (LocaleCompare("interlace",option+1) == 0) { ssize_t interlace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowIdentifyException(OptionError, "UnrecognizedInterlaceType",argv[i]); break; } if (LocaleCompare("interpolate",option+1) == 0) { ssize_t interpolate; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, argv[i]); if (interpolate < 0) ThrowIdentifyException(OptionError, "UnrecognizedInterpolateMethod",argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'l': { if (LocaleCompare("limit",option+1) == 0) { char *p; double value; ssize_t resource; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); resource=ParseCommandOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowIdentifyException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); value=StringToDouble(argv[i],&p); (void) value; if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("list",option+1) == 0) { ssize_t list; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); if (list < 0) ThrowIdentifyException(OptionError,"UnrecognizedListType", argv[i]); status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) argv+j,exception); DestroyIdentify(); return(status != 0 ? MagickFalse : MagickTrue); } if (LocaleCompare("log",option+1) == 0) { if (*option == '+') break; i++; if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'm': { if (LocaleCompare("mask",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("matte",option+1) == 0) break; if (LocaleCompare("monitor",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'n': { if (LocaleCompare("negate",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'p': { if (LocaleCompare("ping",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'q': { if (LocaleCompare("quiet",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'r': { if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleNCompare("respect-parentheses",option+1,17) == 0) { respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("size",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("strip",option+1) == 0) break; if (LocaleCompare("support",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'u': { if (LocaleCompare("unique",option+1) == 0) break; if (LocaleCompare("units",option+1) == 0) { ssize_t units; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); units=ParseCommandOption(MagickResolutionOptions,MagickFalse, argv[i]); if (units < 0) ThrowIdentifyException(OptionError,"UnrecognizedUnitsType", argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if (LocaleCompare("virtual-pixel",option+1) == 0) { ssize_t method; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, argv[i]); if (method < 0) ThrowIdentifyException(OptionError, "UnrecognizedVirtualPixelMethod",argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case '?': break; default: ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & FireOptionFlag) == 0 ? MagickFalse : MagickTrue; if (fire != MagickFalse) FireImageStack(MagickFalse,MagickTrue,MagickTrue); } if (k != 0) ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]); if (i != (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]); DestroyIdentify(); return(status != 0 ? MagickTrue : MagickFalse); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d P E S I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadPESImage() reads a Brother PES image file and returns it. It allocates % the memory necessary for the new Image structure and returns a pointer to % the new image. % % The format of the ReadPESImage method is: % % image=ReadPESImage(image_info) % % A description of each parameter follows: % % o image_info: the image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception) { char filename[MaxTextExtent]; FILE *file; Image *image; ImageInfo *read_info; int delta_x, delta_y, j, unique_file, x, y; MagickBooleanType status; PESBlockInfo blocks[256]; PointInfo *stitches; SegmentInfo bounds; register ssize_t i; size_t number_blocks, number_colors, number_stitches; ssize_t count, offset; unsigned char magick[4], version[4]; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Verify PES identifier. */ count=ReadBlob(image,4,magick); if ((count != 4) || (LocaleNCompare((char *) magick,"#PES",4) != 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); count=ReadBlob(image,4,version); offset=(int) ReadBlobLSBLong(image); if (DiscardBlobBytes(image,offset+36) == MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); if (EOFBlob(image) != MagickFalse) ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); /* Get PES colors. */ number_colors=(size_t) ReadBlobByte(image)+1; for (i=0; i < (ssize_t) number_colors; i++) { j=(int) ReadBlobByte(image); blocks[i].color=PESColor+(j < 0 ? 0 : j); blocks[i].offset=0; } for ( ; i < 256L; i++) blocks[i].offset=0; if (DiscardBlobBytes(image,532L-number_colors-21) == MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); if (EOFBlob(image) != MagickFalse) ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); /* Stitch away. */ number_stitches=64; stitches=(PointInfo *) AcquireQuantumMemory(number_stitches, sizeof(*stitches)); if (stitches == (PointInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); bounds.x1=65535.0; bounds.y1=65535.0; bounds.x2=(-65535.0); bounds.y2=(-65535.0); i=0; j=0; delta_x=0; delta_y=0; while (EOFBlob(image) != EOF) { x=(int) ReadBlobByte(image); y=(int) ReadBlobByte(image); if ((x == 0xff) && (y == 0)) break; if ((x == 254) && (y == 176)) { /* Start a new stitch block. */ j++; blocks[j].offset=(ssize_t) i; if (j >= 256) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); (void) ReadBlobByte(image); continue; } if ((x & 0x80) == 0) { /* Normal stitch. */ if ((x & 0x40) != 0) x-=0x80; } else { /* Jump stitch. */ x=((x & 0x0f) << 8)+y; if ((x & 0x800) != 0) x-=0x1000; y=ReadBlobByte(image); } if ((y & 0x80) == 0) { /* Normal stitch. */ if ((y & 0x40) != 0) y-=0x80; } else { /* Jump stitch. */ y=((y & 0x0f) << 8)+ReadBlobByte(image); if ((y & 0x800) != 0) y-=0x1000; } /* Note stitch (x,y). */ x+=delta_x; y+=delta_y; delta_x=x; delta_y=y; stitches[i].x=(double) x; stitches[i].y=(double) y; if ((double) x < bounds.x1) bounds.x1=(double) x; if ((double) x > bounds.x2) bounds.x2=(double) x; if ((double) y < bounds.y1) bounds.y1=(double) y; if ((double) y > bounds.y2) bounds.y2=(double) y; i++; if (i >= (ssize_t) number_stitches) { /* Make room for more stitches. */ number_stitches<<=1; stitches=(PointInfo *) ResizeQuantumMemory(stitches,(size_t) number_stitches,sizeof(*stitches)); if (stitches == (PointInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } } j++; blocks[j].offset=(ssize_t) i; number_blocks=(size_t) j; /* Write stitches as SVG file. */ file=(FILE *) NULL; unique_file=AcquireUniqueFileResource(filename); if (unique_file != -1) file=fdopen(unique_file,"wb"); if ((unique_file == -1) || (file == (FILE *) NULL)) ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile"); (void) FormatLocaleFile(file,"<?xml version=\"1.0\"?>\n"); (void) FormatLocaleFile(file,"<svg xmlns=\"http://www.w3.org/2000/svg\" " "xlink=\"http://www.w3.org/1999/xlink\" " "ev=\"http://www.w3.org/2001/xml-events\" version=\"1.1\" " "baseProfile=\"full\" width=\"%g\" height=\"%g\">\n",bounds.x2-bounds.x1, bounds.y2-bounds.y1); for (i=0; i < (ssize_t) number_blocks; i++) { offset=blocks[i].offset; (void) FormatLocaleFile(file," <path stroke=\"#%02x%02x%02x\" " "fill=\"none\" d=\"M %g %g",blocks[i].color->red,blocks[i].color->green, blocks[i].color->blue,stitches[offset].x-bounds.x1, stitches[offset].y-bounds.y1); for (j=1; j < (ssize_t) (blocks[i+1].offset-offset); j++) (void) FormatLocaleFile(file," L %g %g",stitches[offset+j].x-bounds.x1, stitches[offset+j].y-bounds.y1); (void) FormatLocaleFile(file,"\"/>\n"); } (void) FormatLocaleFile(file,"</svg>\n"); (void) fclose(file); (void) CloseBlob(image); image=DestroyImage(image); /* Read SVG file. */ read_info=CloneImageInfo(image_info); SetImageInfoBlob(read_info,(void *) NULL,0); (void) FormatLocaleString(read_info->filename,MaxTextExtent,"svg:%s", filename); image=ReadImage(read_info,exception); if (image != (Image *) NULL) { (void) CopyMagickString(image->filename,image_info->filename, MaxTextExtent); (void) CopyMagickString(image->magick_filename,image_info->filename, MaxTextExtent); (void) CopyMagickString(image->magick,"PES",MaxTextExtent); } read_info=DestroyImageInfo(read_info); (void) RelinquishUniqueFileResource(filename); return(GetFirstImageInList(image)); }
WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info, int argc,char **argv,char **metadata,ExceptionInfo *exception) { #define DefaultDissimilarityThreshold 0.31830988618379067154 #define DestroyCompare() \ { \ if (similarity_image != (Image *) NULL) \ similarity_image=DestroyImageList(similarity_image); \ if (difference_image != (Image *) NULL) \ difference_image=DestroyImageList(difference_image); \ DestroyImageStack(); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowCompareException(asperity,tag,option) \ { \ if (exception->severity < (asperity)) \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \ "`%s'",option); \ DestroyCompare(); \ return(MagickFalse); \ } #define ThrowCompareInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","`%s': %s",option,argument); \ DestroyCompare(); \ return(MagickFalse); \ } char *filename, *option; const char *format; ChannelType channels; double dissimilarity_threshold, distortion, similarity_metric; Image *difference_image, *image, *reconstruct_image, *similarity_image; ImageStack image_stack[MaxImageStackDepth+1]; MagickBooleanType fire, pend, respect_parenthesis, subimage_search; MagickStatusType status; MetricType metric; RectangleInfo offset; register ssize_t i; ssize_t j, k; /* Set defaults. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(exception != (ExceptionInfo *) NULL); if (argc == 2) { option=argv[1]; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); return(MagickFalse); } } if (argc < 3) return(CompareUsage()); channels=CompositeChannels; difference_image=NewImageList(); similarity_image=NewImageList(); dissimilarity_threshold=DefaultDissimilarityThreshold; distortion=0.0; format=(char *) NULL; j=1; k=0; metric=UndefinedMetric; NewImageStack(); option=(char *) NULL; pend=MagickFalse; reconstruct_image=NewImageList(); respect_parenthesis=MagickFalse; status=MagickTrue; subimage_search=MagickFalse; /* Compare an image. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); for (i=1; i < (ssize_t) (argc-1); i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { FireImageStack(MagickTrue,MagickTrue,pend); if (k == MaxImageStackDepth) ThrowCompareException(OptionError,"ParenthesisNestedTooDeeply", option); PushImageStack(); continue; } if (LocaleCompare(option,")") == 0) { FireImageStack(MagickTrue,MagickTrue,MagickTrue); if (k == 0) ThrowCompareException(OptionError,"UnableToParseExpression",option); PopImageStack(); continue; } if (IsCommandOption(option) == MagickFalse) { Image *images; /* Read input image. */ FireImageStack(MagickFalse,MagickFalse,pend); filename=argv[i]; if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) filename=argv[++i]; (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); images=ReadImages(image_info,exception); status&=(images != (Image *) NULL) && (exception->severity < ErrorException); if (images == (Image *) NULL) continue; AppendImageStack(images); continue; } pend=image != (Image *) NULL ? MagickTrue : MagickFalse; switch (*(option+1)) { case 'a': { if (LocaleCompare("alpha",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); if (type < 0) ThrowCompareException(OptionError,"UnrecognizedAlphaChannelType", argv[i]); break; } if (LocaleCompare("authenticate",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option); } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { ssize_t channel; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowCompareException(OptionError,"UnrecognizedChannelType", argv[i]); channels=(ChannelType) channel; break; } if (LocaleCompare("colorspace",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, argv[i]); if (colorspace < 0) ThrowCompareException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("compose",option+1) == 0) { ssize_t compose; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); compose=ParseCommandOption(MagickComposeOptions,MagickFalse, argv[i]); if (compose < 0) ThrowCompareException(OptionError,"UnrecognizedComposeOperator", argv[i]); break; } if (LocaleCompare("compress",option+1) == 0) { ssize_t compress; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); compress=ParseCommandOption(MagickCompressOptions,MagickFalse, argv[i]); if (compress < 0) ThrowCompareException(OptionError,"UnrecognizedImageCompression", argv[i]); break; } if (LocaleCompare("concurrent",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'd': { if (LocaleCompare("debug",option+1) == 0) { LogEventType event_mask; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); event_mask=SetLogEventMask(argv[i]); if (event_mask == UndefinedEvents) ThrowCompareException(OptionError,"UnrecognizedEventType", argv[i]); break; } if (LocaleCompare("decipher",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (const char *) NULL) ThrowCompareException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("dissimilarity-threshold",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); if (*option == '+') dissimilarity_threshold=DefaultDissimilarityThreshold; else dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL); break; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'e': { if (LocaleCompare("encipher",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("extract",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'f': { if (LocaleCompare("format",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); format=argv[i]; break; } if (LocaleCompare("fuzz",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'h': { if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) return(CompareUsage()); if (LocaleCompare("highlight-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'i': { if (LocaleCompare("identify",option+1) == 0) break; if (LocaleCompare("interlace",option+1) == 0) { ssize_t interlace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowCompareException(OptionError,"UnrecognizedInterlaceType", argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'l': { if (LocaleCompare("limit",option+1) == 0) { char *p; double value; ssize_t resource; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); resource=ParseCommandOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowCompareException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); value=StringToDouble(argv[i],&p); (void) value; if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("list",option+1) == 0) { ssize_t list; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); if (list < 0) ThrowCompareException(OptionError,"UnrecognizedListType",argv[i]); status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) argv+j,exception); DestroyCompare(); return(status != 0 ? MagickFalse : MagickTrue); } if (LocaleCompare("log",option+1) == 0) { if (*option == '+') break; i++; if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("lowlight-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'm': { if (LocaleCompare("matte",option+1) == 0) break; if (LocaleCompare("metric",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]); if (type < 0) ThrowCompareException(OptionError,"UnrecognizedMetricType", argv[i]); metric=(MetricType) type; break; } if (LocaleCompare("monitor",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'p': { if (LocaleCompare("passphrase",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("profile",option+1) == 0) { i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'q': { if (LocaleCompare("quality",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("quantize",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions, MagickFalse,argv[i]); if (colorspace < 0) ThrowCompareException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("quiet",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'r': { if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleNCompare("respect-parentheses",option+1,17) == 0) { respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("size",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("subimage-search",option+1) == 0) { if (*option == '+') { subimage_search=MagickFalse; break; } subimage_search=MagickTrue; break; } if (LocaleCompare("synchronize",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 't': { if (LocaleCompare("taint",option+1) == 0) break; if (LocaleCompare("transparent-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("type",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); if (type < 0) ThrowCompareException(OptionError,"UnrecognizedImageType", argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); break; } if (LocaleCompare("virtual-pixel",option+1) == 0) { ssize_t method; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, argv[i]); if (method < 0) ThrowCompareException(OptionError, "UnrecognizedVirtualPixelMethod",argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case '?': break; default: ThrowCompareException(OptionError,"UnrecognizedOption",option) } fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & FireOptionFlag) == 0 ? MagickFalse : MagickTrue; if (fire != MagickFalse) FireImageStack(MagickTrue,MagickTrue,MagickTrue); } if (k != 0) ThrowCompareException(OptionError,"UnbalancedParenthesis",argv[i]); if (i-- != (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); FinalizeImageSettings(image_info,image,MagickTrue); if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); image=GetImageFromList(image,0); reconstruct_image=GetImageFromList(image,1); if (subimage_search != MagickFalse) { similarity_image=SimilarityMetricImage(image,reconstruct_image,metric, &offset,&similarity_metric,exception); if (similarity_metric > dissimilarity_threshold) ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename); } if ((reconstruct_image->columns == image->columns) && (reconstruct_image->rows == image->rows)) difference_image=CompareImageChannels(image,reconstruct_image,channels, metric,&distortion,exception); else if (similarity_image == (Image *) NULL) ThrowCompareException(OptionError,"ImageWidthsOrHeightsDiffer", image->filename) else { Image *composite_image; /* Determine if reconstructed image is a subimage of the image. */ composite_image=CloneImage(image,0,0,MagickTrue,exception); if (composite_image == (Image *) NULL) difference_image=CompareImageChannels(image,reconstruct_image, channels,metric,&distortion,exception); else { (void) CompositeImage(composite_image,CopyCompositeOp, reconstruct_image,offset.x,offset.y); difference_image=CompareImageChannels(image,composite_image, channels,metric,&distortion,exception); if (difference_image != (Image *) NULL) { difference_image->page.x=offset.x; difference_image->page.y=offset.y; } composite_image=DestroyImage(composite_image); } if (difference_image != (Image *) NULL) { AppendImageToList(&difference_image,similarity_image); similarity_image=(Image *) NULL; } } if (difference_image == (Image *) NULL) status=0; else { if (image_info->verbose != MagickFalse) (void) IsImagesEqual(image,reconstruct_image); if (*difference_image->magick == '\0') (void) CopyMagickString(difference_image->magick,image->magick, MaxTextExtent); if (image_info->verbose == MagickFalse) { switch (metric) { case FuzzErrorMetric: case MeanAbsoluteErrorMetric: case MeanSquaredErrorMetric: case RootMeanSquaredErrorMetric: case PeakAbsoluteErrorMetric: { (void) FormatLocaleFile(stderr,"%g (%g)",QuantumRange*distortion, (double) distortion); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) difference_image->page.x,(double) difference_image->page.y); (void) FormatLocaleFile(stderr,"\n"); break; } case AbsoluteErrorMetric: case NormalizedCrossCorrelationErrorMetric: case PeakSignalToNoiseRatioMetric: { (void) FormatLocaleFile(stderr,"%g",distortion); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) difference_image->page.x,(double) difference_image->page.y); (void) FormatLocaleFile(stderr,"\n"); break; } case MeanErrorPerPixelMetric: { (void) FormatLocaleFile(stderr,"%g (%g, %g)",distortion, image->error.normalized_mean_error, image->error.normalized_maximum_error); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) difference_image->page.x,(double) difference_image->page.y); (void) FormatLocaleFile(stderr,"\n"); break; } case UndefinedMetric: break; } } else { double *channel_distortion; channel_distortion=GetImageChannelDistortions(image,reconstruct_image, metric,&image->exception); (void) FormatLocaleFile(stderr,"Image: %s\n",image->filename); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr,"Offset: %.20g,%.20g\n",(double) difference_image->page.x,(double) difference_image->page.y); (void) FormatLocaleFile(stderr," Channel distortion: %s\n", CommandOptionToMnemonic(MagickMetricOptions,(ssize_t) metric)); switch (metric) { case FuzzErrorMetric: case MeanAbsoluteErrorMetric: case MeanSquaredErrorMetric: case RootMeanSquaredErrorMetric: case PeakAbsoluteErrorMetric: { switch (image->colorspace) { case RGBColorspace: default: { (void) FormatLocaleFile(stderr," red: %g (%g)\n", QuantumRange*channel_distortion[RedChannel], channel_distortion[RedChannel]); (void) FormatLocaleFile(stderr," green: %g (%g)\n", QuantumRange*channel_distortion[GreenChannel], channel_distortion[GreenChannel]); (void) FormatLocaleFile(stderr," blue: %g (%g)\n", QuantumRange*channel_distortion[BlueChannel], channel_distortion[BlueChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", QuantumRange*channel_distortion[OpacityChannel], channel_distortion[OpacityChannel]); break; } case CMYKColorspace: { (void) FormatLocaleFile(stderr," cyan: %g (%g)\n", QuantumRange*channel_distortion[CyanChannel], channel_distortion[CyanChannel]); (void) FormatLocaleFile(stderr," magenta: %g (%g)\n", QuantumRange*channel_distortion[MagentaChannel], channel_distortion[MagentaChannel]); (void) FormatLocaleFile(stderr," yellow: %g (%g)\n", QuantumRange*channel_distortion[YellowChannel], channel_distortion[YellowChannel]); (void) FormatLocaleFile(stderr," black: %g (%g)\n", QuantumRange*channel_distortion[BlackChannel], channel_distortion[BlackChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", QuantumRange*channel_distortion[OpacityChannel], channel_distortion[OpacityChannel]); break; } case GRAYColorspace: { (void) FormatLocaleFile(stderr," gray: %g (%g)\n", QuantumRange*channel_distortion[GrayChannel], channel_distortion[GrayChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", QuantumRange*channel_distortion[OpacityChannel], channel_distortion[OpacityChannel]); break; } } (void) FormatLocaleFile(stderr," all: %g (%g)\n", QuantumRange*channel_distortion[CompositeChannels], channel_distortion[CompositeChannels]); break; } case AbsoluteErrorMetric: case NormalizedCrossCorrelationErrorMetric: case PeakSignalToNoiseRatioMetric: { switch (image->colorspace) { case RGBColorspace: default: { (void) FormatLocaleFile(stderr," red: %g\n", channel_distortion[RedChannel]); (void) FormatLocaleFile(stderr," green: %g\n", channel_distortion[GreenChannel]); (void) FormatLocaleFile(stderr," blue: %g\n", channel_distortion[BlueChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g\n", channel_distortion[OpacityChannel]); break; } case CMYKColorspace: { (void) FormatLocaleFile(stderr," cyan: %g\n", channel_distortion[CyanChannel]); (void) FormatLocaleFile(stderr," magenta: %g\n", channel_distortion[MagentaChannel]); (void) FormatLocaleFile(stderr," yellow: %g\n", channel_distortion[YellowChannel]); (void) FormatLocaleFile(stderr," black: %g\n", channel_distortion[BlackChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g\n", channel_distortion[OpacityChannel]); break; } case GRAYColorspace: { (void) FormatLocaleFile(stderr," gray: %g\n", channel_distortion[GrayChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g\n", channel_distortion[OpacityChannel]); break; } } (void) FormatLocaleFile(stderr," all: %g\n", channel_distortion[CompositeChannels]); break; } case MeanErrorPerPixelMetric: { (void) FormatLocaleFile(stderr," %g (%g, %g)\n", channel_distortion[CompositeChannels], image->error.normalized_mean_error, image->error.normalized_maximum_error); break; } case UndefinedMetric: break; } channel_distortion=(double *) RelinquishMagickMemory( channel_distortion); } status&=WriteImages(image_info,difference_image,argv[argc-1],exception); if ((metadata != (char **) NULL) && (format != (char *) NULL)) { char *text; text=InterpretImageProperties(image_info,difference_image,format); if (text == (char *) NULL) ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ConcatenateString(&(*metadata),text); (void) ConcatenateString(&(*metadata),"\n"); text=DestroyString(text); } difference_image=DestroyImageList(difference_image); } DestroyCompare(); return(status != 0 ? MagickTrue : MagickFalse); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t M a g i c k R e s o u r c e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListMagickResourceInfo() lists the resource info to a file. % % The format of the ListMagickResourceInfo method is: % % MagickBooleanType ListMagickResourceInfo(FILE *file, % ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ExceptionInfo *magick_unused(exception)) { char area_limit[MagickFormatExtent], disk_limit[MagickFormatExtent], height_limit[MagickFormatExtent], map_limit[MagickFormatExtent], memory_limit[MagickFormatExtent], time_limit[MagickFormatExtent], width_limit[MagickFormatExtent]; magick_unreferenced(exception); if (file == (const FILE *) NULL) file=stdout; if (resource_semaphore == (SemaphoreInfo *) NULL) ActivateSemaphoreInfo(&resource_semaphore); LockSemaphoreInfo(resource_semaphore); (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P", MagickFormatExtent,width_limit); (void) FormatMagickSize(resource_info.height_limit,MagickFalse,"P", MagickFormatExtent,height_limit); (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B", MagickFormatExtent,area_limit); (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,"B", MagickFormatExtent,memory_limit); (void) FormatMagickSize(resource_info.map_limit,MagickTrue,"B", MagickFormatExtent,map_limit); (void) CopyMagickString(disk_limit,"unlimited",MagickFormatExtent); if (resource_info.disk_limit != MagickResourceInfinity) (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B", MagickFormatExtent,disk_limit); (void) CopyMagickString(time_limit,"unlimited",MagickFormatExtent); if (resource_info.time_limit != MagickResourceInfinity) (void) FormatLocaleString(time_limit,MagickFormatExtent,"%.20g",(double) ((MagickOffsetType) resource_info.time_limit)); (void) FormatLocaleFile(file,"Resource limits:\n"); (void) FormatLocaleFile(file," Width: %s\n",width_limit); (void) FormatLocaleFile(file," Height: %s\n",height_limit); (void) FormatLocaleFile(file," Area: %s\n",area_limit); (void) FormatLocaleFile(file," Memory: %s\n",memory_limit); (void) FormatLocaleFile(file," Map: %s\n",map_limit); (void) FormatLocaleFile(file," Disk: %s\n",disk_limit); (void) FormatLocaleFile(file," File: %.20g\n",(double) ((MagickOffsetType) resource_info.file_limit)); (void) FormatLocaleFile(file," Thread: %.20g\n",(double) ((MagickOffsetType) resource_info.thread_limit)); (void) FormatLocaleFile(file," Throttle: %.20g\n",(double) ((MagickOffsetType) resource_info.throttle_limit)); (void) FormatLocaleFile(file," Time: %s\n",time_limit); (void) fflush(file); UnlockSemaphoreInfo(resource_semaphore); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + P r o c e s s C o m m a n d O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ProcessCommandOptions() reads and processes arguments in the given % command line argument array. The array does not contain the command % being processed, only the options. % % The 'process_flags' can be used to control and limit option processing. % For example, to only process one option, or how unknown and special options % are to be handled, and if the last argument in array is to be regarded as a % final image write argument (filename or special coder). % % The format of the ProcessCommandOptions method is: % % int ProcessCommandOptions(MagickCLI *cli_wand,int argc,char **argv, % int index, ProcessOptionFlags process_flags ) % % A description of each parameter follows: % % o cli_wand: the main CLI Wand to use. % % o argc: the number of elements in the argument vector. % % o argv: A text array containing the command line arguments. % % o process_flags: What type of arguments will be processed, ignored % or return errors. % % o index: index in the argv array to start processing from % % The function returns the index ot the next option to be processed. This % is really only releven if process_flags contains a ProcessOneOptionOnly % flag. % */ WandExport int ProcessCommandOptions(MagickCLI *cli_wand, int argc, char **argv, int index ) { const char *option, *arg1, *arg2; int i, end, count; CommandOptionFlags option_type; assert(argc>=index); /* you may have no arguments left! */ assert(argv != (char **)NULL); assert(argv[index] != (char *)NULL); assert(argv[argc-1] != (char *)NULL); assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == WandSignature); if (cli_wand->wand.debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); /* define the error location string for use in exceptions order of localtion format escapes: filename, line, column */ cli_wand->location="at %s argument %u"; cli_wand->filename="CLI"; end = argc; if ( (cli_wand->process_flags & ProcessImpliedWrite) != 0 ) end--; /* the last arument is an implied write, do not process directly */ for (i=index; i < end; i += count +1) { /* Finished processing one option? */ if ( (cli_wand->process_flags & ProcessOneOptionOnly) != 0 && i != index ) return(i); option=argv[i]; cli_wand->line=i; /* note the argument for this option */ { const OptionInfo *option_info = GetCommandOptionInfo(argv[i]); count=option_info->type; option_type=(CommandOptionFlags) option_info->flags; #if 0 (void) FormatLocaleFile(stderr, "CLI %d: \"%s\" matched \"%s\"\n", i, argv[i], option_info->mnemonic ); #endif } if ( option_type == UndefinedOptionFlag || (option_type & NonMagickOptionFlag) != 0 ) { #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "CLI %d Non-Option: \"%s\"\n", i, option); #endif if ( IfMagickFalse(IsCommandOption(option)) ) { if ( (cli_wand->process_flags & ProcessNonOptionImageRead) != 0 ) /* non-option -- treat as a image read */ CLISpecialOperator(cli_wand,"-read",option); else CLIWandException(OptionFatalError,"UnrecognizedOption",option); goto next_argument; } if ( ((cli_wand->process_flags & ProcessScriptOption) != 0) && (LocaleCompare(option,"-script") == 0) ) { /* Call Script from CLI, with a filename as a zeroth argument. NOTE: -script may need to use 'implict write filename' so it must be handled here to prevent 'missing argument' error. */ ProcessScriptOptions(cli_wand,argc,argv,i+1); return(argc); /* Script does not return to CLI -- Yet -- FUTURE */ } CLIWandException(OptionFatalError,"UnrecognizedOption",option); goto next_argument; } if ((i+count) >= end ) { CLIWandException(OptionFatalError,"MissingArgument",option); if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(end); goto next_argument; /* no more arguments unable to proceed */ } arg1 = ( count >= 1 ) ? argv[i+1] : (char *)NULL; arg2 = ( count >= 2 ) ? argv[i+2] : (char *)NULL; #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "CLI %u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", i,option,count,option_type,arg1,arg2); #endif if ( (option_type & DeprecateOptionFlag) != 0 ) { CLIWandException(OptionWarning,"DeprecatedOption",option); if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(end); /* fall through - do the depreciated option */ } if ( (option_type & GenesisOptionFlag) != 0 ) { goto next_argument; /* ignore genesis options */ } if (((option_type & ImageRequiredFlags) != 0 ) && ( cli_wand->wand.images == (Image *)NULL ) ) { CLIWandException(OptionError,"NoImagesFound",option); goto next_argument; } if ( (option_type & SpecialOptionFlag) != 0 ) { if ( (cli_wand->process_flags & ProcessExitOption) != 0 && LocaleCompare(option,"-exit") == 0 ) return(i+count); /* handle any other special operators now */ CLISpecialOperator(cli_wand,option,arg1); } if ( (option_type & SettingOptionFlags) != 0 ) { CLISettingOptionInfo(cli_wand, option, arg1, arg2); // FUTURE: Sync individual Settings into images (no SyncImageSettings()) } if ( cli_wand->wand.images != (Image *)NULL ) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, cli_wand->wand.exception); if ( (option_type & SimpleOperatorOptionFlag) != 0) CLISimpleOperatorImages(cli_wand, option, arg1, arg2); if ( (option_type & ListOperatorOptionFlag) != 0 ) CLIListOperatorImages(cli_wand, option, arg1, arg2); next_argument: #if MagickCommandDebug >= 9 OutputOptions(cli_wand->wand.image_info); if ( cli_wand->wand.images != (Image *)NULL ) { OutputArtifacts(cli_wand->wand.images); OutputProperties(cli_wand->wand.images,cli_wand->wand.exception); } #endif if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(i+count); } assert(i==end); if ( (cli_wand->process_flags & ProcessImpliedWrite) == 0 ) return(end); /* no implied write -- just return to caller */ assert(end==argc-1); /* end should not include last argument */ /* Implicit Write of images to final CLI argument */ option=argv[i]; cli_wand->line=i; #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "CLI %d Write File: \"%s\"\n", i, option ); #endif /* check that stacks are empty */ if (cli_wand->image_list_stack != (Stack *)NULL) CLIWandException(OptionError,"UnbalancedParenthesis", "(eof)"); else if (cli_wand->image_info_stack != (Stack *)NULL) CLIWandException(OptionError,"UnbalancedBraces", "(eof)"); if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(argc); /* This is a valid 'do no write' option - no images needed */ if (LocaleCompare(option,"-exit") == 0 ) return(argc); /* just exit, no image write */ /* If filename looks like an option -- produce an error */ if (IsCommandOption(option) != MagickFalse) { CLIWandException(OptionError,"MissingOutputFilename",option); return(argc); } CLISpecialOperator(cli_wand,"-write",option); return(argc); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + P r o c e s s S c r i p t O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ProcessScriptOptions() reads options and processes options as they are % found in the given file, or pipeline. The filename to open and read % options is given as the 'index' argument of the argument array given. % % Other arguments following index may be read by special script options % as settings (strings), images, or as operations to be processed in various % ways. How they are treated is up to the script being processed. % % Note that a script not 'return' to the command line processing, nor can % they call (and return from) other scripts. At least not at this time. % % There are no 'ProcessOptionFlags' control flags at this time. % % The format of the ProcessScriptOptions method is: % % void ProcessScriptOptions(MagickCLI *cli_wand,const char *filename, % int argc,char **argv,int index) % % A description of each parameter follows: % % o cli_wand: the main CLI Wand to use. % % o filename: the filename of script to process % % o argc: the number of elements in the argument vector. (optional) % % o argv: A text array containing the command line arguments. (optional) % % o index: offset of next argment in argv (script arguments) (optional) % */ WandExport void ProcessScriptOptions(MagickCLI *cli_wand,const char *filename, int argc,char **argv,int index) { ScriptTokenInfo *token_info; CommandOptionFlags option_type; int count; char *option, *arg1, *arg2; assert(filename != (char *) NULL ); /* at least one argument - script name */ assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == MagickWandSignature); if (cli_wand->wand.debug != MagickFalse) (void) LogMagickEvent(CommandEvent,GetMagickModule(), "Processing script \"%s\"", filename); /* open file script or stream, and set up tokenizer */ token_info = AcquireScriptTokenInfo(filename); if (token_info == (ScriptTokenInfo *) NULL) { CLIWandExceptionFile(OptionFatalError,"UnableToOpenScript",filename); return; } /* define the error location string for use in exceptions order of localtion format escapes: filename, line, column */ cli_wand->location="in \"%s\" at line %u,column %u"; if ( LocaleCompare("-", filename) == 0 ) cli_wand->filename="stdin"; else cli_wand->filename=filename; /* Process Options from Script */ option = arg1 = arg2 = (char*) NULL; DisableMSCWarning(4127) while (1) { RestoreMSCWarning { MagickBooleanType status = GetScriptToken(token_info); cli_wand->line=token_info->token_line; cli_wand->column=token_info->token_column; if (status == MagickFalse) break; /* error or end of options */ } do { /* use break to loop to exception handler and loop */ /* save option details */ CloneString(&option,token_info->token); /* get option, its argument count, and option type */ cli_wand->command = GetCommandOptionInfo(option); count=cli_wand->command->type; option_type=(CommandOptionFlags) cli_wand->command->flags; #if 0 (void) FormatLocaleFile(stderr, "Script: %u,%u: \"%s\" matched \"%s\"\n", cli_wand->line, cli_wand->line, option, cli_wand->command->mnemonic ); #endif /* handle a undefined option - image read - always for "magick-script" */ if ( option_type == UndefinedOptionFlag || (option_type & NonMagickOptionFlag) != 0 ) { #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "Script %u,%u Non-Option: \"%s\"\n", cli_wand->line, cli_wand->line, option); #endif if (IsCommandOption(option) == MagickFalse) { /* non-option -- treat as a image read */ cli_wand->command=(const OptionInfo *) NULL; CLIOption(cli_wand,"-read",option); break; /* next option */ } CLIWandException(OptionFatalError,"UnrecognizedOption",option); break; /* next option */ } if ( count >= 1 ) { if (GetScriptToken(token_info) == MagickFalse) CLIWandException(OptionFatalError,"MissingArgument",option); CloneString(&arg1,token_info->token); } else CloneString(&arg1,(char *) NULL); if ( count >= 2 ) { if (GetScriptToken(token_info) == MagickFalse) CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option); CloneString(&arg2,token_info->token); } else CloneString(&arg2,(char *) NULL); /* Process Options */ #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "Script %u,%u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", cli_wand->line,cli_wand->line,option,count,option_type,arg1,arg2); #endif /* Hard Deprecated Options, no code to execute - error */ if ( (option_type & DeprecateOptionFlag) != 0 ) { CLIWandException(OptionError,"DeprecatedOptionNoCode",option); break; /* next option */ } /* MagickCommandGenesis() options have no place in a magick script */ if ( (option_type & GenesisOptionFlag) != 0 ) { CLIWandException(OptionError,"InvalidUseOfOption",option); break; /* next option */ } /* handle any special 'script' options */ if ( (option_type & SpecialOptionFlag) != 0 ) { if ( LocaleCompare(option,"-exit") == 0 ) { goto loop_exit; /* break out of loop - return from script */ } if ( LocaleCompare(option,"-script") == 0 ) { /* FUTURE: call new script from this script - error for now */ CLIWandException(OptionError,"InvalidUseOfOption",option); break; /* next option */ } /* FUTURE: handle special script-argument options here */ /* handle any other special operators now */ CLIWandException(OptionError,"InvalidUseOfOption",option); break; /* next option */ } /* Process non-specific Option */ CLIOption(cli_wand, option, arg1, arg2); (void) fflush(stdout); (void) fflush(stderr); DisableMSCWarning(4127) } while (0); /* break block to next option */ RestoreMSCWarning #if MagickCommandDebug >= 5 fprintf(stderr, "Script Image Count = %ld\n", GetImageListLength(cli_wand->wand.images) ); #endif if (CLICatchException(cli_wand, MagickFalse) != MagickFalse) break; /* exit loop */ } /* Loop exit - check for some tokenization error */ loop_exit: #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "Script End: %d\n", token_info->status); #endif switch( token_info->status ) { case TokenStatusOK: case TokenStatusEOF: if (cli_wand->image_list_stack != (Stack *) NULL) CLIWandException(OptionError,"UnbalancedParenthesis", "(eof)"); else if (cli_wand->image_info_stack != (Stack *) NULL) CLIWandException(OptionError,"UnbalancedBraces", "(eof)"); break; case TokenStatusBadQuotes: /* Ensure last token has a sane length for error report */ if( strlen(token_info->token) > INITAL_TOKEN_LENGTH-1 ) { token_info->token[INITAL_TOKEN_LENGTH-4] = '.'; token_info->token[INITAL_TOKEN_LENGTH-3] = '.'; token_info->token[INITAL_TOKEN_LENGTH-2] = '.'; token_info->token[INITAL_TOKEN_LENGTH-1] = '\0'; } CLIWandException(OptionFatalError,"ScriptUnbalancedQuotes", token_info->token); break; case TokenStatusMemoryFailed: CLIWandException(OptionFatalError,"ScriptTokenMemoryFailed",""); break; case TokenStatusBinary: CLIWandException(OptionFatalError,"ScriptIsBinary",""); break; } (void) fflush(stdout); (void) fflush(stderr); if (cli_wand->wand.debug != MagickFalse) (void) LogMagickEvent(CommandEvent,GetMagickModule(), "Script End \"%s\"", filename); /* Clean up */ token_info = DestroyScriptTokenInfo(token_info); CloneString(&option,(char *) NULL); CloneString(&arg1,(char *) NULL); CloneString(&arg2,(char *) NULL); return; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + P r o c e s s C o m m a n d O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ProcessCommandOptions() reads and processes arguments in the given % command line argument array. The 'index' defines where in the array we % should begin processing % % The 'process_flags' can be used to control and limit option processing. % For example, to only process one option, or how unknown and special options % are to be handled, and if the last argument in array is to be regarded as a % final image write argument (filename or special coder). % % The format of the ProcessCommandOptions method is: % % int ProcessCommandOptions(MagickCLI *cli_wand,int argc,char **argv, % int index) % % A description of each parameter follows: % % o cli_wand: the main CLI Wand to use. % % o argc: the number of elements in the argument vector. % % o argv: A text array containing the command line arguments. % % o process_flags: What type of arguments will be processed, ignored % or return errors. % % o index: index in the argv array to start processing from % % The function returns the index ot the next option to be processed. This % is really only releven if process_flags contains a ProcessOneOptionOnly % flag. % */ WandExport int ProcessCommandOptions(MagickCLI *cli_wand,int argc,char **argv, int index) { const char *option, *arg1, *arg2; int i, end, count; CommandOptionFlags option_type; assert(argc>=index); /* you may have no arguments left! */ assert(argv != (char **) NULL); assert(argv[index] != (char *) NULL); assert(argv[argc-1] != (char *) NULL); assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == MagickWandSignature); /* define the error location string for use in exceptions order of localtion format escapes: filename, line, column */ cli_wand->location="at %s arg %u"; cli_wand->filename="CLI"; cli_wand->line=index; /* note first argument we will process */ if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- Starting (\"%s\")", argv[index]); end = argc; if ( (cli_wand->process_flags & ProcessImplictWrite) != 0 ) end--; /* the last arument is an implied write, do not process directly */ for (i=index; i < end; i += count +1) { /* Finished processing one option? */ if ( (cli_wand->process_flags & ProcessOneOptionOnly) != 0 && i != index ) return(i); do { /* use break to loop to exception handler and loop */ option=argv[i]; cli_wand->line=i; /* note the argument for this option */ /* get option, its argument count, and option type */ cli_wand->command = GetCommandOptionInfo(argv[i]); count=cli_wand->command->type; option_type=(CommandOptionFlags) cli_wand->command->flags; #if 0 (void) FormatLocaleFile(stderr, "CLI %d: \"%s\" matched \"%s\"\n", i, argv[i], cli_wand->command->mnemonic ); #endif if ( option_type == UndefinedOptionFlag || (option_type & NonMagickOptionFlag) != 0 ) { #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "CLI arg %d Non-Option: \"%s\"\n", i, option); #endif if (IsCommandOption(option) == MagickFalse) { if ( (cli_wand->process_flags & ProcessImplictRead) != 0 ) { /* non-option -- treat as a image read */ cli_wand->command=(const OptionInfo *) NULL; CLIOption(cli_wand,"-read",option); break; /* next option */ } } CLIWandException(OptionFatalError,"UnrecognizedOption",option); break; /* next option */ } if ( ((option_type & SpecialOptionFlag) != 0 ) && ((cli_wand->process_flags & ProcessScriptOption) != 0) && (LocaleCompare(option,"-script") == 0) ) { /* Call Script from CLI, with a filename as a zeroth argument. NOTE: -script may need to use the 'implict write filename' argument so it must be handled specially to prevent a 'missing argument' error. */ if ( (i+count) >= argc ) CLIWandException(OptionFatalError,"MissingArgument",option); ProcessScriptOptions(cli_wand,argv[i+1],argc,argv,i+count); return(argc); /* Script does not return to CLI -- Yet */ /* FUTURE: when it does, their may be no write arg! */ } if ((i+count) >= end ) { CLIWandException(OptionFatalError,"MissingArgument",option); if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(end); break; /* next option - not that their is any! */ } arg1 = ( count >= 1 ) ? argv[i+1] : (char *) NULL; arg2 = ( count >= 2 ) ? argv[i+2] : (char *) NULL; /* Process Known Options */ #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "CLI arg %u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", i,option,count,option_type,arg1,arg2); #endif /* ignore 'genesis options' in command line args */ if ( (option_type & GenesisOptionFlag) != 0 ) break; /* next option */ /* Handle any special options for CLI (-script handled above) */ if ( (option_type & SpecialOptionFlag) != 0 ) { if ( (cli_wand->process_flags & ProcessExitOption) != 0 && LocaleCompare(option,"-exit") == 0 ) return(i+count); break; /* next option */ } /* Process standard image option */ CLIOption(cli_wand, option, arg1, arg2); DisableMSCWarning(4127) } while (0); /* break block to next option */ RestoreMSCWarning #if MagickCommandDebug >= 5 (void) FormatLocaleFile(stderr, "CLI-post Image Count = %ld\n", (long) GetImageListLength(cli_wand->wand.images) ); #endif if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(i+count); } assert(i==end); if ( (cli_wand->process_flags & ProcessImplictWrite) == 0 ) return(end); /* no implied write -- just return to caller */ assert(end==argc-1); /* end should not include last argument */ /* Implicit Write of images to final CLI argument */ option=argv[i]; cli_wand->line=i; /* check that stacks are empty - or cause exception */ if (cli_wand->image_list_stack != (Stack *) NULL) CLIWandException(OptionError,"UnbalancedParenthesis", "(end of cli)"); else if (cli_wand->image_info_stack != (Stack *) NULL) CLIWandException(OptionError,"UnbalancedBraces", "(end of cli)"); if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) return(argc); #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr,"CLI arg %d Write File: \"%s\"\n",i,option); #endif /* Valid 'do no write' replacement option (instead of "null:") */ if (LocaleCompare(option,"-exit") == 0 ) return(argc); /* just exit, no image write */ /* If filename looks like an option, Or the common 'end of line' error of a single space. -- produce an error */ if (IsCommandOption(option) != MagickFalse || (option[0] == ' ' && option[1] == '\0') ) { CLIWandException(OptionError,"MissingOutputFilename",option); return(argc); } cli_wand->command=(const OptionInfo *) NULL; CLIOption(cli_wand,"-write",option); return(argc); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + P r o c e s s S c r i p t O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ProcessScriptOptions() reads options and processes options as they are % found in the given file, or pipeline. The filename to open and read % options is given as the 'index' argument of the argument array given. % % Other arguments following index may be read by special script options % as settings (strings), images, or as operations to be processed in various % ways. How they are treated is up to the script being processed. % % Note that a script not 'return' to the command line processing, nor can % they call (and return from) other scripts. At least not at this time. % % There are no 'ProcessOptionFlags' control flags at this time. % % The format of the ProcessScriptOptions method is: % % void ProcessScriptOptions(MagickCLI *cli_wand,int argc,char **argv, % int index) % % A description of each parameter follows: % % o cli_wand: the main CLI Wand to use. % % o argc: the number of elements in the argument vector. % % o argv: A text array containing the command line arguments. % % o index: offset for argc to CLI argumnet count % */ WandExport void ProcessScriptOptions(MagickCLI *cli_wand,int argc,char **argv, int index) { ScriptTokenInfo *token_info; CommandOptionFlags option_type; int count; char *option, *arg1, *arg2; assert(argc>index); /* at least one argument - script name */ assert(argv != (char **)NULL); assert(argv[index] != (char *)NULL); assert(argv[argc-1] != (char *)NULL); assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == WandSignature); if (cli_wand->wand.debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); /* open file script or stream, and set up tokenizer */ token_info = AcquireScriptTokenInfo(argv[index]); if (token_info == (ScriptTokenInfo *) NULL) { CLIWandExceptionFile(OptionFatalError,"UnableToOpenScript",argv[index]); return; } /* define the error location string for use in exceptions order of localtion format escapes: filename, line, column */ cli_wand->location="in \"%s\" at line %u,column %u"; if ( LocaleCompare("-", argv[index]) == 0 ) cli_wand->filename="stdin"; else cli_wand->filename=argv[index]; /* Process Options from Script */ option = arg1 = arg2 = (char*)NULL; while (1) { /* Get a option */ { MagickBooleanType status = GetScriptToken(token_info); cli_wand->line=token_info->token_line; cli_wand->column=token_info->token_column; if( IfMagickFalse(status) ) break; /* error or end of options */ } /* save option details */ CloneString(&option,token_info->token); { /* get option type and argument count */ const OptionInfo *option_info = GetCommandOptionInfo(option); count=option_info->type; option_type=(CommandOptionFlags) option_info->flags; #if 0 (void) FormatLocaleFile(stderr, "Script: %u,%u: \"%s\" matched \"%s\"\n", cli_wand->line, cli_wand->line, option, option_info->mnemonic ); #endif } /* handle a undefined option - image read? */ if ( option_type == UndefinedOptionFlag || (option_type & NonMagickOptionFlag) != 0 ) { #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "Script %u,%u Non-Option: \"%s\"\n", cli_wand->line, cli_wand->line, option); #endif if ( IfMagickFalse(IsCommandOption(option))) { /* non-option -- treat as a image read */ CLISpecialOperator(cli_wand,"-read",option); goto next_token; } if ( LocaleCompare(option,"-script") == 0 ) { option_type=SpecialOptionFlag; count=1; /* fall thru - collect one argument */ } else { CLIWandExceptionBreak(OptionFatalError,"UnrecognizedOption",option); goto next_token; } } if ( count >= 1 ) { if( IfMagickFalse(GetScriptToken(token_info)) ) CLIWandException(OptionFatalError,"MissingArgument",option); CloneString(&arg1,token_info->token); } else CloneString(&arg1,(char *)NULL); if ( count >= 2 ) { if( IfMagickFalse(GetScriptToken(token_info)) ) CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option); CloneString(&arg2,token_info->token); } else CloneString(&arg2,(char *)NULL); #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "Script %u,%u Option: \"%s\" Count: %d Flags: %04x Args: \"%s\" \"%s\"\n", cli_wand->line,cli_wand->line,option,count,option_type,arg1,arg2); #endif if ( (option_type & GenesisOptionFlag) != 0 ) { /* Genesis Options have no place in a magick script */ CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option); goto next_token; } if ( (option_type & DeprecateOptionFlag) != 0 ) { CLIWandException(OptionWarning,"DeprecatedOption",option); if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) break; /* fall through - do the depreciated option */ } if (((option_type & ImageRequiredFlags) != 0 ) && ( cli_wand->wand.images == (Image *)NULL ) ) { CLIWandException(OptionError,"NoImagesFound",option); goto next_token; } /* handle special script-argument options here */ //either continue processing command line // or making use of the command line options. //CLICommandOptions(cli_wand,count+1,argv, MagickScriptArgsFlags); /* Process Option from file */ if ( (option_type & SpecialOptionFlag) != 0 ) { if ( LocaleCompare(option,"-exit") == 0 ) { break; /* forced end of script */ } else if ( LocaleCompare(option,"-script") == 0 ) { /* FUTURE: call new script from this script */ CLIWandExceptionBreak(OptionError,"InvalidUseOfOption",option); goto next_token; } /* handle any other special operators now */ CLISpecialOperator(cli_wand,option,arg1); } if ( (option_type & SettingOptionFlags) != 0 ) { CLISettingOptionInfo(cli_wand, option, arg1, arg2); // FUTURE: Sync Specific Settings into Image Properities (not global) } if ( cli_wand->wand.images != (Image *)NULL ) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, cli_wand->wand.exception); if ( (option_type & SimpleOperatorOptionFlag) != 0) CLISimpleOperatorImages(cli_wand, option, arg1, arg2); if ( (option_type & ListOperatorOptionFlag) != 0 ) CLIListOperatorImages(cli_wand, option, arg1, arg2); next_token: #if MagickCommandDebug >= 9 OutputOptions(cli_wand->wand.image_info); if ( cli_wand->wand.images != (Image *)NULL ) { OutputArtifacts(cli_wand->wand.images); OutputProperties(cli_wand->wand.images,cli_wand->wand.exception); } #endif if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse ) break; } #if MagickCommandDebug >= 3 (void) FormatLocaleFile(stderr, "Script End: %d\n", token_info->status); #endif switch( token_info->status ) { case TokenStatusOK: case TokenStatusEOF: if (cli_wand->image_list_stack != (Stack *)NULL) CLIWandException(OptionError,"UnbalancedParenthesis", "(eof)"); else if (cli_wand->image_info_stack != (Stack *)NULL) CLIWandException(OptionError,"UnbalancedBraces", "(eof)"); break; case TokenStatusBadQuotes: /* Ensure last token has a sane length for error report */ if( strlen(token_info->token) > INITAL_TOKEN_LENGTH-1 ) { token_info->token[INITAL_TOKEN_LENGTH-4] = '.'; token_info->token[INITAL_TOKEN_LENGTH-3] = '.'; token_info->token[INITAL_TOKEN_LENGTH-2] = '.'; token_info->token[INITAL_TOKEN_LENGTH-1] = '\0'; } CLIWandException(OptionFatalError,"ScriptUnbalancedQuotes", token_info->token); break; case TokenStatusMemoryFailed: CLIWandException(OptionFatalError,"ScriptTokenMemoryFailed",""); break; case TokenStatusBinary: CLIWandException(OptionFatalError,"ScriptIsBinary",""); break; } /* Clean up */ token_info = DestroyScriptTokenInfo(token_info); CloneString(&option,(char *)NULL); CloneString(&arg1,(char *)NULL); CloneString(&arg2,(char *)NULL); return; }
WandExport MagickBooleanType MagickImageCommand(ImageInfo *image_info,int argc, char **argv,char **metadata,ExceptionInfo *exception) { MagickCLI *cli_wand; size_t len; assert(image_info != (ImageInfo *) NULL); /* For specific OS command line requirements */ ReadCommandlLine(argc,&argv); /* Initialize special "CLI Wand" to hold images and settings (empty) */ cli_wand=AcquireMagickCLI(image_info,exception); cli_wand->location="Initializing"; cli_wand->filename=argv[0]; cli_wand->line=1; if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "\"%s\"",argv[0]); GetPathComponent(argv[0],TailPath,cli_wand->wand.name); SetClientName(cli_wand->wand.name); ConcatenateMagickString(cli_wand->wand.name,"-CLI",MagickPathExtent); len=strlen(argv[0]); /* precaution */ /* "convert" command - give a "deprecated" warning" */ if (len>=7 && LocaleCompare("convert",argv[0]+len-7) == 0) { cli_wand->process_flags = ConvertCommandOptionFlags; (void) FormatLocaleFile(stderr,"WARNING: %s\n", "The convert command is deprecated in IMv7, use \"magick\"\n"); } /* Special Case: If command name ends with "script" implied "-script" */ if (len>=6 && LocaleCompare("script",argv[0]+len-6) == 0) { if (argc >= 2 && ( (*(argv[1]) != '-') || (strlen(argv[1]) == 1) )) { GetPathComponent(argv[1],TailPath,cli_wand->wand.name); ProcessScriptOptions(cli_wand,argv[1],argc,argv,2); goto Magick_Command_Cleanup; } } /* Special Case: Version Information and Abort */ if (argc == 2) { if ((LocaleCompare("-version",argv[1]) == 0) || /* GNU standard option */ (LocaleCompare("--version",argv[1]) == 0) ) { /* just version */ CLIOption(cli_wand, "-version"); goto Magick_Command_Exit; } if ((LocaleCompare("-help",argv[1]) == 0) || /* GNU standard option */ (LocaleCompare("--help",argv[1]) == 0) ) { /* just a brief summary */ if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- Special Option \"%s\"", argv[1]); MagickUsage(MagickFalse); goto Magick_Command_Exit; } if (LocaleCompare("-usage",argv[1]) == 0) { /* both version & usage */ if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- Special Option \"%s\"", argv[1]); CLIOption(cli_wand, "-version" ); MagickUsage(MagickTrue); goto Magick_Command_Exit; } } /* not enough arguments -- including -help */ if (argc < 3) { (void) FormatLocaleFile(stderr, "Error: Invalid argument or not enough arguments\n\n"); MagickUsage(MagickFalse); goto Magick_Command_Exit; } /* Special "concatenate option (hidden) for delegate usage */ if (LocaleCompare("-concatenate",argv[1]) == 0) { if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- Special Option \"%s\"", argv[1]); ConcatenateImages(argc,argv,exception); goto Magick_Command_Exit; } /* List Information and Abort */ if (argc == 3 && LocaleCompare("-list",argv[1]) == 0) { CLIOption(cli_wand, argv[1], argv[2]); goto Magick_Command_Exit; } /* ------------- */ /* The Main Call */ if (LocaleCompare("-script",argv[1]) == 0) { /* Start processing directly from script, no pre-script options Replace wand command name with script name First argument in the argv array is the script name to read. */ GetPathComponent(argv[2],TailPath,cli_wand->wand.name); ProcessScriptOptions(cli_wand,argv[2],argc,argv,3); } else { /* Normal Command Line, assumes output file as last option */ ProcessCommandOptions(cli_wand,argc,argv,1); } /* ------------- */ Magick_Command_Cleanup: cli_wand->location="Cleanup"; cli_wand->filename=argv[0]; if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "\"%s\"",argv[0]); /* recover original image_info and clean up stacks FUTURE: "-reset stacks" option */ while ((cli_wand->image_list_stack != (Stack *) NULL) && (cli_wand->image_list_stack->next != (Stack *) NULL)) CLIOption(cli_wand,")"); while ((cli_wand->image_info_stack != (Stack *) NULL) && (cli_wand->image_info_stack->next != (Stack *) NULL)) CLIOption(cli_wand,"}"); /* assert we have recovered the original structures */ assert(cli_wand->wand.image_info == image_info); assert(cli_wand->wand.exception == exception); /* Handle metadata for ImageMagickObject COM object for Windows VBS */ if (metadata != (char **) NULL) { const char *format; char *text; format="%w,%h,%m"; // Get this from image_info Option splaytree text=InterpretImageProperties(image_info,cli_wand->wand.images,format, exception); if (text == (char *) NULL) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, "MemoryAllocationFailed","`%s'", GetExceptionMessage(errno)); else { (void) ConcatenateString(&(*metadata),text); text=DestroyString(text); } } Magick_Command_Exit: cli_wand->location="Exiting"; cli_wand->filename=argv[0]; if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "\"%s\"",argv[0]); /* Destroy the special CLI Wand */ cli_wand->wand.image_info = (ImageInfo *) NULL; /* not these */ cli_wand->wand.exception = (ExceptionInfo *) NULL; cli_wand=DestroyMagickCLI(cli_wand); return(exception->severity < ErrorException ? MagickTrue : MagickFalse); }
WandExport MagickBooleanType ConjureImageCommand(ImageInfo *image_info, int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) { #define DestroyConjure() \ { \ image=DestroyImageList(image); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowConjureException(asperity,tag,option) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \ option); \ DestroyConjure(); \ return(MagickFalse); \ } #define ThrowConjureInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","'%s': %s",option,argument); \ DestroyConjure(); \ return(MagickFalse); \ } char filename[MaxTextExtent], *option; Image *image; MagickStatusType status; register ssize_t i; ssize_t number_images; /* Set defaults. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(exception != (ExceptionInfo *) NULL); if (argc < 2) return(ConjureUsage()); image=NewImageList(); number_images=0; option=(char *) NULL; /* Conjure an image. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowConjureException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); for (i=1; i < (ssize_t) argc; i++) { option=argv[i]; if (IsCommandOption(option) != MagickFalse) { if (LocaleCompare("concurrent",option+1) == 0) break; if (LocaleCompare("debug",option+1) == 0) { ssize_t event; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowConjureException(OptionError,"MissingArgument",option); event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); if (event < 0) ThrowConjureException(OptionError,"UnrecognizedEventType", argv[i]); (void) SetLogEventMask(argv[i]); continue; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowConjureException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowConjureInvalidArgumentException(option,argv[i]); continue; } if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) { if (*option == '-') return(ConjureUsage()); continue; } if (LocaleCompare("log",option+1) == 0) { if (*option == '-') { i++; if (i == (ssize_t) argc) ThrowConjureException(OptionError,"MissingLogFormat",option); (void) SetLogFormat(argv[i]); } continue; } if (LocaleCompare("monitor",option+1) == 0) continue; if (LocaleCompare("quiet",option+1) == 0) continue; if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowConjureException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowConjureInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("verbose",option+1) == 0) { image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; continue; } if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); return(MagickFalse); } /* Persist key/value pair. */ (void) DeleteImageOption(image_info,option+1); status=SetImageOption(image_info,option+1,argv[i+1]); if (status == MagickFalse) ThrowConjureException(ImageError,"UnableToPersistKey",option); i++; continue; } /* Interpret MSL script. */ (void) DeleteImageOption(image_info,"filename"); status=SetImageOption(image_info,"filename",argv[i]); if (status == MagickFalse) ThrowConjureException(ImageError,"UnableToPersistKey",argv[i]); (void) FormatLocaleString(filename,MaxTextExtent,"msl:%s",argv[i]); image=ReadImages(image_info,filename,exception); CatchException(exception); if (image != (Image *) NULL) image=DestroyImageList(image); status=image != (Image *) NULL ? MagickTrue : MagickFalse; number_images++; } if (i != (ssize_t) argc) ThrowConjureException(OptionError,"MissingAnImageFilename",argv[i]); if (number_images == 0) ThrowConjureException(OptionError,"MissingAnImageFilename",argv[argc-1]); if (image != (Image *) NULL) image=DestroyImageList(image); for (i=0; i < (ssize_t) argc; i++) argv[i]=DestroyString(argv[i]); argv=(char **) RelinquishMagickMemory(argv); return(status != 0 ? MagickTrue : MagickFalse); }
MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, const MagickBooleanType verbose,ExceptionInfo *exception) { char color[MaxTextExtent], format[MaxTextExtent], key[MaxTextExtent]; ChannelFeatures *channel_features; ChannelStatistics *channel_statistics; ColorspaceType colorspace; const char *artifact, *name, *property, *registry, *value; const MagickInfo *magick_info; double elapsed_time, user_time; ImageType type; MagickBooleanType ping; register const Quantum *p; register ssize_t i, x; size_t distance, scale; ssize_t y; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (file == (FILE *) NULL) file=stdout; *format='\0'; elapsed_time=GetElapsedTime(&image->timer); user_time=GetUserTime(&image->timer); GetTimerInfo(&image->timer); if (verbose == MagickFalse) { /* Display summary info about the image. */ if (*image->magick_filename != '\0') if (LocaleCompare(image->magick_filename,image->filename) != 0) (void) FormatLocaleFile(file,"%s=>",image->magick_filename); if ((GetPreviousImageInList(image) == (Image *) NULL) && (GetNextImageInList(image) == (Image *) NULL) && (image->scene == 0)) (void) FormatLocaleFile(file,"%s ",image->filename); else (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double) image->scene); (void) FormatLocaleFile(file,"%s ",image->magick); if ((image->magick_columns != 0) || (image->magick_rows != 0)) if ((image->magick_columns != image->columns) || (image->magick_rows != image->rows)) (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double) image->magick_columns,(double) image->magick_rows); (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns, (double) image->rows); if ((image->page.width != 0) || (image->page.height != 0) || (image->page.x != 0) || (image->page.y != 0)) (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double) image->page.width,(double) image->page.height,(double) image->page.x, (double) image->page.y); (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth); if (image->type != UndefinedType) (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic( MagickTypeOptions,(ssize_t) image->type)); if (image->storage_class == DirectClass) { (void) FormatLocaleFile(file,"DirectClass "); if (image->total_colors != 0) { (void) FormatMagickSize(image->total_colors,MagickFalse,format); (void) FormatLocaleFile(file,"%s ",format); } } else if (image->total_colors <= image->colors) (void) FormatLocaleFile(file,"PseudoClass %.20gc ",(double) image->colors); else (void) FormatLocaleFile(file,"PseudoClass %.20g=>%.20gc ",(double) image->total_colors,(double) image->colors); if (image->error.mean_error_per_pixel != 0.0) (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double) (image->error.mean_error_per_pixel+0.5), image->error.normalized_mean_error, image->error.normalized_maximum_error); if (GetBlobSize(image) != 0) { (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format); (void) FormatLocaleFile(file,"%s ",format); } (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time, (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod( elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time- floor(elapsed_time)))); (void) FormatLocaleFile(file,"\n"); (void) fflush(file); return(ferror(file) != 0 ? MagickFalse : MagickTrue); } /* Display verbose info about the image. */ p=GetVirtualPixels(image,0,0,1,1,exception); ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse; type=GetImageType(image,exception); (void) SignatureImage(image,exception); (void) FormatLocaleFile(file,"Image: %s\n",image->filename); if (*image->magick_filename != '\0') if (LocaleCompare(image->magick_filename,image->filename) != 0) { char filename[MaxTextExtent]; GetPathComponent(image->magick_filename,TailPath,filename); (void) FormatLocaleFile(file," Base filename: %s\n",filename); } magick_info=GetMagickInfo(image->magick,exception); if ((magick_info == (const MagickInfo *) NULL) || (*GetMagickDescription(magick_info) == '\0')) (void) FormatLocaleFile(file," Format: %s\n",image->magick); else (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick, GetMagickDescription(magick_info)); (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic( MagickClassOptions,(ssize_t) image->storage_class)); (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double) image->columns,(double) image->rows,(double) image->tile_offset.x,(double) image->tile_offset.y); if ((image->magick_columns != 0) || (image->magick_rows != 0)) if ((image->magick_columns != image->columns) || (image->magick_rows != image->rows)) (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double) image->magick_columns,(double) image->magick_rows); if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0)) { (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->resolution.x, image->resolution.y); (void) FormatLocaleFile(file," Print size: %gx%g\n",(double) image->columns/image->resolution.x,(double) image->rows/ image->resolution.y); } (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic( MagickResolutionOptions,(ssize_t) image->units)); (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic( MagickTypeOptions,(ssize_t) type)); if (image->type != UndefinedType) (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic( MagickTypeOptions,(ssize_t) image->type)); (void) FormatLocaleFile(file," Endianess: %s\n",CommandOptionToMnemonic( MagickEndianOptions,(ssize_t) image->endian)); /* Detail channel depth and extrema. */ (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic( MagickColorspaceOptions,(ssize_t) image->colorspace)); channel_statistics=(ChannelStatistics *) NULL; channel_features=(ChannelFeatures *) NULL; colorspace=image->colorspace; scale=1; if (ping == MagickFalse) { size_t depth; channel_statistics=GetImageStatistics(image,exception); artifact=GetImageArtifact(image,"identify:features"); if (artifact != (const char *) NULL) { distance=StringToUnsignedLong(artifact); channel_features=GetImageFeatures(image,distance,exception); } depth=GetImageDepth(image,exception); if (image->depth == depth) (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double) image->depth); else (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double) image->depth,(double) depth); (void) FormatLocaleFile(file," Channel depth:\n"); if (IsImageGray(image,exception) != MagickFalse) colorspace=GRAYColorspace; switch (colorspace) { case RGBColorspace: default: { (void) FormatLocaleFile(file," red: %.20g-bit\n",(double) channel_statistics[RedPixelChannel].depth); (void) FormatLocaleFile(file," green: %.20g-bit\n",(double) channel_statistics[GreenPixelChannel].depth); (void) FormatLocaleFile(file," blue: %.20g-bit\n",(double) channel_statistics[BluePixelChannel].depth); break; } case CMYKColorspace: { (void) FormatLocaleFile(file," cyan: %.20g-bit\n",(double) channel_statistics[CyanPixelChannel].depth); (void) FormatLocaleFile(file," magenta: %.20g-bit\n",(double) channel_statistics[MagentaPixelChannel].depth); (void) FormatLocaleFile(file," yellow: %.20g-bit\n",(double) channel_statistics[YellowPixelChannel].depth); (void) FormatLocaleFile(file," black: %.20g-bit\n",(double) channel_statistics[BlackPixelChannel].depth); break; } case GRAYColorspace: { (void) FormatLocaleFile(file," gray: %.20g-bit\n",(double) channel_statistics[GrayPixelChannel].depth); break; } } if (image->matte != MagickFalse) (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double) channel_statistics[AlphaPixelChannel].depth); scale=1; if (image->depth <= MAGICKCORE_QUANTUM_DEPTH) scale=QuantumRange/((size_t) QuantumRange >> ((size_t) MAGICKCORE_QUANTUM_DEPTH-image->depth)); }