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