MagickWand  7.0.8
Convert, Edit, Or Compose Bitmap Images
mogrify.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7 % MM MM O O G R R I F Y Y %
8 % M M M O O G GGG RRRR I FFF Y %
9 % M M O O G G R R I F Y %
10 % M M OOO GGGG R R IIIII F Y %
11 % %
12 % %
13 % MagickWand Module Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % March 2000 %
18 % %
19 % %
20 % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % https://www.imagemagick.org/script/license.php %
27 % %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
40 % request.
41 %
42 */
43 
44 /*
45  Include declarations.
46 */
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
51 #include "MagickCore/image-private.h"
52 #include "MagickCore/monitor-private.h"
53 #include "MagickCore/string-private.h"
54 #include "MagickCore/thread-private.h"
55 #include "MagickCore/utility-private.h"
56 #include "MagickCore/blob-private.h"
57 #if defined(MAGICKCORE_HAVE_UTIME_H)
58 #include <utime.h>
59 #endif
60 
61 /*
62  Constant declaration.
63 */
64 static const char
65  MogrifyAlphaColor[] = "#bdbdbd", /* gray */
66  MogrifyBackgroundColor[] = "#ffffff", /* white */
67  MogrifyBorderColor[] = "#dfdfdf"; /* gray */
68 
69 /*
70  Define declarations.
71 */
72 #define UndefinedCompressionQuality 0UL
73 
74 /*
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % %
77 % %
78 % %
79 % M a g i c k C o m m a n d G e n e s i s %
80 % %
81 % %
82 % %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 %
85 % MagickCommandGenesis() applies image processing options to an image as
86 % prescribed by command line options.
87 %
88 % It wiil look for special options like "-debug", "-bench", and
89 % "-distribute-cache" that needs to be applied even before the main
90 % processing begins, and may completely overrule normal command processing.
91 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
92 % and are typically ignored (as they have been handled) if seen later.
93 %
94 % The format of the MagickCommandGenesis method is:
95 %
96 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
97 % MagickCommand command,int argc,char **argv,char **metadata,
98 % ExceptionInfo *exception)
99 %
100 % A description of each parameter follows:
101 %
102 % o image_info: the image info.
103 %
104 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
105 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
106 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
107 % DisplayImageCommand, or AnimateImageCommand.
108 %
109 % o argc: Specifies a pointer to an integer describing the number of
110 % elements in the argument vector.
111 %
112 % o argv: Specifies a pointer to a text array containing the command line
113 % arguments.
114 %
115 % o metadata: any metadata is returned here.
116 %
117 % o exception: return any errors or warnings in this structure.
118 %
119 */
120 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
121  MagickCommand command,int argc,char **argv,char **metadata,
122  ExceptionInfo *exception)
123 {
124  char
125  client_name[MaxTextExtent],
126  *option;
127 
128  double
129  duration,
130  serial;
131 
132  MagickBooleanType
133  concurrent,
134  regard_warnings,
135  status;
136 
137  register ssize_t
138  i;
139 
140  size_t
141  iterations,
142  number_threads;
143 
144  ssize_t
145  n;
146 
147  (void) setlocale(LC_ALL,"");
148  (void) setlocale(LC_NUMERIC,"C");
149  GetPathComponent(argv[0],TailPath,client_name);
150  (void) SetClientName(client_name);
151  concurrent=MagickFalse;
152  duration=(-1.0);
153  iterations=1;
154  status=MagickTrue;
155  regard_warnings=MagickFalse;
156  for (i=1; i < (ssize_t) (argc-1); i++)
157  {
158  option=argv[i];
159  if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
160  continue;
161  if (LocaleCompare("-bench",option) == 0)
162  iterations=StringToUnsignedLong(argv[++i]);
163  if (LocaleCompare("-concurrent",option) == 0)
164  concurrent=MagickTrue;
165  if (LocaleCompare("-debug",option) == 0)
166  (void) SetLogEventMask(argv[++i]);
167  if (LocaleCompare("-distribute-cache",option) == 0)
168  {
169  DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
170  exit(0);
171  }
172  if (LocaleCompare("-duration",option) == 0)
173  duration=StringToDouble(argv[++i],(char **) NULL);
174  if (LocaleCompare("-regard-warnings",option) == 0)
175  regard_warnings=MagickTrue;
176  }
177  if (iterations == 1)
178  {
179  char
180  *text;
181 
182  text=(char *) NULL;
183  status=command(image_info,argc,argv,&text,exception);
184  if (exception->severity != UndefinedException)
185  {
186  if ((exception->severity > ErrorException) ||
187  (regard_warnings != MagickFalse))
188  status=MagickFalse;
189  CatchException(exception);
190  }
191  if (text != (char *) NULL)
192  {
193  if (metadata != (char **) NULL)
194  (void) ConcatenateString(&(*metadata),text);
195  text=DestroyString(text);
196  }
197  return(status);
198  }
199  number_threads=GetOpenMPMaximumThreads();
200  serial=0.0;
201  for (n=1; n <= (ssize_t) number_threads; n++)
202  {
203  double
204  e,
205  parallel,
206  user_time;
207 
208  TimerInfo
209  *timer;
210 
211  (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
212  timer=AcquireTimerInfo();
213  if (concurrent == MagickFalse)
214  {
215  for (i=0; i < (ssize_t) iterations; i++)
216  {
217  char
218  *text;
219 
220  text=(char *) NULL;
221  if (status == MagickFalse)
222  continue;
223  if (duration > 0)
224  {
225  if (GetElapsedTime(timer) > duration)
226  continue;
227  (void) ContinueTimer(timer);
228  }
229  status=command(image_info,argc,argv,&text,exception);
230  if (exception->severity != UndefinedException)
231  {
232  if ((exception->severity > ErrorException) ||
233  (regard_warnings != MagickFalse))
234  status=MagickFalse;
235  CatchException(exception);
236  }
237  if (text != (char *) NULL)
238  {
239  if (metadata != (char **) NULL)
240  (void) ConcatenateString(&(*metadata),text);
241  text=DestroyString(text);
242  }
243  }
244  }
245  else
246  {
247  SetOpenMPNested(1);
248 #if defined(MAGICKCORE_OPENMP_SUPPORT)
249  # pragma omp parallel for shared(status)
250 #endif
251  for (i=0; i < (ssize_t) iterations; i++)
252  {
253  char
254  *text;
255 
256  text=(char *) NULL;
257  if (status == MagickFalse)
258  continue;
259  if (duration > 0)
260  {
261  if (GetElapsedTime(timer) > duration)
262  continue;
263  (void) ContinueTimer(timer);
264  }
265  status=command(image_info,argc,argv,&text,exception);
266 #if defined(MAGICKCORE_OPENMP_SUPPORT)
267  # pragma omp critical (MagickCore_MagickCommandGenesis)
268 #endif
269  {
270  if (exception->severity != UndefinedException)
271  {
272  if ((exception->severity > ErrorException) ||
273  (regard_warnings != MagickFalse))
274  status=MagickFalse;
275  CatchException(exception);
276  }
277  if (text != (char *) NULL)
278  {
279  if (metadata != (char **) NULL)
280  (void) ConcatenateString(&(*metadata),text);
281  text=DestroyString(text);
282  }
283  }
284  }
285  }
286  user_time=GetUserTime(timer);
287  parallel=GetElapsedTime(timer);
288  e=1.0;
289  if (n == 1)
290  serial=parallel;
291  else
292  e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
293  (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
294  (void) FormatLocaleFile(stderr,
295  "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
296  (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
297  (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
298  60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
299  timer=DestroyTimerInfo(timer);
300  }
301  return(status);
302 }
303 
304 /*
305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 % %
307 % %
308 % %
309 + M o g r i f y I m a g e %
310 % %
311 % %
312 % %
313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
314 %
315 % MogrifyImage() applies simple single image processing options to a single
316 % image that may be part of a large list, but also handles any 'region'
317 % image handling.
318 %
319 % The image in the list may be modified in three different ways...
320 %
321 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
322 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
323 % * replace by a list of images (only the -separate option!)
324 %
325 % In each case the result is returned into the list, and a pointer to the
326 % modified image (last image added if replaced by a list of images) is
327 % returned.
328 %
329 % ASIDE: The -crop is present but restricted to non-tile single image crops
330 %
331 % This means if all the images are being processed (such as by
332 % MogrifyImages(), next image to be processed will be as per the pointer
333 % (*image)->next. Also the image list may grow as a result of some specific
334 % operations but as images are never merged or deleted, it will never shrink
335 % in length. Typically the list will remain the same length.
336 %
337 % WARNING: As the image pointed to may be replaced, the first image in the
338 % list may also change. GetFirstImageInList() should be used by caller if
339 % they wish return the Image pointer to the first image in list.
340 %
341 %
342 % The format of the MogrifyImage method is:
343 %
344 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
345 % const char **argv,Image **image)
346 %
347 % A description of each parameter follows:
348 %
349 % o image_info: the image info..
350 %
351 % o argc: Specifies a pointer to an integer describing the number of
352 % elements in the argument vector.
353 %
354 % o argv: Specifies a pointer to a text array containing the command line
355 % arguments.
356 %
357 % o image: the image.
358 %
359 % o exception: return any errors or warnings in this structure.
360 %
361 */
362 
363 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
364  ExceptionInfo *exception)
365 {
366  char
367  key[MagickPathExtent];
368 
369  ExceptionInfo
370  *sans_exception;
371 
372  Image
373  *image;
374 
375  ImageInfo
376  *read_info;
377 
378  /*
379  Read an image into a image cache (for repeated usage) if not already in
380  cache. Then return the image that is in the cache.
381  */
382  (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",path);
383  sans_exception=AcquireExceptionInfo();
384  image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
385  sans_exception=DestroyExceptionInfo(sans_exception);
386  if (image != (Image *) NULL)
387  return(image);
388  read_info=CloneImageInfo(image_info);
389  (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
390  image=ReadImage(read_info,exception);
391  read_info=DestroyImageInfo(read_info);
392  if (image != (Image *) NULL)
393  (void) SetImageRegistry(ImageRegistryType,key,image,exception);
394  return(image);
395 }
396 
397 static inline MagickBooleanType IsPathWritable(const char *path)
398 {
399  if (IsPathAccessible(path) == MagickFalse)
400  return(MagickFalse);
401  if (access_utf8(path,W_OK) != 0)
402  return(MagickFalse);
403  return(MagickTrue);
404 }
405 
406 static MagickBooleanType MonitorProgress(const char *text,
407  const MagickOffsetType offset,const MagickSizeType extent,
408  void *wand_unused(client_data))
409 {
410  char
411  message[MagickPathExtent],
412  tag[MagickPathExtent];
413 
414  const char
415  *locale_message;
416 
417  register char
418  *p;
419 
420  magick_unreferenced(client_data);
421 
422  if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
423  return(MagickTrue);
424  if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
425  return(MagickTrue);
426  (void) CopyMagickString(tag,text,MagickPathExtent);
427  p=strrchr(tag,'/');
428  if (p != (char *) NULL)
429  *p='\0';
430  (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag);
431  locale_message=GetLocaleMessage(message);
432  if (locale_message == message)
433  locale_message=tag;
434  if (p == (char *) NULL)
435  (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
436  locale_message,(long) offset,(unsigned long) extent,(long)
437  (100L*offset/(extent-1)));
438  else
439  (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
440  locale_message,p+1,(long) offset,(unsigned long) extent,(long)
441  (100L*offset/(extent-1)));
442  if (offset == (MagickOffsetType) (extent-1))
443  (void) FormatLocaleFile(stderr,"\n");
444  (void) fflush(stderr);
445  return(MagickTrue);
446 }
447 
448 static Image *SparseColorOption(const Image *image,
449  const SparseColorMethod method,const char *arguments,
450  const MagickBooleanType color_from_image,ExceptionInfo *exception)
451 {
452  char
453  token[MagickPathExtent];
454 
455  const char
456  *p;
457 
458  double
459  *sparse_arguments;
460 
461  Image
462  *sparse_image;
463 
464  PixelInfo
465  color;
466 
467  MagickBooleanType
468  error;
469 
470  register size_t
471  x;
472 
473  size_t
474  number_arguments,
475  number_colors;
476 
477  /*
478  SparseColorOption() parses the complex -sparse-color argument into an an
479  array of floating point values then calls SparseColorImage(). Argument is
480  a complex mix of floating-point pixel coodinates, and color specifications
481  (or direct floating point numbers). The number of floats needed to
482  represent a color varies depending on the current channel setting.
483  */
484  assert(image != (Image *) NULL);
485  assert(image->signature == MagickCoreSignature);
486  if (image->debug != MagickFalse)
487  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
488  assert(exception != (ExceptionInfo *) NULL);
489  assert(exception->signature == MagickCoreSignature);
490  /*
491  Limit channels according to image - and add up number of color channel.
492  */
493  number_colors=0;
494  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
495  number_colors++;
496  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
497  number_colors++;
498  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
499  number_colors++;
500  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
501  (image->colorspace == CMYKColorspace))
502  number_colors++;
503  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
504  (image->alpha_trait != UndefinedPixelTrait))
505  number_colors++;
506 
507  /*
508  Read string, to determine number of arguments needed,
509  */
510  p=arguments;
511  x=0;
512  while( *p != '\0' )
513  {
514  GetNextToken(p,&p,MagickPathExtent,token);
515  if ( token[0] == ',' ) continue;
516  if ( isalpha((int) token[0]) || token[0] == '#' ) {
517  if ( color_from_image ) {
518  (void) ThrowMagickException(exception,GetMagickModule(),
519  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
520  "Color arg given, when colors are coming from image");
521  return( (Image *) NULL);
522  }
523  x += number_colors; /* color argument */
524  }
525  else {
526  x++; /* floating point argument */
527  }
528  }
529  error=MagickTrue;
530  if ( color_from_image ) {
531  /* just the control points are being given */
532  error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
533  number_arguments=(x/2)*(2+number_colors);
534  }
535  else {
536  /* control points and color values */
537  error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
538  number_arguments=x;
539  }
540  if ( error ) {
541  (void) ThrowMagickException(exception,GetMagickModule(),
542  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
543  "Invalid number of Arguments");
544  return( (Image *) NULL);
545  }
546 
547  /* Allocate and fill in the floating point arguments */
548  sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
549  sizeof(*sparse_arguments));
550  if (sparse_arguments == (double *) NULL) {
551  (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
552  "MemoryAllocationFailed","%s","SparseColorOption");
553  return( (Image *) NULL);
554  }
555  (void) memset(sparse_arguments,0,number_arguments*
556  sizeof(*sparse_arguments));
557  p=arguments;
558  x=0;
559  while( *p != '\0' && x < number_arguments ) {
560  /* X coordinate */
561  token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
562  if ( token[0] == '\0' ) break;
563  if ( isalpha((int) token[0]) || token[0] == '#' ) {
564  (void) ThrowMagickException(exception,GetMagickModule(),
565  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
566  "Color found, instead of X-coord");
567  error = MagickTrue;
568  break;
569  }
570  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
571  /* Y coordinate */
572  token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
573  if ( token[0] == '\0' ) break;
574  if ( isalpha((int) token[0]) || token[0] == '#' ) {
575  (void) ThrowMagickException(exception,GetMagickModule(),
576  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
577  "Color found, instead of Y-coord");
578  error = MagickTrue;
579  break;
580  }
581  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
582  /* color values for this control point */
583 #if 0
584  if ( (color_from_image ) {
585  /* get color from image */
586  /* HOW??? */
587  }
588  else
589 #endif
590  {
591  /* color name or function given in string argument */
592  token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
593  if ( token[0] == '\0' ) break;
594  if ( isalpha((int) token[0]) || token[0] == '#' ) {
595  /* Color string given */
596  (void) QueryColorCompliance(token,AllCompliance,&color,exception);
597  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
598  sparse_arguments[x++] = QuantumScale*color.red;
599  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
600  sparse_arguments[x++] = QuantumScale*color.green;
601  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
602  sparse_arguments[x++] = QuantumScale*color.blue;
603  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
604  (image->colorspace == CMYKColorspace))
605  sparse_arguments[x++] = QuantumScale*color.black;
606  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
607  (image->alpha_trait != UndefinedPixelTrait))
608  sparse_arguments[x++] = QuantumScale*color.alpha;
609  }
610  else {
611  /* Colors given as a set of floating point values - experimental */
612  /* NB: token contains the first floating point value to use! */
613  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
614  {
615  while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
616  if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
617  break;
618  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
619  token[0] = ','; /* used this token - get another */
620  }
621  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
622  {
623  while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
624  if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
625  break;
626  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
627  token[0] = ','; /* used this token - get another */
628  }
629  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
630  {
631  while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
632  if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
633  break;
634  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
635  token[0] = ','; /* used this token - get another */
636  }
637  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
638  (image->colorspace == CMYKColorspace))
639  {
640  while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
641  if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
642  break;
643  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
644  token[0] = ','; /* used this token - get another */
645  }
646  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
647  (image->alpha_trait != UndefinedPixelTrait))
648  {
649  while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
650  if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
651  break;
652  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
653  token[0] = ','; /* used this token - get another */
654  }
655  }
656  }
657  }
658  if ( number_arguments != x && !error ) {
659  (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
660  "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
661  sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
662  return( (Image *) NULL);
663  }
664  if ( error )
665  return( (Image *) NULL);
666 
667  /* Call the Interpolation function with the parsed arguments */
668  sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
669  exception);
670  sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
671  return( sparse_image );
672 }
673 
674 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
675  const char **argv,Image **image,ExceptionInfo *exception)
676 {
677  CompositeOperator
678  compose;
679 
680  const char
681  *format,
682  *option;
683 
684  double
685  attenuate;
686 
687  DrawInfo
688  *draw_info;
689 
690  GeometryInfo
691  geometry_info;
692 
693  ImageInfo
694  *mogrify_info;
695 
696  MagickStatusType
697  status;
698 
699  PixelInfo
700  fill;
701 
702  MagickStatusType
703  flags;
704 
705  PixelInterpolateMethod
706  interpolate_method;
707 
708  QuantizeInfo
709  *quantize_info;
710 
711  RectangleInfo
712  geometry,
713  region_geometry;
714 
715  register ssize_t
716  i;
717 
718  /*
719  Initialize method variables.
720  */
721  assert(image_info != (const ImageInfo *) NULL);
722  assert(image_info->signature == MagickCoreSignature);
723  assert(image != (Image **) NULL);
724  assert((*image)->signature == MagickCoreSignature);
725  if ((*image)->debug != MagickFalse)
726  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
727  if (argc < 0)
728  return(MagickTrue);
729  mogrify_info=CloneImageInfo(image_info);
730  draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
731  quantize_info=AcquireQuantizeInfo(mogrify_info);
732  SetGeometryInfo(&geometry_info);
733  GetPixelInfo(*image,&fill);
734  fill=(*image)->background_color;
735  attenuate=1.0;
736  compose=(*image)->compose;
737  interpolate_method=UndefinedInterpolatePixel;
738  format=GetImageOption(mogrify_info,"format");
739  SetGeometry(*image,&region_geometry);
740  /*
741  Transmogrify the image.
742  */
743  for (i=0; i < (ssize_t) argc; i++)
744  {
745  Image
746  *mogrify_image;
747 
748  ssize_t
749  count;
750 
751  option=argv[i];
752  if (IsCommandOption(option) == MagickFalse)
753  continue;
754  count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
755  0L);
756  if ((i+count) >= (ssize_t) argc)
757  break;
758  status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
759  mogrify_image=(Image *) NULL;
760  switch (*(option+1))
761  {
762  case 'a':
763  {
764  if (LocaleCompare("adaptive-blur",option+1) == 0)
765  {
766  /*
767  Adaptive blur image.
768  */
769  (void) SyncImageSettings(mogrify_info,*image,exception);
770  flags=ParseGeometry(argv[i+1],&geometry_info);
771  if ((flags & SigmaValue) == 0)
772  geometry_info.sigma=1.0;
773  mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
774  geometry_info.sigma,exception);
775  break;
776  }
777  if (LocaleCompare("adaptive-resize",option+1) == 0)
778  {
779  /*
780  Adaptive resize image.
781  */
782  (void) SyncImageSettings(mogrify_info,*image,exception);
783  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
784  mogrify_image=AdaptiveResizeImage(*image,geometry.width,
785  geometry.height,exception);
786  break;
787  }
788  if (LocaleCompare("adaptive-sharpen",option+1) == 0)
789  {
790  /*
791  Adaptive sharpen image.
792  */
793  (void) SyncImageSettings(mogrify_info,*image,exception);
794  flags=ParseGeometry(argv[i+1],&geometry_info);
795  if ((flags & SigmaValue) == 0)
796  geometry_info.sigma=1.0;
797  mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
798  geometry_info.sigma,exception);
799  break;
800  }
801  if (LocaleCompare("affine",option+1) == 0)
802  {
803  /*
804  Affine matrix.
805  */
806  if (*option == '+')
807  {
808  GetAffineMatrix(&draw_info->affine);
809  break;
810  }
811  (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
812  break;
813  }
814  if (LocaleCompare("alpha",option+1) == 0)
815  {
816  AlphaChannelOption
817  alpha_type;
818 
819  (void) SyncImageSettings(mogrify_info,*image,exception);
820  alpha_type=(AlphaChannelOption) ParseCommandOption(
821  MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
822  (void) SetImageAlphaChannel(*image,alpha_type,exception);
823  break;
824  }
825  if (LocaleCompare("annotate",option+1) == 0)
826  {
827  char
828  *text,
829  geometry_str[MagickPathExtent];
830 
831  /*
832  Annotate image.
833  */
834  (void) SyncImageSettings(mogrify_info,*image,exception);
835  SetGeometryInfo(&geometry_info);
836  flags=ParseGeometry(argv[i+1],&geometry_info);
837  if ((flags & SigmaValue) == 0)
838  geometry_info.sigma=geometry_info.rho;
839  text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
840  exception);
841  if (text == (char *) NULL)
842  break;
843  (void) CloneString(&draw_info->text,text);
844  text=DestroyString(text);
845  (void) FormatLocaleString(geometry_str,MagickPathExtent,"%+f%+f",
846  geometry_info.xi,geometry_info.psi);
847  (void) CloneString(&draw_info->geometry,geometry_str);
848  draw_info->affine.sx=cos(DegreesToRadians(
849  fmod(geometry_info.rho,360.0)));
850  draw_info->affine.rx=sin(DegreesToRadians(
851  fmod(geometry_info.rho,360.0)));
852  draw_info->affine.ry=(-sin(DegreesToRadians(
853  fmod(geometry_info.sigma,360.0))));
854  draw_info->affine.sy=cos(DegreesToRadians(
855  fmod(geometry_info.sigma,360.0)));
856  (void) AnnotateImage(*image,draw_info,exception);
857  break;
858  }
859  if (LocaleCompare("antialias",option+1) == 0)
860  {
861  draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
862  MagickFalse;
863  draw_info->text_antialias=(*option == '-') ? MagickTrue :
864  MagickFalse;
865  break;
866  }
867  if (LocaleCompare("attenuate",option+1) == 0)
868  {
869  if (*option == '+')
870  {
871  attenuate=1.0;
872  break;
873  }
874  attenuate=StringToDouble(argv[i+1],(char **) NULL);
875  break;
876  }
877  if (LocaleCompare("auto-gamma",option+1) == 0)
878  {
879  /*
880  Auto Adjust Gamma of image based on its mean
881  */
882  (void) SyncImageSettings(mogrify_info,*image,exception);
883  (void) AutoGammaImage(*image,exception);
884  break;
885  }
886  if (LocaleCompare("auto-level",option+1) == 0)
887  {
888  /*
889  Perfectly Normalize (max/min stretch) the image
890  */
891  (void) SyncImageSettings(mogrify_info,*image,exception);
892  (void) AutoLevelImage(*image,exception);
893  break;
894  }
895  if (LocaleCompare("auto-orient",option+1) == 0)
896  {
897  (void) SyncImageSettings(mogrify_info,*image,exception);
898  mogrify_image=AutoOrientImage(*image,(*image)->orientation,
899  exception);
900  break;
901  }
902  if (LocaleCompare("auto-threshold",option+1) == 0)
903  {
904  AutoThresholdMethod
905  method;
906 
907  (void) SyncImageSettings(mogrify_info,*image,exception);
908  method=(AutoThresholdMethod) ParseCommandOption(
909  MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
910  (void) AutoThresholdImage(*image,method,exception);
911  break;
912  }
913  break;
914  }
915  case 'b':
916  {
917  if (LocaleCompare("black-threshold",option+1) == 0)
918  {
919  /*
920  Black threshold image.
921  */
922  (void) SyncImageSettings(mogrify_info,*image,exception);
923  (void) BlackThresholdImage(*image,argv[i+1],exception);
924  break;
925  }
926  if (LocaleCompare("blue-shift",option+1) == 0)
927  {
928  /*
929  Blue shift image.
930  */
931  (void) SyncImageSettings(mogrify_info,*image,exception);
932  geometry_info.rho=1.5;
933  if (*option == '-')
934  flags=ParseGeometry(argv[i+1],&geometry_info);
935  mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
936  break;
937  }
938  if (LocaleCompare("blur",option+1) == 0)
939  {
940  /*
941  Gaussian blur image.
942  */
943  (void) SyncImageSettings(mogrify_info,*image,exception);
944  flags=ParseGeometry(argv[i+1],&geometry_info);
945  if ((flags & SigmaValue) == 0)
946  geometry_info.sigma=1.0;
947  if ((flags & XiValue) == 0)
948  geometry_info.xi=0.0;
949  mogrify_image=BlurImage(*image,geometry_info.rho,
950  geometry_info.sigma,exception);
951  break;
952  }
953  if (LocaleCompare("border",option+1) == 0)
954  {
955  /*
956  Surround image with a border of solid color.
957  */
958  (void) SyncImageSettings(mogrify_info,*image,exception);
959  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
960  mogrify_image=BorderImage(*image,&geometry,compose,exception);
961  break;
962  }
963  if (LocaleCompare("bordercolor",option+1) == 0)
964  {
965  if (*option == '+')
966  {
967  (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
968  &draw_info->border_color,exception);
969  break;
970  }
971  (void) QueryColorCompliance(argv[i+1],AllCompliance,
972  &draw_info->border_color,exception);
973  break;
974  }
975  if (LocaleCompare("box",option+1) == 0)
976  {
977  (void) QueryColorCompliance(argv[i+1],AllCompliance,
978  &draw_info->undercolor,exception);
979  break;
980  }
981  if (LocaleCompare("brightness-contrast",option+1) == 0)
982  {
983  double
984  brightness,
985  contrast;
986 
987  /*
988  Brightness / contrast image.
989  */
990  (void) SyncImageSettings(mogrify_info,*image,exception);
991  flags=ParseGeometry(argv[i+1],&geometry_info);
992  brightness=geometry_info.rho;
993  contrast=0.0;
994  if ((flags & SigmaValue) != 0)
995  contrast=geometry_info.sigma;
996  (void) BrightnessContrastImage(*image,brightness,contrast,
997  exception);
998  break;
999  }
1000  break;
1001  }
1002  case 'c':
1003  {
1004  if (LocaleCompare("canny",option+1) == 0)
1005  {
1006  /*
1007  Detect edges in the image.
1008  */
1009  (void) SyncImageSettings(mogrify_info,*image,exception);
1010  flags=ParseGeometry(argv[i+1],&geometry_info);
1011  if ((flags & SigmaValue) == 0)
1012  geometry_info.sigma=1.0;
1013  if ((flags & XiValue) == 0)
1014  geometry_info.xi=0.10;
1015  if ((flags & PsiValue) == 0)
1016  geometry_info.psi=0.30;
1017  if ((flags & PercentValue) != 0)
1018  {
1019  geometry_info.xi/=100.0;
1020  geometry_info.psi/=100.0;
1021  }
1022  mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
1023  geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
1024  break;
1025  }
1026  if (LocaleCompare("cdl",option+1) == 0)
1027  {
1028  char
1029  *color_correction_collection;
1030 
1031  /*
1032  Color correct with a color decision list.
1033  */
1034  (void) SyncImageSettings(mogrify_info,*image,exception);
1035  color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1036  if (color_correction_collection == (char *) NULL)
1037  break;
1038  (void) ColorDecisionListImage(*image,color_correction_collection,
1039  exception);
1040  break;
1041  }
1042  if (LocaleCompare("channel",option+1) == 0)
1043  {
1044  ChannelType
1045  channel;
1046 
1047  (void) SyncImageSettings(mogrify_info,*image,exception);
1048  if (*option == '+')
1049  {
1050  (void) SetPixelChannelMask(*image,DefaultChannels);
1051  break;
1052  }
1053  channel=(ChannelType) ParseChannelOption(argv[i+1]);
1054  (void) SetPixelChannelMask(*image,channel);
1055  break;
1056  }
1057  if (LocaleCompare("charcoal",option+1) == 0)
1058  {
1059  /*
1060  Charcoal image.
1061  */
1062  (void) SyncImageSettings(mogrify_info,*image,exception);
1063  flags=ParseGeometry(argv[i+1],&geometry_info);
1064  if ((flags & SigmaValue) == 0)
1065  geometry_info.sigma=1.0;
1066  if ((flags & XiValue) == 0)
1067  geometry_info.xi=1.0;
1068  mogrify_image=CharcoalImage(*image,geometry_info.rho,
1069  geometry_info.sigma,exception);
1070  break;
1071  }
1072  if (LocaleCompare("chop",option+1) == 0)
1073  {
1074  /*
1075  Chop the image.
1076  */
1077  (void) SyncImageSettings(mogrify_info,*image,exception);
1078  (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1079  mogrify_image=ChopImage(*image,&geometry,exception);
1080  break;
1081  }
1082  if (LocaleCompare("clip",option+1) == 0)
1083  {
1084  (void) SyncImageSettings(mogrify_info,*image,exception);
1085  if (*option == '+')
1086  {
1087  (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
1088  exception);
1089  break;
1090  }
1091  (void) ClipImage(*image,exception);
1092  break;
1093  }
1094  if (LocaleCompare("clip-mask",option+1) == 0)
1095  {
1096  Image
1097  *clip_mask;
1098 
1099  (void) SyncImageSettings(mogrify_info,*image,exception);
1100  if (*option == '+')
1101  {
1102  /*
1103  Remove a mask.
1104  */
1105  (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
1106  exception);
1107  break;
1108  }
1109  /*
1110  Set the image mask.
1111  */
1112  clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
1113  if (clip_mask == (Image *) NULL)
1114  break;
1115  (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
1116  clip_mask=DestroyImage(clip_mask);
1117  break;
1118  }
1119  if (LocaleCompare("clip-path",option+1) == 0)
1120  {
1121  (void) SyncImageSettings(mogrify_info,*image,exception);
1122  (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1123  MagickFalse,exception);
1124  break;
1125  }
1126  if (LocaleCompare("colorize",option+1) == 0)
1127  {
1128  /*
1129  Colorize the image.
1130  */
1131  (void) SyncImageSettings(mogrify_info,*image,exception);
1132  mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1133  break;
1134  }
1135  if (LocaleCompare("color-matrix",option+1) == 0)
1136  {
1137  KernelInfo
1138  *kernel;
1139 
1140  (void) SyncImageSettings(mogrify_info,*image,exception);
1141  kernel=AcquireKernelInfo(argv[i+1],exception);
1142  if (kernel == (KernelInfo *) NULL)
1143  break;
1144  /* FUTURE: check on size of the matrix */
1145  mogrify_image=ColorMatrixImage(*image,kernel,exception);
1146  kernel=DestroyKernelInfo(kernel);
1147  break;
1148  }
1149  if (LocaleCompare("colors",option+1) == 0)
1150  {
1151  /*
1152  Reduce the number of colors in the image.
1153  */
1154  (void) SyncImageSettings(mogrify_info,*image,exception);
1155  quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1156  if (quantize_info->number_colors == 0)
1157  break;
1158  if (((*image)->storage_class == DirectClass) ||
1159  (*image)->colors > quantize_info->number_colors)
1160  (void) QuantizeImage(quantize_info,*image,exception);
1161  else
1162  (void) CompressImageColormap(*image,exception);
1163  break;
1164  }
1165  if (LocaleCompare("colorspace",option+1) == 0)
1166  {
1167  ColorspaceType
1168  colorspace;
1169 
1170  (void) SyncImageSettings(mogrify_info,*image,exception);
1171  if (*option == '+')
1172  {
1173  (void) TransformImageColorspace(*image,sRGBColorspace,
1174  exception);
1175  break;
1176  }
1177  colorspace=(ColorspaceType) ParseCommandOption(
1178  MagickColorspaceOptions,MagickFalse,argv[i+1]);
1179  (void) TransformImageColorspace(*image,colorspace,exception);
1180  break;
1181  }
1182  if (LocaleCompare("compose",option+1) == 0)
1183  {
1184  (void) SyncImageSettings(mogrify_info,*image,exception);
1185  compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1186  MagickFalse,argv[i+1]);
1187  break;
1188  }
1189  if (LocaleCompare("connected-components",option+1) == 0)
1190  {
1191  (void) SyncImageSettings(mogrify_info,*image,exception);
1192  mogrify_image=ConnectedComponentsImage(*image,(size_t)
1193  StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1194  break;
1195  }
1196  if (LocaleCompare("contrast",option+1) == 0)
1197  {
1198  (void) SyncImageSettings(mogrify_info,*image,exception);
1199  (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1200  MagickFalse,exception);
1201  break;
1202  }
1203  if (LocaleCompare("contrast-stretch",option+1) == 0)
1204  {
1205  double
1206  black_point,
1207  white_point;
1208 
1209  /*
1210  Contrast stretch image.
1211  */
1212  (void) SyncImageSettings(mogrify_info,*image,exception);
1213  flags=ParseGeometry(argv[i+1],&geometry_info);
1214  black_point=geometry_info.rho;
1215  white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1216  black_point;
1217  if ((flags & PercentValue) != 0)
1218  {
1219  black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1220  white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1221  }
1222  white_point=(double) (*image)->columns*(*image)->rows-
1223  white_point;
1224  (void) ContrastStretchImage(*image,black_point,white_point,
1225  exception);
1226  break;
1227  }
1228  if (LocaleCompare("convolve",option+1) == 0)
1229  {
1230  double
1231  gamma;
1232 
1233  KernelInfo
1234  *kernel_info;
1235 
1236  register ssize_t
1237  j;
1238 
1239  size_t
1240  extent;
1241 
1242  (void) SyncImageSettings(mogrify_info,*image,exception);
1243  kernel_info=AcquireKernelInfo(argv[i+1],exception);
1244  if (kernel_info == (KernelInfo *) NULL)
1245  break;
1246  extent=kernel_info->width*kernel_info->height;
1247  gamma=0.0;
1248  for (j=0; j < (ssize_t) extent; j++)
1249  gamma+=kernel_info->values[j];
1250  gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1251  for (j=0; j < (ssize_t) extent; j++)
1252  kernel_info->values[j]*=gamma;
1253  mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1254  kernel_info,exception);
1255  kernel_info=DestroyKernelInfo(kernel_info);
1256  break;
1257  }
1258  if (LocaleCompare("crop",option+1) == 0)
1259  {
1260  /*
1261  Crop a image to a smaller size
1262  */
1263  (void) SyncImageSettings(mogrify_info,*image,exception);
1264  mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1265  break;
1266  }
1267  if (LocaleCompare("cycle",option+1) == 0)
1268  {
1269  /*
1270  Cycle an image colormap.
1271  */
1272  (void) SyncImageSettings(mogrify_info,*image,exception);
1273  (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1274  exception);
1275  break;
1276  }
1277  break;
1278  }
1279  case 'd':
1280  {
1281  if (LocaleCompare("decipher",option+1) == 0)
1282  {
1283  StringInfo
1284  *passkey;
1285 
1286  /*
1287  Decipher pixels.
1288  */
1289  (void) SyncImageSettings(mogrify_info,*image,exception);
1290  passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1291  if (passkey != (StringInfo *) NULL)
1292  {
1293  (void) PasskeyDecipherImage(*image,passkey,exception);
1294  passkey=DestroyStringInfo(passkey);
1295  }
1296  break;
1297  }
1298  if (LocaleCompare("density",option+1) == 0)
1299  {
1300  /*
1301  Set image density.
1302  */
1303  (void) CloneString(&draw_info->density,argv[i+1]);
1304  break;
1305  }
1306  if (LocaleCompare("depth",option+1) == 0)
1307  {
1308  (void) SyncImageSettings(mogrify_info,*image,exception);
1309  if (*option == '+')
1310  {
1311  (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1312  break;
1313  }
1314  (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1315  exception);
1316  break;
1317  }
1318  if (LocaleCompare("deskew",option+1) == 0)
1319  {
1320  double
1321  threshold;
1322 
1323  /*
1324  Straighten the image.
1325  */
1326  (void) SyncImageSettings(mogrify_info,*image,exception);
1327  if (*option == '+')
1328  threshold=40.0*QuantumRange/100.0;
1329  else
1330  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1331  1.0);
1332  mogrify_image=DeskewImage(*image,threshold,exception);
1333  break;
1334  }
1335  if (LocaleCompare("despeckle",option+1) == 0)
1336  {
1337  /*
1338  Reduce the speckles within an image.
1339  */
1340  (void) SyncImageSettings(mogrify_info,*image,exception);
1341  mogrify_image=DespeckleImage(*image,exception);
1342  break;
1343  }
1344  if (LocaleCompare("display",option+1) == 0)
1345  {
1346  (void) CloneString(&draw_info->server_name,argv[i+1]);
1347  break;
1348  }
1349  if (LocaleCompare("distort",option+1) == 0)
1350  {
1351  char
1352  *args,
1353  token[MagickPathExtent];
1354 
1355  const char
1356  *p;
1357 
1358  DistortMethod
1359  method;
1360 
1361  double
1362  *arguments;
1363 
1364  register ssize_t
1365  x;
1366 
1367  size_t
1368  number_arguments;
1369 
1370  /*
1371  Distort image.
1372  */
1373  (void) SyncImageSettings(mogrify_info,*image,exception);
1374  method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1375  MagickFalse,argv[i+1]);
1376  if (method == ResizeDistortion)
1377  {
1378  double
1379  resize_args[2];
1380 
1381  /*
1382  Special Case - Argument is actually a resize geometry!
1383  Convert that to an appropriate distortion argument array.
1384  */
1385  (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1386  exception);
1387  resize_args[0]=(double) geometry.width;
1388  resize_args[1]=(double) geometry.height;
1389  mogrify_image=DistortImage(*image,method,(size_t)2,
1390  resize_args,MagickTrue,exception);
1391  break;
1392  }
1393  args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1394  exception);
1395  if (args == (char *) NULL)
1396  break;
1397  p=(char *) args;
1398  for (x=0; *p != '\0'; x++)
1399  {
1400  GetNextToken(p,&p,MagickPathExtent,token);
1401  if (*token == ',')
1402  GetNextToken(p,&p,MagickPathExtent,token);
1403  }
1404  number_arguments=(size_t) x;
1405  arguments=(double *) AcquireQuantumMemory(number_arguments,
1406  sizeof(*arguments));
1407  if (arguments == (double *) NULL)
1408  ThrowWandFatalException(ResourceLimitFatalError,
1409  "MemoryAllocationFailed",(*image)->filename);
1410  (void) memset(arguments,0,number_arguments*
1411  sizeof(*arguments));
1412  p=(char *) args;
1413  for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1414  {
1415  GetNextToken(p,&p,MagickPathExtent,token);
1416  if (*token == ',')
1417  GetNextToken(p,&p,MagickPathExtent,token);
1418  arguments[x]=StringToDouble(token,(char **) NULL);
1419  }
1420  args=DestroyString(args);
1421  mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1422  (*option == '+') ? MagickTrue : MagickFalse,exception);
1423  arguments=(double *) RelinquishMagickMemory(arguments);
1424  break;
1425  }
1426  if (LocaleCompare("dither",option+1) == 0)
1427  {
1428  if (*option == '+')
1429  {
1430  quantize_info->dither_method=NoDitherMethod;
1431  break;
1432  }
1433  quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1434  MagickDitherOptions,MagickFalse,argv[i+1]);
1435  break;
1436  }
1437  if (LocaleCompare("draw",option+1) == 0)
1438  {
1439  /*
1440  Draw image.
1441  */
1442  (void) SyncImageSettings(mogrify_info,*image,exception);
1443  (void) CloneString(&draw_info->primitive,argv[i+1]);
1444  (void) DrawImage(*image,draw_info,exception);
1445  break;
1446  }
1447  break;
1448  }
1449  case 'e':
1450  {
1451  if (LocaleCompare("edge",option+1) == 0)
1452  {
1453  /*
1454  Enhance edges in the image.
1455  */
1456  (void) SyncImageSettings(mogrify_info,*image,exception);
1457  flags=ParseGeometry(argv[i+1],&geometry_info);
1458  mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1459  break;
1460  }
1461  if (LocaleCompare("emboss",option+1) == 0)
1462  {
1463  /*
1464  Emboss image.
1465  */
1466  (void) SyncImageSettings(mogrify_info,*image,exception);
1467  flags=ParseGeometry(argv[i+1],&geometry_info);
1468  if ((flags & SigmaValue) == 0)
1469  geometry_info.sigma=1.0;
1470  mogrify_image=EmbossImage(*image,geometry_info.rho,
1471  geometry_info.sigma,exception);
1472  break;
1473  }
1474  if (LocaleCompare("encipher",option+1) == 0)
1475  {
1476  StringInfo
1477  *passkey;
1478 
1479  /*
1480  Encipher pixels.
1481  */
1482  (void) SyncImageSettings(mogrify_info,*image,exception);
1483  passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1484  if (passkey != (StringInfo *) NULL)
1485  {
1486  (void) PasskeyEncipherImage(*image,passkey,exception);
1487  passkey=DestroyStringInfo(passkey);
1488  }
1489  break;
1490  }
1491  if (LocaleCompare("encoding",option+1) == 0)
1492  {
1493  (void) CloneString(&draw_info->encoding,argv[i+1]);
1494  break;
1495  }
1496  if (LocaleCompare("enhance",option+1) == 0)
1497  {
1498  /*
1499  Enhance image.
1500  */
1501  (void) SyncImageSettings(mogrify_info,*image,exception);
1502  mogrify_image=EnhanceImage(*image,exception);
1503  break;
1504  }
1505  if (LocaleCompare("equalize",option+1) == 0)
1506  {
1507  /*
1508  Equalize image.
1509  */
1510  (void) SyncImageSettings(mogrify_info,*image,exception);
1511  (void) EqualizeImage(*image,exception);
1512  break;
1513  }
1514  if (LocaleCompare("evaluate",option+1) == 0)
1515  {
1516  double
1517  constant;
1518 
1519  MagickEvaluateOperator
1520  op;
1521 
1522  (void) SyncImageSettings(mogrify_info,*image,exception);
1523  op=(MagickEvaluateOperator) ParseCommandOption(
1524  MagickEvaluateOptions,MagickFalse,argv[i+1]);
1525  constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1526  1.0);
1527  (void) EvaluateImage(*image,op,constant,exception);
1528  break;
1529  }
1530  if (LocaleCompare("extent",option+1) == 0)
1531  {
1532  /*
1533  Set the image extent.
1534  */
1535  (void) SyncImageSettings(mogrify_info,*image,exception);
1536  flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1537  if (geometry.width == 0)
1538  geometry.width=(*image)->columns;
1539  if (geometry.height == 0)
1540  geometry.height=(*image)->rows;
1541  mogrify_image=ExtentImage(*image,&geometry,exception);
1542  break;
1543  }
1544  break;
1545  }
1546  case 'f':
1547  {
1548  if (LocaleCompare("family",option+1) == 0)
1549  {
1550  if (*option == '+')
1551  {
1552  if (draw_info->family != (char *) NULL)
1553  draw_info->family=DestroyString(draw_info->family);
1554  break;
1555  }
1556  (void) CloneString(&draw_info->family,argv[i+1]);
1557  break;
1558  }
1559  if (LocaleCompare("features",option+1) == 0)
1560  {
1561  if (*option == '+')
1562  {
1563  (void) DeleteImageArtifact(*image,"identify:features");
1564  break;
1565  }
1566  (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1567  (void) SetImageArtifact(*image,"verbose","true");
1568  break;
1569  }
1570  if (LocaleCompare("fill",option+1) == 0)
1571  {
1572  ExceptionInfo
1573  *sans;
1574 
1575  PixelInfo
1576  color;
1577 
1578  GetPixelInfo(*image,&fill);
1579  if (*option == '+')
1580  {
1581  (void) QueryColorCompliance("none",AllCompliance,&fill,
1582  exception);
1583  draw_info->fill=fill;
1584  if (draw_info->fill_pattern != (Image *) NULL)
1585  draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1586  break;
1587  }
1588  sans=AcquireExceptionInfo();
1589  status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1590  sans=DestroyExceptionInfo(sans);
1591  if (status == MagickFalse)
1592  draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1593  exception);
1594  else
1595  draw_info->fill=fill=color;
1596  break;
1597  }
1598  if (LocaleCompare("flip",option+1) == 0)
1599  {
1600  /*
1601  Flip image scanlines.
1602  */
1603  (void) SyncImageSettings(mogrify_info,*image,exception);
1604  mogrify_image=FlipImage(*image,exception);
1605  break;
1606  }
1607  if (LocaleCompare("floodfill",option+1) == 0)
1608  {
1609  PixelInfo
1610  target;
1611 
1612  /*
1613  Floodfill image.
1614  */
1615  (void) SyncImageSettings(mogrify_info,*image,exception);
1616  (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1617  (void) GetOneVirtualPixelInfo(*image,TileVirtualPixelMethod,
1618  geometry.x,geometry.y,&target,exception);
1619  (void) QueryColorCompliance(argv[i+2],AllCompliance,
1620  &draw_info->fill,exception);
1621  (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1622  geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1623  break;
1624  }
1625  if (LocaleCompare("flop",option+1) == 0)
1626  {
1627  /*
1628  Flop image scanlines.
1629  */
1630  (void) SyncImageSettings(mogrify_info,*image,exception);
1631  mogrify_image=FlopImage(*image,exception);
1632  break;
1633  }
1634  if (LocaleCompare("font",option+1) == 0)
1635  {
1636  if (*option == '+')
1637  {
1638  if (draw_info->font != (char *) NULL)
1639  draw_info->font=DestroyString(draw_info->font);
1640  break;
1641  }
1642  (void) CloneString(&draw_info->font,argv[i+1]);
1643  break;
1644  }
1645  if (LocaleCompare("format",option+1) == 0)
1646  {
1647  format=argv[i+1];
1648  break;
1649  }
1650  if (LocaleCompare("frame",option+1) == 0)
1651  {
1652  FrameInfo
1653  frame_info;
1654 
1655  /*
1656  Surround image with an ornamental border.
1657  */
1658  (void) SyncImageSettings(mogrify_info,*image,exception);
1659  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1660  frame_info.width=geometry.width;
1661  frame_info.height=geometry.height;
1662  frame_info.outer_bevel=geometry.x;
1663  frame_info.inner_bevel=geometry.y;
1664  frame_info.x=(ssize_t) frame_info.width;
1665  frame_info.y=(ssize_t) frame_info.height;
1666  frame_info.width=(*image)->columns+2*frame_info.width;
1667  frame_info.height=(*image)->rows+2*frame_info.height;
1668  mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1669  break;
1670  }
1671  if (LocaleCompare("function",option+1) == 0)
1672  {
1673  char
1674  *arguments,
1675  token[MagickPathExtent];
1676 
1677  const char
1678  *p;
1679 
1680  double
1681  *parameters;
1682 
1683  MagickFunction
1684  function;
1685 
1686  register ssize_t
1687  x;
1688 
1689  size_t
1690  number_parameters;
1691 
1692  /*
1693  Function Modify Image Values
1694  */
1695  (void) SyncImageSettings(mogrify_info,*image,exception);
1696  function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1697  MagickFalse,argv[i+1]);
1698  arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1699  exception);
1700  if (arguments == (char *) NULL)
1701  break;
1702  p=(char *) arguments;
1703  for (x=0; *p != '\0'; x++)
1704  {
1705  GetNextToken(p,&p,MagickPathExtent,token);
1706  if (*token == ',')
1707  GetNextToken(p,&p,MagickPathExtent,token);
1708  }
1709  number_parameters=(size_t) x;
1710  parameters=(double *) AcquireQuantumMemory(number_parameters,
1711  sizeof(*parameters));
1712  if (parameters == (double *) NULL)
1713  ThrowWandFatalException(ResourceLimitFatalError,
1714  "MemoryAllocationFailed",(*image)->filename);
1715  (void) memset(parameters,0,number_parameters*
1716  sizeof(*parameters));
1717  p=(char *) arguments;
1718  for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1719  {
1720  GetNextToken(p,&p,MagickPathExtent,token);
1721  if (*token == ',')
1722  GetNextToken(p,&p,MagickPathExtent,token);
1723  parameters[x]=StringToDouble(token,(char **) NULL);
1724  }
1725  arguments=DestroyString(arguments);
1726  (void) FunctionImage(*image,function,number_parameters,parameters,
1727  exception);
1728  parameters=(double *) RelinquishMagickMemory(parameters);
1729  break;
1730  }
1731  break;
1732  }
1733  case 'g':
1734  {
1735  if (LocaleCompare("gamma",option+1) == 0)
1736  {
1737  /*
1738  Gamma image.
1739  */
1740  (void) SyncImageSettings(mogrify_info,*image,exception);
1741  if (*option == '+')
1742  (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1743  else
1744  (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),
1745  exception);
1746  break;
1747  }
1748  if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1749  (LocaleCompare("gaussian",option+1) == 0))
1750  {
1751  /*
1752  Gaussian blur image.
1753  */
1754  (void) SyncImageSettings(mogrify_info,*image,exception);
1755  flags=ParseGeometry(argv[i+1],&geometry_info);
1756  if ((flags & SigmaValue) == 0)
1757  geometry_info.sigma=1.0;
1758  mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1759  geometry_info.sigma,exception);
1760  break;
1761  }
1762  if (LocaleCompare("geometry",option+1) == 0)
1763  {
1764  /*
1765  Record Image offset, Resize last image.
1766  */
1767  (void) SyncImageSettings(mogrify_info,*image,exception);
1768  if (*option == '+')
1769  {
1770  if ((*image)->geometry != (char *) NULL)
1771  (*image)->geometry=DestroyString((*image)->geometry);
1772  break;
1773  }
1774  flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1775  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1776  (void) CloneString(&(*image)->geometry,argv[i+1]);
1777  else
1778  mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1779  (*image)->filter,exception);
1780  break;
1781  }
1782  if (LocaleCompare("gravity",option+1) == 0)
1783  {
1784  if (*option == '+')
1785  {
1786  draw_info->gravity=UndefinedGravity;
1787  break;
1788  }
1789  draw_info->gravity=(GravityType) ParseCommandOption(
1790  MagickGravityOptions,MagickFalse,argv[i+1]);
1791  break;
1792  }
1793  if (LocaleCompare("grayscale",option+1) == 0)
1794  {
1795  PixelIntensityMethod
1796  method;
1797 
1798  (void) SyncImageSettings(mogrify_info,*image,exception);
1799  method=(PixelIntensityMethod) ParseCommandOption(
1800  MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1801  (void) GrayscaleImage(*image,method,exception);
1802  break;
1803  }
1804  break;
1805  }
1806  case 'h':
1807  {
1808  if (LocaleCompare("highlight-color",option+1) == 0)
1809  {
1810  (void) SetImageArtifact(*image,"compare:highlight-color",argv[i+1]);
1811  break;
1812  }
1813  if (LocaleCompare("hough-lines",option+1) == 0)
1814  {
1815  /*
1816  Detect edges in the image.
1817  */
1818  (void) SyncImageSettings(mogrify_info,*image,exception);
1819  flags=ParseGeometry(argv[i+1],&geometry_info);
1820  if ((flags & SigmaValue) == 0)
1821  geometry_info.sigma=geometry_info.rho;
1822  if ((flags & XiValue) == 0)
1823  geometry_info.xi=40;
1824  mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1825  (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1826  break;
1827  }
1828  break;
1829  }
1830  case 'i':
1831  {
1832  if (LocaleCompare("identify",option+1) == 0)
1833  {
1834  char
1835  *text;
1836 
1837  (void) SyncImageSettings(mogrify_info,*image,exception);
1838  if (format == (char *) NULL)
1839  {
1840  (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1841  exception);
1842  break;
1843  }
1844  text=InterpretImageProperties(mogrify_info,*image,format,
1845  exception);
1846  if (text == (char *) NULL)
1847  break;
1848  (void) fputs(text,stdout);
1849  text=DestroyString(text);
1850  break;
1851  }
1852  if (LocaleCompare("implode",option+1) == 0)
1853  {
1854  /*
1855  Implode image.
1856  */
1857  (void) SyncImageSettings(mogrify_info,*image,exception);
1858  (void) ParseGeometry(argv[i+1],&geometry_info);
1859  mogrify_image=ImplodeImage(*image,geometry_info.rho,
1860  interpolate_method,exception);
1861  break;
1862  }
1863  if (LocaleCompare("interline-spacing",option+1) == 0)
1864  {
1865  if (*option == '+')
1866  (void) ParseGeometry("0",&geometry_info);
1867  else
1868  (void) ParseGeometry(argv[i+1],&geometry_info);
1869  draw_info->interline_spacing=geometry_info.rho;
1870  break;
1871  }
1872  if (LocaleCompare("interpolate",option+1) == 0)
1873  {
1874  interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1875  MagickInterpolateOptions,MagickFalse,argv[i+1]);
1876  break;
1877  }
1878  if (LocaleCompare("interword-spacing",option+1) == 0)
1879  {
1880  if (*option == '+')
1881  (void) ParseGeometry("0",&geometry_info);
1882  else
1883  (void) ParseGeometry(argv[i+1],&geometry_info);
1884  draw_info->interword_spacing=geometry_info.rho;
1885  break;
1886  }
1887  if (LocaleCompare("interpolative-resize",option+1) == 0)
1888  {
1889  /*
1890  Interpolative resize image.
1891  */
1892  (void) SyncImageSettings(mogrify_info,*image,exception);
1893  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1894  mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1895  geometry.height,interpolate_method,exception);
1896  break;
1897  }
1898  break;
1899  }
1900  case 'k':
1901  {
1902  if (LocaleCompare("kerning",option+1) == 0)
1903  {
1904  if (*option == '+')
1905  (void) ParseGeometry("0",&geometry_info);
1906  else
1907  (void) ParseGeometry(argv[i+1],&geometry_info);
1908  draw_info->kerning=geometry_info.rho;
1909  break;
1910  }
1911  if (LocaleCompare("kuwahara",option+1) == 0)
1912  {
1913  /*
1914  Edge preserving blur.
1915  */
1916  (void) SyncImageSettings(mogrify_info,*image,exception);
1917  flags=ParseGeometry(argv[i+1],&geometry_info);
1918  if ((flags & SigmaValue) == 0)
1919  geometry_info.sigma=geometry_info.rho-0.5;
1920  mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1921  geometry_info.sigma,exception);
1922  break;
1923  }
1924  break;
1925  }
1926  case 'l':
1927  {
1928  if (LocaleCompare("lat",option+1) == 0)
1929  {
1930  /*
1931  Local adaptive threshold image.
1932  */
1933  (void) SyncImageSettings(mogrify_info,*image,exception);
1934  flags=ParseGeometry(argv[i+1],&geometry_info);
1935  if ((flags & PercentValue) != 0)
1936  geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1937  mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1938  geometry_info.rho,(size_t) geometry_info.sigma,(double)
1939  geometry_info.xi,exception);
1940  break;
1941  }
1942  if (LocaleCompare("level",option+1) == 0)
1943  {
1944  double
1945  black_point,
1946  gamma,
1947  white_point;
1948 
1949  /*
1950  Parse levels.
1951  */
1952  (void) SyncImageSettings(mogrify_info,*image,exception);
1953  flags=ParseGeometry(argv[i+1],&geometry_info);
1954  black_point=geometry_info.rho;
1955  white_point=(double) QuantumRange;
1956  if ((flags & SigmaValue) != 0)
1957  white_point=geometry_info.sigma;
1958  gamma=1.0;
1959  if ((flags & XiValue) != 0)
1960  gamma=geometry_info.xi;
1961  if ((flags & PercentValue) != 0)
1962  {
1963  black_point*=(double) (QuantumRange/100.0);
1964  white_point*=(double) (QuantumRange/100.0);
1965  }
1966  if ((flags & SigmaValue) == 0)
1967  white_point=(double) QuantumRange-black_point;
1968  if ((*option == '+') || ((flags & AspectValue) != 0))
1969  (void) LevelizeImage(*image,black_point,white_point,gamma,
1970  exception);
1971  else
1972  (void) LevelImage(*image,black_point,white_point,gamma,
1973  exception);
1974  break;
1975  }
1976  if (LocaleCompare("level-colors",option+1) == 0)
1977  {
1978  char
1979  token[MagickPathExtent];
1980 
1981  const char
1982  *p;
1983 
1984  PixelInfo
1985  black_point,
1986  white_point;
1987 
1988  p=(const char *) argv[i+1];
1989  GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */
1990  if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1991  (void) QueryColorCompliance(token,AllCompliance,
1992  &black_point,exception);
1993  else
1994  (void) QueryColorCompliance("#000000",AllCompliance,
1995  &black_point,exception);
1996  if (isalpha((int) token[0]) || (token[0] == '#'))
1997  GetNextToken(p,&p,MagickPathExtent,token);
1998  if (*token == '\0')
1999  white_point=black_point; /* set everything to that color */
2000  else
2001  {
2002  if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2003  GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */
2004  if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2005  (void) QueryColorCompliance(token,AllCompliance,
2006  &white_point,exception);
2007  else
2008  (void) QueryColorCompliance("#ffffff",AllCompliance,
2009  &white_point,exception);
2010  }
2011  (void) LevelImageColors(*image,&black_point,&white_point,
2012  *option == '+' ? MagickTrue : MagickFalse,exception);
2013  break;
2014  }
2015  if (LocaleCompare("linear-stretch",option+1) == 0)
2016  {
2017  double
2018  black_point,
2019  white_point;
2020 
2021  (void) SyncImageSettings(mogrify_info,*image,exception);
2022  flags=ParseGeometry(argv[i+1],&geometry_info);
2023  black_point=geometry_info.rho;
2024  white_point=(double) (*image)->columns*(*image)->rows;
2025  if ((flags & SigmaValue) != 0)
2026  white_point=geometry_info.sigma;
2027  if ((flags & PercentValue) != 0)
2028  {
2029  black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2030  white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2031  }
2032  if ((flags & SigmaValue) == 0)
2033  white_point=(double) (*image)->columns*(*image)->rows-
2034  black_point;
2035  (void) LinearStretchImage(*image,black_point,white_point,exception);
2036  break;
2037  }
2038  if (LocaleCompare("liquid-rescale",option+1) == 0)
2039  {
2040  /*
2041  Liquid rescale image.
2042  */
2043  (void) SyncImageSettings(mogrify_info,*image,exception);
2044  flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2045  if ((flags & XValue) == 0)
2046  geometry.x=1;
2047  if ((flags & YValue) == 0)
2048  geometry.y=0;
2049  mogrify_image=LiquidRescaleImage(*image,geometry.width,
2050  geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2051  break;
2052  }
2053  if (LocaleCompare("local-contrast",option+1) == 0)
2054  {
2055  (void) SyncImageSettings(mogrify_info,*image,exception);
2056  flags=ParseGeometry(argv[i+1],&geometry_info);
2057  if ((flags & RhoValue) == 0)
2058  geometry_info.rho=10;
2059  if ((flags & SigmaValue) == 0)
2060  geometry_info.sigma=12.5;
2061  mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2062  geometry_info.sigma,exception);
2063  break;
2064  }
2065  if (LocaleCompare("lowlight-color",option+1) == 0)
2066  {
2067  (void) SetImageArtifact(*image,"compare:lowlight-color",argv[i+1]);
2068  break;
2069  }
2070  break;
2071  }
2072  case 'm':
2073  {
2074  if (LocaleCompare("magnify",option+1) == 0)
2075  {
2076  /*
2077  Double image size.
2078  */
2079  (void) SyncImageSettings(mogrify_info,*image,exception);
2080  mogrify_image=MagnifyImage(*image,exception);
2081  break;
2082  }
2083  if (LocaleCompare("map",option+1) == 0)
2084  {
2085  Image
2086  *remap_image;
2087 
2088  /*
2089  Transform image colors to match this set of colors.
2090  */
2091  (void) SyncImageSettings(mogrify_info,*image,exception);
2092  if (*option == '+')
2093  break;
2094  remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2095  if (remap_image == (Image *) NULL)
2096  break;
2097  (void) RemapImage(quantize_info,*image,remap_image,exception);
2098  remap_image=DestroyImage(remap_image);
2099  break;
2100  }
2101  if (LocaleCompare("mask",option+1) == 0)
2102  {
2103  Image
2104  *mask;
2105 
2106  (void) SyncImageSettings(mogrify_info,*image,exception);
2107  if (*option == '+')
2108  {
2109  /*
2110  Remove a mask.
2111  */
2112  (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
2113  exception);
2114  break;
2115  }
2116  /*
2117  Set the image mask.
2118  */
2119  mask=GetImageCache(mogrify_info,argv[i+1],exception);
2120  if (mask == (Image *) NULL)
2121  break;
2122  (void) SetImageMask(*image,WritePixelMask,mask,exception);
2123  mask=DestroyImage(mask);
2124  break;
2125  }
2126  if (LocaleCompare("matte",option+1) == 0)
2127  {
2128  (void) SetImageAlphaChannel(*image,(*option == '-') ?
2129  SetAlphaChannel : DeactivateAlphaChannel,exception);
2130  break;
2131  }
2132  if (LocaleCompare("mean-shift",option+1) == 0)
2133  {
2134  /*
2135  Detect edges in the image.
2136  */
2137  (void) SyncImageSettings(mogrify_info,*image,exception);
2138  flags=ParseGeometry(argv[i+1],&geometry_info);
2139  if ((flags & SigmaValue) == 0)
2140  geometry_info.sigma=geometry_info.rho;
2141  if ((flags & XiValue) == 0)
2142  geometry_info.xi=0.10*QuantumRange;
2143  if ((flags & PercentValue) != 0)
2144  geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2145  mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2146  (size_t) geometry_info.sigma,geometry_info.xi,exception);
2147  break;
2148  }
2149  if (LocaleCompare("median",option+1) == 0)
2150  {
2151  /*
2152  Median filter image.
2153  */
2154  (void) SyncImageSettings(mogrify_info,*image,exception);
2155  flags=ParseGeometry(argv[i+1],&geometry_info);
2156  if ((flags & SigmaValue) == 0)
2157  geometry_info.sigma=geometry_info.rho;
2158  mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2159  geometry_info.rho,(size_t) geometry_info.sigma,exception);
2160  break;
2161  }
2162  if (LocaleCompare("mode",option+1) == 0)
2163  {
2164  /*
2165  Mode image.
2166  */
2167  (void) SyncImageSettings(mogrify_info,*image,exception);
2168  flags=ParseGeometry(argv[i+1],&geometry_info);
2169  if ((flags & SigmaValue) == 0)
2170  geometry_info.sigma=geometry_info.rho;
2171  mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2172  geometry_info.rho,(size_t) geometry_info.sigma,exception);
2173  break;
2174  }
2175  if (LocaleCompare("modulate",option+1) == 0)
2176  {
2177  (void) SyncImageSettings(mogrify_info,*image,exception);
2178  (void) ModulateImage(*image,argv[i+1],exception);
2179  break;
2180  }
2181  if (LocaleCompare("moments",option+1) == 0)
2182  {
2183  if (*option == '+')
2184  {
2185  (void) DeleteImageArtifact(*image,"identify:moments");
2186  break;
2187  }
2188  (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2189  (void) SetImageArtifact(*image,"verbose","true");
2190  break;
2191  }
2192  if (LocaleCompare("monitor",option+1) == 0)
2193  {
2194  if (*option == '+')
2195  {
2196  (void) SetImageProgressMonitor(*image,
2197  (MagickProgressMonitor) NULL,(void *) NULL);
2198  break;
2199  }
2200  (void) SetImageProgressMonitor(*image,MonitorProgress,
2201  (void *) NULL);
2202  break;
2203  }
2204  if (LocaleCompare("monochrome",option+1) == 0)
2205  {
2206  (void) SyncImageSettings(mogrify_info,*image,exception);
2207  (void) SetImageType(*image,BilevelType,exception);
2208  break;
2209  }
2210  if (LocaleCompare("morphology",option+1) == 0)
2211  {
2212  char
2213  token[MagickPathExtent];
2214 
2215  const char
2216  *p;
2217 
2218  KernelInfo
2219  *kernel;
2220 
2221  MorphologyMethod
2222  method;
2223 
2224  ssize_t
2225  iterations;
2226 
2227  /*
2228  Morphological Image Operation
2229  */
2230  (void) SyncImageSettings(mogrify_info,*image,exception);
2231  p=argv[i+1];
2232  GetNextToken(p,&p,MagickPathExtent,token);
2233  method=(MorphologyMethod) ParseCommandOption(
2234  MagickMorphologyOptions,MagickFalse,token);
2235  iterations=1L;
2236  GetNextToken(p,&p,MagickPathExtent,token);
2237  if ((*p == ':') || (*p == ','))
2238  GetNextToken(p,&p,MagickPathExtent,token);
2239  if ((*p != '\0'))
2240  iterations=(ssize_t) StringToLong(p);
2241  kernel=AcquireKernelInfo(argv[i+2],exception);
2242  if (kernel == (KernelInfo *) NULL)
2243  {
2244  (void) ThrowMagickException(exception,GetMagickModule(),
2245  OptionError,"UnabletoParseKernel","morphology");
2246  status=MagickFalse;
2247  break;
2248  }
2249  mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2250  exception);
2251  kernel=DestroyKernelInfo(kernel);
2252  break;
2253  }
2254  if (LocaleCompare("motion-blur",option+1) == 0)
2255  {
2256  /*
2257  Motion blur image.
2258  */
2259  (void) SyncImageSettings(mogrify_info,*image,exception);
2260  flags=ParseGeometry(argv[i+1],&geometry_info);
2261  if ((flags & SigmaValue) == 0)
2262  geometry_info.sigma=1.0;
2263  mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2264  geometry_info.sigma,geometry_info.xi,exception);
2265  break;
2266  }
2267  break;
2268  }
2269  case 'n':
2270  {
2271  if (LocaleCompare("negate",option+1) == 0)
2272  {
2273  (void) SyncImageSettings(mogrify_info,*image,exception);
2274  (void) NegateImage(*image,*option == '+' ? MagickTrue :
2275  MagickFalse,exception);
2276  break;
2277  }
2278  if (LocaleCompare("noise",option+1) == 0)
2279  {
2280  (void) SyncImageSettings(mogrify_info,*image,exception);
2281  if (*option == '-')
2282  {
2283  flags=ParseGeometry(argv[i+1],&geometry_info);
2284  if ((flags & SigmaValue) == 0)
2285  geometry_info.sigma=geometry_info.rho;
2286  mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2287  geometry_info.rho,(size_t) geometry_info.sigma,exception);
2288  }
2289  else
2290  {
2291  NoiseType
2292  noise;
2293 
2294  noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2295  MagickFalse,argv[i+1]);
2296  mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2297  }
2298  break;
2299  }
2300  if (LocaleCompare("normalize",option+1) == 0)
2301  {
2302  (void) SyncImageSettings(mogrify_info,*image,exception);
2303  (void) NormalizeImage(*image,exception);
2304  break;
2305  }
2306  break;
2307  }
2308  case 'o':
2309  {
2310  if (LocaleCompare("opaque",option+1) == 0)
2311  {
2312  PixelInfo
2313  target;
2314 
2315  (void) SyncImageSettings(mogrify_info,*image,exception);
2316  (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2317  exception);
2318  (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2319  MagickFalse : MagickTrue,exception);
2320  break;
2321  }
2322  if (LocaleCompare("ordered-dither",option+1) == 0)
2323  {
2324  (void) SyncImageSettings(mogrify_info,*image,exception);
2325  (void) OrderedDitherImage(*image,argv[i+1],exception);
2326  break;
2327  }
2328  break;
2329  }
2330  case 'p':
2331  {
2332  if (LocaleCompare("paint",option+1) == 0)
2333  {
2334  (void) SyncImageSettings(mogrify_info,*image,exception);
2335  (void) ParseGeometry(argv[i+1],&geometry_info);
2336  mogrify_image=OilPaintImage(*image,geometry_info.rho,
2337  geometry_info.sigma,exception);
2338  break;
2339  }
2340  if (LocaleCompare("perceptible",option+1) == 0)
2341  {
2342  /*
2343  Perceptible image.
2344  */
2345  (void) SyncImageSettings(mogrify_info,*image,exception);
2346  (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2347  (char **) NULL),exception);
2348  break;
2349  }
2350  if (LocaleCompare("pointsize",option+1) == 0)
2351  {
2352  if (*option == '+')
2353  (void) ParseGeometry("12",&geometry_info);
2354  else
2355  (void) ParseGeometry(argv[i+1],&geometry_info);
2356  draw_info->pointsize=geometry_info.rho;
2357  break;
2358  }
2359  if (LocaleCompare("polaroid",option+1) == 0)
2360  {
2361  const char
2362  *caption;
2363 
2364  double
2365  angle;
2366 
2367  RandomInfo
2368  *random_info;
2369 
2370  /*
2371  Simulate a Polaroid picture.
2372  */
2373  (void) SyncImageSettings(mogrify_info,*image,exception);
2374  random_info=AcquireRandomInfo();
2375  angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2376  random_info=DestroyRandomInfo(random_info);
2377  if (*option == '-')
2378  {
2379  SetGeometryInfo(&geometry_info);
2380  flags=ParseGeometry(argv[i+1],&geometry_info);
2381  angle=geometry_info.rho;
2382  }
2383  caption=GetImageProperty(*image,"caption",exception);
2384  mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2385  interpolate_method,exception);
2386  break;
2387  }
2388  if (LocaleCompare("posterize",option+1) == 0)
2389  {
2390  /*
2391  Posterize image.
2392  */
2393  (void) SyncImageSettings(mogrify_info,*image,exception);
2394  (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2395  quantize_info->dither_method,exception);
2396  break;
2397  }
2398  if (LocaleCompare("preview",option+1) == 0)
2399  {
2400  PreviewType
2401  preview_type;
2402 
2403  /*
2404  Preview image.
2405  */
2406  (void) SyncImageSettings(mogrify_info,*image,exception);
2407  if (*option == '+')
2408  preview_type=UndefinedPreview;
2409  else
2410  preview_type=(PreviewType) ParseCommandOption(
2411  MagickPreviewOptions,MagickFalse,argv[i+1]);
2412  mogrify_image=PreviewImage(*image,preview_type,exception);
2413  break;
2414  }
2415  if (LocaleCompare("profile",option+1) == 0)
2416  {
2417  const char
2418  *name;
2419 
2420  const StringInfo
2421  *profile;
2422 
2423  Image
2424  *profile_image;
2425 
2426  ImageInfo
2427  *profile_info;
2428 
2429  (void) SyncImageSettings(mogrify_info,*image,exception);
2430  if (*option == '+')
2431  {
2432  /*
2433  Remove a profile from the image.
2434  */
2435  (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2436  NULL,0,exception);
2437  break;
2438  }
2439  /*
2440  Associate a profile with the image.
2441  */
2442  profile_info=CloneImageInfo(mogrify_info);
2443  profile=GetImageProfile(*image,"iptc");
2444  if (profile != (StringInfo *) NULL)
2445  profile_info->profile=(void *) CloneStringInfo(profile);
2446  profile_image=GetImageCache(profile_info,argv[i+1],exception);
2447  profile_info=DestroyImageInfo(profile_info);
2448  if (profile_image == (Image *) NULL)
2449  {
2450  StringInfo
2451  *file_data;
2452 
2453  profile_info=CloneImageInfo(mogrify_info);
2454  (void) CopyMagickString(profile_info->filename,argv[i+1],
2456  file_data=FileToStringInfo(profile_info->filename,~0UL,
2457  exception);
2458  if (file_data != (StringInfo *) NULL)
2459  {
2460  (void) ProfileImage(*image,profile_info->magick,
2461  GetStringInfoDatum(file_data),
2462  GetStringInfoLength(file_data),exception);
2463  file_data=DestroyStringInfo(file_data);
2464  }
2465  profile_info=DestroyImageInfo(profile_info);
2466  break;
2467  }
2468  ResetImageProfileIterator(profile_image);
2469  name=GetNextImageProfile(profile_image);
2470  while (name != (const char *) NULL)
2471  {
2472  profile=GetImageProfile(profile_image,name);
2473  if (profile != (StringInfo *) NULL)
2474  (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2475  (size_t) GetStringInfoLength(profile),exception);
2476  name=GetNextImageProfile(profile_image);
2477  }
2478  profile_image=DestroyImage(profile_image);
2479  break;
2480  }
2481  break;
2482  }
2483  case 'q':
2484  {
2485  if (LocaleCompare("quantize",option+1) == 0)
2486  {
2487  if (*option == '+')
2488  {
2489  quantize_info->colorspace=UndefinedColorspace;
2490  break;
2491  }
2492  quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2493  MagickColorspaceOptions,MagickFalse,argv[i+1]);
2494  break;
2495  }
2496  break;
2497  }
2498  case 'r':
2499  {
2500  if (LocaleCompare("rotational-blur",option+1) == 0)
2501  {
2502  /*
2503  Rotational blur image.
2504  */
2505  (void) SyncImageSettings(mogrify_info,*image,exception);
2506  flags=ParseGeometry(argv[i+1],&geometry_info);
2507  mogrify_image=RotationalBlurImage(*image,geometry_info.rho,
2508  exception);
2509  break;
2510  }
2511  if (LocaleCompare("raise",option+1) == 0)
2512  {
2513  /*
2514  Surround image with a raise of solid color.
2515  */
2516  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2517  (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2518  MagickFalse,exception);
2519  break;
2520  }
2521  if (LocaleCompare("random-threshold",option+1) == 0)
2522  {
2523  /*
2524  Threshold image.
2525  */
2526  double
2527  min_threshold,
2528  max_threshold;
2529 
2530  (void) SyncImageSettings(mogrify_info,*image,exception);
2531  min_threshold=0.0;
2532  max_threshold=(double) QuantumRange;
2533  flags=ParseGeometry(argv[i+1],&geometry_info);
2534  min_threshold=geometry_info.rho;
2535  max_threshold=geometry_info.sigma;
2536  if ((flags & SigmaValue) == 0)
2537  max_threshold=min_threshold;
2538  if (strchr(argv[i+1],'%') != (char *) NULL)
2539  {
2540  max_threshold*=(double) (0.01*QuantumRange);
2541  min_threshold*=(double) (0.01*QuantumRange);
2542  }
2543  (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2544  exception);
2545  break;
2546  }
2547  if (LocaleCompare("read-mask",option+1) == 0)
2548  {
2549  Image
2550  *mask;
2551 
2552  (void) SyncImageSettings(mogrify_info,*image,exception);
2553  if (*option == '+')
2554  {
2555  /*
2556  Remove a mask.
2557  */
2558  (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
2559  exception);
2560  break;
2561  }
2562  /*
2563  Set the image mask.
2564  */
2565  mask=GetImageCache(mogrify_info,argv[i+1],exception);
2566  if (mask == (Image *) NULL)
2567  break;
2568  (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2569  mask=DestroyImage(mask);
2570  break;
2571  }
2572  if (LocaleCompare("region",option+1) == 0)
2573  {
2574  /*
2575  Apply read mask as defined by a region geometry.
2576  */
2577  (void) SyncImageSettings(mogrify_info,*image,exception);
2578  if (*option == '+')
2579  {
2580  (void) SetImageRegionMask(*image,WritePixelMask,
2581  (const RectangleInfo *) NULL,exception);
2582  break;
2583  }
2584  (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2585  (void) SetImageRegionMask(*image,WritePixelMask,&geometry,
2586  exception);
2587  break;
2588  }
2589  if (LocaleCompare("render",option+1) == 0)
2590  {
2591  (void) SyncImageSettings(mogrify_info,*image,exception);
2592  draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2593  break;
2594  }
2595  if (LocaleCompare("remap",option+1) == 0)
2596  {
2597  Image
2598  *remap_image;
2599 
2600  /*
2601  Transform image colors to match this set of colors.
2602  */
2603  (void) SyncImageSettings(mogrify_info,*image,exception);
2604  if (*option == '+')
2605  break;
2606  remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2607  if (remap_image == (Image *) NULL)
2608  break;
2609  (void) RemapImage(quantize_info,*image,remap_image,exception);
2610  remap_image=DestroyImage(remap_image);
2611  break;
2612  }
2613  if (LocaleCompare("repage",option+1) == 0)
2614  {
2615  if (*option == '+')
2616  {
2617  (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2618  break;
2619  }
2620  (void) ResetImagePage(*image,argv[i+1]);
2621  break;
2622  }
2623  if (LocaleCompare("resample",option+1) == 0)
2624  {
2625  /*
2626  Resample image.
2627  */
2628  (void) SyncImageSettings(mogrify_info,*image,exception);
2629  flags=ParseGeometry(argv[i+1],&geometry_info);
2630  if ((flags & SigmaValue) == 0)
2631  geometry_info.sigma=geometry_info.rho;
2632  mogrify_image=ResampleImage(*image,geometry_info.rho,
2633  geometry_info.sigma,(*image)->filter,exception);
2634  break;
2635  }
2636  if (LocaleCompare("resize",option+1) == 0)
2637  {
2638  /*
2639  Resize image.
2640  */
2641  (void) SyncImageSettings(mogrify_info,*image,exception);
2642  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2643  mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2644  (*image)->filter,exception);
2645  break;
2646  }
2647  if (LocaleCompare("roll",option+1) == 0)
2648  {
2649  /*
2650  Roll image.
2651  */
2652  (void) SyncImageSettings(mogrify_info,*image,exception);
2653  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2654  if ((flags & PercentValue) != 0)
2655  {
2656  geometry.x*=(double) (*image)->columns/100.0;
2657  geometry.y*=(double) (*image)->rows/100.0;
2658  }
2659  mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2660  break;
2661  }
2662  if (LocaleCompare("rotate",option+1) == 0)
2663  {
2664  char
2665  *rotation;
2666 
2667  /*
2668  Check for conditional image rotation.
2669  */
2670  (void) SyncImageSettings(mogrify_info,*image,exception);
2671  if (strchr(argv[i+1],'>') != (char *) NULL)
2672  if ((*image)->columns <= (*image)->rows)
2673  break;
2674  if (strchr(argv[i+1],'<') != (char *) NULL)
2675  if ((*image)->columns >= (*image)->rows)
2676  break;
2677  /*
2678  Rotate image.
2679  */
2680  rotation=ConstantString(argv[i+1]);
2681  (void) SubstituteString(&rotation,">","");
2682  (void) SubstituteString(&rotation,"<","");
2683  (void) ParseGeometry(rotation,&geometry_info);
2684  rotation=DestroyString(rotation);
2685  mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2686  break;
2687  }
2688  break;
2689  }
2690  case 's':
2691  {
2692  if (LocaleCompare("sample",option+1) == 0)
2693  {
2694  /*
2695  Sample image with pixel replication.
2696  */
2697  (void) SyncImageSettings(mogrify_info,*image,exception);
2698  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2699  mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2700  exception);
2701  break;
2702  }
2703  if (LocaleCompare("scale",option+1) == 0)
2704  {
2705  /*
2706  Resize image.
2707  */
2708  (void) SyncImageSettings(mogrify_info,*image,exception);
2709  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2710  mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2711  exception);
2712  break;
2713  }
2714  if (LocaleCompare("selective-blur",option+1) == 0)
2715  {
2716  /*
2717  Selectively blur pixels within a contrast threshold.
2718  */
2719  (void) SyncImageSettings(mogrify_info,*image,exception);
2720  flags=ParseGeometry(argv[i+1],&geometry_info);
2721  if ((flags & PercentValue) != 0)
2722  geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2723  mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2724  geometry_info.sigma,geometry_info.xi,exception);
2725  break;
2726  }
2727  if (LocaleCompare("separate",option+1) == 0)
2728  {
2729  /*
2730  Break channels into separate images.
2731  */
2732  (void) SyncImageSettings(mogrify_info,*image,exception);
2733  mogrify_image=SeparateImages(*image,exception);
2734  break;
2735  }
2736  if (LocaleCompare("sepia-tone",option+1) == 0)
2737  {
2738  double
2739  threshold;
2740 
2741  /*
2742  Sepia-tone image.
2743  */
2744  (void) SyncImageSettings(mogrify_info,*image,exception);
2745  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2746  1.0);
2747  mogrify_image=SepiaToneImage(*image,threshold,exception);
2748  break;
2749  }
2750  if (LocaleCompare("segment",option+1) == 0)
2751  {
2752  /*
2753  Segment image.
2754  */
2755  (void) SyncImageSettings(mogrify_info,*image,exception);
2756  flags=ParseGeometry(argv[i+1],&geometry_info);
2757  if ((flags & SigmaValue) == 0)
2758  geometry_info.sigma=1.0;
2759  (void) SegmentImage(*image,(*image)->colorspace,
2760  mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2761  exception);
2762  break;
2763  }
2764  if (LocaleCompare("set",option+1) == 0)
2765  {
2766  char
2767  *value;
2768 
2769  /*
2770  Set image option.
2771  */
2772  if (*option == '+')
2773  {
2774  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2775  (void) DeleteImageRegistry(argv[i+1]+9);
2776  else
2777  if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2778  {
2779  (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2780  (void) DeleteImageArtifact(*image,argv[i+1]+7);
2781  }
2782  else
2783  (void) DeleteImageProperty(*image,argv[i+1]);
2784  break;
2785  }
2786  value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2787  exception);
2788  if (value == (char *) NULL)
2789  break;
2790  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2791  (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2792  exception);
2793  else
2794  if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2795  {
2796  (void) SetImageOption(image_info,argv[i+1]+7,value);
2797  (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2798  (void) SetImageArtifact(*image,argv[i+1]+7,value);
2799  }
2800  else
2801  (void) SetImageProperty(*image,argv[i+1],value,exception);
2802  value=DestroyString(value);
2803  break;
2804  }
2805  if (LocaleCompare("shade",option+1) == 0)
2806  {
2807  /*
2808  Shade image.
2809  */
2810  (void) SyncImageSettings(mogrify_info,*image,exception);
2811  flags=ParseGeometry(argv[i+1],&geometry_info);
2812  if ((flags & SigmaValue) == 0)
2813  geometry_info.sigma=1.0;
2814  mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2815  MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2816  break;
2817  }
2818  if (LocaleCompare("shadow",option+1) == 0)
2819  {
2820  /*
2821  Shadow image.
2822  */
2823  (void) SyncImageSettings(mogrify_info,*image,exception);
2824  flags=ParseGeometry(argv[i+1],&geometry_info);
2825  if ((flags & SigmaValue) == 0)
2826  geometry_info.sigma=1.0;
2827  if ((flags & XiValue) == 0)
2828  geometry_info.xi=4.0;
2829  if ((flags & PsiValue) == 0)
2830  geometry_info.psi=4.0;
2831  mogrify_image=ShadowImage(*image,geometry_info.rho,
2832  geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2833  (ssize_t) ceil(geometry_info.psi-0.5),exception);
2834  break;
2835  }
2836  if (LocaleCompare("sharpen",option+1) == 0)
2837  {
2838  /*
2839  Sharpen image.
2840  */
2841  (void) SyncImageSettings(mogrify_info,*image,exception);
2842  flags=ParseGeometry(argv[i+1],&geometry_info);
2843  if ((flags & SigmaValue) == 0)
2844  geometry_info.sigma=1.0;
2845  if ((flags & XiValue) == 0)
2846  geometry_info.xi=0.0;
2847  mogrify_image=SharpenImage(*image,geometry_info.rho,
2848  geometry_info.sigma,exception);
2849  break;
2850  }
2851  if (LocaleCompare("shave",option+1) == 0)
2852  {
2853  /*
2854  Shave the image edges.
2855  */
2856  (void) SyncImageSettings(mogrify_info,*image,exception);
2857  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2858  mogrify_image=ShaveImage(*image,&geometry,exception);
2859  break;
2860  }
2861  if (LocaleCompare("shear",option+1) == 0)
2862  {
2863  /*
2864  Shear image.
2865  */
2866  (void) SyncImageSettings(mogrify_info,*image,exception);
2867  flags=ParseGeometry(argv[i+1],&geometry_info);
2868  if ((flags & SigmaValue) == 0)
2869  geometry_info.sigma=geometry_info.rho;
2870  mogrify_image=ShearImage(*image,geometry_info.rho,
2871  geometry_info.sigma,exception);
2872  break;
2873  }
2874  if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2875  {
2876  /*
2877  Sigmoidal non-linearity contrast control.
2878  */
2879  (void) SyncImageSettings(mogrify_info,*image,exception);
2880  flags=ParseGeometry(argv[i+1],&geometry_info);
2881  if ((flags & SigmaValue) == 0)
2882  geometry_info.sigma=(double) QuantumRange/2.0;
2883  if ((flags & PercentValue) != 0)
2884  geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2885  100.0;
2886  (void) SigmoidalContrastImage(*image,(*option == '-') ?
2887  MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2888  exception);
2889  break;
2890  }
2891  if (LocaleCompare("sketch",option+1) == 0)
2892  {
2893  /*
2894  Sketch image.
2895  */
2896  (void) SyncImageSettings(mogrify_info,*image,exception);
2897  flags=ParseGeometry(argv[i+1],&geometry_info);
2898  if ((flags & SigmaValue) == 0)
2899  geometry_info.sigma=1.0;
2900  mogrify_image=SketchImage(*image,geometry_info.rho,
2901  geometry_info.sigma,geometry_info.xi,exception);
2902  break;
2903  }
2904  if (LocaleCompare("solarize",option+1) == 0)
2905  {
2906  double
2907  threshold;
2908 
2909  (void) SyncImageSettings(mogrify_info,*image,exception);
2910  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2911  1.0);
2912  (void) SolarizeImage(*image,threshold,exception);
2913  break;
2914  }
2915  if (LocaleCompare("sparse-color",option+1) == 0)
2916  {
2917  SparseColorMethod
2918  method;
2919 
2920  char
2921  *arguments;
2922 
2923  /*
2924  Sparse Color Interpolated Gradient
2925  */
2926  (void) SyncImageSettings(mogrify_info,*image,exception);
2927  method=(SparseColorMethod) ParseCommandOption(
2928  MagickSparseColorOptions,MagickFalse,argv[i+1]);
2929  arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2930  exception);
2931  if (arguments == (char *) NULL)
2932  break;
2933  mogrify_image=SparseColorOption(*image,method,arguments,
2934  option[0] == '+' ? MagickTrue : MagickFalse,exception);
2935  arguments=DestroyString(arguments);
2936  break;
2937  }
2938  if (LocaleCompare("splice",option+1) == 0)
2939  {
2940  /*
2941  Splice a solid color into the image.
2942  */
2943  (void) SyncImageSettings(mogrify_info,*image,exception);
2944  (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2945  mogrify_image=SpliceImage(*image,&geometry,exception);
2946  break;
2947  }
2948  if (LocaleCompare("spread",option+1) == 0)
2949  {
2950  /*
2951  Spread an image.
2952  */
2953  (void) SyncImageSettings(mogrify_info,*image,exception);
2954  (void) ParseGeometry(argv[i+1],&geometry_info);
2955  mogrify_image=SpreadImage(*image,interpolate_method,
2956  geometry_info.rho,exception);
2957  break;
2958  }
2959  if (LocaleCompare("statistic",option+1) == 0)
2960  {
2961  StatisticType
2962  type;
2963 
2964  (void) SyncImageSettings(mogrify_info,*image,exception);
2965  type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2966  MagickFalse,argv[i+1]);
2967  (void) ParseGeometry(argv[i+2],&geometry_info);
2968  mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2969  (size_t) geometry_info.sigma,exception);
2970  break;
2971  }
2972  if (LocaleCompare("stretch",option+1) == 0)
2973  {
2974  if (*option == '+')
2975  {
2976  draw_info->stretch=UndefinedStretch;
2977  break;
2978  }
2979  draw_info->stretch=(StretchType) ParseCommandOption(
2980  MagickStretchOptions,MagickFalse,argv[i+1]);
2981  break;
2982  }
2983  if (LocaleCompare("strip",option+1) == 0)
2984  {
2985  /*
2986  Strip image of profiles and comments.
2987  */
2988  (void) SyncImageSettings(mogrify_info,*image,exception);
2989  (void) StripImage(*image,exception);
2990  break;
2991  }
2992  if (LocaleCompare("stroke",option+1) == 0)
2993  {
2994  ExceptionInfo
2995  *sans;
2996 
2997  PixelInfo
2998  color;
2999 
3000  if (*option == '+')
3001  {
3002  (void) QueryColorCompliance("none",AllCompliance,
3003  &draw_info->stroke,exception);
3004  if (draw_info->stroke_pattern != (Image *) NULL)
3005  draw_info->stroke_pattern=DestroyImage(
3006  draw_info->stroke_pattern);
3007  break;
3008  }
3009  sans=AcquireExceptionInfo();
3010  status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
3011  sans=DestroyExceptionInfo(sans);
3012  if (status == MagickFalse)
3013  draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3014  exception);
3015  else
3016  draw_info->stroke=color;
3017  break;
3018  }
3019  if (LocaleCompare("strokewidth",option+1) == 0)
3020  {
3021  draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
3022  break;
3023  }
3024  if (LocaleCompare("style",option+1) == 0)
3025  {
3026  if (*option == '+')
3027  {
3028  draw_info->style=UndefinedStyle;
3029  break;
3030  }
3031  draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3032  MagickFalse,argv[i+1]);
3033  break;
3034  }
3035  if (LocaleCompare("swirl",option+1) == 0)
3036  {
3037  /*
3038  Swirl image.
3039  */
3040  (void) SyncImageSettings(mogrify_info,*image,exception);
3041  (void) ParseGeometry(argv[i+1],&geometry_info);
3042  mogrify_image=SwirlImage(*image,geometry_info.rho,
3043  interpolate_method,exception);
3044  break;
3045  }
3046  break;
3047  }
3048  case 't':
3049  {
3050  if (LocaleCompare("threshold",option+1) == 0)
3051  {
3052  double
3053  threshold;
3054 
3055  /*
3056  Threshold image.
3057  */
3058  (void) SyncImageSettings(mogrify_info,*image,exception);
3059  if (*option == '+')
3060  threshold=(double) QuantumRange/2;
3061  else
3062  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3063  1.0);
3064  (void) BilevelImage(*image,threshold,exception);
3065  break;
3066  }
3067  if (LocaleCompare("thumbnail",option+1) == 0)
3068  {
3069  /*
3070  Thumbnail image.
3071  */
3072  (void) SyncImageSettings(mogrify_info,*image,exception);
3073  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3074  mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3075  exception);
3076  break;
3077  }
3078  if (LocaleCompare("tile",option+1) == 0)
3079  {
3080  if (*option == '+')
3081  {
3082  if (draw_info->fill_pattern != (Image *) NULL)
3083  draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3084  break;
3085  }
3086  draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3087  exception);
3088  break;
3089  }
3090  if (LocaleCompare("tint",option+1) == 0)
3091  {
3092  /*
3093  Tint the image.
3094  */
3095  (void) SyncImageSettings(mogrify_info,*image,exception);
3096  mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3097  break;
3098  }
3099  if (LocaleCompare("transform",option+1) == 0)
3100  {
3101  /*
3102  Affine transform image.
3103  */
3104  (void) SyncImageSettings(mogrify_info,*image,exception);
3105  mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3106  exception);
3107  break;
3108  }
3109  if (LocaleCompare("transparent",option+1) == 0)
3110  {
3111  PixelInfo
3112  target;
3113 
3114  (void) SyncImageSettings(mogrify_info,*image,exception);
3115  (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3116  exception);
3117  (void) TransparentPaintImage(*image,&target,(Quantum)
3118  TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3119  exception);
3120  break;
3121  }
3122  if (LocaleCompare("transpose",option+1) == 0)
3123  {
3124  /*
3125  Transpose image scanlines.
3126  */
3127  (void) SyncImageSettings(mogrify_info,*image,exception);
3128  mogrify_image=TransposeImage(*image,exception);
3129  break;
3130  }
3131  if (LocaleCompare("transverse",option+1) == 0)
3132  {
3133  /*
3134  Transverse image scanlines.
3135  */
3136  (void) SyncImageSettings(mogrify_info,*image,exception);
3137  mogrify_image=TransverseImage(*image,exception);
3138  break;
3139  }
3140  if (LocaleCompare("treedepth",option+1) == 0)
3141  {
3142  quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3143  break;
3144  }
3145  if (LocaleCompare("trim",option+1) == 0)
3146  {
3147  /*
3148  Trim image.
3149  */
3150  (void) SyncImageSettings(mogrify_info,*image,exception);
3151  mogrify_image=TrimImage(*image,exception);
3152  break;
3153  }
3154  if (LocaleCompare("type",option+1) == 0)
3155  {
3156  ImageType
3157  type;
3158 
3159  (void) SyncImageSettings(mogrify_info,*image,exception);
3160  if (*option == '+')
3161  type=UndefinedType;
3162  else
3163  type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3164  argv[i+1]);
3165  (*image)->type=UndefinedType;
3166  (void) SetImageType(*image,type,exception);
3167  break;
3168  }
3169  break;
3170  }
3171  case 'u':
3172  {
3173  if (LocaleCompare("undercolor",option+1) == 0)
3174  {
3175  (void) QueryColorCompliance(argv[i+1],AllCompliance,
3176  &draw_info->undercolor,exception);
3177  break;
3178  }
3179  if (LocaleCompare("unique",option+1) == 0)
3180  {
3181  if (*option == '+')
3182  {
3183  (void) DeleteImageArtifact(*image,"identify:unique-colors");
3184  break;
3185  }
3186  (void) SetImageArtifact(*image,"identify:unique-colors","true");
3187  (void) SetImageArtifact(*image,"verbose","true");
3188  break;
3189  }
3190  if (LocaleCompare("unique-colors",option+1) == 0)
3191  {
3192  /*
3193  Unique image colors.
3194  */
3195  (void) SyncImageSettings(mogrify_info,*image,exception);
3196  mogrify_image=UniqueImageColors(*image,exception);
3197  break;
3198  }
3199  if (LocaleCompare("unsharp",option+1) == 0)
3200  {
3201  /*
3202  Unsharp mask image.
3203  */
3204  (void) SyncImageSettings(mogrify_info,*image,exception);
3205  flags=ParseGeometry(argv[i+1],&geometry_info);
3206  if ((flags & SigmaValue) == 0)
3207  geometry_info.sigma=1.0;
3208  if ((flags & XiValue) == 0)
3209  geometry_info.xi=1.0;
3210  if ((flags & PsiValue) == 0)
3211  geometry_info.psi=0.05;
3212  mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3213  geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3214  exception);
3215  break;
3216  }
3217  break;
3218  }
3219  case 'v':
3220  {
3221  if (LocaleCompare("verbose",option+1) == 0)
3222  {
3223  (void) SetImageArtifact(*image,option+1,
3224  *option == '+' ? "false" : "true");
3225  break;
3226  }
3227  if (LocaleCompare("vignette",option+1) == 0)
3228  {
3229  /*
3230  Vignette image.
3231  */
3232  (void) SyncImageSettings(mogrify_info,*image,exception);
3233  flags=ParseGeometry(argv[i+1],&geometry_info);
3234  if ((flags & SigmaValue) == 0)
3235  geometry_info.sigma=1.0;
3236  if ((flags & XiValue) == 0)
3237  geometry_info.xi=0.1*(*image)->columns;
3238  if ((flags & PsiValue) == 0)
3239  geometry_info.psi=0.1*(*image)->rows;
3240  if ((flags & PercentValue) != 0)
3241  {
3242  geometry_info.xi*=(double) (*image)->columns/100.0;
3243  geometry_info.psi*=(double) (*image)->rows/100.0;
3244  }
3245  mogrify_image=VignetteImage(*image,geometry_info.rho,
3246  geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3247  (ssize_t) ceil(geometry_info.psi-0.5),exception);
3248  break;
3249  }
3250  if (LocaleCompare("virtual-pixel",option+1) == 0)
3251  {
3252  if (*option == '+')
3253  {
3254  (void) SetImageVirtualPixelMethod(*image,
3255  UndefinedVirtualPixelMethod,exception);
3256  break;
3257  }
3258  (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3259  ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3260  argv[i+1]),exception);
3261  break;
3262  }
3263  break;
3264  }
3265  case 'w':
3266  {
3267  if (LocaleCompare("wave",option+1) == 0)
3268  {
3269  /*
3270  Wave image.
3271  */
3272  (void) SyncImageSettings(mogrify_info,*image,exception);
3273  flags=ParseGeometry(argv[i+1],&geometry_info);
3274  if ((flags & SigmaValue) == 0)
3275  geometry_info.sigma=1.0;
3276  mogrify_image=WaveImage(*image,geometry_info.rho,
3277  geometry_info.sigma,interpolate_method,exception);
3278  break;
3279  }
3280  if (LocaleCompare("wavelet-denoise",option+1) == 0)
3281  {
3282  /*
3283  Wavelet denoise image.
3284  */
3285  (void) SyncImageSettings(mogrify_info,*image,exception);
3286  flags=ParseGeometry(argv[i+1],&geometry_info);
3287  if ((flags & PercentValue) != 0)
3288  {
3289  geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
3290  geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3291  }
3292  if ((flags & SigmaValue) == 0)
3293  geometry_info.sigma=0.0;
3294  mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3295  geometry_info.sigma,exception);
3296  break;
3297  }
3298  if (LocaleCompare("weight",option+1) == 0)
3299  {
3300  ssize_t
3301  weight;
3302 
3303  weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3304  argv[i+1]);
3305  if (weight == -1)
3306  weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3307  draw_info->weight=(size_t) weight;
3308  break;
3309  }
3310  if (LocaleCompare("white-threshold",option+1) == 0)
3311  {
3312  /*
3313  White threshold image.
3314  */
3315  (void) SyncImageSettings(mogrify_info,*image,exception);
3316  (void) WhiteThresholdImage(*image,argv[i+1],exception);
3317  break;
3318  }
3319  if (LocaleCompare("write-mask",option+1) == 0)
3320  {
3321  Image
3322  *mask;
3323 
3324  (void) SyncImageSettings(mogrify_info,*image,exception);
3325  if (*option == '+')
3326  {
3327  /*
3328  Remove a mask.
3329  */
3330  (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
3331  exception);
3332  break;
3333  }
3334  /*
3335  Set the image mask.
3336  */
3337  mask=GetImageCache(mogrify_info,argv[i+1],exception);
3338  if (mask == (Image *) NULL)
3339  break;
3340  (void) SetImageMask(*image,WritePixelMask,mask,exception);
3341  mask=DestroyImage(mask);
3342  break;
3343  }
3344  break;
3345  }
3346  default:
3347  break;
3348  }
3349  /*
3350  Replace current image with any image that was generated
3351  */
3352  if (mogrify_image != (Image *) NULL)
3353  ReplaceImageInListReturnLast(image,mogrify_image);
3354  i+=count;
3355  }
3356  /*
3357  Free resources.
3358  */
3359  quantize_info=DestroyQuantizeInfo(quantize_info);
3360  draw_info=DestroyDrawInfo(draw_info);
3361  mogrify_info=DestroyImageInfo(mogrify_info);
3362  status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3363  return(status == 0 ? MagickFalse : MagickTrue);
3364 }
3365 
3366 /*
3367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3368 % %
3369 % %
3370 % %
3371 + M o g r i f y I m a g e C o m m a n d %
3372 % %
3373 % %
3374 % %
3375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3376 %
3377 % MogrifyImageCommand() transforms an image or a sequence of images. These
3378 % transforms include image scaling, image rotation, color reduction, and
3379 % others. The transmogrified image overwrites the original image.
3380 %
3381 % The format of the MogrifyImageCommand method is:
3382 %
3383 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3384 % const char **argv,char **metadata,ExceptionInfo *exception)
3385 %
3386 % A description of each parameter follows:
3387 %
3388 % o image_info: the image info.
3389 %
3390 % o argc: the number of elements in the argument vector.
3391 %
3392 % o argv: A text array containing the command line arguments.
3393 %
3394 % o metadata: any metadata is returned here.
3395 %
3396 % o exception: return any errors or warnings in this structure.
3397 %
3398 */
3399 
3400 static MagickBooleanType MogrifyUsage(void)
3401 {
3402  static const char
3403  *channel_operators[]=
3404  {
3405  "-channel-fx expression",
3406  " exchange, extract, or transfer one or more image channels",
3407  "-separate separate an image channel into a grayscale image",
3408  (char *) NULL
3409  },
3410  *miscellaneous[]=
3411  {
3412  "-debug events display copious debugging information",
3413  "-distribute-cache port",
3414  " distributed pixel cache spanning one or more servers",
3415  "-help print program options",
3416  "-list type print a list of supported option arguments",
3417  "-log format format of debugging information",
3418  "-version print version information",
3419  (char *) NULL
3420  },
3421  *operators[]=
3422  {
3423  "-adaptive-blur geometry",
3424  " adaptively blur pixels; decrease effect near edges",
3425  "-adaptive-resize geometry",
3426  " adaptively resize image using 'mesh' interpolation",
3427  "-adaptive-sharpen geometry",
3428  " adaptively sharpen pixels; increase effect near edges",
3429  "-alpha option on, activate, off, deactivate, set, opaque, copy",
3430  " transparent, extract, background, or shape",
3431  "-annotate geometry text",
3432  " annotate the image with text",
3433  "-auto-gamma automagically adjust gamma level of image",
3434  "-auto-level automagically adjust color levels of image",
3435  "-auto-orient automagically orient (rotate) image",
3436  "-auto-threshold method",
3437  " automatically perform image thresholding",
3438  "-bench iterations measure performance",
3439  "-black-threshold value",
3440  " force all pixels below the threshold into black",
3441  "-blue-shift simulate a scene at nighttime in the moonlight",
3442  "-blur geometry reduce image noise and reduce detail levels",
3443  "-border geometry surround image with a border of color",
3444  "-bordercolor color border color",
3445  "-brightness-contrast geometry",
3446  " improve brightness / contrast of the image",
3447  "-canny geometry detect edges in the image",
3448  "-cdl filename color correct with a color decision list",
3449  "-channel mask set the image channel mask",
3450  "-charcoal geometry simulate a charcoal drawing",
3451  "-chop geometry remove pixels from the image interior",
3452  "-clamp keep pixel values in range (0-QuantumRange)",
3453  "-clip clip along the first path from the 8BIM profile",
3454  "-clip-mask filename associate a clip mask with the image",
3455  "-clip-path id clip along a named path from the 8BIM profile",
3456  "-colorize value colorize the image with the fill color",
3457  "-color-matrix matrix apply color correction to the image",
3458  "-connected-components connectivity",
3459  " connected-components uniquely labeled",
3460  "-contrast enhance or reduce the image contrast",
3461  "-contrast-stretch geometry",
3462  " improve contrast by 'stretching' the intensity range",
3463  "-convolve coefficients",
3464  " apply a convolution kernel to the image",
3465  "-cycle amount cycle the image colormap",
3466  "-decipher filename convert cipher pixels to plain pixels",
3467  "-deskew threshold straighten an image",
3468  "-despeckle reduce the speckles within an image",
3469  "-distort method args",
3470  " distort images according to given method ad args",
3471  "-draw string annotate the image with a graphic primitive",
3472  "-edge radius apply a filter to detect edges in the image",
3473  "-encipher filename convert plain pixels to cipher pixels",
3474  "-emboss radius emboss an image",
3475  "-enhance apply a digital filter to enhance a noisy image",
3476  "-equalize perform histogram equalization to an image",
3477  "-evaluate operator value",
3478  " evaluate an arithmetic, relational, or logical expression",
3479  "-extent geometry set the image size",
3480  "-extract geometry extract area from image",
3481  "-fft implements the discrete Fourier transform (DFT)",
3482  "-flip flip image vertically",
3483  "-floodfill geometry color",
3484  " floodfill the image with color",
3485  "-flop flop image horizontally",
3486  "-frame geometry surround image with an ornamental border",
3487  "-function name parameters",
3488  " apply function over image values",
3489  "-gamma value level of gamma correction",
3490  "-gaussian-blur geometry",
3491  " reduce image noise and reduce detail levels",
3492  "-geometry geometry preferred size or location of the image",
3493  "-grayscale method convert image to grayscale",
3494  "-hough-lines geometry",
3495  " identify lines in the image",
3496  "-identify identify the format and characteristics of the image",
3497  "-ift implements the inverse discrete Fourier transform (DFT)",
3498  "-implode amount implode image pixels about the center",
3499  "-interpolative-resize geometry",
3500  " resize image using interpolation",
3501  "-kuwahara geometry edge preserving noise reduction filter",
3502  "-lat geometry local adaptive thresholding",
3503  "-level value adjust the level of image contrast",
3504  "-level-colors color,color",
3505  " level image with the given colors",
3506  "-linear-stretch geometry",
3507  " improve contrast by 'stretching with saturation'",
3508  "-liquid-rescale geometry",
3509  " rescale image with seam-carving",
3510  "-local-contrast geometry",
3511  " enhance local contrast",
3512  "-magnify double the size of the image with pixel art scaling",
3513  "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
3514  "-median geometry apply a median filter to the image",
3515  "-mode geometry make each pixel the 'predominant color' of the",
3516  " neighborhood",
3517  "-modulate value vary the brightness, saturation, and hue",
3518  "-monochrome transform image to black and white",
3519  "-morphology method kernel",
3520  " apply a morphology method to the image",
3521  "-motion-blur geometry",
3522  " simulate motion blur",
3523  "-negate replace every pixel with its complementary color ",
3524  "-noise geometry add or reduce noise in an image",
3525  "-normalize transform image to span the full range of colors",
3526  "-opaque color change this color to the fill color",
3527  "-ordered-dither NxN",
3528  " add a noise pattern to the image with specific",
3529  " amplitudes",
3530  "-paint radius simulate an oil painting",
3531  "-perceptible epsilon",
3532  " pixel value less than |epsilon| become epsilon or",
3533  " -epsilon",
3534  "-polaroid angle simulate a Polaroid picture",
3535  "-posterize levels reduce the image to a limited number of color levels",
3536  "-profile filename add, delete, or apply an image profile",
3537  "-quantize colorspace reduce colors in this colorspace",
3538  "-raise value lighten/darken image edges to create a 3-D effect",
3539  "-random-threshold low,high",
3540  " random threshold the image",
3541  "-region geometry apply options to a portion of the image",
3542  "-render render vector graphics",
3543  "-repage geometry size and location of an image canvas",
3544  "-resample geometry change the resolution of an image",
3545  "-resize geometry resize the image",
3546  "-roll geometry roll an image vertically or horizontally",
3547  "-rotate degrees apply Paeth rotation to the image",
3548  "-rotational-blur angle",
3549  " rotational blur the image",
3550  "-sample geometry scale image with pixel sampling",
3551  "-scale geometry scale the image",
3552  "-segment values segment an image",
3553  "-selective-blur geometry",
3554  " selectively blur pixels within a contrast threshold",
3555  "-sepia-tone threshold",
3556  " simulate a sepia-toned photo",
3557  "-set property value set an image property",
3558  "-shade degrees shade the image using a distant light source",
3559  "-shadow geometry simulate an image shadow",
3560  "-sharpen geometry sharpen the image",
3561  "-shave geometry shave pixels from the image edges",
3562  "-shear geometry slide one edge of the image along the X or Y axis",
3563  "-sigmoidal-contrast geometry",
3564  " increase the contrast without saturating highlights or",
3565  " shadows",
3566  "-sketch geometry simulate a pencil sketch",
3567  "-solarize threshold negate all pixels above the threshold level",
3568  "-sparse-color method args",
3569  " fill in a image based on a few color points",
3570  "-splice geometry splice the background color into the image",
3571  "-spread radius displace image pixels by a random amount",
3572  "-statistic type radius",
3573  " replace each pixel with corresponding statistic from the neighborhood",
3574  "-strip strip image of all profiles and comments",
3575  "-swirl degrees swirl image pixels about the center",
3576  "-threshold value threshold the image",
3577  "-thumbnail geometry create a thumbnail of the image",
3578  "-tile filename tile image when filling a graphic primitive",
3579  "-tint value tint the image with the fill color",
3580  "-transform affine transform image",
3581  "-transparent color make this color transparent within the image",
3582  "-transpose flip image vertically and rotate 90 degrees",
3583  "-transverse flop image horizontally and rotate 270 degrees",
3584  "-trim trim image edges",
3585  "-type type image type",
3586  "-unique-colors discard all but one of any pixel color",
3587  "-unsharp geometry sharpen the image",
3588  "-vignette geometry soften the edges of the image in vignette style",
3589  "-wave geometry alter an image along a sine wave",
3590  "-wavelet-denoise threshold",
3591  " removes noise from the image using a wavelet transform",
3592  "-white-threshold value",
3593  " force all pixels above the threshold into white",
3594  (char *) NULL
3595  },
3596  *sequence_operators[]=
3597  {
3598  "-affinity filename transform image colors to match this set of colors",
3599  "-append append an image sequence",
3600  "-clut apply a color lookup table to the image",
3601  "-coalesce merge a sequence of images",
3602  "-combine combine a sequence of images",
3603  "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3604  "-complex operator perform complex mathematics on an image sequence",
3605  "-composite composite image",
3606  "-copy geometry offset",
3607  " copy pixels from one area of an image to another",
3608  "-crop geometry cut out a rectangular region of the image",
3609  "-deconstruct break down an image sequence into constituent parts",
3610  "-evaluate-sequence operator",
3611  " evaluate an arithmetic, relational, or logical expression",
3612  "-flatten flatten a sequence of images",
3613  "-fx expression apply mathematical expression to an image channel(s)",
3614  "-hald-clut apply a Hald color lookup table to the image",
3615  "-layers method optimize, merge, or compare image layers",
3616  "-morph value morph an image sequence",
3617  "-mosaic create a mosaic from an image sequence",
3618  "-poly terms build a polynomial from the image sequence and the corresponding",
3619  " terms (coefficients and degree pairs).",
3620  "-print string interpret string and print to console",
3621  "-process arguments process the image with a custom image filter",
3622  "-smush geometry smush an image sequence together",
3623  "-write filename write images to this file",
3624  (char *) NULL
3625  },
3626  *settings[]=
3627  {
3628  "-adjoin join images into a single multi-image file",
3629  "-affine matrix affine transform matrix",
3630  "-alpha option activate, deactivate, reset, or set the alpha channel",
3631  "-antialias remove pixel-aliasing",
3632  "-authenticate password",
3633  " decipher image with this password",
3634  "-attenuate value lessen (or intensify) when adding noise to an image",
3635  "-background color background color",
3636  "-bias value add bias when convolving an image",
3637  "-black-point-compensation",
3638  " use black point compensation",
3639  "-blue-primary point chromaticity blue primary point",
3640  "-bordercolor color border color",
3641  "-caption string assign a caption to an image",
3642  "-colors value preferred number of colors in the image",
3643  "-colorspace type alternate image colorspace",
3644  "-comment string annotate image with comment",
3645  "-compose operator set image composite operator",
3646  "-compress type type of pixel compression when writing the image",
3647  "-define format:option=value",
3648  " define one or more image format options",
3649  "-delay value display the next image after pausing",
3650  "-density geometry horizontal and vertical density of the image",
3651  "-depth value image depth",
3652  "-direction type render text right-to-left or left-to-right",
3653  "-display server get image or font from this X server",
3654  "-dispose method layer disposal method",
3655  "-dither method apply error diffusion to image",
3656  "-encoding type text encoding type",
3657  "-endian type endianness (MSB or LSB) of the image",
3658  "-family name render text with this font family",
3659  "-features distance analyze image features (e.g. contrast, correlation)",
3660  "-fill color color to use when filling a graphic primitive",
3661  "-filter type use this filter when resizing an image",
3662  "-font name render text with this font",
3663  "-format \"string\" output formatted image characteristics",
3664  "-fuzz distance colors within this distance are considered equal",
3665  "-gravity type horizontal and vertical text placement",
3666  "-green-primary point chromaticity green primary point",
3667  "-intensity method method to generate an intensity value from a pixel",
3668  "-intent type type of rendering intent when managing the image color",
3669  "-interlace type type of image interlacing scheme",
3670  "-interline-spacing value",
3671  " set the space between two text lines",
3672  "-interpolate method pixel color interpolation method",
3673  "-interword-spacing value",
3674  " set the space between two words",
3675  "-kerning value set the space between two letters",
3676  "-label string assign a label to an image",
3677  "-limit type value pixel cache resource limit",
3678  "-loop iterations add Netscape loop extension to your GIF animation",
3679  "-matte store matte channel if the image has one",
3680  "-mattecolor color frame color",
3681  "-monitor monitor progress",
3682  "-orient type image orientation",
3683  "-page geometry size and location of an image canvas (setting)",
3684  "-path path write images to this path on disk",
3685  "-ping efficiently determine image attributes",
3686  "-pointsize value font point size",
3687  "-precision value maximum number of significant digits to print",
3688  "-preview type image preview type",
3689  "-quality value JPEG/MIFF/PNG compression level",
3690  "-quiet suppress all warning messages",
3691  "-read-mask filename associate a read mask with the image",
3692  "-red-primary point chromaticity red primary point",
3693  "-regard-warnings pay attention to warning messages",
3694  "-remap filename transform image colors to match this set of colors",
3695  "-respect-parentheses settings remain in effect until parenthesis boundary",
3696  "-sampling-factor geometry",
3697  " horizontal and vertical sampling factor",
3698  "-scene value image scene number",
3699  "-seed value seed a new sequence of pseudo-random numbers",
3700  "-size geometry width and height of image",
3701  "-stretch type render text with this font stretch",
3702  "-stroke color graphic primitive stroke color",
3703  "-strokewidth value graphic primitive stroke width",
3704  "-style type render text with this font style",
3705  "-synchronize synchronize image to storage device",
3706  "-taint declare the image as modified",
3707  "-texture filename name of texture to tile onto the image background",
3708  "-tile-offset geometry",
3709  " tile offset",
3710  "-treedepth value color tree depth",
3711  "-transparent-color color",
3712  " transparent color",
3713  "-undercolor color annotation bounding box color",
3714  "-units type the units of image resolution",
3715  "-verbose print detailed information about the image",
3716  "-view FlashPix viewing transforms",
3717  "-virtual-pixel method",
3718  " virtual pixel access method",
3719  "-weight type render text with this font weight",
3720  "-white-point point chromaticity white point",
3721  "-write-mask filename associate a write mask with the image",
3722  (char *) NULL
3723  },
3724  *stack_operators[]=
3725  {
3726  "-delete indexes delete the image from the image sequence",
3727  "-duplicate count,indexes",
3728  " duplicate an image one or more times",
3729  "-insert index insert last image into the image sequence",
3730  "-reverse reverse image sequence",
3731  "-swap indexes swap two images in the image sequence",
3732  (char *) NULL
3733  };
3734 
3735  const char
3736  **p;
3737 
3738  ListMagickVersion(stdout);
3739  (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3740  GetClientName());
3741  (void) printf("\nImage Settings:\n");
3742  for (p=settings; *p != (char *) NULL; p++)
3743  (void) printf(" %s\n",*p);
3744  (void) printf("\nImage Operators:\n");
3745  for (p=operators; *p != (char *) NULL; p++)
3746  (void) printf(" %s\n",*p);
3747  (void) printf("\nImage Channel Operators:\n");
3748  for (p=channel_operators; *p != (char *) NULL; p++)
3749  (void) printf(" %s\n",*p);
3750  (void) printf("\nImage Sequence Operators:\n");
3751  for (p=sequence_operators; *p != (char *) NULL; p++)
3752  (void) printf(" %s\n",*p);
3753  (void) printf("\nImage Stack Operators:\n");
3754  for (p=stack_operators; *p != (char *) NULL; p++)
3755  (void) printf(" %s\n",*p);
3756  (void) printf("\nMiscellaneous Options:\n");
3757  for (p=miscellaneous; *p != (char *) NULL; p++)
3758  (void) printf(" %s\n",*p);
3759  (void) printf(
3760  "\nBy default, the image format of 'file' is determined by its magic\n");
3761  (void) printf(
3762  "number. To specify a particular image format, precede the filename\n");
3763  (void) printf(
3764  "with an image format name and a colon (i.e. ps:image) or specify the\n");
3765  (void) printf(
3766  "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3767  (void) printf("'-' for standard input or output.\n");
3768  return(MagickFalse);
3769 }
3770 
3771 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3772  int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3773 {
3774 #define DestroyMogrify() \
3775 { \
3776  if (format != (char *) NULL) \
3777  format=DestroyString(format); \
3778  if (path != (char *) NULL) \
3779  path=DestroyString(path); \
3780  DestroyImageStack(); \
3781  for (i=0; i < (ssize_t) argc; i++) \
3782  argv[i]=DestroyString(argv[i]); \
3783  argv=(char **) RelinquishMagickMemory(argv); \
3784 }
3785 #define ThrowMogrifyException(asperity,tag,option) \
3786 { \
3787  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3788  option); \
3789  DestroyMogrify(); \
3790  return(MagickFalse); \
3791 }
3792 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3793 { \
3794  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3795  "InvalidArgument","'%s': %s",argument,option); \
3796  DestroyMogrify(); \
3797  return(MagickFalse); \
3798 }
3799 
3800  char
3801  *format,
3802  *option,
3803  *path;
3804 
3805  Image
3806  *image;
3807 
3808  ImageStack
3809  image_stack[MaxImageStackDepth+1];
3810 
3811  MagickBooleanType
3812  global_colormap;
3813 
3814  MagickBooleanType
3815  fire,
3816  pend,
3817  respect_parenthesis;
3818 
3819  MagickStatusType
3820  status;
3821 
3822  register ssize_t
3823  i;
3824 
3825  ssize_t
3826  j,
3827  k;
3828 
3829  wand_unreferenced(metadata);
3830 
3831  /*
3832  Set defaults.
3833  */
3834  assert(image_info != (ImageInfo *) NULL);
3835  assert(image_info->signature == MagickCoreSignature);
3836  if (image_info->debug != MagickFalse)
3837  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3838  assert(exception != (ExceptionInfo *) NULL);
3839  if (argc == 2)
3840  {
3841  option=argv[1];
3842  if ((LocaleCompare("version",option+1) == 0) ||
3843  (LocaleCompare("-version",option+1) == 0))
3844  {
3845  ListMagickVersion(stdout);
3846  return(MagickTrue);
3847  }
3848  }
3849  if (argc < 2)
3850  return(MogrifyUsage());
3851  format=(char *) NULL;
3852  path=(char *) NULL;
3853  global_colormap=MagickFalse;
3854  k=0;
3855  j=1;
3856  NewImageStack();
3857  option=(char *) NULL;
3858  pend=MagickFalse;
3859  respect_parenthesis=MagickFalse;
3860  status=MagickTrue;
3861  /*
3862  Parse command line.
3863  */
3864  ReadCommandlLine(argc,&argv);
3865  status=ExpandFilenames(&argc,&argv);
3866  if (status == MagickFalse)
3867  ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3868  GetExceptionMessage(errno));
3869  for (i=1; i < (ssize_t) argc; i++)
3870  {
3871  option=argv[i];
3872  if (LocaleCompare(option,"(") == 0)
3873  {
3874  FireImageStack(MagickFalse,MagickTrue,pend);
3875  if (k == MaxImageStackDepth)
3876  ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3877  option);
3878  PushImageStack();
3879  continue;
3880  }
3881  if (LocaleCompare(option,")") == 0)
3882  {
3883  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3884  if (k == 0)
3885  ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3886  PopImageStack();
3887  continue;
3888  }
3889  if (IsCommandOption(option) == MagickFalse)
3890  {
3891  char
3892  backup_filename[MagickPathExtent],
3893  *filename;
3894 
3895  Image
3896  *images;
3897 
3898  struct stat
3899  properties;
3900 
3901  /*
3902  Option is a file name: begin by reading image from specified file.
3903  */
3904  FireImageStack(MagickFalse,MagickFalse,pend);
3905  filename=argv[i];
3906  if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3907  filename=argv[++i];
3908  images=ReadImages(image_info,filename,exception);
3909  status&=(images != (Image *) NULL) &&
3910  (exception->severity < ErrorException);
3911  if (images == (Image *) NULL)
3912  continue;
3913  properties=(*GetBlobProperties(images));
3914  if (format != (char *) NULL)
3915  (void) CopyMagickString(images->filename,images->magick_filename,
3917  if (path != (char *) NULL)
3918  {
3919  GetPathComponent(option,TailPath,filename);
3920  (void) FormatLocaleString(images->filename,MagickPathExtent,
3921  "%s%c%s",path,*DirectorySeparator,filename);
3922  }
3923  if (format != (char *) NULL)
3924  AppendImageFormat(format,images->filename);
3925  AppendImageStack(images);
3926  FinalizeImageSettings(image_info,image,MagickFalse);
3927  if (global_colormap != MagickFalse)
3928  {
3929  QuantizeInfo
3930  *quantize_info;
3931 
3932  quantize_info=AcquireQuantizeInfo(image_info);
3933  (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3934  quantize_info=DestroyQuantizeInfo(quantize_info);
3935  }
3936  *backup_filename='\0';
3937  if ((LocaleCompare(image->filename,"-") != 0) &&
3938  (IsPathWritable(image->filename) != MagickFalse))
3939  {
3940  /*
3941  Rename image file as backup.
3942  */
3943  (void) CopyMagickString(backup_filename,image->filename,
3945  for (j=0; j < 6; j++)
3946  {
3947  (void) ConcatenateMagickString(backup_filename,"~",
3949  if (IsPathAccessible(backup_filename) == MagickFalse)
3950  break;
3951  }
3952  if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3953  (rename_utf8(image->filename,backup_filename) != 0))
3954  *backup_filename='\0';
3955  }
3956  /*
3957  Write transmogrified image to disk.
3958  */
3959  image_info->synchronize=MagickTrue;
3960  status&=WriteImages(image_info,image,image->filename,exception);
3961  if (status != MagickFalse)
3962  {
3963 #if defined(MAGICKCORE_HAVE_UTIME)
3964  {
3965  MagickBooleanType
3966  preserve_timestamp;
3967 
3968  preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3969  "preserve-timestamp"));
3970  if (preserve_timestamp != MagickFalse)
3971  {
3972  struct utimbuf
3973  timestamp;
3974 
3975  timestamp.actime=properties.st_atime;
3976  timestamp.modtime=properties.st_mtime;
3977  (void) utime(image->filename,&timestamp);
3978  }
3979  }
3980 #endif
3981  if (*backup_filename != '\0')
3982  (void) remove_utf8(backup_filename);
3983  }
3985  continue;
3986  }
3987  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3988  switch (*(option+1))
3989  {
3990  case 'a':
3991  {
3992  if (LocaleCompare("adaptive-blur",option+1) == 0)
3993  {
3994  i++;
3995  if (i == (ssize_t) argc)
3996  ThrowMogrifyException(OptionError,"MissingArgument",option);
3997  if (IsGeometry(argv[i]) == MagickFalse)
3998  ThrowMogrifyInvalidArgumentException(option,argv[i]);
3999  break;
4000  }
4001  if (LocaleCompare("adaptive-resize",option+1) == 0)
4002  {
4003  i++;
4004  if (i == (ssize_t) argc)
4005  ThrowMogrifyException(OptionError,"MissingArgument",option);
4006  if (IsGeometry(argv[i]) == MagickFalse)
4007  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4008  break;
4009  }
4010  if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4011  {
4012  i++;
4013  if (i == (ssize_t) argc)
4014  ThrowMogrifyException(OptionError,"MissingArgument",option);
4015  if (IsGeometry(argv[i]) == MagickFalse)
4016  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4017  break;
4018  }
4019  if (LocaleCompare("affine",option+1) == 0)
4020  {
4021  if (*option == '+')
4022  break;
4023  i++;
4024  if (i == (ssize_t) argc)
4025  ThrowMogrifyException(OptionError,"MissingArgument",option);
4026  break;
4027  }
4028  if (LocaleCompare("alpha",option+1) == 0)
4029  {
4030  ssize_t
4031  type;
4032 
4033  if (*option == '+')
4034  break;
4035  i++;
4036  if (i == (ssize_t) argc)
4037  ThrowMogrifyException(OptionError,"MissingArgument",option);
4038  type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4039  argv[i]);
4040  if (type < 0)
4041  ThrowMogrifyException(OptionError,
4042  "UnrecognizedAlphaChannelOption",argv[i]);
4043  break;
4044  }
4045  if (LocaleCompare("annotate",option+1) == 0)
4046  {
4047  if (*option == '+')
4048  break;
4049  i++;
4050  if (i == (ssize_t) argc)
4051  ThrowMogrifyException(OptionError,"MissingArgument",option);
4052  if (IsGeometry(argv[i]) == MagickFalse)
4053  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4054  if (i == (ssize_t) argc)
4055  ThrowMogrifyException(OptionError,"MissingArgument",option);
4056  i++;
4057  break;
4058  }
4059  if (LocaleCompare("antialias",option+1) == 0)
4060  break;
4061  if (LocaleCompare("append",option+1) == 0)
4062  break;
4063  if (LocaleCompare("attenuate",option+1) == 0)
4064  {
4065  if (*option == '+')
4066  break;
4067  i++;
4068  if (i == (ssize_t) argc)
4069  ThrowMogrifyException(OptionError,"MissingArgument",option);
4070  if (IsGeometry(argv[i]) == MagickFalse)
4071  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4072  break;
4073  }
4074  if (LocaleCompare("authenticate",option+1) == 0)
4075  {
4076  if (*option == '+')
4077  break;
4078  i++;
4079  if (i == (ssize_t) argc)
4080  ThrowMogrifyException(OptionError,"MissingArgument",option);
4081  break;
4082  }
4083  if (LocaleCompare("auto-gamma",option+1) == 0)
4084  break;
4085  if (LocaleCompare("auto-level",option+1) == 0)
4086  break;
4087  if (LocaleCompare("auto-orient",option+1) == 0)
4088  break;
4089  if (LocaleCompare("auto-threshold",option+1) == 0)
4090  {
4091  ssize_t
4092  method;
4093 
4094  if (*option == '+')
4095  break;
4096  i++;
4097  if (i == (ssize_t) argc)
4098  ThrowMogrifyException(OptionError,"MissingArgument",option);
4099  method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4100  argv[i]);
4101  if (method < 0)
4102  ThrowMogrifyException(OptionError,"UnrecognizedThresholdMethod",
4103  argv[i]);
4104  break;
4105  }
4106  if (LocaleCompare("average",option+1) == 0)
4107  break;
4108  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4109  }
4110  case 'b':
4111  {
4112  if (LocaleCompare("background",option+1) == 0)
4113  {
4114  if (*option == '+')
4115  break;
4116  i++;
4117  if (i == (ssize_t) argc)
4118  ThrowMogrifyException(OptionError,"MissingArgument",option);
4119  break;
4120  }
4121  if (LocaleCompare("bias",option+1) == 0)
4122  {
4123  if (*option == '+')
4124  break;
4125  i++;
4126  if (i == (ssize_t) argc)
4127  ThrowMogrifyException(OptionError,"MissingArgument",option);
4128  if (IsGeometry(argv[i]) == MagickFalse)
4129  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4130  break;
4131  }
4132  if (LocaleCompare("black-point-compensation",option+1) == 0)
4133  break;
4134  if (LocaleCompare("black-threshold",option+1) == 0)
4135  {
4136  if (*option == '+')
4137  break;
4138  i++;
4139  if (i == (ssize_t) argc)
4140  ThrowMogrifyException(OptionError,"MissingArgument",option);
4141  if (IsGeometry(argv[i]) == MagickFalse)
4142  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4143  break;
4144  }
4145  if (LocaleCompare("blue-primary",option+1) == 0)
4146  {
4147  if (*option == '+')
4148  break;
4149  i++;
4150  if (i == (ssize_t) argc)
4151  ThrowMogrifyException(OptionError,"MissingArgument",option);
4152  if (IsGeometry(argv[i]) == MagickFalse)
4153  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4154  break;
4155  }
4156  if (LocaleCompare("blue-shift",option+1) == 0)
4157  {
4158  i++;
4159  if (i == (ssize_t) argc)
4160  ThrowMogrifyException(OptionError,"MissingArgument",option);
4161  if (IsGeometry(argv[i]) == MagickFalse)
4162  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4163  break;
4164  }
4165  if (LocaleCompare("blur",option+1) == 0)
4166  {
4167  i++;
4168  if (i == (ssize_t) argc)
4169  ThrowMogrifyException(OptionError,"MissingArgument",option);
4170  if (IsGeometry(argv[i]) == MagickFalse)
4171  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4172  break;
4173  }
4174  if (LocaleCompare("border",option+1) == 0)
4175  {
4176  if (*option == '+')
4177  break;
4178  i++;
4179  if (i == (ssize_t) argc)
4180  ThrowMogrifyException(OptionError,"MissingArgument",option);
4181  if (IsGeometry(argv[i]) == MagickFalse)
4182  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4183  break;
4184  }
4185  if (LocaleCompare("bordercolor",option+1) == 0)
4186  {
4187  if (*option == '+')
4188  break;
4189  i++;
4190  if (i == (ssize_t) argc)
4191  ThrowMogrifyException(OptionError,"MissingArgument",option);
4192  break;
4193  }
4194  if (LocaleCompare("box",option+1) == 0)
4195  {
4196  if (*option == '+')
4197  break;
4198  i++;
4199  if (i == (ssize_t) argc)
4200  ThrowMogrifyException(OptionError,"MissingArgument",option);
4201  break;
4202  }
4203  if (LocaleCompare("brightness-contrast",option+1) == 0)
4204  {
4205  i++;
4206  if (i == (ssize_t) argc)
4207  ThrowMogrifyException(OptionError,"MissingArgument",option);
4208  if (IsGeometry(argv[i]) == MagickFalse)
4209  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4210  break;
4211  }
4212  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4213  }
4214  case 'c':
4215  {
4216  if (LocaleCompare("cache",option+1) == 0)
4217  {
4218  if (*option == '+')
4219  break;
4220  i++;
4221  if (i == (ssize_t) argc)
4222  ThrowMogrifyException(OptionError,"MissingArgument",option);
4223  if (IsGeometry(argv[i]) == MagickFalse)
4224  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4225  break;
4226  }
4227  if (LocaleCompare("canny",option+1) == 0)
4228  {
4229  if (*option == '+')
4230  break;
4231  i++;
4232  if (i == (ssize_t) argc)
4233  ThrowMogrifyException(OptionError,"MissingArgument",option);
4234  if (IsGeometry(argv[i]) == MagickFalse)
4235  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4236  break;
4237  }
4238  if (LocaleCompare("caption",option+1) == 0)
4239  {
4240  if (*option == '+')
4241  break;
4242  i++;
4243  if (i == (ssize_t) argc)
4244  ThrowMogrifyException(OptionError,"MissingArgument",option);
4245  break;
4246  }
4247  if (LocaleCompare("channel",option+1) == 0)
4248  {
4249  ssize_t
4250  channel;
4251 
4252  if (*option == '+')
4253  break;
4254  i++;
4255  if (i == (ssize_t) argc)
4256  ThrowMogrifyException(OptionError,"MissingArgument",option);
4257  channel=ParseChannelOption(argv[i]);
4258  if (channel < 0)
4259  ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4260  argv[i]);
4261  break;
4262  }
4263  if (LocaleCompare("channel-fx",option+1) == 0)
4264  {
4265  ssize_t
4266  channel;
4267 
4268  if (*option == '+')
4269  break;
4270  i++;
4271  if (i == (ssize_t) argc)
4272  ThrowMogrifyException(OptionError,"MissingArgument",option);
4273  channel=ParsePixelChannelOption(argv[i]);
4274  if (channel < 0)
4275  ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4276  argv[i]);
4277  break;
4278  }
4279  if (LocaleCompare("cdl",option+1) == 0)
4280  {
4281  if (*option == '+')
4282  break;
4283  i++;
4284  if (i == (ssize_t) argc)
4285  ThrowMogrifyException(OptionError,"MissingArgument",option);
4286  break;
4287  }
4288  if (LocaleCompare("charcoal",option+1) == 0)
4289  {
4290  if (*option == '+')
4291  break;
4292  i++;
4293  if (i == (ssize_t) argc)
4294  ThrowMogrifyException(OptionError,"MissingArgument",option);
4295  if (IsGeometry(argv[i]) == MagickFalse)
4296  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4297  break;
4298  }
4299  if (LocaleCompare("chop",option+1) == 0)
4300  {
4301  if (*option == '+')
4302  break;
4303  i++;
4304  if (i == (ssize_t) argc)
4305  ThrowMogrifyException(OptionError,"MissingArgument",option);
4306  if (IsGeometry(argv[i]) == MagickFalse)
4307  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4308  break;
4309  }
4310  if (LocaleCompare("clamp",option+1) == 0)
4311  break;
4312  if (LocaleCompare("clip",option+1) == 0)
4313  break;
4314  if (LocaleCompare("clip-mask",option+1) == 0)
4315  {
4316  if (*option == '+')
4317  break;
4318  i++;
4319  if (i == (ssize_t) argc)
4320  ThrowMogrifyException(OptionError,"MissingArgument",option);
4321  break;
4322  }
4323  if (LocaleCompare("clut",option+1) == 0)
4324  break;
4325  if (LocaleCompare("coalesce",option+1) == 0)
4326  break;
4327  if (LocaleCompare("colorize",option+1) == 0)
4328  {
4329  if (*option == '+')
4330  break;
4331  i++;
4332  if (i == (ssize_t) argc)
4333  ThrowMogrifyException(OptionError,"MissingArgument",option);
4334  if (IsGeometry(argv[i]) == MagickFalse)
4335  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4336  break;
4337  }
4338  if (LocaleCompare("color-matrix",option+1) == 0)
4339  {
4340  KernelInfo
4341  *kernel_info;
4342 
4343  if (*option == '+')
4344  break;
4345  i++;
4346  if (i == (ssize_t) argc)
4347  ThrowMogrifyException(OptionError,"MissingArgument",option);
4348  kernel_info=AcquireKernelInfo(argv[i],exception);
4349  if (kernel_info == (KernelInfo *) NULL)
4350  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4351  kernel_info=DestroyKernelInfo(kernel_info);
4352  break;
4353  }
4354  if (LocaleCompare("colors",option+1) == 0)
4355  {
4356  if (*option == '+')
4357  break;
4358  i++;
4359  if (i == (ssize_t) argc)
4360  ThrowMogrifyException(OptionError,"MissingArgument",option);
4361  if (IsGeometry(argv[i]) == MagickFalse)
4362  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4363  break;
4364  }
4365  if (LocaleCompare("colorspace",option+1) == 0)
4366  {
4367  ssize_t
4368  colorspace;
4369 
4370  if (*option == '+')
4371  break;
4372  i++;
4373  if (i == (ssize_t) argc)
4374  ThrowMogrifyException(OptionError,"MissingArgument",option);
4375  colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4376  argv[i]);
4377  if (colorspace < 0)
4378  ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4379  argv[i]);
4380  break;
4381  }
4382  if (LocaleCompare("combine",option+1) == 0)
4383  {
4384  ssize_t
4385  colorspace;
4386 
4387  if (*option == '+')
4388  break;
4389  i++;
4390  if (i == (ssize_t) argc)
4391  ThrowMogrifyException(OptionError,"MissingArgument",option);
4392  colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4393  argv[i]);
4394  if (colorspace < 0)
4395  ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4396  argv[i]);
4397  break;
4398  }
4399  if (LocaleCompare("compare",option+1) == 0)
4400  break;
4401  if (LocaleCompare("comment",option+1) == 0)
4402  {
4403  if (*option == '+')
4404  break;
4405  i++;
4406  if (i == (ssize_t) argc)
4407  ThrowMogrifyException(OptionError,"MissingArgument",option);
4408  break;
4409  }
4410  if (LocaleCompare("composite",option+1) == 0)
4411  break;
4412  if (LocaleCompare("compress",option+1) == 0)
4413  {
4414  ssize_t
4415  compress;
4416 
4417  if (*option == '+')
4418  break;
4419  i++;
4420  if (i == (ssize_t) argc)
4421  ThrowMogrifyException(OptionError,"MissingArgument",option);
4422  compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4423  argv[i]);
4424  if (compress < 0)
4425  ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4426  argv[i]);
4427  break;
4428  }
4429  if (LocaleCompare("concurrent",option+1) == 0)
4430  break;
4431  if (LocaleCompare("connected-components",option+1) == 0)
4432  {
4433  i++;
4434  if (i == (ssize_t) argc)
4435  ThrowMogrifyException(OptionError,"MissingArgument",option);
4436  if (IsGeometry(argv[i]) == MagickFalse)
4437  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4438  break;
4439  }
4440  if (LocaleCompare("contrast",option+1) == 0)
4441  break;
4442  if (LocaleCompare("contrast-stretch",option+1) == 0)
4443  {
4444  i++;
4445  if (i == (ssize_t) argc)
4446  ThrowMogrifyException(OptionError,"MissingArgument",option);
4447  if (IsGeometry(argv[i]) == MagickFalse)
4448  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4449  break;
4450  }
4451  if (LocaleCompare("convolve",option+1) == 0)
4452  {
4453  KernelInfo
4454  *kernel_info;
4455 
4456  if (*option == '+')
4457  break;
4458  i++;
4459  if (i == (ssize_t) argc)
4460  ThrowMogrifyException(OptionError,"MissingArgument",option);
4461  kernel_info=AcquireKernelInfo(argv[i],exception);
4462  if (kernel_info == (KernelInfo *) NULL)
4463  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4464  kernel_info=DestroyKernelInfo(kernel_info);
4465  break;
4466  }
4467  if (LocaleCompare("copy",option+1) == 0)
4468  {
4469  if (*option == '+')
4470  break;
4471  i++;
4472  if (i == (ssize_t) argc)
4473  ThrowMogrifyException(OptionError,"MissingArgument",option);
4474  if (IsGeometry(argv[i]) == MagickFalse)
4475  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4476  i++;
4477  if (i == (ssize_t) argc)
4478  ThrowMogrifyException(OptionError,"MissingArgument",option);
4479  if (IsGeometry(argv[i]) == MagickFalse)
4480  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4481  break;
4482  }
4483  if (LocaleCompare("crop",option+1) == 0)
4484  {
4485  if (*option == '+')
4486  break;
4487  i++;
4488  if (i == (ssize_t) argc)
4489  ThrowMogrifyException(OptionError,"MissingArgument",option);
4490  if (IsGeometry(argv[i]) == MagickFalse)
4491  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4492  break;
4493  }
4494  if (LocaleCompare("cycle",option+1) == 0)
4495  {
4496  if (*option == '+')
4497  break;
4498  i++;
4499  if (i == (ssize_t) argc)
4500  ThrowMogrifyException(OptionError,"MissingArgument",option);
4501  if (IsGeometry(argv[i]) == MagickFalse)
4502  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4503  break;
4504  }
4505  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4506  }
4507  case 'd':
4508  {
4509  if (LocaleCompare("decipher",option+1) == 0)
4510  {
4511  if (*option == '+')
4512  break;
4513  i++;
4514  if (i == (ssize_t) argc)
4515  ThrowMogrifyException(OptionError,"MissingArgument",option);
4516  break;
4517  }
4518  if (LocaleCompare("deconstruct",option+1) == 0)
4519  break;
4520  if (LocaleCompare("debug",option+1) == 0)
4521  {
4522  ssize_t
4523  event;
4524 
4525  if (*option == '+')
4526  break;
4527  i++;
4528  if (i == (ssize_t) argc)
4529  ThrowMogrifyException(OptionError,"MissingArgument",option);
4530  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4531  if (event < 0)
4532  ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4533  argv[i]);
4534  (void) SetLogEventMask(argv[i]);
4535  break;
4536  }
4537  if (LocaleCompare("define",option+1) == 0)
4538  {
4539  i++;
4540  if (i == (ssize_t) argc)
4541  ThrowMogrifyException(OptionError,"MissingArgument",option);
4542  if (*option == '+')
4543  {
4544  const char
4545  *define;
4546 
4547  define=GetImageOption(image_info,argv[i]);
4548  if (define == (const char *) NULL)
4549  ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4550  break;
4551  }
4552  break;
4553  }
4554  if (LocaleCompare("delay",option+1) == 0)
4555  {
4556  if (*option == '+')
4557  break;
4558  i++;
4559  if (i == (ssize_t) argc)
4560  ThrowMogrifyException(OptionError,"MissingArgument",option);
4561  if (IsGeometry(argv[i]) == MagickFalse)
4562  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4563  break;
4564  }
4565  if (LocaleCompare("delete",option+1) == 0)
4566  {
4567  if (*option == '+')
4568  break;
4569  i++;
4570  if (i == (ssize_t) argc)
4571  ThrowMogrifyException(OptionError,"MissingArgument",option);
4572  if (IsGeometry(argv[i]) == MagickFalse)
4573  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4574  break;
4575  }
4576  if (LocaleCompare("density",option+1) == 0)
4577  {
4578  if (*option == '+')
4579  break;
4580  i++;
4581  if (i == (ssize_t) argc)
4582  ThrowMogrifyException(OptionError,"MissingArgument",option);
4583  if (IsGeometry(argv[i]) == MagickFalse)
4584  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4585  break;
4586  }
4587  if (LocaleCompare("depth",option+1) == 0)
4588  {
4589  if (*option == '+')
4590  break;
4591  i++;
4592  if (i == (ssize_t) argc)
4593  ThrowMogrifyException(OptionError,"MissingArgument",option);
4594  if (IsGeometry(argv[i]) == MagickFalse)
4595  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4596  break;
4597  }
4598  if (LocaleCompare("deskew",option+1) == 0)
4599  {
4600  if (*option == '+')
4601  break;
4602  i++;
4603  if (i == (ssize_t) argc)
4604  ThrowMogrifyException(OptionError,"MissingArgument",option);
4605  if (IsGeometry(argv[i]) == MagickFalse)
4606  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4607  break;
4608  }
4609  if (LocaleCompare("despeckle",option+1) == 0)
4610  break;
4611  if (LocaleCompare("dft",option+1) == 0)
4612  break;
4613  if (LocaleCompare("direction",option+1) == 0)
4614  {
4615  ssize_t
4616  direction;
4617 
4618  if (*option == '+')
4619  break;
4620  i++;
4621  if (i == (ssize_t) argc)
4622  ThrowMogrifyException(OptionError,"MissingArgument",option);
4623  direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4624  argv[i]);
4625  if (direction < 0)
4626  ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4627  argv[i]);
4628  break;
4629  }
4630  if (LocaleCompare("display",option+1) == 0)
4631  {
4632  if (*option == '+')
4633  break;
4634  i++;
4635  if (i == (ssize_t) argc)
4636  ThrowMogrifyException(OptionError,"MissingArgument",option);
4637  break;
4638  }
4639  if (LocaleCompare("dispose",option+1) == 0)
4640  {
4641  ssize_t
4642  dispose;
4643 
4644  if (*option == '+')
4645  break;
4646  i++;
4647  if (i == (ssize_t) argc)
4648  ThrowMogrifyException(OptionError,"MissingArgument",option);
4649  dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4650  argv[i]);
4651  if (dispose < 0)
4652  ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4653  argv[i]);
4654  break;
4655  }
4656  if (LocaleCompare("distort",option+1) == 0)
4657  {
4658  ssize_t
4659  op;
4660 
4661  i++;
4662  if (i == (ssize_t) argc)
4663  ThrowMogrifyException(OptionError,"MissingArgument",option);
4664  op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4665  if (op < 0)
4666  ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4667  argv[i]);
4668  i++;
4669  if (i == (ssize_t) argc)
4670  ThrowMogrifyException(OptionError,"MissingArgument",option);
4671  break;
4672  }
4673  if (LocaleCompare("dither",option+1) == 0)
4674  {
4675  ssize_t
4676  method;
4677 
4678  if (*option == '+')
4679  break;
4680  i++;
4681  if (i == (ssize_t) argc)
4682  ThrowMogrifyException(OptionError,"MissingArgument",option);
4683  method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4684  if (method < 0)
4685  ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4686  argv[i]);
4687  break;
4688  }
4689  if (LocaleCompare("draw",option+1) == 0)
4690  {
4691  if (*option == '+')
4692  break;
4693  i++;
4694  if (i == (ssize_t) argc)
4695  ThrowMogrifyException(OptionError,"MissingArgument",option);
4696  break;
4697  }
4698  if (LocaleCompare("duplicate",option+1) == 0)
4699  {
4700  if (*option == '+')
4701  break;
4702  i++;
4703  if (i == (ssize_t) argc)
4704  ThrowMogrifyException(OptionError,"MissingArgument",option);
4705  if (IsGeometry(argv[i]) == MagickFalse)
4706  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4707  break;
4708  }
4709  if (LocaleCompare("duration",option+1) == 0)
4710  {
4711  if (*option == '+')
4712  break;
4713  i++;
4714  if (i == (ssize_t) argc)
4715  ThrowMogrifyException(OptionError,"MissingArgument",option);
4716  if (IsGeometry(argv[i]) == MagickFalse)
4717  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4718  break;
4719  }
4720  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4721  }
4722  case 'e':
4723  {
4724  if (LocaleCompare("edge",option+1) == 0)
4725  {
4726  if (*option == '+')
4727  break;
4728  i++;
4729  if (i == (ssize_t) argc)
4730  ThrowMogrifyException(OptionError,"MissingArgument",option);
4731  if (IsGeometry(argv[i]) == MagickFalse)
4732  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4733  break;
4734  }
4735  if (LocaleCompare("emboss",option+1) == 0)
4736  {
4737  if (*option == '+')
4738  break;
4739  i++;
4740  if (i == (ssize_t) argc)
4741  ThrowMogrifyException(OptionError,"MissingArgument",option);
4742  if (IsGeometry(argv[i]) == MagickFalse)
4743  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4744  break;
4745  }
4746  if (LocaleCompare("encipher",option+1) == 0)
4747  {
4748  if (*option == '+')
4749  break;
4750  i++;
4751  if (i == (ssize_t) argc)
4752  ThrowMogrifyException(OptionError,"MissingArgument",option);
4753  break;
4754  }
4755  if (LocaleCompare("encoding",option+1) == 0)
4756  {
4757  if (*option == '+')
4758  break;
4759  i++;
4760  if (i == (ssize_t) argc)
4761  ThrowMogrifyException(OptionError,"MissingArgument",option);
4762  break;
4763  }
4764  if (LocaleCompare("endian",option+1) == 0)
4765  {
4766  ssize_t
4767  endian;
4768 
4769  if (*option == '+')
4770  break;
4771  i++;
4772  if (i == (ssize_t) argc)
4773  ThrowMogrifyException(OptionError,"MissingArgument",option);
4774  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4775  if (endian < 0)
4776  ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4777  argv[i]);
4778  break;
4779  }
4780  if (LocaleCompare("enhance",option+1) == 0)
4781  break;
4782  if (LocaleCompare("equalize",option+1) == 0)
4783  break;
4784  if (LocaleCompare("evaluate",option+1) == 0)
4785  {
4786  ssize_t
4787  op;
4788 
4789  if (*option == '+')
4790  break;
4791  i++;
4792  if (i == (ssize_t) argc)
4793  ThrowMogrifyException(OptionError,"MissingArgument",option);
4794  op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4795  if (op < 0)
4796  ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4797  argv[i]);
4798  i++;
4799  if (i == (ssize_t) argc)
4800  ThrowMogrifyException(OptionError,"MissingArgument",option);
4801  if (IsGeometry(argv[i]) == MagickFalse)
4802  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4803  break;
4804  }
4805  if (LocaleCompare("evaluate-sequence",option+1) == 0)
4806  {
4807  ssize_t
4808  op;
4809 
4810  if (*option == '+')
4811  break;
4812  i++;
4813  if (i == (ssize_t) argc)
4814  ThrowMogrifyException(OptionError,"MissingArgument",option);
4815  op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4816  if (op < 0)
4817  ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4818  argv[i]);
4819  break;
4820  }
4821  if (LocaleCompare("extent",option+1) == 0)
4822  {
4823  if (*option == '+')
4824  break;
4825  i++;
4826  if (i == (ssize_t) argc)
4827  ThrowMogrifyException(OptionError,"MissingArgument",option);
4828  if (IsGeometry(argv[i]) == MagickFalse)
4829  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4830  break;
4831  }
4832  if (LocaleCompare("extract",option+1) == 0)
4833  {
4834  if (*option == '+')
4835  break;
4836  i++;
4837  if (i == (ssize_t) argc)
4838  ThrowMogrifyException(OptionError,"MissingArgument",option);
4839  if (IsGeometry(argv[i]) == MagickFalse)
4840  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4841  break;
4842  }
4843  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4844  }
4845  case 'f':
4846  {
4847  if (LocaleCompare("family",option+1) == 0)
4848  {
4849  if (*option == '+')
4850  break;
4851  i++;
4852  if (i == (ssize_t) argc)
4853  ThrowMogrifyException(OptionError,"MissingArgument",option);
4854  break;
4855  }
4856  if (LocaleCompare("features",option+1) == 0)
4857  {
4858  if (*option == '+')
4859  break;
4860  i++;
4861  if (i == (ssize_t) argc)
4862  ThrowMogrifyException(OptionError,"MissingArgument",option);
4863  if (IsGeometry(argv[i]) == MagickFalse)
4864  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4865  break;
4866  }
4867  if (LocaleCompare("fill",option+1) == 0)
4868  {
4869  if (*option == '+')
4870  break;
4871  i++;
4872  if (i == (ssize_t) argc)
4873  ThrowMogrifyException(OptionError,"MissingArgument",option);
4874  break;
4875  }
4876  if (LocaleCompare("filter",option+1) == 0)
4877  {
4878  ssize_t
4879  filter;
4880 
4881  if (*option == '+')
4882  break;
4883  i++;
4884  if (i == (ssize_t) argc)
4885  ThrowMogrifyException(OptionError,"MissingArgument",option);
4886  filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4887  if (filter < 0)
4888  ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4889  argv[i]);
4890  break;
4891  }
4892  if (LocaleCompare("flatten",option+1) == 0)
4893  break;
4894  if (LocaleCompare("flip",option+1) == 0)
4895  break;
4896  if (LocaleCompare("flop",option+1) == 0)
4897  break;
4898  if (LocaleCompare("floodfill",option+1) == 0)
4899  {
4900  if (*option == '+')
4901  break;
4902  i++;
4903  if (i == (ssize_t) argc)
4904  ThrowMogrifyException(OptionError,"MissingArgument",option);
4905  if (IsGeometry(argv[i]) == MagickFalse)
4906  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4907  i++;
4908  if (i == (ssize_t) argc)
4909  ThrowMogrifyException(OptionError,"MissingArgument",option);
4910  break;
4911  }
4912  if (LocaleCompare("font",option+1) == 0)
4913  {
4914  if (*option == '+')
4915  break;
4916  i++;
4917  if (i == (ssize_t) argc)
4918  ThrowMogrifyException(OptionError,"MissingArgument",option);
4919  break;
4920  }
4921  if (LocaleCompare("format",option+1) == 0)
4922  {
4923  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
4924  (void) CloneString(&format,(char *) NULL);
4925  if (*option == '+')
4926  break;
4927  i++;
4928  if (i == (ssize_t) argc)
4929  ThrowMogrifyException(OptionError,"MissingArgument",option);
4930  (void) CloneString(&format,argv[i]);
4931  (void) CopyMagickString(image_info->filename,format,
4933  (void) ConcatenateMagickString(image_info->filename,":",
4935  (void) SetImageInfo(image_info,0,exception);
4936  if (*image_info->magick == '\0')
4937  ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4938  format);
4939  break;
4940  }
4941  if (LocaleCompare("frame",option+1) == 0)
4942  {
4943  if (*option == '+')
4944  break;
4945  i++;
4946  if (i == (ssize_t) argc)
4947  ThrowMogrifyException(OptionError,"MissingArgument",option);
4948  if (IsGeometry(argv[i]) == MagickFalse)
4949  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4950  break;
4951  }
4952  if (LocaleCompare("function",option+1) == 0)
4953  {
4954  ssize_t
4955  op;
4956 
4957  if (*option == '+')
4958  break;
4959  i++;
4960  if (i == (ssize_t) argc)
4961  ThrowMogrifyException(OptionError,"MissingArgument",option);
4962  op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4963  if (op < 0)
4964  ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4965  i++;
4966  if (i == (ssize_t) argc)
4967  ThrowMogrifyException(OptionError,"MissingArgument",option);
4968  break;
4969  }
4970  if (LocaleCompare("fuzz",option+1) == 0)
4971  {
4972  if (*option == '+')
4973  break;
4974  i++;
4975  if (i == (ssize_t) argc)
4976  ThrowMogrifyException(OptionError,"MissingArgument",option);
4977  if (IsGeometry(argv[i]) == MagickFalse)
4978  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4979  break;
4980  }
4981  if (LocaleCompare("fx",option+1) == 0)
4982  {
4983  if (*option == '+')
4984  break;
4985  i++;
4986  if (i == (ssize_t) argc)
4987  ThrowMogrifyException(OptionError,"MissingArgument",option);
4988  break;
4989  }
4990  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4991  }
4992  case 'g':
4993  {
4994  if (LocaleCompare("gamma",option+1) == 0)
4995  {
4996  i++;
4997  if (i == (ssize_t) argc)
4998  ThrowMogrifyException(OptionError,"MissingArgument",option);
4999  if (IsGeometry(argv[i]) == MagickFalse)
5000  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5001  break;
5002  }
5003  if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5004  (LocaleCompare("gaussian",option+1) == 0))
5005  {
5006  i++;
5007  if (i == (ssize_t) argc)
5008  ThrowMogrifyException(OptionError,"MissingArgument",option);
5009  if (IsGeometry(argv[i]) == MagickFalse)
5010  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5011  break;
5012  }
5013  if (LocaleCompare("geometry",option+1) == 0)
5014  {
5015  if (*option == '+')
5016  break;
5017  i++;
5018  if (i == (ssize_t) argc)
5019  ThrowMogrifyException(OptionError,"MissingArgument",option);
5020  if (IsGeometry(argv[i]) == MagickFalse)
5021  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5022  break;
5023  }
5024  if (LocaleCompare("gravity",option+1) == 0)
5025  {
5026  ssize_t
5027  gravity;
5028 
5029  if (*option == '+')
5030  break;
5031  i++;
5032  if (i == (ssize_t) argc)
5033  ThrowMogrifyException(OptionError,"MissingArgument",option);
5034  gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5035  argv[i]);
5036  if (gravity < 0)
5037  ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5038  argv[i]);
5039  break;
5040  }
5041  if (LocaleCompare("grayscale",option+1) == 0)
5042  {
5043  ssize_t
5044  method;
5045 
5046  if (*option == '+')
5047  break;
5048  i++;
5049  if (i == (ssize_t) argc)
5050  ThrowMogrifyException(OptionError,"MissingArgument",option);
5051  method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5052  argv[i]);
5053  if (method < 0)
5054  ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
5055  argv[i]);
5056  break;
5057  }
5058  if (LocaleCompare("green-primary",option+1) == 0)
5059  {
5060  if (*option == '+')
5061  break;
5062  i++;
5063  if (i == (ssize_t) argc)
5064  ThrowMogrifyException(OptionError,"MissingArgument",option);
5065  if (IsGeometry(argv[i]) == MagickFalse)
5066  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5067  break;
5068  }
5069  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5070  }
5071  case 'h':
5072  {
5073  if (LocaleCompare("hald-clut",option+1) == 0)
5074  break;
5075  if ((LocaleCompare("help",option+1) == 0) ||
5076  (LocaleCompare("-help",option+1) == 0))
5077  return(MogrifyUsage());
5078  if (LocaleCompare("hough-lines",option+1) == 0)
5079  {
5080  if (*option == '+')
5081  break;
5082  i++;
5083  if (i == (ssize_t) argc)
5084  ThrowMogrifyException(OptionError,"MissingArgument",option);
5085  if (IsGeometry(argv[i]) == MagickFalse)
5086  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5087  break;
5088  }
5089  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5090  }
5091  case 'i':
5092  {
5093  if (LocaleCompare("identify",option+1) == 0)
5094  break;
5095  if (LocaleCompare("idft",option+1) == 0)
5096  break;
5097  if (LocaleCompare("implode",option+1) == 0)
5098  {
5099  if (*option == '+')
5100  break;
5101  i++;
5102  if (i == (ssize_t) argc)
5103  ThrowMogrifyException(OptionError,"MissingArgument",option);
5104  if (IsGeometry(argv[i]) == MagickFalse)
5105  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5106  break;
5107  }
5108  if (LocaleCompare("intensity",option+1) == 0)
5109  {
5110  ssize_t
5111  intensity;
5112 
5113  if (*option == '+')
5114  break;
5115  i++;
5116  if (i == (ssize_t) argc)
5117  ThrowMogrifyException(OptionError,"MissingArgument",option);
5118  intensity=ParseCommandOption(MagickPixelIntensityOptions,
5119  MagickFalse,argv[i]);
5120  if (intensity < 0)
5121  ThrowMogrifyException(OptionError,
5122  "UnrecognizedPixelIntensityMethod",argv[i]);
5123  break;
5124  }
5125  if (LocaleCompare("intent",option+1) == 0)
5126  {
5127  ssize_t
5128  intent;
5129 
5130  if (*option == '+')
5131  break;
5132  i++;
5133  if (i == (ssize_t) argc)
5134  ThrowMogrifyException(OptionError,"MissingArgument",option);
5135  intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5136  if (intent < 0)
5137  ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5138  argv[i]);
5139  break;
5140  }
5141  if (LocaleCompare("interlace",option+1) == 0)
5142  {
5143  ssize_t
5144  interlace;
5145 
5146  if (*option == '+')
5147  break;
5148  i++;
5149  if (i == (ssize_t) argc)
5150  ThrowMogrifyException(OptionError,"MissingArgument",option);
5151  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5152  argv[i]);
5153  if (interlace < 0)
5154  ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5155  argv[i]);
5156  break;
5157  }
5158  if (LocaleCompare("interline-spacing",option+1) == 0)
5159  {
5160  if (*option == '+')
5161  break;
5162  i++;
5163  if (i == (ssize_t) argc)
5164  ThrowMogrifyException(OptionError,"MissingArgument",option);
5165  if (IsGeometry(argv[i]) == MagickFalse)
5166  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5167  break;
5168  }
5169  if (LocaleCompare("interpolate",option+1) == 0)
5170  {
5171  ssize_t
5172  interpolate;
5173 
5174  if (*option == '+')
5175  break;
5176  i++;
5177  if (i == (ssize_t) argc)
5178  ThrowMogrifyException(OptionError,"MissingArgument",option);
5179  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5180  argv[i]);
5181  if (interpolate < 0)
5182  ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5183  argv[i]);
5184  break;
5185  }
5186  if (LocaleCompare("interword-spacing",option+1) == 0)
5187  {
5188  if (*option == '+')
5189  break;
5190  i++;
5191  if (i == (ssize_t) argc)
5192  ThrowMogrifyException(OptionError,"MissingArgument",option);
5193  if (IsGeometry(argv[i]) == MagickFalse)
5194  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5195  break;
5196  }
5197  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5198  }
5199  case 'k':
5200  {
5201  if (LocaleCompare("kerning",option+1) == 0)
5202  {
5203  if (*option == '+')
5204  break;
5205  i++;
5206  if (i == (ssize_t) argc)
5207  ThrowMogrifyException(OptionError,"MissingArgument",option);
5208  if (IsGeometry(argv[i]) == MagickFalse)
5209  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5210  break;
5211  }
5212  if (LocaleCompare("kuwahara",option+1) == 0)
5213  {
5214  i++;
5215  if (i == (ssize_t) argc)
5216  ThrowMogrifyException(OptionError,"MissingArgument",option);
5217  if (IsGeometry(argv[i]) == MagickFalse)
5218  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5219  break;
5220  }
5221  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5222  }
5223  case 'l':
5224  {
5225  if (LocaleCompare("label",option+1) == 0)
5226  {
5227  if (*option == '+')
5228  break;
5229  i++;
5230  if (i == (ssize_t) argc)
5231  ThrowMogrifyException(OptionError,"MissingArgument",option);
5232  break;
5233  }
5234  if (LocaleCompare("lat",option+1) == 0)
5235  {
5236  if (*option == '+')
5237  break;
5238  i++;
5239  if (i == (ssize_t) argc)
5240  ThrowMogrifyException(OptionError,"MissingArgument",option);
5241  if (IsGeometry(argv[i]) == MagickFalse)
5242  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5243  }
5244  if (LocaleCompare("layers",option+1) == 0)
5245  {
5246  ssize_t
5247  type;
5248 
5249  if (*option == '+')
5250  break;
5251  i++;
5252  if (i == (ssize_t) argc)
5253  ThrowMogrifyException(OptionError,"MissingArgument",option);
5254  type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5255  if (type < 0)
5256  ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5257  argv[i]);
5258  break;
5259  }
5260  if (LocaleCompare("level",option+1) == 0)
5261  {
5262  i++;
5263  if (i == (ssize_t) argc)
5264  ThrowMogrifyException(OptionError,"MissingArgument",option);
5265  if (IsGeometry(argv[i]) == MagickFalse)
5266  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5267  break;
5268  }
5269  if (LocaleCompare("level-colors",option+1) == 0)
5270  {
5271  i++;
5272  if (i == (ssize_t) argc)
5273  ThrowMogrifyException(OptionError,"MissingArgument",option);
5274  break;
5275  }
5276  if (LocaleCompare("limit",option+1) == 0)
5277  {
5278  char
5279  *p;
5280 
5281  double
5282  value;
5283 
5284  ssize_t
5285  resource;
5286 
5287  if (*option == '+')
5288  break;
5289  i++;
5290  if (i == (ssize_t) argc)
5291  ThrowMogrifyException(OptionError,"MissingArgument",option);
5292  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5293  argv[i]);
5294  if (resource < 0)
5295  ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5296  argv[i]);
5297  i++;
5298  if (i == (ssize_t) argc)
5299  ThrowMogrifyException(OptionError,"MissingArgument",option);
5300  value=StringToDouble(argv[i],&p);
5301  (void) value;
5302  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5303  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5304  break;
5305  }
5306  if (LocaleCompare("liquid-rescale",option+1) == 0)
5307  {
5308  i++;
5309  if (i == (ssize_t) argc)
5310  ThrowMogrifyException(OptionError,"MissingArgument",option);
5311  if (IsGeometry(argv[i]) == MagickFalse)
5312  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5313  break;
5314  }
5315  if (LocaleCompare("list",option+1) == 0)
5316  {
5317  ssize_t
5318  list;
5319 
5320  if (*option == '+')
5321  break;
5322  i++;
5323  if (i == (ssize_t) argc)
5324  ThrowMogrifyException(OptionError,"MissingArgument",option);
5325  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5326  if (list < 0)
5327  ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5328  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5329  argv+j,exception);
5330  return(status == 0 ? MagickTrue : MagickFalse);
5331  }
5332  if (LocaleCompare("log",option+1) == 0)
5333  {
5334  if (*option == '+')
5335  break;
5336  i++;
5337  if ((i == (ssize_t) argc) ||
5338  (strchr(argv[i],'%') == (char *) NULL))
5339  ThrowMogrifyException(OptionError,"MissingArgument",option);
5340  break;
5341  }
5342  if (LocaleCompare("loop",option+1) == 0)
5343  {
5344  if (*option == '+')
5345  break;
5346  i++;
5347  if (i == (ssize_t) argc)
5348  ThrowMogrifyException(OptionError,"MissingArgument",option);
5349  if (IsGeometry(argv[i]) == MagickFalse)
5350  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5351  break;
5352  }
5353  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5354  }
5355  case 'm':
5356  {
5357  if (LocaleCompare("map",option+1) == 0)
5358  {
5359  global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5360  if (*option == '+')
5361  break;
5362  i++;
5363  if (i == (ssize_t) argc)
5364  ThrowMogrifyException(OptionError,"MissingArgument",option);
5365  break;
5366  }
5367  if (LocaleCompare("mask",option+1) == 0)
5368  {
5369  if (*option == '+')
5370  break;
5371  i++;
5372  if (i == (ssize_t) argc)
5373  ThrowMogrifyException(OptionError,"MissingArgument",option);
5374  break;
5375  }
5376  if (LocaleCompare("matte",option+1) == 0)
5377  break;
5378  if (LocaleCompare("mattecolor",option+1) == 0)
5379  {
5380  if (*option == '+')
5381  break;
5382  i++;
5383  if (i == (ssize_t) argc)
5384  ThrowMogrifyException(OptionError,"MissingArgument",option);
5385  break;
5386  }
5387  if (LocaleCompare("maximum",option+1) == 0)
5388  break;
5389  if (LocaleCompare("mean-shift",option+1) == 0)
5390  {
5391  if (*option == '+')
5392  break;
5393  i++;
5394  if (i == (ssize_t) argc)
5395  ThrowMogrifyException(OptionError,"MissingArgument",option);
5396  if (IsGeometry(argv[i]) == MagickFalse)
5397  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5398  break;
5399  }
5400  if (LocaleCompare("median",option+1) == 0)
5401  {
5402  if (*option == '+')
5403  break;
5404  i++;
5405  if (i == (ssize_t) argc)
5406  ThrowMogrifyException(OptionError,"MissingArgument",option);
5407  if (IsGeometry(argv[i]) == MagickFalse)
5408  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5409  break;
5410  }
5411  if (LocaleCompare("metric",option+1) == 0)
5412  {
5413  ssize_t
5414  type;
5415 
5416  if (*option == '+')
5417  break;
5418  i++;
5419  if (i == (ssize_t) argc)
5420  ThrowMogrifyException(OptionError,"MissingArgument",option);
5421  type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5422  if (type < 0)
5423  ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5424  argv[i]);
5425  break;
5426  }
5427  if (LocaleCompare("minimum",option+1) == 0)
5428  break;
5429  if (LocaleCompare("modulate",option+1) == 0)
5430  {
5431  if (*option == '+')
5432  break;
5433  i++;
5434  if (i == (ssize_t) argc)
5435  ThrowMogrifyException(OptionError,"MissingArgument",option);
5436  if (IsGeometry(argv[i]) == MagickFalse)
5437  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5438  break;
5439  }
5440  if (LocaleCompare("mode",option+1) == 0)
5441  {
5442  if (*option == '+')
5443  break;
5444  i++;
5445  if (i == (ssize_t) argc)
5446  ThrowMogrifyException(OptionError,"MissingArgument",option);
5447  if (IsGeometry(argv[i]) == MagickFalse)
5448  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5449  break;
5450  }
5451  if (LocaleCompare("monitor",option+1) == 0)
5452  break;
5453  if (LocaleCompare("monochrome",option+1) == 0)
5454  break;
5455  if (LocaleCompare("morph",option+1) == 0)
5456  {
5457  if (*option == '+')
5458  break;
5459  i++;
5460  if (i == (ssize_t) argc)
5461  ThrowMogrifyException(OptionError,"MissingArgument",option);
5462  if (IsGeometry(argv[i]) == MagickFalse)
5463  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5464  break;
5465  }
5466  if (LocaleCompare("morphology",option+1) == 0)
5467  {
5468  char
5469  token[MagickPathExtent];
5470 
5471  KernelInfo
5472  *kernel_info;
5473 
5474  ssize_t
5475  op;
5476 
5477  i++;
5478  if (i == (ssize_t) argc)
5479  ThrowMogrifyException(OptionError,"MissingArgument",option);
5480  GetNextToken(argv[i],(const char **) NULL,MagickPathExtent,token);
5481  op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5482  if (op < 0)
5483  ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5484  token);
5485  i++;
5486  if (i == (ssize_t) argc)
5487  ThrowMogrifyException(OptionError,"MissingArgument",option);
5488  kernel_info=AcquireKernelInfo(argv[i],exception);
5489  if (kernel_info == (KernelInfo *) NULL)
5490  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5491  kernel_info=DestroyKernelInfo(kernel_info);
5492  break;
5493  }
5494  if (LocaleCompare("mosaic",option+1) == 0)
5495  break;
5496  if (LocaleCompare("motion-blur",option+1) == 0)
5497  {
5498  if (*option == '+')
5499  break;
5500  i++;
5501  if (i == (ssize_t) argc)
5502  ThrowMogrifyException(OptionError,"MissingArgument",option);
5503  if (IsGeometry(argv[i]) == MagickFalse)
5504  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5505  break;
5506  }
5507  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5508  }
5509  case 'n':
5510  {
5511  if (LocaleCompare("negate",option+1) == 0)
5512  break;
5513  if (LocaleCompare("noise",option+1) == 0)
5514  {
5515  i++;
5516  if (i == (ssize_t) argc)
5517  ThrowMogrifyException(OptionError,"MissingArgument",option);
5518  if (*option == '+')
5519  {
5520  ssize_t
5521  noise;
5522 
5523  noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5524  argv[i]);
5525  if (noise < 0)
5526  ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5527  argv[i]);
5528  break;
5529  }
5530  if (IsGeometry(argv[i]) == MagickFalse)
5531  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5532  break;
5533  }
5534  if (LocaleCompare("noop",option+1) == 0)
5535  break;
5536  if (LocaleCompare("normalize",option+1) == 0)
5537  break;
5538  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5539  }
5540  case 'o':
5541  {
5542  if (LocaleCompare("opaque",option+1) == 0)
5543  {
5544  i++;
5545  if (i == (ssize_t) argc)
5546  ThrowMogrifyException(OptionError,"MissingArgument",option);
5547  break;
5548  }
5549  if (LocaleCompare("ordered-dither",option+1) == 0)
5550  {
5551  if (*option == '+')
5552  break;
5553  i++;
5554  if (i == (ssize_t) argc)
5555  ThrowMogrifyException(OptionError,"MissingArgument",option);
5556  break;
5557  }
5558  if (LocaleCompare("orient",option+1) == 0)
5559  {
5560  ssize_t
5561  orientation;
5562 
5563  orientation=UndefinedOrientation;
5564  if (*option == '+')
5565  break;
5566  i++;
5567  if (i == (ssize_t) argc)
5568  ThrowMogrifyException(OptionError,"MissingArgument",option);
5569  orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5570  argv[i]);
5571  if (orientation < 0)
5572  ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5573  argv[i]);
5574  break;
5575  }
5576  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5577  }
5578  case 'p':
5579  {
5580  if (LocaleCompare("page",option+1) == 0)
5581  {
5582  if (*option == '+')
5583  break;
5584  i++;
5585  if (i == (ssize_t) argc)
5586  ThrowMogrifyException(OptionError,"MissingArgument",option);
5587  break;
5588  }
5589  if (LocaleCompare("paint",option+1) == 0)
5590  {
5591  if (*option == '+')
5592  break;
5593  i++;
5594  if (i == (ssize_t) argc)
5595  ThrowMogrifyException(OptionError,"MissingArgument",option);
5596  if (IsGeometry(argv[i]) == MagickFalse)
5597  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5598  break;
5599  }
5600  if (LocaleCompare("path",option+1) == 0)
5601  {
5602  (void) CloneString(&path,(char *) NULL);
5603  if (*option == '+')
5604  break;
5605  i++;
5606  if (i == (ssize_t) argc)
5607  ThrowMogrifyException(OptionError,"MissingArgument",option);
5608  (void) CloneString(&path,argv[i]);
5609  break;
5610  }
5611  if (LocaleCompare("perceptible",option+1) == 0)
5612  {
5613  if (*option == '+')
5614  break;
5615  i++;
5616  if (i == (ssize_t) argc)
5617  ThrowMogrifyException(OptionError,"MissingArgument",option);
5618  if (IsGeometry(argv[i]) == MagickFalse)
5619  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5620  break;
5621  }
5622  if (LocaleCompare("pointsize",option+1) == 0)
5623  {
5624  if (*option == '+')
5625  break;
5626  i++;
5627  if (i == (ssize_t) argc)
5628  ThrowMogrifyException(OptionError,"MissingArgument",option);
5629  if (IsGeometry(argv[i]) == MagickFalse)
5630  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631  break;
5632  }
5633  if (LocaleCompare("polaroid",option+1) == 0)
5634  {
5635  if (*option == '+')
5636  break;
5637  i++;
5638  if (i == (ssize_t) argc)
5639  ThrowMogrifyException(OptionError,"MissingArgument",option);
5640  if (IsGeometry(argv[i]) == MagickFalse)
5641  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642  break;
5643  }
5644  if (LocaleCompare("poly",option+1) == 0)
5645  {
5646  if (*option == '+')
5647  break;
5648  i++;
5649  if (i == (ssize_t) argc)
5650  ThrowMogrifyException(OptionError,"MissingArgument",option);
5651  if (IsGeometry(argv[i]) == MagickFalse)
5652  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653  break;
5654  }
5655  if (LocaleCompare("posterize",option+1) == 0)
5656  {
5657  if (*option == '+')
5658  break;
5659  i++;
5660  if (i == (ssize_t) argc)
5661  ThrowMogrifyException(OptionError,"MissingArgument",option);
5662  if (IsGeometry(argv[i]) == MagickFalse)
5663  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5664  break;
5665  }
5666  if (LocaleCompare("precision",option+1) == 0)
5667  {
5668  if (*option == '+')
5669  break;
5670  i++;
5671  if (i == (ssize_t) argc)
5672  ThrowMogrifyException(OptionError,"MissingArgument",option);
5673  if (IsGeometry(argv[i]) == MagickFalse)
5674  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5675  break;
5676  }
5677  if (LocaleCompare("print",option+1) == 0)
5678  {
5679  if (*option == '+')
5680  break;
5681  i++;
5682  if (i == (ssize_t) argc)
5683  ThrowMogrifyException(OptionError,"MissingArgument",option);
5684  break;
5685  }
5686  if (LocaleCompare("process",option+1) == 0)
5687  {
5688  if (*option == '+')
5689  break;
5690  i++;
5691  if (i == (ssize_t) argc)
5692  ThrowMogrifyException(OptionError,"MissingArgument",option);
5693  break;
5694  }
5695  if (LocaleCompare("profile",option+1) == 0)
5696  {
5697  i++;
5698  if (i == (ssize_t) argc)
5699  ThrowMogrifyException(OptionError,"MissingArgument",option);
5700  break;
5701  }
5702  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5703  }
5704  case 'q':
5705  {
5706  if (LocaleCompare("quality",option+1) == 0)
5707  {
5708  if (*option == '+')
5709  break;
5710  i++;
5711  if (i == (ssize_t) argc)
5712  ThrowMogrifyException(OptionError,"MissingArgument",option);
5713  if (IsGeometry(argv[i]) == MagickFalse)
5714  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5715  break;
5716  }
5717  if (LocaleCompare("quantize",option+1) == 0)
5718  {
5719  ssize_t
5720  colorspace;
5721 
5722  if (*option == '+')
5723  break;
5724  i++;
5725  if (i == (ssize_t) argc)
5726  ThrowMogrifyException(OptionError,"MissingArgument",option);
5727  colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5728  argv[i]);
5729  if (colorspace < 0)
5730  ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5731  argv[i]);
5732  break;
5733  }
5734  if (LocaleCompare("quiet",option+1) == 0)
5735  break;
5736  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5737  }
5738  case 'r':
5739  {
5740  if (LocaleCompare("rotational-blur",option+1) == 0)
5741  {
5742  i++;
5743  if (i == (ssize_t) argc)
5744  ThrowMogrifyException(OptionError,"MissingArgument",option);
5745  if (IsGeometry(argv[i]) == MagickFalse)
5746  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5747  break;
5748  }
5749  if (LocaleCompare("raise",option+1) == 0)
5750  {
5751  i++;
5752  if (i == (ssize_t) argc)
5753  ThrowMogrifyException(OptionError,"MissingArgument",option);
5754  if (IsGeometry(argv[i]) == MagickFalse)
5755  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5756  break;
5757  }
5758  if (LocaleCompare("random-threshold",option+1) == 0)
5759  {
5760  if (*option == '+')
5761  break;
5762  i++;
5763  if (i == (ssize_t) argc)
5764  ThrowMogrifyException(OptionError,"MissingArgument",option);
5765  if (IsGeometry(argv[i]) == MagickFalse)
5766  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5767  break;
5768  }
5769  if (LocaleCompare("read-mask",option+1) == 0)
5770  {
5771  if (*option == '+')
5772  break;
5773  i++;
5774  if (i == (ssize_t) argc)
5775  ThrowMogrifyException(OptionError,"MissingArgument",option);
5776  break;
5777  }
5778  if (LocaleCompare("red-primary",option+1) == 0)
5779  {
5780  if (*option == '+')
5781  break;
5782  i++;
5783  if (i == (ssize_t) argc)
5784  ThrowMogrifyException(OptionError,"MissingArgument",option);
5785  if (IsGeometry(argv[i]) == MagickFalse)
5786  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5787  }
5788  if (LocaleCompare("regard-warnings",option+1) == 0)
5789  break;
5790  if (LocaleCompare("region",option+1) == 0)
5791  {
5792  if (*option == '+')
5793  break;
5794  i++;
5795  if (i == (ssize_t) argc)
5796  ThrowMogrifyException(OptionError,"MissingArgument",option);
5797  if (IsGeometry(argv[i]) == MagickFalse)
5798  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5799  break;
5800  }
5801  if (LocaleCompare("remap",option+1) == 0)
5802  {
5803  if (*option == '+')
5804  break;
5805  i++;
5806  if (i == (ssize_t) argc)
5807  ThrowMogrifyException(OptionError,"MissingArgument",option);
5808  break;
5809  }
5810  if (LocaleCompare("render",option+1) == 0)
5811  break;
5812  if (LocaleCompare("repage",option+1) == 0)
5813  {
5814  if (*option == '+')
5815  break;
5816  i++;
5817  if (i == (ssize_t) argc)
5818  ThrowMogrifyException(OptionError,"MissingArgument",option);
5819  if (IsGeometry(argv[i]) == MagickFalse)
5820  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5821  break;
5822  }
5823  if (LocaleCompare("resample",option+1) == 0)
5824  {
5825  if (*option == '+')
5826  break;
5827  i++;
5828  if (i == (ssize_t) argc)
5829  ThrowMogrifyException(OptionError,"MissingArgument",option);
5830  if (IsGeometry(argv[i]) == MagickFalse)
5831  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5832  break;
5833  }
5834  if (LocaleCompare("resize",option+1) == 0)
5835  {
5836  if (*option == '+')
5837  break;
5838  i++;
5839  if (i == (ssize_t) argc)
5840  ThrowMogrifyException(OptionError,"MissingArgument",option);
5841  if (IsGeometry(argv[i]) == MagickFalse)
5842  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5843  break;
5844  }
5845  if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5846  {
5847  respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5848  break;
5849  }
5850  if (LocaleCompare("reverse",option+1) == 0)
5851  break;
5852  if (LocaleCompare("roll",option+1) == 0)
5853  {
5854  if (*option == '+')
5855  break;
5856  i++;
5857  if (i == (ssize_t) argc)
5858  ThrowMogrifyException(OptionError,"MissingArgument",option);
5859  if (IsGeometry(argv[i]) == MagickFalse)
5860  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861  break;
5862  }
5863  if (LocaleCompare("rotate",option+1) == 0)
5864  {
5865  i++;
5866  if (i == (ssize_t) argc)
5867  ThrowMogrifyException(OptionError,"MissingArgument",option);
5868  if (IsGeometry(argv[i]) == MagickFalse)
5869  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5870  break;
5871  }
5872  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5873  }
5874  case 's':
5875  {
5876  if (LocaleCompare("sample",option+1) == 0)
5877  {
5878  if (*option == '+')
5879  break;
5880  i++;
5881  if (i == (ssize_t) argc)
5882  ThrowMogrifyException(OptionError,"MissingArgument",option);
5883  if (IsGeometry(argv[i]) == MagickFalse)
5884  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5885  break;
5886  }
5887  if (LocaleCompare("sampling-factor",option+1) == 0)
5888  {
5889  if (*option == '+')
5890  break;
5891  i++;
5892  if (i == (ssize_t) argc)
5893  ThrowMogrifyException(OptionError,"MissingArgument",option);
5894  if (IsGeometry(argv[i]) == MagickFalse)
5895  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5896  break;
5897  }
5898  if (LocaleCompare("scale",option+1) == 0)
5899  {
5900  if (*option == '+')
5901  break;
5902  i++;
5903  if (i == (ssize_t) argc)
5904  ThrowMogrifyException(OptionError,"MissingArgument",option);
5905  if (IsGeometry(argv[i]) == MagickFalse)
5906  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5907  break;
5908  }
5909  if (LocaleCompare("scene",option+1) == 0)
5910  {
5911  if (*option == '+')
5912  break;
5913  i++;
5914  if (i == (ssize_t) argc)
5915  ThrowMogrifyException(OptionError,"MissingArgument",option);
5916  if (IsGeometry(argv[i]) == MagickFalse)
5917  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5918  break;
5919  }
5920  if (LocaleCompare("seed",option+1) == 0)
5921  {
5922  if (*option == '+')
5923  break;
5924  i++;
5925  if (i == (ssize_t) argc)
5926  ThrowMogrifyException(OptionError,"MissingArgument",option);
5927  if (IsGeometry(argv[i]) == MagickFalse)
5928  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5929  break;
5930  }
5931  if (LocaleCompare("segment",option+1) == 0)
5932  {
5933  if (*option == '+')
5934  break;
5935  i++;
5936  if (i == (ssize_t) argc)
5937  ThrowMogrifyException(OptionError,"MissingArgument",option);
5938  if (IsGeometry(argv[i]) == MagickFalse)
5939  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5940  break;
5941  }
5942  if (LocaleCompare("selective-blur",option+1) == 0)
5943  {
5944  i++;
5945  if (i == (ssize_t) argc)
5946  ThrowMogrifyException(OptionError,"MissingArgument",option);
5947  if (IsGeometry(argv[i]) == MagickFalse)
5948  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5949  break;
5950  }
5951  if (LocaleCompare("separate",option+1) == 0)
5952  break;
5953  if (LocaleCompare("sepia-tone",option+1) == 0)
5954  {
5955  if (*option == '+')
5956  break;
5957  i++;
5958  if (i == (ssize_t) argc)
5959  ThrowMogrifyException(OptionError,"MissingArgument",option);
5960  if (IsGeometry(argv[i]) == MagickFalse)
5961  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5962  break;
5963  }
5964  if (LocaleCompare("set",option+1) == 0)
5965  {
5966  i++;
5967  if (i == (ssize_t) argc)
5968  ThrowMogrifyException(OptionError,"MissingArgument",option);
5969  if (*option == '+')
5970  break;
5971  i++;
5972  if (i == (ssize_t) argc)
5973  ThrowMogrifyException(OptionError,"MissingArgument",option);
5974  break;
5975  }
5976  if (LocaleCompare("shade",option+1) == 0)
5977  {
5978  i++;
5979  if (i == (ssize_t) argc)
5980  ThrowMogrifyException(OptionError,"MissingArgument",option);
5981  if (IsGeometry(argv[i]) == MagickFalse)
5982  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5983  break;
5984  }
5985  if (LocaleCompare("shadow",option+1) == 0)
5986  {
5987  if (*option == '+')
5988  break;
5989  i++;
5990  if (i == (ssize_t) argc)
5991  ThrowMogrifyException(OptionError,"MissingArgument",option);
5992  if (IsGeometry(argv[i]) == MagickFalse)
5993  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5994  break;
5995  }
5996  if (LocaleCompare("sharpen",option+1) == 0)
5997  {
5998  i++;
5999  if (i == (ssize_t) argc)
6000  ThrowMogrifyException(OptionError,"MissingArgument",option);
6001  if (IsGeometry(argv[i]) == MagickFalse)
6002  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6003  break;
6004  }
6005  if (LocaleCompare("shave",option+1) == 0)
6006  {
6007  if (*option == '+')
6008  break;
6009  i++;
6010  if (i == (ssize_t) argc)
6011  ThrowMogrifyException(OptionError,"MissingArgument",option);
6012  if (IsGeometry(argv[i]) == MagickFalse)
6013  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6014  break;
6015  }
6016  if (LocaleCompare("shear",option+1) == 0)
6017  {
6018  i++;
6019  if (i == (ssize_t) argc)
6020  ThrowMogrifyException(OptionError,"MissingArgument",option);
6021  if (IsGeometry(argv[i]) == MagickFalse)
6022  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6023  break;
6024  }
6025  if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
6026  {
6027  i++;
6028  if (i == (ssize_t) argc)
6029  ThrowMogrifyException(OptionError,"MissingArgument",option);
6030  if (IsGeometry(argv[i]) == MagickFalse)
6031  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6032  break;
6033  }
6034  if (LocaleCompare("size",option+1) == 0)
6035  {
6036  if (*option == '+')
6037  break;
6038  i++;
6039  if (i == (ssize_t) argc)
6040  ThrowMogrifyException(OptionError,"MissingArgument",option);
6041  if (IsGeometry(argv[i]) == MagickFalse)
6042  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6043  break;
6044  }
6045  if (LocaleCompare("sketch",option+1) == 0)
6046  {
6047  if (*option == '+')
6048  break;
6049  i++;
6050  if (i == (ssize_t) argc)
6051  ThrowMogrifyException(OptionError,"MissingArgument",option);
6052  if (IsGeometry(argv[i]) == MagickFalse)
6053  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6054  break;
6055  }
6056  if (LocaleCompare("smush",option+1) == 0)
6057  {
6058  i++;
6059  if (i == (ssize_t) argc)
6060  ThrowMogrifyException(OptionError,"MissingArgument",option);
6061  if (IsGeometry(argv[i]) == MagickFalse)
6062  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6063  i++;
6064  break;
6065  }
6066  if (LocaleCompare("solarize",option+1) == 0)
6067  {
6068  if (*option == '+')
6069  break;
6070  i++;
6071  if (i == (ssize_t) argc)
6072  ThrowMogrifyException(OptionError,"MissingArgument",option);
6073  if (IsGeometry(argv[i]) == MagickFalse)
6074  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6075  break;
6076  }
6077  if (LocaleCompare("sparse-color",option+1) == 0)
6078  {
6079  ssize_t
6080  op;
6081 
6082  i++;
6083  if (i == (ssize_t) argc)
6084  ThrowMogrifyException(OptionError,"MissingArgument",option);
6085  op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6086  if (op < 0)
6087  ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6088  argv[i]);
6089  i++;
6090  if (i == (ssize_t) argc)
6091  ThrowMogrifyException(OptionError,"MissingArgument",option);
6092  break;
6093  }
6094  if (LocaleCompare("splice",option+1) == 0)
6095  {
6096  if (*option == '+')
6097  break;
6098  i++;
6099  if (i == (ssize_t) argc)
6100  ThrowMogrifyException(OptionError,"MissingArgument",option);
6101  if (IsGeometry(argv[i]) == MagickFalse)
6102  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6103  break;
6104  }
6105  if (LocaleCompare("spread",option+1) == 0)
6106  {
6107  if (*option == '+')
6108  break;
6109  i++;
6110  if (i == (ssize_t) argc)
6111  ThrowMogrifyException(OptionError,"MissingArgument",option);
6112  if (IsGeometry(argv[i]) == MagickFalse)
6113  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6114  break;
6115  }
6116  if (LocaleCompare("statistic",option+1) == 0)
6117  {
6118  ssize_t
6119  op;
6120 
6121  if (*option == '+')
6122  break;
6123  i++;
6124  if (i == (ssize_t) argc)
6125  ThrowMogrifyException(OptionError,"MissingArgument",option);
6126  op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6127  if (op < 0)
6128  ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6129  argv[i]);
6130  i++;
6131  if (i == (ssize_t) argc)
6132  ThrowMogrifyException(OptionError,"MissingArgument",option);
6133  if (IsGeometry(argv[i]) == MagickFalse)
6134  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6135  break;
6136  }
6137  if (LocaleCompare("stretch",option+1) == 0)
6138  {
6139  ssize_t
6140  stretch;
6141 
6142  if (*option == '+')
6143  break;
6144  i++;
6145  if (i == (ssize_t) argc)
6146  ThrowMogrifyException(OptionError,"MissingArgument",option);
6147  stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6148  argv[i]);
6149  if (stretch < 0)
6150  ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6151  argv[i]);
6152  break;
6153  }
6154  if (LocaleCompare("strip",option+1) == 0)
6155  break;
6156  if (LocaleCompare("stroke",option+1) == 0)
6157  {
6158  if (*option == '+')
6159  break;
6160  i++;
6161  if (i == (ssize_t) argc)
6162  ThrowMogrifyException(OptionError,"MissingArgument",option);
6163  break;
6164  }
6165  if (LocaleCompare("strokewidth",option+1) == 0)
6166  {
6167  if (*option == '+')
6168  break;
6169  i++;
6170  if (i == (ssize_t) argc)
6171  ThrowMogrifyException(OptionError,"MissingArgument",option);
6172  if (IsGeometry(argv[i]) == MagickFalse)
6173  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6174  break;
6175  }
6176  if (LocaleCompare("style",option+1) == 0)
6177  {
6178  ssize_t
6179  style;
6180 
6181  if (*option == '+')
6182  break;
6183  i++;
6184  if (i == (ssize_t) argc)
6185  ThrowMogrifyException(OptionError,"MissingArgument",option);
6186  style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6187  if (style < 0)
6188  ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6189  argv[i]);
6190  break;
6191  }
6192  if (LocaleCompare("swap",option+1) == 0)
6193  {
6194  if (*option == '+')
6195  break;
6196  i++;
6197  if (i == (ssize_t) argc)
6198  ThrowMogrifyException(OptionError,"MissingArgument",option);
6199  if (IsGeometry(argv[i]) == MagickFalse)
6200  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6201  break;
6202  }
6203  if (LocaleCompare("swirl",option+1) == 0)
6204  {
6205  if (*option == '+')
6206  break;
6207  i++;
6208  if (i == (ssize_t) argc)
6209  ThrowMogrifyException(OptionError,"MissingArgument",option);
6210  if (IsGeometry(argv[i]) == MagickFalse)
6211  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6212  break;
6213  }
6214  if (LocaleCompare("synchronize",option+1) == 0)
6215  break;
6216  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6217  }
6218  case 't':
6219  {
6220  if (LocaleCompare("taint",option+1) == 0)
6221  break;
6222  if (LocaleCompare("texture",option+1) == 0)
6223  {
6224  if (*option == '+')
6225  break;
6226  i++;
6227  if (i == (ssize_t) argc)
6228  ThrowMogrifyException(OptionError,"MissingArgument",option);
6229  break;
6230  }
6231  if (LocaleCompare("tile",option+1) == 0)
6232  {
6233  if (*option == '+')
6234  break;
6235  i++;
6236  if (i == (ssize_t) argc)
6237  ThrowMogrifyException(OptionError,"MissingArgument",option);
6238  break;
6239  }
6240  if (LocaleCompare("tile-offset",option+1) == 0)
6241  {
6242  if (*option == '+')
6243  break;
6244  i++;
6245  if (i == (ssize_t) argc)
6246  ThrowMogrifyException(OptionError,"MissingArgument",option);
6247  if (IsGeometry(argv[i]) == MagickFalse)
6248  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6249  break;
6250  }
6251  if (LocaleCompare("tint",option+1) == 0)
6252  {
6253  if (*option == '+')
6254  break;
6255  i++;
6256  if (i == (ssize_t) argc)
6257  ThrowMogrifyException(OptionError,"MissingArgument",option);
6258  if (IsGeometry(argv[i]) == MagickFalse)
6259  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6260  break;
6261  }
6262  if (LocaleCompare("transform",option+1) == 0)
6263  break;
6264  if (LocaleCompare("transpose",option+1) == 0)
6265  break;
6266  if (LocaleCompare("transverse",option+1) == 0)
6267  break;
6268  if (LocaleCompare("threshold",option+1) == 0)
6269  {
6270  if (*option == '+')
6271  break;
6272  i++;
6273  if (i == (ssize_t) argc)
6274  ThrowMogrifyException(OptionError,"MissingArgument",option);
6275  if (IsGeometry(argv[i]) == MagickFalse)
6276  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6277  break;
6278  }
6279  if (LocaleCompare("thumbnail",option+1) == 0)
6280  {
6281  if (*option == '+')
6282  break;
6283  i++;
6284  if (i == (ssize_t) argc)
6285  ThrowMogrifyException(OptionError,"MissingArgument",option);
6286  if (IsGeometry(argv[i]) == MagickFalse)
6287  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6288  break;
6289  }
6290  if (LocaleCompare("transparent",option+1) == 0)
6291  {
6292  i++;
6293  if (i == (ssize_t) argc)
6294  ThrowMogrifyException(OptionError,"MissingArgument",option);
6295  break;
6296  }
6297  if (LocaleCompare("transparent-color",option+1) == 0)
6298  {
6299  if (*option == '+')
6300  break;
6301  i++;
6302  if (i == (ssize_t) argc)
6303  ThrowMogrifyException(OptionError,"MissingArgument",option);
6304  break;
6305  }
6306  if (LocaleCompare("treedepth",option+1) == 0)
6307  {
6308  if (*option == '+')
6309  break;
6310  i++;
6311  if (i == (ssize_t) argc)
6312  ThrowMogrifyException(OptionError,"MissingArgument",option);
6313  if (IsGeometry(argv[i]) == MagickFalse)
6314  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6315  break;
6316  }
6317  if (LocaleCompare("trim",option+1) == 0)
6318  break;
6319  if (LocaleCompare("type",option+1) == 0)
6320  {
6321  ssize_t
6322  type;
6323 
6324  if (*option == '+')
6325  break;
6326  i++;
6327  if (i == (ssize_t) argc)
6328  ThrowMogrifyException(OptionError,"MissingArgument",option);
6329  type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6330  if (type < 0)
6331  ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6332  argv[i]);
6333  break;
6334  }
6335  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6336  }
6337  case 'u':
6338  {
6339  if (LocaleCompare("undercolor",option+1) == 0)
6340  {
6341  if (*option == '+')
6342  break;
6343  i++;
6344  if (i == (ssize_t) argc)
6345  ThrowMogrifyException(OptionError,"MissingArgument",option);
6346  break;
6347  }
6348  if (LocaleCompare("unique-colors",option+1) == 0)
6349  break;
6350  if (LocaleCompare("units",option+1) == 0)
6351  {
6352  ssize_t
6353  units;
6354 
6355  if (*option == '+')
6356  break;
6357  i++;
6358  if (i == (ssize_t) argc)
6359  ThrowMogrifyException(OptionError,"MissingArgument",option);
6360  units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6361  argv[i]);
6362  if (units < 0)
6363  ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6364  argv[i]);
6365  break;
6366  }
6367  if (LocaleCompare("unsharp",option+1) == 0)
6368  {
6369  i++;
6370  if (i == (ssize_t) argc)
6371  ThrowMogrifyException(OptionError,"MissingArgument",option);
6372  if (IsGeometry(argv[i]) == MagickFalse)
6373  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6374  break;
6375  }
6376  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6377  }
6378  case 'v':
6379  {
6380  if (LocaleCompare("verbose",option+1) == 0)
6381  {
6382  image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6383  break;
6384  }
6385  if ((LocaleCompare("version",option+1) == 0) ||
6386  (LocaleCompare("-version",option+1) == 0))
6387  {
6388  ListMagickVersion(stdout);
6389  break;
6390  }
6391  if (LocaleCompare("vignette",option+1) == 0)
6392  {
6393  if (*option == '+')
6394  break;
6395  i++;
6396  if (i == (ssize_t) argc)
6397  ThrowMogrifyException(OptionError,"MissingArgument",option);
6398  if (IsGeometry(argv[i]) == MagickFalse)
6399  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6400  break;
6401  }
6402  if (LocaleCompare("virtual-pixel",option+1) == 0)
6403  {
6404  ssize_t
6405  method;
6406 
6407  if (*option == '+')
6408  break;
6409  i++;
6410  if (i == (ssize_t) argc)
6411  ThrowMogrifyException(OptionError,"MissingArgument",option);
6412  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6413  argv[i]);
6414  if (method < 0)
6415  ThrowMogrifyException(OptionError,
6416  "UnrecognizedVirtualPixelMethod",argv[i]);
6417  break;
6418  }
6419  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6420  }
6421  case 'w':
6422  {
6423  if (LocaleCompare("wave",option+1) == 0)
6424  {
6425  i++;
6426  if (i == (ssize_t) argc)
6427  ThrowMogrifyException(OptionError,"MissingArgument",option);
6428  if (IsGeometry(argv[i]) == MagickFalse)
6429  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6430  break;
6431  }
6432  if (LocaleCompare("wavelet-denoise",option+1) == 0)
6433  {
6434  i++;
6435  if (i == (ssize_t) argc)
6436  ThrowMogrifyException(OptionError,"MissingArgument",option);
6437  if (IsGeometry(argv[i]) == MagickFalse)
6438  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6439  break;
6440  }
6441  if (LocaleCompare("weight",option+1) == 0)
6442  {
6443  if (*option == '+')
6444  break;
6445  i++;
6446  if (i == (ssize_t) argc)
6447  ThrowMogrifyException(OptionError,"MissingArgument",option);
6448  break;
6449  }
6450  if (LocaleCompare("white-point",option+1) == 0)
6451  {
6452  if (*option == '+')
6453  break;
6454  i++;
6455  if (i == (ssize_t) argc)
6456  ThrowMogrifyException(OptionError,"MissingArgument",option);
6457  if (IsGeometry(argv[i]) == MagickFalse)
6458  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6459  break;
6460  }
6461  if (LocaleCompare("white-threshold",option+1) == 0)
6462  {
6463  if (*option == '+')
6464  break;
6465  i++;
6466  if (i == (ssize_t) argc)
6467  ThrowMogrifyException(OptionError,"MissingArgument",option);
6468  if (IsGeometry(argv[i]) == MagickFalse)
6469  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6470  break;
6471  }
6472  if (LocaleCompare("write",option+1) == 0)
6473  {
6474  i++;
6475  if (i == (ssize_t) argc)
6476  ThrowMogrifyException(OptionError,"MissingArgument",option);
6477  break;
6478  }
6479  if (LocaleCompare("write-mask",option+1) == 0)
6480  {
6481  if (*option == '+')
6482  break;
6483  i++;
6484  if (i == (ssize_t) argc)
6485  ThrowMogrifyException(OptionError,"MissingArgument",option);
6486  break;
6487  }
6488  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6489  }
6490  case '?':
6491  break;
6492  default:
6493  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6494  }
6495  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6496  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6497  if (fire != MagickFalse)
6498  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6499  }
6500  if (k != 0)
6501  ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6502  if (i != (ssize_t) argc)
6503  ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6504  DestroyMogrify();
6505  return(status != 0 ? MagickTrue : MagickFalse);
6506 }
6507 
6508 /*
6509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6510 % %
6511 % %
6512 % %
6513 + M o g r i f y I m a g e I n f o %
6514 % %
6515 % %
6516 % %
6517 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6518 %
6519 % MogrifyImageInfo() applies image processing settings to the image as
6520 % prescribed by command line options.
6521 %
6522 % The format of the MogrifyImageInfo method is:
6523 %
6524 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6525 % const char **argv,ExceptionInfo *exception)
6526 %
6527 % A description of each parameter follows:
6528 %
6529 % o image_info: the image info..
6530 %
6531 % o argc: Specifies a pointer to an integer describing the number of
6532 % elements in the argument vector.
6533 %
6534 % o argv: Specifies a pointer to a text array containing the command line
6535 % arguments.
6536 %
6537 % o exception: return any errors or warnings in this structure.
6538 %
6539 */
6540 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6541  const int argc,const char **argv,ExceptionInfo *exception)
6542 {
6543  const char
6544  *option;
6545 
6546  GeometryInfo
6547  geometry_info;
6548 
6549  ssize_t
6550  count;
6551 
6552  register ssize_t
6553  i;
6554 
6555  /*
6556  Initialize method variables.
6557  */
6558  assert(image_info != (ImageInfo *) NULL);
6559  assert(image_info->signature == MagickCoreSignature);
6560  if (image_info->debug != MagickFalse)
6561  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6562  image_info->filename);
6563  if (argc < 0)
6564  return(MagickTrue);
6565  /*
6566  Set the image settings.
6567  */
6568  for (i=0; i < (ssize_t) argc; i++)
6569  {
6570  option=argv[i];
6571  if (IsCommandOption(option) == MagickFalse)
6572  continue;
6573  count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6574  count=MagickMax(count,0L);
6575  if ((i+count) >= (ssize_t) argc)
6576  break;
6577  switch (*(option+1))
6578  {
6579  case 'a':
6580  {
6581  if (LocaleCompare("adjoin",option+1) == 0)
6582  {
6583  image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6584  break;
6585  }
6586  if (LocaleCompare("antialias",option+1) == 0)
6587  {
6588  image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6589  break;
6590  }
6591  if (LocaleCompare("authenticate",option+1) == 0)
6592  {
6593  if (*option == '+')
6594  (void) DeleteImageOption(image_info,option+1);
6595  else
6596  (void) SetImageOption(image_info,option+1,argv[i+1]);
6597  break;
6598  }
6599  break;
6600  }
6601  case 'b':
6602  {
6603  if (LocaleCompare("background",option+1) == 0)
6604  {
6605  if (*option == '+')
6606  {
6607  (void) DeleteImageOption(image_info,option+1);
6608  (void) QueryColorCompliance(MogrifyBackgroundColor,
6609  AllCompliance,&image_info->background_color,exception);
6610  break;
6611  }
6612  (void) SetImageOption(image_info,option+1,argv[i+1]);
6613  (void) QueryColorCompliance(argv[i+1],AllCompliance,
6614  &image_info->background_color,exception);
6615  break;
6616  }
6617  if (LocaleCompare("bias",option+1) == 0)
6618  {
6619  if (*option == '+')
6620  {
6621  (void) SetImageOption(image_info,"convolve:bias","0.0");
6622  break;
6623  }
6624  (void) SetImageOption(image_info,"convolve:bias",argv[i+1]);
6625  break;
6626  }
6627  if (LocaleCompare("black-point-compensation",option+1) == 0)
6628  {
6629  if (*option == '+')
6630  {
6631  (void) SetImageOption(image_info,option+1,"false");
6632  break;
6633  }
6634  (void) SetImageOption(image_info,option+1,"true");
6635  break;
6636  }
6637  if (LocaleCompare("blue-primary",option+1) == 0)
6638  {
6639  if (*option == '+')
6640  {
6641  (void) SetImageOption(image_info,option+1,"0.0");
6642  break;
6643  }
6644  (void) SetImageOption(image_info,option+1,argv[i+1]);
6645  break;
6646  }
6647  if (LocaleCompare("bordercolor",option+1) == 0)
6648  {
6649  if (*option == '+')
6650  {
6651  (void) DeleteImageOption(image_info,option+1);
6652  (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6653  &image_info->border_color,exception);
6654  break;
6655  }
6656  (void) QueryColorCompliance(argv[i+1],AllCompliance,
6657  &image_info->border_color,exception);
6658  (void) SetImageOption(image_info,option+1,argv[i+1]);
6659  break;
6660  }
6661  if (LocaleCompare("box",option+1) == 0)
6662  {
6663  if (*option == '+')
6664  {
6665  (void) SetImageOption(image_info,"undercolor","none");
6666  break;
6667  }
6668  (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6669  break;
6670  }
6671  break;
6672  }
6673  case 'c':
6674  {
6675  if (LocaleCompare("cache",option+1) == 0)
6676  {
6677  MagickSizeType
6678  limit;
6679 
6680  limit=MagickResourceInfinity;
6681  if (LocaleCompare("unlimited",argv[i+1]) != 0)
6682  limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6683  100.0);
6684  (void) SetMagickResourceLimit(MemoryResource,limit);
6685  (void) SetMagickResourceLimit(MapResource,2*limit);
6686  break;
6687  }
6688  if (LocaleCompare("caption",option+1) == 0)
6689  {
6690  if (*option == '+')
6691  {
6692  (void) DeleteImageOption(image_info,option+1);
6693  break;
6694  }
6695  (void) SetImageOption(image_info,option+1,argv[i+1]);
6696  break;
6697  }
6698  if (LocaleCompare("colorspace",option+1) == 0)
6699  {
6700  if (*option == '+')
6701  {
6702  image_info->colorspace=UndefinedColorspace;
6703  (void) SetImageOption(image_info,option+1,"undefined");
6704  break;
6705  }
6706  image_info->colorspace=(ColorspaceType) ParseCommandOption(
6707  MagickColorspaceOptions,MagickFalse,argv[i+1]);
6708  (void) SetImageOption(image_info,option+1,argv[i+1]);
6709  break;
6710  }
6711  if (LocaleCompare("comment",option+1) == 0)
6712  {
6713  if (*option == '+')
6714  {
6715  (void) DeleteImageOption(image_info,option+1);
6716  break;
6717  }
6718  (void) SetImageOption(image_info,option+1,argv[i+1]);
6719  break;
6720  }
6721  if (LocaleCompare("compose",option+1) == 0)
6722  {
6723  if (*option == '+')
6724  {
6725  (void) SetImageOption(image_info,option+1,"undefined");
6726  break;
6727  }
6728  (void) SetImageOption(image_info,option+1,argv[i+1]);
6729  break;
6730  }
6731  if (LocaleCompare("compress",option+1) == 0)
6732  {
6733  if (*option == '+')
6734  {
6735  image_info->compression=UndefinedCompression;
6736  (void) SetImageOption(image_info,option+1,"undefined");
6737  break;
6738  }
6739  image_info->compression=(CompressionType) ParseCommandOption(
6740  MagickCompressOptions,MagickFalse,argv[i+1]);
6741  (void) SetImageOption(image_info,option+1,argv[i+1]);
6742  break;
6743  }
6744  break;
6745  }
6746  case 'd':
6747  {
6748  if (LocaleCompare("debug",option+1) == 0)
6749  {
6750  if (*option == '+')
6751  (void) SetLogEventMask("none");
6752  else
6753  (void) SetLogEventMask(argv[i+1]);
6754  image_info->debug=IsEventLogging();
6755  break;
6756  }
6757  if (LocaleCompare("define",option+1) == 0)
6758  {
6759  if (*option == '+')
6760  {
6761  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6762  (void) DeleteImageRegistry(argv[i+1]+9);
6763  else
6764  (void) DeleteImageOption(image_info,argv[i+1]);
6765  break;
6766  }
6767  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6768  {
6769  (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6770  exception);
6771  break;
6772  }
6773  (void) DefineImageOption(image_info,argv[i+1]);
6774  break;
6775  }
6776  if (LocaleCompare("delay",option+1) == 0)
6777  {
6778  if (*option == '+')
6779  {
6780  (void) SetImageOption(image_info,option+1,"0");
6781  break;
6782  }
6783  (void) SetImageOption(image_info,option+1,argv[i+1]);
6784  break;
6785  }
6786  if (LocaleCompare("density",option+1) == 0)
6787  {
6788  /*
6789  Set image density.
6790  */
6791  if (*option == '+')
6792  {
6793  if (image_info->density != (char *) NULL)
6794  image_info->density=DestroyString(image_info->density);
6795  (void) SetImageOption(image_info,option+1,"72");
6796  break;
6797  }
6798  (void) CloneString(&image_info->density,argv[i+1]);
6799  (void) SetImageOption(image_info,option+1,argv[i+1]);
6800  break;
6801  }
6802  if (LocaleCompare("depth",option+1) == 0)
6803  {
6804  if (*option == '+')
6805  {
6806  image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6807  break;
6808  }
6809  image_info->depth=StringToUnsignedLong(argv[i+1]);
6810  break;
6811  }
6812  if (LocaleCompare("direction",option+1) == 0)
6813  {
6814  if (*option == '+')
6815  {
6816  (void) SetImageOption(image_info,option+1,"undefined");
6817  break;
6818  }
6819  (void) SetImageOption(image_info,option+1,argv[i+1]);
6820  break;
6821  }
6822  if (LocaleCompare("display",option+1) == 0)
6823  {
6824  if (*option == '+')
6825  {
6826  if (image_info->server_name != (char *) NULL)
6827  image_info->server_name=DestroyString(
6828  image_info->server_name);
6829  break;
6830  }
6831  (void) CloneString(&image_info->server_name,argv[i+1]);
6832  break;
6833  }
6834  if (LocaleCompare("dispose",option+1) == 0)
6835  {
6836  if (*option == '+')
6837  {
6838  (void) SetImageOption(image_info,option+1,"undefined");
6839  break;
6840  }
6841  (void) SetImageOption(image_info,option+1,argv[i+1]);
6842  break;
6843  }
6844  if (LocaleCompare("dither",option+1) == 0)
6845  {
6846  if (*option == '+')
6847  {
6848  image_info->dither=MagickFalse;
6849  (void) SetImageOption(image_info,option+1,"none");
6850  break;
6851  }
6852  (void) SetImageOption(image_info,option+1,argv[i+1]);
6853  image_info->dither=MagickTrue;
6854  break;
6855  }
6856  break;
6857  }
6858  case 'e':
6859  {
6860  if (LocaleCompare("encoding",option+1) == 0)
6861  {
6862  if (*option == '+')
6863  {
6864  (void) SetImageOption(image_info,option+1,"undefined");
6865  break;
6866  }
6867  (void) SetImageOption(image_info,option+1,argv[i+1]);
6868  break;
6869  }
6870  if (LocaleCompare("endian",option+1) == 0)
6871  {
6872  if (*option == '+')
6873  {
6874  image_info->endian=UndefinedEndian;
6875  (void) SetImageOption(image_info,option+1,"undefined");
6876  break;
6877  }
6878  image_info->endian=(EndianType) ParseCommandOption(
6879  MagickEndianOptions,MagickFalse,argv[i+1]);
6880  (void) SetImageOption(image_info,option+1,argv[i+1]);
6881  break;
6882  }
6883  if (LocaleCompare("extract",option+1) == 0)
6884  {
6885  /*
6886  Set image extract geometry.
6887  */
6888  if (*option == '+')
6889  {
6890  if (image_info->extract != (char *) NULL)
6891  image_info->extract=DestroyString(image_info->extract);
6892  break;
6893  }
6894  (void) CloneString(&image_info->extract,argv[i+1]);
6895  break;
6896  }
6897  break;
6898  }
6899  case 'f':
6900  {
6901  if (LocaleCompare("family",option+1) == 0)
6902  {
6903  if (*option != '+')
6904  (void) SetImageOption(image_info,option+1,argv[i+1]);
6905  break;
6906  }
6907  if (LocaleCompare("fill",option+1) == 0)
6908  {
6909  if (*option == '+')
6910  {
6911  (void) SetImageOption(image_info,option+1,"none");
6912  break;
6913  }
6914  (void) SetImageOption(image_info,option+1,argv[i+1]);
6915  break;
6916  }
6917  if (LocaleCompare("filter",option+1) == 0)
6918  {
6919  if (*option == '+')
6920  {
6921  (void) SetImageOption(image_info,option+1,"undefined");
6922  break;
6923  }
6924  (void) SetImageOption(image_info,option+1,argv[i+1]);
6925  break;
6926  }
6927  if (LocaleCompare("font",option+1) == 0)
6928  {
6929  if (*option == '+')
6930  {
6931  if (image_info->font != (char *) NULL)
6932  image_info->font=DestroyString(image_info->font);
6933  break;
6934  }
6935  (void) CloneString(&image_info->font,argv[i+1]);
6936  break;
6937  }
6938  if (LocaleCompare("format",option+1) == 0)
6939  {
6940  register const char
6941  *q;
6942 
6943  for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6944  if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6945  image_info->ping=MagickFalse;
6946  (void) SetImageOption(image_info,option+1,argv[i+1]);
6947  break;
6948  }
6949  if (LocaleCompare("fuzz",option+1) == 0)
6950  {
6951  if (*option == '+')
6952  {
6953  image_info->fuzz=0.0;
6954  (void) SetImageOption(image_info,option+1,"0");
6955  break;
6956  }
6957  image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6958  QuantumRange+1.0);
6959  (void) SetImageOption(image_info,option+1,argv[i+1]);
6960  break;
6961  }
6962  break;
6963  }
6964  case 'g':
6965  {
6966  if (LocaleCompare("gravity",option+1) == 0)
6967  {
6968  if (*option == '+')
6969  {
6970  (void) SetImageOption(image_info,option+1,"undefined");
6971  break;
6972  }
6973  (void) SetImageOption(image_info,option+1,argv[i+1]);
6974  break;
6975  }
6976  if (LocaleCompare("green-primary",option+1) == 0)
6977  {
6978  if (*option == '+')
6979  {
6980  (void) SetImageOption(image_info,option+1,"0.0");
6981  break;
6982  }
6983  (void) SetImageOption(image_info,option+1,argv[i+1]);
6984  break;
6985  }
6986  break;
6987  }
6988  case 'i':
6989  {
6990  if (LocaleCompare("intensity",option+1) == 0)
6991  {
6992  if (*option == '+')
6993  {
6994  (void) SetImageOption(image_info,option+1,"undefined");
6995  break;
6996  }
6997  (void) SetImageOption(image_info,option+1,argv[i+1]);
6998  break;
6999  }
7000  if (LocaleCompare("intent",option+1) == 0)
7001  {
7002  if (*option == '+')