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