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