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