MagickWand  7.0.8
Convert, Edit, Or Compose Bitmap Images
convert.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % CCCC OOO N N V V EEEEE RRRR TTTTT %
7 % C O O NN N V V E R R T %
8 % C O O N N N V V EEE RRRR T %
9 % C O O N NN V V E R R T %
10 % CCCC OOO N N V EEEEE R R T %
11 % %
12 % %
13 % Convert an image from one format to another. %
14 % %
15 % Software Design %
16 % Cristy %
17 % April 1992 %
18 % %
19 % %
20 % Copyright 1999-2019 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 convert program to convert between image formats as well as resize
37 % an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample,
38 % and much more.
39 %
40 */
41 
42 /*
43  Include declarations.
44 */
45 #include "MagickWand/studio.h"
46 #include "MagickWand/MagickWand.h"
48 #include "MagickCore/string-private.h"
49 #include "MagickCore/utility-private.h"
50 /*
51  Define declarations.
52 */
53 #define ThrowFileException(exception,severity,tag,context) \
54 { \
55  char \
56  *message; \
57  \
58  message=GetExceptionMessage(errno); \
59  (void) ThrowMagickException(exception,GetMagickModule(),severity, \
60  tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context,message); \
61  message=DestroyString(message); \
62 }
63 
64 /*
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 % %
67 % %
68 % %
69 + C o n v e r t I m a g e C o m m a n d %
70 % %
71 % %
72 % %
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %
75 % ConvertImageCommand() reads one or more images, applies one or more image
76 % processing operations, and writes out the image in the same or differing
77 % format.
78 %
79 % The format of the ConvertImageCommand method is:
80 %
81 % MagickBooleanType ConvertImageCommand(ImageInfo *image_info,int argc,
82 % char **argv,char **metadata,ExceptionInfo *exception)
83 %
84 % A description of each parameter follows:
85 %
86 % o image_info: the image info.
87 %
88 % o argc: the number of elements in the argument vector.
89 %
90 % o argv: A text array containing the command line arguments.
91 %
92 % o metadata: any metadata is returned here.
93 %
94 % o exception: return any errors or warnings in this structure.
95 %
96 */
97 
98 static MagickBooleanType ConcatenateImages(int argc,char **argv,
99  ExceptionInfo *exception)
100 {
101  FILE
102  *input,
103  *output;
104 
105  int
106  c;
107 
108  MagickBooleanType
109  status;
110 
111  register ssize_t
112  i;
113 
114  /*
115  Open output file.
116  */
117  output=fopen_utf8(argv[argc-1],"wb");
118  if (output == (FILE *) NULL)
119  {
120  ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
121  argv[argc-1]);
122  return(MagickFalse);
123  }
124  status=MagickTrue;
125  for (i=2; i < (ssize_t) (argc-1); i++)
126  {
127  input=fopen_utf8(argv[i],"rb");
128  if (input == (FILE *) NULL)
129  {
130  ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]);
131  continue;
132  }
133  for (c=fgetc(input); c != EOF; c=fgetc(input))
134  if (fputc((char) c,output) != c)
135  status=MagickFalse;
136  (void) fclose(input);
137  (void) remove_utf8(argv[i]);
138  }
139  (void) fclose(output);
140  return(status);
141 }
142 
143 static MagickBooleanType ConvertUsage(void)
144 {
145  static const char
146  *channel_operators[]=
147  {
148  "-channel-fx expression",
149  " exchange, extract, or transfer one or more image channels",
150  "-separate separate an image channel into a grayscale image",
151  (char *) NULL
152  },
153  *miscellaneous[]=
154  {
155  "-debug events display copious debugging information",
156  "-distribute-cache port",
157  " distributed pixel cache spanning one or more servers",
158  "-help print program options",
159  "-list type print a list of supported option arguments",
160  "-log format format of debugging information",
161  "-version print version information",
162  (char *) NULL
163  },
164  *operators[]=
165  {
166  "-adaptive-blur geometry",
167  " adaptively blur pixels; decrease effect near edges",
168  "-adaptive-resize geometry",
169  " adaptively resize image using 'mesh' interpolation",
170  "-adaptive-sharpen geometry",
171  " adaptively sharpen pixels; increase effect near edges",
172  "-alpha option on, activate, off, deactivate, set, opaque, copy",
173  " transparent, extract, background, or shape",
174  "-annotate geometry text",
175  " annotate the image with text",
176  "-auto-gamma automagically adjust gamma level of image",
177  "-auto-level automagically adjust color levels of image",
178  "-auto-orient automagically orient (rotate) image",
179  "-auto-threshold method",
180  " automatically perform image thresholding",
181  "-bench iterations measure performance",
182  "-black-threshold value",
183  " force all pixels below the threshold into black",
184  "-blue-shift factor simulate a scene at nighttime in the moonlight",
185  "-blur geometry reduce image noise and reduce detail levels",
186  "-border geometry surround image with a border of color",
187  "-bordercolor color border color",
188  "-brightness-contrast geometry",
189  " improve brightness / contrast of the image",
190  "-canny geometry detect edges in the image",
191  "-cdl filename color correct with a color decision list",
192  "-channel mask set the image channel mask",
193  "-charcoal radius simulate a charcoal drawing",
194  "-chop geometry remove pixels from the image interior",
195  "-clahe geometry contrast limited adaptive histogram equalization",
196  "-clamp keep pixel values in range (0-QuantumRange)",
197  "-colorize value colorize the image with the fill color",
198  "-color-matrix matrix apply color correction to the image",
199  "-connected-components connectivity",
200  " connected-components uniquely labeled",
201  "-contrast enhance or reduce the image contrast",
202  "-contrast-stretch geometry",
203  " improve contrast by 'stretching' the intensity range",
204  "-convolve coefficients",
205  " apply a convolution kernel to the image",
206  "-cycle amount cycle the image colormap",
207  "-decipher filename convert cipher pixels to plain pixels",
208  "-deskew threshold straighten an image",
209  "-despeckle reduce the speckles within an image",
210  "-distort method args",
211  " distort images according to given method ad args",
212  "-draw string annotate the image with a graphic primitive",
213  "-edge radius apply a filter to detect edges in the image",
214  "-encipher filename convert plain pixels to cipher pixels",
215  "-emboss radius emboss an image",
216  "-enhance apply a digital filter to enhance a noisy image",
217  "-equalize perform histogram equalization to an image",
218  "-evaluate operator value",
219  " evaluate an arithmetic, relational, or logical expression",
220  "-extent geometry set the image size",
221  "-extract geometry extract area from image",
222  "-fft implements the discrete Fourier transform (DFT)",
223  "-flip flip image vertically",
224  "-floodfill geometry color",
225  " floodfill the image with color",
226  "-flop flop image horizontally",
227  "-frame geometry surround image with an ornamental border",
228  "-function name parameters",
229  " apply function over image values",
230  "-gamma value level of gamma correction",
231  "-gaussian-blur geometry",
232  " reduce image noise and reduce detail levels",
233  "-geometry geometry preferred size or location of the image",
234  "-grayscale method convert image to grayscale",
235  "-hough-lines geometry",
236  " identify lines in the image",
237  "-identify identify the format and characteristics of the image",
238  "-ift implements the inverse discrete Fourier transform (DFT)",
239  "-implode amount implode image pixels about the center",
240  "-kuwahara geometry edge preserving noise reduction filter",
241  "-lat geometry local adaptive thresholding",
242  "-level value adjust the level of image contrast",
243  "-level-colors color,color",
244  " level image with the given colors",
245  "-linear-stretch geometry",
246  " improve contrast by 'stretching with saturation'",
247  "-liquid-rescale geometry",
248  " rescale image with seam-carving",
249  "-local-contrast geometry",
250  " enhance local contrast",
251  "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
252  "-median geometry apply a median filter to the image",
253  "-mode geometry make each pixel the 'predominant color' of the",
254  " neighborhood",
255  "-modulate value vary the brightness, saturation, and hue",
256  "-monochrome transform image to black and white",
257  "-morphology method kernel",
258  " apply a morphology method to the image",
259  "-motion-blur geometry",
260  " simulate motion blur",
261  "-negate replace every pixel with its complementary color ",
262  "-noise geometry add or reduce noise in an image",
263  "-normalize transform image to span the full range of colors",
264  "-opaque color change this color to the fill color",
265  "-ordered-dither NxN",
266  " add a noise pattern to the image with specific",
267  " amplitudes",
268  "-paint radius simulate an oil painting",
269  "-perceptible epsilon",
270  " pixel value less than |epsilon| become epsilon or",
271  " -epsilon",
272  "-polaroid angle simulate a Polaroid picture",
273  "-posterize levels reduce the image to a limited number of color levels",
274  "-profile filename add, delete, or apply an image profile",
275  "-quantize colorspace reduce colors in this colorspace",
276  "-raise value lighten/darken image edges to create a 3-D effect",
277  "-random-threshold low,high",
278  " random threshold the image",
279  "-range-threshold values",
280  " perform either hard or soft thresholding within some range of values in an image",
281  "-region geometry apply options to a portion of the image",
282  "-render render vector graphics",
283  "-resample geometry change the resolution of an image",
284  "-resize geometry resize the image",
285  "-roll geometry roll an image vertically or horizontally",
286  "-rotate degrees apply Paeth rotation to the image",
287  "-rotational-blur angle",
288  " rotational blur the image",
289  "-sample geometry scale image with pixel sampling",
290  "-scale geometry scale the image",
291  "-segment values segment an image",
292  "-selective-blur geometry",
293  " selectively blur pixels within a contrast threshold",
294  "-sepia-tone threshold",
295  " simulate a sepia-toned photo",
296  "-set property value set an image property",
297  "-shade degrees shade the image using a distant light source",
298  "-shadow geometry simulate an image shadow",
299  "-sharpen geometry sharpen the image",
300  "-shave geometry shave pixels from the image edges",
301  "-shear geometry slide one edge of the image along the X or Y axis",
302  "-sigmoidal-contrast geometry",
303  " increase the contrast without saturating highlights or",
304  " shadows",
305  "-sketch geometry simulate a pencil sketch",
306  "-solarize threshold negate all pixels above the threshold level",
307  "-sparse-color method args",
308  " fill in a image based on a few color points",
309  "-splice geometry splice the background color into the image",
310  "-spread radius displace image pixels by a random amount",
311  "-statistic type geometry",
312  " replace each pixel with corresponding statistic from the",
313  " neighborhood",
314  "-strip strip image of all profiles and comments",
315  "-swirl degrees swirl image pixels about the center",
316  "-threshold value threshold the image",
317  "-thumbnail geometry create a thumbnail of the image",
318  "-tile filename tile image when filling a graphic primitive",
319  "-tint value tint the image with the fill color",
320  "-transform affine transform image",
321  "-transparent color make this color transparent within the image",
322  "-transpose flip image vertically and rotate 90 degrees",
323  "-transverse flop image horizontally and rotate 270 degrees",
324  "-trim trim image edges",
325  "-type type image type",
326  "-unique-colors discard all but one of any pixel color",
327  "-unsharp geometry sharpen the image",
328  "-vignette geometry soften the edges of the image in vignette style",
329  "-wave geometry alter an image along a sine wave",
330  "-wavelet-denoise threshold",
331  " removes noise from the image using a wavelet transform",
332  "-white-threshold value",
333  " force all pixels above the threshold into white",
334  (char *) NULL
335  },
336  *sequence_operators[]=
337  {
338  "-append append an image sequence",
339  "-clut apply a color lookup table to the image",
340  "-coalesce merge a sequence of images",
341  "-combine combine a sequence of images",
342  "-compare mathematically and visually annotate the difference between an image and its reconstruction",
343  "-complex operator perform complex mathematics on an image sequence",
344  "-composite composite image",
345  "-copy geometry offset",
346  " copy pixels from one area of an image to another",
347  "-crop geometry cut out a rectangular region of the image",
348  "-deconstruct break down an image sequence into constituent parts",
349  "-evaluate-sequence operator",
350  " evaluate an arithmetic, relational, or logical expression",
351  "-flatten flatten a sequence of images",
352  "-fx expression apply mathematical expression to an image channel(s)",
353  "-hald-clut apply a Hald color lookup table to the image",
354  "-layers method optimize, merge, or compare image layers",
355  "-morph value morph an image sequence",
356  "-mosaic create a mosaic from an image sequence",
357  "-poly terms build a polynomial from the image sequence and the corresponding",
358  " terms (coefficients and degree pairs).",
359  "-print string interpret string and print to console",
360  "-process arguments process the image with a custom image filter",
361  "-smush geometry smush an image sequence together",
362  "-write filename write images to this file",
363  (char *) NULL
364  },
365  *settings[]=
366  {
367  "-adjoin join images into a single multi-image file",
368  "-affine matrix affine transform matrix",
369  "-alpha option activate, deactivate, reset, or set the alpha channel",
370  "-antialias remove pixel-aliasing",
371  "-authenticate password",
372  " decipher image with this password",
373  "-attenuate value lessen (or intensify) when adding noise to an image",
374  "-background color background color",
375  "-bias value add bias when convolving an image",
376  "-black-point-compensation",
377  " use black point compensation",
378  "-blue-primary point chromaticity blue primary point",
379  "-bordercolor color border color",
380  "-caption string assign a caption to an image",
381  "-clip clip along the first path from the 8BIM profile",
382  "-clip-mask filename associate a clip mask with the image",
383  "-clip-path id clip along a named path from the 8BIM profile",
384  "-colors value preferred number of colors in the image",
385  "-colorspace type alternate image colorspace",
386  "-comment string annotate image with comment",
387  "-compose operator set image composite operator",
388  "-compress type type of pixel compression when writing the image",
389  "-define format:option",
390  " define one or more image format options",
391  "-delay value display the next image after pausing",
392  "-density geometry horizontal and vertical density of the image",
393  "-depth value image depth",
394  "-direction type render text right-to-left or left-to-right",
395  "-display server get image or font from this X server",
396  "-dispose method layer disposal method",
397  "-dither method apply error diffusion to image",
398  "-encoding type text encoding type",
399  "-endian type endianness (MSB or LSB) of the image",
400  "-family name render text with this font family",
401  "-features distance analyze image features (e.g. contrast, correlation)",
402  "-fill color color to use when filling a graphic primitive",
403  "-filter type use this filter when resizing an image",
404  "-font name render text with this font",
405  "-format \"string\" output formatted image characteristics",
406  "-fuzz distance colors within this distance are considered equal",
407  "-gravity type horizontal and vertical text placement",
408  "-green-primary point chromaticity green primary point",
409  "-intensity method method to generate an intensity value from a pixel",
410  "-intent type type of rendering intent when managing the image color",
411  "-interlace type type of image interlacing scheme",
412  "-interline-spacing value",
413  " set the space between two text lines",
414  "-interpolate method pixel color interpolation method",
415  "-interword-spacing value",
416  " set the space between two words",
417  "-kerning value set the space between two letters",
418  "-label string assign a label to an image",
419  "-limit type value pixel cache resource limit",
420  "-loop iterations add Netscape loop extension to your GIF animation",
421  "-matte store matte channel if the image has one",
422  "-mattecolor color frame color",
423  "-moments report image moments",
424  "-monitor monitor progress",
425  "-orient type image orientation",
426  "-page geometry size and location of an image canvas (setting)",
427  "-ping efficiently determine image attributes",
428  "-pointsize value font point size",
429  "-precision value maximum number of significant digits to print",
430  "-preview type image preview type",
431  "-quality value JPEG/MIFF/PNG compression level",
432  "-quiet suppress all warning messages",
433  "-read-mask filename associate a read mask with the image",
434  "-red-primary point chromaticity red primary point",
435  "-regard-warnings pay attention to warning messages",
436  "-remap filename transform image colors to match this set of colors",
437  "-repage geometry size and location of an image canvas",
438  "-respect-parentheses settings remain in effect until parenthesis boundary",
439  "-sampling-factor geometry",
440  " horizontal and vertical sampling factor",
441  "-scene value image scene number",
442  "-seed value seed a new sequence of pseudo-random numbers",
443  "-size geometry width and height of image",
444  "-stretch type render text with this font stretch",
445  "-stroke color graphic primitive stroke color",
446  "-strokewidth value graphic primitive stroke width",
447  "-style type render text with this font style",
448  "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp",
449  "-synchronize synchronize image to storage device",
450  "-taint declare the image as modified",
451  "-texture filename name of texture to tile onto the image background",
452  "-tile-offset geometry",
453  " tile offset",
454  "-treedepth value color tree depth",
455  "-transparent-color color",
456  " transparent color",
457  "-undercolor color annotation bounding box color",
458  "-units type the units of image resolution",
459  "-verbose print detailed information about the image",
460  "-view FlashPix viewing transforms",
461  "-virtual-pixel method",
462  " virtual pixel access method",
463  "-weight type render text with this font weight",
464  "-white-point point chromaticity white point",
465  "-write-mask filename associate a write mask with the image",
466  (char *) NULL
467  },
468  *stack_operators[]=
469  {
470  "-clone indexes clone an image",
471  "-delete indexes delete the image from the image sequence",
472  "-duplicate count,indexes",
473  " duplicate an image one or more times",
474  "-insert index insert last image into the image sequence",
475  "-reverse reverse image sequence",
476  "-swap indexes swap two images in the image sequence",
477  (char *) NULL
478  };
479 
480  const char
481  **p;
482 
483  ListMagickVersion(stdout);
484  (void) printf("Usage: %s [options ...] file [ [options ...] "
485  "file ...] [options ...] file\n",GetClientName());
486  (void) printf("\nImage Settings:\n");
487  for (p=settings; *p != (char *) NULL; p++)
488  (void) printf(" %s\n",*p);
489  (void) printf("\nImage Operators:\n");
490  for (p=operators; *p != (char *) NULL; p++)
491  (void) printf(" %s\n",*p);
492  (void) printf("\nImage Channel Operators:\n");
493  for (p=channel_operators; *p != (char *) NULL; p++)
494  (void) printf(" %s\n",*p);
495  (void) printf("\nImage Sequence Operators:\n");
496  for (p=sequence_operators; *p != (char *) NULL; p++)
497  (void) printf(" %s\n",*p);
498  (void) printf("\nImage Stack Operators:\n");
499  for (p=stack_operators; *p != (char *) NULL; p++)
500  (void) printf(" %s\n",*p);
501  (void) printf("\nMiscellaneous Options:\n");
502  for (p=miscellaneous; *p != (char *) NULL; p++)
503  (void) printf(" %s\n",*p);
504  (void) printf(
505  "\nBy default, the image format of 'file' is determined by its magic\n");
506  (void) printf(
507  "number. To specify a particular image format, precede the filename\n");
508  (void) printf(
509  "with an image format name and a colon (i.e. ps:image) or specify the\n");
510  (void) printf(
511  "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
512  (void) printf("'-' for standard input or output.\n");
513  return(MagickFalse);
514 }
515 
516 WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
517  int argc,char **argv,char **metadata,ExceptionInfo *exception)
518 {
519 #define NotInitialized (unsigned int) (~0)
520 #define DestroyConvert() \
521 { \
522  DestroyImageStack(); \
523  for (i=0; i < (ssize_t) argc; i++) \
524  argv[i]=DestroyString(argv[i]); \
525  argv=(char **) RelinquishMagickMemory(argv); \
526 }
527 #define ThrowConvertException(asperity,tag,option) \
528 { \
529  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
530  option); \
531  DestroyConvert(); \
532  return(MagickFalse); \
533 }
534 #define ThrowConvertInvalidArgumentException(option,argument) \
535 { \
536  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
537  "InvalidArgument","'%s': %s",option,argument); \
538  DestroyConvert(); \
539  return(MagickFalse); \
540 }
541 
542  char
543  *filename,
544  *option;
545 
546  const char
547  *format;
548 
549  Image
550  *image;
551 
552  ImageStack
553  image_stack[MaxImageStackDepth+1];
554 
555  MagickBooleanType
556  fire,
557  pend,
558  respect_parenthesis;
559 
560  MagickStatusType
561  status;
562 
563  register ssize_t
564  i;
565 
566  ssize_t
567  j,
568  k;
569 
570  /*
571  Set defaults.
572  */
573  assert(image_info != (ImageInfo *) NULL);
574  assert(image_info->signature == MagickCoreSignature);
575  if (image_info->debug != MagickFalse)
576  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
577  assert(exception != (ExceptionInfo *) NULL);
578  if (argc == 2)
579  {
580  option=argv[1];
581  if ((LocaleCompare("version",option+1) == 0) ||
582  (LocaleCompare("-version",option+1) == 0))
583  {
584  ListMagickVersion(stdout);
585  return(MagickTrue);
586  }
587  }
588  if (argc < 3)
589  return(ConvertUsage());
590  filename=(char *) NULL;
591  format="%w,%h,%m";
592  j=1;
593  k=0;
594  NewImageStack();
595  option=(char *) NULL;
596  pend=MagickFalse;
597  respect_parenthesis=MagickFalse;
598  status=MagickTrue;
599  /*
600  Parse command-line arguments.
601  */
602  ReadCommandlLine(argc,&argv);
603  status=ExpandFilenames(&argc,&argv);
604  if (status == MagickFalse)
605  ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
606  GetExceptionMessage(errno));
607  if ((argc > 2) && (LocaleCompare("-concatenate",argv[1]) == 0))
608  return(ConcatenateImages(argc,argv,exception));
609  for (i=1; i < (ssize_t) (argc-1); i++)
610  {
611  option=argv[i];
612  if (LocaleCompare(option,"(") == 0)
613  {
614  FireImageStack(MagickTrue,MagickTrue,pend);
615  if (k == MaxImageStackDepth)
616  ThrowConvertException(OptionError,"ParenthesisNestedTooDeeply",
617  option);
618  PushImageStack();
619  continue;
620  }
621  if (LocaleCompare(option,")") == 0)
622  {
623  FireImageStack(MagickTrue,MagickTrue,MagickTrue);
624  if (k == 0)
625  ThrowConvertException(OptionError,"UnableToParseExpression",option);
626  PopImageStack();
627  continue;
628  }
629  if (IsCommandOption(option) == MagickFalse)
630  {
631  Image
632  *images;
633 
634  /*
635  Read input image.
636  */
637  FireImageStack(MagickTrue,MagickTrue,pend);
638  filename=argv[i];
639  if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
640  filename=argv[++i];
641  if (image_info->ping != MagickFalse)
642  images=PingImages(image_info,filename,exception);
643  else
644  images=ReadImages(image_info,filename,exception);
645  status&=(images != (Image *) NULL) &&
646  (exception->severity < ErrorException);
647  if (images == (Image *) NULL)
648  continue;
649  AppendImageStack(images);
650  continue;
651  }
652  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
653  switch (*(option+1))
654  {
655  case 'a':
656  {
657  if (LocaleCompare("adaptive-blur",option+1) == 0)
658  {
659  i++;
660  if (i == (ssize_t) argc)
661  ThrowConvertException(OptionError,"MissingArgument",option);
662  if (IsGeometry(argv[i]) == MagickFalse)
663  ThrowConvertInvalidArgumentException(option,argv[i]);
664  break;
665  }
666  if (LocaleCompare("adaptive-resize",option+1) == 0)
667  {
668  i++;
669  if (i == (ssize_t) argc)
670  ThrowConvertException(OptionError,"MissingArgument",option);
671  if (IsGeometry(argv[i]) == MagickFalse)
672  ThrowConvertInvalidArgumentException(option,argv[i]);
673  break;
674  }
675  if (LocaleCompare("adaptive-sharpen",option+1) == 0)
676  {
677  i++;
678  if (i == (ssize_t) argc)
679  ThrowConvertException(OptionError,"MissingArgument",option);
680  if (IsGeometry(argv[i]) == MagickFalse)
681  ThrowConvertInvalidArgumentException(option,argv[i]);
682  break;
683  }
684  if (LocaleCompare("adjoin",option+1) == 0)
685  break;
686  if (LocaleCompare("affine",option+1) == 0)
687  {
688  if (*option == '+')
689  break;
690  i++;
691  if (i == (ssize_t) argc)
692  ThrowConvertException(OptionError,"MissingArgument",option);
693  if (IsGeometry(argv[i]) == MagickFalse)
694  ThrowConvertInvalidArgumentException(option,argv[i]);
695  break;
696  }
697  if (LocaleCompare("alpha",option+1) == 0)
698  {
699  ssize_t
700  type;
701 
702  if (*option == '+')
703  break;
704  i++;
705  if (i == (ssize_t) argc)
706  ThrowConvertException(OptionError,"MissingArgument",option);
707  type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
708  argv[i]);
709  if (type < 0)
710  ThrowConvertException(OptionError,
711  "UnrecognizedAlphaChannelOption",argv[i]);
712  break;
713  }
714  if (LocaleCompare("annotate",option+1) == 0)
715  {
716  if (*option == '+')
717  break;
718  i++;
719  if (i == (ssize_t) argc)
720  ThrowConvertException(OptionError,"MissingArgument",option);
721  if (IsGeometry(argv[i]) == MagickFalse)
722  ThrowConvertInvalidArgumentException(option,argv[i]);
723  i++;
724  if (i == (ssize_t) argc)
725  ThrowConvertException(OptionError,"MissingArgument",option);
726  break;
727  }
728  if (LocaleCompare("antialias",option+1) == 0)
729  break;
730  if (LocaleCompare("append",option+1) == 0)
731  break;
732  if (LocaleCompare("attenuate",option+1) == 0)
733  {
734  if (*option == '+')
735  break;
736  i++;
737  if (i == (ssize_t) argc)
738  ThrowConvertException(OptionError,"MissingArgument",option);
739  if (IsGeometry(argv[i]) == MagickFalse)
740  ThrowConvertInvalidArgumentException(option,argv[i]);
741  break;
742  }
743  if (LocaleCompare("authenticate",option+1) == 0)
744  {
745  if (*option == '+')
746  break;
747  i++;
748  if (i == (ssize_t) argc)
749  ThrowConvertException(OptionError,"MissingArgument",option);
750  break;
751  }
752  if (LocaleCompare("auto-gamma",option+1) == 0)
753  break;
754  if (LocaleCompare("auto-level",option+1) == 0)
755  break;
756  if (LocaleCompare("auto-orient",option+1) == 0)
757  break;
758  if (LocaleCompare("auto-threshold",option+1) == 0)
759  {
760  ssize_t
761  method;
762 
763  if (*option == '+')
764  break;
765  i++;
766  if (i == (ssize_t) argc)
767  ThrowConvertException(OptionError,"MissingArgument",option);
768  method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
769  argv[i]);
770  if (method < 0)
771  ThrowConvertException(OptionError,"UnrecognizedThresholdMethod",
772  argv[i]);
773  break;
774  }
775  if (LocaleCompare("average",option+1) == 0)
776  break;
777  ThrowConvertException(OptionError,"UnrecognizedOption",option)
778  }
779  case 'b':
780  {
781  if (LocaleCompare("background",option+1) == 0)
782  {
783  if (*option == '+')
784  break;
785  i++;
786  if (i == (ssize_t) argc)
787  ThrowConvertException(OptionError,"MissingArgument",option);
788  break;
789  }
790  if (LocaleCompare("bench",option+1) == 0)
791  {
792  if (*option == '+')
793  break;
794  i++;
795  if (i == (ssize_t) argc)
796  ThrowConvertException(OptionError,"MissingArgument",option);
797  if (IsGeometry(argv[i]) == MagickFalse)
798  ThrowConvertInvalidArgumentException(option,argv[i]);
799  break;
800  }
801  if (LocaleCompare("bias",option+1) == 0)
802  {
803  if (*option == '+')
804  break;
805  i++;
806  if (i == (ssize_t) argc)
807  ThrowConvertException(OptionError,"MissingArgument",option);
808  if (IsGeometry(argv[i]) == MagickFalse)
809  ThrowConvertInvalidArgumentException(option,argv[i]);
810  break;
811  }
812  if (LocaleCompare("black-point-compensation",option+1) == 0)
813  break;
814  if (LocaleCompare("black-threshold",option+1) == 0)
815  {
816  if (*option == '+')
817  break;
818  i++;
819  if (i == (ssize_t) argc)
820  ThrowConvertException(OptionError,"MissingArgument",option);
821  if (IsGeometry(argv[i]) == MagickFalse)
822  ThrowConvertInvalidArgumentException(option,argv[i]);
823  break;
824  }
825  if (LocaleCompare("blue-primary",option+1) == 0)
826  {
827  if (*option == '+')
828  break;
829  i++;
830  if (i == (ssize_t) argc)
831  ThrowConvertException(OptionError,"MissingArgument",option);
832  if (IsGeometry(argv[i]) == MagickFalse)
833  ThrowConvertInvalidArgumentException(option,argv[i]);
834  break;
835  }
836  if (LocaleCompare("blue-shift",option+1) == 0)
837  {
838  if (*option == '+')
839  break;
840  i++;
841  if (i == (ssize_t) argc)
842  ThrowConvertException(OptionError,"MissingArgument",option);
843  if (IsGeometry(argv[i]) == MagickFalse)
844  ThrowConvertInvalidArgumentException(option,argv[i]);
845  break;
846  }
847  if (LocaleCompare("blur",option+1) == 0)
848  {
849  if (*option == '+')
850  break;
851  i++;
852  if (i == (ssize_t) argc)
853  ThrowConvertException(OptionError,"MissingArgument",option);
854  if (IsGeometry(argv[i]) == MagickFalse)
855  ThrowConvertInvalidArgumentException(option,argv[i]);
856  break;
857  }
858  if (LocaleCompare("border",option+1) == 0)
859  {
860  if (*option == '+')
861  break;
862  i++;
863  if (i == (ssize_t) argc)
864  ThrowConvertException(OptionError,"MissingArgument",option);
865  if (IsGeometry(argv[i]) == MagickFalse)
866  ThrowConvertInvalidArgumentException(option,argv[i]);
867  break;
868  }
869  if (LocaleCompare("bordercolor",option+1) == 0)
870  {
871  if (*option == '+')
872  break;
873  i++;
874  if (i == (ssize_t) argc)
875  ThrowConvertException(OptionError,"MissingArgument",option);
876  break;
877  }
878  if (LocaleCompare("box",option+1) == 0)
879  {
880  if (*option == '+')
881  break;
882  i++;
883  if (i == (ssize_t) argc)
884  ThrowConvertException(OptionError,"MissingArgument",option);
885  break;
886  }
887  if (LocaleCompare("brightness-contrast",option+1) == 0)
888  {
889  i++;
890  if (i == (ssize_t) argc)
891  ThrowConvertException(OptionError,"MissingArgument",option);
892  if (IsGeometry(argv[i]) == MagickFalse)
893  ThrowConvertInvalidArgumentException(option,argv[i]);
894  break;
895  }
896  ThrowConvertException(OptionError,"UnrecognizedOption",option)
897  }
898  case 'c':
899  {
900  if (LocaleCompare("cache",option+1) == 0)
901  {
902  if (*option == '+')
903  break;
904  i++;
905  if (i == (ssize_t) argc)
906  ThrowConvertException(OptionError,"MissingArgument",option);
907  if (IsGeometry(argv[i]) == MagickFalse)
908  ThrowConvertInvalidArgumentException(option,argv[i]);
909  break;
910  }
911  if (LocaleCompare("canny",option+1) == 0)
912  {
913  if (*option == '+')
914  break;
915  i++;
916  if (i == (ssize_t) argc)
917  ThrowConvertException(OptionError,"MissingArgument",option);
918  if (IsGeometry(argv[i]) == MagickFalse)
919  ThrowConvertInvalidArgumentException(option,argv[i]);
920  break;
921  }
922  if (LocaleCompare("caption",option+1) == 0)
923  {
924  if (*option == '+')
925  break;
926  i++;
927  if (i == (ssize_t) argc)
928  ThrowConvertException(OptionError,"MissingArgument",option);
929  break;
930  }
931  if (LocaleCompare("cdl",option+1) == 0)
932  {
933  if (*option == '+')
934  break;
935  i++;
936  if (i == (ssize_t) argc)
937  ThrowConvertException(OptionError,"MissingArgument",option);
938  break;
939  }
940  if (LocaleCompare("channel",option+1) == 0)
941  {
942  ssize_t
943  channel;
944 
945  if (*option == '+')
946  break;
947  i++;
948  if (i == (ssize_t) argc)
949  ThrowConvertException(OptionError,"MissingArgument",option);
950  channel=ParseChannelOption(argv[i]);
951  if (channel < 0)
952  ThrowConvertException(OptionError,"UnrecognizedChannelType",
953  argv[i]);
954  break;
955  }
956  if (LocaleCompare("channel-fx",option+1) == 0)
957  {
958  ssize_t
959  channel;
960 
961  if (*option == '+')
962  break;
963  i++;
964  if (i == (ssize_t) argc)
965  ThrowConvertException(OptionError,"MissingArgument",option);
966  channel=ParsePixelChannelOption(argv[i]);
967  if (channel < 0)
968  ThrowConvertException(OptionError,"UnrecognizedChannelType",
969  argv[i]);
970  break;
971  }
972  if (LocaleCompare("charcoal",option+1) == 0)
973  {
974  if (*option == '+')
975  break;
976  i++;
977  if (i == (ssize_t) argc)
978  ThrowConvertException(OptionError,"MissingArgument",option);
979  if (IsGeometry(argv[i]) == MagickFalse)
980  ThrowConvertInvalidArgumentException(option,argv[i]);
981  break;
982  }
983  if (LocaleCompare("chop",option+1) == 0)
984  {
985  if (*option == '+')
986  break;
987  i++;
988  if (i == (ssize_t) argc)
989  ThrowConvertException(OptionError,"MissingArgument",option);
990  if (IsGeometry(argv[i]) == MagickFalse)
991  ThrowConvertInvalidArgumentException(option,argv[i]);
992  break;
993  }
994  if (LocaleCompare("clahe",option+1) == 0)
995  {
996  if (*option == '+')
997  break;
998  i++;
999  if (i == (ssize_t) argc)
1000  ThrowConvertException(OptionError,"MissingArgument",option);
1001  if (IsGeometry(argv[i]) == MagickFalse)
1002  ThrowConvertInvalidArgumentException(option,argv[i]);
1003  break;
1004  }
1005  if (LocaleCompare("clamp",option+1) == 0)
1006  break;
1007  if (LocaleCompare("clip",option+1) == 0)
1008  break;
1009  if (LocaleCompare("clip-mask",option+1) == 0)
1010  {
1011  if (*option == '+')
1012  break;
1013  i++;
1014  if (i == (ssize_t) argc)
1015  ThrowConvertException(OptionError,"MissingArgument",option);
1016  break;
1017  }
1018  if (LocaleCompare("clip-path",option+1) == 0)
1019  {
1020  i++;
1021  if (i == (ssize_t) argc)
1022  ThrowConvertException(OptionError,"MissingArgument",option);
1023  break;
1024  }
1025  if (LocaleCompare("clone",option+1) == 0)
1026  {
1027  Image
1028  *clone_images,
1029  *clone_list;
1030 
1031  clone_list=CloneImageList(image,exception);
1032  if (k != 0)
1033  clone_list=CloneImageList(image_stack[k-1].image,exception);
1034  if (clone_list == (Image *) NULL)
1035  ThrowConvertException(ImageError,"ImageSequenceRequired",option);
1036  FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1037  if (*option == '+')
1038  clone_images=CloneImages(clone_list,"-1",exception);
1039  else
1040  {
1041  i++;
1042  if (i == (ssize_t) argc)
1043  ThrowConvertException(OptionError,"MissingArgument",option);
1044  if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1045  ThrowConvertInvalidArgumentException(option,argv[i]);
1046  clone_images=CloneImages(clone_list,argv[i],exception);
1047  }
1048  if (clone_images == (Image *) NULL)
1049  ThrowConvertException(OptionError,"NoSuchImage",option);
1050  AppendImageStack(clone_images);
1051  clone_list=DestroyImageList(clone_list);
1052  break;
1053  }
1054  if (LocaleCompare("clut",option+1) == 0)
1055  break;
1056  if (LocaleCompare("coalesce",option+1) == 0)
1057  break;
1058  if (LocaleCompare("colorize",option+1) == 0)
1059  {
1060  if (*option == '+')
1061  break;
1062  i++;
1063  if (i == (ssize_t) argc)
1064  ThrowConvertException(OptionError,"MissingArgument",option);
1065  if (IsGeometry(argv[i]) == MagickFalse)
1066  ThrowConvertInvalidArgumentException(option,argv[i]);
1067  break;
1068  }
1069  if (LocaleCompare("color-matrix",option+1) == 0)
1070  {
1071  KernelInfo
1072  *kernel_info;
1073 
1074  if (*option == '+')
1075  break;
1076  i++;
1077  if (i == (ssize_t) argc)
1078  ThrowConvertException(OptionError,"MissingArgument",option);
1079  kernel_info=AcquireKernelInfo(argv[i],exception);
1080  if (kernel_info == (KernelInfo *) NULL)
1081  ThrowConvertInvalidArgumentException(option,argv[i]);
1082  kernel_info=DestroyKernelInfo(kernel_info);
1083  break;
1084  }
1085  if (LocaleCompare("colors",option+1) == 0)
1086  {
1087  if (*option == '+')
1088  break;
1089  i++;
1090  if ((i == (ssize_t) argc) ||
1091  (IsGeometry(argv[i]) == MagickFalse))
1092  ThrowConvertException(OptionError,"MissingArgument",option);
1093  break;
1094  }
1095  if (LocaleCompare("colorspace",option+1) == 0)
1096  {
1097  ssize_t
1098  colorspace;
1099 
1100  if (*option == '+')
1101  break;
1102  i++;
1103  if (i == (ssize_t) argc)
1104  ThrowConvertException(OptionError,"MissingArgument",option);
1105  colorspace=ParseCommandOption(MagickColorspaceOptions,
1106  MagickFalse,argv[i]);
1107  if (colorspace < 0)
1108  ThrowConvertException(OptionError,"UnrecognizedColorspace",
1109  argv[i]);
1110  break;
1111  }
1112  if (LocaleCompare("combine",option+1) == 0)
1113  break;
1114  if (LocaleCompare("comment",option+1) == 0)
1115  {
1116  if (*option == '+')
1117  break;
1118  i++;
1119  if (i == (ssize_t) argc)
1120  ThrowConvertException(OptionError,"MissingArgument",option);
1121  break;
1122  }
1123  if (LocaleCompare("compare",option+1) == 0)
1124  break;
1125  if (LocaleCompare("complex",option+1) == 0)
1126  {
1127  ssize_t
1128  op;
1129 
1130  if (*option == '+')
1131  break;
1132  i++;
1133  if (i == (ssize_t) argc)
1134  ThrowConvertException(OptionError,"MissingArgument",option);
1135  op=ParseCommandOption(MagickComplexOptions,MagickFalse,argv[i]);
1136  if (op < 0)
1137  ThrowConvertException(OptionError,"UnrecognizedComplexOperator",
1138  argv[i]);
1139  break;
1140  }
1141  if (LocaleCompare("compose",option+1) == 0)
1142  {
1143  ssize_t
1144  compose;
1145 
1146  if (*option == '+')
1147  break;
1148  i++;
1149  if (i == (ssize_t) argc)
1150  ThrowConvertException(OptionError,"MissingArgument",option);
1151  compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
1152  argv[i]);
1153  if (compose < 0)
1154  ThrowConvertException(OptionError,"UnrecognizedComposeOperator",
1155  argv[i]);
1156  break;
1157  }
1158  if (LocaleCompare("composite",option+1) == 0)
1159  break;
1160  if (LocaleCompare("compress",option+1) == 0)
1161  {
1162  ssize_t
1163  compress;
1164 
1165  if (*option == '+')
1166  break;
1167  i++;
1168  if (i == (ssize_t) argc)
1169  ThrowConvertException(OptionError,"MissingArgument",option);
1170  compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
1171  argv[i]);
1172  if (compress < 0)
1173  ThrowConvertException(OptionError,"UnrecognizedImageCompression",
1174  argv[i]);
1175  break;
1176  }
1177  if (LocaleCompare("concurrent",option+1) == 0)
1178  break;
1179  if (LocaleCompare("connected-components",option+1) == 0)
1180  {
1181  i++;
1182  if (i == (ssize_t) argc)
1183  ThrowConvertException(OptionError,"MissingArgument",option);
1184  if (IsGeometry(argv[i]) == MagickFalse)
1185  ThrowConvertInvalidArgumentException(option,argv[i]);
1186  break;
1187  }
1188  if (LocaleCompare("contrast",option+1) == 0)
1189  break;
1190  if (LocaleCompare("contrast-stretch",option+1) == 0)
1191  {
1192  i++;
1193  if (i == (ssize_t) argc)
1194  ThrowConvertException(OptionError,"MissingArgument",option);
1195  if (IsGeometry(argv[i]) == MagickFalse)
1196  ThrowConvertInvalidArgumentException(option,argv[i]);
1197  break;
1198  }
1199  if (LocaleCompare("convolve",option+1) == 0)
1200  {
1201  KernelInfo
1202  *kernel_info;
1203 
1204  if (*option == '+')
1205  break;
1206  i++;
1207  if (i == (ssize_t) argc)
1208  ThrowConvertException(OptionError,"MissingArgument",option);
1209  kernel_info=AcquireKernelInfo(argv[i],exception);
1210  if (kernel_info == (KernelInfo *) NULL)
1211  ThrowConvertInvalidArgumentException(option,argv[i]);
1212  kernel_info=DestroyKernelInfo(kernel_info);
1213  break;
1214  }
1215  if (LocaleCompare("copy",option+1) == 0)
1216  {
1217  if (*option == '+')
1218  break;
1219  i++;
1220  if (i == (ssize_t) argc)
1221  ThrowConvertException(OptionError,"MissingArgument",option);
1222  if (IsGeometry(argv[i]) == MagickFalse)
1223  ThrowConvertInvalidArgumentException(option,argv[i]);
1224  i++;
1225  if (i == (ssize_t) argc)
1226  ThrowConvertException(OptionError,"MissingArgument",option);
1227  if (IsGeometry(argv[i]) == MagickFalse)
1228  ThrowConvertInvalidArgumentException(option,argv[i]);
1229  break;
1230  }
1231  if (LocaleCompare("crop",option+1) == 0)
1232  {
1233  if (*option == '+')
1234  break;
1235  i++;
1236  if (i == (ssize_t) argc)
1237  ThrowConvertException(OptionError,"MissingArgument",option);
1238  if (IsGeometry(argv[i]) == MagickFalse)
1239  ThrowConvertInvalidArgumentException(option,argv[i]);
1240  break;
1241  }
1242  if (LocaleCompare("cycle",option+1) == 0)
1243  {
1244  if (*option == '+')
1245  break;
1246  i++;
1247  if (i == (ssize_t) argc)
1248  ThrowConvertException(OptionError,"MissingArgument",option);
1249  if (IsGeometry(argv[i]) == MagickFalse)
1250  ThrowConvertInvalidArgumentException(option,argv[i]);
1251  break;
1252  }
1253  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1254  }
1255  case 'd':
1256  {
1257  if (LocaleCompare("decipher",option+1) == 0)
1258  {
1259  if (*option == '+')
1260  break;
1261  i++;
1262  if (i == (ssize_t) argc)
1263  ThrowConvertException(OptionError,"MissingArgument",option);
1264  break;
1265  }
1266  if (LocaleCompare("deconstruct",option+1) == 0)
1267  break;
1268  if (LocaleCompare("debug",option+1) == 0)
1269  {
1270  ssize_t
1271  event;
1272 
1273  if (*option == '+')
1274  break;
1275  i++;
1276  if (i == (ssize_t) argc)
1277  ThrowConvertException(OptionError,"MissingArgument",option);
1278  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
1279  if (event < 0)
1280  ThrowConvertException(OptionError,"UnrecognizedEventType",
1281  argv[i]);
1282  (void) SetLogEventMask(argv[i]);
1283  break;
1284  }
1285  if (LocaleCompare("define",option+1) == 0)
1286  {
1287  i++;
1288  if (i == (ssize_t) argc)
1289  ThrowConvertException(OptionError,"MissingArgument",option);
1290  if (*option == '+')
1291  {
1292  const char
1293  *define;
1294 
1295  define=GetImageOption(image_info,argv[i]);
1296  if (define == (const char *) NULL)
1297  ThrowConvertException(OptionError,"NoSuchOption",argv[i]);
1298  break;
1299  }
1300  break;
1301  }
1302  if (LocaleCompare("delay",option+1) == 0)
1303  {
1304  if (*option == '+')
1305  break;
1306  i++;
1307  if (i == (ssize_t) argc)
1308  ThrowConvertException(OptionError,"MissingArgument",option);
1309  if (IsGeometry(argv[i]) == MagickFalse)
1310  ThrowConvertInvalidArgumentException(option,argv[i]);
1311  break;
1312  }
1313  if (LocaleCompare("density",option+1) == 0)
1314  {
1315  if (*option == '+')
1316  break;
1317  i++;
1318  if (i == (ssize_t) argc)
1319  ThrowConvertException(OptionError,"MissingArgument",option);
1320  if (IsGeometry(argv[i]) == MagickFalse)
1321  ThrowConvertInvalidArgumentException(option,argv[i]);
1322  break;
1323  }
1324  if (LocaleCompare("depth",option+1) == 0)
1325  {
1326  if (*option == '+')
1327  break;
1328  i++;
1329  if (i == (ssize_t) argc)
1330  ThrowConvertException(OptionError,"MissingArgument",option);
1331  if (IsGeometry(argv[i]) == MagickFalse)
1332  ThrowConvertInvalidArgumentException(option,argv[i]);
1333  break;
1334  }
1335  if (LocaleCompare("delete",option+1) == 0)
1336  {
1337  if (*option == '+')
1338  break;
1339  i++;
1340  if (i == (ssize_t) argc)
1341  ThrowConvertException(OptionError,"MissingArgument",option);
1342  if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1343  ThrowConvertInvalidArgumentException(option,argv[i]);
1344  break;
1345  }
1346  if (LocaleCompare("deskew",option+1) == 0)
1347  {
1348  if (*option == '+')
1349  break;
1350  i++;
1351  if (i == (ssize_t) argc)
1352  ThrowConvertException(OptionError,"MissingArgument",option);
1353  if (IsGeometry(argv[i]) == MagickFalse)
1354  ThrowConvertInvalidArgumentException(option,argv[i]);
1355  break;
1356  }
1357  if (LocaleCompare("despeckle",option+1) == 0)
1358  break;
1359  if (LocaleCompare("direction",option+1) == 0)
1360  {
1361  ssize_t
1362  direction;
1363 
1364  if (*option == '+')
1365  break;
1366  i++;
1367  if (i == (ssize_t) argc)
1368  ThrowConvertException(OptionError,"MissingArgument",option);
1369  direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
1370  argv[i]);
1371  if (direction < 0)
1372  ThrowConvertException(OptionError,"UnrecognizedDirectionType",
1373  argv[i]);
1374  break;
1375  }
1376  if (LocaleCompare("display",option+1) == 0)
1377  {
1378  if (*option == '+')
1379  break;
1380  i++;
1381  if (i == (ssize_t) argc)
1382  ThrowConvertException(OptionError,"MissingArgument",option);
1383  break;
1384  }
1385  if (LocaleCompare("dispose",option+1) == 0)
1386  {
1387  ssize_t
1388  dispose;
1389 
1390  if (*option == '+')
1391  break;
1392  i++;
1393  if (i == (ssize_t) argc)
1394  ThrowConvertException(OptionError,"MissingArgument",option);
1395  dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
1396  if (dispose < 0)
1397  ThrowConvertException(OptionError,"UnrecognizedDisposeMethod",
1398  argv[i]);
1399  break;
1400  }
1401  if (LocaleCompare("distort",option+1) == 0)
1402  {
1403  ssize_t
1404  op;
1405 
1406  i++;
1407  if (i == (ssize_t) argc)
1408  ThrowConvertException(OptionError,"MissingArgument",option);
1409  op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
1410  if (op < 0)
1411  ThrowConvertException(OptionError,"UnrecognizedDistortMethod",
1412  argv[i]);
1413  i++;
1414  if (i == (ssize_t) argc)
1415  ThrowConvertException(OptionError,"MissingArgument",option);
1416  break;
1417  }
1418  if (LocaleCompare("dither",option+1) == 0)
1419  {
1420  ssize_t
1421  method;
1422 
1423  if (*option == '+')
1424  break;
1425  i++;
1426  if (i == (ssize_t) argc)
1427  ThrowConvertException(OptionError,"MissingArgument",option);
1428  method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
1429  if (method < 0)
1430  ThrowConvertException(OptionError,"UnrecognizedDitherMethod",
1431  argv[i]);
1432  break;
1433  }
1434  if (LocaleCompare("draw",option+1) == 0)
1435  {
1436  if (*option == '+')
1437  break;
1438  i++;
1439  if (i == (ssize_t) argc)
1440  ThrowConvertException(OptionError,"MissingArgument",option);
1441  break;
1442  }
1443  if (LocaleCompare("duplicate",option+1) == 0)
1444  {
1445  if (*option == '+')
1446  break;
1447  i++;
1448  if (i == (ssize_t) argc)
1449  ThrowConvertException(OptionError,"MissingArgument",option);
1450  if (IsGeometry(argv[i]) == MagickFalse)
1451  ThrowConvertInvalidArgumentException(option,argv[i]);
1452  break;
1453  }
1454  if (LocaleCompare("duration",option+1) == 0)
1455  {
1456  if (*option == '+')
1457  break;
1458  i++;
1459  if (i == (ssize_t) argc)
1460  ThrowConvertException(OptionError,"MissingArgument",option);
1461  if (IsGeometry(argv[i]) == MagickFalse)
1462  ThrowConvertInvalidArgumentException(option,argv[i]);
1463  break;
1464  }
1465  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1466  }
1467  case 'e':
1468  {
1469  if (LocaleCompare("edge",option+1) == 0)
1470  {
1471  if (*option == '+')
1472  break;
1473  i++;
1474  if (i == (ssize_t) argc)
1475  ThrowConvertException(OptionError,"MissingArgument",option);
1476  if (IsGeometry(argv[i]) == MagickFalse)
1477  ThrowConvertInvalidArgumentException(option,argv[i]);
1478  break;
1479  }
1480  if (LocaleCompare("emboss",option+1) == 0)
1481  {
1482  if (*option == '+')
1483  break;
1484  i++;
1485  if (i == (ssize_t) argc)
1486  ThrowConvertException(OptionError,"MissingArgument",option);
1487  if (IsGeometry(argv[i]) == MagickFalse)
1488  ThrowConvertInvalidArgumentException(option,argv[i]);
1489  break;
1490  }
1491  if (LocaleCompare("encipher",option+1) == 0)
1492  {
1493  if (*option == '+')
1494  break;
1495  i++;
1496  if (i == (ssize_t) argc)
1497  ThrowConvertException(OptionError,"MissingArgument",option);
1498  break;
1499  }
1500  if (LocaleCompare("encoding",option+1) == 0)
1501  {
1502  if (*option == '+')
1503  break;
1504  i++;
1505  if (i == (ssize_t) argc)
1506  ThrowConvertException(OptionError,"MissingArgument",option);
1507  break;
1508  }
1509  if (LocaleCompare("endian",option+1) == 0)
1510  {
1511  ssize_t
1512  endian;
1513 
1514  if (*option == '+')
1515  break;
1516  i++;
1517  if (i == (ssize_t) argc)
1518  ThrowConvertException(OptionError,"MissingArgument",option);
1519  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
1520  argv[i]);
1521  if (endian < 0)
1522  ThrowConvertException(OptionError,"UnrecognizedEndianType",
1523  argv[i]);
1524  break;
1525  }
1526  if (LocaleCompare("enhance",option+1) == 0)
1527  break;
1528  if (LocaleCompare("equalize",option+1) == 0)
1529  break;
1530  if (LocaleCompare("evaluate",option+1) == 0)
1531  {
1532  ssize_t
1533  op;
1534 
1535  if (*option == '+')
1536  break;
1537  i++;
1538  if (i == (ssize_t) argc)
1539  ThrowConvertException(OptionError,"MissingArgument",option);
1540  op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
1541  if (op < 0)
1542  ThrowConvertException(OptionError,"UnrecognizedEvaluateOperator",
1543  argv[i]);
1544  i++;
1545  if (i == (ssize_t) argc)
1546  ThrowConvertException(OptionError,"MissingArgument",option);
1547  if (IsGeometry(argv[i]) == MagickFalse)
1548  ThrowConvertInvalidArgumentException(option,argv[i]);
1549  break;
1550  }
1551  if (LocaleCompare("evaluate-sequence",option+1) == 0)
1552  {
1553  ssize_t
1554  op;
1555 
1556  if (*option == '+')
1557  break;
1558  i++;
1559  if (i == (ssize_t) argc)
1560  ThrowConvertException(OptionError,"MissingArgument",option);
1561  op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
1562  if (op < 0)
1563  ThrowConvertException(OptionError,"UnrecognizedEvaluateOperator",
1564  argv[i]);
1565  break;
1566  }
1567  if (LocaleCompare("extent",option+1) == 0)
1568  {
1569  if (*option == '+')
1570  break;
1571  i++;
1572  if (i == (ssize_t) argc)
1573  ThrowConvertException(OptionError,"MissingArgument",option);
1574  if (IsGeometry(argv[i]) == MagickFalse)
1575  ThrowConvertInvalidArgumentException(option,argv[i]);
1576  break;
1577  }
1578  if (LocaleCompare("extract",option+1) == 0)
1579  {
1580  if (*option == '+')
1581  break;
1582  i++;
1583  if (i == (ssize_t) argc)
1584  ThrowConvertException(OptionError,"MissingArgument",option);
1585  if (IsGeometry(argv[i]) == MagickFalse)
1586  ThrowConvertInvalidArgumentException(option,argv[i]);
1587  break;
1588  }
1589  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1590  }
1591  case 'f':
1592  {
1593  if (LocaleCompare("family",option+1) == 0)
1594  {
1595  if (*option == '+')
1596  break;
1597  i++;
1598  if (i == (ssize_t) argc)
1599  ThrowConvertException(OptionError,"MissingArgument",option);
1600  break;
1601  }
1602  if (LocaleCompare("features",option+1) == 0)
1603  {
1604  if (*option == '+')
1605  break;
1606  i++;
1607  if (i == (ssize_t) argc)
1608  ThrowConvertException(OptionError,"MissingArgument",option);
1609  if (IsGeometry(argv[i]) == MagickFalse)
1610  ThrowConvertInvalidArgumentException(option,argv[i]);
1611  break;
1612  }
1613  if (LocaleCompare("fft",option+1) == 0)
1614  break;
1615  if (LocaleCompare("fill",option+1) == 0)
1616  {
1617  if (*option == '+')
1618  break;
1619  i++;
1620  if (i == (ssize_t) argc)
1621  ThrowConvertException(OptionError,"MissingArgument",option);
1622  break;
1623  }
1624  if (LocaleCompare("filter",option+1) == 0)
1625  {
1626  ssize_t
1627  filter;
1628 
1629  if (*option == '+')
1630  break;
1631  i++;
1632  if (i == (ssize_t) argc)
1633  ThrowConvertException(OptionError,"MissingArgument",option);
1634  filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
1635  if (filter < 0)
1636  ThrowConvertException(OptionError,"UnrecognizedImageFilter",
1637  argv[i]);
1638  break;
1639  }
1640  if (LocaleCompare("flatten",option+1) == 0)
1641  break;
1642  if (LocaleCompare("flip",option+1) == 0)
1643  break;
1644  if (LocaleCompare("flop",option+1) == 0)
1645  break;
1646  if (LocaleCompare("floodfill",option+1) == 0)
1647  {
1648  if (*option == '+')
1649  break;
1650  i++;
1651  if (i == (ssize_t) argc)
1652  ThrowConvertException(OptionError,"MissingArgument",option);
1653  if (IsGeometry(argv[i]) == MagickFalse)
1654  ThrowConvertInvalidArgumentException(option,argv[i]);
1655  i++;
1656  if (i == (ssize_t) argc)
1657  ThrowConvertException(OptionError,"MissingArgument",option);
1658  break;
1659  }
1660  if (LocaleCompare("font",option+1) == 0)
1661  {
1662  if (*option == '+')
1663  break;
1664  i++;
1665  if (i == (ssize_t) argc)
1666  ThrowConvertException(OptionError,"MissingArgument",option);
1667  break;
1668  }
1669  if (LocaleCompare("format",option+1) == 0)
1670  {
1671  if (*option == '+')
1672  break;
1673  i++;
1674  if (i == (ssize_t) argc)
1675  ThrowConvertException(OptionError,"MissingArgument",option);
1676  format=argv[i];
1677  break;
1678  }
1679  if (LocaleCompare("frame",option+1) == 0)
1680  {
1681  if (*option == '+')
1682  break;
1683  i++;
1684  if (i == (ssize_t) argc)
1685  ThrowConvertException(OptionError,"MissingArgument",option);
1686  if (IsGeometry(argv[i]) == MagickFalse)
1687  ThrowConvertInvalidArgumentException(option,argv[i]);
1688  break;
1689  }
1690  if (LocaleCompare("function",option+1) == 0)
1691  {
1692  ssize_t
1693  op;
1694 
1695  if (*option == '+')
1696  break;
1697  i++;
1698  if (i == (ssize_t) argc)
1699  ThrowConvertException(OptionError,"MissingArgument",option);
1700  op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
1701  if (op < 0)
1702  ThrowConvertException(OptionError,"UnrecognizedFunction",argv[i]);
1703  i++;
1704  if (i == (ssize_t) argc)
1705  ThrowConvertException(OptionError,"MissingArgument",option);
1706  break;
1707  }
1708  if (LocaleCompare("fuzz",option+1) == 0)
1709  {
1710  if (*option == '+')
1711  break;
1712  i++;
1713  if (i == (ssize_t) argc)
1714  ThrowConvertException(OptionError,"MissingArgument",option);
1715  if (IsGeometry(argv[i]) == MagickFalse)
1716  ThrowConvertInvalidArgumentException(option,argv[i]);
1717  break;
1718  }
1719  if (LocaleCompare("fx",option+1) == 0)
1720  {
1721  if (*option == '+')
1722  break;
1723  i++;
1724  if (i == (ssize_t) argc)
1725  ThrowConvertException(OptionError,"MissingArgument",option);
1726  break;
1727  }
1728  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1729  }
1730  case 'g':
1731  {
1732  if (LocaleCompare("gamma",option+1) == 0)
1733  {
1734  i++;
1735  if (i == (ssize_t) argc)
1736  ThrowConvertException(OptionError,"MissingArgument",option);
1737  if (IsGeometry(argv[i]) == MagickFalse)
1738  ThrowConvertInvalidArgumentException(option,argv[i]);
1739  break;
1740  }
1741  if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1742  (LocaleCompare("gaussian",option+1) == 0))
1743  {
1744  i++;
1745  if (i == (ssize_t) argc)
1746  ThrowConvertException(OptionError,"MissingArgument",option);
1747  if (IsGeometry(argv[i]) == MagickFalse)
1748  ThrowConvertInvalidArgumentException(option,argv[i]);
1749  break;
1750  }
1751  if (LocaleCompare("geometry",option+1) == 0)
1752  {
1753  if (*option == '+')
1754  break;
1755  i++;
1756  if (i == (ssize_t) argc)
1757  ThrowConvertException(OptionError,"MissingArgument",option);
1758  if (IsGeometry(argv[i]) == MagickFalse)
1759  ThrowConvertInvalidArgumentException(option,argv[i]);
1760  break;
1761  }
1762  if (LocaleCompare("gravity",option+1) == 0)
1763  {
1764  ssize_t
1765  gravity;
1766 
1767  if (*option == '+')
1768  break;
1769  i++;
1770  if (i == (ssize_t) argc)
1771  ThrowConvertException(OptionError,"MissingArgument",option);
1772  gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1773  argv[i]);
1774  if (gravity < 0)
1775  ThrowConvertException(OptionError,"UnrecognizedGravityType",
1776  argv[i]);
1777  break;
1778  }
1779  if (LocaleCompare("grayscale",option+1) == 0)
1780  {
1781  ssize_t
1782  method;
1783 
1784  if (*option == '+')
1785  break;
1786  i++;
1787  if (i == (ssize_t) argc)
1788  ThrowConvertException(OptionError,"MissingArgument",option);
1789  method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
1790  argv[i]);
1791  if (method < 0)
1792  ThrowConvertException(OptionError,"UnrecognizedIntensityMethod",
1793  argv[i]);
1794  break;
1795  }
1796  if (LocaleCompare("green-primary",option+1) == 0)
1797  {
1798  if (*option == '+')
1799  break;
1800  i++;
1801  if (i == (ssize_t) argc)
1802  ThrowConvertException(OptionError,"MissingArgument",option);
1803  if (IsGeometry(argv[i]) == MagickFalse)
1804  ThrowConvertInvalidArgumentException(option,argv[i]);
1805  break;
1806  }
1807  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1808  }
1809  case 'h':
1810  {
1811  if (LocaleCompare("hald-clut",option+1) == 0)
1812  break;
1813  if ((LocaleCompare("help",option+1) == 0) ||
1814  (LocaleCompare("-help",option+1) == 0))
1815  return(ConvertUsage());
1816  if (LocaleCompare("hough-lines",option+1) == 0)
1817  {
1818  if (*option == '+')
1819  break;
1820  i++;
1821  if (i == (ssize_t) argc)
1822  ThrowConvertException(OptionError,"MissingArgument",option);
1823  if (IsGeometry(argv[i]) == MagickFalse)
1824  ThrowConvertInvalidArgumentException(option,argv[i]);
1825  break;
1826  }
1827  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1828  }
1829  case 'i':
1830  {
1831  if (LocaleCompare("identify",option+1) == 0)
1832  break;
1833  if (LocaleCompare("ift",option+1) == 0)
1834  break;
1835  if (LocaleCompare("implode",option+1) == 0)
1836  {
1837  if (*option == '+')
1838  break;
1839  i++;
1840  if (i == (ssize_t) argc)
1841  ThrowConvertException(OptionError,"MissingArgument",option);
1842  if (IsGeometry(argv[i]) == MagickFalse)
1843  ThrowConvertInvalidArgumentException(option,argv[i]);
1844  break;
1845  }
1846  if (LocaleCompare("insert",option+1) == 0)
1847  {
1848  if (*option == '+')
1849  break;
1850  i++;
1851  if (i == (ssize_t) argc)
1852  ThrowConvertException(OptionError,"MissingArgument",option);
1853  if (IsGeometry(argv[i]) == MagickFalse)
1854  ThrowConvertInvalidArgumentException(option,argv[i]);
1855  break;
1856  }
1857  if (LocaleCompare("intensity",option+1) == 0)
1858  {
1859  ssize_t
1860  intensity;
1861 
1862  if (*option == '+')
1863  break;
1864  i++;
1865  if (i == (ssize_t) argc)
1866  ThrowConvertException(OptionError,"MissingArgument",option);
1867  intensity=ParseCommandOption(MagickPixelIntensityOptions,
1868  MagickFalse,argv[i]);
1869  if (intensity < 0)
1870  ThrowConvertException(OptionError,"UnrecognizedIntensityMethod",
1871  argv[i]);
1872  break;
1873  }
1874  if (LocaleCompare("intent",option+1) == 0)
1875  {
1876  ssize_t
1877  intent;
1878 
1879  if (*option == '+')
1880  break;
1881  i++;
1882  if (i == (ssize_t) argc)
1883  ThrowConvertException(OptionError,"MissingArgument",option);
1884  intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
1885  if (intent < 0)
1886  ThrowConvertException(OptionError,"UnrecognizedIntentType",argv[i]);
1887  break;
1888  }
1889  if (LocaleCompare("interlace",option+1) == 0)
1890  {
1891  ssize_t
1892  interlace;
1893 
1894  if (*option == '+')
1895  break;
1896  i++;
1897  if (i == (ssize_t) argc)
1898  ThrowConvertException(OptionError,"MissingArgument",option);
1899  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1900  argv[i]);
1901  if (interlace < 0)
1902  ThrowConvertException(OptionError,"UnrecognizedInterlaceType",
1903  argv[i]);
1904  break;
1905  }
1906  if (LocaleCompare("interline-spacing",option+1) == 0)
1907  {
1908  if (*option == '+')
1909  break;
1910  i++;
1911  if (i == (ssize_t) argc)
1912  ThrowConvertException(OptionError,"MissingArgument",option);
1913  if (IsGeometry(argv[i]) == MagickFalse)
1914  ThrowConvertInvalidArgumentException(option,argv[i]);
1915  break;
1916  }
1917  if (LocaleCompare("interpolate",option+1) == 0)
1918  {
1919  ssize_t
1920  interpolate;
1921 
1922  if (*option == '+')
1923  break;
1924  i++;
1925  if (i == (ssize_t) argc)
1926  ThrowConvertException(OptionError,"MissingArgument",option);
1927  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1928  argv[i]);
1929  if (interpolate < 0)
1930  ThrowConvertException(OptionError,"UnrecognizedInterpolateMethod",
1931  argv[i]);
1932  break;
1933  }
1934  if (LocaleCompare("interword-spacing",option+1) == 0)
1935  {
1936  if (*option == '+')
1937  break;
1938  i++;
1939  if (i == (ssize_t) argc)
1940  ThrowConvertException(OptionError,"MissingArgument",option);
1941  if (IsGeometry(argv[i]) == MagickFalse)
1942  ThrowConvertInvalidArgumentException(option,argv[i]);
1943  break;
1944  }
1945  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1946  }
1947  case 'k':
1948  {
1949  if (LocaleCompare("kerning",option+1) == 0)
1950  {
1951  if (*option == '+')
1952  break;
1953  i++;
1954  if (i == (ssize_t) argc)
1955  ThrowConvertException(OptionError,"MissingArgument",option);
1956  if (IsGeometry(argv[i]) == MagickFalse)
1957  ThrowConvertInvalidArgumentException(option,argv[i]);
1958  break;
1959  }
1960  if (LocaleCompare("kuwahara",option+1) == 0)
1961  {
1962  if (*option == '+')
1963  break;
1964  i++;
1965  if (i == (ssize_t) argc)
1966  ThrowConvertException(OptionError,"MissingArgument",option);
1967  if (IsGeometry(argv[i]) == MagickFalse)
1968  ThrowConvertInvalidArgumentException(option,argv[i]);
1969  break;
1970  }
1971  ThrowConvertException(OptionError,"UnrecognizedOption",option)
1972  }
1973  case 'l':
1974  {
1975  if (LocaleCompare("label",option+1) == 0)
1976  {
1977  if (*option == '+')
1978  break;
1979  i++;
1980  if (i == (ssize_t) argc)
1981  ThrowConvertException(OptionError,"MissingArgument",option);
1982  break;
1983  }
1984  if (LocaleCompare("lat",option+1) == 0)
1985  {
1986  if (*option == '+')
1987  break;
1988  i++;
1989  if (i == (ssize_t) argc)
1990  ThrowConvertException(OptionError,"MissingArgument",option);
1991  if (IsGeometry(argv[i]) == MagickFalse)
1992  ThrowConvertInvalidArgumentException(option,argv[i]);
1993  break;
1994  }
1995  if (LocaleCompare("layers",option+1) == 0)
1996  {
1997  ssize_t
1998  type;
1999 
2000  if (*option == '+')
2001  break;
2002  i++;
2003  if (i == (ssize_t) argc)
2004  ThrowConvertException(OptionError,"MissingArgument",option);
2005  type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
2006  if (type < 0)
2007  ThrowConvertException(OptionError,"UnrecognizedLayerMethod",
2008  argv[i]);
2009  break;
2010  }
2011  if (LocaleCompare("level",option+1) == 0)
2012  {
2013  i++;
2014  if (i == (ssize_t) argc)
2015  ThrowConvertException(OptionError,"MissingArgument",option);
2016  if (IsGeometry(argv[i]) == MagickFalse)
2017  ThrowConvertInvalidArgumentException(option,argv[i]);
2018  break;
2019  }
2020  if (LocaleCompare("level-colors",option+1) == 0)
2021  {
2022  i++;
2023  if (i == (ssize_t) argc)
2024  ThrowConvertException(OptionError,"MissingArgument",option);
2025  break;
2026  }
2027  if (LocaleCompare("limit",option+1) == 0)
2028  {
2029  char
2030  *p;
2031 
2032  double
2033  value;
2034 
2035  ssize_t
2036  resource;
2037 
2038  if (*option == '+')
2039  break;
2040  i++;
2041  if (i == (ssize_t) argc)
2042  ThrowConvertException(OptionError,"MissingArgument",option);
2043  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
2044  argv[i]);
2045  if (resource < 0)
2046  ThrowConvertException(OptionError,"UnrecognizedResourceType",
2047  argv[i]);
2048  i++;
2049  if (i == (ssize_t) argc)
2050  ThrowConvertException(OptionError,"MissingArgument",option);
2051  value=StringToDouble(argv[i],&p);
2052  (void) value;
2053  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
2054  ThrowConvertInvalidArgumentException(option,argv[i]);
2055  break;
2056  }
2057  if (LocaleCompare("linear-stretch",option+1) == 0)
2058  {
2059  i++;
2060  if (i == (ssize_t) argc)
2061  ThrowConvertException(OptionError,"MissingArgument",option);
2062  if (IsGeometry(argv[i]) == MagickFalse)
2063  ThrowConvertInvalidArgumentException(option,argv[i]);
2064  break;
2065  }
2066  if (LocaleCompare("liquid-rescale",option+1) == 0)
2067  {
2068  i++;
2069  if (i == (ssize_t) argc)
2070  ThrowConvertException(OptionError,"MissingArgument",option);
2071  if (IsGeometry(argv[i]) == MagickFalse)
2072  ThrowConvertInvalidArgumentException(option,argv[i]);
2073  break;
2074  }
2075  if (LocaleCompare("list",option+1) == 0)
2076  {
2077  ssize_t
2078  list;
2079 
2080  if (*option == '+')
2081  break;
2082  i++;
2083  if (i == (ssize_t) argc)
2084  ThrowConvertException(OptionError,"MissingArgument",option);
2085  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
2086  if (list < 0)
2087  ThrowConvertException(OptionError,"UnrecognizedListType",argv[i]);
2088  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
2089  argv+j,exception);
2090  DestroyConvert();
2091  return(status == 0 ? MagickFalse : MagickTrue);
2092  }
2093  if (LocaleCompare("local-contrast",option+1) == 0)
2094  {
2095  i++;
2096  if (i == (ssize_t)argc)
2097  ThrowConvertException(OptionError, "MissingArgument", option);
2098  if (IsGeometry(argv[i]) == MagickFalse)
2099  ThrowConvertInvalidArgumentException(option,argv[i]);
2100  break;
2101  }
2102  if (LocaleCompare("log",option+1) == 0)
2103  {
2104  if (*option == '+')
2105  break;
2106  i++;
2107  if ((i == (ssize_t) argc) ||
2108  (strchr(argv[i],'%') == (char *) NULL))
2109  ThrowConvertException(OptionError,"MissingArgument",option);
2110  break;
2111  }
2112  if (LocaleCompare("loop",option+1) == 0)
2113  {
2114  if (*option == '+')
2115  break;
2116  i++;
2117  if (i == (ssize_t) argc)
2118  ThrowConvertException(OptionError,"MissingArgument",option);
2119  if (IsGeometry(argv[i]) == MagickFalse)
2120  ThrowConvertInvalidArgumentException(option,argv[i]);
2121  break;
2122  }
2123  ThrowConvertException(OptionError,"UnrecognizedOption",option)
2124  }
2125  case 'm':
2126  {
2127  if (LocaleCompare("magnify",option+1) == 0)
2128  break;
2129  if (LocaleCompare("map",option+1) == 0)
2130  {
2131  if (*option == '+')
2132  break;
2133  i++;
2134  if (i == (ssize_t) argc)
2135  ThrowConvertException(OptionError,"MissingArgument",option);
2136  break;
2137  }
2138  if (LocaleCompare("mask",option+1) == 0)
2139  {
2140  if (*option == '+')
2141  break;
2142  i++;
2143  if (i == (ssize_t) argc)
2144  ThrowConvertException(OptionError,"MissingArgument",option);
2145  break;
2146  }
2147  if (LocaleCompare("matte",option+1) == 0)
2148  break;
2149  if (LocaleCompare("mattecolor",option+1) == 0)
2150  {
2151  if (*option == '+')
2152  break;
2153  i++;
2154  if (i == (ssize_t)argc)
2155  ThrowConvertException(OptionError, "MissingArgument", option);
2156  break;
2157  }
2158  if (LocaleCompare("maximum",option+1) == 0)
2159  break;
2160  if (LocaleCompare("mean-shift",option+1) == 0)
2161  {
2162  if (*option == '+')
2163  break;
2164  i++;
2165  if (i == (ssize_t) argc)
2166  ThrowConvertException(OptionError,"MissingArgument",option);
2167  if (IsGeometry(argv[i]) == MagickFalse)
2168  ThrowConvertInvalidArgumentException(option,argv[i]);
2169  break;
2170  }
2171  if (LocaleCompare("median",option+1) == 0)
2172  {
2173  if (*option == '+')
2174  break;
2175  i++;
2176  if (i == (ssize_t) argc)
2177  ThrowConvertException(OptionError,"MissingArgument",option);
2178  if (IsGeometry(argv[i]) == MagickFalse)
2179  ThrowConvertInvalidArgumentException(option,argv[i]);
2180  break;
2181  }
2182  if (LocaleCompare("metric",option+1) == 0)
2183  {
2184  ssize_t
2185  type;
2186 
2187  if (*option == '+')
2188  break;
2189  i++;
2190  if (i == (ssize_t) argc)
2191  ThrowConvertException(OptionError,"MissingArgument",option);
2192  type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
2193  if (type < 0)
2194  ThrowConvertException(OptionError,"UnrecognizedMetricType",
2195  argv[i]);
2196  break;
2197  }
2198  if (LocaleCompare("minimum",option+1) == 0)
2199  break;
2200  if (LocaleCompare("mode",option+1) == 0)
2201  {
2202  if (*option == '+')
2203  break;
2204  i++;
2205  if (i == (ssize_t) argc)
2206  ThrowConvertException(OptionError,"MissingArgument",option);
2207  if (IsGeometry(argv[i]) == MagickFalse)
2208  ThrowConvertInvalidArgumentException(option,argv[i]);
2209  break;
2210  }
2211  if (LocaleCompare("modulate",option+1) == 0)
2212  {
2213  if (*option == '+')
2214  break;
2215  i++;
2216  if (i == (ssize_t) argc)
2217  ThrowConvertException(OptionError,"MissingArgument",option);
2218  if (IsGeometry(argv[i]) == MagickFalse)
2219  ThrowConvertInvalidArgumentException(option,argv[i]);
2220  break;
2221  }
2222  if (LocaleCompare("moments",option+1) == 0)
2223  break;
2224  if (LocaleCompare("monitor",option+1) == 0)
2225  break;
2226  if (LocaleCompare("monochrome",option+1) == 0)
2227  break;
2228  if (LocaleCompare("morph",option+1) == 0)
2229  {
2230  if (*option == '+')
2231  break;
2232  i++;
2233  if (i == (ssize_t) argc)
2234  ThrowConvertException(OptionError,"MissingArgument",option);
2235  if (IsGeometry(argv[i]) == MagickFalse)
2236  ThrowConvertInvalidArgumentException(option,argv[i]);
2237  break;
2238  }
2239  if (LocaleCompare("morphology",option+1) == 0)
2240  {
2241  char
2242  token[MagickPathExtent];
2243 
2244  KernelInfo
2245  *kernel_info;
2246 
2247  ssize_t
2248  op;
2249 
2250  i++;
2251  if (i == (ssize_t) argc)
2252  ThrowConvertException(OptionError,"MissingArgument",option);
2253  GetNextToken(argv[i],(const char **) NULL,MagickPathExtent,token);
2254  op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
2255  if (op < 0)
2256  ThrowConvertException(OptionError,"UnrecognizedMorphologyMethod",
2257  token);
2258  i++;
2259  if (i == (ssize_t) argc)
2260  ThrowConvertException(OptionError,"MissingArgument",option);
2261  kernel_info=AcquireKernelInfo(argv[i],exception);
2262  if (kernel_info == (KernelInfo *) NULL)
2263  ThrowConvertInvalidArgumentException(option,argv[i]);
2264  kernel_info=DestroyKernelInfo(kernel_info);
2265  break;
2266  }
2267  if (LocaleCompare("mosaic",option+1) == 0)
2268  break;
2269  if (LocaleCompare("motion-blur",option+1) == 0)
2270  {
2271  if (*option == '+')
2272  break;
2273  i++;
2274  if (i == (ssize_t) argc)
2275  ThrowConvertException(OptionError,"MissingArgument",option);
2276  if (IsGeometry(argv[i]) == MagickFalse)
2277  ThrowConvertInvalidArgumentException(option,argv[i]);
2278  break;
2279  }
2280  ThrowConvertException(OptionError,"UnrecognizedOption",option)
2281  }
2282  case 'n':
2283  {
2284  if (LocaleCompare("negate",option+1) == 0)
2285  break;
2286  if (LocaleCompare("noise",option+1) == 0)
2287  {
2288  i++;
2289  if (i == (ssize_t) argc)
2290  ThrowConvertException(OptionError,"MissingArgument",option);
2291  if (*option == '+')
2292  {
2293  ssize_t
2294  noise;
2295 
2296  noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
2297  argv[i]);
2298  if (noise < 0)
2299  ThrowConvertException(OptionError,"UnrecognizedNoiseType",
2300  argv[i]);
2301  break;
2302  }
2303  if (IsGeometry(argv[i]) == MagickFalse)
2304  ThrowConvertInvalidArgumentException(option,argv[i]);
2305  break;
2306  }
2307  if (LocaleCompare("noop",option+1) == 0)
2308  break;
2309  if (LocaleCompare("normalize",option+1) == 0)
2310  break;
2311  ThrowConvertException(OptionError,"UnrecognizedOption",option)
2312  }
2313  case 'o':
2314  {
2315  if (LocaleCompare("opaque",option+1) == 0)
2316  {
2317  i++;
2318  if (i == (ssize_t) argc)
2319  ThrowConvertException(OptionError,"MissingArgument",option);
2320  break;
2321  }
2322  if (LocaleCompare("ordered-dither",option+1) == 0)
2323  {
2324  if (*option == '+')
2325  break;
2326  i++;
2327  if (i == (ssize_t) argc)
2328  ThrowConvertException(OptionError,"MissingArgument",option);
2329  break;
2330  }
2331  if (LocaleCompare("orient",option+1) == 0)
2332  {
2333  ssize_t
2334  orientation;
2335 
2336  if (*option == '+')
2337  break;
2338  i++;
2339  if (i == (ssize_t) argc)
2340  ThrowConvertException(OptionError,"MissingArgument",option);
2341  orientation=ParseCommandOption(MagickOrientationOptions,
2342  MagickFalse,argv[i]);
2343  if (orientation < 0)
2344  ThrowConvertException(OptionError,"UnrecognizedImageOrientation",
2345  argv[i]);
2346  break;
2347  }
2348  ThrowConvertException(OptionError,"UnrecognizedOption",argv[i])
2349  }
2350  case 'p':
2351  {
2352  if (LocaleCompare("page",option+1) == 0)
2353  {
2354  if (*option == '+')
2355  break;
2356  i++;
2357  if (i == (ssize_t) argc)
2358  ThrowConvertException(OptionError,"MissingArgument",option);
2359  break;
2360  }
2361  if (LocaleCompare("paint",option+1) == 0)
2362  {
2363  if (*option == '+')
2364  break;
2365  i++;
2366  if (i == (ssize_t) argc)
2367  ThrowConvertException(OptionError,"MissingArgument",option);
2368  if (IsGeometry(argv[i]) == MagickFalse)
2369  ThrowConvertInvalidArgumentException(option,argv[i]);
2370  break;
2371  }
2372  if (LocaleCompare("perceptible",option+1) == 0)
2373  {
2374  if (*option == '+')
2375  break;
2376  i++;
2377  if (i == (ssize_t) argc)
2378  ThrowConvertException(OptionError,"MissingArgument",option);
2379  if (IsGeometry(argv[i]) == MagickFalse)
2380  ThrowConvertInvalidArgumentException(option,argv[i]);
2381  break;
2382  }
2383  if (LocaleCompare("ping",option+1) == 0)
2384  break;
2385  if (LocaleCompare("pointsize",option+1) == 0)
2386  {
2387  if (*option == '+')
2388  break;
2389  i++;
2390  if (i == (ssize_t) argc)
2391  ThrowConvertException(OptionError,"MissingArgument",option);
2392  if (IsGeometry(argv[i]) == MagickFalse)
2393  ThrowConvertInvalidArgumentException(option,argv[i]);
2394  break;
2395  }
2396  if (LocaleCompare("polaroid",option+1) == 0)
2397  {
2398  if (*option == '+')
2399  break;
2400  i++;
2401  if (i == (ssize_t) argc)
2402  ThrowConvertException(OptionError,"MissingArgument",option);
2403  if (IsGeometry(argv[i]) == MagickFalse)
2404  ThrowConvertInvalidArgumentException(option,argv[i]);
2405  break;
2406  }
2407  if (LocaleCompare("poly",option+1) == 0)
2408  {
2409  if (*option == '+')
2410  break;
2411  i++;
2412  if (i == (ssize_t) argc)
2413  ThrowConvertException(OptionError,"MissingArgument",option);
2414  if (IsGeometry(argv[i]) == MagickFalse)
2415  ThrowConvertInvalidArgumentException(option,argv[i]);
2416  break;
2417  }
2418  if (LocaleCompare("posterize",option+1) == 0)
2419  {
2420  if (*option == '+')
2421  break;
2422  i++;
2423  if (i == (ssize_t) argc)
2424  ThrowConvertException(OptionError,"MissingArgument",option);
2425  if (IsGeometry(argv[i]) == MagickFalse)
2426  ThrowConvertInvalidArgumentException(option,argv[i]);
2427  break;
2428  }
2429  if (LocaleCompare("precision",option+1) == 0)
2430  {
2431  if (*option == '+')
2432  break;
2433  i++;
2434  if (i == (ssize_t) argc)
2435  ThrowConvertException(OptionError,"MissingArgument",option);
2436  if (IsGeometry(argv[i]) == MagickFalse)
2437  ThrowConvertInvalidArgumentException(option,argv[i]);
2438  break;
2439  }
2440  if (LocaleCompare("preview",option+1) == 0)
2441  {
2442  ssize_t
2443  preview;
2444 
2445  if (*option == '+')
2446  break;
2447  i++;
2448  if (i == (ssize_t) argc)
2449  ThrowConvertException(OptionError,"MissingArgument",option);
2450  preview=ParseCommandOption(MagickPreviewOptions,MagickFalse,
2451  argv[i]);
2452  if (preview < 0)
2453  ThrowConvertException(OptionError,"UnrecognizedPreviewType",
2454  argv[i]);
2455  break;
2456  }
2457  if (LocaleCompare("print",option+1) == 0)
2458  {
2459  if (*option == '+')
2460  break;
2461  i++;
2462  if (i == (ssize_t) argc)
2463  ThrowConvertException(OptionError,"MissingArgument",option);
2464  break;
2465  }
2466  if (LocaleCompare("process",option+1) == 0)
2467  {
2468  if (*option == '+')
2469  break;
2470  i++;
2471  if (i == (ssize_t) argc)
2472  ThrowConvertException(OptionError,"MissingArgument",option);
2473  break;
2474  }
2475  if (LocaleCompare("profile",option+1) == 0)
2476  {
2477  i++;
2478  if (i == (ssize_t) argc)
2479  ThrowConvertException(OptionError,"MissingArgument",option);
2480  break;
2481  }
2482  ThrowConvertException(OptionError,"UnrecognizedOption",option)
2483  }
2484  case 'q':
2485  {
2486  if (LocaleCompare("quality",option+1) == 0)
2487  {
2488  if (*option == '+')
2489  break;
2490  i++;
2491  if (i == (ssize_t) argc)
2492  ThrowConvertException(OptionError,"MissingArgument",option);
2493  if (IsGeometry(argv[i]) == MagickFalse)
2494  ThrowConvertInvalidArgumentException(option,argv[i]);
2495  break;
2496  }
2497  if (LocaleCompare("quantize",option+1) == 0)
2498  {
2499  ssize_t
2500  colorspace;
2501 
2502  if (*option == '+')
2503  break;
2504  i++;
2505  if (i == (ssize_t) argc)
2506  ThrowConvertException(OptionError,"MissingArgument",option);
2507  colorspace=ParseCommandOption(MagickColorspaceOptions,
2508  MagickFalse,argv[i]);
2509  if (colorspace < 0)
2510  ThrowConvertException(OptionError,"UnrecognizedColorspace",
2511  argv[i]);
2512  break;
2513  }
2514  if (LocaleCompare("quiet",option+1) == 0)
2515  break;
2516  ThrowConvertException(OptionError,"UnrecognizedOption",option)
2517  }
2518  case 'r':
2519  {
2520  if (LocaleCompare("rotational-blur",option+1) == 0)
2521  {
2522  i++;
2523  if (i == (ssize_t) argc)
2524  ThrowConvertException(OptionError,"MissingArgument",option);
2525  if (IsGeometry(argv[i]) == MagickFalse)
2526  ThrowConvertInvalidArgumentException(option,argv[i]);
2527  break;
2528  }
2529  if (LocaleCompare("raise",option+1) == 0)
2530  {
2531  i++;
2532  if (i == (ssize_t) argc)
2533  ThrowConvertException(OptionError,"MissingArgument",option);
2534  if (IsGeometry(argv[i]) == MagickFalse)
2535  ThrowConvertInvalidArgumentException(option,argv[i]);
2536  break;
2537  }
2538  if (LocaleCompare("random-threshold",option+1) == 0)
2539  {
2540  if (*option == '+')
2541  break;
2542  i++;
2543  if (i == (ssize_t) argc)
2544  ThrowConvertException(OptionError,"MissingArgument",option);
2545  if (IsGeometry(argv[i]) == MagickFalse)
2546  ThrowConvertInvalidArgumentException(option,argv[i]);
2547  break;
2548  }
2549  if (LocaleCompare("range-threshold",option+1) == 0)
2550  {
2551  if (*option == '+')
2552  break;
2553  i++;
2554  if (i == (ssize_t) argc)
2555  ThrowConvertException(OptionError,"MissingArgument",option);
2556  if (IsGeometry(argv[i]) == MagickFalse)
2557  ThrowConvertInvalidArgumentException(option,argv[i]);
2558  break;
2559  }
2560  if (LocaleCompare("read-mask",option+1) == 0)
2561  {
2562  if (*option == '+')
2563  break;
2564  i++;
2565  if (i == (ssize_t) argc)
2566  ThrowConvertException(OptionError,"MissingArgument",option);
2567  break;
2568  }
2569  if (LocaleCompare("red-primary",option+1) == 0)
2570  {
2571  if (*option == '+')
2572  break;
2573  i++;
2574  if (i == (ssize_t) argc)
2575  ThrowConvertException(OptionError,"MissingArgument",option);
2576  if (IsGeometry(argv[i]) == MagickFalse)
2577  ThrowConvertInvalidArgumentException(option,argv[i]);
2578  break;
2579  }
2580  if (LocaleCompare("regard-warnings",option+1) == 0)
2581  break;
2582  if (LocaleCompare("region",option+1) == 0)
2583  {
2584  if (*option == '+')
2585  break;
2586  i++;
2587  if (i == (ssize_t) argc)
2588  ThrowConvertException(OptionError,"MissingArgument",option);
2589  if (IsGeometry(argv[i]) == MagickFalse)
2590  ThrowConvertInvalidArgumentException(option,argv[i]);
2591  break;
2592  }
2593  if (LocaleCompare("remap",option+1) == 0)
2594  {
2595  if (*option == '+')
2596  break;
2597  i++;
2598  if (i == (ssize_t) argc)
2599  ThrowConvertException(OptionError,"MissingArgument",option);
2600  break;
2601  }
2602  if (LocaleCompare("render",option+1) == 0)
2603  break;
2604  if (LocaleCompare("repage",option+1) == 0)
2605  {
2606  if (*option == '+')
2607  break;
2608  i++;
2609  if (i == (ssize_t) argc)
2610  ThrowConvertException(OptionError,"MissingArgument",option);
2611  if (IsGeometry(argv[i]) == MagickFalse)
2612  ThrowConvertInvalidArgumentException(option,argv[i]);
2613  break;
2614  }
2615  if (LocaleCompare("resample",option+1) == 0)
2616  {
2617  if (*option == '+')
2618  break;
2619  i++;
2620  if (i == (ssize_t) argc)
2621  ThrowConvertException(OptionError,"MissingArgument",option);
2622  if (IsGeometry(argv[i]) == MagickFalse)
2623  ThrowConvertInvalidArgumentException(option,argv[i]);
2624  break;
2625  }
2626  if (LocaleCompare("resize",option+1) == 0)
2627  {
2628  if (*option == '+')
2629  break;
2630  i++;
2631  if (i == (ssize_t) argc)
2632  ThrowConvertException(OptionError,"MissingArgument",option);
2633  if (IsGeometry(argv[i]) == MagickFalse)
2634  ThrowConvertInvalidArgumentException(option,argv[i]);
2635  break;
2636  }
2637  if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2638  {
2639  respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2640  break;
2641  }
2642  if (LocaleCompare("reverse",option+1) == 0)
2643  break;
2644  if (LocaleCompare("roll",option+1) == 0)
2645  {
2646  if (*option == '+')
2647  break;
2648  i++;
2649  if (i == (ssize_t) argc)
2650  ThrowConvertException(OptionError,"MissingArgument",option);
2651  if (IsGeometry(argv[i]) == MagickFalse)
2652  ThrowConvertInvalidArgumentException(option,argv[i]);
2653  break;
2654  }
2655  if (LocaleCompare("rotate",option+1) == 0)
2656  {
2657  i++;
2658  if (i == (ssize_t) argc)
2659  ThrowConvertException(OptionError,"MissingArgument",option);
2660  if (IsGeometry(argv[i]) == MagickFalse)
2661  ThrowConvertInvalidArgumentException(option,argv[i]);
2662  break;
2663  }
2664  ThrowConvertException(OptionError,"UnrecognizedOption",option)
2665  }
2666  case 's':
2667  {
2668  if (LocaleCompare("sample",option+1) == 0)
2669  {
2670  if (*option == '+')
2671  break;
2672  i++;
2673  if (i == (ssize_t) argc)
2674  ThrowConvertException(OptionError,"MissingArgument",option);
2675  if (IsGeometry(argv[i]) == MagickFalse)
2676  ThrowConvertInvalidArgumentException(option,argv[i]);
2677  break;
2678  }
2679  if (LocaleCompare("sampling-factor",option+1) == 0)
2680  {
2681  if (*option == '+')
2682  break;
2683  i++;
2684  if (i == (ssize_t) argc)
2685  ThrowConvertException(OptionError,"MissingArgument",option);
2686  if (IsGeometry(argv[i]) == MagickFalse)
2687  ThrowConvertInvalidArgumentException(option,argv[i]);
2688  break;
2689  }
2690  if (LocaleCompare("scale",option+1) == 0)
2691  {
2692  if (*option == '+')
2693  break;
2694  i++;
2695  if (i == (ssize_t) argc)
2696  ThrowConvertException(OptionError,"MissingArgument",option);
2697  if (IsGeometry(argv[i]) == MagickFalse)
2698  ThrowConvertInvalidArgumentException(option,argv[i]);
2699  break;
2700  }
2701  if (LocaleCompare("scene",option+1) == 0)
2702  {
2703  if (*option == '+')
2704  break;
2705  i++;
2706  if (i == (ssize_t) argc)
2707  ThrowConvertException(OptionError,"MissingArgument",option);
2708  if (IsGeometry(argv[i]) == MagickFalse)
2709  ThrowConvertInvalidArgumentException(option,argv[i]);
2710  break;
2711  }
2712  if (LocaleCompare("seed",option+1) == 0)
2713  {
2714  if (*option == '+')
2715  break;
2716  i++;
2717  if (i == (ssize_t) argc)
2718  ThrowConvertException(OptionError,"MissingArgument",option);
2719  if (IsGeometry(argv[i]) == MagickFalse)
2720  ThrowConvertInvalidArgumentException(option,argv[i]);
2721  break;
2722  }
2723  if (LocaleCompare("segment",option+1) == 0)
2724  {
2725  if (*option == '+')
2726  break;
2727  i++;
2728  if (i == (ssize_t) argc)
2729  ThrowConvertException(OptionError,"MissingArgument",option);
2730  if (IsGeometry(argv[i]) == MagickFalse)
2731  ThrowConvertInvalidArgumentException(option,argv[i]);
2732  break;
2733  }
2734  if (LocaleCompare("selective-blur",option+1) == 0)
2735  {
2736  i++;
2737  if (i == (ssize_t) argc)
2738  ThrowConvertException(OptionError,"MissingArgument",option);
2739  if (IsGeometry(argv[i]) == MagickFalse)
2740  ThrowConvertInvalidArgumentException(option,argv[i]);
2741  break;
2742  }
2743  if (LocaleCompare("separate",option+1) == 0)
2744  break;
2745  if (LocaleCompare("sepia-tone",option+1) == 0)
2746  {
2747  if (*option == '+')
2748  break;
2749  i++;
2750  if (i == (ssize_t) argc)
2751  ThrowConvertException(OptionError,"MissingArgument",option);
2752  if (IsGeometry(argv[i]) == MagickFalse)
2753  ThrowConvertInvalidArgumentException(option,argv[i]);
2754  break;
2755  }
2756  if (LocaleCompare("set",option+1) == 0)
2757  {
2758  i++;
2759  if (i == (ssize_t) argc)
2760  ThrowConvertException(OptionError,"MissingArgument",option);
2761  if (*option == '+')
2762  break;
2763  i++;
2764  if (i == (ssize_t) argc)
2765  ThrowConvertException(OptionError,"MissingArgument",option);
2766  break;
2767  }
2768  if (LocaleCompare("shade",option+1) == 0)
2769  {
2770  i++;
2771  if (i == (ssize_t) argc)
2772  ThrowConvertException(OptionError,"MissingArgument",option);
2773  if (IsGeometry(argv[i]) == MagickFalse)
2774  ThrowConvertInvalidArgumentException(option,argv[i]);
2775  break;
2776  }
2777  if (LocaleCompare("shadow",option+1) == 0)
2778  {
2779  if (*option == '+')
2780  break;
2781  i++;
2782  if (i == (ssize_t) argc)
2783  ThrowConvertException(OptionError,"MissingArgument",option);
2784  if (IsGeometry(argv[i]) == MagickFalse)
2785  ThrowConvertInvalidArgumentException(option,argv[i]);
2786  break;
2787  }
2788  if (LocaleCompare("sharpen",option+1) == 0)
2789  {
2790  i++;
2791  if (i == (ssize_t) argc)
2792  ThrowConvertException(OptionError,"MissingArgument",option);
2793  if (IsGeometry(argv[i]) == MagickFalse)
2794  ThrowConvertInvalidArgumentException(option,argv[i]);
2795  break;
2796  }
2797  if (LocaleCompare("shave",option+1) == 0)
2798  {
2799  if (*option == '+')
2800  break;
2801  i++;
2802  if (i == (ssize_t) argc)
2803  ThrowConvertException(OptionError,"MissingArgument",option);
2804  if (IsGeometry(argv[i]) == MagickFalse)
2805  ThrowConvertInvalidArgumentException(option,argv[i]);
2806  break;
2807  }
2808  if (LocaleCompare("shear",option+1) == 0)
2809  {
2810  i++;
2811  if (i == (ssize_t) argc)
2812  ThrowConvertException(OptionError,"MissingArgument",option);
2813  if (IsGeometry(argv[i]) == MagickFalse)
2814  ThrowConvertInvalidArgumentException(option,argv[i]);
2815  break;
2816  }
2817  if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2818  {
2819  i++;
2820  if (i == (ssize_t) argc)
2821  ThrowConvertException(OptionError,"MissingArgument",option);
2822  if (IsGeometry(argv[i]) == MagickFalse)
2823  ThrowConvertInvalidArgumentException(option,argv[i]);
2824  break;
2825  }
2826  if (LocaleCompare("size",option+1) == 0)
2827  {
2828  if (*option == '+')
2829  break;
2830  i++;
2831  if (i == (ssize_t) argc)
2832  ThrowConvertException(OptionError,"MissingArgument",option);
2833  if (IsGeometry(argv[i]) == MagickFalse)
2834  ThrowConvertInvalidArgumentException(option,argv[i]);
2835  break;
2836  }
2837  if (LocaleCompare("sketch",option+1) == 0)
2838  {
2839  if (*option == '+')
2840  break;
2841  i++;
2842  if (i == (ssize_t) argc)
2843  ThrowConvertException(OptionError,"MissingArgument",option);
2844  if (IsGeometry(argv[i]) == MagickFalse)
2845  ThrowConvertInvalidArgumentException(option,argv[i]);
2846  break;
2847  }
2848  if (LocaleCompare("smush",option+1) == 0)
2849  {
2850  i++;
2851  if (i == (ssize_t) argc)
2852  ThrowConvertException(OptionError,"MissingArgument",option);
2853  if (IsGeometry(argv[i]) == MagickFalse)
2854  ThrowConvertInvalidArgumentException(option,argv[i]);
2855  break;
2856  }
2857  if (LocaleCompare("solarize",option+1) == 0)
2858  {
2859  if (*option == '+')
2860  break;
2861  i++;
2862  if (i == (ssize_t) argc)
2863  ThrowConvertException(OptionError,"MissingArgument",option);
2864  if (IsGeometry(argv[i]) == MagickFalse)
2865  ThrowConvertInvalidArgumentException(option,argv[i]);
2866  break;
2867  }
2868  if (LocaleCompare("sparse-color",option+1) == 0)
2869  {
2870  ssize_t
2871  op;
2872 
2873  i++;
2874  if (i == (ssize_t) argc)
2875  ThrowConvertException(OptionError,"MissingArgument",option);
2876  op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
2877  if (op < 0)
2878  ThrowConvertException(OptionError,"UnrecognizedSparseColorMethod",
2879  argv[i]);
2880  i++;
2881  if (i == (ssize_t) argc)
2882  ThrowConvertException(OptionError,"MissingArgument",option);
2883  break;
2884  }
2885  if (LocaleCompare("splice",option+1) == 0)
2886  {
2887  if (*option == '+')
2888  break;
2889  i++;
2890  if (i == (ssize_t) argc)
2891  ThrowConvertException(OptionError,"MissingArgument",option);
2892  if (IsGeometry(argv[i]) == MagickFalse)
2893  ThrowConvertInvalidArgumentException(option,argv[i]);
2894  break;
2895  }
2896  if (LocaleCompare("spread",option+1) == 0)
2897  {
2898  if (*option == '+')
2899  break;
2900  i++;
2901  if ((i == (ssize_t) argc) ||
2902  (IsGeometry(argv[i]) == MagickFalse))
2903  ThrowConvertException(OptionError,"MissingArgument",option);
2904  break;
2905  }
2906  if (LocaleCompare("statistic",option+1) == 0)
2907  {
2908  ssize_t
2909  op;
2910 
2911  if (*option == '+')
2912  break;
2913  i++;
2914  if (i == (ssize_t) argc)
2915  ThrowConvertException(OptionError,"MissingArgument",option);
2916  op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
2917  if (op < 0)
2918  ThrowConvertException(OptionError,"UnrecognizedStatisticType",
2919  argv[i]);
2920  i++;
2921  if (i == (ssize_t) argc)
2922  ThrowConvertException(OptionError,"MissingArgument",option);
2923  if (IsGeometry(argv[i]) == MagickFalse)
2924  ThrowConvertInvalidArgumentException(option,argv[i]);
2925  break;
2926  }
2927  if (LocaleCompare("stretch",option+1) == 0)
2928  {
2929  ssize_t
2930  stretch;
2931 
2932  if (*option == '+')
2933  break;
2934  i++;
2935  if (i == (ssize_t) argc)
2936  ThrowConvertException(OptionError,"MissingArgument",option);
2937  stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
2938  argv[i]);
2939  if (stretch < 0)
2940  ThrowConvertException(OptionError,"UnrecognizedStyleType",
2941  argv[i]);
2942  break;
2943  }
2944  if (LocaleCompare("strip",option+1) == 0)
2945  break;
2946  if (LocaleCompare("stroke",option+1) == 0)
2947  {
2948  if (*option == '+')
2949  break;
2950  i++;
2951  if (i == (ssize_t) argc)
2952  ThrowConvertException(OptionError,"MissingArgument",option);
2953  break;
2954  }
2955  if (LocaleCompare("strokewidth",option+1) == 0)
2956  {
2957  if (*option == '+')
2958  break;
2959  i++;
2960  if (i == (ssize_t) argc)
2961  ThrowConvertException(OptionError,"MissingArgument",option);
2962  if (IsGeometry(argv[i]) == MagickFalse)
2963  ThrowConvertInvalidArgumentException(option,argv[i]);
2964  break;
2965  }
2966  if (LocaleCompare("style",option+1) == 0)
2967  {
2968  ssize_t
2969  style;
2970 
2971  if (*option == '+')
2972  break;
2973  i++;
2974  if (i == (ssize_t) argc)
2975  ThrowConvertException(OptionError,"MissingArgument",option);
2976  style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
2977  if (style < 0)
2978  ThrowConvertException(OptionError,"UnrecognizedStyleType",
2979  argv[i]);
2980  break;
2981  }
2982  if (LocaleCompare("support",option+1) == 0)
2983  {
2984  i++; /* deprecated */
2985  break;
2986  }
2987  if (LocaleCompare("swap",option+1) == 0)
2988  {
2989  if (*option == '+')
2990  break;
2991  i++;
2992  if (i == (ssize_t) argc)
2993  ThrowConvertException(OptionError,"MissingArgument",option);
2994  if (IsGeometry(argv[i]) == MagickFalse)
2995  ThrowConvertInvalidArgumentException(option,argv[i]);
2996  break;
2997  }
2998  if (LocaleCompare("swirl",option+1) == 0)
2999  {
3000  if (*option == '+')
3001  break;
3002  i++;
3003  if (i == (ssize_t) argc)
3004  ThrowConvertException(OptionError,"MissingArgument",option);
3005  if (IsGeometry(argv[i]) == MagickFalse)
3006  ThrowConvertInvalidArgumentException(option,argv[i]);
3007  break;
3008  }
3009  if (LocaleCompare("synchronize",option+1) == 0)
3010  break;
3011  ThrowConvertException(OptionError,"UnrecognizedOption",option)
3012  }
3013  case 't':
3014  {
3015  if (LocaleCompare("taint",option+1) == 0)
3016  break;
3017  if (LocaleCompare("texture",option+1) == 0)
3018  {
3019  if (*option == '+')
3020  break;
3021  i++;
3022  if (i == (ssize_t) argc)
3023  ThrowConvertException(OptionError,"MissingArgument",option);
3024  break;
3025  }
3026  if (LocaleCompare("threshold",option+1) == 0)
3027  {
3028  if (*option == '+')
3029  break;
3030  i++;
3031  if (i == (ssize_t) argc)
3032  ThrowConvertException(OptionError,"MissingArgument",option);
3033  if (IsGeometry(argv[i]) == MagickFalse)
3034  ThrowConvertInvalidArgumentException(option,argv[i]);
3035  break;
3036  }
3037  if (LocaleCompare("thumbnail",option+1) == 0)
3038  {
3039  if (*option == '+')
3040  break;
3041  i++;
3042  if (i == (ssize_t) argc)
3043  ThrowConvertException(OptionError,"MissingArgument",option);
3044  if (IsGeometry(argv[i]) == MagickFalse)
3045  ThrowConvertInvalidArgumentException(option,argv[i]);
3046  break;
3047  }
3048  if (LocaleCompare("tile",option+1) == 0)
3049  {
3050  if (*option == '+')
3051  break;
3052  i++;
3053  if (i == (ssize_t) argc)
3054  ThrowConvertException(OptionError,"MissingArgument",option);
3055  break;
3056  }
3057  if (LocaleCompare("tile-offset",option+1) == 0)
3058  {
3059  if (*option == '+')
3060  break;
3061  i++;
3062  if (i == (ssize_t) argc)
3063  ThrowConvertException(OptionError,"MissingArgument",option);
3064  if (IsGeometry(argv[i]) == MagickFalse)
3065  ThrowConvertInvalidArgumentException(option,argv[i]);
3066  break;
3067  }
3068  if (LocaleCompare("tint",option+1) == 0)
3069  {
3070  if (*option == '+')
3071  break;
3072  i++;
3073  if (i == (ssize_t) argc)
3074  ThrowConvertException(OptionError,"MissingArgument",option);
3075  if (IsGeometry(argv[i]) == MagickFalse)
3076  ThrowConvertInvalidArgumentException(option,argv[i]);
3077  break;
3078  }
3079  if (LocaleCompare("transform",option+1) == 0)
3080  break;
3081  if (LocaleCompare("transparent",option+1) == 0)
3082  {
3083  i++;
3084  if (i == (ssize_t) argc)
3085  ThrowConvertException(OptionError,"MissingArgument",option);
3086  break;
3087  }
3088  if (LocaleCompare("transparent-color",option+1) == 0)
3089  {
3090  if (*option == '+')
3091  break;
3092  i++;
3093  if (i == (ssize_t) argc)
3094  ThrowConvertException(OptionError,"MissingArgument",option);
3095  break;
3096  }
3097  if (LocaleCompare("transpose",option+1) == 0)
3098  break;
3099  if (LocaleCompare("transverse",option+1) == 0)
3100  break;
3101  if (LocaleCompare("treedepth",option+1) == 0)
3102  {
3103  if (*option == '+')
3104  break;
3105  i++;
3106  if (i == (ssize_t) argc)
3107  ThrowConvertException(OptionError,"MissingArgument",option);
3108  if (IsGeometry(argv[i]) == MagickFalse)
3109  ThrowConvertInvalidArgumentException(option,argv[i]);
3110  break;
3111  }
3112  if (LocaleCompare("trim",option+1) == 0)
3113  break;
3114  if (LocaleCompare("type",option+1) == 0)
3115  {
3116  ssize_t
3117  type;
3118 
3119  if (*option == '+')
3120  break;
3121  i++;
3122  if (i == (ssize_t) argc)
3123  ThrowConvertException(OptionError,"MissingArgument",option);
3124  type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
3125  if (type < 0)
3126  ThrowConvertException(OptionError,"UnrecognizedImageType",
3127  argv[i]);
3128  break;
3129  }
3130  ThrowConvertException(OptionError,"UnrecognizedOption",option)
3131  }
3132  case 'u':
3133  {
3134  if (LocaleCompare("undercolor",option+1) == 0)
3135  {
3136  if (*option == '+')
3137  break;
3138  i++;
3139  if (i == (ssize_t) argc)
3140  ThrowConvertException(OptionError,"MissingArgument",option);
3141  break;
3142  }
3143  if (LocaleCompare("unique-colors",option+1) == 0)
3144  break;
3145  if (LocaleCompare("units",option+1) == 0)
3146  {
3147  ssize_t
3148  units;
3149 
3150  if (*option == '+')
3151  break;
3152  i++;
3153  if (i == (ssize_t) argc)
3154  ThrowConvertException(OptionError,"MissingArgument",option);
3155  units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
3156  argv[i]);
3157  if (units < 0)
3158  ThrowConvertException(OptionError,"UnrecognizedUnitsType",
3159  argv[i]);
3160  break;
3161  }
3162  if (LocaleCompare("unsharp",option+1) == 0)
3163  {
3164  if (*option == '+')
3165  break;
3166  i++;
3167  if (i == (ssize_t) argc)
3168  ThrowConvertException(OptionError,"MissingArgument",option);
3169  if (IsGeometry(argv[i]) == MagickFalse)
3170  ThrowConvertInvalidArgumentException(option,argv[i]);
3171  break;
3172  }
3173  ThrowConvertException(OptionError,"UnrecognizedOption",option)
3174  }
3175  case 'v':
3176  {
3177  if (LocaleCompare("verbose",option+1) == 0)
3178  break;
3179  if ((LocaleCompare("version",option+1) == 0) ||
3180  (LocaleCompare("-version",option+1) == 0))
3181  {
3182  ListMagickVersion(stdout);
3183  break;
3184  }
3185  if (LocaleCompare("vignette",option+1) == 0)
3186  {
3187  if (*option == '+')
3188  break;
3189  i++;
3190  if (i == (ssize_t) argc)
3191  ThrowConvertException(OptionError,"MissingArgument",option);
3192  if (IsGeometry(argv[i]) == MagickFalse)
3193  ThrowConvertInvalidArgumentException(option,argv[i]);
3194  break;
3195  }
3196  if (LocaleCompare("virtual-pixel",option+1) == 0)
3197  {
3198  ssize_t
3199  method;
3200 
3201  if (*option == '+')
3202  break;
3203  i++;
3204  if (i == (ssize_t) argc)
3205  ThrowConvertException(OptionError,"MissingArgument",option);
3206  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3207  argv[i]);
3208  if (method < 0)
3209  ThrowConvertException(OptionError,
3210  "UnrecognizedVirtualPixelMethod",argv[i]);
3211  break;
3212  }
3213  ThrowConvertException(OptionError,"UnrecognizedOption",option)
3214  }
3215  case 'w':
3216  {
3217  if (LocaleCompare("wave",option+1) == 0)
3218  {
3219  i++;
3220  if (i == (ssize_t) argc)
3221  ThrowConvertException(OptionError,"MissingArgument",option);
3222  if (IsGeometry(argv[i]) == MagickFalse)
3223  ThrowConvertInvalidArgumentException(option,argv[i]);
3224  break;
3225  }
3226  if (LocaleCompare("wavelet-denoise",option+1) == 0)
3227  {
3228  i++;
3229  if (i == (ssize_t) argc)
3230  ThrowConvertException(OptionError,"MissingArgument",option);
3231  if (IsGeometry(argv[i]) == MagickFalse)
3232  ThrowConvertInvalidArgumentException(option,argv[i]);
3233  break;
3234  }
3235  if (LocaleCompare("weight",option+1) == 0)
3236  {
3237  if (*option == '+')
3238  break;
3239  i++;
3240  if (i == (ssize_t) argc)
3241  ThrowConvertException(OptionError,"MissingArgument",option);
3242  break;
3243  }
3244  if (LocaleCompare("white-point",option+1) == 0)
3245  {
3246  if (*option == '+')
3247  break;
3248  i++;
3249  if (i == (ssize_t) argc)
3250  ThrowConvertException(OptionError,"MissingArgument",option);
3251  if (IsGeometry(argv[i]) == MagickFalse)
3252  ThrowConvertInvalidArgumentException(option,argv[i]);
3253  break;
3254  }
3255  if (LocaleCompare("white-threshold",option+1) == 0)
3256  {
3257  if (*option == '+')
3258  break;
3259  i++;
3260  if (i == (ssize_t) argc)
3261  ThrowConvertException(OptionError,"MissingArgument",option);
3262  if (IsGeometry(argv[i]) == MagickFalse)
3263  ThrowConvertInvalidArgumentException(option,argv[i]);
3264  break;
3265  }
3266  if (LocaleCompare("write",option+1) == 0)
3267  {
3268  i++;
3269  if (i == (ssize_t) argc)
3270  ThrowConvertException(OptionError,"MissingArgument",option);
3271  break;
3272  }
3273  if (LocaleCompare("write-mask",option+1) == 0)
3274  {
3275  if (*option == '+')
3276  break;
3277  i++;
3278  if (i == (ssize_t) argc)
3279  ThrowConvertException(OptionError,"MissingArgument",option);
3280  break;
3281  }
3282  ThrowConvertException(OptionError,"UnrecognizedOption",option)
3283  }
3284  case '?':
3285  break;
3286  default:
3287  ThrowConvertException(OptionError,"UnrecognizedOption",option)
3288  }
3289  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
3290  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
3291  if (fire != MagickFalse)
3292  FireImageStack(MagickTrue,MagickTrue,MagickTrue);
3293  }
3294  if (k != 0)
3295  ThrowConvertException(OptionError,"UnbalancedParenthesis",argv[i]);
3296  if (i-- != (ssize_t) (argc-1))
3297  ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
3298  FinalizeImageSettings(image_info,image,MagickTrue);
3299  if (image == (Image *) NULL)
3300  ThrowConvertException(OptionError,"NoImagesDefined",argv[argc-1]);
3301  if (IsCommandOption(argv[argc-1]))
3302  ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
3303  if (LocaleCompare(" ",argv[argc-1])==0) /* common line continuation error */
3304  ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
3305  status&=WriteImages(image_info,image,argv[argc-1],exception);
3306  if (metadata != (char **) NULL)
3307  {
3308  char
3309  *text;
3310 
3311  text=InterpretImageProperties(image_info,image,format,exception);
3312  if (text == (char *) NULL)
3313  ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
3314  GetExceptionMessage(errno));
3315  (void) ConcatenateString(&(*metadata),text);
3316  text=DestroyString(text);
3317  }
3318  DestroyConvert();
3319  return(status != 0 ? MagickTrue : MagickFalse);
3320 }
#define ThrowConvertException(asperity, tag, option)
#define FinalizeImageSettings(image_info, image, advance)
static MagickBooleanType ConcatenateImages(int argc, char **argv, ExceptionInfo *exception)
Definition: convert.c:98
#define NewImageStack()
#define WandExport
#define AppendImageStack(images)
WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, const int argc, const char **argv, ExceptionInfo *exception)
Definition: mogrify.c:6601
#define MagickPathExtent
#define ReadCommandlLine(argc, argv)
Definition: studio.h:260
#define DestroyConvert()
WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info, int argc, char **argv, char **metadata, ExceptionInfo *exception)
Definition: convert.c:516
#define PopImageStack()
static MagickBooleanType ConvertUsage(void)
Definition: convert.c:143
#define ThrowFileException(exception, severity, tag, context)
Definition: convert.c:53
#define ThrowConvertInvalidArgumentException(option, argument)
#define PushImageStack()
#define FireImageStack(postfix, advance, fire)
#define MaxImageStackDepth