blob: b94f9f64a1ef7d76d4d7b21887d903868423fe92 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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% John Cristy %
17% April 1992 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36% Use the convert program to convert between image formats as well as resize
37% an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample,
38% and much more.
39%
40*/
41
42/*
43 Include declarations.
44*/
45#include "wand/studio.h"
46#include "wand/MagickWand.h"
47#include "wand/mogrify-private.h"
cristy5d28d482011-03-20 21:59:40 +000048#include "magick/string-private.h"
cristy3ed852e2009-09-05 21:47:34 +000049
50/*
51 Define declarations.
52*/
53#define ThrowFileException(exception,severity,tag,context) \
54{ \
55 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
56 tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \
57 GetExceptionMessage(errno)); \
58}
59
60/*
61%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62% %
63% %
64% %
65+ C o n v e r t I m a g e C o m m a n d %
66% %
67% %
68% %
69%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70%
71% ConvertImageCommand() reads one or more images, applies one or more image
72% processing operations, and writes out the image in the same or differing
73% format.
74%
75% The format of the ConvertImageCommand method is:
76%
77% MagickBooleanType ConvertImageCommand(ImageInfo *image_info,int argc,
78% char **argv,char **metadata,ExceptionInfo *exception)
79%
80% A description of each parameter follows:
81%
82% o image_info: the image info.
83%
84% o argc: the number of elements in the argument vector.
85%
86% o argv: A text array containing the command line arguments.
87%
88% o metadata: any metadata is returned here.
89%
90% o exception: return any errors or warnings in this structure.
91%
92*/
93
94static MagickBooleanType ConcatenateImages(int argc,char **argv,
95 ExceptionInfo *exception)
96{
97 FILE
98 *input,
99 *output;
100
101 int
102 c;
103
cristybb503372010-05-27 20:51:26 +0000104 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000105 i;
106
107 /*
108 Open output file.
109 */
110 output=OpenMagickStream(argv[argc-1],"wb");
111 if (output == (FILE *) NULL)
112 {
113 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
114 argv[argc-1]);
115 return(MagickFalse);
116 }
cristybb503372010-05-27 20:51:26 +0000117 for (i=2; i < (ssize_t) (argc-1); i++)
cristy3ed852e2009-09-05 21:47:34 +0000118 {
119 input=OpenMagickStream(argv[i],"rb");
120 if (input == (FILE *) NULL)
121 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]);
122 for (c=fgetc(input); c != EOF; c=fgetc(input))
123 (void) fputc((char) c,output);
124 (void) fclose(input);
125 (void) remove(argv[i]);
126 }
127 (void) fclose(output);
128 return(MagickTrue);
129}
130
131static MagickBooleanType ConvertUsage(void)
132{
133 static const char
134 *miscellaneous[]=
135 {
136 "-debug events display copious debugging information",
137 "-help print program options",
138 "-list type print a list of supported option arguments",
139 "-log format format of debugging information",
140 "-version print version information",
141 (char *) NULL
142 },
143 *operators[]=
144 {
145 "-adaptive-blur geometry",
146 " adaptively blur pixels; decrease effect near edges",
147 "-adaptive-resize geometry",
148 " adaptively resize image using 'mesh' interpolation",
149 "-adaptive-sharpen geometry",
150 " adaptively sharpen pixels; increase effect near edges",
151 "-alpha option on, activate, off, deactivate, set, opaque, copy",
152 " transparent, extract, background, or shape",
153 "-annotate geometry text",
154 " annotate the image with text",
155 "-auto-gamma automagically adjust gamma level of image",
156 "-auto-level automagically adjust color levels of image",
157 "-auto-orient automagically orient (rotate) image",
158 "-bench iterations measure performance",
159 "-black-threshold value",
160 " force all pixels below the threshold into black",
161 "-blue-shift factor simulate a scene at nighttime in the moonlight",
162 "-blur geometry reduce image noise and reduce detail levels",
163 "-border geometry surround image with a border of color",
164 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +0000165 "-brightness-contrast geometry",
166 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +0000167 "-cdl filename color correct with a color decision list",
168 "-charcoal radius simulate a charcoal drawing",
169 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +0000170 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +0000171 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +0000172 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +0000173 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +0000174 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +0000175 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +0000176 "-contrast enhance or reduce the image contrast",
177 "-contrast-stretch geometry",
178 " improve contrast by `stretching' the intensity range",
179 "-convolve coefficients",
180 " apply a convolution kernel to the image",
181 "-cycle amount cycle the image colormap",
182 "-decipher filename convert cipher pixels to plain pixels",
183 "-deskew threshold straighten an image",
184 "-despeckle reduce the speckles within an image",
185 "-distort method args",
186 " distort images according to given method ad args",
187 "-draw string annotate the image with a graphic primitive",
188 "-edge radius apply a filter to detect edges in the image",
189 "-encipher filename convert plain pixels to cipher pixels",
190 "-emboss radius emboss an image",
191 "-enhance apply a digital filter to enhance a noisy image",
192 "-equalize perform histogram equalization to an image",
193 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +0000194 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +0000195 "-extent geometry set the image size",
196 "-extract geometry extract area from image",
197 "-fft implements the discrete Fourier transform (DFT)",
198 "-flip flip image vertically",
199 "-floodfill geometry color",
200 " floodfill the image with color",
201 "-flop flop image horizontally",
202 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +0000203 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +0000204 " apply function over image values",
205 "-gamma value level of gamma correction",
206 "-gaussian-blur geometry",
207 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +0000208 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +0000209 "-identify identify the format and characteristics of the image",
210 "-ift implements the inverse discrete Fourier transform (DFT)",
211 "-implode amount implode image pixels about the center",
212 "-lat geometry local adaptive thresholding",
213 "-layers method optimize, merge, or compare image layers",
214 "-level value adjust the level of image contrast",
215 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +0000216 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +0000217 "-linear-stretch geometry",
218 " improve contrast by `stretching with saturation'",
219 "-liquid-rescale geometry",
220 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +0000221 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +0000222 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +0000223 "-modulate value vary the brightness, saturation, and hue",
224 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +0000225 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +0000226 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +0000227 "-motion-blur geometry",
228 " simulate motion blur",
229 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +0000230 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +0000231 "-normalize transform image to span the full range of colors",
232 "-opaque color change this color to the fill color",
233 "-ordered-dither NxN",
234 " add a noise pattern to the image with specific",
235 " amplitudes",
236 "-paint radius simulate an oil painting",
237 "-polaroid angle simulate a Polaroid picture",
238 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +0000239 "-profile filename add, delete, or apply an image profile",
240 "-quantize colorspace reduce colors in this colorspace",
241 "-radial-blur angle radial blur the image",
242 "-raise value lighten/darken image edges to create a 3-D effect",
243 "-random-threshold low,high",
244 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +0000245 "-region geometry apply options to a portion of the image",
246 "-render render vector graphics",
247 "-repage geometry size and location of an image canvas",
248 "-resample geometry change the resolution of an image",
249 "-resize geometry resize the image",
250 "-roll geometry roll an image vertically or horizontally",
251 "-rotate degrees apply Paeth rotation to the image",
252 "-sample geometry scale image with pixel sampling",
253 "-scale geometry scale the image",
254 "-segment values segment an image",
255 "-selective-blur geometry",
256 " selectively blur pixels within a contrast threshold",
257 "-sepia-tone threshold",
258 " simulate a sepia-toned photo",
259 "-set property value set an image property",
260 "-shade degrees shade the image using a distant light source",
261 "-shadow geometry simulate an image shadow",
262 "-sharpen geometry sharpen the image",
263 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +0000264 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +0000265 "-sigmoidal-contrast geometry",
266 " increase the contrast without saturating highlights or shadows",
267 "-sketch geometry simulate a pencil sketch",
268 "-solarize threshold negate all pixels above the threshold level",
269 "-sparse-color method args",
270 " fill in a image based on a few color points",
271 "-splice geometry splice the background color into the image",
272 "-spread radius displace image pixels by a random amount",
cristy95c38342011-03-18 22:39:51 +0000273 "-statistic type geometry",
cristy0834d642011-03-18 18:26:08 +0000274 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +0000275 "-strip strip image of all profiles and comments",
276 "-swirl degrees swirl image pixels about the center",
277 "-threshold value threshold the image",
278 "-thumbnail geometry create a thumbnail of the image",
279 "-tile filename tile image when filling a graphic primitive",
280 "-tint value tint the image with the fill color",
281 "-transform affine transform image",
282 "-transparent color make this color transparent within the image",
283 "-transpose flip image vertically and rotate 90 degrees",
284 "-transverse flop image horizontally and rotate 270 degrees",
285 "-trim trim image edges",
286 "-type type image type",
287 "-unique-colors discard all but one of any pixel color",
288 "-unsharp geometry sharpen the image",
289 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +0000290 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +0000291 "-white-threshold value",
292 " force all pixels above the threshold into white",
293 (char *) NULL
294 },
295 *sequence_operators[]=
296 {
cristy4285d782011-02-09 20:12:28 +0000297 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +0000298 "-clut apply a color lookup table to the image",
299 "-coalesce merge a sequence of images",
300 "-combine combine a sequence of images",
301 "-composite composite image",
302 "-crop geometry cut out a rectangular region of the image",
303 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +0000304 "-evaluate-sequence operator",
305 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +0000306 "-flatten flatten a sequence of images",
307 "-fx expression apply mathematical expression to an image channel(s)",
308 "-hald-clut apply a Hald color lookup table to the image",
309 "-morph value morph an image sequence",
310 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +0000311 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +0000312 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +0000313 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +0000314 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +0000315 "-write filename write images to this file",
316 (char *) NULL
317 },
318 *settings[]=
319 {
320 "-adjoin join images into a single multi-image file",
321 "-affine matrix affine transform matrix",
322 "-alpha option activate, deactivate, reset, or set the alpha channel",
323 "-antialias remove pixel-aliasing",
324 "-authenticate password",
325 " decipher image with this password",
326 "-attenuate value lessen (or intensify) when adding noise to an image",
327 "-background color background color",
328 "-bias value add bias when convolving an image",
329 "-black-point-compensation",
330 " use black point compensation",
331 "-blue-primary point chromaticity blue primary point",
332 "-bordercolor color border color",
333 "-caption string assign a caption to an image",
334 "-channel type apply option to select image channels",
335 "-colors value preferred number of colors in the image",
336 "-colorspace type alternate image colorspace",
337 "-comment string annotate image with comment",
338 "-compose operator set image composite operator",
339 "-compress type type of pixel compression when writing the image",
340 "-define format:option",
341 " define one or more image format options",
342 "-delay value display the next image after pausing",
343 "-density geometry horizontal and vertical density of the image",
344 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +0000345 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +0000346 "-display server get image or font from this X server",
347 "-dispose method layer disposal method",
348 "-dither method apply error diffusion to image",
349 "-encoding type text encoding type",
350 "-endian type endianness (MSB or LSB) of the image",
351 "-family name render text with this font family",
352 "-fill color color to use when filling a graphic primitive",
353 "-filter type use this filter when resizing an image",
354 "-font name render text with this font",
355 "-format \"string\" output formatted image characteristics",
356 "-fuzz distance colors within this distance are considered equal",
357 "-gravity type horizontal and vertical text placement",
358 "-green-primary point chromaticity green primary point",
359 "-intent type type of rendering intent when managing the image color",
360 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +0000361 "-interline-spacing value",
362 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +0000363 "-interpolate method pixel color interpolation method",
364 "-interword-spacing value",
365 " set the space between two words",
366 "-kerning value set the space between two letters",
367 "-label string assign a label to an image",
368 "-limit type value pixel cache resource limit",
369 "-loop iterations add Netscape loop extension to your GIF animation",
370 "-mask filename associate a mask with the image",
371 "-mattecolor color frame color",
372 "-monitor monitor progress",
373 "-orient type image orientation",
374 "-page geometry size and location of an image canvas (setting)",
375 "-ping efficiently determine image attributes",
376 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +0000377 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +0000378 "-preview type image preview type",
379 "-quality value JPEG/MIFF/PNG compression level",
380 "-quiet suppress all warning messages",
381 "-red-primary point chromaticity red primary point",
382 "-regard-warnings pay attention to warning messages",
383 "-remap filename transform image colors to match this set of colors",
384 "-respect-parentheses settings remain in effect until parenthesis boundary",
385 "-sampling-factor geometry",
386 " horizontal and vertical sampling factor",
387 "-scene value image scene number",
388 "-seed value seed a new sequence of pseudo-random numbers",
389 "-size geometry width and height of image",
390 "-stretch type render text with this font stretch",
391 "-stroke color graphic primitive stroke color",
392 "-strokewidth value graphic primitive stroke width",
393 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +0000394 "-synchronize synchronize image to storage device",
395 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +0000396 "-texture filename name of texture to tile onto the image background",
397 "-tile-offset geometry",
398 " tile offset",
399 "-treedepth value color tree depth",
400 "-transparent-color color",
401 " transparent color",
402 "-undercolor color annotation bounding box color",
403 "-units type the units of image resolution",
404 "-verbose print detailed information about the image",
405 "-view FlashPix viewing transforms",
406 "-virtual-pixel method",
407 " virtual pixel access method",
408 "-weight type render text with this font weight",
409 "-white-point point chromaticity white point",
410 (char *) NULL
411 },
412 *stack_operators[]=
413 {
anthonyb69c4b32011-03-23 04:37:44 +0000414 "-clone indexes clone an image",
415 "-delete indexes delete the image from the image sequence",
416 "-duplicate count,indexes",
cristy5d28d482011-03-20 21:59:40 +0000417 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +0000418 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +0000419 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +0000420 "-swap indexes swap two images in the image sequence",
421 (char *) NULL
422 };
423
424 const char
425 **p;
426
cristybb503372010-05-27 20:51:26 +0000427 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +0000428 (void) printf("Copyright: %s\n",GetMagickCopyright());
429 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000430 (void) printf("Usage: %s [options ...] file [ [options ...] "
431 "file ...] [options ...] file\n",GetClientName());
432 (void) printf("\nImage Settings:\n");
433 for (p=settings; *p != (char *) NULL; p++)
434 (void) printf(" %s\n",*p);
435 (void) printf("\nImage Operators:\n");
436 for (p=operators; *p != (char *) NULL; p++)
437 (void) printf(" %s\n",*p);
438 (void) printf("\nImage Sequence Operators:\n");
439 for (p=sequence_operators; *p != (char *) NULL; p++)
440 (void) printf(" %s\n",*p);
441 (void) printf("\nImage Stack Operators:\n");
442 for (p=stack_operators; *p != (char *) NULL; p++)
443 (void) printf(" %s\n",*p);
444 (void) printf("\nMiscellaneous Options:\n");
445 for (p=miscellaneous; *p != (char *) NULL; p++)
446 (void) printf(" %s\n",*p);
447 (void) printf(
448 "\nBy default, the image format of `file' is determined by its magic\n");
449 (void) printf(
450 "number. To specify a particular image format, precede the filename\n");
451 (void) printf(
452 "with an image format name and a colon (i.e. ps:image) or specify the\n");
453 (void) printf(
454 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
455 (void) printf("'-' for standard input or output.\n");
456 return(MagickFalse);
457}
458
459WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
460 int argc,char **argv,char **metadata,ExceptionInfo *exception)
461{
462#define NotInitialized (unsigned int) (~0)
463#define DestroyConvert() \
464{ \
465 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +0000466 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +0000467 argv[i]=DestroyString(argv[i]); \
468 argv=(char **) RelinquishMagickMemory(argv); \
469}
470#define ThrowConvertException(asperity,tag,option) \
471{ \
472 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
473 option); \
474 DestroyConvert(); \
475 return(MagickFalse); \
476}
477#define ThrowConvertInvalidArgumentException(option,argument) \
478{ \
479 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
480 "InvalidArgument","`%s': %s",option,argument); \
481 DestroyConvert(); \
482 return(MagickFalse); \
483}
484
485 char
486 *filename,
487 *option;
488
489 const char
490 *format;
491
492 Image
493 *image;
494
495 ImageStack
496 image_stack[MaxImageStackDepth+1];
497
cristy3ed852e2009-09-05 21:47:34 +0000498 MagickBooleanType
499 fire,
cristyebbcfea2011-02-25 02:43:54 +0000500 pend,
501 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +0000502
503 MagickStatusType
504 status;
505
cristybb503372010-05-27 20:51:26 +0000506 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000507 i;
508
cristy9d314ff2011-03-09 01:30:28 +0000509 ssize_t
510 j,
511 k;
512
cristy3ed852e2009-09-05 21:47:34 +0000513 /*
514 Set defaults.
515 */
516 assert(image_info != (ImageInfo *) NULL);
517 assert(image_info->signature == MagickSignature);
518 if (image_info->debug != MagickFalse)
519 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
520 assert(exception != (ExceptionInfo *) NULL);
521 if (argc == 2)
522 {
523 option=argv[1];
524 if ((LocaleCompare("version",option+1) == 0) ||
525 (LocaleCompare("-version",option+1) == 0))
526 {
cristyb51dff52011-05-19 16:55:47 +0000527 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +0000528 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +0000529 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
530 GetMagickCopyright());
531 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
532 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000533 return(MagickFalse);
534 }
535 }
536 if (argc < 3)
cristy13e61a12010-02-04 20:19:00 +0000537 return(ConvertUsage());
cristy3ed852e2009-09-05 21:47:34 +0000538 filename=(char *) NULL;
539 format="%w,%h,%m";
540 j=1;
541 k=0;
542 NewImageStack();
543 option=(char *) NULL;
544 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +0000545 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000546 status=MagickTrue;
547 /*
548 Parse command-line arguments.
549 */
550 ReadCommandlLine(argc,&argv);
551 status=ExpandFilenames(&argc,&argv);
552 if (status == MagickFalse)
553 ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
554 GetExceptionMessage(errno));
555 if ((argc > 2) && (LocaleCompare("-concatenate",argv[1]) == 0))
556 return(ConcatenateImages(argc,argv,exception));
cristybb503372010-05-27 20:51:26 +0000557 for (i=1; i < (ssize_t) (argc-1); i++)
cristy3ed852e2009-09-05 21:47:34 +0000558 {
559 option=argv[i];
560 if (LocaleCompare(option,"(") == 0)
561 {
562 FireImageStack(MagickTrue,MagickTrue,pend);
563 if (k == MaxImageStackDepth)
564 ThrowConvertException(OptionError,"ParenthesisNestedTooDeeply",
565 option);
566 PushImageStack();
567 continue;
568 }
569 if (LocaleCompare(option,")") == 0)
570 {
571 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
572 if (k == 0)
573 ThrowConvertException(OptionError,"UnableToParseExpression",option);
574 PopImageStack();
575 continue;
576 }
cristy042ee782011-04-22 18:48:30 +0000577 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000578 {
579 Image
580 *images;
581
582 /*
583 Read input image.
584 */
585 FireImageStack(MagickTrue,MagickTrue,pend);
586 filename=argv[i];
cristycee97112010-05-28 00:44:52 +0000587 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +0000588 filename=argv[++i];
589 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
590 if (image_info->ping != MagickFalse)
591 images=PingImages(image_info,exception);
592 else
593 images=ReadImages(image_info,exception);
594 status&=(images != (Image *) NULL) &&
595 (exception->severity < ErrorException);
596 if (images == (Image *) NULL)
597 continue;
598 AppendImageStack(images);
599 continue;
600 }
601 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
602 switch (*(option+1))
603 {
604 case 'a':
605 {
606 if (LocaleCompare("adaptive-blur",option+1) == 0)
607 {
608 i++;
cristybb503372010-05-27 20:51:26 +0000609 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000610 ThrowConvertException(OptionError,"MissingArgument",option);
611 if (IsGeometry(argv[i]) == MagickFalse)
612 ThrowConvertInvalidArgumentException(option,argv[i]);
613 break;
614 }
615 if (LocaleCompare("adaptive-resize",option+1) == 0)
616 {
617 i++;
cristybb503372010-05-27 20:51:26 +0000618 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000619 ThrowConvertException(OptionError,"MissingArgument",option);
620 if (IsGeometry(argv[i]) == MagickFalse)
621 ThrowConvertInvalidArgumentException(option,argv[i]);
622 break;
623 }
624 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
625 {
626 i++;
cristybb503372010-05-27 20:51:26 +0000627 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000628 ThrowConvertException(OptionError,"MissingArgument",option);
629 if (IsGeometry(argv[i]) == MagickFalse)
630 ThrowConvertInvalidArgumentException(option,argv[i]);
631 break;
632 }
633 if (LocaleCompare("adjoin",option+1) == 0)
634 break;
635 if (LocaleCompare("affine",option+1) == 0)
636 {
637 if (*option == '+')
638 break;
639 i++;
cristybb503372010-05-27 20:51:26 +0000640 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000641 ThrowConvertException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +0000642 break;
643 }
644 if (LocaleCompare("alpha",option+1) == 0)
645 {
cristybb503372010-05-27 20:51:26 +0000646 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000647 type;
648
649 if (*option == '+')
650 break;
651 i++;
cristybb503372010-05-27 20:51:26 +0000652 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000653 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000654 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000655 if (type < 0)
656 ThrowConvertException(OptionError,"UnrecognizedAlphaChannelType",
657 argv[i]);
658 break;
659 }
660 if (LocaleCompare("annotate",option+1) == 0)
661 {
662 if (*option == '+')
663 break;
664 i++;
cristybb503372010-05-27 20:51:26 +0000665 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000666 ThrowConvertException(OptionError,"MissingArgument",option);
667 if (IsGeometry(argv[i]) == MagickFalse)
668 ThrowConvertInvalidArgumentException(option,argv[i]);
669 i++;
cristybb503372010-05-27 20:51:26 +0000670 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000671 ThrowConvertException(OptionError,"MissingArgument",option);
672 break;
673 }
674 if (LocaleCompare("antialias",option+1) == 0)
675 break;
676 if (LocaleCompare("append",option+1) == 0)
677 break;
678 if (LocaleCompare("attenuate",option+1) == 0)
679 {
680 if (*option == '+')
681 break;
682 i++;
cristybb503372010-05-27 20:51:26 +0000683 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000684 ThrowConvertException(OptionError,"MissingArgument",option);
685 if (IsGeometry(argv[i]) == MagickFalse)
686 ThrowConvertInvalidArgumentException(option,argv[i]);
687 break;
688 }
689 if (LocaleCompare("authenticate",option+1) == 0)
690 {
691 if (*option == '+')
692 break;
693 i++;
cristybb503372010-05-27 20:51:26 +0000694 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000695 ThrowConvertException(OptionError,"MissingArgument",option);
696 break;
697 }
698 if (LocaleCompare("auto-gamma",option+1) == 0)
699 break;
700 if (LocaleCompare("auto-level",option+1) == 0)
701 break;
702 if (LocaleCompare("auto-orient",option+1) == 0)
703 break;
704 if (LocaleCompare("average",option+1) == 0)
705 break;
706 ThrowConvertException(OptionError,"UnrecognizedOption",option)
707 }
708 case 'b':
709 {
710 if (LocaleCompare("background",option+1) == 0)
711 {
712 if (*option == '+')
713 break;
714 i++;
cristybb503372010-05-27 20:51:26 +0000715 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000716 ThrowConvertException(OptionError,"MissingArgument",option);
717 break;
718 }
719 if (LocaleCompare("bench",option+1) == 0)
720 {
721 if (*option == '+')
722 break;
723 i++;
cristybb503372010-05-27 20:51:26 +0000724 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000725 ThrowConvertException(OptionError,"MissingArgument",option);
726 if (IsGeometry(argv[i]) == MagickFalse)
727 ThrowConvertInvalidArgumentException(option,argv[i]);
728 break;
729 }
730 if (LocaleCompare("bias",option+1) == 0)
731 {
732 if (*option == '+')
733 break;
734 i++;
cristybb503372010-05-27 20:51:26 +0000735 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000736 ThrowConvertException(OptionError,"MissingArgument",option);
737 if (IsGeometry(argv[i]) == MagickFalse)
738 ThrowConvertInvalidArgumentException(option,argv[i]);
739 break;
740 }
741 if (LocaleCompare("black-point-compensation",option+1) == 0)
742 break;
743 if (LocaleCompare("black-threshold",option+1) == 0)
744 {
745 if (*option == '+')
746 break;
747 i++;
cristybb503372010-05-27 20:51:26 +0000748 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000749 ThrowConvertException(OptionError,"MissingArgument",option);
750 if (IsGeometry(argv[i]) == MagickFalse)
751 ThrowConvertInvalidArgumentException(option,argv[i]);
752 break;
753 }
754 if (LocaleCompare("blue-primary",option+1) == 0)
755 {
756 if (*option == '+')
757 break;
758 i++;
cristybb503372010-05-27 20:51:26 +0000759 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000760 ThrowConvertException(OptionError,"MissingArgument",option);
761 if (IsGeometry(argv[i]) == MagickFalse)
762 ThrowConvertInvalidArgumentException(option,argv[i]);
763 break;
764 }
765 if (LocaleCompare("blue-shift",option+1) == 0)
766 {
767 if (*option == '+')
768 break;
769 i++;
cristybb503372010-05-27 20:51:26 +0000770 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000771 ThrowConvertException(OptionError,"MissingArgument",option);
772 if (IsGeometry(argv[i]) == MagickFalse)
773 ThrowConvertInvalidArgumentException(option,argv[i]);
774 break;
775 }
776 if (LocaleCompare("blur",option+1) == 0)
777 {
778 if (*option == '+')
779 break;
780 i++;
cristybb503372010-05-27 20:51:26 +0000781 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000782 ThrowConvertException(OptionError,"MissingArgument",option);
783 if (IsGeometry(argv[i]) == MagickFalse)
784 ThrowConvertInvalidArgumentException(option,argv[i]);
785 break;
786 }
787 if (LocaleCompare("border",option+1) == 0)
788 {
789 if (*option == '+')
790 break;
791 i++;
cristybb503372010-05-27 20:51:26 +0000792 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000793 ThrowConvertException(OptionError,"MissingArgument",option);
794 if (IsGeometry(argv[i]) == MagickFalse)
795 ThrowConvertInvalidArgumentException(option,argv[i]);
796 break;
797 }
798 if (LocaleCompare("bordercolor",option+1) == 0)
799 {
800 if (*option == '+')
801 break;
802 i++;
cristybb503372010-05-27 20:51:26 +0000803 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000804 ThrowConvertException(OptionError,"MissingArgument",option);
805 break;
806 }
807 if (LocaleCompare("box",option+1) == 0)
808 {
809 if (*option == '+')
810 break;
811 i++;
cristybb503372010-05-27 20:51:26 +0000812 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000813 ThrowConvertException(OptionError,"MissingArgument",option);
814 break;
815 }
cristya28d6b82010-01-11 20:03:47 +0000816 if (LocaleCompare("brightness-contrast",option+1) == 0)
817 {
818 i++;
cristybb503372010-05-27 20:51:26 +0000819 if (i == (ssize_t) (argc-1))
cristya28d6b82010-01-11 20:03:47 +0000820 ThrowConvertException(OptionError,"MissingArgument",option);
821 if (IsGeometry(argv[i]) == MagickFalse)
822 ThrowConvertInvalidArgumentException(option,argv[i]);
823 break;
824 }
cristy3ed852e2009-09-05 21:47:34 +0000825 ThrowConvertException(OptionError,"UnrecognizedOption",option)
826 }
827 case 'c':
828 {
829 if (LocaleCompare("cache",option+1) == 0)
830 {
831 if (*option == '+')
832 break;
833 i++;
cristybb503372010-05-27 20:51:26 +0000834 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000835 ThrowConvertException(OptionError,"MissingArgument",option);
836 if (IsGeometry(argv[i]) == MagickFalse)
837 ThrowConvertInvalidArgumentException(option,argv[i]);
838 break;
839 }
840 if (LocaleCompare("caption",option+1) == 0)
841 {
842 if (*option == '+')
843 break;
844 i++;
cristybb503372010-05-27 20:51:26 +0000845 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000846 ThrowConvertException(OptionError,"MissingArgument",option);
847 break;
848 }
849 if (LocaleCompare("cdl",option+1) == 0)
850 {
851 if (*option == '+')
852 break;
853 i++;
cristybb503372010-05-27 20:51:26 +0000854 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000855 ThrowConvertException(OptionError,"MissingArgument",option);
856 break;
857 }
858 if (LocaleCompare("channel",option+1) == 0)
859 {
cristybb503372010-05-27 20:51:26 +0000860 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000861 channel;
862
863 if (*option == '+')
864 break;
865 i++;
cristybb503372010-05-27 20:51:26 +0000866 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000867 ThrowConvertException(OptionError,"MissingArgument",option);
868 channel=ParseChannelOption(argv[i]);
869 if (channel < 0)
870 ThrowConvertException(OptionError,"UnrecognizedChannelType",
871 argv[i]);
872 break;
873 }
874 if (LocaleCompare("charcoal",option+1) == 0)
875 {
876 if (*option == '+')
877 break;
878 i++;
cristybb503372010-05-27 20:51:26 +0000879 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000880 ThrowConvertException(OptionError,"MissingArgument",option);
881 if (IsGeometry(argv[i]) == MagickFalse)
882 ThrowConvertInvalidArgumentException(option,argv[i]);
883 break;
884 }
885 if (LocaleCompare("chop",option+1) == 0)
886 {
887 if (*option == '+')
888 break;
889 i++;
cristybb503372010-05-27 20:51:26 +0000890 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000891 ThrowConvertException(OptionError,"MissingArgument",option);
892 if (IsGeometry(argv[i]) == MagickFalse)
893 ThrowConvertInvalidArgumentException(option,argv[i]);
894 break;
895 }
cristy1eb45dd2009-09-25 16:38:06 +0000896 if (LocaleCompare("clamp",option+1) == 0)
897 break;
cristy3ed852e2009-09-05 21:47:34 +0000898 if (LocaleCompare("clip",option+1) == 0)
899 break;
900 if (LocaleCompare("clip-mask",option+1) == 0)
901 {
902 if (*option == '+')
903 break;
904 i++;
cristybb503372010-05-27 20:51:26 +0000905 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000906 ThrowConvertException(OptionError,"MissingArgument",option);
907 break;
908 }
909 if (LocaleCompare("clip-path",option+1) == 0)
910 {
911 i++;
cristybb503372010-05-27 20:51:26 +0000912 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000913 ThrowConvertException(OptionError,"MissingArgument",option);
914 break;
915 }
916 if (LocaleCompare("clone",option+1) == 0)
917 {
918 Image
919 *clone_images;
920
921 clone_images=image;
922 if (k != 0)
923 clone_images=image_stack[k-1].image;
924 if (clone_images == (Image *) NULL)
925 ThrowConvertException(ImageError,"ImageSequenceRequired",option);
926 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
927 if (*option == '+')
928 clone_images=CloneImages(clone_images,"-1",exception);
929 else
930 {
931 i++;
cristybb503372010-05-27 20:51:26 +0000932 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000933 ThrowConvertException(OptionError,"MissingArgument",option);
934 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
935 ThrowConvertInvalidArgumentException(option,argv[i]);
936 clone_images=CloneImages(clone_images,argv[i],exception);
937 }
938 if (clone_images == (Image *) NULL)
939 ThrowConvertException(OptionError,"NoSuchImage",option);
940 AppendImageStack(clone_images);
941 break;
942 }
943 if (LocaleCompare("clut",option+1) == 0)
944 break;
945 if (LocaleCompare("coalesce",option+1) == 0)
946 break;
947 if (LocaleCompare("colorize",option+1) == 0)
948 {
949 if (*option == '+')
950 break;
951 i++;
cristybb503372010-05-27 20:51:26 +0000952 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000953 ThrowConvertException(OptionError,"MissingArgument",option);
954 if (IsGeometry(argv[i]) == MagickFalse)
955 ThrowConvertInvalidArgumentException(option,argv[i]);
956 break;
957 }
cristye6365592010-04-02 17:31:23 +0000958 if (LocaleCompare("color-matrix",option+1) == 0)
959 {
cristyb6bd4ad2010-08-08 01:12:27 +0000960 KernelInfo
961 *kernel_info;
962
cristye6365592010-04-02 17:31:23 +0000963 if (*option == '+')
964 break;
965 i++;
cristybb503372010-05-27 20:51:26 +0000966 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +0000967 ThrowConvertException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +0000968 kernel_info=AcquireKernelInfo(argv[i]);
969 if (kernel_info == (KernelInfo *) NULL)
cristye6365592010-04-02 17:31:23 +0000970 ThrowConvertInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +0000971 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +0000972 break;
973 }
cristy3ed852e2009-09-05 21:47:34 +0000974 if (LocaleCompare("colors",option+1) == 0)
975 {
976 if (*option == '+')
977 break;
978 i++;
cristybb503372010-05-27 20:51:26 +0000979 if ((i == (ssize_t) (argc-1)) ||
cristy3ed852e2009-09-05 21:47:34 +0000980 (IsGeometry(argv[i]) == MagickFalse))
981 ThrowConvertException(OptionError,"MissingArgument",option);
982 break;
983 }
984 if (LocaleCompare("colorspace",option+1) == 0)
985 {
cristybb503372010-05-27 20:51:26 +0000986 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000987 colorspace;
988
989 if (*option == '+')
990 break;
991 i++;
cristybb503372010-05-27 20:51:26 +0000992 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000993 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000994 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000995 MagickFalse,argv[i]);
996 if (colorspace < 0)
997 ThrowConvertException(OptionError,"UnrecognizedColorspace",
998 argv[i]);
999 break;
1000 }
1001 if (LocaleCompare("combine",option+1) == 0)
1002 break;
1003 if (LocaleCompare("comment",option+1) == 0)
1004 {
1005 if (*option == '+')
1006 break;
1007 i++;
cristybb503372010-05-27 20:51:26 +00001008 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001009 ThrowConvertException(OptionError,"MissingArgument",option);
1010 break;
1011 }
1012 if (LocaleCompare("compose",option+1) == 0)
1013 {
cristybb503372010-05-27 20:51:26 +00001014 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001015 compose;
1016
1017 if (*option == '+')
1018 break;
1019 i++;
cristybb503372010-05-27 20:51:26 +00001020 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001021 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001022 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001023 argv[i]);
1024 if (compose < 0)
1025 ThrowConvertException(OptionError,"UnrecognizedComposeOperator",
1026 argv[i]);
1027 break;
1028 }
1029 if (LocaleCompare("composite",option+1) == 0)
1030 break;
1031 if (LocaleCompare("compress",option+1) == 0)
1032 {
cristybb503372010-05-27 20:51:26 +00001033 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001034 compress;
1035
1036 if (*option == '+')
1037 break;
1038 i++;
cristybb503372010-05-27 20:51:26 +00001039 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001040 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001041 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001042 argv[i]);
1043 if (compress < 0)
1044 ThrowConvertException(OptionError,"UnrecognizedImageCompression",
1045 argv[i]);
1046 break;
1047 }
cristy22879752009-10-25 23:55:40 +00001048 if (LocaleCompare("concurrent",option+1) == 0)
1049 break;
cristy3ed852e2009-09-05 21:47:34 +00001050 if (LocaleCompare("contrast",option+1) == 0)
1051 break;
1052 if (LocaleCompare("contrast-stretch",option+1) == 0)
1053 {
1054 i++;
cristybb503372010-05-27 20:51:26 +00001055 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001056 ThrowConvertException(OptionError,"MissingArgument",option);
1057 if (IsGeometry(argv[i]) == MagickFalse)
1058 ThrowConvertInvalidArgumentException(option,argv[i]);
1059 break;
1060 }
1061 if (LocaleCompare("convolve",option+1) == 0)
1062 {
cristyb6bd4ad2010-08-08 01:12:27 +00001063 KernelInfo
1064 *kernel_info;
1065
cristy3ed852e2009-09-05 21:47:34 +00001066 if (*option == '+')
1067 break;
1068 i++;
cristybb503372010-05-27 20:51:26 +00001069 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001070 ThrowConvertException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00001071 kernel_info=AcquireKernelInfo(argv[i]);
1072 if (kernel_info == (KernelInfo *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001073 ThrowConvertInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00001074 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00001075 break;
1076 }
1077 if (LocaleCompare("crop",option+1) == 0)
1078 {
1079 if (*option == '+')
1080 break;
1081 i++;
cristybb503372010-05-27 20:51:26 +00001082 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001083 ThrowConvertException(OptionError,"MissingArgument",option);
1084 if (IsGeometry(argv[i]) == MagickFalse)
1085 ThrowConvertInvalidArgumentException(option,argv[i]);
1086 break;
1087 }
1088 if (LocaleCompare("cycle",option+1) == 0)
1089 {
1090 if (*option == '+')
1091 break;
1092 i++;
cristybb503372010-05-27 20:51:26 +00001093 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001094 ThrowConvertException(OptionError,"MissingArgument",option);
1095 if (IsGeometry(argv[i]) == MagickFalse)
1096 ThrowConvertInvalidArgumentException(option,argv[i]);
1097 break;
1098 }
1099 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1100 }
1101 case 'd':
1102 {
1103 if (LocaleCompare("decipher",option+1) == 0)
1104 {
1105 if (*option == '+')
1106 break;
1107 i++;
cristybb503372010-05-27 20:51:26 +00001108 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001109 ThrowConvertException(OptionError,"MissingArgument",option);
1110 break;
1111 }
1112 if (LocaleCompare("deconstruct",option+1) == 0)
1113 break;
1114 if (LocaleCompare("debug",option+1) == 0)
1115 {
cristybb503372010-05-27 20:51:26 +00001116 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001117 event;
1118
1119 if (*option == '+')
1120 break;
1121 i++;
cristybb503372010-05-27 20:51:26 +00001122 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001123 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001124 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001125 if (event < 0)
1126 ThrowConvertException(OptionError,"UnrecognizedEventType",
1127 argv[i]);
1128 (void) SetLogEventMask(argv[i]);
1129 break;
1130 }
1131 if (LocaleCompare("define",option+1) == 0)
1132 {
1133 i++;
cristybb503372010-05-27 20:51:26 +00001134 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001135 ThrowConvertException(OptionError,"MissingArgument",option);
1136 if (*option == '+')
1137 {
1138 const char
1139 *define;
1140
1141 define=GetImageOption(image_info,argv[i]);
1142 if (define == (const char *) NULL)
1143 ThrowConvertException(OptionError,"NoSuchOption",argv[i]);
1144 break;
1145 }
1146 break;
1147 }
1148 if (LocaleCompare("delay",option+1) == 0)
1149 {
1150 if (*option == '+')
1151 break;
1152 i++;
cristybb503372010-05-27 20:51:26 +00001153 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001154 ThrowConvertException(OptionError,"MissingArgument",option);
1155 if (IsGeometry(argv[i]) == MagickFalse)
1156 ThrowConvertInvalidArgumentException(option,argv[i]);
1157 break;
1158 }
1159 if (LocaleCompare("density",option+1) == 0)
1160 {
1161 if (*option == '+')
1162 break;
1163 i++;
cristybb503372010-05-27 20:51:26 +00001164 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001165 ThrowConvertException(OptionError,"MissingArgument",option);
1166 if (IsGeometry(argv[i]) == MagickFalse)
1167 ThrowConvertInvalidArgumentException(option,argv[i]);
1168 break;
1169 }
1170 if (LocaleCompare("depth",option+1) == 0)
1171 {
1172 if (*option == '+')
1173 break;
1174 i++;
cristybb503372010-05-27 20:51:26 +00001175 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001176 ThrowConvertException(OptionError,"MissingArgument",option);
1177 if (IsGeometry(argv[i]) == MagickFalse)
1178 ThrowConvertInvalidArgumentException(option,argv[i]);
1179 break;
1180 }
1181 if (LocaleCompare("delete",option+1) == 0)
1182 {
1183 if (*option == '+')
1184 break;
1185 i++;
cristybb503372010-05-27 20:51:26 +00001186 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001187 ThrowConvertException(OptionError,"MissingArgument",option);
1188 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1189 ThrowConvertInvalidArgumentException(option,argv[i]);
1190 break;
1191 }
1192 if (LocaleCompare("deskew",option+1) == 0)
1193 {
1194 if (*option == '+')
1195 break;
1196 i++;
cristybb503372010-05-27 20:51:26 +00001197 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001198 ThrowConvertException(OptionError,"MissingArgument",option);
1199 if (IsGeometry(argv[i]) == MagickFalse)
1200 ThrowConvertInvalidArgumentException(option,argv[i]);
1201 break;
1202 }
1203 if (LocaleCompare("despeckle",option+1) == 0)
1204 break;
cristyc9b12952010-03-28 01:12:28 +00001205 if (LocaleCompare("direction",option+1) == 0)
1206 {
cristybb503372010-05-27 20:51:26 +00001207 ssize_t
cristyc9b12952010-03-28 01:12:28 +00001208 direction;
1209
1210 if (*option == '+')
1211 break;
1212 i++;
cristybb503372010-05-27 20:51:26 +00001213 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00001214 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001215 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00001216 argv[i]);
1217 if (direction < 0)
1218 ThrowConvertException(OptionError,"UnrecognizedDirectionType",
1219 argv[i]);
1220 break;
1221 }
cristy3ed852e2009-09-05 21:47:34 +00001222 if (LocaleCompare("display",option+1) == 0)
1223 {
1224 if (*option == '+')
1225 break;
1226 i++;
cristybb503372010-05-27 20:51:26 +00001227 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001228 ThrowConvertException(OptionError,"MissingArgument",option);
1229 break;
1230 }
1231 if (LocaleCompare("dispose",option+1) == 0)
1232 {
cristybb503372010-05-27 20:51:26 +00001233 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001234 dispose;
1235
1236 if (*option == '+')
1237 break;
1238 i++;
cristybb503372010-05-27 20:51:26 +00001239 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001240 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001241 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001242 if (dispose < 0)
1243 ThrowConvertException(OptionError,"UnrecognizedDisposeMethod",
1244 argv[i]);
1245 break;
1246 }
1247 if (LocaleCompare("distort",option+1) == 0)
1248 {
cristybb503372010-05-27 20:51:26 +00001249 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001250 op;
1251
1252 i++;
cristybb503372010-05-27 20:51:26 +00001253 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001254 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001255 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001256 if (op < 0)
1257 ThrowConvertException(OptionError,"UnrecognizedDistortMethod",
1258 argv[i]);
1259 i++;
cristybb503372010-05-27 20:51:26 +00001260 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001261 ThrowConvertException(OptionError,"MissingArgument",option);
1262 break;
1263 }
1264 if (LocaleCompare("dither",option+1) == 0)
1265 {
cristybb503372010-05-27 20:51:26 +00001266 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001267 method;
1268
1269 if (*option == '+')
1270 break;
1271 i++;
cristybb503372010-05-27 20:51:26 +00001272 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001273 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001274 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001275 if (method < 0)
1276 ThrowConvertException(OptionError,"UnrecognizedDitherMethod",
1277 argv[i]);
1278 break;
1279 }
1280 if (LocaleCompare("draw",option+1) == 0)
1281 {
1282 if (*option == '+')
1283 break;
1284 i++;
cristybb503372010-05-27 20:51:26 +00001285 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001286 ThrowConvertException(OptionError,"MissingArgument",option);
1287 break;
1288 }
cristy5d28d482011-03-20 21:59:40 +00001289 if (LocaleCompare("duplicate",option+1) == 0)
1290 {
cristy5d28d482011-03-20 21:59:40 +00001291 if (*option == '+')
cristyecb10ff2011-03-22 13:14:03 +00001292 break;
1293 i++;
1294 if (i == (ssize_t) (argc-1))
1295 ThrowConvertException(OptionError,"MissingArgument",option);
1296 if (IsGeometry(argv[i]) == MagickFalse)
1297 ThrowConvertInvalidArgumentException(option,argv[i]);
cristy5d28d482011-03-20 21:59:40 +00001298 break;
1299 }
cristy22879752009-10-25 23:55:40 +00001300 if (LocaleCompare("duration",option+1) == 0)
1301 {
1302 if (*option == '+')
1303 break;
1304 i++;
cristybb503372010-05-27 20:51:26 +00001305 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00001306 ThrowConvertException(OptionError,"MissingArgument",option);
1307 if (IsGeometry(argv[i]) == MagickFalse)
1308 ThrowConvertInvalidArgumentException(option,argv[i]);
1309 break;
1310 }
cristy3ed852e2009-09-05 21:47:34 +00001311 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1312 }
1313 case 'e':
1314 {
1315 if (LocaleCompare("edge",option+1) == 0)
1316 {
1317 if (*option == '+')
1318 break;
1319 i++;
cristybb503372010-05-27 20:51:26 +00001320 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001321 ThrowConvertException(OptionError,"MissingArgument",option);
1322 if (IsGeometry(argv[i]) == MagickFalse)
1323 ThrowConvertInvalidArgumentException(option,argv[i]);
1324 break;
1325 }
1326 if (LocaleCompare("emboss",option+1) == 0)
1327 {
1328 if (*option == '+')
1329 break;
1330 i++;
cristybb503372010-05-27 20:51:26 +00001331 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001332 ThrowConvertException(OptionError,"MissingArgument",option);
1333 if (IsGeometry(argv[i]) == MagickFalse)
1334 ThrowConvertInvalidArgumentException(option,argv[i]);
1335 break;
1336 }
1337 if (LocaleCompare("encipher",option+1) == 0)
1338 {
1339 if (*option == '+')
1340 break;
1341 i++;
cristybb503372010-05-27 20:51:26 +00001342 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001343 ThrowConvertException(OptionError,"MissingArgument",option);
1344 break;
1345 }
1346 if (LocaleCompare("encoding",option+1) == 0)
1347 {
1348 if (*option == '+')
1349 break;
1350 i++;
cristybb503372010-05-27 20:51:26 +00001351 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001352 ThrowConvertException(OptionError,"MissingArgument",option);
1353 break;
1354 }
1355 if (LocaleCompare("endian",option+1) == 0)
1356 {
cristybb503372010-05-27 20:51:26 +00001357 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001358 endian;
1359
1360 if (*option == '+')
1361 break;
1362 i++;
cristybb503372010-05-27 20:51:26 +00001363 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001364 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001365 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001366 argv[i]);
1367 if (endian < 0)
1368 ThrowConvertException(OptionError,"UnrecognizedEndianType",
1369 argv[i]);
1370 break;
1371 }
1372 if (LocaleCompare("enhance",option+1) == 0)
1373 break;
1374 if (LocaleCompare("equalize",option+1) == 0)
1375 break;
1376 if (LocaleCompare("evaluate",option+1) == 0)
1377 {
cristybb503372010-05-27 20:51:26 +00001378 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001379 op;
1380
1381 if (*option == '+')
1382 break;
1383 i++;
cristybb503372010-05-27 20:51:26 +00001384 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001385 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001386 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001387 if (op < 0)
1388 ThrowConvertException(OptionError,"UnrecognizedEvaluateOperator",
1389 argv[i]);
1390 i++;
cristybb503372010-05-27 20:51:26 +00001391 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001392 ThrowConvertException(OptionError,"MissingArgument",option);
1393 if (IsGeometry(argv[i]) == MagickFalse)
1394 ThrowConvertInvalidArgumentException(option,argv[i]);
1395 break;
1396 }
cristyd18ae7c2010-03-07 17:39:52 +00001397 if (LocaleCompare("evaluate-sequence",option+1) == 0)
1398 {
cristybb503372010-05-27 20:51:26 +00001399 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00001400 op;
1401
1402 if (*option == '+')
1403 break;
1404 i++;
cristybb503372010-05-27 20:51:26 +00001405 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00001406 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001407 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00001408 if (op < 0)
1409 ThrowConvertException(OptionError,"UnrecognizedEvaluateOperator",
1410 argv[i]);
1411 break;
1412 }
cristy3ed852e2009-09-05 21:47:34 +00001413 if (LocaleCompare("extent",option+1) == 0)
1414 {
1415 if (*option == '+')
1416 break;
1417 i++;
cristybb503372010-05-27 20:51:26 +00001418 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001419 ThrowConvertException(OptionError,"MissingArgument",option);
1420 if (IsGeometry(argv[i]) == MagickFalse)
1421 ThrowConvertInvalidArgumentException(option,argv[i]);
1422 break;
1423 }
1424 if (LocaleCompare("extract",option+1) == 0)
1425 {
1426 if (*option == '+')
1427 break;
1428 i++;
cristybb503372010-05-27 20:51:26 +00001429 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001430 ThrowConvertException(OptionError,"MissingArgument",option);
1431 if (IsGeometry(argv[i]) == MagickFalse)
1432 ThrowConvertInvalidArgumentException(option,argv[i]);
1433 break;
1434 }
1435 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1436 }
1437 case 'f':
1438 {
1439 if (LocaleCompare("family",option+1) == 0)
1440 {
1441 if (*option == '+')
1442 break;
1443 i++;
cristybb503372010-05-27 20:51:26 +00001444 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001445 ThrowConvertException(OptionError,"MissingArgument",option);
1446 break;
1447 }
1448 if (LocaleCompare("fft",option+1) == 0)
1449 break;
1450 if (LocaleCompare("fill",option+1) == 0)
1451 {
1452 if (*option == '+')
1453 break;
1454 i++;
cristybb503372010-05-27 20:51:26 +00001455 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001456 ThrowConvertException(OptionError,"MissingArgument",option);
1457 break;
1458 }
1459 if (LocaleCompare("filter",option+1) == 0)
1460 {
cristybb503372010-05-27 20:51:26 +00001461 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001462 filter;
1463
1464 if (*option == '+')
1465 break;
1466 i++;
cristybb503372010-05-27 20:51:26 +00001467 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001468 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001469 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001470 if (filter < 0)
1471 ThrowConvertException(OptionError,"UnrecognizedImageFilter",
1472 argv[i]);
1473 break;
1474 }
1475 if (LocaleCompare("flatten",option+1) == 0)
1476 break;
1477 if (LocaleCompare("flip",option+1) == 0)
1478 break;
1479 if (LocaleCompare("flop",option+1) == 0)
1480 break;
1481 if (LocaleCompare("floodfill",option+1) == 0)
1482 {
1483 if (*option == '+')
1484 break;
1485 i++;
cristybb503372010-05-27 20:51:26 +00001486 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001487 ThrowConvertException(OptionError,"MissingArgument",option);
1488 if (IsGeometry(argv[i]) == MagickFalse)
1489 ThrowConvertInvalidArgumentException(option,argv[i]);
1490 i++;
cristybb503372010-05-27 20:51:26 +00001491 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001492 ThrowConvertException(OptionError,"MissingArgument",option);
1493 break;
1494 }
1495 if (LocaleCompare("font",option+1) == 0)
1496 {
1497 if (*option == '+')
1498 break;
1499 i++;
cristybb503372010-05-27 20:51:26 +00001500 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001501 ThrowConvertException(OptionError,"MissingArgument",option);
1502 break;
1503 }
1504 if (LocaleCompare("format",option+1) == 0)
1505 {
1506 if (*option == '+')
1507 break;
1508 i++;
cristybb503372010-05-27 20:51:26 +00001509 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001510 ThrowConvertException(OptionError,"MissingArgument",option);
1511 format=argv[i];
1512 break;
1513 }
1514 if (LocaleCompare("frame",option+1) == 0)
1515 {
1516 if (*option == '+')
1517 break;
1518 i++;
cristybb503372010-05-27 20:51:26 +00001519 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001520 ThrowConvertException(OptionError,"MissingArgument",option);
1521 if (IsGeometry(argv[i]) == MagickFalse)
1522 ThrowConvertInvalidArgumentException(option,argv[i]);
1523 break;
1524 }
1525 if (LocaleCompare("function",option+1) == 0)
1526 {
cristybb503372010-05-27 20:51:26 +00001527 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001528 op;
1529
1530 if (*option == '+')
1531 break;
1532 i++;
cristybb503372010-05-27 20:51:26 +00001533 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001534 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001535 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001536 if (op < 0)
1537 ThrowConvertException(OptionError,"UnrecognizedFunction",argv[i]);
1538 i++;
cristybb503372010-05-27 20:51:26 +00001539 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001540 ThrowConvertException(OptionError,"MissingArgument",option);
1541 break;
1542 }
1543 if (LocaleCompare("fuzz",option+1) == 0)
1544 {
1545 if (*option == '+')
1546 break;
1547 i++;
cristybb503372010-05-27 20:51:26 +00001548 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001549 ThrowConvertException(OptionError,"MissingArgument",option);
1550 if (IsGeometry(argv[i]) == MagickFalse)
1551 ThrowConvertInvalidArgumentException(option,argv[i]);
1552 break;
1553 }
1554 if (LocaleCompare("fx",option+1) == 0)
1555 {
1556 if (*option == '+')
1557 break;
1558 i++;
cristybb503372010-05-27 20:51:26 +00001559 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001560 ThrowConvertException(OptionError,"MissingArgument",option);
1561 break;
1562 }
1563 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1564 }
1565 case 'g':
1566 {
1567 if (LocaleCompare("gamma",option+1) == 0)
1568 {
1569 i++;
cristybb503372010-05-27 20:51:26 +00001570 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001571 ThrowConvertException(OptionError,"MissingArgument",option);
1572 if (IsGeometry(argv[i]) == MagickFalse)
1573 ThrowConvertInvalidArgumentException(option,argv[i]);
1574 break;
1575 }
1576 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1577 (LocaleCompare("gaussian",option+1) == 0))
1578 {
1579 i++;
cristybb503372010-05-27 20:51:26 +00001580 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001581 ThrowConvertException(OptionError,"MissingArgument",option);
1582 if (IsGeometry(argv[i]) == MagickFalse)
1583 ThrowConvertInvalidArgumentException(option,argv[i]);
1584 break;
1585 }
1586 if (LocaleCompare("geometry",option+1) == 0)
1587 {
1588 if (*option == '+')
1589 break;
1590 i++;
cristybb503372010-05-27 20:51:26 +00001591 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001592 ThrowConvertException(OptionError,"MissingArgument",option);
1593 if (IsGeometry(argv[i]) == MagickFalse)
1594 ThrowConvertInvalidArgumentException(option,argv[i]);
1595 break;
1596 }
1597 if (LocaleCompare("gravity",option+1) == 0)
1598 {
cristybb503372010-05-27 20:51:26 +00001599 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001600 gravity;
1601
1602 if (*option == '+')
1603 break;
1604 i++;
cristybb503372010-05-27 20:51:26 +00001605 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001606 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001607 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001608 argv[i]);
1609 if (gravity < 0)
1610 ThrowConvertException(OptionError,"UnrecognizedGravityType",
1611 argv[i]);
1612 break;
1613 }
1614 if (LocaleCompare("green-primary",option+1) == 0)
1615 {
1616 if (*option == '+')
1617 break;
1618 i++;
cristybb503372010-05-27 20:51:26 +00001619 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001620 ThrowConvertException(OptionError,"MissingArgument",option);
1621 if (IsGeometry(argv[i]) == MagickFalse)
1622 ThrowConvertInvalidArgumentException(option,argv[i]);
1623 break;
1624 }
1625 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1626 }
1627 case 'h':
1628 {
1629 if (LocaleCompare("hald-clut",option+1) == 0)
1630 break;
1631 if ((LocaleCompare("help",option+1) == 0) ||
1632 (LocaleCompare("-help",option+1) == 0))
1633 return(ConvertUsage());
1634 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1635 }
1636 case 'i':
1637 {
1638 if (LocaleCompare("identify",option+1) == 0)
1639 break;
1640 if (LocaleCompare("ift",option+1) == 0)
1641 break;
1642 if (LocaleCompare("implode",option+1) == 0)
1643 {
1644 if (*option == '+')
1645 break;
1646 i++;
cristybb503372010-05-27 20:51:26 +00001647 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001648 ThrowConvertException(OptionError,"MissingArgument",option);
1649 if (IsGeometry(argv[i]) == MagickFalse)
1650 ThrowConvertInvalidArgumentException(option,argv[i]);
1651 break;
1652 }
1653 if (LocaleCompare("insert",option+1) == 0)
1654 {
1655 if (*option == '+')
1656 break;
1657 i++;
cristybb503372010-05-27 20:51:26 +00001658 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001659 ThrowConvertException(OptionError,"MissingArgument",option);
1660 if (IsGeometry(argv[i]) == MagickFalse)
1661 ThrowConvertInvalidArgumentException(option,argv[i]);
1662 break;
1663 }
1664 if (LocaleCompare("intent",option+1) == 0)
1665 {
cristybb503372010-05-27 20:51:26 +00001666 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001667 intent;
1668
1669 if (*option == '+')
1670 break;
1671 i++;
cristybb503372010-05-27 20:51:26 +00001672 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001673 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001674 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001675 argv[i]);
1676 if (intent < 0)
1677 ThrowConvertException(OptionError,"UnrecognizedIntentType",
1678 argv[i]);
1679 break;
1680 }
1681 if (LocaleCompare("interlace",option+1) == 0)
1682 {
cristybb503372010-05-27 20:51:26 +00001683 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001684 interlace;
1685
1686 if (*option == '+')
1687 break;
1688 i++;
cristybb503372010-05-27 20:51:26 +00001689 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001690 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001691 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001692 argv[i]);
1693 if (interlace < 0)
1694 ThrowConvertException(OptionError,"UnrecognizedInterlaceType",
1695 argv[i]);
1696 break;
1697 }
cristyb32b90a2009-09-07 21:45:48 +00001698 if (LocaleCompare("interline-spacing",option+1) == 0)
1699 {
1700 if (*option == '+')
1701 break;
1702 i++;
cristybb503372010-05-27 20:51:26 +00001703 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00001704 ThrowConvertException(OptionError,"MissingArgument",option);
1705 if (IsGeometry(argv[i]) == MagickFalse)
1706 ThrowConvertInvalidArgumentException(option,argv[i]);
1707 break;
1708 }
cristy3ed852e2009-09-05 21:47:34 +00001709 if (LocaleCompare("interpolate",option+1) == 0)
1710 {
cristybb503372010-05-27 20:51:26 +00001711 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001712 interpolate;
1713
1714 if (*option == '+')
1715 break;
1716 i++;
cristybb503372010-05-27 20:51:26 +00001717 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001718 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001719 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001720 argv[i]);
1721 if (interpolate < 0)
1722 ThrowConvertException(OptionError,"UnrecognizedInterpolateMethod",
1723 argv[i]);
1724 break;
1725 }
1726 if (LocaleCompare("interword-spacing",option+1) == 0)
1727 {
1728 if (*option == '+')
1729 break;
1730 i++;
cristybb503372010-05-27 20:51:26 +00001731 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001732 ThrowConvertException(OptionError,"MissingArgument",option);
1733 if (IsGeometry(argv[i]) == MagickFalse)
1734 ThrowConvertInvalidArgumentException(option,argv[i]);
1735 break;
1736 }
1737 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1738 }
1739 case 'k':
1740 {
1741 if (LocaleCompare("kerning",option+1) == 0)
1742 {
1743 if (*option == '+')
1744 break;
1745 i++;
cristybb503372010-05-27 20:51:26 +00001746 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001747 ThrowConvertException(OptionError,"MissingArgument",option);
1748 if (IsGeometry(argv[i]) == MagickFalse)
1749 ThrowConvertInvalidArgumentException(option,argv[i]);
1750 break;
1751 }
1752 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1753 }
1754 case 'l':
1755 {
1756 if (LocaleCompare("label",option+1) == 0)
1757 {
1758 if (*option == '+')
1759 break;
1760 i++;
cristybb503372010-05-27 20:51:26 +00001761 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001762 ThrowConvertException(OptionError,"MissingArgument",option);
1763 break;
1764 }
1765 if (LocaleCompare("lat",option+1) == 0)
1766 {
1767 if (*option == '+')
1768 break;
1769 i++;
cristybb503372010-05-27 20:51:26 +00001770 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001771 ThrowConvertException(OptionError,"MissingArgument",option);
1772 if (IsGeometry(argv[i]) == MagickFalse)
1773 ThrowConvertInvalidArgumentException(option,argv[i]);
1774 break;
1775 }
1776 if (LocaleCompare("layers",option+1) == 0)
1777 {
cristybb503372010-05-27 20:51:26 +00001778 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001779 type;
1780
1781 if (*option == '+')
1782 break;
1783 i++;
cristybb503372010-05-27 20:51:26 +00001784 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001785 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001786 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001787 if (type < 0)
1788 ThrowConvertException(OptionError,"UnrecognizedLayerMethod",
1789 argv[i]);
1790 break;
1791 }
1792 if (LocaleCompare("level",option+1) == 0)
1793 {
1794 i++;
cristybb503372010-05-27 20:51:26 +00001795 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001796 ThrowConvertException(OptionError,"MissingArgument",option);
1797 if (IsGeometry(argv[i]) == MagickFalse)
1798 ThrowConvertInvalidArgumentException(option,argv[i]);
1799 break;
1800 }
1801 if (LocaleCompare("level-colors",option+1) == 0)
1802 {
1803 i++;
cristybb503372010-05-27 20:51:26 +00001804 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001805 ThrowConvertException(OptionError,"MissingArgument",option);
1806 break;
1807 }
1808 if (LocaleCompare("linewidth",option+1) == 0)
1809 {
1810 if (*option == '+')
1811 break;
1812 i++;
cristybb503372010-05-27 20:51:26 +00001813 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001814 ThrowConvertException(OptionError,"MissingArgument",option);
1815 if (IsGeometry(argv[i]) == MagickFalse)
1816 ThrowConvertInvalidArgumentException(option,argv[i]);
1817 break;
1818 }
1819 if (LocaleCompare("liquid-rescale",option+1) == 0)
1820 {
1821 i++;
cristybb503372010-05-27 20:51:26 +00001822 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001823 ThrowConvertException(OptionError,"MissingArgument",option);
1824 if (IsGeometry(argv[i]) == MagickFalse)
1825 ThrowConvertInvalidArgumentException(option,argv[i]);
1826 break;
1827 }
1828 if (LocaleCompare("limit",option+1) == 0)
1829 {
1830 char
1831 *p;
1832
1833 double
1834 value;
1835
cristybb503372010-05-27 20:51:26 +00001836 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001837 resource;
1838
1839 if (*option == '+')
1840 break;
1841 i++;
cristybb503372010-05-27 20:51:26 +00001842 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001843 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001844 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001845 argv[i]);
1846 if (resource < 0)
1847 ThrowConvertException(OptionError,"UnrecognizedResourceType",
1848 argv[i]);
1849 i++;
cristybb503372010-05-27 20:51:26 +00001850 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001851 ThrowConvertException(OptionError,"MissingArgument",option);
cristyc1acd842011-05-19 23:05:47 +00001852 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00001853 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00001854 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1855 ThrowConvertInvalidArgumentException(option,argv[i]);
1856 break;
1857 }
1858 if (LocaleCompare("linear-stretch",option+1) == 0)
1859 {
1860 i++;
cristybb503372010-05-27 20:51:26 +00001861 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001862 ThrowConvertException(OptionError,"MissingArgument",option);
1863 if (IsGeometry(argv[i]) == MagickFalse)
1864 ThrowConvertInvalidArgumentException(option,argv[i]);
1865 break;
1866 }
1867 if (LocaleCompare("list",option+1) == 0)
1868 {
cristybb503372010-05-27 20:51:26 +00001869 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001870 list;
1871
1872 if (*option == '+')
1873 break;
1874 i++;
cristybb503372010-05-27 20:51:26 +00001875 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001876 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001877 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001878 if (list < 0)
1879 ThrowConvertException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00001880 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00001881 argv+j,exception);
1882 DestroyConvert();
cristyaeb2cbc2010-05-07 13:28:58 +00001883 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00001884 }
1885 if (LocaleCompare("log",option+1) == 0)
1886 {
1887 if (*option == '+')
1888 break;
1889 i++;
cristybb503372010-05-27 20:51:26 +00001890 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00001891 (strchr(argv[i],'%') == (char *) NULL))
1892 ThrowConvertException(OptionError,"MissingArgument",option);
1893 break;
1894 }
1895 if (LocaleCompare("loop",option+1) == 0)
1896 {
1897 if (*option == '+')
1898 break;
1899 i++;
cristybb503372010-05-27 20:51:26 +00001900 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001901 ThrowConvertException(OptionError,"MissingArgument",option);
1902 if (IsGeometry(argv[i]) == MagickFalse)
1903 ThrowConvertInvalidArgumentException(option,argv[i]);
1904 break;
1905 }
1906 ThrowConvertException(OptionError,"UnrecognizedOption",option)
1907 }
1908 case 'm':
1909 {
1910 if (LocaleCompare("map",option+1) == 0)
1911 {
1912 if (*option == '+')
1913 break;
1914 i++;
cristybb503372010-05-27 20:51:26 +00001915 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001916 ThrowConvertException(OptionError,"MissingArgument",option);
1917 break;
1918 }
1919 if (LocaleCompare("mask",option+1) == 0)
1920 {
1921 if (*option == '+')
1922 break;
1923 i++;
cristybb503372010-05-27 20:51:26 +00001924 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001925 ThrowConvertException(OptionError,"MissingArgument",option);
1926 break;
1927 }
1928 if (LocaleCompare("matte",option+1) == 0)
1929 break;
1930 if (LocaleCompare("mattecolor",option+1) == 0)
1931 {
1932 if (*option == '+')
1933 break;
1934 i++;
cristybb503372010-05-27 20:51:26 +00001935 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001936 ThrowConvertException(OptionError,"MissingArgument",option);
1937 break;
1938 }
cristy875e28a2010-03-06 19:46:55 +00001939 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00001940 break;
cristy3ed852e2009-09-05 21:47:34 +00001941 if (LocaleCompare("median",option+1) == 0)
1942 {
1943 if (*option == '+')
1944 break;
1945 i++;
cristybb503372010-05-27 20:51:26 +00001946 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001947 ThrowConvertException(OptionError,"MissingArgument",option);
1948 if (IsGeometry(argv[i]) == MagickFalse)
1949 ThrowConvertInvalidArgumentException(option,argv[i]);
1950 break;
1951 }
cristy875e28a2010-03-06 19:46:55 +00001952 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00001953 break;
cristyd28f7532011-02-27 23:57:37 +00001954 if (LocaleCompare("mode",option+1) == 0)
1955 {
1956 if (*option == '+')
1957 break;
1958 i++;
1959 if (i == (ssize_t) (argc-1))
1960 ThrowConvertException(OptionError,"MissingArgument",option);
1961 if (IsGeometry(argv[i]) == MagickFalse)
1962 ThrowConvertInvalidArgumentException(option,argv[i]);
1963 break;
1964 }
cristy3ed852e2009-09-05 21:47:34 +00001965 if (LocaleCompare("modulate",option+1) == 0)
1966 {
1967 if (*option == '+')
1968 break;
1969 i++;
cristybb503372010-05-27 20:51:26 +00001970 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001971 ThrowConvertException(OptionError,"MissingArgument",option);
1972 if (IsGeometry(argv[i]) == MagickFalse)
1973 ThrowConvertInvalidArgumentException(option,argv[i]);
1974 break;
1975 }
1976 if (LocaleCompare("monitor",option+1) == 0)
1977 break;
1978 if (LocaleCompare("monochrome",option+1) == 0)
1979 break;
1980 if (LocaleCompare("morph",option+1) == 0)
1981 {
1982 if (*option == '+')
1983 break;
1984 i++;
cristybb503372010-05-27 20:51:26 +00001985 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001986 ThrowConvertException(OptionError,"MissingArgument",option);
1987 if (IsGeometry(argv[i]) == MagickFalse)
1988 ThrowConvertInvalidArgumentException(option,argv[i]);
1989 break;
1990 }
anthony29188a82010-01-22 10:12:34 +00001991 if (LocaleCompare("morphology",option+1) == 0)
1992 {
anthony29188a82010-01-22 10:12:34 +00001993 char
1994 token[MaxTextExtent];
1995
cristyb6bd4ad2010-08-08 01:12:27 +00001996 KernelInfo
1997 *kernel_info;
1998
cristybb503372010-05-27 20:51:26 +00001999 ssize_t
cristye6365592010-04-02 17:31:23 +00002000 op;
2001
anthony29188a82010-01-22 10:12:34 +00002002 i++;
cristybb503372010-05-27 20:51:26 +00002003 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00002004 ThrowConvertException(OptionError,"MissingArgument",option);
2005 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00002006 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00002007 if (op < 0)
2008 ThrowConvertException(OptionError,"UnrecognizedMorphologyMethod",
cristye6365592010-04-02 17:31:23 +00002009 token);
anthony29188a82010-01-22 10:12:34 +00002010 i++;
cristybb503372010-05-27 20:51:26 +00002011 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00002012 ThrowConvertException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00002013 kernel_info=AcquireKernelInfo(argv[i]);
2014 if (kernel_info == (KernelInfo *) NULL)
anthony29188a82010-01-22 10:12:34 +00002015 ThrowConvertInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00002016 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00002017 break;
2018 }
cristy3ed852e2009-09-05 21:47:34 +00002019 if (LocaleCompare("mosaic",option+1) == 0)
2020 break;
2021 if (LocaleCompare("motion-blur",option+1) == 0)
2022 {
2023 if (*option == '+')
2024 break;
2025 i++;
cristybb503372010-05-27 20:51:26 +00002026 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002027 ThrowConvertException(OptionError,"MissingArgument",option);
2028 if (IsGeometry(argv[i]) == MagickFalse)
2029 ThrowConvertInvalidArgumentException(option,argv[i]);
2030 break;
2031 }
2032 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2033 }
2034 case 'n':
2035 {
2036 if (LocaleCompare("negate",option+1) == 0)
2037 break;
2038 if (LocaleCompare("noise",option+1) == 0)
2039 {
2040 i++;
cristybb503372010-05-27 20:51:26 +00002041 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002042 ThrowConvertException(OptionError,"MissingArgument",option);
2043 if (*option == '+')
2044 {
cristybb503372010-05-27 20:51:26 +00002045 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002046 noise;
2047
cristy042ee782011-04-22 18:48:30 +00002048 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00002049 if (noise < 0)
2050 ThrowConvertException(OptionError,"UnrecognizedNoiseType",
2051 argv[i]);
2052 break;
2053 }
2054 if (IsGeometry(argv[i]) == MagickFalse)
2055 ThrowConvertInvalidArgumentException(option,argv[i]);
2056 break;
2057 }
2058 if (LocaleCompare("noop",option+1) == 0)
2059 break;
2060 if (LocaleCompare("normalize",option+1) == 0)
2061 break;
2062 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2063 }
2064 case 'o':
2065 {
2066 if (LocaleCompare("opaque",option+1) == 0)
2067 {
2068 i++;
cristybb503372010-05-27 20:51:26 +00002069 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002070 ThrowConvertException(OptionError,"MissingArgument",option);
2071 break;
2072 }
2073 if (LocaleCompare("ordered-dither",option+1) == 0)
2074 {
2075 if (*option == '+')
2076 break;
2077 i++;
cristybb503372010-05-27 20:51:26 +00002078 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002079 ThrowConvertException(OptionError,"MissingArgument",option);
2080 break;
2081 }
2082 if (LocaleCompare("orient",option+1) == 0)
2083 {
cristybb503372010-05-27 20:51:26 +00002084 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002085 orientation;
2086
2087 if (*option == '+')
2088 break;
2089 i++;
cristybb503372010-05-27 20:51:26 +00002090 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002091 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002092 orientation=ParseCommandOption(MagickOrientationOptions,
cristy3ed852e2009-09-05 21:47:34 +00002093 MagickFalse,argv[i]);
2094 if (orientation < 0)
2095 ThrowConvertException(OptionError,"UnrecognizedImageOrientation",
2096 argv[i]);
2097 break;
2098 }
2099 ThrowConvertException(OptionError,"UnrecognizedOption",argv[i])
2100 }
2101 case 'p':
2102 {
2103 if (LocaleCompare("page",option+1) == 0)
2104 {
2105 if (*option == '+')
2106 break;
2107 i++;
cristybb503372010-05-27 20:51:26 +00002108 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00002109 ThrowConvertException(OptionError,"MissingArgument",option);
2110 break;
2111 }
2112 if (LocaleCompare("paint",option+1) == 0)
2113 {
2114 if (*option == '+')
2115 break;
2116 i++;
cristybb503372010-05-27 20:51:26 +00002117 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002118 ThrowConvertException(OptionError,"MissingArgument",option);
2119 if (IsGeometry(argv[i]) == MagickFalse)
2120 ThrowConvertInvalidArgumentException(option,argv[i]);
2121 break;
2122 }
2123 if (LocaleCompare("ping",option+1) == 0)
2124 break;
2125 if (LocaleCompare("pointsize",option+1) == 0)
2126 {
2127 if (*option == '+')
2128 break;
2129 i++;
cristybb503372010-05-27 20:51:26 +00002130 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002131 ThrowConvertException(OptionError,"MissingArgument",option);
2132 if (IsGeometry(argv[i]) == MagickFalse)
2133 ThrowConvertInvalidArgumentException(option,argv[i]);
2134 break;
2135 }
2136 if (LocaleCompare("polaroid",option+1) == 0)
2137 {
2138 if (*option == '+')
2139 break;
2140 i++;
cristybb503372010-05-27 20:51:26 +00002141 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002142 ThrowConvertException(OptionError,"MissingArgument",option);
2143 if (IsGeometry(argv[i]) == MagickFalse)
2144 ThrowConvertInvalidArgumentException(option,argv[i]);
2145 break;
2146 }
2147 if (LocaleCompare("posterize",option+1) == 0)
2148 {
2149 if (*option == '+')
2150 break;
2151 i++;
cristybb503372010-05-27 20:51:26 +00002152 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002153 ThrowConvertException(OptionError,"MissingArgument",option);
2154 if (IsGeometry(argv[i]) == MagickFalse)
2155 ThrowConvertInvalidArgumentException(option,argv[i]);
2156 break;
2157 }
cristye7f51092010-01-17 00:39:37 +00002158 if (LocaleCompare("precision",option+1) == 0)
2159 {
2160 if (*option == '+')
2161 break;
2162 i++;
cristybb503372010-05-27 20:51:26 +00002163 if (i == (ssize_t) (argc-1))
cristye7f51092010-01-17 00:39:37 +00002164 ThrowConvertException(OptionError,"MissingArgument",option);
2165 if (IsGeometry(argv[i]) == MagickFalse)
2166 ThrowConvertInvalidArgumentException(option,argv[i]);
2167 break;
2168 }
cristy3ed852e2009-09-05 21:47:34 +00002169 if (LocaleCompare("preview",option+1) == 0)
2170 {
cristybb503372010-05-27 20:51:26 +00002171 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002172 preview;
2173
2174 if (*option == '+')
2175 break;
2176 i++;
cristybb503372010-05-27 20:51:26 +00002177 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002178 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002179 preview=ParseCommandOption(MagickPreviewOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00002180 argv[i]);
2181 if (preview < 0)
2182 ThrowConvertException(OptionError,"UnrecognizedPreviewType",
2183 argv[i]);
2184 break;
2185 }
2186 if (LocaleCompare("print",option+1) == 0)
2187 {
2188 if (*option == '+')
2189 break;
2190 i++;
cristybb503372010-05-27 20:51:26 +00002191 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002192 ThrowConvertException(OptionError,"MissingArgument",option);
2193 break;
2194 }
2195 if (LocaleCompare("process",option+1) == 0)
2196 {
2197 if (*option == '+')
2198 break;
2199 i++;
cristybb503372010-05-27 20:51:26 +00002200 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002201 ThrowConvertException(OptionError,"MissingArgument",option);
2202 break;
2203 }
2204 if (LocaleCompare("profile",option+1) == 0)
2205 {
2206 i++;
cristybb503372010-05-27 20:51:26 +00002207 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002208 ThrowConvertException(OptionError,"MissingArgument",option);
2209 break;
2210 }
2211 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2212 }
2213 case 'q':
2214 {
2215 if (LocaleCompare("quality",option+1) == 0)
2216 {
2217 if (*option == '+')
2218 break;
2219 i++;
cristybb503372010-05-27 20:51:26 +00002220 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002221 ThrowConvertException(OptionError,"MissingArgument",option);
2222 if (IsGeometry(argv[i]) == MagickFalse)
2223 ThrowConvertInvalidArgumentException(option,argv[i]);
2224 break;
2225 }
2226 if (LocaleCompare("quantize",option+1) == 0)
2227 {
cristybb503372010-05-27 20:51:26 +00002228 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002229 colorspace;
2230
2231 if (*option == '+')
2232 break;
2233 i++;
cristybb503372010-05-27 20:51:26 +00002234 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002235 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002236 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +00002237 MagickFalse,argv[i]);
2238 if (colorspace < 0)
2239 ThrowConvertException(OptionError,"UnrecognizedColorspace",
2240 argv[i]);
2241 break;
2242 }
2243 if (LocaleCompare("quiet",option+1) == 0)
2244 break;
2245 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2246 }
2247 case 'r':
2248 {
2249 if (LocaleCompare("radial-blur",option+1) == 0)
2250 {
2251 i++;
cristybb503372010-05-27 20:51:26 +00002252 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002253 ThrowConvertException(OptionError,"MissingArgument",option);
2254 if (IsGeometry(argv[i]) == MagickFalse)
2255 ThrowConvertInvalidArgumentException(option,argv[i]);
2256 break;
2257 }
2258 if (LocaleCompare("raise",option+1) == 0)
2259 {
2260 i++;
cristybb503372010-05-27 20:51:26 +00002261 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002262 ThrowConvertException(OptionError,"MissingArgument",option);
2263 if (IsGeometry(argv[i]) == MagickFalse)
2264 ThrowConvertInvalidArgumentException(option,argv[i]);
2265 break;
2266 }
2267 if (LocaleCompare("random-threshold",option+1) == 0)
2268 {
2269 if (*option == '+')
2270 break;
2271 i++;
cristybb503372010-05-27 20:51:26 +00002272 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002273 ThrowConvertException(OptionError,"MissingArgument",option);
2274 if (IsGeometry(argv[i]) == MagickFalse)
2275 ThrowConvertInvalidArgumentException(option,argv[i]);
2276 break;
2277 }
2278 if (LocaleCompare("recolor",option+1) == 0)
2279 {
2280 if (*option == '+')
2281 break;
2282 i++;
cristybb503372010-05-27 20:51:26 +00002283 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002284 ThrowConvertException(OptionError,"MissingArgument",option);
2285 if (IsGeometry(argv[i]) == MagickFalse)
2286 ThrowConvertInvalidArgumentException(option,argv[i]);
2287 break;
2288 }
2289 if (LocaleCompare("red-primary",option+1) == 0)
2290 {
2291 if (*option == '+')
2292 break;
2293 i++;
cristybb503372010-05-27 20:51:26 +00002294 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002295 ThrowConvertException(OptionError,"MissingArgument",option);
2296 if (IsGeometry(argv[i]) == MagickFalse)
2297 ThrowConvertInvalidArgumentException(option,argv[i]);
2298 break;
2299 }
2300 if (LocaleCompare("regard-warnings",option+1) == 0)
2301 break;
2302 if (LocaleCompare("region",option+1) == 0)
2303 {
2304 if (*option == '+')
2305 break;
2306 i++;
cristybb503372010-05-27 20:51:26 +00002307 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002308 ThrowConvertException(OptionError,"MissingArgument",option);
2309 if (IsGeometry(argv[i]) == MagickFalse)
2310 ThrowConvertInvalidArgumentException(option,argv[i]);
2311 break;
2312 }
2313 if (LocaleCompare("remap",option+1) == 0)
2314 {
2315 if (*option == '+')
2316 break;
2317 i++;
cristybb503372010-05-27 20:51:26 +00002318 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002319 ThrowConvertException(OptionError,"MissingArgument",option);
2320 break;
2321 }
2322 if (LocaleCompare("render",option+1) == 0)
2323 break;
2324 if (LocaleCompare("repage",option+1) == 0)
2325 {
2326 if (*option == '+')
2327 break;
2328 i++;
cristybb503372010-05-27 20:51:26 +00002329 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002330 ThrowConvertException(OptionError,"MissingArgument",option);
2331 if (IsGeometry(argv[i]) == MagickFalse)
2332 ThrowConvertInvalidArgumentException(option,argv[i]);
2333 break;
2334 }
2335 if (LocaleCompare("resample",option+1) == 0)
2336 {
2337 if (*option == '+')
2338 break;
2339 i++;
cristybb503372010-05-27 20:51:26 +00002340 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002341 ThrowConvertException(OptionError,"MissingArgument",option);
2342 if (IsGeometry(argv[i]) == MagickFalse)
2343 ThrowConvertInvalidArgumentException(option,argv[i]);
2344 break;
2345 }
2346 if (LocaleCompare("resize",option+1) == 0)
2347 {
2348 if (*option == '+')
2349 break;
2350 i++;
cristybb503372010-05-27 20:51:26 +00002351 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002352 ThrowConvertException(OptionError,"MissingArgument",option);
2353 if (IsGeometry(argv[i]) == MagickFalse)
2354 ThrowConvertInvalidArgumentException(option,argv[i]);
2355 break;
2356 }
2357 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
2358 {
2359 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
2360 break;
2361 }
2362 if (LocaleCompare("reverse",option+1) == 0)
2363 break;
2364 if (LocaleCompare("roll",option+1) == 0)
2365 {
2366 if (*option == '+')
2367 break;
2368 i++;
cristybb503372010-05-27 20:51:26 +00002369 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002370 ThrowConvertException(OptionError,"MissingArgument",option);
2371 if (IsGeometry(argv[i]) == MagickFalse)
2372 ThrowConvertInvalidArgumentException(option,argv[i]);
2373 break;
2374 }
2375 if (LocaleCompare("rotate",option+1) == 0)
2376 {
2377 i++;
cristybb503372010-05-27 20:51:26 +00002378 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002379 ThrowConvertException(OptionError,"MissingArgument",option);
2380 if (IsGeometry(argv[i]) == MagickFalse)
2381 ThrowConvertInvalidArgumentException(option,argv[i]);
2382 break;
2383 }
2384 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2385 }
2386 case 's':
2387 {
2388 if (LocaleCompare("sample",option+1) == 0)
2389 {
2390 if (*option == '+')
2391 break;
2392 i++;
cristybb503372010-05-27 20:51:26 +00002393 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002394 ThrowConvertException(OptionError,"MissingArgument",option);
2395 if (IsGeometry(argv[i]) == MagickFalse)
2396 ThrowConvertInvalidArgumentException(option,argv[i]);
2397 break;
2398 }
2399 if (LocaleCompare("sampling-factor",option+1) == 0)
2400 {
2401 if (*option == '+')
2402 break;
2403 i++;
cristybb503372010-05-27 20:51:26 +00002404 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002405 ThrowConvertException(OptionError,"MissingArgument",option);
2406 if (IsGeometry(argv[i]) == MagickFalse)
2407 ThrowConvertInvalidArgumentException(option,argv[i]);
2408 break;
2409 }
2410 if (LocaleCompare("scale",option+1) == 0)
2411 {
2412 if (*option == '+')
2413 break;
2414 i++;
cristybb503372010-05-27 20:51:26 +00002415 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002416 ThrowConvertException(OptionError,"MissingArgument",option);
2417 if (IsGeometry(argv[i]) == MagickFalse)
2418 ThrowConvertInvalidArgumentException(option,argv[i]);
2419 break;
2420 }
2421 if (LocaleCompare("scene",option+1) == 0)
2422 {
2423 if (*option == '+')
2424 break;
2425 i++;
cristybb503372010-05-27 20:51:26 +00002426 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002427 ThrowConvertException(OptionError,"MissingArgument",option);
2428 if (IsGeometry(argv[i]) == MagickFalse)
2429 ThrowConvertInvalidArgumentException(option,argv[i]);
2430 break;
2431 }
2432 if (LocaleCompare("seed",option+1) == 0)
2433 {
2434 if (*option == '+')
2435 break;
2436 i++;
cristybb503372010-05-27 20:51:26 +00002437 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002438 ThrowConvertException(OptionError,"MissingArgument",option);
2439 if (IsGeometry(argv[i]) == MagickFalse)
2440 ThrowConvertInvalidArgumentException(option,argv[i]);
2441 break;
2442 }
2443 if (LocaleCompare("segment",option+1) == 0)
2444 {
2445 if (*option == '+')
2446 break;
2447 i++;
cristybb503372010-05-27 20:51:26 +00002448 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002449 ThrowConvertException(OptionError,"MissingArgument",option);
2450 if (IsGeometry(argv[i]) == MagickFalse)
2451 ThrowConvertInvalidArgumentException(option,argv[i]);
2452 break;
2453 }
2454 if (LocaleCompare("selective-blur",option+1) == 0)
2455 {
2456 i++;
cristybb503372010-05-27 20:51:26 +00002457 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002458 ThrowConvertException(OptionError,"MissingArgument",option);
2459 if (IsGeometry(argv[i]) == MagickFalse)
2460 ThrowConvertInvalidArgumentException(option,argv[i]);
2461 break;
2462 }
2463 if (LocaleCompare("separate",option+1) == 0)
2464 break;
2465 if (LocaleCompare("sepia-tone",option+1) == 0)
2466 {
2467 if (*option == '+')
2468 break;
2469 i++;
cristybb503372010-05-27 20:51:26 +00002470 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002471 ThrowConvertException(OptionError,"MissingArgument",option);
2472 if (IsGeometry(argv[i]) == MagickFalse)
2473 ThrowConvertInvalidArgumentException(option,argv[i]);
2474 break;
2475 }
2476 if (LocaleCompare("set",option+1) == 0)
2477 {
2478 i++;
cristybb503372010-05-27 20:51:26 +00002479 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00002480 ThrowConvertException(OptionError,"MissingArgument",option);
2481 if (*option == '+')
2482 break;
2483 i++;
cristybb503372010-05-27 20:51:26 +00002484 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00002485 ThrowConvertException(OptionError,"MissingArgument",option);
2486 break;
2487 }
2488 if (LocaleCompare("shade",option+1) == 0)
2489 {
2490 i++;
cristybb503372010-05-27 20:51:26 +00002491 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002492 ThrowConvertException(OptionError,"MissingArgument",option);
2493 if (IsGeometry(argv[i]) == MagickFalse)
2494 ThrowConvertInvalidArgumentException(option,argv[i]);
2495 break;
2496 }
2497 if (LocaleCompare("shadow",option+1) == 0)
2498 {
2499 if (*option == '+')
2500 break;
2501 i++;
cristybb503372010-05-27 20:51:26 +00002502 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002503 ThrowConvertException(OptionError,"MissingArgument",option);
2504 if (IsGeometry(argv[i]) == MagickFalse)
2505 ThrowConvertInvalidArgumentException(option,argv[i]);
2506 break;
2507 }
2508 if (LocaleCompare("sharpen",option+1) == 0)
2509 {
2510 i++;
cristybb503372010-05-27 20:51:26 +00002511 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002512 ThrowConvertException(OptionError,"MissingArgument",option);
2513 if (IsGeometry(argv[i]) == MagickFalse)
2514 ThrowConvertInvalidArgumentException(option,argv[i]);
2515 break;
2516 }
2517 if (LocaleCompare("shave",option+1) == 0)
2518 {
2519 if (*option == '+')
2520 break;
2521 i++;
cristybb503372010-05-27 20:51:26 +00002522 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002523 ThrowConvertException(OptionError,"MissingArgument",option);
2524 if (IsGeometry(argv[i]) == MagickFalse)
2525 ThrowConvertInvalidArgumentException(option,argv[i]);
2526 break;
2527 }
2528 if (LocaleCompare("shear",option+1) == 0)
2529 {
2530 i++;
cristybb503372010-05-27 20:51:26 +00002531 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002532 ThrowConvertException(OptionError,"MissingArgument",option);
2533 if (IsGeometry(argv[i]) == MagickFalse)
2534 ThrowConvertInvalidArgumentException(option,argv[i]);
2535 break;
2536 }
2537 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2538 {
2539 i++;
cristybb503372010-05-27 20:51:26 +00002540 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002541 ThrowConvertException(OptionError,"MissingArgument",option);
2542 if (IsGeometry(argv[i]) == MagickFalse)
2543 ThrowConvertInvalidArgumentException(option,argv[i]);
2544 break;
2545 }
2546 if (LocaleCompare("size",option+1) == 0)
2547 {
2548 if (*option == '+')
2549 break;
2550 i++;
cristybb503372010-05-27 20:51:26 +00002551 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002552 ThrowConvertException(OptionError,"MissingArgument",option);
2553 if (IsGeometry(argv[i]) == MagickFalse)
2554 ThrowConvertInvalidArgumentException(option,argv[i]);
2555 break;
2556 }
2557 if (LocaleCompare("sketch",option+1) == 0)
2558 {
2559 if (*option == '+')
2560 break;
2561 i++;
cristybb503372010-05-27 20:51:26 +00002562 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002563 ThrowConvertException(OptionError,"MissingArgument",option);
2564 if (IsGeometry(argv[i]) == MagickFalse)
2565 ThrowConvertInvalidArgumentException(option,argv[i]);
2566 break;
2567 }
cristy4285d782011-02-09 20:12:28 +00002568 if (LocaleCompare("smush",option+1) == 0)
2569 {
cristy4285d782011-02-09 20:12:28 +00002570 i++;
2571 if (i == (ssize_t) (argc-1))
2572 ThrowConvertException(OptionError,"MissingArgument",option);
2573 if (IsGeometry(argv[i]) == MagickFalse)
2574 ThrowConvertInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00002575 break;
2576 }
cristy3ed852e2009-09-05 21:47:34 +00002577 if (LocaleCompare("solarize",option+1) == 0)
2578 {
2579 if (*option == '+')
2580 break;
2581 i++;
cristybb503372010-05-27 20:51:26 +00002582 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002583 ThrowConvertException(OptionError,"MissingArgument",option);
2584 if (IsGeometry(argv[i]) == MagickFalse)
2585 ThrowConvertInvalidArgumentException(option,argv[i]);
2586 break;
2587 }
2588 if (LocaleCompare("sparse-color",option+1) == 0)
2589 {
cristybb503372010-05-27 20:51:26 +00002590 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002591 op;
2592
2593 i++;
cristybb503372010-05-27 20:51:26 +00002594 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00002595 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002596 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00002597 if (op < 0)
2598 ThrowConvertException(OptionError,"UnrecognizedSparseColorMethod",
2599 argv[i]);
2600 i++;
cristybb503372010-05-27 20:51:26 +00002601 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002602 ThrowConvertException(OptionError,"MissingArgument",option);
2603 break;
2604 }
2605 if (LocaleCompare("splice",option+1) == 0)
2606 {
2607 if (*option == '+')
2608 break;
2609 i++;
cristybb503372010-05-27 20:51:26 +00002610 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002611 ThrowConvertException(OptionError,"MissingArgument",option);
2612 if (IsGeometry(argv[i]) == MagickFalse)
2613 ThrowConvertInvalidArgumentException(option,argv[i]);
2614 break;
2615 }
2616 if (LocaleCompare("spread",option+1) == 0)
2617 {
2618 if (*option == '+')
2619 break;
2620 i++;
cristybb503372010-05-27 20:51:26 +00002621 if ((i == (ssize_t) (argc-1)) ||
cristy3ed852e2009-09-05 21:47:34 +00002622 (IsGeometry(argv[i]) == MagickFalse))
2623 ThrowConvertException(OptionError,"MissingArgument",option);
2624 break;
2625 }
cristy0834d642011-03-18 18:26:08 +00002626 if (LocaleCompare("statistic",option+1) == 0)
2627 {
2628 ssize_t
2629 op;
2630
2631 if (*option == '+')
2632 break;
2633 i++;
2634 if (i == (ssize_t) argc)
2635 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002636 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00002637 if (op < 0)
2638 ThrowConvertException(OptionError,"UnrecognizedStatisticType",
2639 argv[i]);
2640 i++;
2641 if (i == (ssize_t) (argc-1))
2642 ThrowConvertException(OptionError,"MissingArgument",option);
2643 if (IsGeometry(argv[i]) == MagickFalse)
2644 ThrowConvertInvalidArgumentException(option,argv[i]);
2645 break;
2646 }
cristy3ed852e2009-09-05 21:47:34 +00002647 if (LocaleCompare("stretch",option+1) == 0)
2648 {
cristybb503372010-05-27 20:51:26 +00002649 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002650 stretch;
2651
2652 if (*option == '+')
2653 break;
2654 i++;
cristybb503372010-05-27 20:51:26 +00002655 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002656 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002657 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00002658 argv[i]);
2659 if (stretch < 0)
2660 ThrowConvertException(OptionError,"UnrecognizedStyleType",
2661 argv[i]);
2662 break;
2663 }
2664 if (LocaleCompare("strip",option+1) == 0)
2665 break;
2666 if (LocaleCompare("stroke",option+1) == 0)
2667 {
2668 if (*option == '+')
2669 break;
2670 i++;
cristybb503372010-05-27 20:51:26 +00002671 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002672 ThrowConvertException(OptionError,"MissingArgument",option);
2673 break;
2674 }
2675 if (LocaleCompare("strokewidth",option+1) == 0)
2676 {
2677 if (*option == '+')
2678 break;
2679 i++;
cristybb503372010-05-27 20:51:26 +00002680 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002681 ThrowConvertException(OptionError,"MissingArgument",option);
2682 if (IsGeometry(argv[i]) == MagickFalse)
2683 ThrowConvertInvalidArgumentException(option,argv[i]);
2684 break;
2685 }
2686 if (LocaleCompare("style",option+1) == 0)
2687 {
cristybb503372010-05-27 20:51:26 +00002688 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002689 style;
2690
2691 if (*option == '+')
2692 break;
2693 i++;
cristybb503372010-05-27 20:51:26 +00002694 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002695 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002696 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00002697 if (style < 0)
2698 ThrowConvertException(OptionError,"UnrecognizedStyleType",
2699 argv[i]);
2700 break;
2701 }
2702 if (LocaleCompare("support",option+1) == 0)
2703 {
2704 i++; /* deprecated */
2705 break;
2706 }
2707 if (LocaleCompare("swap",option+1) == 0)
2708 {
2709 if (*option == '+')
2710 break;
2711 i++;
cristybb503372010-05-27 20:51:26 +00002712 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002713 ThrowConvertException(OptionError,"MissingArgument",option);
2714 if (IsGeometry(argv[i]) == MagickFalse)
2715 ThrowConvertInvalidArgumentException(option,argv[i]);
2716 break;
2717 }
2718 if (LocaleCompare("swirl",option+1) == 0)
2719 {
2720 if (*option == '+')
2721 break;
2722 i++;
cristybb503372010-05-27 20:51:26 +00002723 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002724 ThrowConvertException(OptionError,"MissingArgument",option);
2725 if (IsGeometry(argv[i]) == MagickFalse)
2726 ThrowConvertInvalidArgumentException(option,argv[i]);
2727 break;
2728 }
cristyd9a29192010-10-16 16:49:53 +00002729 if (LocaleCompare("synchronize",option+1) == 0)
2730 break;
cristy3ed852e2009-09-05 21:47:34 +00002731 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2732 }
2733 case 't':
2734 {
2735 if (LocaleCompare("taint",option+1) == 0)
2736 break;
2737 if (LocaleCompare("texture",option+1) == 0)
2738 {
2739 if (*option == '+')
2740 break;
2741 i++;
cristybb503372010-05-27 20:51:26 +00002742 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002743 ThrowConvertException(OptionError,"MissingArgument",option);
2744 break;
2745 }
2746 if (LocaleCompare("thumbnail",option+1) == 0)
2747 {
2748 if (*option == '+')
2749 break;
2750 i++;
cristybb503372010-05-27 20:51:26 +00002751 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002752 ThrowConvertException(OptionError,"MissingArgument",option);
2753 if (IsGeometry(argv[i]) == MagickFalse)
2754 ThrowConvertInvalidArgumentException(option,argv[i]);
2755 break;
2756 }
2757 if (LocaleCompare("threshold",option+1) == 0)
2758 {
2759 if (*option == '+')
2760 break;
2761 i++;
cristybb503372010-05-27 20:51:26 +00002762 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002763 ThrowConvertException(OptionError,"MissingArgument",option);
2764 if (IsGeometry(argv[i]) == MagickFalse)
2765 ThrowConvertInvalidArgumentException(option,argv[i]);
2766 break;
2767 }
2768 if (LocaleCompare("tile",option+1) == 0)
2769 {
2770 if (*option == '+')
2771 break;
2772 i++;
cristybb503372010-05-27 20:51:26 +00002773 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002774 ThrowConvertException(OptionError,"MissingArgument",option);
2775 break;
2776 }
2777 if (LocaleCompare("tile-offset",option+1) == 0)
2778 {
2779 if (*option == '+')
2780 break;
2781 i++;
cristybb503372010-05-27 20:51:26 +00002782 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002783 ThrowConvertException(OptionError,"MissingArgument",option);
2784 if (IsGeometry(argv[i]) == MagickFalse)
2785 ThrowConvertInvalidArgumentException(option,argv[i]);
2786 break;
2787 }
2788 if (LocaleCompare("tint",option+1) == 0)
2789 {
2790 if (*option == '+')
2791 break;
2792 i++;
cristybb503372010-05-27 20:51:26 +00002793 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002794 ThrowConvertException(OptionError,"MissingArgument",option);
2795 if (IsGeometry(argv[i]) == MagickFalse)
2796 ThrowConvertInvalidArgumentException(option,argv[i]);
2797 break;
2798 }
2799 if (LocaleCompare("transform",option+1) == 0)
2800 break;
2801 if (LocaleCompare("transparent",option+1) == 0)
2802 {
2803 i++;
cristybb503372010-05-27 20:51:26 +00002804 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002805 ThrowConvertException(OptionError,"MissingArgument",option);
2806 break;
2807 }
2808 if (LocaleCompare("transparent-color",option+1) == 0)
2809 {
2810 if (*option == '+')
2811 break;
2812 i++;
cristybb503372010-05-27 20:51:26 +00002813 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002814 ThrowConvertException(OptionError,"MissingArgument",option);
2815 break;
2816 }
2817 if (LocaleCompare("transpose",option+1) == 0)
2818 break;
2819 if (LocaleCompare("transverse",option+1) == 0)
2820 break;
2821 if (LocaleCompare("treedepth",option+1) == 0)
2822 {
2823 if (*option == '+')
2824 break;
2825 i++;
cristybb503372010-05-27 20:51:26 +00002826 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002827 ThrowConvertException(OptionError,"MissingArgument",option);
2828 if (IsGeometry(argv[i]) == MagickFalse)
2829 ThrowConvertInvalidArgumentException(option,argv[i]);
2830 break;
2831 }
2832 if (LocaleCompare("trim",option+1) == 0)
2833 break;
2834 if (LocaleCompare("type",option+1) == 0)
2835 {
cristybb503372010-05-27 20:51:26 +00002836 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002837 type;
2838
2839 if (*option == '+')
2840 break;
2841 i++;
cristybb503372010-05-27 20:51:26 +00002842 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002843 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002844 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00002845 if (type < 0)
2846 ThrowConvertException(OptionError,"UnrecognizedImageType",
2847 argv[i]);
2848 break;
2849 }
2850 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2851 }
2852 case 'u':
2853 {
2854 if (LocaleCompare("undercolor",option+1) == 0)
2855 {
2856 if (*option == '+')
2857 break;
2858 i++;
cristybb503372010-05-27 20:51:26 +00002859 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002860 ThrowConvertException(OptionError,"MissingArgument",option);
2861 break;
2862 }
2863 if (LocaleCompare("unique-colors",option+1) == 0)
2864 break;
2865 if (LocaleCompare("units",option+1) == 0)
2866 {
cristybb503372010-05-27 20:51:26 +00002867 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002868 units;
2869
2870 if (*option == '+')
2871 break;
2872 i++;
cristybb503372010-05-27 20:51:26 +00002873 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002874 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002875 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00002876 argv[i]);
2877 if (units < 0)
2878 ThrowConvertException(OptionError,"UnrecognizedUnitsType",
2879 argv[i]);
2880 break;
2881 }
2882 if (LocaleCompare("unsharp",option+1) == 0)
2883 {
2884 if (*option == '+')
2885 break;
2886 i++;
cristybb503372010-05-27 20:51:26 +00002887 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002888 ThrowConvertException(OptionError,"MissingArgument",option);
2889 if (IsGeometry(argv[i]) == MagickFalse)
2890 ThrowConvertInvalidArgumentException(option,argv[i]);
2891 break;
2892 }
2893 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2894 }
2895 case 'v':
2896 {
2897 if (LocaleCompare("verbose",option+1) == 0)
2898 break;
2899 if ((LocaleCompare("version",option+1) == 0) ||
2900 (LocaleCompare("-version",option+1) == 0))
2901 {
cristyb51dff52011-05-19 16:55:47 +00002902 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00002903 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00002904 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
2905 GetMagickCopyright());
2906 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
2907 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00002908 break;
2909 }
2910 if (LocaleCompare("view",option+1) == 0)
2911 {
2912 if (*option == '+')
2913 break;
2914 i++;
cristybb503372010-05-27 20:51:26 +00002915 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002916 ThrowConvertException(OptionError,"MissingArgument",option);
2917 break;
2918 }
2919 if (LocaleCompare("vignette",option+1) == 0)
2920 {
2921 if (*option == '+')
2922 break;
2923 i++;
cristybb503372010-05-27 20:51:26 +00002924 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002925 ThrowConvertException(OptionError,"MissingArgument",option);
2926 if (IsGeometry(argv[i]) == MagickFalse)
2927 ThrowConvertInvalidArgumentException(option,argv[i]);
2928 break;
2929 }
2930 if (LocaleCompare("virtual-pixel",option+1) == 0)
2931 {
cristybb503372010-05-27 20:51:26 +00002932 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00002933 method;
2934
2935 if (*option == '+')
2936 break;
2937 i++;
cristybb503372010-05-27 20:51:26 +00002938 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002939 ThrowConvertException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00002940 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00002941 argv[i]);
2942 if (method < 0)
2943 ThrowConvertException(OptionError,
2944 "UnrecognizedVirtualPixelMethod",argv[i]);
2945 break;
2946 }
2947 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2948 }
2949 case 'w':
2950 {
2951 if (LocaleCompare("wave",option+1) == 0)
2952 {
2953 i++;
cristybb503372010-05-27 20:51:26 +00002954 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002955 ThrowConvertException(OptionError,"MissingArgument",option);
2956 if (IsGeometry(argv[i]) == MagickFalse)
2957 ThrowConvertInvalidArgumentException(option,argv[i]);
2958 break;
2959 }
2960 if (LocaleCompare("weight",option+1) == 0)
2961 {
2962 if (*option == '+')
2963 break;
2964 i++;
cristybb503372010-05-27 20:51:26 +00002965 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002966 ThrowConvertException(OptionError,"MissingArgument",option);
2967 break;
2968 }
2969 if (LocaleCompare("white-point",option+1) == 0)
2970 {
2971 if (*option == '+')
2972 break;
2973 i++;
cristybb503372010-05-27 20:51:26 +00002974 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002975 ThrowConvertException(OptionError,"MissingArgument",option);
2976 if (IsGeometry(argv[i]) == MagickFalse)
2977 ThrowConvertInvalidArgumentException(option,argv[i]);
2978 break;
2979 }
2980 if (LocaleCompare("white-threshold",option+1) == 0)
2981 {
2982 if (*option == '+')
2983 break;
2984 i++;
cristybb503372010-05-27 20:51:26 +00002985 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002986 ThrowConvertException(OptionError,"MissingArgument",option);
2987 if (IsGeometry(argv[i]) == MagickFalse)
2988 ThrowConvertInvalidArgumentException(option,argv[i]);
2989 break;
2990 }
2991 if (LocaleCompare("write",option+1) == 0)
2992 {
2993 i++;
cristybb503372010-05-27 20:51:26 +00002994 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00002995 ThrowConvertException(OptionError,"MissingArgument",option);
2996 break;
2997 }
2998 ThrowConvertException(OptionError,"UnrecognizedOption",option)
2999 }
3000 case '?':
3001 break;
3002 default:
3003 ThrowConvertException(OptionError,"UnrecognizedOption",option)
3004 }
cristy042ee782011-04-22 18:48:30 +00003005 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
3006 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00003007 if (fire != MagickFalse)
3008 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
3009 }
3010 if (k != 0)
3011 ThrowConvertException(OptionError,"UnbalancedParenthesis",argv[i]);
cristybb503372010-05-27 20:51:26 +00003012 if (i-- != (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003013 ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
3014 if (image == (Image *) NULL)
3015 ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
3016 FinalizeImageSettings(image_info,image,MagickTrue);
cristy94f20072009-09-12 02:12:36 +00003017 if (image == (Image *) NULL)
3018 ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
cristy3ed852e2009-09-05 21:47:34 +00003019 status&=WriteImages(image_info,image,argv[argc-1],exception);
3020 if (metadata != (char **) NULL)
3021 {
3022 char
3023 *text;
3024
3025 text=InterpretImageProperties(image_info,image,format);
3026 if (text == (char *) NULL)
3027 ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
3028 GetExceptionMessage(errno));
3029 (void) ConcatenateString(&(*metadata),text);
3030 text=DestroyString(text);
3031 }
3032 DestroyConvert();
3033 return(status != 0 ? MagickTrue : MagickFalse);
3034}