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