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