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