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