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