MagickWand 7.1.1
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
montage.c
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% M M OOO N N TTTTT AAA GGGG EEEEE %
7% MM MM O O NN N T A A G E %
8% M M M O O N N N T AAAAA G GG EEE %
9% M M O O N NN T A A G G E %
10% M M OOO N N T A A GGG EEEEE %
11% %
12% %
13% MagickWand Methods to Create Image Thumbnails %
14% %
15% Software Design %
16% Cristy %
17% July 1992 %
18% %
19% %
20% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization %
21% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% https://imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36% Use the montage program to create a composite image by combining several
37% separate images. The images are tiled on the composite image optionally
38% adorned with a border, frame, image name, and more.
39%
40*/
41
42/*
43 Include declarations.
44*/
45#include "MagickWand/studio.h"
46#include "MagickWand/MagickWand.h"
47#include "MagickWand/mogrify-private.h"
48#include "MagickCore/string-private.h"
49
50/*
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52% %
53% %
54% %
55+ M o n t a g e I m a g e C o m m a n d %
56% %
57% %
58% %
59%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60%
61% MontageImageCommand() reads one or more images, applies one or more image
62% processing operations, and writes out the image in the same or
63% differing format.
64%
65% The format of the MontageImageCommand method is:
66%
67% MagickBooleanType MontageImageCommand(ImageInfo *image_info,int argc,
68% char **argv,char **metadata,ExceptionInfo *exception)
69%
70% A description of each parameter follows:
71%
72% o image_info: the image info.
73%
74% o argc: the number of elements in the argument vector.
75%
76% o argv: A text array containing the command line arguments.
77%
78% o metadata: any metadata is returned here.
79%
80% o exception: return any errors or warnings in this structure.
81%
82*/
83
84static MagickBooleanType MontageUsage(void)
85{
86 static const char
87 miscellaneous[] =
88 " -debug events display copious debugging information\n"
89 " -help print program options\n"
90 " -list type print a list of supported option arguments\n"
91 " -log format format of debugging information\n"
92 " -version print version information",
93 operators[] =
94 " -adaptive-sharpen geometry\n"
95 " adaptively sharpen pixels; increase effect near edges\n"
96 " -annotate geometry text\n"
97 " annotate the image with text\n"
98 " -auto-orient automagically orient image\n"
99 " -blur geometry reduce image noise and reduce detail levels\n"
100 " -border geometry surround image with a border of color\n"
101 " -channel mask set the image channel mask\n"
102 " -crop geometry preferred size and location of the cropped image\n"
103 " -distort method args\n"
104 " distort images according to given method and args\n"
105 " -extent geometry set the image size\n"
106 " -flatten flatten a sequence of images\n"
107 " -flip flip image in the vertical direction\n"
108 " -flop flop image in the horizontal direction\n"
109 " -frame geometry surround image with an ornamental border\n"
110 " -layers method optimize, merge, or compare image layers\n"
111 " -monochrome transform image to black and white\n"
112 " -polaroid angle simulate a Polaroid picture\n"
113 " -repage geometry size and location of an image canvas (operator)\n"
114 " -resize geometry resize the image\n"
115 " -rotate degrees apply Paeth rotation to the image\n"
116 " -scale geometry scale the image\n"
117 " -strip strip image of all profiles and comments\n"
118 " -transform affine transform image\n"
119 " -transpose flip image vertically and rotate 90 degrees\n"
120 " -transparent color make this color transparent within the image\n"
121 " -type type image type\n"
122 " -unsharp geometry sharpen the image",
123 settings[] =
124 " -adjoin join images into a single multi-image file\n"
125 " -affine matrix affine transform matrix\n"
126 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
127 " transparent, extract, background, or shape\n"
128 " -authenticate password\n"
129 " decipher image with this password\n"
130 " -blue-primary point chromaticity blue primary point\n"
131 " -bordercolor color border color\n"
132 " -caption string assign a caption to an image\n"
133 " -colors value preferred number of colors in the image\n"
134 " -colorspace type alternate image colorspace\n"
135 " -comment string annotate image with comment\n"
136 " -compose operator composite operator\n"
137 " -compress type type of pixel compression when writing the image\n"
138 " -define format:option\n"
139 " define one or more image format options\n"
140 " -delay value display the next image after pausing\n"
141 " -density geometry horizontal and vertical density of the image\n"
142 " -depth value image depth\n"
143 " -display server query font from this X server\n"
144 " -dispose method layer disposal method\n"
145 " -dither method apply error diffusion to image\n"
146 " -draw string annotate the image with a graphic primitive\n"
147 " -encoding type text encoding type\n"
148 " -endian type endianness (MSB or LSB) of the image\n"
149 " -extract geometry extract area from image\n"
150 " -family name render text with this font family\n"
151 " -fill color color to use when filling a graphic primitive\n"
152 " -filter type use this filter when resizing an image\n"
153 " -font name render text with this font\n"
154 " -format \"string\" output formatted image characteristics\n"
155 " -gamma value level of gamma correction\n"
156 " -geometry geometry preferred tile and border sizes\n"
157 " -gravity direction which direction to gravitate towards\n"
158 " -green-primary point chromaticity green primary point\n"
159 " -identify identify the format and characteristics of the image\n"
160 " -interlace type type of image interlacing scheme\n"
161 " -interpolate method pixel color interpolation method\n"
162 " -kerning value set the space between two letters\n"
163 " -label string assign a label to an image\n"
164 " -limit type value pixel cache resource limit\n"
165 " -matte store matte channel if the image has one\n"
166 " -mattecolor color frame color\n"
167 " -mode type framing style\n"
168 " -monitor monitor progress\n"
169 " -page geometry size and location of an image canvas (setting)\n"
170 " -pointsize value font point size\n"
171 " -profile filename add, delete, or apply an image profile\n"
172 " -quality value JPEG/MIFF/PNG compression level\n"
173 " -quantize colorspace reduce colors in this colorspace\n"
174 " -quiet suppress all warning messages\n"
175 " -red-primary point chromaticity red primary point\n"
176 " -regard-warnings pay attention to warning messages\n"
177 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
178 " -sampling-factor geometry\n"
179 " horizontal and vertical sampling factor\n"
180 " -scenes range image scene range\n"
181 " -seed value seed a new sequence of pseudo-random numbers\n"
182 " -set attribute value set an image attribute\n"
183 " -shadow add a shadow beneath a tile to simulate depth\n"
184 " -size geometry width and height of image\n"
185 " -stroke color color to use when stroking a graphic primitive\n"
186 " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
187 " -synchronize synchronize image to storage device\n"
188 " -taint declare the image as modified\n"
189 " -texture filename name of texture to tile onto the image background\n"
190 " -thumbnail geometry create a thumbnail of the image\n"
191 " -tile geometry number of tiles per row and column\n"
192 " -title string decorate the montage image with a title\n"
193 " -transparent-color color\n"
194 " transparent color\n"
195 " -treedepth value color tree depth\n"
196 " -trim trim image edges\n"
197 " -units type the units of image resolution\n"
198 " -verbose print detailed information about the image\n"
199 " -virtual-pixel method\n"
200 " virtual pixel access method\n"
201 " -white-point point chromaticity white point",
202 sequence_operators[] =
203 " -coalesce merge a sequence of images\n"
204 " -composite composite image",
205 stack_operators[] =
206 " -clone indexes clone an image\n"
207 " -delete indexes delete the image from the image sequence\n"
208 " -duplicate count,indexes\n"
209 " duplicate an image one or more times\n"
210 " -insert index insert last image into the image sequence\n"
211 " -reverse reverse image sequence\n"
212 " -swap indexes swap two images in the image sequence";
213
214 ListMagickVersion(stdout);
215 (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n",
216 GetClientName());
217 (void) printf("\nImage Settings:\n");
218 (void) puts(settings);
219 (void) printf("\nImage Operators:\n");
220 (void) puts(operators);
221 (void) printf("\nImage Sequence Operators:\n");
222 (void) puts(sequence_operators);
223 (void) printf("\nImage Stack Operators:\n");
224 (void) puts(stack_operators);
225 (void) printf("\nMiscellaneous Options:\n");
226 (void) puts(miscellaneous);
227 (void) printf(
228 "\nIn addition to those listed above, you can specify these standard X\n");
229 (void) printf(
230 "resources as command line options: -background, -bordercolor,\n");
231 (void) printf(
232 "-mattecolor, -borderwidth, -font, or -title\n");
233 (void) printf(
234 "\nBy default, the image format of 'file' is determined by its magic\n");
235 (void) printf(
236 "number. To specify a particular image format, precede the filename\n");
237 (void) printf(
238 "with an image format name and a colon (i.e. ps:image) or specify the\n");
239 (void) printf(
240 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
241 (void) printf("'-' for standard input or output.\n");
242 return(MagickTrue);
243}
244
245WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
246 int argc,char **argv,char **metadata,ExceptionInfo *exception)
247{
248#define DestroyMontage() \
249{ \
250 if (montage_image != (Image *) NULL) \
251 montage_image=DestroyImageList(montage_image); \
252 if (montage_info != (MontageInfo *) NULL) \
253 montage_info=DestroyMontageInfo(montage_info); \
254 DestroyImageStack(); \
255 for (i=0; i < (ssize_t) argc; i++) \
256 argv[i]=DestroyString(argv[i]); \
257 argv=(char **) RelinquishMagickMemory(argv); \
258}
259#define ThrowMontageException(asperity,tag,option) \
260{ \
261 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
262 option); \
263 DestroyMontage(); \
264 return(MagickFalse); \
265}
266#define ThrowMontageInvalidArgumentException(option,argument) \
267{ \
268 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
269 "InvalidArgument","'%s': %s",option,argument); \
270 DestroyMontage(); \
271 return(MagickFalse); \
272}
273
274 char
275 *option,
276 *transparent_color;
277
278 const char
279 *format;
280
281 Image
282 *image = (Image *) NULL,
283 *montage_image;
284
286 image_stack[MaxImageStackDepth+1];
287
288 long
289 first_scene,
290 last_scene;
291
292 MagickBooleanType
293 fire,
294 pend,
295 respect_parentheses;
296
297 MagickStatusType
298 status;
299
300 MontageInfo
301 *montage_info;
302
303 ssize_t
304 i;
305
306 ssize_t
307 j,
308 k,
309 scene;
310
311 /*
312 Set defaults.
313 */
314 assert(image_info != (ImageInfo *) NULL);
315 assert(image_info->signature == MagickCoreSignature);
316 assert(exception != (ExceptionInfo *) NULL);
317 if (IsEventLogging() != MagickFalse)
318 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
319 if (argc == 2)
320 {
321 option=argv[1];
322 if ((LocaleCompare("help",option+1) == 0) ||
323 (LocaleCompare("-help",option+1) == 0))
324 return(MontageUsage());
325 if ((LocaleCompare("version",option+1) == 0) ||
326 (LocaleCompare("-version",option+1) == 0))
327 {
328 ListMagickVersion(stdout);
329 return(MagickTrue);
330 }
331 }
332 if (argc < 3)
333 {
334 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
335 "MissingArgument","%s","");
336 (void) MontageUsage();
337 return(MagickFalse);
338 }
339 format="%w,%h,%m";
340 first_scene=0;
341 j=1;
342 k=0;
343 last_scene=0;
344 montage_image=NewImageList();
345 montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
346 NewImageStack();
347 option=(char *) NULL;
348 pend=MagickFalse;
349 respect_parentheses=MagickFalse;
350 scene=0;
351 status=MagickFalse;
352 transparent_color=(char *) NULL;
353 /*
354 Parse command line.
355 */
356 ReadCommandlLine(argc,&argv);
357 status=ExpandFilenames(&argc,&argv);
358 if (status == MagickFalse)
359 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
360 GetExceptionMessage(errno));
361 for (i=1; i < (ssize_t) (argc-1); i++)
362 {
363 option=argv[i];
364 if (LocaleCompare(option,"(") == 0)
365 {
366 FireImageStack(MagickTrue,MagickTrue,pend);
367 if (k == MaxImageStackDepth)
368 ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply",
369 option);
370 PushImageStack();
371 continue;
372 }
373 if (LocaleCompare(option,")") == 0)
374 {
375 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
376 if (k == 0)
377 ThrowMontageException(OptionError,"UnableToParseExpression",option);
378 PopImageStack();
379 continue;
380 }
381 if (IsCommandOption(option) == MagickFalse)
382 {
383 Image
384 *images;
385
386 FireImageStack(MagickFalse,MagickFalse,pend);
387 for (scene=(ssize_t) first_scene; scene <= (ssize_t) last_scene ; scene++)
388 {
389 char
390 *filename;
391
392 /*
393 Option is a file name: begin by reading image from specified file.
394 */
395 filename=argv[i];
396 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
397 filename=argv[++i];
398 (void) CloneString(&image_info->font,montage_info->font);
399 if (first_scene == last_scene)
400 images=ReadImages(image_info,filename,exception);
401 else
402 {
403 char
404 scene_filename[MagickPathExtent];
405
406 /*
407 Form filename for multi-part images.
408 */
409 (void) InterpretImageFilename(image_info,(Image *) NULL,
410 image_info->filename,(int) scene,scene_filename,exception);
411 if (LocaleCompare(filename,image_info->filename) == 0)
412 (void) FormatLocaleString(scene_filename,MagickPathExtent,
413 "%s.%.20g",image_info->filename,(double) scene);
414 images=ReadImages(image_info,scene_filename,exception);
415 }
416 status&=(MagickStatusType) (images != (Image *) NULL) &&
417 (exception->severity < ErrorException);
418 if (images == (Image *) NULL)
419 continue;
420 AppendImageStack(images);
421 }
422 continue;
423 }
424 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
425 switch (*(option+1))
426 {
427 case 'a':
428 {
429 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
430 {
431 i++;
432 if (i == (ssize_t) argc)
433 ThrowMontageException(OptionError,"MissingArgument",option);
434 if (IsGeometry(argv[i]) == MagickFalse)
435 ThrowMontageInvalidArgumentException(option,argv[i]);
436 break;
437 }
438 if (LocaleCompare("adjoin",option+1) == 0)
439 break;
440 if (LocaleCompare("affine",option+1) == 0)
441 {
442 if (*option == '+')
443 break;
444 i++;
445 if (i == (ssize_t) argc)
446 ThrowMontageException(OptionError,"MissingArgument",option);
447 if (IsGeometry(argv[i]) == MagickFalse)
448 ThrowMontageInvalidArgumentException(option,argv[i]);
449 break;
450 }
451 if (LocaleCompare("alpha",option+1) == 0)
452 {
453 ssize_t
454 type;
455
456 if (*option == '+')
457 break;
458 i++;
459 if (i == (ssize_t) argc)
460 ThrowMontageException(OptionError,"MissingArgument",option);
461 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
462 argv[i]);
463 if (type < 0)
464 ThrowMontageException(OptionError,
465 "UnrecognizedAlphaChannelOption",argv[i]);
466 break;
467 }
468 if (LocaleCompare("annotate",option+1) == 0)
469 {
470 if (*option == '+')
471 break;
472 i++;
473 if (i == (ssize_t) argc)
474 ThrowMontageException(OptionError,"MissingArgument",option);
475 if (IsGeometry(argv[i]) == MagickFalse)
476 ThrowMontageInvalidArgumentException(option,argv[i]);
477 if (i == (ssize_t) argc)
478 ThrowMontageException(OptionError,"MissingArgument",option);
479 i++;
480 break;
481 }
482 if (LocaleCompare("auto-orient",option+1) == 0)
483 break;
484 if (LocaleCompare("authenticate",option+1) == 0)
485 {
486 if (*option == '+')
487 break;
488 i++;
489 if (i == (ssize_t) argc)
490 ThrowMontageException(OptionError,"MissingArgument",option);
491 break;
492 }
493 ThrowMontageException(OptionError,"UnrecognizedOption",option)
494 }
495 case 'b':
496 {
497 if (LocaleCompare("background",option+1) == 0)
498 {
499 if (*option == '+')
500 break;
501 i++;
502 if (i == (ssize_t) argc)
503 ThrowMontageException(OptionError,"MissingArgument",option);
504 (void) QueryColorCompliance(argv[i],AllCompliance,
505 &montage_info->background_color,exception);
506 break;
507 }
508 if (LocaleCompare("blue-primary",option+1) == 0)
509 {
510 if (*option == '+')
511 break;
512 i++;
513 if (i == (ssize_t) argc)
514 ThrowMontageException(OptionError,"MissingArgument",option);
515 if (IsGeometry(argv[i]) == MagickFalse)
516 ThrowMontageInvalidArgumentException(option,argv[i]);
517 break;
518 }
519 if (LocaleCompare("blur",option+1) == 0)
520 {
521 if (*option == '+')
522 break;
523 i++;
524 if (i == (ssize_t) argc)
525 ThrowMontageException(OptionError,"MissingArgument",option);
526 if (IsGeometry(argv[i]) == MagickFalse)
527 ThrowMontageInvalidArgumentException(option,argv[i]);
528 break;
529 }
530 if (LocaleCompare("border",option+1) == 0)
531 {
532 if (k == 0)
533 {
534 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
535 montage_info->border_width=0;
536 }
537 if (*option == '+')
538 break;
539 i++;
540 if (i == (ssize_t) argc)
541 ThrowMontageException(OptionError,"MissingArgument",option);
542 if (IsGeometry(argv[i]) == MagickFalse)
543 ThrowMontageInvalidArgumentException(option,argv[i]);
544 if (k == 0)
545 montage_info->border_width=StringToUnsignedLong(argv[i]);
546 break;
547 }
548 if (LocaleCompare("bordercolor",option+1) == 0)
549 {
550 if (*option == '+')
551 break;
552 i++;
553 if (i == (ssize_t) argc)
554 ThrowMontageException(OptionError,"MissingArgument",option);
555 (void) QueryColorCompliance(argv[i],AllCompliance,
556 &montage_info->border_color,exception);
557 break;
558 }
559 if (LocaleCompare("borderwidth",option+1) == 0)
560 {
561 montage_info->border_width=0;
562 if (*option == '+')
563 break;
564 i++;
565 if (i == (ssize_t) argc)
566 ThrowMontageException(OptionError,"MissingArgument",option);
567 if (IsGeometry(argv[i]) == MagickFalse)
568 ThrowMontageInvalidArgumentException(option,argv[i]);
569 montage_info->border_width=StringToUnsignedLong(argv[i]);
570 break;
571 }
572 ThrowMontageException(OptionError,"UnrecognizedOption",option)
573 }
574 case 'c':
575 {
576 if (LocaleCompare("cache",option+1) == 0)
577 {
578 if (*option == '+')
579 break;
580 i++;
581 if (i == (ssize_t) argc)
582 ThrowMontageException(OptionError,"MissingArgument",option);
583 if (IsGeometry(argv[i]) == MagickFalse)
584 ThrowMontageInvalidArgumentException(option,argv[i]);
585 break;
586 }
587 if (LocaleCompare("caption",option+1) == 0)
588 {
589 if (*option == '+')
590 break;
591 i++;
592 if (i == (ssize_t) argc)
593 ThrowMontageException(OptionError,"MissingArgument",option);
594 break;
595 }
596 if (LocaleCompare("channel",option+1) == 0)
597 {
598 ssize_t
599 channel;
600
601 if (*option == '+')
602 break;
603 i++;
604 if (i == (ssize_t) argc)
605 ThrowMontageException(OptionError,"MissingArgument",option);
606 channel=ParseChannelOption(argv[i]);
607 if (channel < 0)
608 ThrowMontageException(OptionError,"UnrecognizedChannelType",
609 argv[i]);
610 break;
611 }
612 if (LocaleCompare("clone",option+1) == 0)
613 {
614 Image
615 *clone_images,
616 *clone_list;
617
618 clone_list=CloneImageList(image,exception);
619 if (k != 0)
620 clone_list=CloneImageList(image_stack[k-1].image,exception);
621 if (clone_list == (Image *) NULL)
622 ThrowMontageException(ImageError,"ImageSequenceRequired",option);
623 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
624 if (*option == '+')
625 clone_images=CloneImages(clone_list,"-1",exception);
626 else
627 {
628 i++;
629 if (i == (ssize_t) argc)
630 ThrowMontageException(OptionError,"MissingArgument",option);
631 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
632 ThrowMontageInvalidArgumentException(option,argv[i]);
633 clone_images=CloneImages(clone_list,argv[i],exception);
634 }
635 if (clone_images == (Image *) NULL)
636 ThrowMontageException(OptionError,"NoSuchImage",option);
637 AppendImageStack(clone_images);
638 clone_list=DestroyImageList(clone_list);
639 break;
640 }
641 if (LocaleCompare("coalesce",option+1) == 0)
642 break;
643 if (LocaleCompare("colors",option+1) == 0)
644 {
645 if (*option == '+')
646 break;
647 i++;
648 if (i == (ssize_t) argc)
649 ThrowMontageException(OptionError,"MissingArgument",option);
650 if (IsGeometry(argv[i]) == MagickFalse)
651 ThrowMontageInvalidArgumentException(option,argv[i]);
652 break;
653 }
654 if (LocaleCompare("colorspace",option+1) == 0)
655 {
656 ssize_t
657 colorspace;
658
659 if (*option == '+')
660 break;
661 i++;
662 if (i == (ssize_t) argc)
663 ThrowMontageException(OptionError,"MissingArgument",option);
664 colorspace=ParseCommandOption(MagickColorspaceOptions,
665 MagickFalse,argv[i]);
666 if (colorspace < 0)
667 ThrowMontageException(OptionError,"UnrecognizedColorspace",
668 argv[i]);
669 break;
670 }
671 if (LocaleCompare("comment",option+1) == 0)
672 {
673 if (*option == '+')
674 break;
675 i++;
676 if (i == (ssize_t) argc)
677 ThrowMontageException(OptionError,"MissingArgument",option);
678 break;
679 }
680 if (LocaleCompare("compose",option+1) == 0)
681 {
682 ssize_t
683 compose;
684
685 if (*option == '+')
686 break;
687 i++;
688 if (i == (ssize_t) argc)
689 ThrowMontageException(OptionError,"MissingArgument",option);
690 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,argv[i]);
691 if (compose < 0)
692 ThrowMontageException(OptionError,"UnrecognizedComposeOperator",
693 argv[i]);
694 break;
695 }
696 if (LocaleCompare("composite",option+1) == 0)
697 break;
698 if (LocaleCompare("compress",option+1) == 0)
699 {
700 ssize_t
701 compress;
702
703 if (*option == '+')
704 break;
705 i++;
706 if (i == (ssize_t) argc)
707 ThrowMontageException(OptionError,"MissingArgument",option);
708 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
709 argv[i]);
710 if (compress < 0)
711 ThrowMontageException(OptionError,"UnrecognizedCompressType",
712 argv[i]);
713 break;
714 }
715 if (LocaleCompare("concurrent",option+1) == 0)
716 break;
717 if (LocaleCompare("crop",option+1) == 0)
718 {
719 if (*option == '+')
720 break;
721 i++;
722 if (i == (ssize_t) argc)
723 ThrowMontageException(OptionError,"MissingArgument",option);
724 if (IsGeometry(argv[i]) == MagickFalse)
725 ThrowMontageInvalidArgumentException(option,argv[i]);
726 break;
727 }
728 ThrowMontageException(OptionError,"UnrecognizedOption",option)
729 }
730 case 'd':
731 {
732 if (LocaleCompare("debug",option+1) == 0)
733 {
734 ssize_t
735 event;
736
737 if (*option == '+')
738 break;
739 i++;
740 if (i == (ssize_t) argc)
741 ThrowMontageException(OptionError,"MissingArgument",option);
742 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
743 if (event < 0)
744 ThrowMontageException(OptionError,"UnrecognizedEventType",
745 argv[i]);
746 (void) SetLogEventMask(argv[i]);
747 break;
748 }
749 if (LocaleCompare("define",option+1) == 0)
750 {
751 i++;
752 if (i == (ssize_t) argc)
753 ThrowMontageException(OptionError,"MissingArgument",option);
754 if (*option == '+')
755 {
756 const char
757 *define;
758
759 define=GetImageOption(image_info,argv[i]);
760 if (define == (const char *) NULL)
761 ThrowMontageException(OptionError,"NoSuchOption",argv[i]);
762 break;
763 }
764 break;
765 }
766 if (LocaleCompare("delay",option+1) == 0)
767 {
768 if (*option == '+')
769 break;
770 i++;
771 if (i == (ssize_t) argc)
772 ThrowMontageException(OptionError,"MissingArgument",option);
773 if (IsGeometry(argv[i]) == MagickFalse)
774 ThrowMontageInvalidArgumentException(option,argv[i]);
775 break;
776 }
777 if (LocaleCompare("delete",option+1) == 0)
778 {
779 if (*option == '+')
780 break;
781 i++;
782 if (i == (ssize_t) argc)
783 ThrowMontageException(OptionError,"MissingArgument",option);
784 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
785 ThrowMontageInvalidArgumentException(option,argv[i]);
786 break;
787 }
788 if (LocaleCompare("density",option+1) == 0)
789 {
790 if (*option == '+')
791 break;
792 i++;
793 if (i == (ssize_t) argc)
794 ThrowMontageException(OptionError,"MissingArgument",option);
795 if (IsGeometry(argv[i]) == MagickFalse)
796 ThrowMontageInvalidArgumentException(option,argv[i]);
797 break;
798 }
799 if (LocaleCompare("depth",option+1) == 0)
800 {
801 if (*option == '+')
802 break;
803 i++;
804 if (i == (ssize_t) argc)
805 ThrowMontageException(OptionError,"MissingArgument",option);
806 if (IsGeometry(argv[i]) == MagickFalse)
807 ThrowMontageInvalidArgumentException(option,argv[i]);
808 break;
809 }
810 if (LocaleCompare("display",option+1) == 0)
811 {
812 if (*option == '+')
813 break;
814 i++;
815 if (i == (ssize_t) argc)
816 ThrowMontageException(OptionError,"MissingArgument",option);
817 break;
818 }
819 if (LocaleCompare("dispose",option+1) == 0)
820 {
821 ssize_t
822 dispose;
823
824 if (*option == '+')
825 break;
826 i++;
827 if (i == (ssize_t) argc)
828 ThrowMontageException(OptionError,"MissingArgument",option);
829 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
830 argv[i]);
831 if (dispose < 0)
832 ThrowMontageException(OptionError,"UnrecognizedDisposeMethod",
833 argv[i]);
834 break;
835 }
836 if (LocaleCompare("distort",option+1) == 0)
837 {
838 ssize_t
839 op;
840
841 i++;
842 if (i == (ssize_t) argc)
843 ThrowMontageException(OptionError,"MissingArgument",option);
844 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
845 if (op < 0)
846 ThrowMontageException(OptionError,"UnrecognizedDistortMethod",
847 argv[i]);
848 i++;
849 if (i == (ssize_t) argc)
850 ThrowMontageException(OptionError,"MissingArgument",option);
851 break;
852 }
853 if (LocaleCompare("dither",option+1) == 0)
854 {
855 ssize_t
856 method;
857
858 if (*option == '+')
859 break;
860 i++;
861 if (i == (ssize_t) argc)
862 ThrowMontageException(OptionError,"MissingArgument",option);
863 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
864 if (method < 0)
865 ThrowMontageException(OptionError,"UnrecognizedDitherMethod",
866 argv[i]);
867 break;
868 }
869 if (LocaleCompare("draw",option+1) == 0)
870 {
871 if (*option == '+')
872 break;
873 i++;
874 if (i == (ssize_t) argc)
875 ThrowMontageException(OptionError,"MissingArgument",option);
876 break;
877 }
878 if (LocaleCompare("duplicate",option+1) == 0)
879 {
880 if (*option == '+')
881 break;
882 i++;
883 if (i == (ssize_t) argc)
884 ThrowMontageException(OptionError,"MissingArgument",option);
885 if (IsGeometry(argv[i]) == MagickFalse)
886 ThrowMontageInvalidArgumentException(option,argv[i]);
887 break;
888 }
889 if (LocaleCompare("duration",option+1) == 0)
890 {
891 if (*option == '+')
892 break;
893 i++;
894 if (i == (ssize_t) argc)
895 ThrowMontageException(OptionError,"MissingArgument",option);
896 if (IsGeometry(argv[i]) == MagickFalse)
897 ThrowMontageInvalidArgumentException(option,argv[i]);
898 break;
899 }
900 ThrowMontageException(OptionError,"UnrecognizedOption",option)
901 }
902 case 'e':
903 {
904 if (LocaleCompare("encoding",option+1) == 0)
905 {
906 if (*option == '+')
907 break;
908 i++;
909 if (i == (ssize_t) argc)
910 ThrowMontageException(OptionError,"MissingArgument",option);
911 break;
912 }
913 if (LocaleCompare("endian",option+1) == 0)
914 {
915 ssize_t
916 endian;
917
918 if (*option == '+')
919 break;
920 i++;
921 if (i == (ssize_t) argc)
922 ThrowMontageException(OptionError,"MissingArgument",option);
923 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
924 argv[i]);
925 if (endian < 0)
926 ThrowMontageException(OptionError,"UnrecognizedEndianType",
927 argv[i]);
928 break;
929 }
930 if (LocaleCompare("extent",option+1) == 0)
931 {
932 if (*option == '+')
933 break;
934 i++;
935 if (i == (ssize_t) argc)
936 ThrowMontageException(OptionError,"MissingArgument",option);
937 if (IsGeometry(argv[i]) == MagickFalse)
938 ThrowMontageInvalidArgumentException(option,argv[i]);
939 break;
940 }
941 ThrowMontageException(OptionError,"UnrecognizedOption",option)
942 }
943 case 'f':
944 {
945 if (LocaleCompare("family",option+1) == 0)
946 {
947 if (*option == '+')
948 break;
949 i++;
950 if (i == (ssize_t) argc)
951 ThrowMontageException(OptionError,"MissingArgument",option);
952 break;
953 }
954 if (LocaleCompare("fill",option+1) == 0)
955 {
956 (void) QueryColorCompliance("none",AllCompliance,
957 &montage_info->fill,exception);
958 if (*option == '+')
959 break;
960 i++;
961 if (i == (ssize_t) argc)
962 ThrowMontageException(OptionError,"MissingArgument",option);
963 (void) QueryColorCompliance(argv[i],AllCompliance,
964 &montage_info->fill,exception);
965 break;
966 }
967 if (LocaleCompare("filter",option+1) == 0)
968 {
969 ssize_t
970 filter;
971
972 if (*option == '+')
973 break;
974 i++;
975 if (i == (ssize_t) argc)
976 ThrowMontageException(OptionError,"MissingArgument",option);
977 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
978 if (filter < 0)
979 ThrowMontageException(OptionError,"UnrecognizedImageFilter",
980 argv[i]);
981 break;
982 }
983 if (LocaleCompare("flatten",option+1) == 0)
984 break;
985 if (LocaleCompare("flip",option+1) == 0)
986 break;
987 if (LocaleCompare("flop",option+1) == 0)
988 break;
989 if (LocaleCompare("font",option+1) == 0)
990 {
991 if (*option == '+')
992 break;
993 i++;
994 if (i == (ssize_t) argc)
995 ThrowMontageException(OptionError,"MissingArgument",option);
996 (void) CloneString(&montage_info->font,argv[i]);
997 break;
998 }
999 if (LocaleCompare("format",option+1) == 0)
1000 {
1001 if (*option == '+')
1002 break;
1003 i++;
1004 if (i == (ssize_t) argc)
1005 ThrowMontageException(OptionError,"MissingArgument",option);
1006 format=argv[i];
1007 break;
1008 }
1009 if (LocaleCompare("frame",option+1) == 0)
1010 {
1011 if (k == 0)
1012 {
1013 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1014 (void) CloneString(&montage_info->frame,(char *) NULL);
1015 }
1016 if (*option == '+')
1017 break;
1018 i++;
1019 if (i == (ssize_t) argc)
1020 ThrowMontageException(OptionError,"MissingArgument",option);
1021 if (IsGeometry(argv[i]) == MagickFalse)
1022 ThrowMontageInvalidArgumentException(option,argv[i]);
1023 if (k == 0)
1024 (void) CloneString(&montage_info->frame,argv[i]);
1025 break;
1026 }
1027 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1028 }
1029 case 'g':
1030 {
1031 if (LocaleCompare("gamma",option+1) == 0)
1032 {
1033 i++;
1034 if (i == (ssize_t) argc)
1035 ThrowMontageException(OptionError,"MissingArgument",option);
1036 if (IsGeometry(argv[i]) == MagickFalse)
1037 ThrowMontageInvalidArgumentException(option,argv[i]);
1038 break;
1039 }
1040 if (LocaleCompare("geometry",option+1) == 0)
1041 {
1042 (void) CloneString(&montage_info->geometry,(char *) NULL);
1043 if (*option == '+')
1044 break;
1045 i++;
1046 if (i == (ssize_t) argc)
1047 ThrowMontageException(OptionError,"MissingArgument",option);
1048 if (IsGeometry(argv[i]) == MagickFalse)
1049 ThrowMontageInvalidArgumentException(option,argv[i]);
1050 (void) CloneString(&montage_info->geometry,argv[i]);
1051 break;
1052 }
1053 if (LocaleCompare("gravity",option+1) == 0)
1054 {
1055 ssize_t
1056 gravity;
1057
1058 montage_info->gravity=UndefinedGravity;
1059 if (*option == '+')
1060 break;
1061 i++;
1062 if (i == (ssize_t) argc)
1063 ThrowMontageException(OptionError,"MissingArgument",option);
1064 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1065 argv[i]);
1066 if (gravity < 0)
1067 ThrowMontageException(OptionError,"UnrecognizedGravityType",
1068 argv[i]);
1069 montage_info->gravity=(GravityType) gravity;
1070 break;
1071 }
1072 if (LocaleCompare("green-primary",option+1) == 0)
1073 {
1074 if (*option == '+')
1075 break;
1076 i++;
1077 if (i == (ssize_t) argc)
1078 ThrowMontageException(OptionError,"MissingArgument",option);
1079 if (IsGeometry(argv[i]) == MagickFalse)
1080 ThrowMontageInvalidArgumentException(option,argv[i]);
1081 break;
1082 }
1083 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1084 }
1085 case 'h':
1086 {
1087 if ((LocaleCompare("help",option+1) == 0) ||
1088 (LocaleCompare("-help",option+1) == 0))
1089 {
1090 DestroyMontage();
1091 return(MontageUsage());
1092 }
1093 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1094 }
1095 case 'i':
1096 {
1097 if (LocaleCompare("identify",option+1) == 0)
1098 break;
1099 if (LocaleCompare("insert",option+1) == 0)
1100 {
1101 if (*option == '+')
1102 break;
1103 i++;
1104 if (i == (ssize_t) argc)
1105 ThrowMontageException(OptionError,"MissingArgument",option);
1106 if (IsGeometry(argv[i]) == MagickFalse)
1107 ThrowMontageInvalidArgumentException(option,argv[i]);
1108 break;
1109 }
1110 if (LocaleCompare("interlace",option+1) == 0)
1111 {
1112 ssize_t
1113 interlace;
1114
1115 if (*option == '+')
1116 break;
1117 i++;
1118 if (i == (ssize_t) argc)
1119 ThrowMontageException(OptionError,"MissingArgument",option);
1120 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1121 argv[i]);
1122 if (interlace < 0)
1123 ThrowMontageException(OptionError,"UnrecognizedInterlaceType",
1124 argv[i]);
1125 break;
1126 }
1127 if (LocaleCompare("interpolate",option+1) == 0)
1128 {
1129 ssize_t
1130 interpolate;
1131
1132 if (*option == '+')
1133 break;
1134 i++;
1135 if (i == (ssize_t) argc)
1136 ThrowMontageException(OptionError,"MissingArgument",option);
1137 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1138 argv[i]);
1139 if (interpolate < 0)
1140 ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod",
1141 argv[i]);
1142 break;
1143 }
1144 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1145 }
1146 case 'k':
1147 {
1148 if (LocaleCompare("kerning",option+1) == 0)
1149 {
1150 if (*option == '+')
1151 break;
1152 i++;
1153 if (i == (ssize_t) argc)
1154 ThrowMontageException(OptionError,"MissingArgument",option);
1155 if (IsGeometry(argv[i]) == MagickFalse)
1156 ThrowMontageInvalidArgumentException(option,argv[i]);
1157 break;
1158 }
1159 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1160 }
1161 case 'l':
1162 {
1163 if (LocaleCompare("label",option+1) == 0)
1164 {
1165 if (*option == '+')
1166 break;
1167 i++;
1168 if (i == (ssize_t) argc)
1169 ThrowMontageException(OptionError,"MissingArgument",option);
1170 break;
1171 }
1172 if (LocaleCompare("layers",option+1) == 0)
1173 {
1174 ssize_t
1175 type;
1176
1177 if (*option == '+')
1178 break;
1179 i++;
1180 if (i == (ssize_t) argc)
1181 ThrowMontageException(OptionError,"MissingArgument",option);
1182 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
1183 if (type < 0)
1184 ThrowMontageException(OptionError,"UnrecognizedLayerMethod",
1185 argv[i]);
1186 break;
1187 }
1188 if (LocaleCompare("limit",option+1) == 0)
1189 {
1190 char
1191 *p;
1192
1193 double
1194 value;
1195
1196 ssize_t
1197 resource;
1198
1199 if (*option == '+')
1200 break;
1201 i++;
1202 if (i == (ssize_t) argc)
1203 ThrowMontageException(OptionError,"MissingArgument",option);
1204 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1205 argv[i]);
1206 if (resource < 0)
1207 ThrowMontageException(OptionError,"UnrecognizedResourceType",
1208 argv[i]);
1209 i++;
1210 if (i == (ssize_t) argc)
1211 ThrowMontageException(OptionError,"MissingArgument",option);
1212 value=StringToDouble(argv[i],&p);
1213 (void) value;
1214 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1215 ThrowMontageInvalidArgumentException(option,argv[i]);
1216 break;
1217 }
1218 if (LocaleCompare("list",option+1) == 0)
1219 {
1220 ssize_t
1221 list;
1222
1223 if (*option == '+')
1224 break;
1225 i++;
1226 if (i == (ssize_t) argc)
1227 ThrowMontageException(OptionError,"MissingArgument",option);
1228 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1229 if (list < 0)
1230 ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]);
1231 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1232 argv+j,exception);
1233 DestroyMontage();
1234 return(status == 0 ? MagickFalse : MagickTrue);
1235 }
1236 if (LocaleCompare("log",option+1) == 0)
1237 {
1238 if (*option == '+')
1239 break;
1240 i++;
1241 if ((i == (ssize_t) argc) ||
1242 (strchr(argv[i],'%') == (char *) NULL))
1243 ThrowMontageException(OptionError,"MissingArgument",option);
1244 break;
1245 }
1246 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1247 }
1248 case 'm':
1249 {
1250 if (LocaleCompare("matte",option+1) == 0)
1251 break;
1252 if (LocaleCompare("mattecolor",option+1) == 0)
1253 {
1254 if (*option == '+')
1255 break;
1256 i++;
1257 if (i == (ssize_t) argc)
1258 ThrowMontageException(OptionError,"MissingArgument",option);
1259 (void) QueryColorCompliance(argv[i],AllCompliance,
1260 &montage_info->matte_color,exception);
1261 break;
1262 }
1263 if (LocaleCompare("mode",option+1) == 0)
1264 {
1265 MontageMode
1266 mode;
1267
1268 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1269 if (*option == '+')
1270 break;
1271 i++;
1272 if (i == (ssize_t) argc)
1273 ThrowMontageException(OptionError,"MissingArgument",option);
1274 mode=UndefinedMode;
1275 if (LocaleCompare("frame",argv[i]) == 0)
1276 {
1277 mode=FrameMode;
1278 (void) CloneString(&montage_info->frame,"15x15+3+3");
1279 montage_info->shadow=MagickTrue;
1280 break;
1281 }
1282 if (LocaleCompare("unframe",argv[i]) == 0)
1283 {
1284 mode=UnframeMode;
1285 montage_info->frame=(char *) NULL;
1286 montage_info->shadow=MagickFalse;
1287 montage_info->border_width=0;
1288 break;
1289 }
1290 if (LocaleCompare("concatenate",argv[i]) == 0)
1291 {
1292 mode=ConcatenateMode;
1293 montage_info->frame=(char *) NULL;
1294 montage_info->shadow=MagickFalse;
1295 montage_info->gravity=(GravityType) NorthWestGravity;
1296 (void) CloneString(&montage_info->geometry,"+0+0");
1297 montage_info->border_width=0;
1298 break;
1299 }
1300 if (mode == UndefinedMode)
1301 ThrowMontageException(OptionError,"UnrecognizedImageMode",
1302 argv[i]);
1303 break;
1304 }
1305 if (LocaleCompare("monitor",option+1) == 0)
1306 break;
1307 if (LocaleCompare("monochrome",option+1) == 0)
1308 break;
1309 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1310 }
1311 case 'n':
1312 {
1313 if (LocaleCompare("noop",option+1) == 0)
1314 break;
1315 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1316 }
1317 case 'p':
1318 {
1319 if (LocaleCompare("page",option+1) == 0)
1320 {
1321 if (*option == '+')
1322 break;
1323 i++;
1324 if (i == (ssize_t) argc)
1325 ThrowMontageException(OptionError,"MissingArgument",option);
1326 break;
1327 }
1328 if (LocaleCompare("pointsize",option+1) == 0)
1329 {
1330 montage_info->pointsize=12;
1331 if (*option == '+')
1332 break;
1333 i++;
1334 if (i == (ssize_t) argc)
1335 ThrowMontageException(OptionError,"MissingArgument",option);
1336 if (IsGeometry(argv[i]) == MagickFalse)
1337 ThrowMontageInvalidArgumentException(option,argv[i]);
1338 montage_info->pointsize=StringToDouble(argv[i],(char **) NULL);
1339 break;
1340 }
1341 if (LocaleCompare("polaroid",option+1) == 0)
1342 {
1343 if (*option == '+')
1344 break;
1345 i++;
1346 if (i == (ssize_t) argc)
1347 ThrowMontageException(OptionError,"MissingArgument",option);
1348 if (IsGeometry(argv[i]) == MagickFalse)
1349 ThrowMontageInvalidArgumentException(option,argv[i]);
1350 break;
1351 }
1352 if (LocaleCompare("profile",option+1) == 0)
1353 {
1354 i++;
1355 if (i == (ssize_t) argc)
1356 ThrowMontageException(OptionError,"MissingArgument",option);
1357 break;
1358 }
1359 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1360 }
1361 case 'q':
1362 {
1363 if (LocaleCompare("quality",option+1) == 0)
1364 {
1365 if (*option == '+')
1366 break;
1367 i++;
1368 if (i == (ssize_t) argc)
1369 ThrowMontageException(OptionError,"MissingArgument",option);
1370 if (IsGeometry(argv[i]) == MagickFalse)
1371 ThrowMontageInvalidArgumentException(option,argv[i]);
1372 break;
1373 }
1374 if (LocaleCompare("quantize",option+1) == 0)
1375 {
1376 ssize_t
1377 colorspace;
1378
1379 if (*option == '+')
1380 break;
1381 i++;
1382 if (i == (ssize_t) argc)
1383 ThrowMontageException(OptionError,"MissingArgument",option);
1384 colorspace=ParseCommandOption(MagickColorspaceOptions,
1385 MagickFalse,argv[i]);
1386 if (colorspace < 0)
1387 ThrowMontageException(OptionError,"UnrecognizedColorspace",
1388 argv[i]);
1389 break;
1390 }
1391 if (LocaleCompare("quiet",option+1) == 0)
1392 break;
1393 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1394 }
1395 case 'r':
1396 {
1397 if (LocaleCompare("red-primary",option+1) == 0)
1398 {
1399 if (*option == '+')
1400 break;
1401 i++;
1402 if (i == (ssize_t) argc)
1403 ThrowMontageException(OptionError,"MissingArgument",option);
1404 if (IsGeometry(argv[i]) == MagickFalse)
1405 ThrowMontageInvalidArgumentException(option,argv[i]);
1406 break;
1407 }
1408 if (LocaleCompare("regard-warnings",option+1) == 0)
1409 break;
1410 if (LocaleCompare("render",option+1) == 0)
1411 break;
1412 if (LocaleCompare("repage",option+1) == 0)
1413 {
1414 if (*option == '+')
1415 break;
1416 i++;
1417 if (i == (ssize_t) argc)
1418 ThrowMontageException(OptionError,"MissingArgument",option);
1419 if (IsGeometry(argv[i]) == MagickFalse)
1420 ThrowMontageInvalidArgumentException(option,argv[i]);
1421 break;
1422 }
1423 if (LocaleCompare("resize",option+1) == 0)
1424 {
1425 if (*option == '+')
1426 break;
1427 i++;
1428 if (i == (ssize_t) argc)
1429 ThrowMontageException(OptionError,"MissingArgument",option);
1430 if (IsGeometry(argv[i]) == MagickFalse)
1431 ThrowMontageInvalidArgumentException(option,argv[i]);
1432 break;
1433 }
1434 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1435 {
1436 respect_parentheses=(*option == '-') ? MagickTrue : MagickFalse;
1437 break;
1438 }
1439 if (LocaleCompare("reverse",option+1) == 0)
1440 break;
1441 if (LocaleCompare("rotate",option+1) == 0)
1442 {
1443 i++;
1444 if (i == (ssize_t) argc)
1445 ThrowMontageException(OptionError,"MissingArgument",option);
1446 if (IsGeometry(argv[i]) == MagickFalse)
1447 ThrowMontageInvalidArgumentException(option,argv[i]);
1448 break;
1449 }
1450 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1451 }
1452 case 's':
1453 {
1454 if (LocaleCompare("sampling-factor",option+1) == 0)
1455 {
1456 if (*option == '+')
1457 break;
1458 i++;
1459 if (i == (ssize_t) argc)
1460 ThrowMontageException(OptionError,"MissingArgument",option);
1461 if (IsGeometry(argv[i]) == MagickFalse)
1462 ThrowMontageInvalidArgumentException(option,argv[i]);
1463 break;
1464 }
1465 if (LocaleCompare("scale",option+1) == 0)
1466 {
1467 if (*option == '+')
1468 break;
1469 i++;
1470 if (i == (ssize_t) argc)
1471 ThrowMontageException(OptionError,"MissingArgument",option);
1472 if (IsGeometry(argv[i]) == MagickFalse)
1473 ThrowMontageInvalidArgumentException(option,argv[i]);
1474 break;
1475 }
1476 if (LocaleCompare("scenes",option+1) == 0)
1477 {
1478 first_scene=0;
1479 last_scene=0;
1480 if (*option == '+')
1481 break;
1482 i++;
1483 if (i == (ssize_t) argc)
1484 ThrowMontageException(OptionError,"MissingArgument",option);
1485 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1486 ThrowMontageInvalidArgumentException(option,argv[i]);
1487 first_scene=StringToLong(argv[i]);
1488 last_scene=first_scene;
1489 (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene);
1490 break;
1491 }
1492 if (LocaleCompare("seed",option+1) == 0)
1493 {
1494 if (*option == '+')
1495 break;
1496 i++;
1497 if (i == (ssize_t) argc)
1498 ThrowMontageException(OptionError,"MissingArgument",option);
1499 if (IsGeometry(argv[i]) == MagickFalse)
1500 ThrowMontageInvalidArgumentException(option,argv[i]);
1501 break;
1502 }
1503 if (LocaleCompare("set",option+1) == 0)
1504 {
1505 i++;
1506 if (i == (ssize_t) argc)
1507 ThrowMontageException(OptionError,"MissingArgument",option);
1508 if (*option == '+')
1509 break;
1510 i++;
1511 if (i == (ssize_t) argc)
1512 ThrowMontageException(OptionError,"MissingArgument",option);
1513 break;
1514 }
1515 if (LocaleCompare("shadow",option+1) == 0)
1516 {
1517 if (k == 0)
1518 {
1519 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1520 montage_info->shadow=(*option == '-') ? MagickTrue :
1521 MagickFalse;
1522 break;
1523 }
1524 if (*option == '+')
1525 break;
1526 i++;
1527 if (i == (ssize_t) argc)
1528 ThrowMontageException(OptionError,"MissingArgument",option);
1529 if (IsGeometry(argv[i]) == MagickFalse)
1530 ThrowMontageInvalidArgumentException(option,argv[i]);
1531 break;
1532 }
1533 if (LocaleCompare("sharpen",option+1) == 0)
1534 {
1535 if (*option == '+')
1536 break;
1537 i++;
1538 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
1539 ThrowMontageException(OptionError,"MissingArgument",option);
1540 break;
1541 }
1542 if (LocaleCompare("size",option+1) == 0)
1543 {
1544 if (*option == '+')
1545 break;
1546 i++;
1547 if (i == (ssize_t) argc)
1548 ThrowMontageException(OptionError,"MissingArgument",option);
1549 if (IsGeometry(argv[i]) == MagickFalse)
1550 ThrowMontageInvalidArgumentException(option,argv[i]);
1551 break;
1552 }
1553 if (LocaleCompare("stroke",option+1) == 0)
1554 {
1555 (void) QueryColorCompliance("none",AllCompliance,
1556 &montage_info->stroke,exception);
1557 if (*option == '+')
1558 break;
1559 i++;
1560 if (i == (ssize_t) argc)
1561 ThrowMontageException(OptionError,"MissingArgument",option);
1562 (void) QueryColorCompliance(argv[i],AllCompliance,
1563 &montage_info->stroke,exception);
1564 break;
1565 }
1566 if (LocaleCompare("strip",option+1) == 0)
1567 break;
1568 if (LocaleCompare("strokewidth",option+1) == 0)
1569 {
1570 if (*option == '+')
1571 break;
1572 i++;
1573 if (i == (ssize_t) argc)
1574 ThrowMontageException(OptionError,"MissingArgument",option);
1575 if (IsGeometry(argv[i]) == MagickFalse)
1576 ThrowMontageInvalidArgumentException(option,argv[i]);
1577 break;
1578 }
1579 if (LocaleCompare("support",option+1) == 0)
1580 {
1581 i++; /* deprecated */
1582 break;
1583 }
1584 if (LocaleCompare("swap",option+1) == 0)
1585 {
1586 if (*option == '+')
1587 break;
1588 i++;
1589 if (i == (ssize_t) argc)
1590 ThrowMontageException(OptionError,"MissingArgument",option);
1591 if (IsGeometry(argv[i]) == MagickFalse)
1592 ThrowMontageInvalidArgumentException(option,argv[i]);
1593 break;
1594 }
1595 if (LocaleCompare("synchronize",option+1) == 0)
1596 break;
1597 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1598 }
1599 case 't':
1600 {
1601 if (LocaleCompare("taint",option+1) == 0)
1602 break;
1603 if (LocaleCompare("texture",option+1) == 0)
1604 {
1605 (void) CloneString(&montage_info->texture,(char *) NULL);
1606 if (*option == '+')
1607 break;
1608 i++;
1609 if (i == (ssize_t) argc)
1610 ThrowMontageException(OptionError,"MissingArgument",option);
1611 (void) CloneString(&montage_info->texture,argv[i]);
1612 break;
1613 }
1614 if (LocaleCompare("thumbnail",option+1) == 0)
1615 {
1616 if (*option == '+')
1617 break;
1618 i++;
1619 if (i == (ssize_t) argc)
1620 ThrowMontageException(OptionError,"MissingArgument",option);
1621 if (IsGeometry(argv[i]) == MagickFalse)
1622 ThrowMontageInvalidArgumentException(option,argv[i]);
1623 break;
1624 }
1625 if (LocaleCompare("tile",option+1) == 0)
1626 {
1627 if (k == 0)
1628 {
1629 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1630 (void) CloneString(&montage_info->tile,(char *) NULL);
1631 }
1632 if (*option == '+')
1633 break;
1634 i++;
1635 if (i == (ssize_t) argc)
1636 ThrowMontageException(OptionError,"MissingArgument",option);
1637 if (IsGeometry(argv[i]) == MagickFalse)
1638 ThrowMontageInvalidArgumentException(option,argv[i]);
1639 if (k == 0)
1640 (void) CloneString(&montage_info->tile,argv[i]);
1641 break;
1642 }
1643 if (LocaleCompare("tile-offset",option+1) == 0)
1644 {
1645 if (*option == '+')
1646 break;
1647 i++;
1648 if (i == (ssize_t) argc)
1649 ThrowMontageException(OptionError,"MissingArgument",option);
1650 if (IsGeometry(argv[i]) == MagickFalse)
1651 ThrowMontageInvalidArgumentException(option,argv[i]);
1652 break;
1653 }
1654 if (LocaleCompare("tint",option+1) == 0)
1655 {
1656 if (*option == '+')
1657 break;
1658 i++;
1659 if (i == (ssize_t) argc)
1660 ThrowMontageException(OptionError,"MissingArgument",option);
1661 if (IsGeometry(argv[i]) == MagickFalse)
1662 ThrowMontageInvalidArgumentException(option,argv[i]);
1663 break;
1664 }
1665 if (LocaleCompare("transform",option+1) == 0)
1666 break;
1667 if (LocaleCompare("transpose",option+1) == 0)
1668 break;
1669 if (LocaleCompare("title",option+1) == 0)
1670 {
1671 (void) CloneString(&montage_info->title,(char *) NULL);
1672 if (*option == '+')
1673 break;
1674 i++;
1675 if (i == (ssize_t) argc)
1676 ThrowMontageException(OptionError,"MissingArgument",option);
1677 (void) CloneString(&montage_info->title,argv[i]);
1678 break;
1679 }
1680 if (LocaleCompare("transform",option+1) == 0)
1681 break;
1682 if (LocaleCompare("transparent",option+1) == 0)
1683 {
1684 transparent_color=(char *) NULL;
1685 i++;
1686 if (i == (ssize_t) argc)
1687 ThrowMontageException(OptionError,"MissingArgument",option);
1688 (void) CloneString(&transparent_color,argv[i]);
1689 break;
1690 }
1691 if (LocaleCompare("transparent-color",option+1) == 0)
1692 {
1693 if (*option == '+')
1694 break;
1695 i++;
1696 if (i == (ssize_t) argc)
1697 ThrowMontageException(OptionError,"MissingArgument",option);
1698 break;
1699 }
1700 if (LocaleCompare("treedepth",option+1) == 0)
1701 {
1702 if (*option == '+')
1703 break;
1704 i++;
1705 if (i == (ssize_t) argc)
1706 ThrowMontageException(OptionError,"MissingArgument",option);
1707 if (IsGeometry(argv[i]) == MagickFalse)
1708 ThrowMontageInvalidArgumentException(option,argv[i]);
1709 break;
1710 }
1711 if (LocaleCompare("trim",option+1) == 0)
1712 break;
1713 if (LocaleCompare("type",option+1) == 0)
1714 {
1715 ssize_t
1716 type;
1717
1718 if (*option == '+')
1719 break;
1720 i++;
1721 if (i == (ssize_t) argc)
1722 ThrowMontageException(OptionError,"MissingArgument",option);
1723 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1724 if (type < 0)
1725 ThrowMontageException(OptionError,"UnrecognizedImageType",
1726 argv[i]);
1727 break;
1728 }
1729 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1730 }
1731 case 'u':
1732 {
1733 if (LocaleCompare("units",option+1) == 0)
1734 {
1735 ssize_t
1736 units;
1737
1738 if (*option == '+')
1739 break;
1740 i++;
1741 if (i == (ssize_t) argc)
1742 ThrowMontageException(OptionError,"MissingArgument",option);
1743 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1744 argv[i]);
1745 if (units < 0)
1746 ThrowMontageException(OptionError,"UnrecognizedUnitsType",
1747 argv[i]);
1748 break;
1749 }
1750 if (LocaleCompare("unsharp",option+1) == 0)
1751 {
1752 if (*option == '+')
1753 break;
1754 i++;
1755 if (i == (ssize_t) argc)
1756 ThrowMontageException(OptionError,"MissingArgument",option);
1757 if (IsGeometry(argv[i]) == MagickFalse)
1758 ThrowMontageInvalidArgumentException(option,argv[i]);
1759 break;
1760 }
1761 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1762 }
1763 case 'v':
1764 {
1765 if (LocaleCompare("verbose",option+1) == 0)
1766 {
1767 break;
1768 }
1769 if ((LocaleCompare("version",option+1) == 0) ||
1770 (LocaleCompare("-version",option+1) == 0))
1771 {
1772 ListMagickVersion(stdout);
1773 break;
1774 }
1775 if (LocaleCompare("virtual-pixel",option+1) == 0)
1776 {
1777 ssize_t
1778 method;
1779
1780 if (*option == '+')
1781 break;
1782 i++;
1783 if (i == (ssize_t) argc)
1784 ThrowMontageException(OptionError,"MissingArgument",option);
1785 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1786 argv[i]);
1787 if (method < 0)
1788 ThrowMontageException(OptionError,
1789 "UnrecognizedVirtualPixelMethod",argv[i]);
1790 break;
1791 }
1792 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1793 }
1794 case 'w':
1795 {
1796 if (LocaleCompare("white-point",option+1) == 0)
1797 {
1798 if (*option == '+')
1799 break;
1800 i++;
1801 if (i == (ssize_t) argc)
1802 ThrowMontageException(OptionError,"MissingArgument",option);
1803 if (IsGeometry(argv[i]) == MagickFalse)
1804 ThrowMontageInvalidArgumentException(option,argv[i]);
1805 break;
1806 }
1807 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1808 }
1809 case '?':
1810 break;
1811 default:
1812 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1813 }
1814 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1815 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1816 if (fire != MagickFalse)
1817 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1818 }
1819 if (k != 0)
1820 ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
1821 if (i-- != (ssize_t) (argc-1))
1822 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
1823 if (image == (Image *) NULL)
1824 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1825 FinalizeImageSettings(image_info,image,MagickTrue);
1826 if (image == (Image *) NULL)
1827 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1828 (void) CopyMagickString(montage_info->filename,argv[argc-1],MagickPathExtent);
1829 montage_image=MontageImageList(image_info,montage_info,image,exception);
1830 if (montage_image == (Image *) NULL)
1831 status=MagickFalse;
1832 else
1833 {
1834 /*
1835 Write image.
1836 */
1837 (void) CopyMagickString(image_info->filename,argv[argc-1],
1838 MagickPathExtent);
1839 (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1840 MagickPathExtent);
1841 if (*montage_image->magick == '\0')
1842 (void) CopyMagickString(montage_image->magick,image->magick,
1843 MagickPathExtent);
1844 status&=(MagickStatusType) WriteImages(image_info,montage_image,
1845 argv[argc-1],exception);
1846 if (metadata != (char **) NULL)
1847 {
1848 char
1849 *text;
1850
1851 text=InterpretImageProperties(image_info,montage_image,format,
1852 exception);
1853 if (text == (char *) NULL)
1854 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
1855 GetExceptionMessage(errno));
1856 (void) ConcatenateString(&(*metadata),text);
1857 text=DestroyString(text);
1858 }
1859 }
1860 DestroyMontage();
1861 return(status != 0 ? MagickTrue : MagickFalse);
1862}