MagickWand  7.1.1-43
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 @ 1999 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 similar 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/geometry-private.h"
60 #include "MagickCore/image-private.h"
61 #include "MagickCore/monitor-private.h"
62 #include "MagickCore/profile-private.h"
63 #include "MagickCore/string-private.h"
64 #include "MagickCore/thread-private.h"
65 #include "MagickCore/timer-private.h"
66 #include "MagickCore/utility-private.h"
67 
68 /*
69  Constant declaration.
70 */
71 static const char
72  MogrifyAlphaColor[] = "#bdbdbd", /* gray */
73  MogrifyBackgroundColor[] = "#ffffff", /* white */
74  MogrifyBorderColor[] = "#dfdfdf"; /* gray */
75 
76 /*
77  Define declarations.
78 */
79 #define UndefinedCompressionQuality 0UL
80 
81 /*
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 % %
84 % %
85 % %
86 + M o g r i f y I m a g e %
87 % %
88 % %
89 % %
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 %
92 % MogrifyImage() applies simple single image processing options to a single
93 % image that may be part of a large list, but also handles any 'region'
94 % image handling.
95 %
96 % The image in the list may be modified in three different ways...
97 %
98 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
99 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
100 % * replace by a list of images (only the -separate option!)
101 %
102 % In each case the result is returned into the list, and a pointer to the
103 % modified image (last image added if replaced by a list of images) is
104 % returned.
105 %
106 % ASIDE: The -crop is present but restricted to non-tile single image crops
107 %
108 % This means if all the images are being processed (such as by
109 % MogrifyImages(), next image to be processed will be as per the pointer
110 % (*image)->next. Also the image list may grow as a result of some specific
111 % operations but as images are never merged or deleted, it will never shrink
112 % in length. Typically the list will remain the same length.
113 %
114 % WARNING: As the image pointed to may be replaced, the first image in the
115 % list may also change. GetFirstImageInList() should be used by caller if
116 % they wish return the Image pointer to the first image in list.
117 %
118 %
119 % The format of the MogrifyImage method is:
120 %
121 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
122 % const char **argv,Image **image)
123 %
124 % A description of each parameter follows:
125 %
126 % o image_info: the image info..
127 %
128 % o argc: Specifies a pointer to an integer describing the number of
129 % elements in the argument vector.
130 %
131 % o argv: Specifies a pointer to a text array containing the command line
132 % arguments.
133 %
134 % o image: the image.
135 %
136 % o exception: return any errors or warnings in this structure.
137 %
138 */
139 
140 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
141  ExceptionInfo *exception)
142 {
143  char
144  key[MagickPathExtent];
145 
146  ExceptionInfo
147  *sans_exception;
148 
149  Image
150  *image;
151 
152  ImageInfo
153  *read_info;
154 
155  /*
156  Read an image into a image cache (for repeated usage) if not already in
157  cache. Then return the image that is in the cache.
158  */
159  (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",path);
160  sans_exception=AcquireExceptionInfo();
161  image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
162  sans_exception=DestroyExceptionInfo(sans_exception);
163  if (image != (Image *) NULL)
164  return(image);
165  read_info=CloneImageInfo(image_info);
166  (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
167  image=ReadImage(read_info,exception);
168  read_info=DestroyImageInfo(read_info);
169  if (image != (Image *) NULL)
170  (void) SetImageRegistry(ImageRegistryType,key,image,exception);
171  return(image);
172 }
173 
174 static inline MagickBooleanType IsPathWritable(const char *path)
175 {
176  if (IsPathAccessible(path) == MagickFalse)
177  return(MagickFalse);
178  if (access_utf8(path,W_OK) != 0)
179  return(MagickFalse);
180  return(MagickTrue);
181 }
182 
183 static MagickBooleanType MonitorProgress(const char *text,
184  const MagickOffsetType offset,const MagickSizeType extent,
185  void *wand_unused(client_data))
186 {
187  char
188  message[MagickPathExtent],
189  tag[MagickPathExtent];
190 
191  const char
192  *locale_message;
193 
194  char
195  *p;
196 
197  magick_unreferenced(client_data);
198 
199  if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
200  return(MagickTrue);
201  if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
202  return(MagickTrue);
203  (void) CopyMagickString(tag,text == (const char *) NULL ? "null" : text,
204  MagickPathExtent);
205  p=strrchr(tag,'/');
206  if (p != (char *) NULL)
207  *p='\0';
208  (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag);
209  locale_message=GetLocaleMessage(message);
210  if (locale_message == message)
211  locale_message=tag;
212  if (p == (char *) NULL)
213  (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
214  locale_message,(long) offset,(unsigned long) extent,(long)
215  (100.0*offset*PerceptibleReciprocal(extent-1.0)));
216  else
217  (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
218  locale_message,p+1,(long) offset,(unsigned long) extent,(long)
219  (100.0*offset*PerceptibleReciprocal(extent-1.0)));
220  if (offset == (MagickOffsetType) (extent-1))
221  (void) FormatLocaleFile(stderr,"\n");
222  (void) fflush(stderr);
223  return(MagickTrue);
224 }
225 
226 static Image *SparseColorOption(const Image *image,
227  const SparseColorMethod method,const char *arguments,
228  const MagickBooleanType color_from_image,ExceptionInfo *exception)
229 {
230  char
231  token[MagickPathExtent];
232 
233  const char
234  *p;
235 
236  double
237  *sparse_arguments;
238 
239  Image
240  *sparse_image;
241 
242  MagickBooleanType
243  error;
244 
245  PixelInfo
246  color;
247 
248  size_t
249  x;
250 
251  size_t
252  number_arguments,
253  number_colors;
254 
255  /*
256  SparseColorOption() parses the complex -sparse-color argument into an an
257  array of floating point values then calls SparseColorImage(). Argument is
258  a complex mix of floating-point pixel coordinates, and color specifications
259  (or direct floating point numbers). The number of floats needed to
260  represent a color varies depending on the current channel setting.
261  */
262  assert(image != (Image *) NULL);
263  assert(image->signature == MagickCoreSignature);
264  assert(exception != (ExceptionInfo *) NULL);
265  assert(exception->signature == MagickCoreSignature);
266  if (IsEventLogging() != MagickFalse)
267  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
268  /*
269  Limit channels according to image - and add up number of color channel.
270  */
271  number_colors=0;
272  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
273  number_colors++;
274  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
275  number_colors++;
276  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
277  number_colors++;
278  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
279  (image->colorspace == CMYKColorspace))
280  number_colors++;
281  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
282  (image->alpha_trait != UndefinedPixelTrait))
283  number_colors++;
284 
285  /*
286  Read string, to determine number of arguments needed,
287  */
288  p=arguments;
289  x=0;
290  while( *p != '\0' )
291  {
292  (void) GetNextToken(p,&p,MagickPathExtent,token);
293  if (*token == ',') continue;
294  if ( isalpha((int) ((unsigned char) *token)) || (*token == '#')) {
295  if ( color_from_image ) {
296  (void) ThrowMagickException(exception,GetMagickModule(),
297  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
298  "Color arg given, when colors are coming from image");
299  return( (Image *) NULL);
300  }
301  x += number_colors; /* color argument */
302  }
303  else {
304  x++; /* floating point argument */
305  }
306  }
307  error=MagickTrue;
308  if ( color_from_image ) {
309  /* just the control points are being given */
310  error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
311  number_arguments=(x/2)*(2+number_colors);
312  }
313  else {
314  /* control points and color values */
315  error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
316  number_arguments=x;
317  }
318  if ( error ) {
319  (void) ThrowMagickException(exception,GetMagickModule(),
320  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
321  "Invalid number of Arguments");
322  return( (Image *) NULL);
323  }
324 
325  /* Allocate and fill in the floating point arguments */
326  sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
327  sizeof(*sparse_arguments));
328  if (sparse_arguments == (double *) NULL) {
329  (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
330  " MemoryAllocationFailed\n""%s","SparseColorOption");
331  return( (Image *) NULL);
332  }
333  (void) memset(sparse_arguments,0,number_arguments*
334  sizeof(*sparse_arguments));
335  p=arguments;
336  x=0;
337  while ((*p != '\0') && (x < number_arguments))
338  {
339  /* X coordinate */
340  *token=',';
341  while (*token == ',')
342  (void) GetNextToken(p,&p,MagickPathExtent,token);
343  if (*token == '\0') break;
344  if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
345  {
346  (void) ThrowMagickException(exception,GetMagickModule(),
347  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
348  "Color found, instead of X-coord");
349  error=MagickTrue;
350  break;
351  }
352  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
353  /* Y coordinate */
354  *token=',';
355  while (*token == ',')
356  (void) GetNextToken(p,&p,MagickPathExtent,token);
357  if (*token == '\0')
358  break;
359  if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
360  {
361  (void) ThrowMagickException(exception,GetMagickModule(),
362  OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
363  "Color found, instead of Y-coord");
364  error = MagickTrue;
365  break;
366  }
367  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
368  /* color values for this control point */
369 #if 0
370  if ( (color_from_image ) {
371  /* get color from image */
372  /* HOW??? */
373  }
374  else
375 #endif
376  {
377  /* color name or function given in string argument */
378  *token=',';
379  while (*token == ',')
380  (void) GetNextToken(p,&p,MagickPathExtent,token);
381  if (*token == '\0')
382  break;
383  if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
384  {
385  /* Color string given */
386  (void) QueryColorCompliance(token,AllCompliance,&color,exception);
387  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
388  sparse_arguments[x++] = QuantumScale*color.red;
389  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
390  sparse_arguments[x++] = QuantumScale*color.green;
391  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
392  sparse_arguments[x++] = QuantumScale*color.blue;
393  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
394  (image->colorspace == CMYKColorspace))
395  sparse_arguments[x++] = QuantumScale*color.black;
396  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
397  (image->alpha_trait != UndefinedPixelTrait))
398  sparse_arguments[x++] = QuantumScale*color.alpha;
399  }
400  else {
401  /* Colors given as a set of floating point values - experimental */
402  /* NB: token contains the first floating point value to use! */
403  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
404  {
405  while (*token == ',')
406  (void) GetNextToken(p,&p,MagickPathExtent,token);
407  if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
408  (*token == '#'))
409  break;
410  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
411  *token = ','; /* used this token - get another */
412  }
413  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
414  {
415  while (*token == ',')
416  (void) GetNextToken(p,&p,MagickPathExtent,token);
417  if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
418  (*token == '#'))
419  break;
420  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
421  *token = ','; /* used this token - get another */
422  }
423  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
424  {
425  while (*token == ',')
426  (void) GetNextToken(p,&p,MagickPathExtent,token);
427  if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
428  (*token == '#'))
429  break;
430  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
431  *token = ','; /* used this token - get another */
432  }
433  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
434  (image->colorspace == CMYKColorspace))
435  {
436  while (*token == ',')
437  (void) GetNextToken(p,&p,MagickPathExtent,token);
438  if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
439  (*token == '#'))
440  break;
441  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
442  *token=','; /* used this token - get another */
443  }
444  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
445  (image->alpha_trait != UndefinedPixelTrait))
446  {
447  while (*token == ',')
448  (void) GetNextToken(p,&p,MagickPathExtent,token);
449  if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
450  (*token == '#'))
451  break;
452  sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
453  *token = ','; /* used this token - get another */
454  }
455  }
456  }
457  }
458  if ((number_arguments != x) && (!error))
459  {
460  (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
461  " InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
462  sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
463  return((Image *) NULL);
464  }
465  if (error)
466  return((Image *) NULL);
467  /*
468  Call the Interpolation function with the parsed arguments.
469  */
470  sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
471  exception);
472  sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
473  return( sparse_image );
474 }
475 
476 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
477  const char **argv,Image **image,ExceptionInfo *exception)
478 {
479  CompositeOperator
480  compose;
481 
482  const char
483  *format,
484  *option;
485 
486  double
487  attenuate;
488 
489  DrawInfo
490  *draw_info;
491 
492  GeometryInfo
493  geometry_info;
494 
495  ImageInfo
496  *mogrify_info;
497 
498  MagickStatusType
499  status;
500 
501  PixelInfo
502  fill;
503 
504  MagickStatusType
505  flags;
506 
507  PixelInterpolateMethod
508  interpolate_method;
509 
510  QuantizeInfo
511  *quantize_info;
512 
513  RectangleInfo
514  geometry,
515  region_geometry;
516 
517  ssize_t
518  i;
519 
520  /*
521  Initialize method variables.
522  */
523  assert(image_info != (const ImageInfo *) NULL);
524  assert(image_info->signature == MagickCoreSignature);
525  assert(image != (Image **) NULL);
526  assert((*image)->signature == MagickCoreSignature);
527  if (IsEventLogging() != MagickFalse)
528  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
529  if (argc < 0)
530  return(MagickTrue);
531  mogrify_info=CloneImageInfo(image_info);
532  draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
533  quantize_info=AcquireQuantizeInfo(mogrify_info);
534  SetGeometryInfo(&geometry_info);
535  GetPixelInfo(*image,&fill);
536  fill=(*image)->background_color;
537  attenuate=1.0;
538  compose=(*image)->compose;
539  interpolate_method=UndefinedInterpolatePixel;
540  format=GetImageOption(mogrify_info,"format");
541  SetGeometry(*image,&region_geometry);
542  /*
543  Transmogrify the image.
544  */
545  for (i=0; i < (ssize_t) argc; i++)
546  {
547  Image
548  *mogrify_image;
549 
550  ssize_t
551  count;
552 
553  option=argv[i];
554  if (IsCommandOption(option) == MagickFalse)
555  continue;
556  count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
557  0L);
558  if ((i+count) >= (ssize_t) argc)
559  break;
560  status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
561  mogrify_image=(Image *) NULL;
562  switch (*(option+1))
563  {
564  case 'a':
565  {
566  if (LocaleCompare("adaptive-blur",option+1) == 0)
567  {
568  /*
569  Adaptive blur image.
570  */
571  (void) SyncImageSettings(mogrify_info,*image,exception);
572  flags=ParseGeometry(argv[i+1],&geometry_info);
573  if ((flags & SigmaValue) == 0)
574  geometry_info.sigma=1.0;
575  mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
576  geometry_info.sigma,exception);
577  break;
578  }
579  if (LocaleCompare("adaptive-resize",option+1) == 0)
580  {
581  /*
582  Adaptive resize image.
583  */
584  (void) SyncImageSettings(mogrify_info,*image,exception);
585  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
586  mogrify_image=AdaptiveResizeImage(*image,geometry.width,
587  geometry.height,exception);
588  break;
589  }
590  if (LocaleCompare("adaptive-sharpen",option+1) == 0)
591  {
592  /*
593  Adaptive sharpen image.
594  */
595  (void) SyncImageSettings(mogrify_info,*image,exception);
596  flags=ParseGeometry(argv[i+1],&geometry_info);
597  if ((flags & SigmaValue) == 0)
598  geometry_info.sigma=1.0;
599  mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
600  geometry_info.sigma,exception);
601  break;
602  }
603  if (LocaleCompare("affine",option+1) == 0)
604  {
605  /*
606  Affine matrix.
607  */
608  if (*option == '+')
609  {
610  GetAffineMatrix(&draw_info->affine);
611  break;
612  }
613  (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
614  break;
615  }
616  if (LocaleCompare("alpha",option+1) == 0)
617  {
618  AlphaChannelOption
619  alpha_type;
620 
621  (void) SyncImageSettings(mogrify_info,*image,exception);
622  alpha_type=(AlphaChannelOption) ParseCommandOption(
623  MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
624  (void) SetImageAlphaChannel(*image,alpha_type,exception);
625  break;
626  }
627  if (LocaleCompare("annotate",option+1) == 0)
628  {
629  char
630  *text,
631  geometry_str[MagickPathExtent];
632 
633  /*
634  Annotate image.
635  */
636  (void) SyncImageSettings(mogrify_info,*image,exception);
637  SetGeometryInfo(&geometry_info);
638  flags=ParseGeometry(argv[i+1],&geometry_info);
639  if ((flags & SigmaValue) == 0)
640  geometry_info.sigma=geometry_info.rho;
641  text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
642  exception);
643  if (text == (char *) NULL)
644  break;
645  (void) CloneString(&draw_info->text,text);
646  text=DestroyString(text);
647  (void) FormatLocaleString(geometry_str,MagickPathExtent,"%+f%+f",
648  geometry_info.xi,geometry_info.psi);
649  (void) CloneString(&draw_info->geometry,geometry_str);
650  draw_info->affine.sx=cos(DegreesToRadians(
651  fmod(geometry_info.rho,360.0)));
652  draw_info->affine.rx=sin(DegreesToRadians(
653  fmod(geometry_info.rho,360.0)));
654  draw_info->affine.ry=(-sin(DegreesToRadians(
655  fmod(geometry_info.sigma,360.0))));
656  draw_info->affine.sy=cos(DegreesToRadians(
657  fmod(geometry_info.sigma,360.0)));
658  (void) AnnotateImage(*image,draw_info,exception);
659  break;
660  }
661  if (LocaleCompare("antialias",option+1) == 0)
662  {
663  draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
664  MagickFalse;
665  draw_info->text_antialias=(*option == '-') ? MagickTrue :
666  MagickFalse;
667  break;
668  }
669  if (LocaleCompare("attenuate",option+1) == 0)
670  {
671  if (*option == '+')
672  {
673  attenuate=1.0;
674  break;
675  }
676  attenuate=StringToDouble(argv[i+1],(char **) NULL);
677  break;
678  }
679  if (LocaleCompare("auto-gamma",option+1) == 0)
680  {
681  /*
682  Auto Adjust Gamma of image based on its mean.
683  */
684  (void) SyncImageSettings(mogrify_info,*image,exception);
685  (void) AutoGammaImage(*image,exception);
686  break;
687  }
688  if (LocaleCompare("auto-level",option+1) == 0)
689  {
690  /*
691  Perfectly Normalize (max/min stretch) the image.
692  */
693  (void) SyncImageSettings(mogrify_info,*image,exception);
694  (void) AutoLevelImage(*image,exception);
695  break;
696  }
697  if (LocaleCompare("auto-orient",option+1) == 0)
698  {
699  (void) SyncImageSettings(mogrify_info,*image,exception);
700  mogrify_image=AutoOrientImage(*image,(*image)->orientation,
701  exception);
702  break;
703  }
704  if (LocaleCompare("auto-threshold",option+1) == 0)
705  {
706  AutoThresholdMethod
707  method;
708 
709  (void) SyncImageSettings(mogrify_info,*image,exception);
710  method=(AutoThresholdMethod) ParseCommandOption(
711  MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
712  (void) AutoThresholdImage(*image,method,exception);
713  break;
714  }
715  break;
716  }
717  case 'b':
718  {
719  if (LocaleCompare("bilateral-blur",option+1) == 0)
720  {
721  /*
722  Bilateral filter image.
723  */
724  (void) SyncImageSettings(mogrify_info,*image,exception);
725  flags=ParseGeometry(argv[i+1],&geometry_info);
726  if ((flags & SigmaValue) == 0)
727  geometry_info.sigma=geometry_info.rho;
728  if ((flags & XiValue) == 0)
729  geometry_info.xi=1.0*sqrt(geometry_info.rho*geometry_info.rho+
730  geometry_info.sigma*geometry_info.sigma);
731  if ((flags & PsiValue) == 0)
732  geometry_info.psi=0.25*sqrt(geometry_info.rho*geometry_info.rho+
733  geometry_info.sigma*geometry_info.sigma);
734  mogrify_image=BilateralBlurImage(*image,(size_t) geometry_info.rho,
735  (size_t) geometry_info.sigma,geometry_info.xi,geometry_info.psi,
736  exception);
737  break;
738  }
739  if (LocaleCompare("black-threshold",option+1) == 0)
740  {
741  /*
742  Black threshold image.
743  */
744  (void) SyncImageSettings(mogrify_info,*image,exception);
745  (void) BlackThresholdImage(*image,argv[i+1],exception);
746  break;
747  }
748  if (LocaleCompare("blue-shift",option+1) == 0)
749  {
750  /*
751  Blue shift image.
752  */
753  (void) SyncImageSettings(mogrify_info,*image,exception);
754  geometry_info.rho=1.5;
755  if (*option == '-')
756  flags=ParseGeometry(argv[i+1],&geometry_info);
757  mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
758  break;
759  }
760  if (LocaleCompare("blur",option+1) == 0)
761  {
762  /*
763  Gaussian blur image.
764  */
765  (void) SyncImageSettings(mogrify_info,*image,exception);
766  flags=ParseGeometry(argv[i+1],&geometry_info);
767  if ((flags & SigmaValue) == 0)
768  geometry_info.sigma=1.0;
769  if ((flags & XiValue) == 0)
770  geometry_info.xi=0.0;
771  mogrify_image=BlurImage(*image,geometry_info.rho,
772  geometry_info.sigma,exception);
773  break;
774  }
775  if (LocaleCompare("border",option+1) == 0)
776  {
777  /*
778  Surround image with a border of solid color.
779  */
780  (void) SyncImageSettings(mogrify_info,*image,exception);
781  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
782  mogrify_image=BorderImage(*image,&geometry,compose,exception);
783  break;
784  }
785  if (LocaleCompare("bordercolor",option+1) == 0)
786  {
787  if (*option == '+')
788  {
789  (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
790  &draw_info->border_color,exception);
791  break;
792  }
793  (void) QueryColorCompliance(argv[i+1],AllCompliance,
794  &draw_info->border_color,exception);
795  break;
796  }
797  if (LocaleCompare("box",option+1) == 0)
798  {
799  (void) QueryColorCompliance(argv[i+1],AllCompliance,
800  &draw_info->undercolor,exception);
801  break;
802  }
803  if (LocaleCompare("brightness-contrast",option+1) == 0)
804  {
805  double
806  brightness,
807  contrast;
808 
809  /*
810  Brightness / contrast image.
811  */
812  (void) SyncImageSettings(mogrify_info,*image,exception);
813  flags=ParseGeometry(argv[i+1],&geometry_info);
814  brightness=geometry_info.rho;
815  contrast=0.0;
816  if ((flags & SigmaValue) != 0)
817  contrast=geometry_info.sigma;
818  (void) BrightnessContrastImage(*image,brightness,contrast,
819  exception);
820  break;
821  }
822  break;
823  }
824  case 'c':
825  {
826  if (LocaleCompare("canny",option+1) == 0)
827  {
828  /*
829  Detect edges in the image.
830  */
831  (void) SyncImageSettings(mogrify_info,*image,exception);
832  flags=ParseGeometry(argv[i+1],&geometry_info);
833  if ((flags & SigmaValue) == 0)
834  geometry_info.sigma=1.0;
835  if ((flags & XiValue) == 0)
836  geometry_info.xi=0.10;
837  if ((flags & PsiValue) == 0)
838  geometry_info.psi=0.30;
839  if ((flags & PercentValue) != 0)
840  {
841  geometry_info.xi/=100.0;
842  geometry_info.psi/=100.0;
843  }
844  mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
845  geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
846  break;
847  }
848  if (LocaleCompare("cdl",option+1) == 0)
849  {
850  char
851  *color_correction_collection;
852 
853  /*
854  Color correct with a color decision list.
855  */
856  (void) SyncImageSettings(mogrify_info,*image,exception);
857  color_correction_collection=FileToString(argv[i+1],~0UL,exception);
858  if (color_correction_collection == (char *) NULL)
859  break;
860  (void) ColorDecisionListImage(*image,color_correction_collection,
861  exception);
862  break;
863  }
864  if (LocaleCompare("channel",option+1) == 0)
865  {
866  ChannelType
867  channel;
868 
869  (void) SyncImageSettings(mogrify_info,*image,exception);
870  if (*option == '+')
871  {
872  (void) SetPixelChannelMask(*image,DefaultChannels);
873  break;
874  }
875  channel=(ChannelType) ParseChannelOption(argv[i+1]);
876  (void) SetPixelChannelMask(*image,channel);
877  break;
878  }
879  if (LocaleCompare("charcoal",option+1) == 0)
880  {
881  /*
882  Charcoal image.
883  */
884  (void) SyncImageSettings(mogrify_info,*image,exception);
885  flags=ParseGeometry(argv[i+1],&geometry_info);
886  if ((flags & SigmaValue) == 0)
887  geometry_info.sigma=1.0;
888  if ((flags & XiValue) == 0)
889  geometry_info.xi=1.0;
890  mogrify_image=CharcoalImage(*image,geometry_info.rho,
891  geometry_info.sigma,exception);
892  break;
893  }
894  if (LocaleCompare("chop",option+1) == 0)
895  {
896  /*
897  Chop the image.
898  */
899  (void) SyncImageSettings(mogrify_info,*image,exception);
900  (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
901  mogrify_image=ChopImage(*image,&geometry,exception);
902  break;
903  }
904  if (LocaleCompare("clahe",option+1) == 0)
905  {
906  /*
907  Contrast limited adaptive histogram equalization.
908  */
909  (void) SyncImageSettings(mogrify_info,*image,exception);
910  flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
911  flags=ParseGeometry(argv[i+1],&geometry_info);
912  (void) CLAHEImage(*image,geometry.width,geometry.height,
913  (size_t) geometry.x,geometry_info.psi,exception);
914  break;
915  }
916  if (LocaleCompare("clip",option+1) == 0)
917  {
918  (void) SyncImageSettings(mogrify_info,*image,exception);
919  if (*option == '+')
920  {
921  (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
922  exception);
923  break;
924  }
925  (void) ClipImage(*image,exception);
926  break;
927  }
928  if (LocaleCompare("clip-mask",option+1) == 0)
929  {
930  Image
931  *clip_mask;
932 
933  (void) SyncImageSettings(mogrify_info,*image,exception);
934  if (*option == '+')
935  {
936  /*
937  Remove a mask.
938  */
939  (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
940  exception);
941  break;
942  }
943  /*
944  Set the image mask.
945  */
946  clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
947  if (clip_mask == (Image *) NULL)
948  break;
949  (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
950  clip_mask=DestroyImage(clip_mask);
951  break;
952  }
953  if (LocaleCompare("clip-path",option+1) == 0)
954  {
955  (void) SyncImageSettings(mogrify_info,*image,exception);
956  (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
957  MagickFalse,exception);
958  break;
959  }
960  if (LocaleCompare("colorize",option+1) == 0)
961  {
962  /*
963  Colorize the image.
964  */
965  (void) SyncImageSettings(mogrify_info,*image,exception);
966  mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
967  break;
968  }
969  if (LocaleCompare("color-matrix",option+1) == 0)
970  {
971  KernelInfo
972  *kernel;
973 
974  (void) SyncImageSettings(mogrify_info,*image,exception);
975  kernel=AcquireKernelInfo(argv[i+1],exception);
976  if (kernel == (KernelInfo *) NULL)
977  break;
978  /* FUTURE: check on size of the matrix */
979  mogrify_image=ColorMatrixImage(*image,kernel,exception);
980  kernel=DestroyKernelInfo(kernel);
981  break;
982  }
983  if (LocaleCompare("colors",option+1) == 0)
984  {
985  /*
986  Reduce the number of colors in the image.
987  */
988  (void) SyncImageSettings(mogrify_info,*image,exception);
989  quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
990  if (quantize_info->number_colors == 0)
991  break;
992  if (((*image)->storage_class == DirectClass) ||
993  (*image)->colors > quantize_info->number_colors)
994  (void) QuantizeImage(quantize_info,*image,exception);
995  else
996  (void) CompressImageColormap(*image,exception);
997  break;
998  }
999  if (LocaleCompare("colorspace",option+1) == 0)
1000  {
1001  ColorspaceType
1002  colorspace;
1003 
1004  (void) SyncImageSettings(mogrify_info,*image,exception);
1005  if (*option == '+')
1006  {
1007  (void) TransformImageColorspace(*image,sRGBColorspace,
1008  exception);
1009  break;
1010  }
1011  colorspace=(ColorspaceType) ParseCommandOption(
1012  MagickColorspaceOptions,MagickFalse,argv[i+1]);
1013  (void) TransformImageColorspace(*image,colorspace,exception);
1014  break;
1015  }
1016  if (LocaleCompare("color-threshold",option+1) == 0)
1017  {
1018  PixelInfo
1019  start,
1020  stop;
1021 
1022  /*
1023  Color threshold image.
1024  */
1025  (void) SyncImageSettings(mogrify_info,*image,exception);
1026  if (*option == '+')
1027  (void) GetColorRange("white-black",&start,&stop,exception);
1028  else
1029  (void) GetColorRange(argv[i+1],&start,&stop,exception);
1030  (void) ColorThresholdImage(*image,&start,&stop,exception);
1031  break;
1032  }
1033  if (LocaleCompare("compose",option+1) == 0)
1034  {
1035  (void) SyncImageSettings(mogrify_info,*image,exception);
1036  compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1037  MagickFalse,argv[i+1]);
1038  break;
1039  }
1040  if (LocaleCompare("connected-components",option+1) == 0)
1041  {
1042  (void) SyncImageSettings(mogrify_info,*image,exception);
1043  mogrify_image=ConnectedComponentsImage(*image,(size_t)
1044  StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1045  break;
1046  }
1047  if (LocaleCompare("contrast",option+1) == 0)
1048  {
1049  (void) SyncImageSettings(mogrify_info,*image,exception);
1050  (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1051  MagickFalse,exception);
1052  break;
1053  }
1054  if (LocaleCompare("contrast-stretch",option+1) == 0)
1055  {
1056  double
1057  black_point,
1058  white_point;
1059 
1060  /*
1061  Contrast stretch image.
1062  */
1063  (void) SyncImageSettings(mogrify_info,*image,exception);
1064  flags=ParseGeometry(argv[i+1],&geometry_info);
1065  black_point=geometry_info.rho;
1066  white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1067  black_point;
1068  if ((flags & PercentValue) != 0)
1069  {
1070  black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1071  white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1072  }
1073  white_point=(double) (*image)->columns*(*image)->rows-
1074  white_point;
1075  (void) ContrastStretchImage(*image,black_point,white_point,
1076  exception);
1077  break;
1078  }
1079  if (LocaleCompare("convolve",option+1) == 0)
1080  {
1081  double
1082  gamma;
1083 
1084  KernelInfo
1085  *kernel_info;
1086 
1087  ssize_t
1088  j;
1089 
1090  size_t
1091  extent;
1092 
1093  (void) SyncImageSettings(mogrify_info,*image,exception);
1094  kernel_info=AcquireKernelInfo(argv[i+1],exception);
1095  if (kernel_info == (KernelInfo *) NULL)
1096  break;
1097  extent=kernel_info->width*kernel_info->height;
1098  gamma=0.0;
1099  for (j=0; j < (ssize_t) extent; j++)
1100  gamma+=kernel_info->values[j];
1101  gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1102  for (j=0; j < (ssize_t) extent; j++)
1103  kernel_info->values[j]*=gamma;
1104  mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1105  kernel_info,exception);
1106  kernel_info=DestroyKernelInfo(kernel_info);
1107  break;
1108  }
1109  if (LocaleCompare("crop",option+1) == 0)
1110  {
1111  /*
1112  Crop a image to a smaller size
1113  */
1114  (void) SyncImageSettings(mogrify_info,*image,exception);
1115  mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1116  break;
1117  }
1118  if (LocaleCompare("cycle",option+1) == 0)
1119  {
1120  /*
1121  Cycle an image colormap.
1122  */
1123  (void) SyncImageSettings(mogrify_info,*image,exception);
1124  (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1125  exception);
1126  break;
1127  }
1128  break;
1129  }
1130  case 'd':
1131  {
1132  if (LocaleCompare("decipher",option+1) == 0)
1133  {
1134  StringInfo
1135  *passkey;
1136 
1137  /*
1138  Decipher pixels.
1139  */
1140  (void) SyncImageSettings(mogrify_info,*image,exception);
1141  passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1142  if (passkey != (StringInfo *) NULL)
1143  {
1144  (void) PasskeyDecipherImage(*image,passkey,exception);
1145  passkey=DestroyStringInfo(passkey);
1146  }
1147  break;
1148  }
1149  if (LocaleCompare("density",option+1) == 0)
1150  {
1151  /*
1152  Set image density.
1153  */
1154  (void) CloneString(&draw_info->density,argv[i+1]);
1155  break;
1156  }
1157  if (LocaleCompare("depth",option+1) == 0)
1158  {
1159  (void) SyncImageSettings(mogrify_info,*image,exception);
1160  if (*option == '+')
1161  {
1162  (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1163  break;
1164  }
1165  (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1166  exception);
1167  break;
1168  }
1169  if (LocaleCompare("deskew",option+1) == 0)
1170  {
1171  double
1172  threshold;
1173 
1174  /*
1175  Straighten the image.
1176  */
1177  (void) SyncImageSettings(mogrify_info,*image,exception);
1178  if (*option == '+')
1179  threshold=40.0*(double) QuantumRange/100.0;
1180  else
1181  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1182  1.0);
1183  mogrify_image=DeskewImage(*image,threshold,exception);
1184  break;
1185  }
1186  if (LocaleCompare("despeckle",option+1) == 0)
1187  {
1188  /*
1189  Reduce the speckles within an image.
1190  */
1191  (void) SyncImageSettings(mogrify_info,*image,exception);
1192  mogrify_image=DespeckleImage(*image,exception);
1193  break;
1194  }
1195  if (LocaleCompare("display",option+1) == 0)
1196  {
1197  (void) CloneString(&draw_info->server_name,argv[i+1]);
1198  break;
1199  }
1200  if (LocaleCompare("distort",option+1) == 0)
1201  {
1202  char
1203  *args,
1204  token[MagickPathExtent];
1205 
1206  const char
1207  *p;
1208 
1209  DistortMethod
1210  method;
1211 
1212  double
1213  *arguments;
1214 
1215  ssize_t
1216  x;
1217 
1218  size_t
1219  number_arguments;
1220 
1221  /*
1222  Distort image.
1223  */
1224  (void) SyncImageSettings(mogrify_info,*image,exception);
1225  method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1226  MagickFalse,argv[i+1]);
1227  if (method == ResizeDistortion)
1228  {
1229  double
1230  resize_args[2];
1231 
1232  /*
1233  Special Case - Argument is actually a resize geometry!
1234  Convert that to an appropriate distortion argument array.
1235  */
1236  (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1237  exception);
1238  resize_args[0]=(double) geometry.width;
1239  resize_args[1]=(double) geometry.height;
1240  mogrify_image=DistortImage(*image,method,(size_t)2,
1241  resize_args,MagickTrue,exception);
1242  break;
1243  }
1244  args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1245  exception);
1246  if (args == (char *) NULL)
1247  break;
1248  p=(char *) args;
1249  for (x=0; *p != '\0'; x++)
1250  {
1251  (void) GetNextToken(p,&p,MagickPathExtent,token);
1252  if (*token == ',')
1253  (void) GetNextToken(p,&p,MagickPathExtent,token);
1254  }
1255  number_arguments=(size_t) x;
1256  arguments=(double *) AcquireQuantumMemory(number_arguments,
1257  sizeof(*arguments));
1258  if (arguments == (double *) NULL)
1259  ThrowWandFatalException(ResourceLimitFatalError,
1260  "MemoryAllocationFailed",(*image)->filename);
1261  (void) memset(arguments,0,number_arguments*
1262  sizeof(*arguments));
1263  p=(char *) args;
1264  for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1265  {
1266  (void) GetNextToken(p,&p,MagickPathExtent,token);
1267  if (*token == ',')
1268  (void) GetNextToken(p,&p,MagickPathExtent,token);
1269  arguments[x]=StringToDouble(token,(char **) NULL);
1270  }
1271  args=DestroyString(args);
1272  mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1273  (*option == '+') ? MagickTrue : MagickFalse,exception);
1274  arguments=(double *) RelinquishMagickMemory(arguments);
1275  break;
1276  }
1277  if (LocaleCompare("dither",option+1) == 0)
1278  {
1279  if (*option == '+')
1280  {
1281  quantize_info->dither_method=NoDitherMethod;
1282  break;
1283  }
1284  quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1285  MagickDitherOptions,MagickFalse,argv[i+1]);
1286  break;
1287  }
1288  if (LocaleCompare("draw",option+1) == 0)
1289  {
1290  /*
1291  Draw image.
1292  */
1293  (void) SyncImageSettings(mogrify_info,*image,exception);
1294  (void) CloneString(&draw_info->primitive,argv[i+1]);
1295  (void) DrawImage(*image,draw_info,exception);
1296  break;
1297  }
1298  break;
1299  }
1300  case 'e':
1301  {
1302  if (LocaleCompare("edge",option+1) == 0)
1303  {
1304  /*
1305  Enhance edges in the image.
1306  */
1307  (void) SyncImageSettings(mogrify_info,*image,exception);
1308  flags=ParseGeometry(argv[i+1],&geometry_info);
1309  mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1310  break;
1311  }
1312  if (LocaleCompare("emboss",option+1) == 0)
1313  {
1314  /*
1315  Emboss image.
1316  */
1317  (void) SyncImageSettings(mogrify_info,*image,exception);
1318  flags=ParseGeometry(argv[i+1],&geometry_info);
1319  if ((flags & SigmaValue) == 0)
1320  geometry_info.sigma=1.0;
1321  mogrify_image=EmbossImage(*image,geometry_info.rho,
1322  geometry_info.sigma,exception);
1323  break;
1324  }
1325  if (LocaleCompare("encipher",option+1) == 0)
1326  {
1327  StringInfo
1328  *passkey;
1329 
1330  /*
1331  Encipher pixels.
1332  */
1333  (void) SyncImageSettings(mogrify_info,*image,exception);
1334  passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1335  if (passkey != (StringInfo *) NULL)
1336  {
1337  (void) PasskeyEncipherImage(*image,passkey,exception);
1338  passkey=DestroyStringInfo(passkey);
1339  }
1340  break;
1341  }
1342  if (LocaleCompare("encoding",option+1) == 0)
1343  {
1344  (void) CloneString(&draw_info->encoding,argv[i+1]);
1345  break;
1346  }
1347  if (LocaleCompare("enhance",option+1) == 0)
1348  {
1349  /*
1350  Enhance image.
1351  */
1352  (void) SyncImageSettings(mogrify_info,*image,exception);
1353  mogrify_image=EnhanceImage(*image,exception);
1354  break;
1355  }
1356  if (LocaleCompare("equalize",option+1) == 0)
1357  {
1358  /*
1359  Equalize image.
1360  */
1361  (void) SyncImageSettings(mogrify_info,*image,exception);
1362  (void) EqualizeImage(*image,exception);
1363  break;
1364  }
1365  if (LocaleCompare("evaluate",option+1) == 0)
1366  {
1367  double
1368  constant;
1369 
1370  MagickEvaluateOperator
1371  op;
1372 
1373  (void) SyncImageSettings(mogrify_info,*image,exception);
1374  op=(MagickEvaluateOperator) ParseCommandOption(
1375  MagickEvaluateOptions,MagickFalse,argv[i+1]);
1376  constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1377  1.0);
1378  (void) EvaluateImage(*image,op,constant,exception);
1379  break;
1380  }
1381  if (LocaleCompare("extent",option+1) == 0)
1382  {
1383  /*
1384  Set the image extent.
1385  */
1386  (void) SyncImageSettings(mogrify_info,*image,exception);
1387  flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1388  if (geometry.width == 0)
1389  geometry.width=(*image)->columns;
1390  if (geometry.height == 0)
1391  geometry.height=(*image)->rows;
1392  mogrify_image=ExtentImage(*image,&geometry,exception);
1393  break;
1394  }
1395  break;
1396  }
1397  case 'f':
1398  {
1399  if (LocaleCompare("family",option+1) == 0)
1400  {
1401  if (*option == '+')
1402  {
1403  if (draw_info->family != (char *) NULL)
1404  draw_info->family=DestroyString(draw_info->family);
1405  break;
1406  }
1407  (void) SetImageOption(image_info,option+1,argv[i+1]);
1408  (void) CloneString(&draw_info->family,argv[i+1]);
1409  break;
1410  }
1411  if (LocaleCompare("features",option+1) == 0)
1412  {
1413  if (*option == '+')
1414  {
1415  (void) DeleteImageArtifact(*image,"identify:features");
1416  break;
1417  }
1418  (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1419  (void) SetImageArtifact(*image,"verbose","true");
1420  break;
1421  }
1422  if (LocaleCompare("fill",option+1) == 0)
1423  {
1424  ExceptionInfo
1425  *sans;
1426 
1427  PixelInfo
1428  color;
1429 
1430  GetPixelInfo(*image,&fill);
1431  if (*option == '+')
1432  {
1433  (void) QueryColorCompliance("none",AllCompliance,&fill,
1434  exception);
1435  draw_info->fill=fill;
1436  if (draw_info->fill_pattern != (Image *) NULL)
1437  draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1438  break;
1439  }
1440  sans=AcquireExceptionInfo();
1441  status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1442  sans=DestroyExceptionInfo(sans);
1443  if (status == MagickFalse)
1444  draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1445  exception);
1446  else
1447  draw_info->fill=fill=color;
1448  break;
1449  }
1450  if (LocaleCompare("flip",option+1) == 0)
1451  {
1452  /*
1453  Flip image scanlines.
1454  */
1455  (void) SyncImageSettings(mogrify_info,*image,exception);
1456  mogrify_image=FlipImage(*image,exception);
1457  break;
1458  }
1459  if (LocaleCompare("floodfill",option+1) == 0)
1460  {
1461  PixelInfo
1462  target;
1463 
1464  /*
1465  Floodfill image.
1466  */
1467  (void) SyncImageSettings(mogrify_info,*image,exception);
1468  (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1469  (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1470  exception);
1471  (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1472  geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1473  break;
1474  }
1475  if (LocaleCompare("flop",option+1) == 0)
1476  {
1477  /*
1478  Flop image scanlines.
1479  */
1480  (void) SyncImageSettings(mogrify_info,*image,exception);
1481  mogrify_image=FlopImage(*image,exception);
1482  break;
1483  }
1484  if (LocaleCompare("font",option+1) == 0)
1485  {
1486  if (*option == '+')
1487  {
1488  if (draw_info->font != (char *) NULL)
1489  draw_info->font=DestroyString(draw_info->font);
1490  break;
1491  }
1492  (void) CloneString(&draw_info->font,argv[i+1]);
1493  break;
1494  }
1495  if (LocaleCompare("format",option+1) == 0)
1496  {
1497  format=argv[i+1];
1498  break;
1499  }
1500  if (LocaleCompare("frame",option+1) == 0)
1501  {
1502  FrameInfo
1503  frame_info;
1504 
1505  /*
1506  Surround image with an ornamental border.
1507  */
1508  (void) SyncImageSettings(mogrify_info,*image,exception);
1509  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1510  frame_info.width=geometry.width;
1511  frame_info.height=geometry.height;
1512  frame_info.outer_bevel=geometry.x;
1513  frame_info.inner_bevel=geometry.y;
1514  frame_info.x=(ssize_t) frame_info.width;
1515  frame_info.y=(ssize_t) frame_info.height;
1516  frame_info.width=(*image)->columns+2*frame_info.width;
1517  frame_info.height=(*image)->rows+2*frame_info.height;
1518  mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1519  break;
1520  }
1521  if (LocaleCompare("function",option+1) == 0)
1522  {
1523  char
1524  *arguments,
1525  token[MagickPathExtent];
1526 
1527  const char
1528  *p;
1529 
1530  double
1531  *parameters;
1532 
1533  MagickFunction
1534  function;
1535 
1536  ssize_t
1537  x;
1538 
1539  size_t
1540  number_parameters;
1541 
1542  /*
1543  Function Modify Image Values
1544  */
1545  (void) SyncImageSettings(mogrify_info,*image,exception);
1546  function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1547  MagickFalse,argv[i+1]);
1548  arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1549  exception);
1550  if (arguments == (char *) NULL)
1551  break;
1552  p=(char *) arguments;
1553  for (x=0; *p != '\0'; x++)
1554  {
1555  (void) GetNextToken(p,&p,MagickPathExtent,token);
1556  if (*token == ',')
1557  (void) GetNextToken(p,&p,MagickPathExtent,token);
1558  }
1559  number_parameters=(size_t) x;
1560  parameters=(double *) AcquireQuantumMemory(number_parameters,
1561  sizeof(*parameters));
1562  if (parameters == (double *) NULL)
1563  ThrowWandFatalException(ResourceLimitFatalError,
1564  "MemoryAllocationFailed",(*image)->filename);
1565  (void) memset(parameters,0,number_parameters*
1566  sizeof(*parameters));
1567  p=(char *) arguments;
1568  for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1569  {
1570  (void) GetNextToken(p,&p,MagickPathExtent,token);
1571  if (*token == ',')
1572  (void) GetNextToken(p,&p,MagickPathExtent,token);
1573  parameters[x]=StringToDouble(token,(char **) NULL);
1574  }
1575  arguments=DestroyString(arguments);
1576  (void) FunctionImage(*image,function,number_parameters,parameters,
1577  exception);
1578  parameters=(double *) RelinquishMagickMemory(parameters);
1579  break;
1580  }
1581  break;
1582  }
1583  case 'g':
1584  {
1585  if (LocaleCompare("gamma",option+1) == 0)
1586  {
1587  /*
1588  Gamma image.
1589  */
1590  (void) SyncImageSettings(mogrify_info,*image,exception);
1591  if (*option == '+')
1592  (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1593  else
1594  (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),
1595  exception);
1596  break;
1597  }
1598  if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1599  (LocaleCompare("gaussian",option+1) == 0))
1600  {
1601  /*
1602  Gaussian blur image.
1603  */
1604  (void) SyncImageSettings(mogrify_info,*image,exception);
1605  flags=ParseGeometry(argv[i+1],&geometry_info);
1606  if ((flags & SigmaValue) == 0)
1607  geometry_info.sigma=1.0;
1608  mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1609  geometry_info.sigma,exception);
1610  break;
1611  }
1612  if (LocaleCompare("geometry",option+1) == 0)
1613  {
1614  /*
1615  Record Image offset, Resize last image.
1616  */
1617  (void) SyncImageSettings(mogrify_info,*image,exception);
1618  if (*option == '+')
1619  {
1620  if ((*image)->geometry != (char *) NULL)
1621  (*image)->geometry=DestroyString((*image)->geometry);
1622  break;
1623  }
1624  flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1625  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1626  (void) CloneString(&(*image)->geometry,argv[i+1]);
1627  else
1628  mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1629  (*image)->filter,exception);
1630  break;
1631  }
1632  if (LocaleCompare("gravity",option+1) == 0)
1633  {
1634  if (*option == '+')
1635  {
1636  draw_info->gravity=UndefinedGravity;
1637  break;
1638  }
1639  draw_info->gravity=(GravityType) ParseCommandOption(
1640  MagickGravityOptions,MagickFalse,argv[i+1]);
1641  break;
1642  }
1643  if (LocaleCompare("grayscale",option+1) == 0)
1644  {
1645  PixelIntensityMethod
1646  method;
1647 
1648  (void) SyncImageSettings(mogrify_info,*image,exception);
1649  method=(PixelIntensityMethod) ParseCommandOption(
1650  MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1651  (void) GrayscaleImage(*image,method,exception);
1652  break;
1653  }
1654  break;
1655  }
1656  case 'h':
1657  {
1658  if (LocaleCompare("highlight-color",option+1) == 0)
1659  {
1660  (void) SetImageArtifact(*image,"compare:highlight-color",argv[i+1]);
1661  break;
1662  }
1663  if (LocaleCompare("hough-lines",option+1) == 0)
1664  {
1665  /*
1666  Detect edges in the image.
1667  */
1668  (void) SyncImageSettings(mogrify_info,*image,exception);
1669  flags=ParseGeometry(argv[i+1],&geometry_info);
1670  if ((flags & SigmaValue) == 0)
1671  geometry_info.sigma=geometry_info.rho;
1672  if ((flags & XiValue) == 0)
1673  geometry_info.xi=40;
1674  mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1675  (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1676  break;
1677  }
1678  break;
1679  }
1680  case 'i':
1681  {
1682  if (LocaleCompare("identify",option+1) == 0)
1683  {
1684  char
1685  *text;
1686 
1687  (void) SyncImageSettings(mogrify_info,*image,exception);
1688  if (format == (char *) NULL)
1689  {
1690  (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1691  exception);
1692  break;
1693  }
1694  text=InterpretImageProperties(mogrify_info,*image,format,exception);
1695  if (text == (char *) NULL)
1696  break;
1697  (void) fputs(text,stdout);
1698  text=DestroyString(text);
1699  break;
1700  }
1701  if (LocaleCompare("illuminant",option+1) == 0)
1702  {
1703  (void) SetImageArtifact(*image,"color:illuminant",argv[i+1]);
1704  break;
1705  }
1706  if (LocaleCompare("implode",option+1) == 0)
1707  {
1708  /*
1709  Implode image.
1710  */
1711  (void) SyncImageSettings(mogrify_info,*image,exception);
1712  (void) ParseGeometry(argv[i+1],&geometry_info);
1713  mogrify_image=ImplodeImage(*image,geometry_info.rho,
1714  interpolate_method,exception);
1715  break;
1716  }
1717  if (LocaleCompare("integral",option+1) == 0)
1718  {
1719  (void) SyncImageSettings(mogrify_info,*image,exception);
1720  mogrify_image=IntegralImage(*image,exception);
1721  break;
1722  }
1723  if (LocaleCompare("interline-spacing",option+1) == 0)
1724  {
1725  if (*option == '+')
1726  (void) ParseGeometry("0",&geometry_info);
1727  else
1728  (void) ParseGeometry(argv[i+1],&geometry_info);
1729  draw_info->interline_spacing=geometry_info.rho;
1730  break;
1731  }
1732  if (LocaleCompare("interpolate",option+1) == 0)
1733  {
1734  interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1735  MagickInterpolateOptions,MagickFalse,argv[i+1]);
1736  break;
1737  }
1738  if (LocaleCompare("interword-spacing",option+1) == 0)
1739  {
1740  if (*option == '+')
1741  (void) ParseGeometry("0",&geometry_info);
1742  else
1743  (void) ParseGeometry(argv[i+1],&geometry_info);
1744  draw_info->interword_spacing=geometry_info.rho;
1745  break;
1746  }
1747  if (LocaleCompare("interpolative-resize",option+1) == 0)
1748  {
1749  /*
1750  Interpolative resize image.
1751  */
1752  (void) SyncImageSettings(mogrify_info,*image,exception);
1753  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1754  mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1755  geometry.height,interpolate_method,exception);
1756  break;
1757  }
1758  break;
1759  }
1760  case 'k':
1761  {
1762  if (LocaleCompare("kerning",option+1) == 0)
1763  {
1764  if (*option == '+')
1765  (void) ParseGeometry("0",&geometry_info);
1766  else
1767  (void) ParseGeometry(argv[i+1],&geometry_info);
1768  draw_info->kerning=geometry_info.rho;
1769  break;
1770  }
1771  if (LocaleCompare("kmeans",option+1) == 0)
1772  {
1773  /*
1774  K-means clustering.
1775  */
1776  (void) SyncImageSettings(mogrify_info,*image,exception);
1777  flags=ParseGeometry(argv[i+1],&geometry_info);
1778  if ((flags & SigmaValue) == 0)
1779  geometry_info.sigma=300.0;
1780  if ((flags & XiValue) == 0)
1781  geometry_info.xi=0.0001;
1782  (void) KmeansImage(*image,(size_t) geometry_info.rho,
1783  (size_t) geometry_info.sigma,geometry_info.xi,exception);
1784  break;
1785  }
1786  if (LocaleCompare("kuwahara",option+1) == 0)
1787  {
1788  /*
1789  Edge preserving blur.
1790  */
1791  (void) SyncImageSettings(mogrify_info,*image,exception);
1792  flags=ParseGeometry(argv[i+1],&geometry_info);
1793  if ((flags & SigmaValue) == 0)
1794  geometry_info.sigma=geometry_info.rho-0.5;
1795  mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1796  geometry_info.sigma,exception);
1797  break;
1798  }
1799  break;
1800  }
1801  case 'l':
1802  {
1803  if (LocaleCompare("lat",option+1) == 0)
1804  {
1805  /*
1806  Local adaptive threshold image.
1807  */
1808  (void) SyncImageSettings(mogrify_info,*image,exception);
1809  flags=ParseGeometry(argv[i+1],&geometry_info);
1810  if ((flags & PercentValue) != 0)
1811  geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1812  mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1813  geometry_info.rho,(size_t) geometry_info.sigma,(double)
1814  geometry_info.xi,exception);
1815  break;
1816  }
1817  if (LocaleCompare("level",option+1) == 0)
1818  {
1819  double
1820  black_point,
1821  gamma,
1822  white_point;
1823 
1824  /*
1825  Parse levels.
1826  */
1827  (void) SyncImageSettings(mogrify_info,*image,exception);
1828  flags=ParseGeometry(argv[i+1],&geometry_info);
1829  black_point=geometry_info.rho;
1830  white_point=(double) QuantumRange;
1831  if ((flags & SigmaValue) != 0)
1832  white_point=geometry_info.sigma;
1833  gamma=1.0;
1834  if ((flags & XiValue) != 0)
1835  gamma=geometry_info.xi;
1836  if ((flags & PercentValue) != 0)
1837  {
1838  black_point*=(double) QuantumRange/100.0;
1839  white_point*=(double) QuantumRange/100.0;
1840  }
1841  if ((flags & SigmaValue) == 0)
1842  white_point=(double) QuantumRange-black_point;
1843  if ((*option == '+') || ((flags & AspectValue) != 0))
1844  (void) LevelizeImage(*image,black_point,white_point,gamma,
1845  exception);
1846  else
1847  (void) LevelImage(*image,black_point,white_point,gamma,exception);
1848  break;
1849  }
1850  if (LocaleCompare("level-colors",option+1) == 0)
1851  {
1852  char
1853  token[MagickPathExtent];
1854 
1855  const char
1856  *p;
1857 
1858  PixelInfo
1859  black_point,
1860  white_point;
1861 
1862  p=(const char *) argv[i+1];
1863  (void) GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */
1864  if ((isalpha((int) ((unsigned char) *token)) != 0) || ((*token == '#') != 0))
1865  (void) QueryColorCompliance(token,AllCompliance,&black_point,
1866  exception);
1867  else
1868  (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
1869  exception);
1870  if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
1871  (void) GetNextToken(p,&p,MagickPathExtent,token);
1872  if (*token == '\0')
1873  white_point=black_point; /* set everything to that color */
1874  else
1875  {
1876  if ((isalpha((int) ((unsigned char) *token)) == 0) && ((*token == '#') == 0))
1877  (void) GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */
1878  if ((isalpha((int) ((unsigned char) *token)) != 0) || ((*token == '#') != 0))
1879  (void) QueryColorCompliance(token,AllCompliance,&white_point,
1880  exception);
1881  else
1882  (void) QueryColorCompliance("#ffffff",AllCompliance,
1883  &white_point,exception);
1884  }
1885  (void) LevelImageColors(*image,&black_point,&white_point,
1886  *option == '+' ? MagickTrue : MagickFalse,exception);
1887  break;
1888  }
1889  if (LocaleCompare("linear-stretch",option+1) == 0)
1890  {
1891  double
1892  black_point,
1893  white_point;
1894 
1895  (void) SyncImageSettings(mogrify_info,*image,exception);
1896  flags=ParseGeometry(argv[i+1],&geometry_info);
1897  black_point=geometry_info.rho;
1898  white_point=(double) (*image)->columns*(*image)->rows;
1899  if ((flags & SigmaValue) != 0)
1900  white_point=geometry_info.sigma;
1901  if ((flags & PercentValue) != 0)
1902  {
1903  black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1904  white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1905  }
1906  if ((flags & SigmaValue) == 0)
1907  white_point=(double) (*image)->columns*(*image)->rows-
1908  black_point;
1909  (void) LinearStretchImage(*image,black_point,white_point,exception);
1910  break;
1911  }
1912  if (LocaleCompare("liquid-rescale",option+1) == 0)
1913  {
1914  /*
1915  Liquid rescale image.
1916  */
1917  (void) SyncImageSettings(mogrify_info,*image,exception);
1918  flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1919  if ((flags & XValue) == 0)
1920  geometry.x=1;
1921  if ((flags & YValue) == 0)
1922  geometry.y=0;
1923  mogrify_image=LiquidRescaleImage(*image,geometry.width,
1924  geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1925  break;
1926  }
1927  if (LocaleCompare("local-contrast",option+1) == 0)
1928  {
1929  (void) SyncImageSettings(mogrify_info,*image,exception);
1930  flags=ParseGeometry(argv[i+1],&geometry_info);
1931  if ((flags & RhoValue) == 0)
1932  geometry_info.rho=10;
1933  if ((flags & SigmaValue) == 0)
1934  geometry_info.sigma=12.5;
1935  mogrify_image=LocalContrastImage(*image,geometry_info.rho,
1936  geometry_info.sigma,exception);
1937  break;
1938  }
1939  if (LocaleCompare("lowlight-color",option+1) == 0)
1940  {
1941  (void) SetImageArtifact(*image,"compare:lowlight-color",argv[i+1]);
1942  break;
1943  }
1944  break;
1945  }
1946  case 'm':
1947  {
1948  if (LocaleCompare("magnify",option+1) == 0)
1949  {
1950  /*
1951  Double image size.
1952  */
1953  (void) SyncImageSettings(mogrify_info,*image,exception);
1954  mogrify_image=MagnifyImage(*image,exception);
1955  break;
1956  }
1957  if (LocaleCompare("map",option+1) == 0)
1958  {
1959  Image
1960  *remap_image;
1961 
1962  /*
1963  Transform image colors to match this set of colors.
1964  */
1965  (void) SyncImageSettings(mogrify_info,*image,exception);
1966  if (*option == '+')
1967  break;
1968  remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
1969  if (remap_image == (Image *) NULL)
1970  break;
1971  (void) RemapImage(quantize_info,*image,remap_image,exception);
1972  remap_image=DestroyImage(remap_image);
1973  break;
1974  }
1975  if (LocaleCompare("mask",option+1) == 0)
1976  {
1977  Image
1978  *mask;
1979 
1980  (void) SyncImageSettings(mogrify_info,*image,exception);
1981  if (*option == '+')
1982  {
1983  /*
1984  Remove a mask.
1985  */
1986  (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
1987  exception);
1988  break;
1989  }
1990  /*
1991  Set the image mask.
1992  */
1993  mask=GetImageCache(mogrify_info,argv[i+1],exception);
1994  if (mask == (Image *) NULL)
1995  break;
1996  (void) SetImageMask(*image,WritePixelMask,mask,exception);
1997  mask=DestroyImage(mask);
1998  break;
1999  }
2000  if (LocaleCompare("matte",option+1) == 0)
2001  {
2002  (void) SetImageAlphaChannel(*image,(*option == '-') ?
2003  SetAlphaChannel : DeactivateAlphaChannel,exception);
2004  break;
2005  }
2006  if (LocaleCompare("mean-shift",option+1) == 0)
2007  {
2008  /*
2009  Detect edges in the image.
2010  */
2011  (void) SyncImageSettings(mogrify_info,*image,exception);
2012  flags=ParseGeometry(argv[i+1],&geometry_info);
2013  if ((flags & SigmaValue) == 0)
2014  geometry_info.sigma=geometry_info.rho;
2015  if ((flags & XiValue) == 0)
2016  geometry_info.xi=0.10*(double) QuantumRange;
2017  if ((flags & PercentValue) != 0)
2018  geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2019  mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2020  (size_t) geometry_info.sigma,geometry_info.xi,exception);
2021  break;
2022  }
2023  if (LocaleCompare("median",option+1) == 0)
2024  {
2025  /*
2026  Median filter image.
2027  */
2028  (void) SyncImageSettings(mogrify_info,*image,exception);
2029  flags=ParseGeometry(argv[i+1],&geometry_info);
2030  if ((flags & SigmaValue) == 0)
2031  geometry_info.sigma=geometry_info.rho;
2032  mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2033  geometry_info.rho,(size_t) geometry_info.sigma,exception);
2034  break;
2035  }
2036  if (LocaleCompare("mode",option+1) == 0)
2037  {
2038  /*
2039  Mode image.
2040  */
2041  (void) SyncImageSettings(mogrify_info,*image,exception);
2042  flags=ParseGeometry(argv[i+1],&geometry_info);
2043  if ((flags & SigmaValue) == 0)
2044  geometry_info.sigma=geometry_info.rho;
2045  mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2046  geometry_info.rho,(size_t) geometry_info.sigma,exception);
2047  break;
2048  }
2049  if (LocaleCompare("modulate",option+1) == 0)
2050  {
2051  (void) SyncImageSettings(mogrify_info,*image,exception);
2052  (void) ModulateImage(*image,argv[i+1],exception);
2053  break;
2054  }
2055  if (LocaleCompare("moments",option+1) == 0)
2056  {
2057  if (*option == '+')
2058  {
2059  (void) DeleteImageArtifact(*image,"identify:moments");
2060  break;
2061  }
2062  (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2063  (void) SetImageArtifact(*image,"verbose","true");
2064  break;
2065  }
2066  if (LocaleCompare("monitor",option+1) == 0)
2067  {
2068  if (*option == '+')
2069  {
2070  (void) SetImageProgressMonitor(*image,
2071  (MagickProgressMonitor) NULL,(void *) NULL);
2072  break;
2073  }
2074  (void) SetImageProgressMonitor(*image,MonitorProgress,
2075  (void *) NULL);
2076  break;
2077  }
2078  if (LocaleCompare("monochrome",option+1) == 0)
2079  {
2080  (void) SyncImageSettings(mogrify_info,*image,exception);
2081  (void) SetImageType(*image,BilevelType,exception);
2082  break;
2083  }
2084  if (LocaleCompare("morphology",option+1) == 0)
2085  {
2086  char
2087  token[MagickPathExtent];
2088 
2089  const char
2090  *p;
2091 
2092  KernelInfo
2093  *kernel;
2094 
2095  MorphologyMethod
2096  method;
2097 
2098  ssize_t
2099  iterations;
2100 
2101  /*
2102  Morphological Image Operation
2103  */
2104  (void) SyncImageSettings(mogrify_info,*image,exception);
2105  p=argv[i+1];
2106  (void) GetNextToken(p,&p,MagickPathExtent,token);
2107  method=(MorphologyMethod) ParseCommandOption(
2108  MagickMorphologyOptions,MagickFalse,token);
2109  iterations=1L;
2110  (void) GetNextToken(p,&p,MagickPathExtent,token);
2111  if ((*p == ':') || (*p == ','))
2112  (void) GetNextToken(p,&p,MagickPathExtent,token);
2113  if ((*p != '\0'))
2114  iterations=(ssize_t) StringToLong(p);
2115  kernel=AcquireKernelInfo(argv[i+2],exception);
2116  if (kernel == (KernelInfo *) NULL)
2117  {
2118  (void) ThrowMagickException(exception,GetMagickModule(),
2119  OptionError,"UnabletoParseKernel","morphology");
2120  status=MagickFalse;
2121  break;
2122  }
2123  mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2124  exception);
2125  kernel=DestroyKernelInfo(kernel);
2126  break;
2127  }
2128  if (LocaleCompare("motion-blur",option+1) == 0)
2129  {
2130  /*
2131  Motion blur image.
2132  */
2133  (void) SyncImageSettings(mogrify_info,*image,exception);
2134  flags=ParseGeometry(argv[i+1],&geometry_info);
2135  if ((flags & SigmaValue) == 0)
2136  geometry_info.sigma=1.0;
2137  mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2138  geometry_info.sigma,geometry_info.xi,exception);
2139  break;
2140  }
2141  break;
2142  }
2143  case 'n':
2144  {
2145  if (LocaleCompare("negate",option+1) == 0)
2146  {
2147  (void) SyncImageSettings(mogrify_info,*image,exception);
2148  (void) NegateImage(*image,*option == '+' ? MagickTrue :
2149  MagickFalse,exception);
2150  break;
2151  }
2152  if (LocaleCompare("noise",option+1) == 0)
2153  {
2154  (void) SyncImageSettings(mogrify_info,*image,exception);
2155  if (*option == '-')
2156  {
2157  flags=ParseGeometry(argv[i+1],&geometry_info);
2158  if ((flags & SigmaValue) == 0)
2159  geometry_info.sigma=geometry_info.rho;
2160  mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2161  geometry_info.rho,(size_t) geometry_info.sigma,exception);
2162  }
2163  else
2164  {
2165  NoiseType
2166  noise;
2167 
2168  noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2169  MagickFalse,argv[i+1]);
2170  mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2171  }
2172  break;
2173  }
2174  if (LocaleCompare("normalize",option+1) == 0)
2175  {
2176  (void) SyncImageSettings(mogrify_info,*image,exception);
2177  (void) NormalizeImage(*image,exception);
2178  break;
2179  }
2180  break;
2181  }
2182  case 'o':
2183  {
2184  if (LocaleCompare("opaque",option+1) == 0)
2185  {
2186  PixelInfo
2187  target;
2188 
2189  (void) SyncImageSettings(mogrify_info,*image,exception);
2190  (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2191  exception);
2192  (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2193  MagickFalse : MagickTrue,exception);
2194  break;
2195  }
2196  if (LocaleCompare("ordered-dither",option+1) == 0)
2197  {
2198  (void) SyncImageSettings(mogrify_info,*image,exception);
2199  (void) OrderedDitherImage(*image,argv[i+1],exception);
2200  break;
2201  }
2202  break;
2203  }
2204  case 'p':
2205  {
2206  if (LocaleCompare("paint",option+1) == 0)
2207  {
2208  (void) SyncImageSettings(mogrify_info,*image,exception);
2209  (void) ParseGeometry(argv[i+1],&geometry_info);
2210  mogrify_image=OilPaintImage(*image,geometry_info.rho,
2211  geometry_info.sigma,exception);
2212  break;
2213  }
2214  if (LocaleCompare("perceptible",option+1) == 0)
2215  {
2216  /*
2217  Perceptible image.
2218  */
2219  (void) SyncImageSettings(mogrify_info,*image,exception);
2220  (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2221  (char **) NULL),exception);
2222  break;
2223  }
2224  if (LocaleCompare("pointsize",option+1) == 0)
2225  {
2226  if (*option == '+')
2227  (void) ParseGeometry("12",&geometry_info);
2228  else
2229  (void) ParseGeometry(argv[i+1],&geometry_info);
2230  draw_info->pointsize=geometry_info.rho;
2231  break;
2232  }
2233  if (LocaleCompare("polaroid",option+1) == 0)
2234  {
2235  const char
2236  *caption;
2237 
2238  double
2239  angle;
2240 
2241  RandomInfo
2242  *random_info;
2243 
2244  /*
2245  Simulate a Polaroid picture.
2246  */
2247  (void) SyncImageSettings(mogrify_info,*image,exception);
2248  random_info=AcquireRandomInfo();
2249  angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2250  random_info=DestroyRandomInfo(random_info);
2251  if (*option == '-')
2252  {
2253  SetGeometryInfo(&geometry_info);
2254  flags=ParseGeometry(argv[i+1],&geometry_info);
2255  angle=geometry_info.rho;
2256  }
2257  caption=GetImageProperty(*image,"caption",exception);
2258  mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2259  interpolate_method,exception);
2260  break;
2261  }
2262  if (LocaleCompare("posterize",option+1) == 0)
2263  {
2264  /*
2265  Posterize image.
2266  */
2267  (void) SyncImageSettings(mogrify_info,*image,exception);
2268  (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2269  quantize_info->dither_method,exception);
2270  break;
2271  }
2272  if (LocaleCompare("preview",option+1) == 0)
2273  {
2274  PreviewType
2275  preview_type;
2276 
2277  /*
2278  Preview image.
2279  */
2280  (void) SyncImageSettings(mogrify_info,*image,exception);
2281  if (*option == '+')
2282  preview_type=UndefinedPreview;
2283  else
2284  preview_type=(PreviewType) ParseCommandOption(
2285  MagickPreviewOptions,MagickFalse,argv[i+1]);
2286  mogrify_image=PreviewImage(*image,preview_type,exception);
2287  break;
2288  }
2289  if (LocaleCompare("profile",option+1) == 0)
2290  {
2291  const char
2292  *name;
2293 
2294  const StringInfo
2295  *profile;
2296 
2297  ExceptionInfo
2298  *sans_exception;
2299 
2300  Image
2301  *profile_image;
2302 
2303  ImageInfo
2304  *profile_info;
2305 
2306  (void) SyncImageSettings(mogrify_info,*image,exception);
2307  if (*option == '+')
2308  {
2309  /*
2310  Remove a profile from the image.
2311  */
2312  (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2313  NULL,0,exception);
2314  break;
2315  }
2316  /*
2317  Associate a profile with the image.
2318  */
2319  profile_info=CloneImageInfo(mogrify_info);
2320  profile=GetImageProfile(*image,"iptc");
2321  if (profile != (StringInfo *) NULL)
2322  profile_info->profile=(void *) CloneStringInfo(profile);
2323  sans_exception=AcquireExceptionInfo();
2324  profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2325  sans_exception=DestroyExceptionInfo(sans_exception);
2326  profile_info=DestroyImageInfo(profile_info);
2327  if (profile_image == (Image *) NULL)
2328  {
2329  StringInfo
2330  *file_data;
2331 
2332  profile_info=CloneImageInfo(mogrify_info);
2333  (void) CopyMagickString(profile_info->filename,argv[i+1],
2334  MagickPathExtent);
2335  file_data=FileToStringInfo(profile_info->filename,~0UL,
2336  exception);
2337  if (file_data != (StringInfo *) NULL)
2338  {
2339  (void) SetImageInfo(profile_info,0,exception);
2340  (void) ProfileImage(*image,profile_info->magick,
2341  GetStringInfoDatum(file_data),
2342  GetStringInfoLength(file_data),exception);
2343  file_data=DestroyStringInfo(file_data);
2344  }
2345  profile_info=DestroyImageInfo(profile_info);
2346  break;
2347  }
2348  ResetImageProfileIterator(profile_image);
2349  name=GetNextImageProfile(profile_image);
2350  while (name != (const char *) NULL)
2351  {
2352  profile=GetImageProfile(profile_image,name);
2353  if (profile != (StringInfo *) NULL)
2354  (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2355  (size_t) GetStringInfoLength(profile),exception);
2356  name=GetNextImageProfile(profile_image);
2357  }
2358  profile_image=DestroyImage(profile_image);
2359  break;
2360  }
2361  break;
2362  }
2363  case 'q':
2364  {
2365  if (LocaleCompare("quantize",option+1) == 0)
2366  {
2367  if (*option == '+')
2368  {
2369  quantize_info->colorspace=UndefinedColorspace;
2370  break;
2371  }
2372  quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2373  MagickColorspaceOptions,MagickFalse,argv[i+1]);
2374  break;
2375  }
2376  break;
2377  }
2378  case 'r':
2379  {
2380  if (LocaleCompare("rotational-blur",option+1) == 0)
2381  {
2382  /*
2383  Rotational blur image.
2384  */
2385  (void) SyncImageSettings(mogrify_info,*image,exception);
2386  flags=ParseGeometry(argv[i+1],&geometry_info);
2387  mogrify_image=RotationalBlurImage(*image,geometry_info.rho,
2388  exception);
2389  break;
2390  }
2391  if (LocaleCompare("raise",option+1) == 0)
2392  {
2393  /*
2394  Surround image with a raise of solid color.
2395  */
2396  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2397  (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2398  MagickFalse,exception);
2399  break;
2400  }
2401  if (LocaleCompare("random-threshold",option+1) == 0)
2402  {
2403  /*
2404  Random threshold image.
2405  */
2406  double
2407  min_threshold,
2408  max_threshold;
2409 
2410  (void) SyncImageSettings(mogrify_info,*image,exception);
2411  min_threshold=0.0;
2412  max_threshold=(double) QuantumRange;
2413  flags=ParseGeometry(argv[i+1],&geometry_info);
2414  min_threshold=geometry_info.rho;
2415  max_threshold=geometry_info.sigma;
2416  if ((flags & SigmaValue) == 0)
2417  max_threshold=min_threshold;
2418  if (strchr(argv[i+1],'%') != (char *) NULL)
2419  {
2420  max_threshold*=0.01*(double) QuantumRange;
2421  min_threshold*=0.01*(double) QuantumRange;
2422  }
2423  (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2424  exception);
2425  break;
2426  }
2427  if (LocaleCompare("range-threshold",option+1) == 0)
2428  {
2429  /*
2430  Range threshold image.
2431  */
2432  (void) SyncImageSettings(mogrify_info,*image,exception);
2433  flags=ParseGeometry(argv[i+1],&geometry_info);
2434  if ((flags & SigmaValue) == 0)
2435  geometry_info.sigma=geometry_info.rho;
2436  if ((flags & XiValue) == 0)
2437  geometry_info.xi=geometry_info.sigma;
2438  if ((flags & PsiValue) == 0)
2439  geometry_info.psi=geometry_info.xi;
2440  if (strchr(argv[i+1],'%') != (char *) NULL)
2441  {
2442  geometry_info.rho*=0.01*(double) QuantumRange;
2443  geometry_info.sigma*=0.01*(double) QuantumRange;
2444  geometry_info.xi*=0.01*(double) QuantumRange;
2445  geometry_info.psi*=0.01*(double) QuantumRange;
2446  }
2447  (void) RangeThresholdImage(*image,geometry_info.rho,
2448  geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2449  break;
2450  }
2451  if (LocaleCompare("read-mask",option+1) == 0)
2452  {
2453  Image
2454  *mask;
2455 
2456  (void) SyncImageSettings(mogrify_info,*image,exception);
2457  if (*option == '+')
2458  {
2459  /*
2460  Remove a mask.
2461  */
2462  (void) SetImageMask(*image,ReadPixelMask,(const Image *) NULL,
2463  exception);
2464  break;
2465  }
2466  /*
2467  Set the image mask.
2468  */
2469  mask=GetImageCache(mogrify_info,argv[i+1],exception);
2470  if (mask == (Image *) NULL)
2471  break;
2472  (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2473  mask=DestroyImage(mask);
2474  break;
2475  }
2476  if (LocaleCompare("region",option+1) == 0)
2477  {
2478  /*
2479  Apply read mask as defined by a region geometry.
2480  */
2481  (void) SyncImageSettings(mogrify_info,*image,exception);
2482  if (*option == '+')
2483  {
2484  (void) SetImageRegionMask(*image,WritePixelMask,
2485  (const RectangleInfo *) NULL,exception);
2486  break;
2487  }
2488  (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2489  (void) SetImageRegionMask(*image,WritePixelMask,&geometry,
2490  exception);
2491  break;
2492  }
2493  if (LocaleCompare("render",option+1) == 0)
2494  {
2495  (void) SyncImageSettings(mogrify_info,*image,exception);
2496  draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2497  break;
2498  }
2499  if (LocaleCompare("remap",option+1) == 0)
2500  {
2501  Image
2502  *remap_image;
2503 
2504  /*
2505  Transform image colors to match this set of colors.
2506  */
2507  (void) SyncImageSettings(mogrify_info,*image,exception);
2508  if (*option == '+')
2509  break;
2510  remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2511  if (remap_image == (Image *) NULL)
2512  break;
2513  (void) RemapImage(quantize_info,*image,remap_image,exception);
2514  remap_image=DestroyImage(remap_image);
2515  break;
2516  }
2517  if (LocaleCompare("repage",option+1) == 0)
2518  {
2519  if (*option == '+')
2520  {
2521  (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2522  break;
2523  }
2524  (void) ResetImagePage(*image,argv[i+1]);
2525  break;
2526  }
2527  if (LocaleCompare("resample",option+1) == 0)
2528  {
2529  /*
2530  Resample image.
2531  */
2532  (void) SyncImageSettings(mogrify_info,*image,exception);
2533  flags=ParseGeometry(argv[i+1],&geometry_info);
2534  if ((flags & SigmaValue) == 0)
2535  geometry_info.sigma=geometry_info.rho;
2536  mogrify_image=ResampleImage(*image,geometry_info.rho,
2537  geometry_info.sigma,(*image)->filter,exception);
2538  break;
2539  }
2540  if (LocaleCompare("reshape",option+1) == 0)
2541  {
2542  /*
2543  Reshape image.
2544  */
2545  (void) SyncImageSettings(mogrify_info,*image,exception);
2546  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2547  (void) ReshapePixelCache(*image,geometry.width,geometry.height,
2548  exception);
2549  break;
2550  }
2551  if (LocaleCompare("resize",option+1) == 0)
2552  {
2553  /*
2554  Resize image.
2555  */
2556  (void) SyncImageSettings(mogrify_info,*image,exception);
2557  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2558  mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2559  (*image)->filter,exception);
2560  break;
2561  }
2562  if (LocaleCompare("roll",option+1) == 0)
2563  {
2564  /*
2565  Roll image.
2566  */
2567  (void) SyncImageSettings(mogrify_info,*image,exception);
2568  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2569  if ((flags & PercentValue) != 0)
2570  {
2571  geometry.x*=(double) (*image)->columns/100.0;
2572  geometry.y*=(double) (*image)->rows/100.0;
2573  }
2574  mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2575  break;
2576  }
2577  if (LocaleCompare("rotate",option+1) == 0)
2578  {
2579  char
2580  *rotation;
2581 
2582  /*
2583  Check for conditional image rotation.
2584  */
2585  (void) SyncImageSettings(mogrify_info,*image,exception);
2586  if (strchr(argv[i+1],'>') != (char *) NULL)
2587  if ((*image)->columns <= (*image)->rows)
2588  break;
2589  if (strchr(argv[i+1],'<') != (char *) NULL)
2590  if ((*image)->columns >= (*image)->rows)
2591  break;
2592  /*
2593  Rotate image.
2594  */
2595  rotation=ConstantString(argv[i+1]);
2596  (void) SubstituteString(&rotation,">","");
2597  (void) SubstituteString(&rotation,"<","");
2598  (void) ParseGeometry(rotation,&geometry_info);
2599  rotation=DestroyString(rotation);
2600  mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2601  break;
2602  }
2603  break;
2604  }
2605  case 's':
2606  {
2607  if (LocaleCompare("sample",option+1) == 0)
2608  {
2609  /*
2610  Sample image with pixel replication.
2611  */
2612  (void) SyncImageSettings(mogrify_info,*image,exception);
2613  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2614  mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2615  exception);
2616  break;
2617  }
2618  if (LocaleCompare("scale",option+1) == 0)
2619  {
2620  /*
2621  Resize image.
2622  */
2623  (void) SyncImageSettings(mogrify_info,*image,exception);
2624  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2625  mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2626  exception);
2627  break;
2628  }
2629  if (LocaleCompare("selective-blur",option+1) == 0)
2630  {
2631  /*
2632  Selectively blur pixels within a contrast threshold.
2633  */
2634  (void) SyncImageSettings(mogrify_info,*image,exception);
2635  flags=ParseGeometry(argv[i+1],&geometry_info);
2636  if ((flags & PercentValue) != 0)
2637  geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2638  mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2639  geometry_info.sigma,geometry_info.xi,exception);
2640  break;
2641  }
2642  if (LocaleCompare("separate",option+1) == 0)
2643  {
2644  /*
2645  Break channels into separate images.
2646  */
2647  (void) SyncImageSettings(mogrify_info,*image,exception);
2648  mogrify_image=SeparateImages(*image,exception);
2649  break;
2650  }
2651  if (LocaleCompare("sepia-tone",option+1) == 0)
2652  {
2653  double
2654  threshold;
2655 
2656  /*
2657  Sepia-tone image.
2658  */
2659  (void) SyncImageSettings(mogrify_info,*image,exception);
2660  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2661  1.0);
2662  mogrify_image=SepiaToneImage(*image,threshold,exception);
2663  break;
2664  }
2665  if (LocaleCompare("segment",option+1) == 0)
2666  {
2667  /*
2668  Segment image.
2669  */
2670  (void) SyncImageSettings(mogrify_info,*image,exception);
2671  flags=ParseGeometry(argv[i+1],&geometry_info);
2672  if ((flags & SigmaValue) == 0)
2673  geometry_info.sigma=1.0;
2674  (void) SegmentImage(*image,(*image)->colorspace,
2675  mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2676  exception);
2677  break;
2678  }
2679  if (LocaleCompare("set",option+1) == 0)
2680  {
2681  char
2682  *value;
2683 
2684  /*
2685  Set image option.
2686  */
2687  if (*option == '+')
2688  {
2689  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2690  (void) DeleteImageRegistry(argv[i+1]+9);
2691  else
2692  if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2693  {
2694  (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2695  (void) DeleteImageArtifact(*image,argv[i+1]+7);
2696  }
2697  else
2698  (void) DeleteImageProperty(*image,argv[i+1]);
2699  break;
2700  }
2701  value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2702  exception);
2703  if (value == (char *) NULL)
2704  break;
2705  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2706  (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2707  exception);
2708  else
2709  if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2710  {
2711  (void) SetImageOption(image_info,argv[i+1]+7,value);
2712  (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2713  (void) SetImageArtifact(*image,argv[i+1]+7,value);
2714  }
2715  else
2716  if (LocaleCompare(argv[i+1],"profile") == 0)
2717  {
2718  StringInfo
2719  *profile = (StringInfo *) NULL;
2720 
2721  (void) CopyMagickString(image_info->filename,value,
2722  MagickPathExtent);
2723  (void) SetImageInfo(image_info,1,exception);
2724  if (LocaleCompare(image_info->filename,"-") != 0)
2725  profile=FileToStringInfo(image_info->filename,~0UL,
2726  exception);
2727  if (profile != (StringInfo *) NULL)
2728  {
2729  SetStringInfoName(profile,image_info->magick);
2730  status=SetImageProfilePrivate(*image,profile,exception);
2731  }
2732  }
2733  else
2734  (void) SetImageProperty(*image,argv[i+1],value,exception);
2735  value=DestroyString(value);
2736  break;
2737  }
2738  if (LocaleCompare("shade",option+1) == 0)
2739  {
2740  /*
2741  Shade image.
2742  */
2743  (void) SyncImageSettings(mogrify_info,*image,exception);
2744  flags=ParseGeometry(argv[i+1],&geometry_info);
2745  if ((flags & SigmaValue) == 0)
2746  geometry_info.sigma=1.0;
2747  mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2748  MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2749  break;
2750  }
2751  if (LocaleCompare("shadow",option+1) == 0)
2752  {
2753  /*
2754  Shadow image.
2755  */
2756  (void) SyncImageSettings(mogrify_info,*image,exception);
2757  flags=ParseGeometry(argv[i+1],&geometry_info);
2758  if ((flags & SigmaValue) == 0)
2759  geometry_info.sigma=1.0;
2760  if ((flags & XiValue) == 0)
2761  geometry_info.xi=4.0;
2762  if ((flags & PsiValue) == 0)
2763  geometry_info.psi=4.0;
2764  mogrify_image=ShadowImage(*image,geometry_info.rho,
2765  geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2766  (ssize_t) ceil(geometry_info.psi-0.5),exception);
2767  break;
2768  }
2769  if (LocaleCompare("sharpen",option+1) == 0)
2770  {
2771  /*
2772  Sharpen image.
2773  */
2774  (void) SyncImageSettings(mogrify_info,*image,exception);
2775  flags=ParseGeometry(argv[i+1],&geometry_info);
2776  if ((flags & SigmaValue) == 0)
2777  geometry_info.sigma=1.0;
2778  if ((flags & XiValue) == 0)
2779  geometry_info.xi=0.0;
2780  mogrify_image=SharpenImage(*image,geometry_info.rho,
2781  geometry_info.sigma,exception);
2782  break;
2783  }
2784  if (LocaleCompare("shave",option+1) == 0)
2785  {
2786  /*
2787  Shave the image edges.
2788  */
2789  (void) SyncImageSettings(mogrify_info,*image,exception);
2790  flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2791  mogrify_image=ShaveImage(*image,&geometry,exception);
2792  break;
2793  }
2794  if (LocaleCompare("shear",option+1) == 0)
2795  {
2796  /*
2797  Shear image.
2798  */
2799  (void) SyncImageSettings(mogrify_info,*image,exception);
2800  flags=ParseGeometry(argv[i+1],&geometry_info);
2801  if ((flags & SigmaValue) == 0)
2802  geometry_info.sigma=geometry_info.rho;
2803  mogrify_image=ShearImage(*image,geometry_info.rho,
2804  geometry_info.sigma,exception);
2805  break;
2806  }
2807  if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2808  {
2809  /*
2810  Sigmoidal non-linearity contrast control.
2811  */
2812  (void) SyncImageSettings(mogrify_info,*image,exception);
2813  flags=ParseGeometry(argv[i+1],&geometry_info);
2814  if ((flags & SigmaValue) == 0)
2815  geometry_info.sigma=(double) QuantumRange/2.0;
2816  if ((flags & PercentValue) != 0)
2817  geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2818  100.0;
2819  (void) SigmoidalContrastImage(*image,(*option == '-') ?
2820  MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2821  exception);
2822  break;
2823  }
2824  if (LocaleCompare("sketch",option+1) == 0)
2825  {
2826  /*
2827  Sketch image.
2828  */
2829  (void) SyncImageSettings(mogrify_info,*image,exception);
2830  flags=ParseGeometry(argv[i+1],&geometry_info);
2831  if ((flags & SigmaValue) == 0)
2832  geometry_info.sigma=1.0;
2833  mogrify_image=SketchImage(*image,geometry_info.rho,
2834  geometry_info.sigma,geometry_info.xi,exception);
2835  break;
2836  }
2837  if (LocaleCompare("solarize",option+1) == 0)
2838  {
2839  double
2840  threshold;
2841 
2842  (void) SyncImageSettings(mogrify_info,*image,exception);
2843  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2844  1.0);
2845  (void) SolarizeImage(*image,threshold,exception);
2846  break;
2847  }
2848  if (LocaleCompare("sort-pixels",option+1) == 0)
2849  {
2850  /*
2851  Sort each scanline in scending order of intensity.
2852  */
2853  (void) SyncImageSettings(mogrify_info,*image,exception);
2854  (void) SortImagePixels(*image,exception);
2855  break;
2856  }
2857  if (LocaleCompare("sparse-color",option+1) == 0)
2858  {
2859  SparseColorMethod
2860  method;
2861 
2862  char
2863  *arguments;
2864 
2865  /*
2866  Sparse Color Interpolated Gradient
2867  */
2868  (void) SyncImageSettings(mogrify_info,*image,exception);
2869  method=(SparseColorMethod) ParseCommandOption(
2870  MagickSparseColorOptions,MagickFalse,argv[i+1]);
2871  arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2872  exception);
2873  if (arguments == (char *) NULL)
2874  break;
2875  mogrify_image=SparseColorOption(*image,method,arguments,
2876  option[0] == '+' ? MagickTrue : MagickFalse,exception);
2877  arguments=DestroyString(arguments);
2878  break;
2879  }
2880  if (LocaleCompare("splice",option+1) == 0)
2881  {
2882  /*
2883  Splice a solid color into the image.
2884  */
2885  (void) SyncImageSettings(mogrify_info,*image,exception);
2886  (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2887  mogrify_image=SpliceImage(*image,&geometry,exception);
2888  break;
2889  }
2890  if (LocaleCompare("spread",option+1) == 0)
2891  {
2892  /*
2893  Spread an image.
2894  */
2895  (void) SyncImageSettings(mogrify_info,*image,exception);
2896  (void) ParseGeometry(argv[i+1],&geometry_info);
2897  mogrify_image=SpreadImage(*image,interpolate_method,
2898  geometry_info.rho,exception);
2899  break;
2900  }
2901  if (LocaleCompare("statistic",option+1) == 0)
2902  {
2903  StatisticType
2904  type;
2905 
2906  (void) SyncImageSettings(mogrify_info,*image,exception);
2907  type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2908  MagickFalse,argv[i+1]);
2909  (void) ParseGeometry(argv[i+2],&geometry_info);
2910  mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2911  (size_t) geometry_info.sigma,exception);
2912  break;
2913  }
2914  if (LocaleCompare("stretch",option+1) == 0)
2915  {
2916  if (*option == '+')
2917  {
2918  draw_info->stretch=UndefinedStretch;
2919  break;
2920  }
2921  draw_info->stretch=(StretchType) ParseCommandOption(
2922  MagickStretchOptions,MagickFalse,argv[i+1]);
2923  break;
2924  }
2925  if (LocaleCompare("strip",option+1) == 0)
2926  {
2927  /*
2928  Strip image of profiles and comments.
2929  */
2930  (void) SyncImageSettings(mogrify_info,*image,exception);
2931  (void) StripImage(*image,exception);
2932  break;
2933  }
2934  if (LocaleCompare("stroke",option+1) == 0)
2935  {
2936  ExceptionInfo
2937  *sans;
2938 
2939  PixelInfo
2940  color;
2941 
2942  if (*option == '+')
2943  {
2944  (void) QueryColorCompliance("none",AllCompliance,
2945  &draw_info->stroke,exception);
2946  if (draw_info->stroke_pattern != (Image *) NULL)
2947  draw_info->stroke_pattern=DestroyImage(
2948  draw_info->stroke_pattern);
2949  break;
2950  }
2951  sans=AcquireExceptionInfo();
2952  status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2953  sans=DestroyExceptionInfo(sans);
2954  if (status == MagickFalse)
2955  draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2956  exception);
2957  else
2958  draw_info->stroke=color;
2959  break;
2960  }
2961  if (LocaleCompare("strokewidth",option+1) == 0)
2962  {
2963  draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2964  break;
2965  }
2966  if (LocaleCompare("style",option+1) == 0)
2967  {
2968  if (*option == '+')
2969  {
2970  draw_info->style=UndefinedStyle;
2971  break;
2972  }
2973  draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2974  MagickFalse,argv[i+1]);
2975  break;
2976  }
2977  if (LocaleCompare("swirl",option+1) == 0)
2978  {
2979  /*
2980  Swirl image.
2981  */
2982  (void) SyncImageSettings(mogrify_info,*image,exception);
2983  (void) ParseGeometry(argv[i+1],&geometry_info);
2984  mogrify_image=SwirlImage(*image,geometry_info.rho,
2985  interpolate_method,exception);
2986  break;
2987  }
2988  break;
2989  }
2990  case 't':
2991  {
2992  if (LocaleCompare("threshold",option+1) == 0)
2993  {
2994  double
2995  threshold;
2996 
2997  /*
2998  Threshold image.
2999  */
3000  (void) SyncImageSettings(mogrify_info,*image,exception);
3001  if (*option == '+')
3002  threshold=(double) QuantumRange/2;
3003  else
3004  threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3005  1.0);
3006  (void) BilevelImage(*image,threshold,exception);
3007  break;
3008  }
3009  if (LocaleCompare("thumbnail",option+1) == 0)
3010  {
3011  /*
3012  Thumbnail image.
3013  */
3014  (void) SyncImageSettings(mogrify_info,*image,exception);
3015  (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3016  mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3017  exception);
3018  break;
3019  }
3020  if (LocaleCompare("tile",option+1) == 0)
3021  {
3022  if (*option == '+')
3023  {
3024  if (draw_info->fill_pattern != (Image *) NULL)
3025  draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3026  break;
3027  }
3028  draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3029  exception);
3030  break;
3031  }
3032  if (LocaleCompare("tint",option+1) == 0)
3033  {
3034  /*
3035  Tint the image.
3036  */
3037  (void) SyncImageSettings(mogrify_info,*image,exception);
3038  mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3039  break;
3040  }
3041  if (LocaleCompare("transform",option+1) == 0)
3042  {
3043  /*
3044  Affine transform image.
3045  */
3046  (void) SyncImageSettings(mogrify_info,*image,exception);
3047  mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3048  exception);
3049  break;
3050  }
3051  if (LocaleCompare("transparent",option+1) == 0)
3052  {
3053  PixelInfo
3054  target;
3055 
3056  (void) SyncImageSettings(mogrify_info,*image,exception);
3057  (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3058  exception);
3059  (void) TransparentPaintImage(*image,&target,(Quantum)
3060  TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3061  exception);
3062  break;
3063  }
3064  if (LocaleCompare("transpose",option+1) == 0)
3065  {
3066  /*
3067  Transpose image scanlines.
3068  */
3069  (void) SyncImageSettings(mogrify_info,*image,exception);
3070  mogrify_image=TransposeImage(*image,exception);
3071  break;
3072  }
3073  if (LocaleCompare("transverse",option+1) == 0)
3074  {
3075  /*
3076  Transverse image scanlines.
3077  */
3078  (void) SyncImageSettings(mogrify_info,*image,exception);
3079  mogrify_image=TransverseImage(*image,exception);
3080  break;
3081  }
3082  if (LocaleCompare("treedepth",option+1) == 0)
3083  {
3084  quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3085  break;
3086  }
3087  if (LocaleCompare("trim",option+1) == 0)
3088  {
3089  /*
3090  Trim image.
3091  */
3092  (void) SyncImageSettings(mogrify_info,*image,exception);
3093  mogrify_image=TrimImage(*image,exception);
3094  break;
3095  }
3096  if (LocaleCompare("type",option+1) == 0)
3097  {
3098  ImageType
3099  type;
3100 
3101  (void) SyncImageSettings(mogrify_info,*image,exception);
3102  if (*option == '+')
3103  type=UndefinedType;
3104  else
3105  type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3106  argv[i+1]);
3107  (*image)->type=UndefinedType;
3108  (void) SetImageType(*image,type,exception);
3109  break;
3110  }
3111  break;
3112  }
3113  case 'u':
3114  {
3115  if (LocaleCompare("undercolor",option+1) == 0)
3116  {
3117  (void) QueryColorCompliance(argv[i+1],AllCompliance,
3118  &draw_info->undercolor,exception);
3119  break;
3120  }
3121  if (LocaleCompare("unique",option+1) == 0)
3122  {
3123  if (*option == '+')
3124  {
3125  (void) DeleteImageArtifact(*image,"identify:unique-colors");
3126  break;
3127  }
3128  (void) SetImageArtifact(*image,"identify:unique-colors","true");
3129  (void) SetImageArtifact(*image,"verbose","true");
3130  break;
3131  }
3132  if (LocaleCompare("unique-colors",option+1) == 0)
3133  {
3134  /*
3135  Unique image colors.
3136  */
3137  (void) SyncImageSettings(mogrify_info,*image,exception);
3138  mogrify_image=UniqueImageColors(*image,exception);
3139  break;
3140  }
3141  if (LocaleCompare("unsharp",option+1) == 0)
3142  {
3143  /*
3144  Unsharp mask image.
3145  */
3146  (void) SyncImageSettings(mogrify_info,*image,exception);
3147  flags=ParseGeometry(argv[i+1],&geometry_info);
3148  if ((flags & SigmaValue) == 0)
3149  geometry_info.sigma=1.0;
3150  if ((flags & XiValue) == 0)
3151  geometry_info.xi=1.0;
3152  if ((flags & PsiValue) == 0)
3153  geometry_info.psi=0.05;
3154  mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3155  geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3156  exception);
3157  break;
3158  }
3159  break;
3160  }
3161  case 'v':
3162  {
3163  if (LocaleCompare("verbose",option+1) == 0)
3164  {
3165  (void) SetImageArtifact(*image,option+1,
3166  *option == '+' ? "false" : "true");
3167  break;
3168  }
3169  if (LocaleCompare("vignette",option+1) == 0)
3170  {
3171  /*
3172  Vignette image.
3173  */
3174  (void) SyncImageSettings(mogrify_info,*image,exception);
3175  flags=ParseGeometry(argv[i+1],&geometry_info);
3176  if ((flags & SigmaValue) == 0)
3177  geometry_info.sigma=1.0;
3178  if ((flags & XiValue) == 0)
3179  geometry_info.xi=0.1*(*image)->columns;
3180  if ((flags & PsiValue) == 0)
3181  geometry_info.psi=0.1*(*image)->rows;
3182  if ((flags & PercentValue) != 0)
3183  {
3184  geometry_info.xi*=(double) (*image)->columns/100.0;
3185  geometry_info.psi*=(double) (*image)->rows/100.0;
3186  }
3187  mogrify_image=VignetteImage(*image,geometry_info.rho,
3188  geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3189  (ssize_t) ceil(geometry_info.psi-0.5),exception);
3190  break;
3191  }
3192  if (LocaleCompare("virtual-pixel",option+1) == 0)
3193  {
3194  if (*option == '+')
3195  {
3196  (void) SetImageVirtualPixelMethod(*image,
3197  UndefinedVirtualPixelMethod,exception);
3198  break;
3199  }
3200  (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3201  ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3202  argv[i+1]),exception);
3203  break;
3204  }
3205  break;
3206  }
3207  case 'w':
3208  {
3209  if (LocaleCompare("wave",option+1) == 0)
3210  {
3211  /*
3212  Wave image.
3213  */
3214  (void) SyncImageSettings(mogrify_info,*image,exception);
3215  flags=ParseGeometry(argv[i+1],&geometry_info);
3216  if ((flags & SigmaValue) == 0)
3217  geometry_info.sigma=1.0;
3218  mogrify_image=WaveImage(*image,geometry_info.rho,
3219  geometry_info.sigma,interpolate_method,exception);
3220  break;
3221  }
3222  if (LocaleCompare("wavelet-denoise",option+1) == 0)
3223  {
3224  /*
3225  Wavelet denoise image.
3226  */
3227  (void) SyncImageSettings(mogrify_info,*image,exception);
3228  flags=ParseGeometry(argv[i+1],&geometry_info);
3229  if ((flags & PercentValue) != 0)
3230  {
3231  geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3232  geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3233  100.0;
3234  }
3235  if ((flags & SigmaValue) == 0)
3236  geometry_info.sigma=0.0;
3237  mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3238  geometry_info.sigma,exception);
3239  break;
3240  }
3241  if (LocaleCompare("weight",option+1) == 0)
3242  {
3243  ssize_t
3244  weight;
3245 
3246  weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3247  argv[i+1]);
3248  if (weight == -1)
3249  weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3250  draw_info->weight=(size_t) weight;
3251  break;
3252  }
3253  if (LocaleCompare("white-balance",option+1) == 0)
3254  {
3255  /*
3256  White balance image.
3257  */
3258  (void) SyncImageSettings(mogrify_info,*image,exception);
3259  (void) WhiteBalanceImage(*image,exception);
3260  break;
3261  }
3262  if (LocaleCompare("white-threshold",option+1) == 0)
3263  {
3264  /*
3265  White threshold image.
3266  */
3267  (void) SyncImageSettings(mogrify_info,*image,exception);
3268  (void) WhiteThresholdImage(*image,argv[i+1],exception);
3269  break;
3270  }
3271  if (LocaleCompare("write-mask",option+1) == 0)
3272  {
3273  Image
3274  *mask;
3275 
3276  (void) SyncImageSettings(mogrify_info,*image,exception);
3277  if (*option == '+')
3278  {
3279  /*
3280  Remove a mask.
3281  */
3282  (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
3283  exception);
3284  break;
3285  }
3286  /*
3287  Set the image mask.
3288  */
3289  mask=GetImageCache(mogrify_info,argv[i+1],exception);
3290  if (mask == (Image *) NULL)
3291  break;
3292  (void) SetImageMask(*image,WritePixelMask,mask,exception);
3293  mask=DestroyImage(mask);
3294  break;
3295  }
3296  if (LocaleCompare("word-break",option+1) == 0)
3297  {
3298  (void) SetImageOption(image_info,option+1,argv[i+1]);
3299  break;
3300  }
3301  break;
3302  }
3303  default:
3304  break;
3305  }
3306  /*
3307  Replace current image with any image that was generated
3308  */
3309  if (mogrify_image != (Image *) NULL)
3310  ReplaceImageInListReturnLast(image,mogrify_image);
3311  i+=count;
3312  }
3313  /*
3314  Free resources.
3315  */
3316  quantize_info=DestroyQuantizeInfo(quantize_info);
3317  draw_info=DestroyDrawInfo(draw_info);
3318  mogrify_info=DestroyImageInfo(mogrify_info);
3319  status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3320  return(status == 0 ? MagickFalse : MagickTrue);
3321 }
3322 
3323 /*
3324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3325 % %
3326 % %
3327 % %
3328 + M o g r i f y I m a g e C o m m a n d %
3329 % %
3330 % %
3331 % %
3332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3333 %
3334 % MogrifyImageCommand() transforms an image or a sequence of images. These
3335 % transforms include image scaling, image rotation, color reduction, and
3336 % others. The transmogrified image overwrites the original image.
3337 %
3338 % The format of the MogrifyImageCommand method is:
3339 %
3340 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3341 % const char **argv,char **metadata,ExceptionInfo *exception)
3342 %
3343 % A description of each parameter follows:
3344 %
3345 % o image_info: the image info.
3346 %
3347 % o argc: the number of elements in the argument vector.
3348 %
3349 % o argv: A text array containing the command line arguments.
3350 %
3351 % o metadata: any metadata is returned here.
3352 %
3353 % o exception: return any errors or warnings in this structure.
3354 %
3355 */
3356 
3357 static MagickBooleanType MogrifyUsage(void)
3358 {
3359  static const char
3360  channel_operators[] =
3361  " -channel-fx expression\n"
3362  " exchange, extract, or transfer one or more image channels\n"
3363  " -separate separate an image channel into a grayscale image",
3364  miscellaneous[] =
3365  " -debug events display copious debugging information\n"
3366  " -distribute-cache port\n"
3367  " distributed pixel cache spanning one or more servers\n"
3368  " -help print program options\n"
3369  " -list type print a list of supported option arguments\n"
3370  " -log format format of debugging information\n"
3371  " -version print version information",
3372  operators[] =
3373  " -adaptive-blur geometry\n"
3374  " adaptively blur pixels; decrease effect near edges\n"
3375  " -adaptive-resize geometry\n"
3376  " adaptively resize image using 'mesh' interpolation\n"
3377  " -adaptive-sharpen geometry\n"
3378  " adaptively sharpen pixels; increase effect near edges\n"
3379  " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3380  " transparent, extract, background, or shape\n"
3381  " -annotate geometry text\n"
3382  " annotate the image with text\n"
3383  " -auto-gamma automagically adjust gamma level of image\n"
3384  " -auto-level automagically adjust color levels of image\n"
3385  " -auto-orient automagically orient (rotate) image\n"
3386  " -auto-threshold method\n"
3387  " automatically perform image thresholding\n"
3388  " -bench iterations measure performance\n"
3389  " -bilateral-blur geometry\n"
3390  " non-linear, edge-preserving, and noise-reducing smoothing filter\n"
3391  " -black-threshold value\n"
3392  " force all pixels below the threshold into black\n"
3393  " -blue-shift simulate a scene at nighttime in the moonlight\n"
3394  " -blur geometry reduce image noise and reduce detail levels\n"
3395  " -border geometry surround image with a border of color\n"
3396  " -bordercolor color border color\n"
3397  " -brightness-contrast geometry\n"
3398  " improve brightness / contrast of the image\n"
3399  " -canny geometry detect edges in the image\n"
3400  " -cdl filename color correct with a color decision list\n"
3401  " -channel mask set the image channel mask\n"
3402  " -charcoal geometry simulate a charcoal drawing\n"
3403  " -chop geometry remove pixels from the image interior\n"
3404  " -clahe geometry contrast limited adaptive histogram equalization\n"
3405  " -clamp keep pixel values in range (0-QuantumRange)\n"
3406  " -clip clip along the first path from the 8BIM profile\n"
3407  " -clip-mask filename associate a clip mask with the image\n"
3408  " -clip-path id clip along a named path from the 8BIM profile\n"
3409  " -colorize value colorize the image with the fill color\n"
3410  " -color-matrix matrix apply color correction to the image\n"
3411  " -colors value preferred number of colors in the image\n"
3412  " -color-threshold start_color-stop_color\n"
3413  " force all pixels in the color range to white otherwise black\n"
3414  " -connected-components connectivity\n"
3415  " connected-components uniquely labeled\n"
3416  " -contrast enhance or reduce the image contrast\n"
3417  " -contrast-stretch geometry\n"
3418  " improve contrast by 'stretching' the intensity range\n"
3419  " -convolve coefficients\n"
3420  " apply a convolution kernel to the image\n"
3421  " -cycle amount cycle the image colormap\n"
3422  " -decipher filename convert cipher pixels to plain pixels\n"
3423  " -deskew threshold straighten an image\n"
3424  " -despeckle reduce the speckles within an image\n"
3425  " -distort method args\n"
3426  " distort images according to given method ad args\n"
3427  " -draw string annotate the image with a graphic primitive\n"
3428  " -edge radius apply a filter to detect edges in the image\n"
3429  " -encipher filename convert plain pixels to cipher pixels\n"
3430  " -emboss radius emboss an image\n"
3431  " -enhance apply a digital filter to enhance a noisy image\n"
3432  " -equalize perform histogram equalization to an image\n"
3433  " -evaluate operator value\n"
3434  " evaluate an arithmetic, relational, or logical expression\n"
3435  " -extent geometry set the image size\n"
3436  " -extract geometry extract area from image\n"
3437  " -fft implements the discrete Fourier transform (DFT)\n"
3438  " -flip flip image vertically\n"
3439  " -floodfill geometry color\n"
3440  " floodfill the image with color\n"
3441  " -flop flop image horizontally\n"
3442  " -frame geometry surround image with an ornamental border\n"
3443  " -function name parameters\n"
3444  " apply function over image values\n"
3445  " -gamma value level of gamma correction\n"
3446  " -gaussian-blur geometry\n"
3447  " reduce image noise and reduce detail levels\n"
3448  " -geometry geometry preferred size or location of the image\n"
3449  " -grayscale method convert image to grayscale\n"
3450  " -hough-lines geometry\n"
3451  " identify lines in the image\n"
3452  " -identify identify the format and characteristics of the image\n"
3453  " -ift implements the inverse discrete Fourier transform (DFT)\n"
3454  " -implode amount implode image pixels about the center\n"
3455  " -integral calculate the sum of values (pixel values) in the image\n"
3456  " -interpolative-resize geometry\n"
3457  " resize image using interpolation\n"
3458  " -kmeans geometry K means color reduction\n"
3459  " -kuwahara geometry edge preserving noise reduction filter\n"
3460  " -lat geometry local adaptive thresholding\n"
3461  " -level value adjust the level of image contrast\n"
3462  " -level-colors color,color\n"
3463  " level image with the given colors\n"
3464  " -linear-stretch geometry\n"
3465  " improve contrast by 'stretching with saturation'\n"
3466  " -liquid-rescale geometry\n"
3467  " rescale image with seam-carving\n"
3468  " -local-contrast geometry\n"
3469  " enhance local contrast\n"
3470  " -magnify double the size of the image with pixel art scaling\n"
3471  " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3472  " -median geometry apply a median filter to the image\n"
3473  " -mode geometry make each pixel the 'predominant color' of the\n"
3474  " neighborhood\n"
3475  " -modulate value vary the brightness, saturation, and hue\n"
3476  " -monochrome transform image to black and white\n"
3477  " -morphology method kernel\n"
3478  " apply a morphology method to the image\n"
3479  " -motion-blur geometry\n"
3480  " simulate motion blur\n"
3481  " -negate replace every pixel with its complementary color \n"
3482  " -noise geometry add or reduce noise in an image\n"
3483  " -normalize transform image to span the full range of colors\n"
3484  " -opaque color change this color to the fill color\n"
3485  " -ordered-dither NxN\n"
3486  " add a noise pattern to the image with specific\n"
3487  " amplitudes\n"
3488  " -paint radius simulate an oil painting\n"
3489  " -perceptible epsilon\n"
3490  " pixel value less than |epsilon| become epsilon or\n"
3491  " -epsilon\n"
3492  " -polaroid angle simulate a Polaroid picture\n"
3493  " -posterize levels reduce the image to a limited number of color levels\n"
3494  " -profile filename add, delete, or apply an image profile\n"
3495  " -quantize colorspace reduce colors in this colorspace\n"
3496  " -raise value lighten/darken image edges to create a 3-D effect\n"
3497  " -random-threshold low,high\n"
3498  " random threshold the image\n"
3499  " -range-threshold values\n"
3500  " perform either hard or soft thresholding within some range of values in an image\n"
3501  " -region geometry apply options to a portion of the image\n"
3502  " -render render vector graphics\n"
3503  " -repage geometry size and location of an image canvas\n"
3504  " -resample geometry change the resolution of an image\n"
3505  " -reshape geometry reshape the image\n"
3506  " -resize geometry resize the image\n"
3507  " -roll geometry roll an image vertically or horizontally\n"
3508  " -rotate degrees apply Paeth rotation to the image\n"
3509  " -rotational-blur angle\n"
3510  " rotational blur the image\n"
3511  " -sample geometry scale image with pixel sampling\n"
3512  " -scale geometry scale the image\n"
3513  " -segment values segment an image\n"
3514  " -selective-blur geometry\n"
3515  " selectively blur pixels within a contrast threshold\n"
3516  " -sepia-tone threshold\n"
3517  " simulate a sepia-toned photo\n"
3518  " -set property value set an image property\n"
3519  " -shade degrees shade the image using a distant light source\n"
3520  " -shadow geometry simulate an image shadow\n"
3521  " -sharpen geometry sharpen the image\n"
3522  " -shave geometry shave pixels from the image edges\n"
3523  " -shear geometry slide one edge of the image along the X or Y axis\n"
3524  " -sigmoidal-contrast geometry\n"
3525  " increase the contrast without saturating highlights or\n"
3526  " shadows\n"
3527  " -sketch geometry simulate a pencil sketch\n"
3528  " -solarize threshold negate all pixels above the threshold level\n"
3529  " -sort-pixels sort each scanline in ascending order of intensity\n"
3530  " -sparse-color method args\n"
3531  " fill in a image based on a few color points\n"
3532  " -splice geometry splice the background color into the image\n"
3533  " -spread radius displace image pixels by a random amount\n"
3534  " -statistic type radius\n"
3535  " replace each pixel with corresponding statistic from the neighborhood\n"
3536  " -strip strip image of all profiles and comments\n"
3537  " -swirl degrees swirl image pixels about the center\n"
3538  " -threshold value threshold the image\n"
3539  " -thumbnail geometry create a thumbnail of the image\n"
3540  " -tile filename tile image when filling a graphic primitive\n"
3541  " -tint value tint the image with the fill color\n"
3542  " -transform affine transform image\n"
3543  " -transparent color make this color transparent within the image\n"
3544  " -transpose flip image vertically and rotate 90 degrees\n"
3545  " -transverse flop image horizontally and rotate 270 degrees\n"
3546  " -trim trim image edges\n"
3547  " -type type image type\n"
3548  " -unique-colors discard all but one of any pixel color\n"
3549  " -unsharp geometry sharpen the image\n"
3550  " -vignette geometry soften the edges of the image in vignette style\n"
3551  " -wave geometry alter an image along a sine wave\n"
3552  " -wavelet-denoise threshold\n"
3553  " removes noise from the image using a wavelet transform\n"
3554  " -white-balance automagically adjust white balance of image\n"
3555  " -white-threshold value\n"
3556  " force all pixels above the threshold into white",
3557  sequence_operators[] =
3558  " -affinity filename transform image colors to match this set of colors\n"
3559  " -append append an image sequence\n"
3560  " -clut apply a color lookup table to the image\n"
3561  " -coalesce merge a sequence of images\n"
3562  " -combine combine a sequence of images\n"
3563  " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3564  " -complex operator perform complex mathematics on an image sequence\n"
3565  " -composite composite image\n"
3566  " -copy geometry offset\n"
3567  " copy pixels from one area of an image to another\n"
3568  " -crop geometry cut out a rectangular region of the image\n"
3569  " -deconstruct break down an image sequence into constituent parts\n"
3570  " -evaluate-sequence operator\n"
3571  " evaluate an arithmetic, relational, or logical expression\n"
3572  " -flatten flatten a sequence of images\n"
3573  " -fx expression apply mathematical expression to an image channel(s)\n"
3574  " -hald-clut apply a Hald color lookup table to the image\n"
3575  " -layers method optimize, merge, or compare image layers\n"
3576  " -morph value morph an image sequence\n"
3577  " -mosaic create a mosaic from an image sequence\n"
3578  " -poly terms build a polynomial from the image sequence and the corresponding\n"
3579  " terms (coefficients and degree pairs).\n"
3580  " -print string interpret string and print to console\n"
3581  " -process arguments process the image with a custom image filter\n"
3582  " -smush geometry smush an image sequence together\n"
3583  " -write filename write images to this file",
3584  settings[] =
3585  " -adjoin join images into a single multi-image file\n"
3586  " -affine matrix affine transform matrix\n"
3587  " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3588  " -antialias remove pixel-aliasing\n"
3589  " -authenticate password\n"
3590  " decipher image with this password\n"
3591  " -attenuate value lessen (or intensify) when adding noise to an image\n"
3592  " -background color background color\n"
3593  " -bias value add bias when convolving an image\n"
3594  " -black-point-compensation\n"
3595  " use black point compensation\n"
3596  " -blue-primary point chromaticity blue primary point\n"
3597  " -bordercolor color border color\n"
3598  " -caption string assign a caption to an image\n"
3599  " -colorspace type alternate image colorspace\n"
3600  " -comment string annotate image with comment\n"
3601  " -compose operator set image composite operator\n"
3602  " -compress type type of pixel compression when writing the image\n"
3603  " -define format:option=value\n"
3604  " define one or more image format options\n"
3605  " -delay value display the next image after pausing\n"
3606  " -density geometry horizontal and vertical density of the image\n"
3607  " -depth value image depth\n"
3608  " -direction type render text right-to-left or left-to-right\n"
3609  " -display server get image or font from this X server\n"
3610  " -dispose method layer disposal method\n"
3611  " -dither method apply error diffusion to image\n"
3612  " -encoding type text encoding type\n"
3613  " -endian type endianness (MSB or LSB) of the image\n"
3614  " -family name render text with this font family\n"
3615  " -features distance analyze image features (e.g. contrast, correlation)\n"
3616  " -fill color color to use when filling a graphic primitive\n"
3617  " -filter type use this filter when resizing an image\n"
3618  " -font name render text with this font\n"
3619  " -format \"string\" output formatted image characteristics\n"
3620  " -fuzz distance colors within this distance are considered equal\n"
3621  " -gravity type horizontal and vertical text placement\n"
3622  " -green-primary point chromaticity green primary point\n"
3623  " -illuminant type reference illuminant\n"
3624  " -intensity method method to generate an intensity value from a pixel\n"
3625  " -intent type type of rendering intent when managing the image color\n"
3626  " -interlace type type of image interlacing scheme\n"
3627  " -interline-spacing value\n"
3628  " set the space between two text lines\n"
3629  " -interpolate method pixel color interpolation method\n"
3630  " -interword-spacing value\n"
3631  " set the space between two words\n"
3632  " -kerning value set the space between two letters\n"
3633  " -label string assign a label to an image\n"
3634  " -limit type value pixel cache resource limit\n"
3635  " -loop iterations add Netscape loop extension to your GIF animation\n"
3636  " -matte store matte channel if the image has one\n"
3637  " -mattecolor color frame color\n"
3638  " -monitor monitor progress\n"
3639  " -orient type image orientation\n"
3640  " -page geometry size and location of an image canvas (setting)\n"
3641  " -path path write images to this path on disk\n"
3642  " -ping efficiently determine image attributes\n"
3643  " -pointsize value font point size\n"
3644  " -precision value maximum number of significant digits to print\n"
3645  " -preview type image preview type\n"
3646  " -quality value JPEG/MIFF/PNG compression level\n"
3647  " -quiet suppress all warning messages\n"
3648  " -read-mask filename associate a read mask with the image\n"
3649  " -red-primary point chromaticity red primary point\n"
3650  " -regard-warnings pay attention to warning messages\n"
3651  " -remap filename transform image colors to match this set of colors\n"
3652  " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3653  " -sampling-factor geometry\n"
3654  " horizontal and vertical sampling factor\n"
3655  " -scene value image scene number\n"
3656  " -seed value seed a new sequence of pseudo-random numbers\n"
3657  " -size geometry width and height of image\n"
3658  " -stretch type render text with this font stretch\n"
3659  " -stroke color graphic primitive stroke color\n"
3660  " -strokewidth value graphic primitive stroke width\n"
3661  " -style type render text with this font style\n"
3662  " -synchronize synchronize image to storage device\n"
3663  " -taint declare the image as modified\n"
3664  " -texture filename name of texture to tile onto the image background\n"
3665  " -tile-offset geometry\n"
3666  " tile offset\n"
3667  " -treedepth value color tree depth\n"
3668  " -transparent-color color\n"
3669  " transparent color\n"
3670  " -undercolor color annotation bounding box color\n"
3671  " -units type the units of image resolution\n"
3672  " -verbose print detailed information about the image\n"
3673  " -view FlashPix viewing transforms\n"
3674  " -virtual-pixel method\n"
3675  " virtual pixel access method\n"
3676  " -weight type render text with this font weight\n"
3677  " -white-point point chromaticity white point\n"
3678  " -word-break type sets whether line breaks appear wherever the text would otherwise overflow"
3679  " -write-mask filename associate a write mask with the image",
3680  stack_operators[] =
3681  " -delete indexes delete the image from the image sequence\n"
3682  " -duplicate count,indexes\n"
3683  " duplicate an image one or more times\n"
3684  " -insert index insert last image into the image sequence\n"
3685  " -reverse reverse image sequence\n"
3686  " -swap indexes swap two images in the image sequence";
3687 
3688  ListMagickVersion(stdout);
3689  (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3690  GetClientName());
3691  (void) fprintf(stdout,"\nImage Settings:\n");
3692  (void) fputs(settings,stdout);
3693  (void) fprintf(stdout,"\nImage Operators:\n");
3694  (void) fputs(operators,stdout);
3695  (void) fprintf(stdout,"\nImage Channel Operators:\n");
3696  (void) fputs(channel_operators,stdout);
3697  (void) fprintf(stdout,"\nImage Sequence Operators:\n");
3698  (void) fputs(sequence_operators,stdout);
3699  (void) fprintf(stdout,"\nImage Stack Operators:\n");
3700  (void) fputs(stack_operators,stdout);
3701  (void) fprintf(stdout,"\nMiscellaneous Options:\n");
3702  (void) fputs(miscellaneous,stdout);
3703  (void) fprintf(stdout,
3704  "\nBy default, the image format of 'file' is determined by its magic\n");
3705  (void) fprintf(stdout,
3706  "number. To specify a particular image format, precede the filename\n");
3707  (void) fprintf(stdout,
3708  "with an image format name and a colon (i.e. ps:image) or specify the\n");
3709  (void) fprintf(stdout,
3710  "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3711  (void) fprintf(stdout,"'-' for standard input or output.\n");
3712  return(MagickTrue);
3713 }
3714 
3715 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3716  int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3717 {
3718 #define DestroyMogrify() \
3719 { \
3720  if (format != (char *) NULL) \
3721  format=DestroyString(format); \
3722  if (path != (char *) NULL) \
3723  path=DestroyString(path); \
3724  DestroyImageStack(); \
3725  for (i=0; i < (ssize_t) argc; i++) \
3726  argv[i]=DestroyString(argv[i]); \
3727  argv=(char **) RelinquishMagickMemory(argv); \
3728 }
3729 #define ThrowMogrifyException(asperity,tag,option) \
3730 { \
3731  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3732  option); \
3733  DestroyMogrify(); \
3734  return(MagickFalse); \
3735 }
3736 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3737 { \
3738  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3739  "InvalidArgument","'%s': %s",argument,option); \
3740  DestroyMogrify(); \
3741  return(MagickFalse); \
3742 }
3743 
3744  char
3745  *format,
3746  *option,
3747  *path;
3748 
3749  Image
3750  *image;
3751 
3752  ImageStack
3753  image_stack[MaxImageStackDepth+1];
3754 
3755  MagickBooleanType
3756  global_colormap;
3757 
3758  MagickBooleanType
3759  fire,
3760  pend,
3761  respect_parentheses;
3762 
3763  MagickStatusType
3764  status;
3765 
3766  ssize_t
3767  i;
3768 
3769  ssize_t
3770  j,
3771  k;
3772 
3773  wand_unreferenced(metadata);
3774 
3775  /*
3776  Set defaults.
3777  */
3778  assert(image_info != (ImageInfo *) NULL);
3779  assert(image_info->signature == MagickCoreSignature);
3780  if (IsEventLogging() != MagickFalse)
3781  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3782  assert(exception != (ExceptionInfo *) NULL);
3783  if (argc == 2)
3784  {
3785  option=argv[1];
3786  if ((LocaleCompare("version",option+1) == 0) ||
3787  (LocaleCompare("-version",option+1) == 0))
3788  {
3789  ListMagickVersion(stdout);
3790  return(MagickTrue);
3791  }
3792  }
3793  if (argc < 2)
3794  {
3795  (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3796  "MissingArgument","%s","");
3797  (void) MogrifyUsage();
3798  return(MagickFalse);
3799  }
3800  format=(char *) NULL;
3801  path=(char *) NULL;
3802  global_colormap=MagickFalse;
3803  k=0;
3804  j=1;
3805  NewImageStack();
3806  option=(char *) NULL;
3807  pend=MagickFalse;
3808  respect_parentheses=MagickFalse;
3809  status=MagickTrue;
3810  /*
3811  Parse command line.
3812  */
3813  ReadCommandlLine(argc,&argv);
3814  status=ExpandFilenames(&argc,&argv);
3815  if (status == MagickFalse)
3816  ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3817  GetExceptionMessage(errno));
3818  for (i=1; i < (ssize_t) argc; i++)
3819  {
3820  option=argv[i];
3821  if (LocaleCompare(option,"(") == 0)
3822  {
3823  FireImageStack(MagickFalse,MagickTrue,pend);
3824  if (k == MaxImageStackDepth)
3825  ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3826  option);
3827  PushImageStack();
3828  continue;
3829  }
3830  if (LocaleCompare(option,")") == 0)
3831  {
3832  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3833  if (k == 0)
3834  ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3835  PopImageStack();
3836  continue;
3837  }
3838  if (IsCommandOption(option) == MagickFalse)
3839  {
3840  char
3841  backup_filename[MagickPathExtent],
3842  *filename,
3843  magic[MagickPathExtent];
3844 
3845  Image
3846  *images;
3847 
3848  struct stat
3849  properties;
3850 
3851  /*
3852  Option is a file name: begin by reading image from specified file.
3853  */
3854  FireImageStack(MagickFalse,MagickFalse,pend);
3855  filename=argv[i];
3856  if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3857  filename=argv[++i];
3858  images=ReadImages(image_info,filename,exception);
3859  status&=(MagickStatusType) (images != (Image *) NULL) &&
3860  (exception->severity < ErrorException);
3861  if (images == (Image *) NULL)
3862  continue;
3863  properties=(*GetBlobProperties(images));
3864  if (format != (char *) NULL)
3865  GetPathComponent(images->magick_filename,
3866  BasePathSansCompressExtension,images->filename);
3867  if (path != (char *) NULL)
3868  {
3869  GetPathComponent(option,TailPath,filename);
3870  (void) FormatLocaleString(images->filename,MagickPathExtent,
3871  "%s%c%s",path,*DirectorySeparator,filename);
3872  }
3873  if (format != (char *) NULL)
3874  AppendImageFormat(format,images->filename);
3875  AppendImageStack(images);
3876  FinalizeImageSettings(image_info,image,MagickFalse);
3877  if (image == (Image *) NULL)
3878  continue;
3879  if (global_colormap != MagickFalse)
3880  {
3881  QuantizeInfo
3882  *quantize_info;
3883 
3884  quantize_info=AcquireQuantizeInfo(image_info);
3885  (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3886  quantize_info=DestroyQuantizeInfo(quantize_info);
3887  }
3888  *backup_filename='\0';
3889  *magic='\0';
3890  GetPathComponent(filename,MagickPath,magic);
3891  if (*magic != '\0')
3892  {
3893  char
3894  name[MagickPathExtent];
3895 
3896  if (format != (char *) NULL)
3897  (void) CopyMagickString(magic,format,MagickPathExtent);
3898  (void) FormatLocaleString(name,MagickPathExtent,"%s:%s",magic,
3899  image->filename);
3900  (void) CopyMagickString(image->filename,name,MagickPathExtent);
3901  }
3902  if ((LocaleCompare(image->filename,"-") != 0) &&
3903  (IsPathWritable(image->filename) != MagickFalse))
3904  {
3905  /*
3906  Rename image file as backup.
3907  */
3908  (void) CopyMagickString(backup_filename,image->filename,
3909  MagickPathExtent);
3910  for (j=0; j < 6; j++)
3911  {
3912  (void) ConcatenateMagickString(backup_filename,"~",
3913  MagickPathExtent);
3914  if (IsPathAccessible(backup_filename) == MagickFalse)
3915  break;
3916  }
3917  if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3918  (rename_utf8(image->filename,backup_filename) != 0))
3919  *backup_filename='\0';
3920  }
3921  /*
3922  Write transmogrified image to disk.
3923  */
3924  image_info->synchronize=MagickTrue;
3925  status&=(MagickStatusType) WriteImages(image_info,image,image->filename,
3926  exception);
3927  if (status != MagickFalse)
3928  {
3929  {
3930  MagickBooleanType
3931  preserve_timestamp;
3932 
3933  preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3934  "preserve-timestamp"));
3935  if (preserve_timestamp != MagickFalse)
3936  (void) set_file_timestamp(image->filename,&properties);
3937  }
3938  if (*backup_filename != '\0')
3939  (void) remove_utf8(backup_filename);
3940  }
3941  else
3942  if (*backup_filename != '\0')
3943  (void) rename_utf8(backup_filename,image->filename);
3944  RemoveAllImageStack();
3945  continue;
3946  }
3947  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3948  switch (*(option+1))
3949  {
3950  case 'a':
3951  {
3952  if (LocaleCompare("adaptive-blur",option+1) == 0)
3953  {
3954  i++;
3955  if (i == (ssize_t) argc)
3956  ThrowMogrifyException(OptionError,"MissingArgument",option);
3957  if (IsGeometry(argv[i]) == MagickFalse)
3958  ThrowMogrifyInvalidArgumentException(option,argv[i]);
3959  break;
3960  }
3961  if (LocaleCompare("adaptive-resize",option+1) == 0)
3962  {
3963  i++;
3964  if (i == (ssize_t) argc)
3965  ThrowMogrifyException(OptionError,"MissingArgument",option);
3966  if (IsGeometry(argv[i]) == MagickFalse)
3967  ThrowMogrifyInvalidArgumentException(option,argv[i]);
3968  break;
3969  }
3970  if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3971  {
3972  i++;
3973  if (i == (ssize_t) argc)
3974  ThrowMogrifyException(OptionError,"MissingArgument",option);
3975  if (IsGeometry(argv[i]) == MagickFalse)
3976  ThrowMogrifyInvalidArgumentException(option,argv[i]);
3977  break;
3978  }
3979  if (LocaleCompare("affine",option+1) == 0)
3980  {
3981  if (*option == '+')
3982  break;
3983  i++;
3984  if (i == (ssize_t) argc)
3985  ThrowMogrifyException(OptionError,"MissingArgument",option);
3986  break;
3987  }
3988  if (LocaleCompare("alpha",option+1) == 0)
3989  {
3990  ssize_t
3991  type;
3992 
3993  if (*option == '+')
3994  break;
3995  i++;
3996  if (i == (ssize_t) argc)
3997  ThrowMogrifyException(OptionError,"MissingArgument",option);
3998  type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
3999  argv[i]);
4000  if (type < 0)
4001  ThrowMogrifyException(OptionError,
4002  "UnrecognizedAlphaChannelOption",argv[i]);
4003  break;
4004  }
4005  if (LocaleCompare("annotate",option+1) == 0)
4006  {
4007  if (*option == '+')
4008  break;
4009  i++;
4010  if (i == (ssize_t) argc)
4011  ThrowMogrifyException(OptionError,"MissingArgument",option);
4012  if (IsGeometry(argv[i]) == MagickFalse)
4013  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4014  if (i == (ssize_t) argc)
4015  ThrowMogrifyException(OptionError,"MissingArgument",option);
4016  i++;
4017  break;
4018  }
4019  if (LocaleCompare("antialias",option+1) == 0)
4020  break;
4021  if (LocaleCompare("append",option+1) == 0)
4022  break;
4023  if (LocaleCompare("attenuate",option+1) == 0)
4024  {
4025  if (*option == '+')
4026  break;
4027  i++;
4028  if (i == (ssize_t) argc)
4029  ThrowMogrifyException(OptionError,"MissingArgument",option);
4030  if (IsGeometry(argv[i]) == MagickFalse)
4031  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4032  break;
4033  }
4034  if (LocaleCompare("authenticate",option+1) == 0)
4035  {
4036  if (*option == '+')
4037  break;
4038  i++;
4039  if (i == (ssize_t) argc)
4040  ThrowMogrifyException(OptionError,"MissingArgument",option);
4041  break;
4042  }
4043  if (LocaleCompare("auto-gamma",option+1) == 0)
4044  break;
4045  if (LocaleCompare("auto-level",option+1) == 0)
4046  break;
4047  if (LocaleCompare("auto-orient",option+1) == 0)
4048  break;
4049  if (LocaleCompare("auto-threshold",option+1) == 0)
4050  {
4051  ssize_t
4052  method;
4053 
4054  if (*option == '+')
4055  break;
4056  i++;
4057  if (i == (ssize_t) argc)
4058  ThrowMogrifyException(OptionError,"MissingArgument",option);
4059  method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4060  argv[i]);
4061  if (method < 0)
4062  ThrowMogrifyException(OptionError,"UnrecognizedThresholdMethod",
4063  argv[i]);
4064  break;
4065  }
4066  if (LocaleCompare("average",option+1) == 0)
4067  break;
4068  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4069  }
4070  case 'b':
4071  {
4072  if (LocaleCompare("background",option+1) == 0)
4073  {
4074  if (*option == '+')
4075  break;
4076  i++;
4077  if (i == (ssize_t) argc)
4078  ThrowMogrifyException(OptionError,"MissingArgument",option);
4079  break;
4080  }
4081  if (LocaleCompare("bias",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("bilateral-blur",option+1) == 0)
4093  {
4094  if (*option == '+')
4095  break;
4096  i++;
4097  if (i == (ssize_t) argc)
4098  ThrowMogrifyException(OptionError,"MissingArgument",option);
4099  if (IsGeometry(argv[i]) == MagickFalse)
4100  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4101  break;
4102  }
4103  if (LocaleCompare("black-point-compensation",option+1) == 0)
4104  break;
4105  if (LocaleCompare("black-threshold",option+1) == 0)
4106  {
4107  if (*option == '+')
4108  break;
4109  i++;
4110  if (i == (ssize_t) argc)
4111  ThrowMogrifyException(OptionError,"MissingArgument",option);
4112  if (IsGeometry(argv[i]) == MagickFalse)
4113  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4114  break;
4115  }
4116  if (LocaleCompare("blue-primary",option+1) == 0)
4117  {
4118  if (*option == '+')
4119  break;
4120  i++;
4121  if (i == (ssize_t) argc)
4122  ThrowMogrifyException(OptionError,"MissingArgument",option);
4123  if (IsGeometry(argv[i]) == MagickFalse)
4124  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4125  break;
4126  }
4127  if (LocaleCompare("blue-shift",option+1) == 0)
4128  {
4129  i++;
4130  if (i == (ssize_t) argc)
4131  ThrowMogrifyException(OptionError,"MissingArgument",option);
4132  if (IsGeometry(argv[i]) == MagickFalse)
4133  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4134  break;
4135  }
4136  if (LocaleCompare("blur",option+1) == 0)
4137  {
4138  i++;
4139  if (i == (ssize_t) argc)
4140  ThrowMogrifyException(OptionError,"MissingArgument",option);
4141  if (IsGeometry(argv[i]) == MagickFalse)
4142  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4143  break;
4144  }
4145  if (LocaleCompare("border",option+1) == 0)
4146  {
4147  if (*option == '+')
4148  break;
4149  i++;
4150  if (i == (ssize_t) argc)
4151  ThrowMogrifyException(OptionError,"MissingArgument",option);
4152  if (IsGeometry(argv[i]) == MagickFalse)
4153  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4154  break;
4155  }
4156  if (LocaleCompare("bordercolor",option+1) == 0)
4157  {
4158  if (*option == '+')
4159  break;
4160  i++;
4161  if (i == (ssize_t) argc)
4162  ThrowMogrifyException(OptionError,"MissingArgument",option);
4163  break;
4164  }
4165  if (LocaleCompare("box",option+1) == 0)
4166  {
4167  if (*option == '+')
4168  break;
4169  i++;
4170  if (i == (ssize_t) argc)
4171  ThrowMogrifyException(OptionError,"MissingArgument",option);
4172  break;
4173  }
4174  if (LocaleCompare("brightness-contrast",option+1) == 0)
4175  {
4176  i++;
4177  if (i == (ssize_t) argc)
4178  ThrowMogrifyException(OptionError,"MissingArgument",option);
4179  if (IsGeometry(argv[i]) == MagickFalse)
4180  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4181  break;
4182  }
4183  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4184  }
4185  case 'c':
4186  {
4187  if (LocaleCompare("cache",option+1) == 0)
4188  {
4189  if (*option == '+')
4190  break;
4191  i++;
4192  if (i == (ssize_t) argc)
4193  ThrowMogrifyException(OptionError,"MissingArgument",option);
4194  if (IsGeometry(argv[i]) == MagickFalse)
4195  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4196  break;
4197  }
4198  if (LocaleCompare("canny",option+1) == 0)
4199  {
4200  if (*option == '+')
4201  break;
4202  i++;
4203  if (i == (ssize_t) argc)
4204  ThrowMogrifyException(OptionError,"MissingArgument",option);
4205  if (IsGeometry(argv[i]) == MagickFalse)
4206  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4207  break;
4208  }
4209  if (LocaleCompare("caption",option+1) == 0)
4210  {
4211  if (*option == '+')
4212  break;
4213  i++;
4214  if (i == (ssize_t) argc)
4215  ThrowMogrifyException(OptionError,"MissingArgument",option);
4216  break;
4217  }
4218  if (LocaleCompare("channel",option+1) == 0)
4219  {
4220  ssize_t
4221  channel;
4222 
4223  if (*option == '+')
4224  break;
4225  i++;
4226  if (i == (ssize_t) argc)
4227  ThrowMogrifyException(OptionError,"MissingArgument",option);
4228  channel=ParseChannelOption(argv[i]);
4229  if (channel < 0)
4230  ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4231  argv[i]);
4232  break;
4233  }
4234  if (LocaleCompare("channel-fx",option+1) == 0)
4235  {
4236  ssize_t
4237  channel;
4238 
4239  if (*option == '+')
4240  break;
4241  i++;
4242  if (i == (ssize_t) argc)
4243  ThrowMogrifyException(OptionError,"MissingArgument",option);
4244  channel=ParsePixelChannelOption(argv[i]);
4245  if (channel < 0)
4246  ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4247  argv[i]);
4248  break;
4249  }
4250  if (LocaleCompare("cdl",option+1) == 0)
4251  {
4252  if (*option == '+')
4253  break;
4254  i++;
4255  if (i == (ssize_t) argc)
4256  ThrowMogrifyException(OptionError,"MissingArgument",option);
4257  break;
4258  }
4259  if (LocaleCompare("charcoal",option+1) == 0)
4260  {
4261  if (*option == '+')
4262  break;
4263  i++;
4264  if (i == (ssize_t) argc)
4265  ThrowMogrifyException(OptionError,"MissingArgument",option);
4266  if (IsGeometry(argv[i]) == MagickFalse)
4267  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4268  break;
4269  }
4270  if (LocaleCompare("chop",option+1) == 0)
4271  {
4272  if (*option == '+')
4273  break;
4274  i++;
4275  if (i == (ssize_t) argc)
4276  ThrowMogrifyException(OptionError,"MissingArgument",option);
4277  if (IsGeometry(argv[i]) == MagickFalse)
4278  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4279  break;
4280  }
4281  if (LocaleCompare("clahe",option+1) == 0)
4282  {
4283  if (*option == '+')
4284  break;
4285  i++;
4286  if (i == (ssize_t) argc)
4287  ThrowMogrifyException(OptionError,"MissingArgument",option);
4288  if (IsGeometry(argv[i]) == MagickFalse)
4289  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4290  break;
4291  }
4292  if (LocaleCompare("clamp",option+1) == 0)
4293  break;
4294  if (LocaleCompare("clip",option+1) == 0)
4295  break;
4296  if (LocaleCompare("clip-mask",option+1) == 0)
4297  {
4298  if (*option == '+')
4299  break;
4300  i++;
4301  if (i == (ssize_t) argc)
4302  ThrowMogrifyException(OptionError,"MissingArgument",option);
4303  break;
4304  }
4305  if (LocaleCompare("clut",option+1) == 0)
4306  break;
4307  if (LocaleCompare("coalesce",option+1) == 0)
4308  break;
4309  if (LocaleCompare("colorize",option+1) == 0)
4310  {
4311  if (*option == '+')
4312  break;
4313  i++;
4314  if (i == (ssize_t) argc)
4315  ThrowMogrifyException(OptionError,"MissingArgument",option);
4316  if (IsGeometry(argv[i]) == MagickFalse)
4317  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4318  break;
4319  }
4320  if (LocaleCompare("color-matrix",option+1) == 0)
4321  {
4322  KernelInfo
4323  *kernel_info;
4324 
4325  if (*option == '+')
4326  break;
4327  i++;
4328  if (i == (ssize_t) argc)
4329  ThrowMogrifyException(OptionError,"MissingArgument",option);
4330  kernel_info=AcquireKernelInfo(argv[i],exception);
4331  if (kernel_info == (KernelInfo *) NULL)
4332  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4333  kernel_info=DestroyKernelInfo(kernel_info);
4334  break;
4335  }
4336  if (LocaleCompare("colors",option+1) == 0)
4337  {
4338  if (*option == '+')
4339  break;
4340  i++;
4341  if (i == (ssize_t) argc)
4342  ThrowMogrifyException(OptionError,"MissingArgument",option);
4343  if (IsGeometry(argv[i]) == MagickFalse)
4344  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4345  break;
4346  }
4347  if (LocaleCompare("colorspace",option+1) == 0)
4348  {
4349  ssize_t
4350  colorspace;
4351 
4352  if (*option == '+')
4353  break;
4354  i++;
4355  if (i == (ssize_t) argc)
4356  ThrowMogrifyException(OptionError,"MissingArgument",option);
4357  colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4358  argv[i]);
4359  if (colorspace < 0)
4360  ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4361  argv[i]);
4362  break;
4363  }
4364  if (LocaleCompare("color-threshold",option+1) == 0)
4365  {
4366  if (*option == '+')
4367  break;
4368  i++;
4369  if (i == (ssize_t) argc)
4370  ThrowMogrifyException(OptionError,"MissingArgument",option);
4371  break;
4372  }
4373  if (LocaleCompare("combine",option+1) == 0)
4374  {
4375  ssize_t
4376  colorspace;
4377 
4378  if (*option == '+')
4379  break;
4380  i++;
4381  if (i == (ssize_t) argc)
4382  ThrowMogrifyException(OptionError,"MissingArgument",option);
4383  colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4384  argv[i]);
4385  if (colorspace < 0)
4386  ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4387  argv[i]);
4388  break;
4389  }
4390  if (LocaleCompare("comment",option+1) == 0)
4391  {
4392  if (*option == '+')
4393  break;
4394  i++;
4395  if (i == (ssize_t) argc)
4396  ThrowMogrifyException(OptionError,"MissingArgument",option);
4397  break;
4398  }
4399  if (LocaleCompare("compare",option+1) == 0)
4400  break;
4401  if (LocaleCompare("compose",option+1) == 0)
4402  {
4403  ssize_t
4404  compose;
4405 
4406  if (*option == '+')
4407  break;
4408  i++;
4409  if (i == (ssize_t) argc)
4410  ThrowMogrifyException(OptionError,"MissingArgument",option);
4411  compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4412  argv[i]);
4413  if (compose < 0)
4414  ThrowMogrifyException(OptionError,"UnrecognizedComposeOperator",
4415  argv[i]);
4416  break;
4417  }
4418  if (LocaleCompare("composite",option+1) == 0)
4419  break;
4420  if (LocaleCompare("compress",option+1) == 0)
4421  {
4422  ssize_t
4423  compress;
4424 
4425  if (*option == '+')
4426  break;
4427  i++;
4428  if (i == (ssize_t) argc)
4429  ThrowMogrifyException(OptionError,"MissingArgument",option);
4430  compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4431  argv[i]);
4432  if (compress < 0)
4433  ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4434  argv[i]);
4435  break;
4436  }
4437  if (LocaleCompare("concurrent",option+1) == 0)
4438  break;
4439  if (LocaleCompare("connected-components",option+1) == 0)
4440  {
4441  i++;
4442  if (i == (ssize_t) argc)
4443  ThrowMogrifyException(OptionError,"MissingArgument",option);
4444  if (IsGeometry(argv[i]) == MagickFalse)
4445  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4446  break;
4447  }
4448  if (LocaleCompare("contrast",option+1) == 0)
4449  break;
4450  if (LocaleCompare("contrast-stretch",option+1) == 0)
4451  {
4452  i++;
4453  if (i == (ssize_t) argc)
4454  ThrowMogrifyException(OptionError,"MissingArgument",option);
4455  if (IsGeometry(argv[i]) == MagickFalse)
4456  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4457  break;
4458  }
4459  if (LocaleCompare("convolve",option+1) == 0)
4460  {
4461  KernelInfo
4462  *kernel_info;
4463 
4464  if (*option == '+')
4465  break;
4466  i++;
4467  if (i == (ssize_t) argc)
4468  ThrowMogrifyException(OptionError,"MissingArgument",option);
4469  kernel_info=AcquireKernelInfo(argv[i],exception);
4470  if (kernel_info == (KernelInfo *) NULL)
4471  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4472  kernel_info=DestroyKernelInfo(kernel_info);
4473  break;
4474  }
4475  if (LocaleCompare("copy",option+1) == 0)
4476  {
4477  if (*option == '+')
4478  break;
4479  i++;
4480  if (i == (ssize_t) argc)
4481  ThrowMogrifyException(OptionError,"MissingArgument",option);
4482  if (IsGeometry(argv[i]) == MagickFalse)
4483  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4484  i++;
4485  if (i == (ssize_t) argc)
4486  ThrowMogrifyException(OptionError,"MissingArgument",option);
4487  if (IsGeometry(argv[i]) == MagickFalse)
4488  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4489  break;
4490  }
4491  if (LocaleCompare("crop",option+1) == 0)
4492  {
4493  if (*option == '+')
4494  break;
4495  i++;
4496  if (i == (ssize_t) argc)
4497  ThrowMogrifyException(OptionError,"MissingArgument",option);
4498  if (IsGeometry(argv[i]) == MagickFalse)
4499  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4500  break;
4501  }
4502  if (LocaleCompare("cycle",option+1) == 0)
4503  {
4504  if (*option == '+')
4505  break;
4506  i++;
4507  if (i == (ssize_t) argc)
4508  ThrowMogrifyException(OptionError,"MissingArgument",option);
4509  if (IsGeometry(argv[i]) == MagickFalse)
4510  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4511  break;
4512  }
4513  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4514  }
4515  case 'd':
4516  {
4517  if (LocaleCompare("decipher",option+1) == 0)
4518  {
4519  if (*option == '+')
4520  break;
4521  i++;
4522  if (i == (ssize_t) argc)
4523  ThrowMogrifyException(OptionError,"MissingArgument",option);
4524  break;
4525  }
4526  if (LocaleCompare("deconstruct",option+1) == 0)
4527  break;
4528  if (LocaleCompare("debug",option+1) == 0)
4529  {
4530  ssize_t
4531  event;
4532 
4533  if (*option == '+')
4534  break;
4535  i++;
4536  if (i == (ssize_t) argc)
4537  ThrowMogrifyException(OptionError,"MissingArgument",option);
4538  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4539  if (event < 0)
4540  ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4541  argv[i]);
4542  (void) SetLogEventMask(argv[i]);
4543  break;
4544  }
4545  if (LocaleCompare("define",option+1) == 0)
4546  {
4547  i++;
4548  if (i == (ssize_t) argc)
4549  ThrowMogrifyException(OptionError,"MissingArgument",option);
4550  if (*option == '+')
4551  {
4552  const char
4553  *define;
4554 
4555  define=GetImageOption(image_info,argv[i]);
4556  if (define == (const char *) NULL)
4557  ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4558  break;
4559  }
4560  break;
4561  }
4562  if (LocaleCompare("delay",option+1) == 0)
4563  {
4564  if (*option == '+')
4565  break;
4566  i++;
4567  if (i == (ssize_t) argc)
4568  ThrowMogrifyException(OptionError,"MissingArgument",option);
4569  if (IsGeometry(argv[i]) == MagickFalse)
4570  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4571  break;
4572  }
4573  if (LocaleCompare("delete",option+1) == 0)
4574  {
4575  if (*option == '+')
4576  break;
4577  i++;
4578  if (i == (ssize_t) argc)
4579  ThrowMogrifyException(OptionError,"MissingArgument",option);
4580  if (LocaleNCompare(argv[i],"registry:",9) == 0)
4581  {
4582  (void) DeleteImageRegistry(argv[i]+9);
4583  break;
4584  }
4585  if (IsGeometry(argv[i]) == MagickFalse)
4586  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4587  break;
4588  }
4589  if (LocaleCompare("density",option+1) == 0)
4590  {
4591  if (*option == '+')
4592  break;
4593  i++;
4594  if (i == (ssize_t) argc)
4595  ThrowMogrifyException(OptionError,"MissingArgument",option);
4596  if (IsGeometry(argv[i]) == MagickFalse)
4597  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4598  break;
4599  }
4600  if (LocaleCompare("depth",option+1) == 0)
4601  {
4602  if (*option == '+')
4603  break;
4604  i++;
4605  if (i == (ssize_t) argc)
4606  ThrowMogrifyException(OptionError,"MissingArgument",option);
4607  if (IsGeometry(argv[i]) == MagickFalse)
4608  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4609  break;
4610  }
4611  if (LocaleCompare("deskew",option+1) == 0)
4612  {
4613  if (*option == '+')
4614  break;
4615  i++;
4616  if (i == (ssize_t) argc)
4617  ThrowMogrifyException(OptionError,"MissingArgument",option);
4618  if (IsGeometry(argv[i]) == MagickFalse)
4619  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4620  break;
4621  }
4622  if (LocaleCompare("despeckle",option+1) == 0)
4623  break;
4624  if (LocaleCompare("dft",option+1) == 0)
4625  break;
4626  if (LocaleCompare("direction",option+1) == 0)
4627  {
4628  ssize_t
4629  direction;
4630 
4631  if (*option == '+')
4632  break;
4633  i++;
4634  if (i == (ssize_t) argc)
4635  ThrowMogrifyException(OptionError,"MissingArgument",option);
4636  direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4637  argv[i]);
4638  if (direction < 0)
4639  ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4640  argv[i]);
4641  break;
4642  }
4643  if (LocaleCompare("display",option+1) == 0)
4644  {
4645  if (*option == '+')
4646  break;
4647  i++;
4648  if (i == (ssize_t) argc)
4649  ThrowMogrifyException(OptionError,"MissingArgument",option);
4650  break;
4651  }
4652  if (LocaleCompare("dispose",option+1) == 0)
4653  {
4654  ssize_t
4655  dispose;
4656 
4657  if (*option == '+')
4658  break;
4659  i++;
4660  if (i == (ssize_t) argc)
4661  ThrowMogrifyException(OptionError,"MissingArgument",option);
4662  dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4663  argv[i]);
4664  if (dispose < 0)
4665  ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4666  argv[i]);
4667  break;
4668  }
4669  if (LocaleCompare("distort",option+1) == 0)
4670  {
4671  ssize_t
4672  op;
4673 
4674  i++;
4675  if (i == (ssize_t) argc)
4676  ThrowMogrifyException(OptionError,"MissingArgument",option);
4677  op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4678  if (op < 0)
4679  ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4680  argv[i]);
4681  i++;
4682  if (i == (ssize_t) argc)
4683  ThrowMogrifyException(OptionError,"MissingArgument",option);
4684  break;
4685  }
4686  if (LocaleCompare("dither",option+1) == 0)
4687  {
4688  ssize_t
4689  method;
4690 
4691  if (*option == '+')
4692  break;
4693  i++;
4694  if (i == (ssize_t) argc)
4695  ThrowMogrifyException(OptionError,"MissingArgument",option);
4696  method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4697  if (method < 0)
4698  ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4699  argv[i]);
4700  break;
4701  }
4702  if (LocaleCompare("draw",option+1) == 0)
4703  {
4704  if (*option == '+')
4705  break;
4706  i++;
4707  if (i == (ssize_t) argc)
4708  ThrowMogrifyException(OptionError,"MissingArgument",option);
4709  break;
4710  }
4711  if (LocaleCompare("duplicate",option+1) == 0)
4712  {
4713  if (*option == '+')
4714  break;
4715  i++;
4716  if (i == (ssize_t) argc)
4717  ThrowMogrifyException(OptionError,"MissingArgument",option);
4718  if (IsGeometry(argv[i]) == MagickFalse)
4719  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4720  break;
4721  }
4722  if (LocaleCompare("duration",option+1) == 0)
4723  {
4724  if (*option == '+')
4725  break;
4726  i++;
4727  if (i == (ssize_t) argc)
4728  ThrowMogrifyException(OptionError,"MissingArgument",option);
4729  if (IsGeometry(argv[i]) == MagickFalse)
4730  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4731  break;
4732  }
4733  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4734  }
4735  case 'e':
4736  {
4737  if (LocaleCompare("edge",option+1) == 0)
4738  {
4739  if (*option == '+')
4740  break;
4741  i++;
4742  if (i == (ssize_t) argc)
4743  ThrowMogrifyException(OptionError,"MissingArgument",option);
4744  if (IsGeometry(argv[i]) == MagickFalse)
4745  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4746  break;
4747  }
4748  if (LocaleCompare("emboss",option+1) == 0)
4749  {
4750  if (*option == '+')
4751  break;
4752  i++;
4753  if (i == (ssize_t) argc)
4754  ThrowMogrifyException(OptionError,"MissingArgument",option);
4755  if (IsGeometry(argv[i]) == MagickFalse)
4756  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4757  break;
4758  }
4759  if (LocaleCompare("encipher",option+1) == 0)
4760  {
4761  if (*option == '+')
4762  break;
4763  i++;
4764  if (i == (ssize_t) argc)
4765  ThrowMogrifyException(OptionError,"MissingArgument",option);
4766  break;
4767  }
4768  if (LocaleCompare("encoding",option+1) == 0)
4769  {
4770  if (*option == '+')
4771  break;
4772  i++;
4773  if (i == (ssize_t) argc)
4774  ThrowMogrifyException(OptionError,"MissingArgument",option);
4775  break;
4776  }
4777  if (LocaleCompare("endian",option+1) == 0)
4778  {
4779  ssize_t
4780  endian;
4781 
4782  if (*option == '+')
4783  break;
4784  i++;
4785  if (i == (ssize_t) argc)
4786  ThrowMogrifyException(OptionError,"MissingArgument",option);
4787  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4788  if (endian < 0)
4789  ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4790  argv[i]);
4791  break;
4792  }
4793  if (LocaleCompare("enhance",option+1) == 0)
4794  break;
4795  if (LocaleCompare("equalize",option+1) == 0)
4796  break;
4797  if (LocaleCompare("evaluate",option+1) == 0)
4798  {
4799  ssize_t
4800  op;
4801 
4802  if (*option == '+')
4803  break;
4804  i++;
4805  if (i == (ssize_t) argc)
4806  ThrowMogrifyException(OptionError,"MissingArgument",option);
4807  op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4808  if (op < 0)
4809  ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4810  argv[i]);
4811  i++;
4812  if (i == (ssize_t) argc)
4813  ThrowMogrifyException(OptionError,"MissingArgument",option);
4814  if (IsGeometry(argv[i]) == MagickFalse)
4815  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4816  break;
4817  }
4818  if (LocaleCompare("evaluate-sequence",option+1) == 0)
4819  {
4820  ssize_t
4821  op;
4822 
4823  if (*option == '+')
4824  break;
4825  i++;
4826  if (i == (ssize_t) argc)
4827  ThrowMogrifyException(OptionError,"MissingArgument",option);
4828  op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4829  if (op < 0)
4830  ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4831  argv[i]);
4832  break;
4833  }
4834  if (LocaleCompare("extent",option+1) == 0)
4835  {
4836  if (*option == '+')
4837  break;
4838  i++;
4839  if (i == (ssize_t) argc)
4840  ThrowMogrifyException(OptionError,"MissingArgument",option);
4841  if (IsGeometry(argv[i]) == MagickFalse)
4842  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4843  break;
4844  }
4845  if (LocaleCompare("extract",option+1) == 0)
4846  {
4847  if (*option == '+')
4848  break;
4849  i++;
4850  if (i == (ssize_t) argc)
4851  ThrowMogrifyException(OptionError,"MissingArgument",option);
4852  if (IsGeometry(argv[i]) == MagickFalse)
4853  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4854  break;
4855  }
4856  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4857  }
4858  case 'f':
4859  {
4860  if (LocaleCompare("family",option+1) == 0)
4861  {
4862  if (*option == '+')
4863  break;
4864  i++;
4865  if (i == (ssize_t) argc)
4866  ThrowMogrifyException(OptionError,"MissingArgument",option);
4867  break;
4868  }
4869  if (LocaleCompare("features",option+1) == 0)
4870  {
4871  if (*option == '+')
4872  break;
4873  i++;
4874  if (i == (ssize_t) argc)
4875  ThrowMogrifyException(OptionError,"MissingArgument",option);
4876  if (IsGeometry(argv[i]) == MagickFalse)
4877  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4878  break;
4879  }
4880  if (LocaleCompare("fill",option+1) == 0)
4881  {
4882  if (*option == '+')
4883  break;
4884  i++;
4885  if (i == (ssize_t) argc)
4886  ThrowMogrifyException(OptionError,"MissingArgument",option);
4887  break;
4888  }
4889  if (LocaleCompare("filter",option+1) == 0)
4890  {
4891  ssize_t
4892  filter;
4893 
4894  if (*option == '+')
4895  break;
4896  i++;
4897  if (i == (ssize_t) argc)
4898  ThrowMogrifyException(OptionError,"MissingArgument",option);
4899  filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4900  if (filter < 0)
4901  ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4902  argv[i]);
4903  break;
4904  }
4905  if (LocaleCompare("flatten",option+1) == 0)
4906  break;
4907  if (LocaleCompare("flip",option+1) == 0)
4908  break;
4909  if (LocaleCompare("flop",option+1) == 0)
4910  break;
4911  if (LocaleCompare("floodfill",option+1) == 0)
4912  {
4913  if (*option == '+')
4914  break;
4915  i++;
4916  if (i == (ssize_t) argc)
4917  ThrowMogrifyException(OptionError,"MissingArgument",option);
4918  if (IsGeometry(argv[i]) == MagickFalse)
4919  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4920  i++;
4921  if (i == (ssize_t) argc)
4922  ThrowMogrifyException(OptionError,"MissingArgument",option);
4923  break;
4924  }
4925  if (LocaleCompare("font",option+1) == 0)
4926  {
4927  if (*option == '+')
4928  break;
4929  i++;
4930  if (i == (ssize_t) argc)
4931  ThrowMogrifyException(OptionError,"MissingArgument",option);
4932  break;
4933  }
4934  if (LocaleCompare("format",option+1) == 0)
4935  {
4936  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
4937  (void) CloneString(&format,(char *) NULL);
4938  if (*option == '+')
4939  break;
4940  i++;
4941  if (i == (ssize_t) argc)
4942  ThrowMogrifyException(OptionError,"MissingArgument",option);
4943  (void) CloneString(&format,argv[i]);
4944  (void) CopyMagickString(image_info->filename,format,
4945  MagickPathExtent);
4946  (void) ConcatenateMagickString(image_info->filename,":",
4947  MagickPathExtent);
4948  (void) SetImageInfo(image_info,0,exception);
4949  if (*image_info->magick == '\0')
4950  ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4951  format);
4952  break;
4953  }
4954  if (LocaleCompare("frame",option+1) == 0)
4955  {
4956  if (*option == '+')
4957  break;
4958  i++;
4959  if (i == (ssize_t) argc)
4960  ThrowMogrifyException(OptionError,"MissingArgument",option);
4961  if (IsGeometry(argv[i]) == MagickFalse)
4962  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4963  break;
4964  }
4965  if (LocaleCompare("function",option+1) == 0)
4966  {
4967  ssize_t
4968  op;
4969 
4970  if (*option == '+')
4971  break;
4972  i++;
4973  if (i == (ssize_t) argc)
4974  ThrowMogrifyException(OptionError,"MissingArgument",option);
4975  op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4976  if (op < 0)
4977  ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4978  i++;
4979  if (i == (ssize_t) argc)
4980  ThrowMogrifyException(OptionError,"MissingArgument",option);
4981  break;
4982  }
4983  if (LocaleCompare("fuzz",option+1) == 0)
4984  {
4985  if (*option == '+')
4986  break;
4987  i++;
4988  if (i == (ssize_t) argc)
4989  ThrowMogrifyException(OptionError,"MissingArgument",option);
4990  if (IsGeometry(argv[i]) == MagickFalse)
4991  ThrowMogrifyInvalidArgumentException(option,argv[i]);
4992  break;
4993  }
4994  if (LocaleCompare("fx",option+1) == 0)
4995  {
4996  i++;
4997  if (i == (ssize_t) argc)
4998  ThrowMogrifyException(OptionError,"MissingArgument",option);
4999  break;
5000  }
5001  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5002  }
5003  case 'g':
5004  {
5005  if (LocaleCompare("gamma",option+1) == 0)
5006  {
5007  i++;
5008  if (i == (ssize_t) argc)
5009  ThrowMogrifyException(OptionError,"MissingArgument",option);
5010  if (IsGeometry(argv[i]) == MagickFalse)
5011  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5012  break;
5013  }
5014  if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5015  (LocaleCompare("gaussian",option+1) == 0))
5016  {
5017  i++;
5018  if (i == (ssize_t) argc)
5019  ThrowMogrifyException(OptionError,"MissingArgument",option);
5020  if (IsGeometry(argv[i]) == MagickFalse)
5021  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5022  break;
5023  }
5024  if (LocaleCompare("geometry",option+1) == 0)
5025  {
5026  if (*option == '+')
5027  break;
5028  i++;
5029  if (i == (ssize_t) argc)
5030  ThrowMogrifyException(OptionError,"MissingArgument",option);
5031  if (IsGeometry(argv[i]) == MagickFalse)
5032  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5033  break;
5034  }
5035  if (LocaleCompare("gravity",option+1) == 0)
5036  {
5037  ssize_t
5038  gravity;
5039 
5040  if (*option == '+')
5041  break;
5042  i++;
5043  if (i == (ssize_t) argc)
5044  ThrowMogrifyException(OptionError,"MissingArgument",option);
5045  gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5046  argv[i]);
5047  if (gravity < 0)
5048  ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5049  argv[i]);
5050  break;
5051  }
5052  if (LocaleCompare("grayscale",option+1) == 0)
5053  {
5054  ssize_t
5055  method;
5056 
5057  if (*option == '+')
5058  break;
5059  i++;
5060  if (i == (ssize_t) argc)
5061  ThrowMogrifyException(OptionError,"MissingArgument",option);
5062  method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5063  argv[i]);
5064  if (method < 0)
5065  ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
5066  argv[i]);
5067  break;
5068  }
5069  if (LocaleCompare("green-primary",option+1) == 0)
5070  {
5071  if (*option == '+')
5072  break;
5073  i++;
5074  if (i == (ssize_t) argc)
5075  ThrowMogrifyException(OptionError,"MissingArgument",option);
5076  if (IsGeometry(argv[i]) == MagickFalse)
5077  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5078  break;
5079  }
5080  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5081  }
5082  case 'h':
5083  {
5084  if (LocaleCompare("hald-clut",option+1) == 0)
5085  break;
5086  if ((LocaleCompare("help",option+1) == 0) ||
5087  (LocaleCompare("-help",option+1) == 0))
5088  {
5089  DestroyMogrify();
5090  return(MogrifyUsage());
5091  }
5092  if (LocaleCompare("hough-lines",option+1) == 0)
5093  {
5094  if (*option == '+')
5095  break;
5096  i++;
5097  if (i == (ssize_t) argc)
5098  ThrowMogrifyException(OptionError,"MissingArgument",option);
5099  if (IsGeometry(argv[i]) == MagickFalse)
5100  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5101  break;
5102  }
5103  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5104  }
5105  case 'i':
5106  {
5107  if (LocaleCompare("identify",option+1) == 0)
5108  break;
5109  if (LocaleCompare("idft",option+1) == 0)
5110  break;
5111  if (LocaleCompare("illuminant",option+1) == 0)
5112  {
5113  ssize_t
5114  type;
5115 
5116  if (*option == '+')
5117  break;
5118  i++;
5119  if (i == (ssize_t) argc)
5120  ThrowMogrifyException(OptionError,"MissingArgument",option);
5121  type=ParseCommandOption(MagickIlluminantOptions,MagickFalse,
5122  argv[i]);
5123  if (type < 0)
5124  ThrowMogrifyException(OptionError,"UnrecognizedIlluminantMethod",
5125  argv[i]);
5126  break;
5127  }
5128  if (LocaleCompare("implode",option+1) == 0)
5129  {
5130  if (*option == '+')
5131  break;
5132  i++;
5133  if (i == (ssize_t) argc)
5134  ThrowMogrifyException(OptionError,"MissingArgument",option);
5135  if (IsGeometry(argv[i]) == MagickFalse)
5136  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5137  break;
5138  }
5139  if (LocaleCompare("intensity",option+1) == 0)
5140  {
5141  ssize_t
5142  intensity;
5143 
5144  if (*option == '+')
5145  break;
5146  i++;
5147  if (i == (ssize_t) argc)
5148  ThrowMogrifyException(OptionError,"MissingArgument",option);
5149  intensity=ParseCommandOption(MagickPixelIntensityOptions,
5150  MagickFalse,argv[i]);
5151  if (intensity < 0)
5152  ThrowMogrifyException(OptionError,
5153  "UnrecognizedPixelIntensityMethod",argv[i]);
5154  break;
5155  }
5156  if (LocaleCompare("integral",option+1) == 0)
5157  break;
5158  if (LocaleCompare("intent",option+1) == 0)
5159  {
5160  ssize_t
5161  intent;
5162 
5163  if (*option == '+')
5164  break;
5165  i++;
5166  if (i == (ssize_t) argc)
5167  ThrowMogrifyException(OptionError,"MissingArgument",option);
5168  intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5169  if (intent < 0)
5170  ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5171  argv[i]);
5172  break;
5173  }
5174  if (LocaleCompare("interlace",option+1) == 0)
5175  {
5176  ssize_t
5177  interlace;
5178 
5179  if (*option == '+')
5180  break;
5181  i++;
5182  if (i == (ssize_t) argc)
5183  ThrowMogrifyException(OptionError,"MissingArgument",option);
5184  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5185  argv[i]);
5186  if (interlace < 0)
5187  ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5188  argv[i]);
5189  break;
5190  }
5191  if (LocaleCompare("interline-spacing",option+1) == 0)
5192  {
5193  if (*option == '+')
5194  break;
5195  i++;
5196  if (i == (ssize_t) argc)
5197  ThrowMogrifyException(OptionError,"MissingArgument",option);
5198  if (IsGeometry(argv[i]) == MagickFalse)
5199  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5200  break;
5201  }
5202  if (LocaleCompare("interpolate",option+1) == 0)
5203  {
5204  ssize_t
5205  interpolate;
5206 
5207  if (*option == '+')
5208  break;
5209  i++;
5210  if (i == (ssize_t) argc)
5211  ThrowMogrifyException(OptionError,"MissingArgument",option);
5212  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5213  argv[i]);
5214  if (interpolate < 0)
5215  ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5216  argv[i]);
5217  break;
5218  }
5219  if (LocaleCompare("interword-spacing",option+1) == 0)
5220  {
5221  if (*option == '+')
5222  break;
5223  i++;
5224  if (i == (ssize_t) argc)
5225  ThrowMogrifyException(OptionError,"MissingArgument",option);
5226  if (IsGeometry(argv[i]) == MagickFalse)
5227  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5228  break;
5229  }
5230  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5231  }
5232  case 'k':
5233  {
5234  if (LocaleCompare("kerning",option+1) == 0)
5235  {
5236  if (*option == '+')
5237  break;
5238  i++;
5239  if (i == (ssize_t) argc)
5240  ThrowMogrifyException(OptionError,"MissingArgument",option);
5241  if (IsGeometry(argv[i]) == MagickFalse)
5242  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5243  break;
5244  }
5245  if (LocaleCompare("kmeans",option+1) == 0)
5246  {
5247  i++;
5248  if (i == (ssize_t) argc)
5249  ThrowMogrifyException(OptionError,"MissingArgument",option);
5250  if (IsGeometry(argv[i]) == MagickFalse)
5251  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5252  break;
5253  }
5254  if (LocaleCompare("kuwahara",option+1) == 0)
5255  {
5256  i++;
5257  if (i == (ssize_t) argc)
5258  ThrowMogrifyException(OptionError,"MissingArgument",option);
5259  if (IsGeometry(argv[i]) == MagickFalse)
5260  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5261  break;
5262  }
5263  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5264  }
5265  case 'l':
5266  {
5267  if (LocaleCompare("label",option+1) == 0)
5268  {
5269  if (*option == '+')
5270  break;
5271  i++;
5272  if (i == (ssize_t) argc)
5273  ThrowMogrifyException(OptionError,"MissingArgument",option);
5274  break;
5275  }
5276  if (LocaleCompare("lat",option+1) == 0)
5277  {
5278  if (*option == '+')
5279  break;
5280  i++;
5281  if (i == (ssize_t) argc)
5282  ThrowMogrifyException(OptionError,"MissingArgument",option);
5283  if (IsGeometry(argv[i]) == MagickFalse)
5284  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5285  break;
5286  }
5287  if (LocaleCompare("layers",option+1) == 0)
5288  {
5289  ssize_t
5290  type;
5291 
5292  if (*option == '+')
5293  break;
5294  i++;
5295  if (i == (ssize_t) argc)
5296  ThrowMogrifyException(OptionError,"MissingArgument",option);
5297  type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5298  if (type < 0)
5299  ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5300  argv[i]);
5301  break;
5302  }
5303  if (LocaleCompare("level",option+1) == 0)
5304  {
5305  i++;
5306  if (i == (ssize_t) argc)
5307  ThrowMogrifyException(OptionError,"MissingArgument",option);
5308  if (IsGeometry(argv[i]) == MagickFalse)
5309  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5310  break;
5311  }
5312  if (LocaleCompare("level-colors",option+1) == 0)
5313  {
5314  i++;
5315  if (i == (ssize_t) argc)
5316  ThrowMogrifyException(OptionError,"MissingArgument",option);
5317  break;
5318  }
5319  if (LocaleCompare("limit",option+1) == 0)
5320  {
5321  char
5322  *p;
5323 
5324  double
5325  value;
5326 
5327  ssize_t
5328  resource;
5329 
5330  if (*option == '+')
5331  break;
5332  i++;
5333  if (i == (ssize_t) argc)
5334  ThrowMogrifyException(OptionError,"MissingArgument",option);
5335  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5336  argv[i]);
5337  if (resource < 0)
5338  ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5339  argv[i]);
5340  i++;
5341  if (i == (ssize_t) argc)
5342  ThrowMogrifyException(OptionError,"MissingArgument",option);
5343  value=StringToDouble(argv[i],&p);
5344  (void) value;
5345  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5346  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5347  break;
5348  }
5349  if (LocaleCompare("liquid-rescale",option+1) == 0)
5350  {
5351  i++;
5352  if (i == (ssize_t) argc)
5353  ThrowMogrifyException(OptionError,"MissingArgument",option);
5354  if (IsGeometry(argv[i]) == MagickFalse)
5355  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5356  break;
5357  }
5358  if (LocaleCompare("list",option+1) == 0)
5359  {
5360  ssize_t
5361  list;
5362 
5363  if (*option == '+')
5364  break;
5365  i++;
5366  if (i == (ssize_t) argc)
5367  ThrowMogrifyException(OptionError,"MissingArgument",option);
5368  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5369  if (list < 0)
5370  ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5371  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5372  argv+j,exception);
5373  return(status == 0 ? MagickFalse : MagickTrue);
5374  }
5375  if (LocaleCompare("log",option+1) == 0)
5376  {
5377  if (*option == '+')
5378  break;
5379  i++;
5380  if ((i == (ssize_t) argc) ||
5381  (strchr(argv[i],'%') == (char *) NULL))
5382  ThrowMogrifyException(OptionError,"MissingArgument",option);
5383  break;
5384  }
5385  if (LocaleCompare("loop",option+1) == 0)
5386  {
5387  if (*option == '+')
5388  break;
5389  i++;
5390  if (i == (ssize_t) argc)
5391  ThrowMogrifyException(OptionError,"MissingArgument",option);
5392  if (IsGeometry(argv[i]) == MagickFalse)
5393  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5394  break;
5395  }
5396  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5397  }
5398  case 'm':
5399  {
5400  if (LocaleCompare("magnify",option+1) == 0)
5401  break;
5402  if (LocaleCompare("map",option+1) == 0)
5403  {
5404  global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5405  if (*option == '+')
5406  break;
5407  i++;
5408  if (i == (ssize_t) argc)
5409  ThrowMogrifyException(OptionError,"MissingArgument",option);
5410  break;
5411  }
5412  if (LocaleCompare("mask",option+1) == 0)
5413  {
5414  if (*option == '+')
5415  break;
5416  i++;
5417  if (i == (ssize_t) argc)
5418  ThrowMogrifyException(OptionError,"MissingArgument",option);
5419  break;
5420  }
5421  if (LocaleCompare("matte",option+1) == 0)
5422  break;
5423  if (LocaleCompare("mattecolor",option+1) == 0)
5424  {
5425  if (*option == '+')
5426  break;
5427  i++;
5428  if (i == (ssize_t) argc)
5429  ThrowMogrifyException(OptionError,"MissingArgument",option);
5430  break;
5431  }
5432  if (LocaleCompare("maximum",option+1) == 0)
5433  break;
5434  if (LocaleCompare("mean-shift",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("median",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("metric",option+1) == 0)
5457  {
5458  ssize_t
5459  type;
5460 
5461  if (*option == '+')
5462  break;
5463  i++;
5464  if (i == (ssize_t) argc)
5465  ThrowMogrifyException(OptionError,"MissingArgument",option);
5466  type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5467  if (type < 0)
5468  ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5469  argv[i]);
5470  break;
5471  }
5472  if (LocaleCompare("minimum",option+1) == 0)
5473  break;
5474  if (LocaleCompare("modulate",option+1) == 0)
5475  {
5476  if (*option == '+')
5477  break;
5478  i++;
5479  if (i == (ssize_t) argc)
5480  ThrowMogrifyException(OptionError,"MissingArgument",option);
5481  if (IsGeometry(argv[i]) == MagickFalse)
5482  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5483  break;
5484  }
5485  if (LocaleCompare("mode",option+1) == 0)
5486  {
5487  if (*option == '+')
5488  break;
5489  i++;
5490  if (i == (ssize_t) argc)
5491  ThrowMogrifyException(OptionError,"MissingArgument",option);
5492  if (IsGeometry(argv[i]) == MagickFalse)
5493  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5494  break;
5495  }
5496  if (LocaleCompare("monitor",option+1) == 0)
5497  break;
5498  if (LocaleCompare("monochrome",option+1) == 0)
5499  break;
5500  if (LocaleCompare("morph",option+1) == 0)
5501  {
5502  if (*option == '+')
5503  break;
5504  i++;
5505  if (i == (ssize_t) argc)
5506  ThrowMogrifyException(OptionError,"MissingArgument",option);
5507  if (IsGeometry(argv[i]) == MagickFalse)
5508  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5509  break;
5510  }
5511  if (LocaleCompare("morphology",option+1) == 0)
5512  {
5513  char
5514  token[MagickPathExtent];
5515 
5516  KernelInfo
5517  *kernel_info;
5518 
5519  ssize_t
5520  op;
5521 
5522  i++;
5523  if (i == (ssize_t) argc)
5524  ThrowMogrifyException(OptionError,"MissingArgument",option);
5525  (void) GetNextToken(argv[i],(const char **) NULL,MagickPathExtent,
5526  token);
5527  op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5528  if (op < 0)
5529  ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5530  token);
5531  i++;
5532  if (i == (ssize_t) argc)
5533  ThrowMogrifyException(OptionError,"MissingArgument",option);
5534  kernel_info=AcquireKernelInfo(argv[i],exception);
5535  if (kernel_info == (KernelInfo *) NULL)
5536  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537  kernel_info=DestroyKernelInfo(kernel_info);
5538  break;
5539  }
5540  if (LocaleCompare("mosaic",option+1) == 0)
5541  break;
5542  if (LocaleCompare("motion-blur",option+1) == 0)
5543  {
5544  if (*option == '+')
5545  break;
5546  i++;
5547  if (i == (ssize_t) argc)
5548  ThrowMogrifyException(OptionError,"MissingArgument",option);
5549  if (IsGeometry(argv[i]) == MagickFalse)
5550  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5551  break;
5552  }
5553  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5554  }
5555  case 'n':
5556  {
5557  if (LocaleCompare("negate",option+1) == 0)
5558  break;
5559  if (LocaleCompare("noise",option+1) == 0)
5560  {
5561  i++;
5562  if (i == (ssize_t) argc)
5563  ThrowMogrifyException(OptionError,"MissingArgument",option);
5564  if (*option == '+')
5565  {
5566  ssize_t
5567  noise;
5568 
5569  noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5570  argv[i]);
5571  if (noise < 0)
5572  ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5573  argv[i]);
5574  break;
5575  }
5576  if (IsGeometry(argv[i]) == MagickFalse)
5577  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5578  break;
5579  }
5580  if (LocaleCompare("noop",option+1) == 0)
5581  break;
5582  if (LocaleCompare("normalize",option+1) == 0)
5583  break;
5584  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5585  }
5586  case 'o':
5587  {
5588  if (LocaleCompare("opaque",option+1) == 0)
5589  {
5590  i++;
5591  if (i == (ssize_t) argc)
5592  ThrowMogrifyException(OptionError,"MissingArgument",option);
5593  break;
5594  }
5595  if (LocaleCompare("ordered-dither",option+1) == 0)
5596  {
5597  if (*option == '+')
5598  break;
5599  i++;
5600  if (i == (ssize_t) argc)
5601  ThrowMogrifyException(OptionError,"MissingArgument",option);
5602  break;
5603  }
5604  if (LocaleCompare("orient",option+1) == 0)
5605  {
5606  ssize_t
5607  orientation;
5608 
5609  orientation=UndefinedOrientation;
5610  if (*option == '+')
5611  break;
5612  i++;
5613  if (i == (ssize_t) argc)
5614  ThrowMogrifyException(OptionError,"MissingArgument",option);
5615  orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5616  argv[i]);
5617  if (orientation < 0)
5618  ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5619  argv[i]);
5620  break;
5621  }
5622  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5623  }
5624  case 'p':
5625  {
5626  if (LocaleCompare("page",option+1) == 0)
5627  {
5628  if (*option == '+')
5629  break;
5630  i++;
5631  if (i == (ssize_t) argc)
5632  ThrowMogrifyException(OptionError,"MissingArgument",option);
5633  break;
5634  }
5635  if (LocaleCompare("paint",option+1) == 0)
5636  {
5637  if (*option == '+')
5638  break;
5639  i++;
5640  if (i == (ssize_t) argc)
5641  ThrowMogrifyException(OptionError,"MissingArgument",option);
5642  if (IsGeometry(argv[i]) == MagickFalse)
5643  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5644  break;
5645  }
5646  if (LocaleCompare("path",option+1) == 0)
5647  {
5648  (void) CloneString(&path,(char *) NULL);
5649  if (*option == '+')
5650  break;
5651  i++;
5652  if (i == (ssize_t) argc)
5653  ThrowMogrifyException(OptionError,"MissingArgument",option);
5654  (void) CloneString(&path,argv[i]);
5655  break;
5656  }
5657  if (LocaleCompare("perceptible",option+1) == 0)
5658  {
5659  if (*option == '+')
5660  break;
5661  i++;
5662  if (i == (ssize_t) argc)
5663  ThrowMogrifyException(OptionError,"MissingArgument",option);
5664  if (IsGeometry(argv[i]) == MagickFalse)
5665  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5666  break;
5667  }
5668  if (LocaleCompare("pointsize",option+1) == 0)
5669  {
5670  if (*option == '+')
5671  break;
5672  i++;
5673  if (i == (ssize_t) argc)
5674  ThrowMogrifyException(OptionError,"MissingArgument",option);
5675  if (IsGeometry(argv[i]) == MagickFalse)
5676  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5677  break;
5678  }
5679  if (LocaleCompare("polaroid",option+1) == 0)
5680  {
5681  if (*option == '+')
5682  break;
5683  i++;
5684  if (i == (ssize_t) argc)
5685  ThrowMogrifyException(OptionError,"MissingArgument",option);
5686  if (IsGeometry(argv[i]) == MagickFalse)
5687  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5688  break;
5689  }
5690  if (LocaleCompare("poly",option+1) == 0)
5691  {
5692  if (*option == '+')
5693  break;
5694  i++;
5695  if (i == (ssize_t) argc)
5696  ThrowMogrifyException(OptionError,"MissingArgument",option);
5697  if (IsGeometry(argv[i]) == MagickFalse)
5698  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5699  break;
5700  }
5701  if (LocaleCompare("posterize",option+1) == 0)
5702  {
5703  if (*option == '+')
5704  break;
5705  i++;
5706  if (i == (ssize_t) argc)
5707  ThrowMogrifyException(OptionError,"MissingArgument",option);
5708  if (IsGeometry(argv[i]) == MagickFalse)
5709  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5710  break;
5711  }
5712  if (LocaleCompare("precision",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("print",option+1) == 0)
5724  {
5725  if (*option == '+')
5726  break;
5727  i++;
5728  if (i == (ssize_t) argc)
5729  ThrowMogrifyException(OptionError,"MissingArgument",option);
5730  break;
5731  }
5732  if (LocaleCompare("process",option+1) == 0)
5733  {
5734  if (*option == '+')
5735  break;
5736  i++;
5737  if (i == (ssize_t) argc)
5738  ThrowMogrifyException(OptionError,"MissingArgument",option);
5739  break;
5740  }
5741  if (LocaleCompare("profile",option+1) == 0)
5742  {
5743  i++;
5744  if (i == (ssize_t) argc)
5745  ThrowMogrifyException(OptionError,"MissingArgument",option);
5746  break;
5747  }
5748  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5749  }
5750  case 'q':
5751  {
5752  if (LocaleCompare("quality",option+1) == 0)
5753  {
5754  if (*option == '+')
5755  break;
5756  i++;
5757  if (i == (ssize_t) argc)
5758  ThrowMogrifyException(OptionError,"MissingArgument",option);
5759  if (IsGeometry(argv[i]) == MagickFalse)
5760  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5761  break;
5762  }
5763  if (LocaleCompare("quantize",option+1) == 0)
5764  {
5765  ssize_t
5766  colorspace;
5767 
5768  if (*option == '+')
5769  break;
5770  i++;
5771  if (i == (ssize_t) argc)
5772  ThrowMogrifyException(OptionError,"MissingArgument",option);
5773  colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5774  argv[i]);
5775  if (colorspace < 0)
5776  ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5777  argv[i]);
5778  break;
5779  }
5780  if (LocaleCompare("quiet",option+1) == 0)
5781  break;
5782  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5783  }
5784  case 'r':
5785  {
5786  if (LocaleCompare("rotational-blur",option+1) == 0)
5787  {
5788  i++;
5789  if (i == (ssize_t) argc)
5790  ThrowMogrifyException(OptionError,"MissingArgument",option);
5791  if (IsGeometry(argv[i]) == MagickFalse)
5792  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5793  break;
5794  }
5795  if (LocaleCompare("raise",option+1) == 0)
5796  {
5797  i++;
5798  if (i == (ssize_t) argc)
5799  ThrowMogrifyException(OptionError,"MissingArgument",option);
5800  if (IsGeometry(argv[i]) == MagickFalse)
5801  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5802  break;
5803  }
5804  if (LocaleCompare("random-threshold",option+1) == 0)
5805  {
5806  if (*option == '+')
5807  break;
5808  i++;
5809  if (i == (ssize_t) argc)
5810  ThrowMogrifyException(OptionError,"MissingArgument",option);
5811  if (IsGeometry(argv[i]) == MagickFalse)
5812  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5813  break;
5814  }
5815  if (LocaleCompare("range-threshold",option+1) == 0)
5816  {
5817  if (*option == '+')
5818  break;
5819  i++;
5820  if (i == (ssize_t) argc)
5821  ThrowMogrifyException(OptionError,"MissingArgument",option);
5822  if (IsGeometry(argv[i]) == MagickFalse)
5823  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5824  break;
5825  }
5826  if (LocaleCompare("read-mask",option+1) == 0)
5827  {
5828  if (*option == '+')
5829  break;
5830  i++;
5831  if (i == (ssize_t) argc)
5832  ThrowMogrifyException(OptionError,"MissingArgument",option);
5833  break;
5834  }
5835  if (LocaleCompare("red-primary",option+1) == 0)
5836  {
5837  if (*option == '+')
5838  break;
5839  i++;
5840  if (i == (ssize_t) argc)
5841  ThrowMogrifyException(OptionError,"MissingArgument",option);
5842  if (IsGeometry(argv[i]) == MagickFalse)
5843  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5844  }
5845  if (LocaleCompare("regard-warnings",option+1) == 0)
5846  break;
5847  if (LocaleCompare("region",option+1) == 0)
5848  {
5849  if (*option == '+')
5850  break;
5851  i++;
5852  if (i == (ssize_t) argc)
5853  ThrowMogrifyException(OptionError,"MissingArgument",option);
5854  if (IsGeometry(argv[i]) == MagickFalse)
5855  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5856  break;
5857  }
5858  if (LocaleCompare("remap",option+1) == 0)
5859  {
5860  if (*option == '+')
5861  break;
5862  i++;
5863  if (i == (ssize_t) argc)
5864  ThrowMogrifyException(OptionError,"MissingArgument",option);
5865  break;
5866  }
5867  if (LocaleCompare("render",option+1) == 0)
5868  break;
5869  if (LocaleCompare("repage",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("resample",option+1) == 0)
5881  {
5882  if (*option == '+')
5883  break;
5884  i++;
5885  if (i == (ssize_t) argc)
5886  ThrowMogrifyException(OptionError,"MissingArgument",option);
5887  if (IsGeometry(argv[i]) == MagickFalse)
5888  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5889  break;
5890  }
5891  if (LocaleCompare("reshape",option+1) == 0)
5892  {
5893  if (*option == '+')
5894  break;
5895  i++;
5896  if (i == (ssize_t) argc)
5897  ThrowMogrifyException(OptionError,"MissingArgument",option);
5898  if (IsGeometry(argv[i]) == MagickFalse)
5899  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5900  break;
5901  }
5902  if (LocaleCompare("resize",option+1) == 0)
5903  {
5904  if (*option == '+')
5905  break;
5906  i++;
5907  if (i == (ssize_t) argc)
5908  ThrowMogrifyException(OptionError,"MissingArgument",option);
5909  if (IsGeometry(argv[i]) == MagickFalse)
5910  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5911  break;
5912  }
5913  if ((LocaleNCompare("respect-parentheses",option+1,17) == 0) ||
5914  (LocaleNCompare("respect-parenthesis",option+1,17) == 0))
5915  {
5916  respect_parentheses=(*option == '-') ? MagickTrue : MagickFalse;
5917  break;
5918  }
5919  if (LocaleCompare("reverse",option+1) == 0)
5920  break;
5921  if (LocaleCompare("roll",option+1) == 0)
5922  {
5923  if (*option == '+')
5924  break;
5925  i++;
5926  if (i == (ssize_t) argc)
5927  ThrowMogrifyException(OptionError,"MissingArgument",option);
5928  if (IsGeometry(argv[i]) == MagickFalse)
5929  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5930  break;
5931  }
5932  if (LocaleCompare("rotate",option+1) == 0)
5933  {
5934  i++;
5935  if (i == (ssize_t) argc)
5936  ThrowMogrifyException(OptionError,"MissingArgument",option);
5937  if (IsGeometry(argv[i]) == MagickFalse)
5938  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5939  break;
5940  }
5941  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5942  }
5943  case 's':
5944  {
5945  if (LocaleCompare("sample",option+1) == 0)
5946  {
5947  if (*option == '+')
5948  break;
5949  i++;
5950  if (i == (ssize_t) argc)
5951  ThrowMogrifyException(OptionError,"MissingArgument",option);
5952  if (IsGeometry(argv[i]) == MagickFalse)
5953  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5954  break;
5955  }
5956  if (LocaleCompare("sampling-factor",option+1) == 0)
5957  {
5958  if (*option == '+')
5959  break;
5960  i++;
5961  if (i == (ssize_t) argc)
5962  ThrowMogrifyException(OptionError,"MissingArgument",option);
5963  if (IsGeometry(argv[i]) == MagickFalse)
5964  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5965  break;
5966  }
5967  if (LocaleCompare("scale",option+1) == 0)
5968  {
5969  if (*option == '+')
5970  break;
5971  i++;
5972  if (i == (ssize_t) argc)
5973  ThrowMogrifyException(OptionError,"MissingArgument",option);
5974  if (IsGeometry(argv[i]) == MagickFalse)
5975  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5976  break;
5977  }
5978  if (LocaleCompare("scene",option+1) == 0)
5979  {
5980  if (*option == '+')
5981  break;
5982  i++;
5983  if (i == (ssize_t) argc)
5984  ThrowMogrifyException(OptionError,"MissingArgument",option);
5985  if (IsGeometry(argv[i]) == MagickFalse)
5986  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5987  break;
5988  }
5989  if (LocaleCompare("seed",option+1) == 0)
5990  {
5991  if (*option == '+')
5992  break;
5993  i++;
5994  if (i == (ssize_t) argc)
5995  ThrowMogrifyException(OptionError,"MissingArgument",option);
5996  if (IsGeometry(argv[i]) == MagickFalse)
5997  ThrowMogrifyInvalidArgumentException(option,argv[i]);
5998  break;
5999  }
6000  if (LocaleCompare("segment",option+1) == 0)
6001  {
6002  if (*option == '+')
6003  break;
6004  i++;
6005  if (i == (ssize_t) argc)
6006  ThrowMogrifyException(OptionError,"MissingArgument",option);
6007  if (IsGeometry(argv[i]) == MagickFalse)
6008  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6009  break;
6010  }
6011  if (LocaleCompare("selective-blur",option+1) == 0)
6012  {
6013  i++;
6014  if (i == (ssize_t) argc)
6015  ThrowMogrifyException(OptionError,"MissingArgument",option);
6016  if (IsGeometry(argv[i]) == MagickFalse)
6017  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6018  break;
6019  }
6020  if (LocaleCompare("separate",option+1) == 0)
6021  break;
6022  if (LocaleCompare("sepia-tone",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("set",option+1) == 0)
6034  {
6035  i++;
6036  if (i == (ssize_t) argc)
6037  ThrowMogrifyException(OptionError,"MissingArgument",option);
6038  if (*option == '+')
6039  break;
6040  i++;
6041  if (i == (ssize_t) argc)
6042  ThrowMogrifyException(OptionError,"MissingArgument",option);
6043  break;
6044  }
6045  if (LocaleCompare("shade",option+1) == 0)
6046  {
6047  i++;
6048  if (i == (ssize_t) argc)
6049  ThrowMogrifyException(OptionError,"MissingArgument",option);
6050  if (IsGeometry(argv[i]) == MagickFalse)
6051  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6052  break;
6053  }
6054  if (LocaleCompare("shadow",option+1) == 0)
6055  {
6056  if (*option == '+')
6057  break;
6058  i++;
6059  if (i == (ssize_t) argc)
6060  ThrowMogrifyException(OptionError,"MissingArgument",option);
6061  if (IsGeometry(argv[i]) == MagickFalse)
6062  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6063  break;
6064  }
6065  if (LocaleCompare("sharpen",option+1) == 0)
6066  {
6067  i++;
6068  if (i == (ssize_t) argc)
6069  ThrowMogrifyException(OptionError,"MissingArgument",option);
6070  if (IsGeometry(argv[i]) == MagickFalse)
6071  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6072  break;
6073  }
6074  if (LocaleCompare("shave",option+1) == 0)
6075  {
6076  if (*option == '+')
6077  break;
6078  i++;
6079  if (i == (ssize_t) argc)
6080  ThrowMogrifyException(OptionError,"MissingArgument",option);
6081  if (IsGeometry(argv[i]) == MagickFalse)
6082  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6083  break;
6084  }
6085  if (LocaleCompare("shear",option+1) == 0)
6086  {
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("sigmoidal-contrast",option+1) == 0)
6095  {
6096  i++;
6097  if (i == (ssize_t) argc)
6098  ThrowMogrifyException(OptionError,"MissingArgument",option);
6099  if (IsGeometry(argv[i]) == MagickFalse)
6100  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6101  break;
6102  }
6103  if (LocaleCompare("size",option+1) == 0)
6104  {
6105  if (*option == '+')
6106  break;
6107  i++;
6108  if (i == (ssize_t) argc)
6109  ThrowMogrifyException(OptionError,"MissingArgument",option);
6110  if (IsGeometry(argv[i]) == MagickFalse)
6111  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6112  break;
6113  }
6114  if (LocaleCompare("sketch",option+1) == 0)
6115  {
6116  if (*option == '+')
6117  break;
6118  i++;
6119  if (i == (ssize_t) argc)
6120  ThrowMogrifyException(OptionError,"MissingArgument",option);
6121  if (IsGeometry(argv[i]) == MagickFalse)
6122  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6123  break;
6124  }
6125  if (LocaleCompare("smush",option+1) == 0)
6126  {
6127  i++;
6128  if (i == (ssize_t) argc)
6129  ThrowMogrifyException(OptionError,"MissingArgument",option);
6130  if (IsGeometry(argv[i]) == MagickFalse)
6131  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6132  i++;
6133  break;
6134  }
6135  if (LocaleCompare("solarize",option+1) == 0)
6136  {
6137  if (*option == '+')
6138  break;
6139  i++;
6140  if (i == (ssize_t) argc)
6141  ThrowMogrifyException(OptionError,"MissingArgument",option);
6142  if (IsGeometry(argv[i]) == MagickFalse)
6143  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6144  break;
6145  }
6146  if (LocaleCompare("sort",option+1) == 0)
6147  break;
6148  if (LocaleCompare("sparse-color",option+1) == 0)
6149  {
6150  ssize_t
6151  op;
6152 
6153  i++;
6154  if (i == (ssize_t) argc)
6155  ThrowMogrifyException(OptionError,"MissingArgument",option);
6156  op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6157  if (op < 0)
6158  ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6159  argv[i]);
6160  i++;
6161  if (i == (ssize_t) argc)
6162  ThrowMogrifyException(OptionError,"MissingArgument",option);
6163  break;
6164  }
6165  if (LocaleCompare("splice",option+1) == 0)
6166  {
6167  if (*option == '+')
6168  break;
6169  i++;
6170  if (i == (ssize_t) argc)
6171  ThrowMogrifyException(OptionError,"MissingArgument",option);
6172  if (IsGeometry(argv[i]) == MagickFalse)
6173  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6174  break;
6175  }
6176  if (LocaleCompare("spread",option+1) == 0)
6177  {
6178  if (*option == '+')
6179  break;
6180  i++;
6181  if (i == (ssize_t) argc)
6182  ThrowMogrifyException(OptionError,"MissingArgument",option);
6183  if (IsGeometry(argv[i]) == MagickFalse)
6184  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6185  break;
6186  }
6187  if (LocaleCompare("statistic",option+1) == 0)
6188  {
6189  ssize_t
6190  op;
6191 
6192  if (*option == '+')
6193  break;
6194  i++;
6195  if (i == (ssize_t) argc)
6196  ThrowMogrifyException(OptionError,"MissingArgument",option);
6197  op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6198  if (op < 0)
6199  ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6200  argv[i]);
6201  i++;
6202  if (i == (ssize_t) argc)
6203  ThrowMogrifyException(OptionError,"MissingArgument",option);
6204  if (IsGeometry(argv[i]) == MagickFalse)
6205  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6206  break;
6207  }
6208  if (LocaleCompare("stretch",option+1) == 0)
6209  {
6210  ssize_t
6211  stretch;
6212 
6213  if (*option == '+')
6214  break;
6215  i++;
6216  if (i == (ssize_t) argc)
6217  ThrowMogrifyException(OptionError,"MissingArgument",option);
6218  stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6219  argv[i]);
6220  if (stretch < 0)
6221  ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6222  argv[i]);
6223  break;
6224  }
6225  if (LocaleCompare("strip",option+1) == 0)
6226  break;
6227  if (LocaleCompare("stroke",option+1) == 0)
6228  {
6229  if (*option == '+')
6230  break;
6231  i++;
6232  if (i == (ssize_t) argc)
6233  ThrowMogrifyException(OptionError,"MissingArgument",option);
6234  break;
6235  }
6236  if (LocaleCompare("strokewidth",option+1) == 0)
6237  {
6238  if (*option == '+')
6239  break;
6240  i++;
6241  if (i == (ssize_t) argc)
6242  ThrowMogrifyException(OptionError,"MissingArgument",option);
6243  if (IsGeometry(argv[i]) == MagickFalse)
6244  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6245  break;
6246  }
6247  if (LocaleCompare("style",option+1) == 0)
6248  {
6249  ssize_t
6250  style;
6251 
6252  if (*option == '+')
6253  break;
6254  i++;
6255  if (i == (ssize_t) argc)
6256  ThrowMogrifyException(OptionError,"MissingArgument",option);
6257  style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6258  if (style < 0)
6259  ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6260  argv[i]);
6261  break;
6262  }
6263  if (LocaleCompare("swap",option+1) == 0)
6264  {
6265  if (*option == '+')
6266  break;
6267  i++;
6268  if (i == (ssize_t) argc)
6269  ThrowMogrifyException(OptionError,"MissingArgument",option);
6270  if (IsGeometry(argv[i]) == MagickFalse)
6271  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6272  break;
6273  }
6274  if (LocaleCompare("swirl",option+1) == 0)
6275  {
6276  if (*option == '+')
6277  break;
6278  i++;
6279  if (i == (ssize_t) argc)
6280  ThrowMogrifyException(OptionError,"MissingArgument",option);
6281  if (IsGeometry(argv[i]) == MagickFalse)
6282  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6283  break;
6284  }
6285  if (LocaleCompare("synchronize",option+1) == 0)
6286  break;
6287  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6288  }
6289  case 't':
6290  {
6291  if (LocaleCompare("taint",option+1) == 0)
6292  break;
6293  if (LocaleCompare("texture",option+1) == 0)
6294  {
6295  if (*option == '+')
6296  break;
6297  i++;
6298  if (i == (ssize_t) argc)
6299  ThrowMogrifyException(OptionError,"MissingArgument",option);
6300  break;
6301  }
6302  if (LocaleCompare("tile",option+1) == 0)
6303  {
6304  if (*option == '+')
6305  break;
6306  i++;
6307  if (i == (ssize_t) argc)
6308  ThrowMogrifyException(OptionError,"MissingArgument",option);
6309  break;
6310  }
6311  if (LocaleCompare("tile-offset",option+1) == 0)
6312  {
6313  if (*option == '+')
6314  break;
6315  i++;
6316  if (i == (ssize_t) argc)
6317  ThrowMogrifyException(OptionError,"MissingArgument",option);
6318  if (IsGeometry(argv[i]) == MagickFalse)
6319  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6320  break;
6321  }
6322  if (LocaleCompare("tint",option+1) == 0)
6323  {
6324  if (*option == '+')
6325  break;
6326  i++;
6327  if (i == (ssize_t) argc)
6328  ThrowMogrifyException(OptionError,"MissingArgument",option);
6329  if (IsGeometry(argv[i]) == MagickFalse)
6330  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6331  break;
6332  }
6333  if (LocaleCompare("transform",option+1) == 0)
6334  break;
6335  if (LocaleCompare("transpose",option+1) == 0)
6336  break;
6337  if (LocaleCompare("transverse",option+1) == 0)
6338  break;
6339  if (LocaleCompare("threshold",option+1) == 0)
6340  {
6341  if (*option == '+')
6342  break;
6343  i++;
6344  if (i == (ssize_t) argc)
6345  ThrowMogrifyException(OptionError,"MissingArgument",option);
6346  if (IsGeometry(argv[i]) == MagickFalse)
6347  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6348  break;
6349  }
6350  if (LocaleCompare("thumbnail",option+1) == 0)
6351  {
6352  if (*option == '+')
6353  break;
6354  i++;
6355  if (i == (ssize_t) argc)
6356  ThrowMogrifyException(OptionError,"MissingArgument",option);
6357  if (IsGeometry(argv[i]) == MagickFalse)
6358  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6359  break;
6360  }
6361  if (LocaleCompare("transparent",option+1) == 0)
6362  {
6363  i++;
6364  if (i == (ssize_t) argc)
6365  ThrowMogrifyException(OptionError,"MissingArgument",option);
6366  break;
6367  }
6368  if (LocaleCompare("transparent-color",option+1) == 0)
6369  {
6370  if (*option == '+')
6371  break;
6372  i++;
6373  if (i == (ssize_t) argc)
6374  ThrowMogrifyException(OptionError,"MissingArgument",option);
6375  break;
6376  }
6377  if (LocaleCompare("treedepth",option+1) == 0)
6378  {
6379  if (*option == '+')
6380  break;
6381  i++;
6382  if (i == (ssize_t) argc)
6383  ThrowMogrifyException(OptionError,"MissingArgument",option);
6384  if (IsGeometry(argv[i]) == MagickFalse)
6385  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6386  break;
6387  }
6388  if (LocaleCompare("trim",option+1) == 0)
6389  break;
6390  if (LocaleCompare("type",option+1) == 0)
6391  {
6392  ssize_t
6393  type;
6394 
6395  if (*option == '+')
6396  break;
6397  i++;
6398  if (i == (ssize_t) argc)
6399  ThrowMogrifyException(OptionError,"MissingArgument",option);
6400  type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6401  if (type < 0)
6402  ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6403  argv[i]);
6404  break;
6405  }
6406  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6407  }
6408  case 'u':
6409  {
6410  if (LocaleCompare("undercolor",option+1) == 0)
6411  {
6412  if (*option == '+')
6413  break;
6414  i++;
6415  if (i == (ssize_t) argc)
6416  ThrowMogrifyException(OptionError,"MissingArgument",option);
6417  break;
6418  }
6419  if (LocaleCompare("unique-colors",option+1) == 0)
6420  break;
6421  if (LocaleCompare("units",option+1) == 0)
6422  {
6423  ssize_t
6424  units;
6425 
6426  if (*option == '+')
6427  break;
6428  i++;
6429  if (i == (ssize_t) argc)
6430  ThrowMogrifyException(OptionError,"MissingArgument",option);
6431  units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6432  argv[i]);
6433  if (units < 0)
6434  ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6435  argv[i]);
6436  break;
6437  }
6438  if (LocaleCompare("unsharp",option+1) == 0)
6439  {
6440  i++;
6441  if (i == (ssize_t) argc)
6442  ThrowMogrifyException(OptionError,"MissingArgument",option);
6443  if (IsGeometry(argv[i]) == MagickFalse)
6444  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6445  break;
6446  }
6447  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6448  }
6449  case 'v':
6450  {
6451  if (LocaleCompare("verbose",option+1) == 0)
6452  {
6453  image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6454  break;
6455  }
6456  if ((LocaleCompare("version",option+1) == 0) ||
6457  (LocaleCompare("-version",option+1) == 0))
6458  {
6459  ListMagickVersion(stdout);
6460  break;
6461  }
6462  if (LocaleCompare("vignette",option+1) == 0)
6463  {
6464  if (*option == '+')
6465  break;
6466  i++;
6467  if (i == (ssize_t) argc)
6468  ThrowMogrifyException(OptionError,"MissingArgument",option);
6469  if (IsGeometry(argv[i]) == MagickFalse)
6470  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6471  break;
6472  }
6473  if (LocaleCompare("virtual-pixel",option+1) == 0)
6474  {
6475  ssize_t
6476  method;
6477 
6478  if (*option == '+')
6479  break;
6480  i++;
6481  if (i == (ssize_t) argc)
6482  ThrowMogrifyException(OptionError,"MissingArgument",option);
6483  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6484  argv[i]);
6485  if (method < 0)
6486  ThrowMogrifyException(OptionError,
6487  "UnrecognizedVirtualPixelMethod",argv[i]);
6488  break;
6489  }
6490  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6491  }
6492  case 'w':
6493  {
6494  if (LocaleCompare("wave",option+1) == 0)
6495  {
6496  i++;
6497  if (i == (ssize_t) argc)
6498  ThrowMogrifyException(OptionError,"MissingArgument",option);
6499  if (IsGeometry(argv[i]) == MagickFalse)
6500  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6501  break;
6502  }
6503  if (LocaleCompare("wavelet-denoise",option+1) == 0)
6504  {
6505  i++;
6506  if (i == (ssize_t) argc)
6507  ThrowMogrifyException(OptionError,"MissingArgument",option);
6508  if (IsGeometry(argv[i]) == MagickFalse)
6509  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6510  break;
6511  }
6512  if (LocaleCompare("weight",option+1) == 0)
6513  {
6514  if (*option == '+')
6515  break;
6516  i++;
6517  if (i == (ssize_t) argc)
6518  ThrowMogrifyException(OptionError,"MissingArgument",option);
6519  break;
6520  }
6521  if (LocaleCompare("word-break",option+1) == 0)
6522  {
6523  ssize_t
6524  word_break;
6525 
6526  if (*option == '+')
6527  break;
6528  i++;
6529  if (i == (ssize_t) argc)
6530  ThrowMogrifyException(OptionError,"MissingArgument",option);
6531  word_break=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
6532  argv[i]);
6533  if (word_break < 0)
6534  ThrowMogrifyException(OptionError,"UnrecognizedArgument",argv[i]);
6535  break;
6536  }
6537  if (LocaleCompare("white-balance",option+1) == 0)
6538  break;
6539  if (LocaleCompare("white-point",option+1) == 0)
6540  {
6541  if (*option == '+')
6542  break;
6543  i++;
6544  if (i == (ssize_t) argc)
6545  ThrowMogrifyException(OptionError,"MissingArgument",option);
6546  if (IsGeometry(argv[i]) == MagickFalse)
6547  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6548  break;
6549  }
6550  if (LocaleCompare("white-threshold",option+1) == 0)
6551  {
6552  if (*option == '+')
6553  break;
6554  i++;
6555  if (i == (ssize_t) argc)
6556  ThrowMogrifyException(OptionError,"MissingArgument",option);
6557  if (IsGeometry(argv[i]) == MagickFalse)
6558  ThrowMogrifyInvalidArgumentException(option,argv[i]);
6559  break;
6560  }
6561  if (LocaleCompare("write",option+1) == 0)
6562  {
6563  i++;
6564  if (i == (ssize_t) argc)
6565  ThrowMogrifyException(OptionError,"MissingArgument",option);
6566  break;
6567  }
6568  if (LocaleCompare("write-mask",option+1) == 0)
6569  {
6570  if (*option == '+')
6571  break;
6572  i++;
6573  if (i == (ssize_t) argc)
6574  ThrowMogrifyException(OptionError,"MissingArgument",option);
6575  break;
6576  }
6577  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6578  }
6579  case '?':
6580  break;
6581  default:
6582  ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6583  }
6584  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6585  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6586  if (fire != MagickFalse)
6587  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6588  }
6589  if (k != 0)
6590  ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6591  if (i != (ssize_t) argc)
6592  ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6593  DestroyMogrify();
6594  return(status != 0 ? MagickTrue : MagickFalse);
6595 }
6596 
6597 /*
6598 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6599 % %
6600 % %
6601 % %
6602 + M o g r i f y I m a g e I n f o %
6603 % %
6604 % %
6605 % %
6606 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6607 %
6608 % MogrifyImageInfo() applies image processing settings to the image as
6609 % prescribed by command line options.
6610 %
6611 % The format of the MogrifyImageInfo method is:
6612 %
6613 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6614 % const char **argv,ExceptionInfo *exception)
6615 %
6616 % A description of each parameter follows:
6617 %
6618 % o image_info: the image info..
6619 %
6620 % o argc: Specifies a pointer to an integer describing the number of
6621 % elements in the argument vector.
6622 %
6623 % o argv: Specifies a pointer to a text array containing the command line
6624 % arguments.
6625 %
6626 % o exception: return any errors or warnings in this structure.
6627 %
6628 */
6629 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6630  const int argc,const char **argv,ExceptionInfo *exception)
6631 {
6632  const char
6633  *option;
6634 
6635  GeometryInfo
6636  geometry_info;
6637 
6638  ssize_t
6639  count;
6640 
6641  ssize_t
6642  i;
6643 
6644  /*
6645  Initialize method variables.
6646  */
6647  assert(image_info != (ImageInfo *) NULL);
6648  assert(image_info->signature == MagickCoreSignature);
6649  if (IsEventLogging() != MagickFalse)
6650  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6651  image_info->filename);
6652  if (argc < 0)
6653  return(MagickTrue);
6654  /*
6655  Set the image settings.
6656  */
6657  for (i=0; i < (ssize_t) argc; i++)
6658  {
6659  option=argv[i];
6660  if (IsCommandOption(option) == MagickFalse)
6661  continue;
6662  count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6663  count=MagickMax(count,0L);
6664  if ((i+count) >= (ssize_t) argc)
6665  break;
6666  switch (*(option+1))
6667  {
6668  case 'a':
6669  {
6670  if (LocaleCompare("adjoin",option+1) == 0)
6671  {
6672  image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6673  break;
6674  }
6675  if (LocaleCompare("antialias",option+1) == 0)
6676  {
6677  image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6678  break;
6679  }
6680  if (LocaleCompare("authenticate",option+1) == 0)
6681  {
6682  if (*option == '+')
6683  (void) DeleteImageOption(image_info,option+1);
6684  else
6685  (void) SetImageOption(image_info,option+1,argv[i+1]);
6686  break;
6687  }
6688  break;
6689  }
6690  case 'b':
6691  {
6692  if (LocaleCompare("background",option+1) == 0)
6693  {
6694  if (*option == '+')
6695  {
6696  (void) DeleteImageOption(image_info,option+1);
6697  (void) QueryColorCompliance(MogrifyBackgroundColor,
6698  AllCompliance,&image_info->background_color,exception);
6699  break;
6700  }
6701  (void) SetImageOption(image_info,option+1,argv[i+1]);
6702  (void) QueryColorCompliance(argv[i+1],AllCompliance,
6703  &image_info->background_color,exception);
6704  break;
6705  }
6706  if (LocaleCompare("bias",option+1) == 0)
6707  {
6708  if (*option == '+')
6709  {
6710  (void) SetImageOption(image_info,"convolve:bias","0.0");
6711  break;
6712  }
6713  (void) SetImageOption(image_info,"convolve:bias",argv[i+1]);
6714  break;
6715  }
6716  if (LocaleCompare("black-point-compensation",option+1) == 0)
6717  {
6718  if (*option == '+')
6719  {
6720  (void) SetImageOption(image_info,option+1,"false");
6721  break;
6722  }
6723  (void) SetImageOption(image_info,option+1,"true");
6724  break;
6725  }
6726  if (LocaleCompare("blue-primary",option+1) == 0)
6727  {
6728  if (*option == '+')
6729  {
6730  (void) SetImageOption(image_info,option+1,"0.0");
6731  break;
6732  }
6733  (void) SetImageOption(image_info,option+1,argv[i+1]);
6734  break;
6735  }
6736  if (LocaleCompare("bordercolor",option+1) == 0)
6737  {
6738  if (*option == '+')
6739  {
6740  (void) DeleteImageOption(image_info,option+1);
6741  (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6742  &image_info->border_color,exception);
6743  break;
6744  }
6745  (void) QueryColorCompliance(argv[i+1],AllCompliance,
6746  &image_info->border_color,exception);
6747  (void) SetImageOption(image_info,option+1,argv[i+1]);
6748  break;
6749  }
6750  if (LocaleCompare("box",option+1) == 0)
6751  {
6752  if (*option == '+')
6753  {
6754  (void) SetImageOption(image_info,"undercolor","none");
6755  break;
6756  }
6757  (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6758  break;
6759  }
6760  break;
6761  }
6762  case 'c':
6763  {
6764  if (LocaleCompare("cache",option+1) == 0)
6765  {
6766  MagickSizeType
6767  limit;
6768 
6769  limit=MagickResourceInfinity;
6770  if (LocaleCompare("unlimited",argv[i+1]) != 0)
6771  limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6772  100.0);
6773  (void) SetMagickResourceLimit(MemoryResource,limit);
6774  (void) SetMagickResourceLimit(MapResource,2*limit);
6775  break;
6776  }
6777  if (LocaleCompare("caption",option+1) == 0)
6778  {
6779  if (*option == '+')
6780  {
6781  (void) DeleteImageOption(image_info,option+1);
6782  break;
6783  }
6784  (void) SetImageOption(image_info,option+1,argv[i+1]);
6785  break;
6786  }
6787  if (LocaleCompare("colorspace",option+1) == 0)
6788  {
6789  if (*option == '+')
6790  {
6791  image_info->colorspace=UndefinedColorspace;
6792  (void) SetImageOption(image_info,option+1,"undefined");
6793  break;
6794  }
6795  image_info->colorspace=(ColorspaceType) ParseCommandOption(
6796  MagickColorspaceOptions,MagickFalse,argv[i+1]);
6797  (void) SetImageOption(image_info,option+1,argv[i+1]);
6798  break;
6799  }
6800  if (LocaleCompare("comment",option+1) == 0)
6801  {
6802  if (*option == '+')
6803  {
6804  (void) DeleteImageOption(image_info,option+1);
6805  break;
6806  }
6807  (void) SetImageOption(image_info,option+1,argv[i+1]);
6808  break;
6809  }
6810  if (LocaleCompare("compose",option+1) == 0)
6811  {
6812  if (*option == '+')
6813  {
6814  (void) SetImageOption(image_info,option+1,"undefined");
6815  break;
6816  }
6817  (void) SetImageOption(image_info,option+1,argv[i+1]);
6818  break;
6819  }
6820  if (LocaleCompare("compress",option+1) == 0)
6821  {
6822  if (*option == '+')
6823  {
6824  image_info->compression=UndefinedCompression;
6825  (void) SetImageOption(image_info,option+1,"undefined");
6826  break;
6827  }
6828  image_info->compression=(CompressionType) ParseCommandOption(
6829  MagickCompressOptions,MagickFalse,argv[i+1]);
6830  (void) SetImageOption(image_info,option+1,argv[i+1]);
6831  break;
6832  }
6833  break;
6834  }
6835  case 'd':
6836  {
6837  if (LocaleCompare("debug",option+1) == 0)
6838  {
6839  if (*option == '+')
6840  (void) SetLogEventMask("none");
6841  else
6842  (void) SetLogEventMask(argv[i+1]);
6843  image_info->debug=IsEventLogging();
6844  break;
6845  }
6846  if (LocaleCompare("define",option+1) == 0)
6847  {
6848  if (*option == '+')
6849  {
6850  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6851  (void) DeleteImageRegistry(argv[i+1]+9);
6852  else
6853  (void) DeleteImageOption(image_info,argv[i+1]);
6854  break;
6855  }
6856  if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6857  {
6858  (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6859  exception);
6860  break;
6861  }
6862  (void) DefineImageOption(image_info,argv[i+1]);
6863  break;
6864  }
6865  if (LocaleCompare("delay",option+1) == 0)
6866  {
6867  if (*option == '+')
6868  {
6869  (void) SetImageOption(image_info,option+1,"0");
6870  break;
6871  }
6872  (void) SetImageOption(image_info,option+1,argv[i+1]);
6873  break;
6874  }
6875  if (LocaleCompare("density",option+1) == 0)
6876  {
6877  /*
6878  Set image density.
6879  */
6880  if (*option == '+')
6881  {
6882  if (image_info->density != (char *) NULL)
6883  image_info->density=DestroyString(image_info->density);
6884  (void) SetImageOption(image_info,option+1,"72");
6885  break;
6886  }
6887  (void) CloneString(&image_info->density,argv[i+1]);
6888  (void) SetImageOption(image_info,option+1,argv[i+1]);
6889  break;
6890  }
6891  if (LocaleCompare("depth",option+1) == 0)
6892  {
6893  if (*option == '+')
6894  {
6895  image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6896  break;
6897  }
6898  image_info->depth=StringToUnsignedLong(argv[i+1]);
6899  break;
6900  }
6901  if (LocaleCompare("direction",option+1) == 0)
6902  {
6903  if (*option == '+')
6904  {
6905  (void) SetImageOption(image_info,option+1,"undefined");
6906  break;
6907  }
6908  (void) SetImageOption(image_info,option+1,argv[i+1]);
6909  break;
6910  }
6911  if (LocaleCompare("display",option+1) == 0)
6912  {
6913  if (*option == '+')
6914  {
6915  if (image_info->server_name != (char *) NULL)
6916  image_info->server_name=DestroyString(
6917  image_info->server_name);
6918  break;
6919  }
6920  (void) CloneString(&image_info->server_name,argv[i+1]);
6921  break;
6922  }
6923  if (LocaleCompare("dispose",option+1) == 0)
6924  {
6925  if (*option == '+')
6926  {
6927  (void) SetImageOption(image_info,option+1,"undefined");
6928  break;
6929  }
6930  (void) SetImageOption(image_info,option+1,argv[i+1]);
6931  break;
6932  }
6933  if (LocaleCompare("dither",option+1) == 0)
6934  {
6935  if (*option == '+')
6936  {
6937  image_info->dither=MagickFalse;
6938  (void) SetImageOption(image_info,option+1,"none");
6939  break;
6940  }
6941  (void) SetImageOption(image_info,option+1,argv[i+1]);
6942  image_info->dither=MagickTrue;
6943  break;
6944  }
6945  break;
6946  }
6947  case 'e':
6948  {
6949  if (LocaleCompare("encoding",option+1) == 0)
6950  {
6951  if (*option == '+')
6952  {
6953  (void) SetImageOption(image_info,option+1,"undefined");
6954  break;
6955  }
6956  (void) SetImageOption(image_info,option+1,argv[i+1]);
6957  break;
6958  }
6959  if (LocaleCompare("endian",option+1) == 0)
6960  {
6961  if (*option == '+')
6962  {
6963  image_info->endian=UndefinedEndian;
6964  (void) SetImageOption(image_info,option+1,"undefined");
6965  break;
6966  }
6967  image_info->endian=(EndianType) ParseCommandOption(
6968  MagickEndianOptions,MagickFalse,argv[i+1]);
6969  (void) SetImageOption(image_info,option+1,argv[i+1]);
6970  break;
6971  }
6972  if (LocaleCompare("extract",option+1) == 0)
6973  {
6974  /*
6975  Set image extract geometry.
6976  */
6977  if (*option == '+')
6978  {
6979  if (image_info->extract != (char *) NULL)
6980  image_info->extract=DestroyString(image_info->extract);
6981  break;
6982  }
6983  (void) CloneString(&image_info->extract,argv[i+1]);
6984  break;
6985  }
6986  break;
6987  }
6988  case 'f':
6989  {
6990  if (LocaleCompare("family",option+1) == 0)
6991  {
6992  if (*option != '+')
6993  (void) SetImageOption(image_info,option+1,argv[i+1]);
6994  break;
6995  }
6996  if (LocaleCompare("fill",option+1) == 0)
6997  {
6998  if (*option == '+')
6999  {
7000  (void) SetImageOption(image_info,option+1,"none");
7001  break;
7002  }
7003  (void) SetImageOption(image_info,option+1,argv[i+1]);
7004  break;
7005  }
7006  if (LocaleCompare("filter",option+1) == 0)
7007  {
7008  if (*option == '+')
7009  {
7010  (void) SetImageOption(image_info,option+1,"undefined");
7011  break;
7012  }
7013  (void) SetImageOption(image_info,option+1,argv[i+1]);
7014  break;
7015  }
7016  if (LocaleCompare("font",option+1) == 0)
7017  {
7018  if (*option == '+')
7019  {
7020  if (image_info->font != (char *) NULL)
7021  image_info->font=DestroyString(image_info->font);
7022  break;
7023  }
7024  (void) CloneString(&image_info->font,argv[i+1]);
7025  break;
7026  }
7027  if (LocaleCompare("format",option+1) == 0)
7028  {
7029  (void) SetImageOption(image_info,option+1,argv[i+1]);
7030  break;
7031  }
7032  if (LocaleCompare("fuzz",option+1) == 0)
7033  {
7034  if (*option == '+')
7035  {
7036  image_info->fuzz=0.0;
7037  (void) SetImageOption(image_info,option+1,"0");
7038  break;
7039  }
7040  image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
7041  QuantumRange+1.0);
7042  (void) SetImageOption(image_info,option+1,argv[i+1]);
7043  break;
7044  }
7045  break;
7046  }
7047  case 'g':
7048  {
7049  if (LocaleCompare("gravity",option+1) == 0)
7050  {
7051  if (*option == '+')
7052  {
7053  (void) SetImageOption(image_info,option+1,"undefined");
7054  break;
7055  }
7056  (void) SetImageOption(image_info,option+1,argv[i+1]);
7057  break;
7058  }
7059  if (LocaleCompare("green-primary",option+1) == 0)
7060  {
7061  if (*option == '+')
7062  {
7063  (void) SetImageOption(image_info,option+1,"0.0");
7064  break;
7065  }
7066  (void) SetImageOption(image_info,option+1,argv[i+1]);
7067  break;
7068  }
7069  break;
7070  }
7071  case 'i':
7072  {
7073  if (LocaleCompare("intensity",option+1) == 0)
7074  {
7075  if (*option == '+')
7076  {
7077  (void) SetImageOption(image_info,option+1,"undefined");
7078  break;
7079  }
7080  (void) SetImageOption(image_info,option+1,argv[i+1]);
7081  break;
7082  }
7083  if (LocaleCompare("intent",option+1) == 0)
7084  {
7085  if (*option == '+')
7086  {
7087  (void) SetImageOption(image_info,option+1,"undefined");
7088  break;
7089  }
7090  (void) SetImageOption(image_info,option+1,argv[i+1]);
7091  break;
7092  }
7093  if (LocaleCompare("interlace",option+1) == 0)
7094  {
7095  if (*option == '+')
7096  {
7097  image_info->interlace=UndefinedInterlace;
7098  (void) SetImageOption(image_info,option+1,"undefined");
7099  break;
7100  }
7101  image_info->interlace=(InterlaceType) ParseCommandOption(
7102  MagickInterlaceOptions,MagickFalse,argv[i+1]);
7103  (void) SetImageOption(image_info,option+1,argv[i+1]);
7104  break;
7105  }
7106  if (LocaleCompare("interline-spacing",option+1) == 0)
7107  {
7108  if (*option == '+')
7109  {
7110  (void) SetImageOption(image_info,option+1,"undefined");
7111  break;
7112  }
7113  (void) SetImageOption(image_info,option+1,argv[i+1]);
7114  break;
7115  }
7116  if (LocaleCompare("interpolate",option+1) == 0)
7117  {
7118  if (*option == '+')
7119  {
7120  (void) SetImageOption(image_info,option+1,"undefined");
7121  break;
7122  }
7123  (void) SetImageOption(image_info,option+1,argv[i+1]);
7124  break;
7125  }
7126  if (LocaleCompare("interword-spacing",option+1) == 0)
7127  {
7128  if (*option == '+')
7129  {
7130  (void) SetImageOption(image_info,option+1,"undefined");
7131  break;
7132  }
7133  (void) SetImageOption(image_info,option+1,argv[i+1]);
7134  break;
7135  }
7136  break;
7137  }
7138  case 'k':
7139  {
7140  if (LocaleCompare("kerning",option+1) == 0)
7141  {
7142  if (*option == '+')
7143  {
7144  (void) SetImageOption(image_info,option+1,"undefined");
7145  break;
7146  }
7147  (void) SetImageOption(image_info,option+1,argv[i+1]);
7148  break;
7149  }
7150  break;
7151  }
7152  case 'l':
7153  {
7154  if (LocaleCompare("label",option+1) == 0)
7155  {
7156  if (*option == '+')
7157  {
7158  (void) DeleteImageOption(image_info,option+1);
7159  break;
7160  }
7161  (void) SetImageOption(image_info,option+1,argv[i+1]);
7162  break;
7163  }
7164  if (LocaleCompare("limit",option+1) == 0)
7165  {
7166  MagickSizeType
7167  limit;
7168 
7169  ResourceType
7170  type;
7171 
7172  if (*option == '+')
7173  break;
7174  type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7175  MagickFalse,argv[i+1]);
7176  limit=MagickResourceInfinity;
7177  if (LocaleCompare("unlimited",argv[i+2]) != 0)
7178  limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7179  if (type == TimeResource)
7180  limit=(MagickSizeType) ParseMagickTimeToLive(argv[i+2]);
7181  (void) SetMagickResourceLimit(type,limit);
7182  break;
7183  }
7184  if (LocaleCompare("list",option+1) == 0)
7185  {
7186  ssize_t
7187  list;
7188 
7189  /*
7190  Display configuration list.
7191  */
7192  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7193  switch (list)
7194  {
7195  case MagickCoderOptions:
7196  {
7197  (void) ListCoderInfo((FILE *) NULL,exception);
7198  break;
7199  }
7200  case MagickColorOptions:
7201  {
7202  (void) ListColorInfo((FILE *) NULL,exception);
7203  break;
7204  }
7205  case MagickConfigureOptions:
7206  {
7207  (void) ListConfigureInfo((FILE *) NULL,exception);
7208  break;
7209  }
7210  case MagickDelegateOptions:
7211  {
7212  (void) ListDelegateInfo((FILE *) NULL,exception);
7213  break;
7214  }
7215  case MagickFontOptions:
7216  {
7217  (void) ListTypeInfo((FILE *) NULL,exception);
7218  break;
7219  }
7220  case MagickFormatOptions:
7221  {
7222  (void) ListMagickInfo((FILE *) NULL,exception);
7223  break;
7224  }
7225  case MagickLocaleOptions:
7226  {
7227  (void) ListLocaleInfo((FILE *) NULL,exception);
7228  break;
7229  }
7230  case MagickLogOptions:
7231  {
7232  (void) ListLogInfo((FILE *) NULL,exception);
7233  break;
7234  }
7235  case MagickMagicOptions:
7236  {
7237  (void) ListMagicInfo((FILE *) NULL,exception);
7238  break;
7239  }
7240  case MagickMimeOptions:
7241  {
7242  (void) ListMimeInfo((FILE *) NULL,exception);
7243  break;
7244  }
7245  case MagickModuleOptions:
7246  {
7247  (void) ListModuleInfo((FILE *) NULL,exception);
7248  break;
7249  }
7250  case MagickPagesizeOptions:
7251  {
7252  (void) ListPagesizes((FILE *) NULL,exception);
7253  break;
7254  }
7255  case MagickPolicyOptions:
7256  {
7257  (void) ListPolicyInfo((FILE *) NULL,exception);
7258  break;
7259  }
7260  case MagickResourceOptions:
7261  {
7262  (void) ListMagickResourceInfo((FILE *) NULL,exception);
7263  break;
7264  }
7265  case MagickThresholdOptions:
7266  {
7267  (void) ListThresholdMaps((FILE *) NULL,exception);
7268  break;
7269  }
7270  default:
7271  {
7272  (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7273  exception);
7274  break;
7275  }
7276  }
7277  break;
7278  }
7279  if (LocaleCompare("log",option+1) == 0)
7280  {
7281  if (*option == '+')
7282  break;
7283  (void) SetLogFormat(argv[i+1]);
7284  break;
7285  }
7286  if (LocaleCompare("loop",option+1) == 0)
7287  {
7288  if (*option == '+')
7289  {
7290  (void) SetImageOption(image_info,option+1,"0");
7291  break;
7292  }
7293  (void) SetImageOption(image_info,option+1,argv[i+1]);
7294  break;
7295  }
7296  break;
7297  }
7298  case 'm':
7299  {
7300  if (LocaleCompare("matte",option+1) == 0)
7301  {
7302  if (*option == '+')
7303  {
7304  (void) SetImageOption(image_info,option+1,"false");
7305  break;
7306  }
7307  (void) SetImageOption(image_info,option+1,"true");
7308  break;
7309  }
7310  if (LocaleCompare("mattecolor",option+1) == 0)
7311  {
7312  if (*option == '+')
7313  {
7314  (void) SetImageOption(image_info,option+1,argv[i+1]);
7315  (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7316  &image_info->matte_color,exception);
7317  break;
7318  }
7319  (void) SetImageOption(image_info,option+1,argv[i+1]);
7320  (void) QueryColorCompliance(argv[i+1],AllCompliance,
7321  &image_info->matte_color,exception);
7322  break;
7323  }
7324  if (LocaleCompare("metric",option+1) == 0)
7325  {
7326  if (*option == '+')
7327  (void) DeleteImageOption(image_info,option+1);
7328  else
7329  (void) SetImageOption(image_info,option+1,argv[i+1]);
7330  break;
7331  }
7332  if (LocaleCompare("monitor",option+1) == 0)
7333  {
7334  (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7335  (void *) NULL);
7336  break;
7337  }
7338  if (LocaleCompare("monochrome",option+1) == 0)
7339  {
7340  image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7341  break;
7342  }
7343  break;
7344  }
7345  case 'o':
7346  {
7347  if (LocaleCompare("orient",option+1) == 0)
7348  {
7349  if (*option == '+')
7350  {
7351  image_info->orientation=UndefinedOrientation;
7352  (void) SetImageOption(image_info,option+1,"undefined");
7353  break;
7354  }
7355  image_info->orientation=(OrientationType) ParseCommandOption(
7356  MagickOrientationOptions,MagickFalse,argv[i+1]);
7357  (void) SetImageOption(image_info,option+1,argv[i+1]);
7358  break;
7359  }
7360  break;
7361  }
7362  case 'p':
7363  {
7364  if (LocaleCompare("page",option+1) == 0)
7365  {
7366  char
7367  *canonical_page,
7368  page[MagickPathExtent];
7369 
7370  const char
7371  *image_option;
7372 
7373  MagickStatusType
7374  flags;
7375 
7376  RectangleInfo
7377  geometry;
7378 
7379  if (*option == '+')
7380  {
7381  (void) DeleteImageOption(image_info,option+1);
7382  (void) CloneString(&image_info->page,(char *) NULL);
7383  break;
7384  }
7385  (void) memset(&geometry,0,sizeof(geometry));
7386  image_option=GetImageOption(image_info,"page");
7387  if (image_option != (const char *) NULL)
7388  flags=ParseAbsoluteGeometry(image_option,&geometry);
7389  canonical_page=GetPageGeometry(argv[i+1]);
7390  flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7391  canonical_page=DestroyString(canonical_page);
7392  (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu",
7393  (unsigned long) geometry.width,(unsigned long) geometry.height);
7394  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7395  (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu%+ld%+ld",
7396  (unsigned long) geometry.width,(unsigned long) geometry.height,
7397  (long) geometry.x,(long) geometry.y);
7398  (void) SetImageOption(image_info,option+1,page);
7399  (void) CloneString(&image_info->page,page);
7400  break;
7401  }
7402  if (LocaleCompare("ping",option+1) == 0)
7403  {
7404  image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7405  break;
7406  }
7407  if (LocaleCompare("pointsize",option+1) == 0)
7408  {
7409  if (*option == '+')
7410  geometry_info.rho=0.0;
7411  else
7412  (void) ParseGeometry(argv[i+1],&geometry_info);
7413  image_info->pointsize=geometry_info.rho;
7414  break;
7415  }
7416  if (LocaleCompare("precision",option+1) == 0)
7417  {
7418  (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7419  break;
7420  }
7421  break;
7422  }
7423  case 'q':
7424  {
7425  if (LocaleCompare("quality",option+1) == 0)
7426  {
7427  /*
7428  Set image compression quality.
7429  */
7430  if (*option == '+')
7431  {
7432  image_info->quality=UndefinedCompressionQuality;
7433  (void) SetImageOption(image_info,option+1,"0");
7434  break;
7435  }
7436  image_info->quality=StringToUnsignedLong(argv[i+1]);
7437  (void) SetImageOption(image_info,option+1,argv[i+1]);
7438  break;
7439  }
7440  if (LocaleCompare("quiet",option+1) == 0)
7441  {
7442  static WarningHandler
7443  warning_handler = (WarningHandler) NULL;
7444 
7445  if (*option == '+')
7446  {
7447  /*
7448  Restore error or warning messages.
7449  */
7450  warning_handler=SetWarningHandler(warning_handler);
7451  break;
7452  }
7453  /*
7454  Suppress error or warning messages.
7455  */
7456  warning_handler=SetWarningHandler((WarningHandler) NULL);
7457  break;
7458  }
7459  break;
7460  }
7461  case 'r':
7462  {
7463  if (LocaleCompare("red-primary",option+1) == 0)
7464  {
7465  if (*option == '+')
7466  {
7467  (void) SetImageOption(image_info,option+1,"0.0");
7468  break;
7469  }
7470  (void) SetImageOption(image_info,option+1,argv[i+1]);
7471  break;
7472  }
7473  break;
7474  }
7475  case 's':
7476  {
7477  if (LocaleCompare("sampling-factor",option+1) == 0)
7478  {
7479  /*
7480  Set image sampling factor.
7481  */
7482  if (*option == '+')
7483  {
7484  if (image_info->sampling_factor != (char *) NULL)
7485  image_info->sampling_factor=DestroyString(
7486  image_info->sampling_factor);
7487  break;
7488  }
7489  (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7490  break;
7491  }
7492  if (LocaleCompare("scene",option+1) == 0)
7493  {
7494  /*
7495  Set image scene.
7496  */
7497  if (*option == '+')
7498  {
7499  image_info->scene=0;
7500  (void) SetImageOption(image_info,option+1,"0");
7501  break;
7502  }
7503  image_info->scene=StringToUnsignedLong(argv[i+1]);
7504  (void) SetImageOption(image_info,option+1,argv[i+1]);
7505  break;
7506  }
7507  if (LocaleCompare("seed",option+1) == 0)
7508  {
7509  unsigned long
7510  seed;
7511 
7512  if (*option == '+')
7513  {
7514  seed=(unsigned long) time((time_t *) NULL);
7515  SetRandomSecretKey(seed);
7516  break;
7517  }
7518  seed=StringToUnsignedLong(argv[i+1]);
7519  SetRandomSecretKey(seed);
7520  break;
7521  }
7522  if (LocaleCompare("size",option+1) == 0)
7523  {
7524  if (*option == '+')
7525  {
7526  if (image_info->size != (char *) NULL)
7527  image_info->size=DestroyString(image_info->size);
7528  break;
7529  }
7530  (void) CloneString(&image_info->size,argv[i+1]);
7531  break;
7532  }
7533  if (LocaleCompare("stroke",option+1) == 0)
7534  {
7535  if (*option == '+')
7536  {
7537  (void) SetImageOption(image_info,option+1,"none");
7538  break;
7539  }
7540  (void) SetImageOption(image_info,option+1,argv[i+1]);
7541  break;
7542  }
7543  if (LocaleCompare("strokewidth",option+1) == 0)
7544  {
7545  if (*option == '+')
7546  (void) SetImageOption(image_info,option+1,"0");
7547  else
7548  (void) SetImageOption(image_info,option+1,argv[i+1]);
7549  break;
7550  }
7551  if (LocaleCompare("style",option+1) == 0)
7552  {
7553  if (*option == '+')
7554  {
7555  (void) SetImageOption(image_info,option+1,"none");
7556  break;
7557  }
7558  (void) SetImageOption(image_info,option+1,argv[i+1]);
7559  break;
7560  }
7561  if (LocaleCompare("synchronize",option+1) == 0)
7562  {
7563  if (*option == '+')
7564  {
7565  image_info->synchronize=MagickFalse;
7566  break;
7567  }
7568  image_info->synchronize=MagickTrue;
7569  break;
7570  }
7571  break;
7572  }
7573  case 't':
7574  {
7575  if (LocaleCompare("taint",option+1) == 0)
7576  {
7577  if (*option == '+')
7578  {
7579  (void) SetImageOption(image_info,option+1,"false");
7580  break;
7581  }
7582  (void) SetImageOption(image_info,option+1,"true");
7583  break;
7584  }
7585  if (LocaleCompare("texture",option+1) == 0)
7586  {
7587  if (*option == '+')
7588  {
7589  if (image_info->texture != (char *) NULL)
7590  image_info->texture=DestroyString(image_info->texture);
7591  break;
7592  }
7593  (void) CloneString(&image_info->texture,argv[i+1]);
7594  break;
7595  }
7596  if (LocaleCompare("tile-offset",option+1) == 0)
7597  {
7598  if (*option == '+')
7599  (void) SetImageOption(image_info,option+1,"0");
7600  else
7601  (void) SetImageOption(image_info,option+1,argv[i+1]);
7602  break;
7603  }
7604  if (LocaleCompare("transparent-color",option+1) == 0)
7605  {
7606  if (*option == '+')
7607  {
7608  (void) QueryColorCompliance("none",AllCompliance,
7609  &image_info->transparent_color,exception);
7610  (void) SetImageOption(image_info,option+1,"none");
7611  break;
7612  }
7613  (void) QueryColorCompliance(argv[i+1],AllCompliance,
7614  &image_info->transparent_color,exception);
7615  (void) SetImageOption(image_info,option+1,argv[i+1]);
7616  break;
7617  }
7618  if (LocaleCompare("type",option+1) == 0)
7619  {
7620  if (*option == '+')
7621  {
7622  image_info->type=UndefinedType;
7623  (void) SetImageOption(image_info,option+1,"undefined");
7624  break;
7625  }
7626  image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7627  MagickFalse,argv[i+1]);
7628  (void) SetImageOption(image_info,option+1,argv[i+1]);
7629  break;
7630  }
7631  break;
7632  }
7633  case 'u':
7634  {
7635  if (LocaleCompare("undercolor",option+1) == 0)
7636  {
7637  if (*option == '+')
7638  (void) DeleteImageOption(image_info,option+1);
7639  else
7640  (void) SetImageOption(image_info,option+1,argv[i+1]);
7641  break;
7642  }
7643  if (LocaleCompare("units",option+1) == 0)
7644  {
7645  if (*option == '+')
7646  {
7647  image_info->units=UndefinedResolution;
7648  (void) SetImageOption(image_info,option+1,"undefined");
7649  break;
7650  }
7651  image_info->units=(ResolutionType) ParseCommandOption(
7652  MagickResolutionOptions,MagickFalse,argv[i+1]);
7653  (void) SetImageOption(image_info,option+1,argv[i+1]);
7654  break;
7655  }
7656  break;
7657  }
7658  case 'v':
7659  {
7660  if (LocaleCompare("verbose",option+1) == 0)
7661  {
7662  if (*option == '+')
7663  {
7664  image_info->verbose=MagickFalse;
7665  break;
7666  }
7667  image_info->verbose=MagickTrue;
7668  image_info->ping=MagickFalse;
7669  break;
7670  }
7671  if (LocaleCompare("virtual-pixel",option+1) == 0)
7672  {
7673  if (*option == '+')
7674  (void) SetImageOption(image_info,option+1,"undefined");
7675  else
7676  (void) SetImageOption(image_info,option+1,argv[i+1]);
7677  break;
7678  }
7679  break;
7680  }
7681  case 'w':
7682  {
7683  if (LocaleCompare("weight",option+1) == 0)
7684  {
7685  if (*option == '+')
7686  (void) SetImageOption(image_info,option+1,"0");
7687  else
7688  (void) SetImageOption(image_info,option+1,argv[i+1]);
7689  break;
7690  }
7691  if (LocaleCompare("white-point",option+1) == 0)
7692  {
7693  if (*option == '+')
7694  (void) SetImageOption(image_info,option+1,"0.0");
7695  else
7696  (void) SetImageOption(image_info,option+1,argv[i+1]);
7697  break;
7698  }
7699  if (LocaleCompare("word-break",option+1) == 0)
7700  {
7701  if (*option == '+')
7702  {
7703  (void) SetImageOption(image_info,option+1,"undefined");
7704  break;
7705  }
7706  (void) SetImageOption(image_info,option+1,argv[i+1]);
7707  break;
7708  }
7709  break;
7710  }
7711  default:
7712  break;
7713  }
7714  i+=count;
7715  }
7716  return(MagickTrue);
7717 }
7718 
7719 /*
7720 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7721 % %
7722 % %
7723 % %
7724 + M o g r i f y I m a g e L i s t %
7725 % %
7726 % %
7727 % %
7728 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7729 %
7730 % MogrifyImageList() applies any command line options that might affect the
7731 % entire image list (e.g. -append, -coalesce, etc.).
7732 %
7733 % The format of the MogrifyImage method is:
7734 %
7735 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7736 % const char **argv,Image **images,ExceptionInfo *exception)
7737 %
7738 % A description of each parameter follows:
7739 %
7740 % o image_info: the image info..
7741 %
7742 % o argc: Specifies a pointer to an integer describing the number of
7743 % elements in the argument vector.
7744 %
7745 % o argv: Specifies a pointer to a text array containing the command line
7746 % arguments.
7747 %
7748 % o images: pointer to pointer of the first image in image list.
7749 %
7750 % o exception: return any errors or warnings in this structure.
7751 %
7752 */
7753 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7754  const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7755 {
7756  const char
7757  *option;
7758 
7759  ImageInfo
7760  *mogrify_info;
7761 
7762  MagickStatusType
7763  status;
7764 
7765  PixelInterpolateMethod
7766  interpolate_method;
7767 
7768  QuantizeInfo
7769  *quantize_info;
7770 
7771  ssize_t
7772  i;
7773 
7774  ssize_t
7775  count,
7776  index;
7777 
7778  /*
7779  Apply options to the image list.
7780  */
7781  assert(image_info != (ImageInfo *) NULL);
7782  assert(image_info->signature == MagickCoreSignature);
7783  assert(images != (Image **) NULL);
7784  assert((*images)->previous == (Image *) NULL);
7785  assert((*images)->signature == MagickCoreSignature);
7786  if (IsEventLogging() != MagickFalse)
7787  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7788  (*images)->filename);
7789  if ((argc <= 0) || (*argv == (char *) NULL))
7790  return(MagickTrue);
7791  interpolate_method=UndefinedInterpolatePixel;
7792  mogrify_info=CloneImageInfo(image_info);
7793  quantize_info=AcquireQuantizeInfo(mogrify_info);
7794  status=MagickTrue;
7795  for (i=0; i < (ssize_t) argc; i++)
7796  {
7797  if (*images == (Image *) NULL)
7798  break;
7799  option=argv[i];
7800  if (IsCommandOption(option) == MagickFalse)
7801  continue;
7802  count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7803  count=MagickMax(count,0L);
7804  if ((i+count) >= (ssize_t) argc)
7805  break;
7806  status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7807  switch (*(option+1))
7808  {
7809  case 'a':
7810  {
7811  if (LocaleCompare("affinity",option+1) == 0)
7812  {
7813  (void) SyncImagesSettings(mogrify_info,*images,exception);
7814  if (*option == '+')
7815  {
7816  (void) RemapImages(quantize_info,*images,(Image *) NULL,
7817  exception);
7818  break;
7819  }
7820  i++;
7821  break;
7822  }
7823  if (LocaleCompare("append",option+1) == 0)
7824  {
7825  Image
7826  *append_image;
7827 
7828  (void) SyncImagesSettings(mogrify_info,*images,exception);
7829  append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7830  MagickFalse,exception);
7831  if (append_image == (Image *) NULL)
7832  {
7833  status=MagickFalse;
7834  break;
7835  }
7836  *images=DestroyImageList(*images);
7837  *images=append_image;
7838  break;
7839  }
7840  if (LocaleCompare("average",option+1) == 0)
7841  {
7842  Image
7843  *average_image;
7844 
7845  /*
7846  Average an image sequence (deprecated).
7847  */
7848  (void) SyncImagesSettings(mogrify_info,*images,exception);
7849  average_image=EvaluateImages(*images,MeanEvaluateOperator,
7850  exception);
7851  if (average_image == (Image *) NULL)
7852  {
7853  status=MagickFalse;
7854  break;
7855  }
7856  *images=DestroyImageList(*images);
7857  *images=average_image;
7858  break;
7859  }
7860  break;
7861  }
7862  case 'c':
7863  {
7864  if (LocaleCompare("channel-fx",option+1) == 0)
7865  {
7866  Image
7867  *channel_image;
7868 
7869  (void) SyncImagesSettings(mogrify_info,*images,exception);
7870  channel_image=ChannelFxImage(*images,argv[i+1],exception);
7871  if (channel_image == (Image *) NULL)
7872  {
7873  status=MagickFalse;
7874  break;
7875  }
7876  *images=DestroyImageList(*images);
7877  *images=channel_image;
7878  break;
7879  }
7880  if (LocaleCompare("clut",option+1) == 0)
7881  {
7882  Image
7883  *clut_image,
7884  *image;
7885 
7886  (void) SyncImagesSettings(mogrify_info,*images,exception);
7887  image=RemoveFirstImageFromList(images);
7888  clut_image=RemoveFirstImageFromList(images);
7889  if (clut_image == (Image *) NULL)
7890  {
7891  (void) ThrowMagickException(exception,GetMagickModule(),
7892  OptionError,"ImageSequenceRequired","`%s'",option);
7893  image=DestroyImage(image);
7894  status=MagickFalse;
7895  break;
7896  }
7897  (void) ClutImage(image,clut_image,interpolate_method,exception);
7898  clut_image=DestroyImage(clut_image);
7899  *images=DestroyImageList(*images);
7900  *images=image;
7901  break;
7902  }
7903  if (LocaleCompare("coalesce",option+1) == 0)
7904  {
7905  Image
7906  *coalesce_image;
7907 
7908  (void) SyncImagesSettings(mogrify_info,*images,exception);
7909  coalesce_image=CoalesceImages(*images,exception);
7910  if (coalesce_image == (Image *) NULL)
7911  {
7912  status=MagickFalse;
7913  break;
7914  }
7915  *images=DestroyImageList(*images);
7916  *images=coalesce_image;
7917  break;
7918  }
7919  if (LocaleCompare("combine",option+1) == 0)
7920  {
7921  ColorspaceType
7922  colorspace;
7923 
7924  Image
7925  *combine_image;
7926 
7927  (void) SyncImagesSettings(mogrify_info,*images,exception);
7928  colorspace=(*images)->colorspace;
7929  if ((*images)->number_channels < GetImageListLength(*images))
7930  colorspace=sRGBColorspace;
7931  if (*option == '+')
7932  colorspace=(ColorspaceType) ParseCommandOption(
7933  MagickColorspaceOptions,MagickFalse,argv[i+1]);
7934  combine_image=CombineImages(*images,colorspace,exception);
7935  if (combine_image == (Image *) NULL)
7936  {
7937  status=MagickFalse;
7938  break;
7939  }
7940  *images=DestroyImageList(*images);
7941  *images=combine_image;
7942  break;
7943  }
7944  if (LocaleCompare("compare",option+1) == 0)
7945  {
7946  double
7947  distortion;
7948 
7949  Image
7950  *difference_image,
7951  *image,
7952  *reconstruct_image;
7953 
7954  MetricType
7955  metric;
7956 
7957  /*
7958  Mathematically and visually annotate the difference between an
7959  image and its reconstruction.
7960  */
7961  (void) SyncImagesSettings(mogrify_info,*images,exception);
7962  image=RemoveFirstImageFromList(images);
7963  reconstruct_image=RemoveFirstImageFromList(images);
7964  if (reconstruct_image == (Image *) NULL)
7965  {
7966  (void) ThrowMagickException(exception,GetMagickModule(),
7967  OptionError,"ImageSequenceRequired","`%s'",option);
7968  image=DestroyImage(image);
7969  status=MagickFalse;
7970  break;
7971  }
7972  metric=UndefinedErrorMetric;
7973  option=GetImageOption(mogrify_info,"metric");
7974  if (option != (const char *) NULL)
7975  metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7976  MagickFalse,option);
7977  difference_image=CompareImages(image,reconstruct_image,metric,
7978  &distortion,exception);
7979  if (difference_image == (Image *) NULL)
7980  break;
7981  reconstruct_image=DestroyImage(reconstruct_image);
7982  image=DestroyImage(image);
7983  if (*images != (Image *) NULL)
7984  *images=DestroyImageList(*images);
7985  *images=difference_image;
7986  break;
7987  }
7988  if (LocaleCompare("complex",option+1) == 0)
7989  {
7990  ComplexOperator
7991  op;
7992 
7993  Image
7994  *complex_images;
7995 
7996  (void) SyncImageSettings(mogrify_info,*images,exception);
7997  op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7998  MagickFalse,argv[i+1]);
7999  complex_images=ComplexImages(*images,op,exception);
8000  if (complex_images == (Image *) NULL)
8001  {
8002  status=MagickFalse;
8003  break;
8004  }
8005  *images=DestroyImageList(*images);
8006  *images=complex_images;
8007  break;
8008  }
8009  if (LocaleCompare("composite",option+1) == 0)
8010  {
8011  CompositeOperator
8012  compose;
8013 
8014  const char*
8015  value;
8016 
8017  MagickBooleanType
8018  clip_to_self;
8019 
8020  Image
8021  *mask_image,
8022  *new_images,
8023  *source_image;
8024 
8025  RectangleInfo
8026  geometry;
8027 
8028  /* Compose value from "-compose" option only */
8029  (void) SyncImageSettings(mogrify_info,*images,exception);
8030  value=GetImageOption(mogrify_info,"compose");
8031  if (value == (const char *) NULL)
8032  compose=OverCompositeOp; /* use Over not source_image->compose */
8033  else
8034  compose=(CompositeOperator) ParseCommandOption(
8035  MagickComposeOptions,MagickFalse,value);
8036 
8037  /* Get "clip-to-self" expert setting (false is normal) */
8038  clip_to_self=GetCompositeClipToSelf(compose);
8039  value=GetImageOption(mogrify_info,"compose:clip-to-self");
8040  if (value != (const char *) NULL)
8041  clip_to_self=IsStringTrue(value);
8042  value=GetImageOption(mogrify_info,"compose:outside-overlay");
8043  if (value != (const char *) NULL)
8044  clip_to_self=IsStringFalse(value); /* deprecated */
8045 
8046  new_images=RemoveFirstImageFromList(images);
8047  source_image=RemoveFirstImageFromList(images);
8048  if (source_image == (Image *) NULL)
8049  {
8050  (void) ThrowMagickException(exception,GetMagickModule(),
8051  OptionError,"ImageSequenceRequired","`%s'",option);
8052  new_images=DestroyImage(new_images);
8053  status=MagickFalse;
8054  break;
8055  }
8056 
8057  /* FUTURE: this should not be here! - should be part of -geometry */
8058  if (source_image->geometry != (char *) NULL)
8059  {
8060  RectangleInfo
8061  resize_geometry;
8062 
8063  (void) ParseRegionGeometry(source_image,source_image->geometry,
8064  &resize_geometry,exception);
8065  if ((source_image->columns != resize_geometry.width) ||
8066  (source_image->rows != resize_geometry.height))
8067  {
8068  Image
8069  *resize_image;
8070 
8071  resize_image=ResizeImage(source_image,resize_geometry.width,
8072  resize_geometry.height,source_image->filter,exception);
8073  if (resize_image != (Image *) NULL)
8074  {
8075  source_image=DestroyImage(source_image);
8076  source_image=resize_image;
8077  }
8078  }
8079  }
8080  SetGeometry(source_image,&geometry);
8081  (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
8082  GravityAdjustGeometry(new_images->columns,new_images->rows,
8083  new_images->gravity,&geometry);
8084  mask_image=RemoveFirstImageFromList(images);
8085  if (mask_image == (Image *) NULL)
8086  status&=(MagickStatusType) CompositeImage(new_images,source_image,
8087  compose,clip_to_self,geometry.x,geometry.y,exception);
8088  else
8089  {
8090  Image
8091  *canvas_image;
8092 
8093  canvas_image=CloneImage(new_images,0,0,MagickTrue,exception);
8094  if (canvas_image == (Image *) NULL)
8095  break;
8096  switch (compose)
8097  {
8098  case BlendCompositeOp:
8099  {
8100  status&=(MagickStatusType) CompositeImage(new_images,
8101  source_image,compose,clip_to_self,geometry.x,geometry.y,
8102  exception);
8103  status&=(MagickStatusType) CompositeImage(new_images,
8104  mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8105  break;
8106  }
8107  case DisplaceCompositeOp:
8108  case DistortCompositeOp:
8109  {
8110  status&=(MagickStatusType) CompositeImage(source_image,
8111  mask_image,CopyGreenCompositeOp,MagickTrue,0,0,exception);
8112  (void) SetImageColorspace(source_image,sRGBColorspace,
8113  exception);
8114  status&=(MagickStatusType) CompositeImage(new_images,
8115  source_image,compose,clip_to_self,geometry.x,geometry.y,
8116  exception);
8117  break;
8118  }
8119  case SaliencyBlendCompositeOp:
8120  case SeamlessBlendCompositeOp:
8121  {
8122  status&=(MagickStatusType) CompositeImage(source_image,
8123  mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8124  status&=(MagickStatusType) CompositeImage(new_images,
8125  source_image,compose,clip_to_self,geometry.x,geometry.y,
8126  exception);
8127  break;
8128  }
8129  default:
8130  {
8131  Image
8132  *clone_image;
8133 
8134  clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
8135  if (clone_image == (Image *) NULL)
8136  break;
8137  status&=(MagickStatusType) CompositeImage(new_images,
8138  source_image,compose,clip_to_self,geometry.x,geometry.y,
8139  exception);
8140  status&=(MagickStatusType) CompositeImage(new_images,
8141  mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8142  status&=(MagickStatusType) CompositeImage(clone_image,
8143  new_images,OverCompositeOp,clip_to_self,0,0,exception);
8144  new_images=DestroyImageList(new_images);
8145  new_images=clone_image;
8146  break;
8147  }
8148  }
8149  switch (compose)
8150  {
8151  case DisplaceCompositeOp:
8152  case DistortCompositeOp:
8153  {
8154  status&=(MagickStatusType) CompositeImage(canvas_image,
8155  new_images,CopyCompositeOp,clip_to_self,0,0,exception);
8156  break;
8157  }
8158  default:
8159  {
8160  status&=(MagickStatusType) CompositeImage(canvas_image,
8161  new_images,OverCompositeOp,clip_to_self,0,0,exception);
8162  break;
8163  }
8164  }
8165  new_images=DestroyImageList(new_images);
8166  new_images=canvas_image;
8167  mask_image=DestroyImage(mask_image);
8168  }
8169  source_image=DestroyImage(source_image);
8170  *images=DestroyImageList(*images);
8171  *images=new_images;
8172  break;
8173  }
8174  if (LocaleCompare("copy",option+1) == 0)
8175  {
8176  Image
8177  *source_image;
8178 
8179  OffsetInfo
8180  offset;
8181 
8182  RectangleInfo
8183  geometry;
8184 
8185  /*
8186  Copy image pixels.
8187  */
8188  (void) SyncImageSettings(mogrify_info,*images,exception);
8189  (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8190  offset.x=geometry.x;
8191  offset.y=geometry.y;
8192  source_image=(*images);
8193  if (source_image->next != (Image *) NULL)
8194  source_image=source_image->next;
8195  (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8196  exception);
8197  status=CopyImagePixels(*images,source_image,&geometry,&offset,
8198  exception);
8199  break;
8200  }
8201  break;
8202  }
8203  case 'd':
8204  {
8205  if (LocaleCompare("deconstruct",option+1) == 0)
8206  {
8207  Image
8208  *deconstruct_image;
8209 
8210  (void) SyncImagesSettings(mogrify_info,*images,exception);
8211  deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8212  exception);
8213  if (deconstruct_image == (Image *) NULL)
8214  {
8215  status=MagickFalse;
8216  break;
8217  }
8218  *images=DestroyImageList(*images);
8219  *images=deconstruct_image;
8220  break;
8221  }
8222  if (LocaleCompare("delete",option+1) == 0)
8223  {
8224  if (*option == '+')
8225  DeleteImages(images,"-1",exception);
8226  else
8227  DeleteImages(images,argv[i+1],exception);
8228  break;
8229  }
8230  if (LocaleCompare("dither",option+1) == 0)
8231  {
8232  if (*option == '+')
8233  {
8234  quantize_info->dither_method=NoDitherMethod;
8235  break;
8236  }
8237  quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8238  MagickDitherOptions,MagickFalse,argv[i+1]);
8239  break;
8240  }
8241  if (LocaleCompare("duplicate",option+1) == 0)
8242  {
8243  Image
8244  *duplicate_images;
8245 
8246  if (*option == '+')
8247  duplicate_images=DuplicateImages(*images,1,"-1",exception);
8248  else
8249  {
8250  const char
8251  *p;
8252 
8253  size_t
8254  number_duplicates;
8255 
8256  number_duplicates=(size_t) StringToLong(argv[i+1]);
8257  p=strchr(argv[i+1],',');
8258  if (p == (const char *) NULL)
8259  duplicate_images=DuplicateImages(*images,number_duplicates,
8260  "-1",exception);
8261  else
8262  duplicate_images=DuplicateImages(*images,number_duplicates,
8263  p+1,exception);
8264  }
8265  AppendImageToList(images, duplicate_images);
8266  (void) SyncImagesSettings(mogrify_info,*images,exception);
8267  break;
8268  }
8269  break;
8270  }
8271  case 'e':
8272  {
8273  if (LocaleCompare("evaluate-sequence",option+1) == 0)
8274  {
8275  Image
8276  *evaluate_image;
8277 
8278  MagickEvaluateOperator
8279  op;
8280 
8281  (void) SyncImageSettings(mogrify_info,*images,exception);
8282  op=(MagickEvaluateOperator) ParseCommandOption(
8283  MagickEvaluateOptions,MagickFalse,argv[i+1]);
8284  evaluate_image=EvaluateImages(*images,op,exception);
8285  if (evaluate_image == (Image *) NULL)
8286  {
8287  status=MagickFalse;
8288  break;
8289  }
8290  *images=DestroyImageList(*images);
8291  *images=evaluate_image;
8292  break;
8293  }
8294  break;
8295  }
8296  case 'f':
8297  {
8298  if (LocaleCompare("fft",option+1) == 0)
8299  {
8300  Image
8301  *fourier_image;
8302 
8303  /*
8304  Implements the discrete Fourier transform (DFT).
8305  */
8306  (void) SyncImageSettings(mogrify_info,*images,exception);
8307  fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8308  MagickTrue : MagickFalse,exception);
8309  if (fourier_image == (Image *) NULL)
8310  break;
8311  *images=DestroyImageList(*images);
8312  *images=fourier_image;
8313  break;
8314  }
8315  if (LocaleCompare("flatten",option+1) == 0)
8316  {
8317  Image
8318  *flatten_image;
8319 
8320  (void) SyncImagesSettings(mogrify_info,*images,exception);
8321  flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8322  if (flatten_image == (Image *) NULL)
8323  break;
8324  *images=DestroyImageList(*images);
8325  *images=flatten_image;
8326  break;
8327  }
8328  if (LocaleCompare("fx",option+1) == 0)
8329  {
8330  Image
8331  *fx_image;
8332 
8333 puts("list");
8334  (void) SyncImagesSettings(mogrify_info,*images,exception);
8335  fx_image=FxImage(*images,argv[i+1],exception);
8336  if (fx_image == (Image *) NULL)
8337  {
8338  status=MagickFalse;
8339  break;
8340  }
8341  *images=DestroyImageList(*images);
8342  *images=fx_image;
8343  break;
8344  }
8345  break;
8346  }
8347  case 'h':
8348  {
8349  if (LocaleCompare("hald-clut",option+1) == 0)
8350  {
8351  Image
8352  *hald_image,
8353  *image;
8354 
8355  (void) SyncImagesSettings(mogrify_info,*images,exception);
8356  image=RemoveFirstImageFromList(images);
8357  hald_image=RemoveFirstImageFromList(images);
8358  if (hald_image == (Image *) NULL)
8359  {
8360  (void) ThrowMagickException(exception,GetMagickModule(),
8361  OptionError,"ImageSequenceRequired","`%s'",option);
8362  image=DestroyImage(image);
8363  status=MagickFalse;
8364  break;
8365  }
8366  (void) HaldClutImage(image,hald_image,exception);
8367  hald_image=DestroyImage(hald_image);
8368  if (*images != (Image *) NULL)
8369  *images=DestroyImageList(*images);
8370  *images=image;
8371  break;
8372  }
8373  break;
8374  }
8375  case 'i':
8376  {
8377  if (LocaleCompare("ift",option+1) == 0)
8378  {
8379  Image
8380  *fourier_image,
8381  *magnitude_image,
8382  *phase_image;
8383 
8384  /*
8385  Implements the inverse fourier discrete Fourier transform (DFT).
8386  */
8387  (void) SyncImagesSettings(mogrify_info,*images,exception);
8388  magnitude_image=RemoveFirstImageFromList(images);
8389  phase_image=RemoveFirstImageFromList(images);
8390  if (phase_image == (Image *) NULL)
8391  {
8392  (void) ThrowMagickException(exception,GetMagickModule(),
8393  OptionError,"ImageSequenceRequired","`%s'",option);
8394  magnitude_image=DestroyImage(magnitude_image);
8395  status=MagickFalse;
8396  break;
8397  }
8398  fourier_image=InverseFourierTransformImage(magnitude_image,
8399  phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
8400  magnitude_image=DestroyImage(magnitude_image);
8401  phase_image=DestroyImage(phase_image);
8402  if (fourier_image == (Image *) NULL)
8403  break;
8404  if (*images != (Image *) NULL)
8405  *images=DestroyImageList(*images);
8406  *images=fourier_image;
8407  break;
8408  }
8409  if (LocaleCompare("insert",option+1) == 0)
8410  {
8411  Image
8412  *p,
8413  *q;
8414 
8415  index=0;
8416  if (*option != '+')
8417  index=(ssize_t) StringToLong(argv[i+1]);
8418  p=RemoveLastImageFromList(images);
8419  if (p == (Image *) NULL)
8420  {
8421  (void) ThrowMagickException(exception,GetMagickModule(),
8422  OptionError,"NoSuchImage","`%s'",argv[i+1]);
8423  status=MagickFalse;
8424  break;
8425  }
8426  q=p;
8427  if (index == 0)
8428  PrependImageToList(images,q);
8429  else
8430  if (index == (ssize_t) GetImageListLength(*images))
8431  AppendImageToList(images,q);
8432  else
8433  {
8434  q=GetImageFromList(*images,index-1);
8435  if (q == (Image *) NULL)
8436  {
8437  p=DestroyImage(p);
8438  (void) ThrowMagickException(exception,GetMagickModule(),
8439  OptionError,"NoSuchImage","`%s'",argv[i+1]);
8440  status=MagickFalse;
8441  break;
8442  }
8443  InsertImageInList(&q,p);
8444  }
8445  *images=GetFirstImageInList(q);
8446  break;
8447  }
8448  if (LocaleCompare("interpolate",option+1) == 0)
8449  {
8450  interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8451  MagickInterpolateOptions,MagickFalse,argv[i+1]);
8452  break;
8453  }
8454  break;
8455  }
8456  case 'l':
8457  {
8458  if (LocaleCompare("layers",option+1) == 0)
8459  {
8460  Image
8461  *layers;
8462 
8463  LayerMethod
8464  method;
8465 
8466  (void) SyncImagesSettings(mogrify_info,*images,exception);
8467  layers=(Image *) NULL;
8468  method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8469  MagickFalse,argv[i+1]);
8470  switch (method)
8471  {
8472  case CoalesceLayer:
8473  {
8474  layers=CoalesceImages(*images,exception);
8475  break;
8476  }
8477  case CompareAnyLayer:
8478  case CompareClearLayer:
8479  case CompareOverlayLayer:
8480  default:
8481  {
8482  layers=CompareImagesLayers(*images,method,exception);
8483  break;
8484  }
8485  case MergeLayer:
8486  case FlattenLayer:
8487  case MosaicLayer:
8488  case TrimBoundsLayer:
8489  {
8490  layers=MergeImageLayers(*images,method,exception);
8491  break;
8492  }
8493  case DisposeLayer:
8494  {
8495  layers=DisposeImages(*images,exception);
8496  break;
8497  }
8498  case OptimizeImageLayer:
8499  {
8500  layers=OptimizeImageLayers(*images,exception);
8501  break;
8502  }
8503  case OptimizePlusLayer:
8504  {
8505  layers=OptimizePlusImageLayers(*images,exception);
8506  break;
8507  }
8508  case OptimizeTransLayer:
8509  {
8510  OptimizeImageTransparency(*images,exception);
8511  break;
8512  }
8513  case RemoveDupsLayer:
8514  {
8515  RemoveDuplicateLayers(images,exception);
8516  break;
8517  }
8518  case RemoveZeroLayer:
8519  {
8520  RemoveZeroDelayLayers(images,exception);
8521  break;
8522  }
8523  case OptimizeLayer:
8524  {
8525  /*
8526  General Purpose, GIF Animation Optimizer.
8527  */
8528  layers=CoalesceImages(*images,exception);
8529  if (layers == (Image *) NULL)
8530  {
8531  status=MagickFalse;
8532  break;
8533  }
8534  *images=DestroyImageList(*images);
8535  *images=layers;
8536  layers=OptimizeImageLayers(*images,exception);
8537  if (layers == (Image *) NULL)
8538  {
8539  status=MagickFalse;
8540  break;
8541  }
8542  *images=DestroyImageList(*images);
8543  *images=layers;
8544  layers=(Image *) NULL;
8545  OptimizeImageTransparency(*images,exception);
8546  (void) RemapImages(quantize_info,*images,(Image *) NULL,
8547  exception);
8548  break;
8549  }
8550  case CompositeLayer:
8551  {
8552  CompositeOperator
8553  compose;
8554 
8555  Image
8556  *source;
8557 
8558  RectangleInfo
8559  geometry;
8560 
8561  /*
8562  Split image sequence at the first 'NULL:' image.
8563  */
8564  source=(*images);
8565  while (source != (Image *) NULL)
8566  {
8567  source=GetNextImageInList(source);
8568  if ((source != (Image *) NULL) &&
8569  (LocaleCompare(source->magick,"NULL") == 0))
8570  break;
8571  }
8572  if (source != (Image *) NULL)
8573  {
8574  if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8575  (GetNextImageInList(source) == (Image *) NULL))
8576  source=(Image *) NULL;
8577  else
8578  {
8579  /*
8580  Separate the two lists, junk the null: image.
8581  */
8582  source=SplitImageList(source->previous);
8583  DeleteImageFromList(&source);
8584  }
8585  }
8586  if (source == (Image *) NULL)
8587  {
8588  (void) ThrowMagickException(exception,GetMagickModule(),
8589  OptionError,"MissingNullSeparator","layers Composite");
8590  status=MagickFalse;
8591  break;
8592  }
8593  /*
8594  Adjust offset with gravity and virtual canvas.
8595  */
8596  SetGeometry(*images,&geometry);
8597  (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8598  geometry.width=source->page.width != 0 ?
8599  source->page.width : source->columns;
8600  geometry.height=source->page.height != 0 ?
8601  source->page.height : source->rows;
8602  GravityAdjustGeometry((*images)->page.width != 0 ?
8603  (*images)->page.width : (*images)->columns,
8604  (*images)->page.height != 0 ? (*images)->page.height :
8605  (*images)->rows,(*images)->gravity,&geometry);
8606  compose=OverCompositeOp;
8607  option=GetImageOption(mogrify_info,"compose");
8608  if (option != (const char *) NULL)
8609  compose=(CompositeOperator) ParseCommandOption(
8610  MagickComposeOptions,MagickFalse,option);
8611  CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8612  exception);
8613  source=DestroyImageList(source);
8614  break;
8615  }
8616  }
8617  if (layers == (Image *) NULL)
8618  break;
8619  *images=DestroyImageList(*images);
8620  *images=layers;
8621  break;
8622  }
8623  break;
8624  }
8625  case 'm':
8626  {
8627  if (LocaleCompare("map",option+1) == 0)
8628  {
8629  (void) SyncImagesSettings(mogrify_info,*images,exception);
8630  if (*option == '+')
8631  {
8632  (void) RemapImages(quantize_info,*images,(Image *) NULL,
8633  exception);
8634  break;
8635  }
8636  i++;
8637  break;
8638  }
8639  if (LocaleCompare("maximum",option+1) == 0)
8640  {
8641  Image
8642  *maximum_image;
8643 
8644  /*
8645  Maximum image sequence (deprecated).
8646  */
8647  (void) SyncImagesSettings(mogrify_info,*images,exception);
8648  maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8649  if (maximum_image == (Image *) NULL)
8650  {
8651  status=MagickFalse;
8652  break;
8653  }
8654  *images=DestroyImageList(*images);
8655  *images=maximum_image;
8656  break;
8657  }
8658  if (LocaleCompare("minimum",option+1) == 0)
8659  {
8660  Image
8661  *minimum_image;
8662 
8663  /*
8664  Minimum image sequence (deprecated).
8665  */
8666  (void) SyncImagesSettings(mogrify_info,*images,exception);
8667  minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8668  if (minimum_image == (Image *) NULL)
8669  {
8670  status=MagickFalse;
8671  break;
8672  }
8673  *images=DestroyImageList(*images);
8674  *images=minimum_image;
8675  break;
8676  }
8677  if (LocaleCompare("morph",option+1) == 0)
8678  {
8679  Image
8680  *morph_image;
8681 
8682  (void) SyncImagesSettings(mogrify_info,*images,exception);
8683  morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8684  exception);
8685  if (morph_image == (Image *) NULL)
8686  {
8687  status=MagickFalse;
8688  break;
8689  }
8690  *images=DestroyImageList(*images);
8691  *images=morph_image;
8692  break;
8693  }
8694  if (LocaleCompare("mosaic",option+1) == 0)
8695  {
8696  Image
8697  *mosaic_image;
8698 
8699  (void) SyncImagesSettings(mogrify_info,*images,exception);
8700  mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8701  if (mosaic_image == (Image *) NULL)
8702  {
8703  status=MagickFalse;
8704  break;
8705  }
8706  *images=DestroyImageList(*images);
8707  *images=mosaic_image;
8708  break;
8709  }
8710  break;
8711  }
8712  case 'p':
8713  {
8714  if (LocaleCompare("poly",option+1) == 0)
8715  {
8716  char
8717  *args,
8718  token[MagickPathExtent];
8719 
8720  const char
8721  *p;
8722 
8723  double
8724  *arguments;
8725 
8726  Image
8727  *polynomial_image;
8728 
8729  ssize_t
8730  x;
8731 
8732  size_t
8733  number_arguments;
8734 
8735  /*
8736  Polynomial image.
8737  */
8738  (void) SyncImageSettings(mogrify_info,*images,exception);
8739  args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8740  exception);
8741  if (args == (char *) NULL)
8742  break;
8743  p=(char *) args;
8744  for (x=0; *p != '\0'; x++)
8745  {
8746  (void) GetNextToken(p,&p,MagickPathExtent,token);
8747  if (*token == ',')
8748  (void) GetNextToken(p,&p,MagickPathExtent,token);
8749  }
8750  number_arguments=(size_t) x;
8751  arguments=(double *) AcquireQuantumMemory(number_arguments,
8752  sizeof(*arguments));
8753  if (arguments == (double *) NULL)
8754  ThrowWandFatalException(ResourceLimitFatalError,
8755  "MemoryAllocationFailed",(*images)->filename);
8756  (void) memset(arguments,0,number_arguments*
8757  sizeof(*arguments));
8758  p=(char *) args;
8759  for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8760  {
8761  (void) GetNextToken(p,&p,MagickPathExtent,token);
8762  if (*token == ',')
8763  (void) GetNextToken(p,&p,MagickPathExtent,token);
8764  arguments[x]=StringToDouble(token,(char **) NULL);
8765  }
8766  args=DestroyString(args);
8767  polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8768  arguments,exception);
8769  arguments=(double *) RelinquishMagickMemory(arguments);
8770  if (polynomial_image == (Image *) NULL)
8771  {
8772  status=MagickFalse;
8773  break;
8774  }
8775  *images=DestroyImageList(*images);
8776  *images=polynomial_image;
8777  }
8778  if (LocaleCompare("print",option+1) == 0)
8779  {
8780  char
8781  *string;
8782 
8783  (void) SyncImagesSettings(mogrify_info,*images,exception);
8784  string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8785  exception);
8786  if (string == (char *) NULL)
8787  break;
8788  (void) FormatLocaleFile(stdout,"%s",string);
8789  string=DestroyString(string);
8790  }
8791  if (LocaleCompare("process",option+1) == 0)
8792  {
8793  char
8794  **arguments;
8795 
8796  int
8797  j,
8798  number_arguments;
8799 
8800  (void) SyncImagesSettings(mogrify_info,*images,exception);
8801  arguments=StringToArgv(argv[i+1],&number_arguments);
8802  if ((arguments == (char **) NULL) || (number_arguments == 1))
8803  break;
8804  if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8805  {
8806  char
8807  breaker,
8808  quote,
8809  *token;
8810 
8811  const char
8812  *argument;
8813 
8814  int
8815  next,
8816  token_status;
8817 
8818  size_t
8819  length;
8820 
8821  TokenInfo
8822  *token_info;
8823 
8824  /*
8825  Support old style syntax, filter="-option arg".
8826  */
8827  length=strlen(argv[i+1]);
8828  token=(char *) NULL;
8829  if (~length >= (MagickPathExtent-1))
8830  token=(char *) AcquireQuantumMemory(length+MagickPathExtent,
8831  sizeof(*token));
8832  if (token == (char *) NULL)
8833  break;
8834  next=0;
8835  argument=argv[i+1];
8836  token_info=AcquireTokenInfo();
8837  token_status=Tokenizer(token_info,0,token,length,argument,"",
8838  "=","\"",'\0',&breaker,&next,&quote);
8839  token_info=DestroyTokenInfo(token_info);
8840  if (token_status == 0)
8841  {
8842  const char
8843  *arg;
8844 
8845  arg=(&(argument[next]));
8846  (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8847  exception);
8848  }
8849  token=DestroyString(token);
8850  break;
8851  }
8852  (void) SubstituteString(&arguments[1],"-","");
8853  (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8854  number_arguments-2,(const char **) arguments+2,exception);
8855  for (j=0; j < number_arguments; j++)
8856  arguments[j]=DestroyString(arguments[j]);
8857  arguments=(char **) RelinquishMagickMemory(arguments);
8858  break;
8859  }
8860  break;
8861  }
8862  case 'r':
8863  {
8864  if (LocaleCompare("reverse",option+1) == 0)
8865  {
8866  ReverseImageList(images);
8867  break;
8868  }
8869  break;
8870  }
8871  case 's':
8872  {
8873  if (LocaleCompare("smush",option+1) == 0)
8874  {
8875  Image
8876  *smush_image;
8877 
8878  ssize_t
8879  offset;
8880 
8881  (void) SyncImagesSettings(mogrify_info,*images,exception);
8882  offset=(ssize_t) StringToLong(argv[i+1]);
8883  smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8884  MagickFalse,offset,exception);
8885  if (smush_image == (Image *) NULL)
8886  {
8887  status=MagickFalse;
8888  break;
8889  }
8890  *images=DestroyImageList(*images);
8891  *images=smush_image;
8892  break;
8893  }
8894  if (LocaleCompare("swap",option+1) == 0)
8895  {
8896  Image
8897  *p,
8898  *q,
8899  *u,
8900  *v;
8901 
8902  ssize_t
8903  swap_index;
8904 
8905  index=(-1);
8906  swap_index=(-2);
8907  if (*option != '+')
8908  {
8909  GeometryInfo
8910  geometry_info;
8911 
8912  MagickStatusType
8913  flags;
8914 
8915  swap_index=(-1);
8916  flags=ParseGeometry(argv[i+1],&geometry_info);
8917  index=(ssize_t) geometry_info.rho;
8918  if ((flags & SigmaValue) != 0)
8919  swap_index=(ssize_t) geometry_info.sigma;
8920  }
8921  p=GetImageFromList(*images,index);
8922  q=GetImageFromList(*images,swap_index);
8923  if ((p == (Image *) NULL) || (q == (Image *) NULL))
8924  {
8925  (void) ThrowMagickException(exception,GetMagickModule(),
8926  OptionError,"NoSuchImage","`%s'",(*images)->filename);
8927  status=MagickFalse;
8928  break;
8929  }
8930  if (p == q)
8931  break;
8932  u=CloneImage(p,0,0,MagickTrue,exception);
8933  if (u == (Image *) NULL)
8934  break;
8935  v=CloneImage(q,0,0,MagickTrue,exception);
8936  if (v == (Image *) NULL)
8937  {
8938  u=DestroyImage(u);
8939  break;
8940  }
8941  ReplaceImageInList(&p,v);
8942  ReplaceImageInList(&q,u);
8943  *images=GetFirstImageInList(q);
8944  break;
8945  }
8946  break;
8947  }
8948  case 'w':
8949  {
8950  if (LocaleCompare("write",option+1) == 0)
8951  {
8952  char
8953  key[MagickPathExtent];
8954 
8955  Image
8956  *write_images;
8957 
8958  ImageInfo
8959  *write_info;
8960 
8961  (void) SyncImagesSettings(mogrify_info,*images,exception);
8962  (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",
8963  argv[i+1]);
8964  (void) DeleteImageRegistry(key);
8965  write_images=CloneImageList(*images,exception);
8966  write_info=CloneImageInfo(mogrify_info);
8967  status&=(MagickStatusType) WriteImages(write_info,write_images,
8968  argv[i+1],exception);
8969  write_info=DestroyImageInfo(write_info);
8970  write_images=DestroyImageList(write_images);
8971  break;
8972  }
8973  break;
8974  }
8975  default:
8976  break;
8977  }
8978  i+=count;
8979  }
8980  quantize_info=DestroyQuantizeInfo(quantize_info);
8981  mogrify_info=DestroyImageInfo(mogrify_info);
8982  status&=(MagickStatusType) MogrifyImageInfo(image_info,argc,argv,exception);
8983  return(status != 0 ? MagickTrue : MagickFalse);
8984 }
8985 
8986 /*
8987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8988 % %
8989 % %
8990 % %
8991 + M o g r i f y I m a g e s %
8992 % %
8993 % %
8994 % %
8995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8996 %
8997 % MogrifyImages() applies image processing options to a sequence of images as
8998 % prescribed by command line options.
8999 %
9000 % The format of the MogrifyImage method is:
9001 %
9002 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
9003 % const MagickBooleanType post,const int argc,const char **argv,
9004 % Image **images,Exceptioninfo *exception)
9005 %
9006 % A description of each parameter follows:
9007 %
9008 % o image_info: the image info..
9009 %
9010 % o post: If true, post process image list operators otherwise pre-process.
9011 %
9012 % o argc: Specifies a pointer to an integer describing the number of
9013 % elements in the argument vector.
9014 %
9015 % o argv: Specifies a pointer to a text array containing the command line
9016 % arguments.
9017 %
9018 % o images: pointer to a pointer of the first image in image list.
9019 %
9020 % o exception: return any errors or warnings in this structure.
9021 %
9022 */
9023 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
9024  const MagickBooleanType post,const int argc,const char **argv,
9025  Image **images,ExceptionInfo *exception)
9026 {
9027 #define MogrifyImageTag "Mogrify/Image"
9028 
9029  MagickStatusType
9030  status;
9031 
9032  MagickBooleanType
9033  proceed;
9034 
9035  size_t
9036  n;
9037 
9038  ssize_t
9039  i;
9040 
9041  assert(image_info != (ImageInfo *) NULL);
9042  assert(image_info->signature == MagickCoreSignature);
9043  if (images == (Image **) NULL)
9044  return(MogrifyImage(image_info,argc,argv,images,exception));
9045  assert((*images)->previous == (Image *) NULL);
9046  assert((*images)->signature == MagickCoreSignature);
9047  if (IsEventLogging() != MagickFalse)
9048  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
9049  (*images)->filename);
9050  if ((argc <= 0) || (*argv == (char *) NULL))
9051  return(MagickTrue);
9052  (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
9053  (void *) NULL);
9054  status=MagickTrue;
9055 #if 0
9056  (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
9057  post?"post":"pre");
9058 #endif
9059  /*
9060  Pre-process multi-image sequence operators
9061  */
9062  if (post == MagickFalse)
9063  status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9064  exception);
9065  /*
9066  For each image, process simple single image operators
9067  */
9068  i=0;
9069  n=GetImageListLength(*images);
9070  for ( ; ; )
9071  {
9072 #if 0
9073  (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
9074  GetImageIndexInList(*images),(long)GetImageListLength(*images));
9075 #endif
9076  status&=(MagickStatusType) MogrifyImage(image_info,argc,argv,images,
9077  exception);
9078  proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
9079  if (proceed == MagickFalse)
9080  break;
9081  if ( (*images)->next == (Image *) NULL )
9082  break;
9083  *images=(*images)->next;
9084  i++;
9085  }
9086  assert( *images != (Image *) NULL );
9087 #if 0
9088  (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
9089  GetImageIndexInList(*images),(long)GetImageListLength(*images));
9090 #endif
9091  /*
9092  Post-process, multi-image sequence operators
9093  */
9094  *images=GetFirstImageInList(*images);
9095  if (post != MagickFalse)
9096  status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9097  exception);
9098  return(status != 0 ? MagickTrue : MagickFalse);
9099 }
_ImageStack
Definition: mogrify-private.h:113