2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
13 % MagickWand Methods to Create Image Thumbnails %
20 % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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.
45 #include "wand/studio.h"
46 #include "wand/MagickWand.h"
47 #include "wand/mogrify-private.h"
48 #include "magick/string-private.h"
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 + M o n t a g e I m a g e C o m m a n d %
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 % MontageImageCommand() reads one or more images, applies one or more image
62 % processing operations, and writes out the image in the same or
65 % The format of the MontageImageCommand method is:
67 % MagickBooleanType MontageImageCommand(ImageInfo *image_info,int argc,
68 % char **argv,char **metadata,ExceptionInfo *exception)
70 % A description of each parameter follows:
72 % o image_info: the image info.
74 % o argc: the number of elements in the argument vector.
76 % o argv: A text array containing the command line arguments.
78 % o metadata: any metadata is returned here.
80 % o exception: return any errors or warnings in this structure.
84 static MagickBooleanType MontageUsage(void)
92 "-debug events display copious debugging information",
93 "-help print program options",
94 "-list type print a list of supported option arguments",
95 "-log format format of debugging information",
96 "-version print version information",
101 "-adaptive-sharpen geometry",
102 " adaptively sharpen pixels; increase effect near edges",
103 " annotate geometry text",
104 " annotate the image with text",
105 "-auto-orient automagically orient image",
106 "-blur geometry reduce image noise and reduce detail levels",
107 "-border geometry surround image with a border of color",
108 "-crop geometry preferred size and location of the cropped image",
109 "-extent geometry set the image size",
110 "-flatten flatten a sequence of images",
111 "-flip flip image in the vertical direction",
112 "-flop flop image in the horizontal direction",
113 "-frame geometry surround image with an ornamental border",
114 "-monochrome transform image to black and white",
115 "-polaroid angle simulate a Polaroid picture",
116 "-repage geometry size and location of an image canvas (operator)",
117 "-resize geometry resize the image",
118 "-rotate degrees apply Paeth rotation to the image",
119 "-strip strip image of all profiles and comments",
120 "-transform affine transform image",
121 "-transpose flip image vertically and rotate 90 degrees",
122 "-transparent color make this color transparent within the image",
123 "-type type image type",
124 "-unsharp geometry sharpen the image",
129 "-adjoin join images into a single multi-image file",
130 "-affine matrix affine transform matrix",
131 "-alpha option on, activate, off, deactivate, set, opaque, copy",
132 " transparent, extract, background, or shape",
133 "-authenticate password",
134 " decipher image with this password",
135 "-blue-primary point chromaticity blue primary point",
136 "-bordercolor color border color",
137 "-caption string assign a caption to an image",
138 "-channel type apply option to select image channels",
139 "-colors value preferred number of colors in the image",
140 "-colorspace type alternate image colorsapce",
141 "-comment string annotate image with comment",
142 "-compose operator composite operator",
143 "-compress type type of pixel compression when writing the image",
144 "-define format:option",
145 " define one or more image format options",
146 "-density geometry horizontal and vertical density of the image",
147 "-depth value image depth",
148 "-display server query font from this X server",
149 "-dispose method layer disposal method",
150 "-dither method apply error diffusion to image",
151 "-draw string annotate the image with a graphic primitive",
152 "-encoding type text encoding type",
153 "-endian type endianness (MSB or LSB) of the image",
154 "-extract geometry extract area from image",
155 "-fill color color to use when filling a graphic primitive",
156 "-filter type use this filter when resizing an image",
157 "-font name render text with this font",
158 "-format \"string\" output formatted image characteristics",
159 "-gamma value level of gamma correction",
160 "-geometry geometry preferred tile and border sizes",
161 "-gravity direction which direction to gravitate towards",
162 "-green-primary point chromaticity green primary point",
163 "-identify identify the format and characteristics of the image",
164 "-interlace type type of image interlacing scheme",
165 "-interpolate method pixel color interpolation method",
166 "-label string assign a label to an image",
167 "-limit type value pixel cache resource limit",
168 "-mattecolor color frame color",
169 "-mode type framing style",
170 "-monitor monitor progress",
171 "-origin geometry image origin",
172 "-page geometry size and location of an image canvas (setting)",
173 "-pointsize value font point size",
174 "-profile filename add, delete, or apply an image profile",
175 "-quality value JPEG/MIFF/PNG compression level",
176 "-quantize colorspace reduce colors in this colorspace",
177 "-quiet suppress all warning messages",
178 "-red-primary point chromaticity red primary point",
179 "-regard-warnings pay attention to warning messages",
180 "-respect-parentheses settings remain in effect until parenthesis boundary",
181 "-sampling-factor geometry",
182 " horizontal and vertical sampling factor",
183 "-scenes range image scene range",
184 "-seed value seed a new sequence of pseudo-random numbers",
185 "-set attribute value set an image attribute",
186 "-shadow add a shadow beneath a tile to simulate depth",
187 "-size geometry width and height of image",
188 "-stroke color color to use when stroking a graphic primitive",
189 "-texture filename name of texture to tile onto the image background",
190 "-thumbnail geometry create a thumbnail of the image",
191 "-tile geometry number of tiles per row and column",
192 "-title string decorate the montage image with a title",
193 "-transparent-color color",
194 " transparent color",
195 "-treedepth value color tree depth",
196 "-trim trim image edges",
197 "-units type the units of image resolution",
198 "-verbose print detailed information about the image",
199 "-virtual-pixel method",
200 " virtual pixel access method",
201 "-white-point point chromaticity white point",
204 *sequence_operators[]=
206 "-coalesce merge a sequence of images",
207 "-composite composite image",
212 "-clone index clone an image",
216 (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
217 (void) printf("Copyright: %s\n",GetMagickCopyright());
218 (void) printf("Features: %s\n\n",GetMagickFeatures());
219 (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n",
221 (void) printf("\nImage Settings:\n");
222 for (p=settings; *p != (char *) NULL; p++)
223 (void) printf(" %s\n",*p);
224 (void) printf("\nImage Operators:\n");
225 for (p=operators; *p != (char *) NULL; p++)
226 (void) printf(" %s\n",*p);
227 (void) printf("\nImage Sequence Operators:\n");
228 for (p=sequence_operators; *p != (char *) NULL; p++)
229 (void) printf(" %s\n",*p);
230 (void) printf("\nImage Stack Operators:\n");
231 for (p=stack_operators; *p != (char *) NULL; p++)
232 (void) printf(" %s\n",*p);
233 (void) printf("\nMiscellaneous Options:\n");
234 for (p=miscellaneous; *p != (char *) NULL; p++)
235 (void) printf(" %s\n",*p);
237 "\nIn addition to those listed above, you can specify these standard X\n");
239 "resources as command line options: -background, -bordercolor,\n");
241 "-borderwidth, -font, -mattecolor, or -title\n");
243 "\nBy default, the image format of `file' is determined by its magic\n");
245 "number. To specify a particular image format, precede the filename\n");
247 "with an image format name and a colon (i.e. ps:image) or specify the\n");
249 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
250 (void) printf("'-' for standard input or output.\n");
254 WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
255 int argc,char **argv,char **metadata,ExceptionInfo *exception)
257 #define DestroyMontage() \
259 if (montage_image != (Image *) NULL) \
260 montage_image=DestroyImageList(montage_image); \
261 DestroyImageStack(); \
262 for (i=0; i < (long) argc; i++) \
263 argv[i]=DestroyString(argv[i]); \
264 argv=(char **) RelinquishMagickMemory(argv); \
266 #define ThrowMontageException(asperity,tag,option) \
268 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
271 return(MagickFalse); \
273 #define ThrowMontageInvalidArgumentException(option,argument) \
275 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
276 "InvalidArgument","`%s': %s",option,argument); \
278 return(MagickFalse); \
293 image_stack[MaxImageStackDepth+1];
318 assert(image_info != (ImageInfo *) NULL);
319 assert(image_info->signature == MagickSignature);
320 if (image_info->debug != MagickFalse)
321 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
322 assert(exception != (ExceptionInfo *) NULL);
326 if ((LocaleCompare("version",option+1) == 0) ||
327 (LocaleCompare("-version",option+1) == 0))
329 (void) fprintf(stdout,"Version: %s\n",
330 GetMagickVersion((unsigned long *) NULL));
331 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
332 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
337 return(MontageUsage());
343 montage_image=NewImageList();
344 montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
346 option=(char *) NULL;
350 transparent_color=(char *) NULL;
354 ReadCommandlLine(argc,&argv);
355 status=ExpandFilenames(&argc,&argv);
356 if (status == MagickFalse)
357 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
358 GetExceptionMessage(errno));
359 for (i=1; i < (long) (argc-1); i++)
362 if (LocaleCompare(option,"(") == 0)
364 FireImageStack(MagickTrue,MagickTrue,pend);
365 if (k == MaxImageStackDepth)
366 ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply",
371 if (LocaleCompare(option,")") == 0)
373 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
375 ThrowMontageException(OptionError,"UnableToParseExpression",option);
379 if (IsMagickOption(option) == MagickFalse)
384 FireImageStack(MagickFalse,MagickFalse,pend);
385 for (scene=first_scene; scene <= last_scene ; scene++)
391 Option is a file name: begin by reading image from specified file.
394 if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
396 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
397 if (first_scene != last_scene)
400 filename[MaxTextExtent];
403 Form filename for multi-part images.
405 (void) InterpretImageFilename(image_info,(Image *) NULL,
406 image_info->filename,(int) scene,filename);
407 if (LocaleCompare(filename,image_info->filename) == 0)
408 (void) FormatMagickString(filename,MaxTextExtent,"%s.%lu",
409 image_info->filename,scene);
410 (void) CopyMagickString(image_info->filename,filename,
413 (void) CloneString(&image_info->font,montage_info->font);
414 images=ReadImages(image_info,exception);
415 status&=(images != (Image *) NULL) &&
416 (exception->severity < ErrorException);
417 if (images == (Image *) NULL)
419 AppendImageStack(images);
423 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
428 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
431 if (i == (long) (argc-1))
432 ThrowMontageException(OptionError,"MissingArgument",option);
433 if (IsGeometry(argv[i]) == MagickFalse)
434 ThrowMontageInvalidArgumentException(option,argv[i]);
437 if (LocaleCompare("adjoin",option+1) == 0)
439 if (LocaleCompare("affine",option+1) == 0)
444 if (i == (long) (argc-1))
445 ThrowMontageException(OptionError,"MissingArgument",option);
446 if (IsGeometry(argv[i]) == MagickFalse)
447 ThrowMontageInvalidArgumentException(option,argv[i]);
450 if (LocaleCompare("alpha",option+1) == 0)
458 if (i == (long) argc)
459 ThrowMontageException(OptionError,"MissingArgument",option);
460 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
462 ThrowMontageException(OptionError,"UnrecognizedAlphaChannelType",
466 if (LocaleCompare("annotate",option+1) == 0)
471 if (i == (long) (argc-1))
472 ThrowMontageException(OptionError,"MissingArgument",option);
473 if (IsGeometry(argv[i]) == MagickFalse)
474 ThrowMontageInvalidArgumentException(option,argv[i]);
475 if (i == (long) (argc-1))
476 ThrowMontageException(OptionError,"MissingArgument",option);
480 if (LocaleCompare("auto-orient",option+1) == 0)
482 if (LocaleCompare("authenticate",option+1) == 0)
487 if (i == (long) argc)
488 ThrowMontageException(OptionError,"MissingArgument",option);
491 ThrowMontageException(OptionError,"UnrecognizedOption",option)
495 if (LocaleCompare("background",option+1) == 0)
500 if (i == (long) argc)
501 ThrowMontageException(OptionError,"MissingArgument",option);
502 (void) QueryColorDatabase(argv[i],
503 &montage_info->background_color,exception);
506 if (LocaleCompare("blue-primary",option+1) == 0)
511 if (i == (long) argc)
512 ThrowMontageException(OptionError,"MissingArgument",option);
513 if (IsGeometry(argv[i]) == MagickFalse)
514 ThrowMontageInvalidArgumentException(option,argv[i]);
517 if (LocaleCompare("blur",option+1) == 0)
522 if (i == (long) argc)
523 ThrowMontageException(OptionError,"MissingArgument",option);
524 if (IsGeometry(argv[i]) == MagickFalse)
525 ThrowMontageInvalidArgumentException(option,argv[i]);
528 if (LocaleCompare("border",option+1) == 0)
530 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
531 montage_info->border_width=0;
535 if (i == (long) argc)
536 ThrowMontageException(OptionError,"MissingArgument",option);
537 if (IsGeometry(argv[i]) == MagickFalse)
538 ThrowMontageInvalidArgumentException(option,argv[i]);
539 montage_info->border_width=StringToUnsignedLong(argv[i]);
542 if (LocaleCompare("bordercolor",option+1) == 0)
547 if (i == (long) argc)
548 ThrowMontageException(OptionError,"MissingArgument",option);
549 (void) QueryColorDatabase(argv[i],&montage_info->border_color,
553 if (LocaleCompare("borderwidth",option+1) == 0)
555 montage_info->border_width=0;
559 if (i == (long) argc)
560 ThrowMontageException(OptionError,"MissingArgument",option);
561 if (IsGeometry(argv[i]) == MagickFalse)
562 ThrowMontageInvalidArgumentException(option,argv[i]);
563 montage_info->border_width=StringToUnsignedLong(argv[i]);
566 ThrowMontageException(OptionError,"UnrecognizedOption",option)
570 if (LocaleCompare("cache",option+1) == 0)
575 if (i == (long) argc)
576 ThrowMontageException(OptionError,"MissingArgument",option);
577 if (IsGeometry(argv[i]) == MagickFalse)
578 ThrowMontageInvalidArgumentException(option,argv[i]);
581 if (LocaleCompare("caption",option+1) == 0)
586 if (i == (long) argc)
587 ThrowMontageException(OptionError,"MissingArgument",option);
590 if (LocaleCompare("channel",option+1) == 0)
598 if (i == (long) (argc-1))
599 ThrowMontageException(OptionError,"MissingArgument",option);
600 channel=ParseChannelOption(argv[i]);
602 ThrowMontageException(OptionError,"UnrecognizedChannelType",
606 if (LocaleCompare("clone",option+1) == 0)
613 clone_images=image_stack[k-1].image;
614 if (clone_images == (Image *) NULL)
615 ThrowMontageException(ImageError,"ImageSequenceRequired",option);
616 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
618 clone_images=CloneImages(clone_images,"-1",exception);
622 if (i == (long) (argc-1))
623 ThrowMontageException(OptionError,"MissingArgument",option);
624 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
625 ThrowMontageInvalidArgumentException(option,argv[i]);
626 clone_images=CloneImages(clone_images,argv[i],exception);
628 if (clone_images == (Image *) NULL)
629 ThrowMontageException(OptionError,"NoSuchImage",option);
630 AppendImageStack(clone_images);
633 if (LocaleCompare("coalesce",option+1) == 0)
635 if (LocaleCompare("colors",option+1) == 0)
640 if (i == (long) argc)
641 ThrowMontageException(OptionError,"MissingArgument",option);
642 if (IsGeometry(argv[i]) == MagickFalse)
643 ThrowMontageInvalidArgumentException(option,argv[i]);
646 if (LocaleCompare("colorspace",option+1) == 0)
654 if (i == (long) argc)
655 ThrowMontageException(OptionError,"MissingArgument",option);
656 colorspace=ParseMagickOption(MagickColorspaceOptions,
657 MagickFalse,argv[i]);
659 ThrowMontageException(OptionError,"UnrecognizedColorspace",
663 if (LocaleCompare("comment",option+1) == 0)
668 if (i == (long) argc)
669 ThrowMontageException(OptionError,"MissingArgument",option);
672 if (LocaleCompare("compose",option+1) == 0)
680 if (i == (long) argc)
681 ThrowMontageException(OptionError,"MissingArgument",option);
682 compose=ParseMagickOption(MagickComposeOptions,MagickFalse,argv[i]);
684 ThrowMontageException(OptionError,"UnrecognizedComposeOperator",
688 if (LocaleCompare("composite",option+1) == 0)
690 if (LocaleCompare("compress",option+1) == 0)
698 if (i == (long) argc)
699 ThrowMontageException(OptionError,"MissingArgument",option);
700 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
703 ThrowMontageException(OptionError,"UnrecognizedCompressType",
707 if (LocaleCompare("concurrent",option+1) == 0)
709 if (LocaleCompare("crop",option+1) == 0)
714 if (i == (long) argc)
715 ThrowMontageException(OptionError,"MissingArgument",option);
716 if (IsGeometry(argv[i]) == MagickFalse)
717 ThrowMontageInvalidArgumentException(option,argv[i]);
720 ThrowMontageException(OptionError,"UnrecognizedOption",option)
724 if (LocaleCompare("debug",option+1) == 0)
732 if (i == (long) argc)
733 ThrowMontageException(OptionError,"MissingArgument",option);
734 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
736 ThrowMontageException(OptionError,"UnrecognizedEventType",
738 (void) SetLogEventMask(argv[i]);
741 if (LocaleCompare("define",option+1) == 0)
744 if (i == (long) argc)
745 ThrowMontageException(OptionError,"MissingArgument",option);
751 define=GetImageOption(image_info,argv[i]);
752 if (define == (const char *) NULL)
753 ThrowMontageException(OptionError,"NoSuchOption",argv[i]);
758 if (LocaleCompare("density",option+1) == 0)
763 if (i == (long) argc)
764 ThrowMontageException(OptionError,"MissingArgument",option);
765 if (IsGeometry(argv[i]) == MagickFalse)
766 ThrowMontageInvalidArgumentException(option,argv[i]);
769 if (LocaleCompare("depth",option+1) == 0)
774 if (i == (long) argc)
775 ThrowMontageException(OptionError,"MissingArgument",option);
776 if (IsGeometry(argv[i]) == MagickFalse)
777 ThrowMontageInvalidArgumentException(option,argv[i]);
780 if (LocaleCompare("display",option+1) == 0)
785 if (i == (long) argc)
786 ThrowMontageException(OptionError,"MissingArgument",option);
789 if (LocaleCompare("dispose",option+1) == 0)
797 if (i == (long) argc)
798 ThrowMontageException(OptionError,"MissingArgument",option);
799 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
801 ThrowMontageException(OptionError,"UnrecognizedDisposeMethod",
805 if (LocaleCompare("dither",option+1) == 0)
813 if (i == (long) argc)
814 ThrowMontageException(OptionError,"MissingArgument",option);
815 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
817 ThrowMontageException(OptionError,"UnrecognizedDitherMethod",
821 if (LocaleCompare("draw",option+1) == 0)
826 if (i == (long) argc)
827 ThrowMontageException(OptionError,"MissingArgument",option);
830 if (LocaleCompare("duration",option+1) == 0)
835 if (i == (long) (argc-1))
836 ThrowMontageException(OptionError,"MissingArgument",option);
837 if (IsGeometry(argv[i]) == MagickFalse)
838 ThrowMontageInvalidArgumentException(option,argv[i]);
841 ThrowMontageException(OptionError,"UnrecognizedOption",option)
845 if (LocaleCompare("encoding",option+1) == 0)
850 if (i == (long) argc)
851 ThrowMontageException(OptionError,"MissingArgument",option);
854 if (LocaleCompare("endian",option+1) == 0)
862 if (i == (long) argc)
863 ThrowMontageException(OptionError,"MissingArgument",option);
864 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
867 ThrowMontageException(OptionError,"UnrecognizedEndianType",
871 if (LocaleCompare("extent",option+1) == 0)
876 if (i == (long) (argc-1))
877 ThrowMontageException(OptionError,"MissingArgument",option);
878 if (IsGeometry(argv[i]) == MagickFalse)
879 ThrowMontageInvalidArgumentException(option,argv[i]);
882 ThrowMontageException(OptionError,"UnrecognizedOption",option)
886 if (LocaleCompare("fill",option+1) == 0)
888 (void) QueryColorDatabase("none",&montage_info->fill,exception);
892 if (i == (long) argc)
893 ThrowMontageException(OptionError,"MissingArgument",option);
894 (void) QueryColorDatabase(argv[i],&montage_info->fill,
898 if (LocaleCompare("filter",option+1) == 0)
906 if (i == (long) argc)
907 ThrowMontageException(OptionError,"MissingArgument",option);
908 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
910 ThrowMontageException(OptionError,"UnrecognizedImageFilter",
914 if (LocaleCompare("flatten",option+1) == 0)
916 if (LocaleCompare("flip",option+1) == 0)
918 if (LocaleCompare("flop",option+1) == 0)
920 if (LocaleCompare("font",option+1) == 0)
925 if (i == (long) argc)
926 ThrowMontageException(OptionError,"MissingArgument",option);
927 (void) CloneString(&montage_info->font,argv[i]);
930 if (LocaleCompare("format",option+1) == 0)
935 if (i == (long) argc)
936 ThrowMontageException(OptionError,"MissingArgument",option);
940 if (LocaleCompare("frame",option+1) == 0)
942 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
943 (void) CloneString(&montage_info->frame,(char *) NULL);
947 if (i == (long) argc)
948 ThrowMontageException(OptionError,"MissingArgument",option);
949 if (IsGeometry(argv[i]) == MagickFalse)
950 ThrowMontageInvalidArgumentException(option,argv[i]);
951 (void) CloneString(&montage_info->frame,argv[i]);
954 ThrowMontageException(OptionError,"UnrecognizedOption",option)
958 if (LocaleCompare("gamma",option+1) == 0)
961 if (i == (long) argc)
962 ThrowMontageException(OptionError,"MissingArgument",option);
963 if (IsGeometry(argv[i]) == MagickFalse)
964 ThrowMontageInvalidArgumentException(option,argv[i]);
967 if (LocaleCompare("geometry",option+1) == 0)
969 (void) CloneString(&montage_info->geometry,(char *) NULL);
973 if (i == (long) argc)
974 ThrowMontageException(OptionError,"MissingArgument",option);
975 if (IsGeometry(argv[i]) == MagickFalse)
976 ThrowMontageInvalidArgumentException(option,argv[i]);
977 (void) CloneString(&montage_info->geometry,argv[i]);
980 if (LocaleCompare("gravity",option+1) == 0)
985 montage_info->gravity=UndefinedGravity;
989 if (i == (long) argc)
990 ThrowMontageException(OptionError,"MissingArgument",option);
991 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
994 ThrowMontageException(OptionError,"UnrecognizedGravityType",
996 montage_info->gravity=(GravityType) gravity;
999 if (LocaleCompare("green-primary",option+1) == 0)
1004 if (i == (long) argc)
1005 ThrowMontageException(OptionError,"MissingArgument",option);
1006 if (IsGeometry(argv[i]) == MagickFalse)
1007 ThrowMontageInvalidArgumentException(option,argv[i]);
1010 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1014 if ((LocaleCompare("help",option+1) == 0) ||
1015 (LocaleCompare("-help",option+1) == 0))
1016 return(MontageUsage());
1017 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1021 if (LocaleCompare("identify",option+1) == 0)
1023 if (LocaleCompare("interlace",option+1) == 0)
1031 if (i == (long) argc)
1032 ThrowMontageException(OptionError,"MissingArgument",option);
1033 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
1036 ThrowMontageException(OptionError,"UnrecognizedInterlaceType",
1040 if (LocaleCompare("interpolate",option+1) == 0)
1048 if (i == (long) argc)
1049 ThrowMontageException(OptionError,"MissingArgument",option);
1050 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
1052 if (interpolate < 0)
1053 ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod",
1057 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1061 if (LocaleCompare("label",option+1) == 0)
1066 if (i == (long) argc)
1067 ThrowMontageException(OptionError,"MissingArgument",option);
1070 if (LocaleCompare("limit",option+1) == 0)
1084 if (i == (long) argc)
1085 ThrowMontageException(OptionError,"MissingArgument",option);
1086 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
1089 ThrowMontageException(OptionError,"UnrecognizedResourceType",
1092 if (i == (long) argc)
1093 ThrowMontageException(OptionError,"MissingArgument",option);
1094 value=strtod(argv[i],&p);
1095 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1096 ThrowMontageInvalidArgumentException(option,argv[i]);
1099 if (LocaleCompare("list",option+1) == 0)
1107 if (i == (long) argc)
1108 ThrowMontageException(OptionError,"MissingArgument",option);
1109 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
1111 ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]);
1112 (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1117 if (LocaleCompare("log",option+1) == 0)
1122 if ((i == (long) argc) ||
1123 (strchr(argv[i],'%') == (char *) NULL))
1124 ThrowMontageException(OptionError,"MissingArgument",option);
1127 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1131 if (LocaleCompare("matte",option+1) == 0)
1133 if (LocaleCompare("mattecolor",option+1) == 0)
1138 if (i == (long) argc)
1139 ThrowMontageException(OptionError,"MissingArgument",option);
1140 (void) QueryColorDatabase(argv[i],&montage_info->matte_color,
1144 if (LocaleCompare("mode",option+1) == 0)
1152 if (i == (long) argc)
1153 ThrowMontageException(OptionError,"MissingArgument",option);
1155 if (LocaleCompare("frame",argv[i]) == 0)
1158 (void) CloneString(&montage_info->frame,"15x15+3+3");
1159 montage_info->shadow=MagickTrue;
1162 if (LocaleCompare("unframe",argv[i]) == 0)
1165 montage_info->frame=(char *) NULL;
1166 montage_info->shadow=MagickFalse;
1167 montage_info->border_width=0;
1170 if (LocaleCompare("concatenate",argv[i]) == 0)
1172 mode=ConcatenateMode;
1173 montage_info->frame=(char *) NULL;
1174 montage_info->shadow=MagickFalse;
1175 montage_info->gravity=(GravityType) NorthWestGravity;
1176 (void) CloneString(&montage_info->geometry,"+0+0");
1177 montage_info->border_width=0;
1180 if (mode == UndefinedMode)
1181 ThrowMontageException(OptionError,"UnrecognizedImageMode",
1185 if (LocaleCompare("monitor",option+1) == 0)
1187 if (LocaleCompare("monochrome",option+1) == 0)
1193 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1197 if (LocaleCompare("noop",option+1) == 0)
1199 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1203 if (LocaleCompare("origin",option+1) == 0)
1208 if (i == (long) argc)
1209 ThrowMontageException(OptionError,"MissingArgument",option);
1210 if (IsGeometry(argv[i]) == MagickFalse)
1211 ThrowMontageInvalidArgumentException(option,argv[i]);
1214 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1218 if (LocaleCompare("page",option+1) == 0)
1223 if (i == (long) argc)
1224 ThrowMontageException(OptionError,"MissingArgument",option);
1227 if (LocaleCompare("pointsize",option+1) == 0)
1229 montage_info->pointsize=12;
1233 if (i == (long) argc)
1234 ThrowMontageException(OptionError,"MissingArgument",option);
1235 if (IsGeometry(argv[i]) == MagickFalse)
1236 ThrowMontageInvalidArgumentException(option,argv[i]);
1237 montage_info->pointsize=StringToDouble(argv[i]);
1240 if (LocaleCompare("polaroid",option+1) == 0)
1245 if (i == (long) (argc-1))
1246 ThrowMontageException(OptionError,"MissingArgument",option);
1247 if (IsGeometry(argv[i]) == MagickFalse)
1248 ThrowMontageInvalidArgumentException(option,argv[i]);
1251 if (LocaleCompare("profile",option+1) == 0)
1254 if (i == (long) (argc-1))
1255 ThrowMontageException(OptionError,"MissingArgument",option);
1258 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1262 if (LocaleCompare("quality",option+1) == 0)
1267 if (i == (long) argc)
1268 ThrowMontageException(OptionError,"MissingArgument",option);
1269 if (IsGeometry(argv[i]) == MagickFalse)
1270 ThrowMontageInvalidArgumentException(option,argv[i]);
1273 if (LocaleCompare("quantize",option+1) == 0)
1281 if (i == (long) (argc-1))
1282 ThrowMontageException(OptionError,"MissingArgument",option);
1283 colorspace=ParseMagickOption(MagickColorspaceOptions,
1284 MagickFalse,argv[i]);
1286 ThrowMontageException(OptionError,"UnrecognizedColorspace",
1290 if (LocaleCompare("quiet",option+1) == 0)
1292 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1296 if (LocaleCompare("red-primary",option+1) == 0)
1301 if (i == (long) argc)
1302 ThrowMontageException(OptionError,"MissingArgument",option);
1303 if (IsGeometry(argv[i]) == MagickFalse)
1304 ThrowMontageInvalidArgumentException(option,argv[i]);
1307 if (LocaleCompare("regard-warnings",option+1) == 0)
1309 if (LocaleCompare("render",option+1) == 0)
1311 if (LocaleCompare("repage",option+1) == 0)
1316 if (i == (long) argc)
1317 ThrowMontageException(OptionError,"MissingArgument",option);
1318 if (IsGeometry(argv[i]) == MagickFalse)
1319 ThrowMontageInvalidArgumentException(option,argv[i]);
1322 if (LocaleCompare("resize",option+1) == 0)
1327 if (i == (long) argc)
1328 ThrowMontageException(OptionError,"MissingArgument",option);
1329 if (IsGeometry(argv[i]) == MagickFalse)
1330 ThrowMontageInvalidArgumentException(option,argv[i]);
1333 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1335 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1338 if (LocaleCompare("rotate",option+1) == 0)
1341 if (i == (long) argc)
1342 ThrowMontageException(OptionError,"MissingArgument",option);
1343 if (IsGeometry(argv[i]) == MagickFalse)
1344 ThrowMontageInvalidArgumentException(option,argv[i]);
1347 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1351 if (LocaleCompare("sampling-factor",option+1) == 0)
1356 if (i == (long) argc)
1357 ThrowMontageException(OptionError,"MissingArgument",option);
1358 if (IsGeometry(argv[i]) == MagickFalse)
1359 ThrowMontageInvalidArgumentException(option,argv[i]);
1362 if (LocaleCompare("seed",option+1) == 0)
1367 if (i == (long) (argc-1))
1368 ThrowMontageException(OptionError,"MissingArgument",option);
1369 if (IsGeometry(argv[i]) == MagickFalse)
1370 ThrowMontageInvalidArgumentException(option,argv[i]);
1373 if (LocaleCompare("scenes",option+1) == 0)
1380 if (i == (long) argc)
1381 ThrowMontageException(OptionError,"MissingArgument",option);
1382 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1383 ThrowMontageInvalidArgumentException(option,argv[i]);
1384 first_scene=StringToLong(argv[i]);
1385 last_scene=first_scene;
1386 (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene);
1389 if (LocaleCompare("set",option+1) == 0)
1392 if (i == (long) argc)
1393 ThrowMontageException(OptionError,"MissingArgument",option);
1397 if (i == (long) argc)
1398 ThrowMontageException(OptionError,"MissingArgument",option);
1401 if (LocaleCompare("shadow",option+1) == 0)
1403 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1404 montage_info->shadow=(*option == '-') ? MagickTrue : MagickFalse;
1407 if (LocaleCompare("sharpen",option+1) == 0)
1412 if ((i == (long) argc) || (IsGeometry(argv[i]) == MagickFalse))
1413 ThrowMontageException(OptionError,"MissingArgument",option);
1416 if (LocaleCompare("size",option+1) == 0)
1421 if (i == (long) argc)
1422 ThrowMontageException(OptionError,"MissingArgument",option);
1423 if (IsGeometry(argv[i]) == MagickFalse)
1424 ThrowMontageInvalidArgumentException(option,argv[i]);
1427 if (LocaleCompare("stroke",option+1) == 0)
1429 (void) QueryColorDatabase("none",&montage_info->stroke,exception);
1433 if (i == (long) argc)
1434 ThrowMontageException(OptionError,"MissingArgument",option);
1435 (void) QueryColorDatabase(argv[i],&montage_info->stroke,
1439 if (LocaleCompare("strip",option+1) == 0)
1441 if (LocaleCompare("strokewidth",option+1) == 0)
1446 if (i == (long) argc)
1447 ThrowMontageException(OptionError,"MissingArgument",option);
1448 if (IsGeometry(argv[i]) == MagickFalse)
1449 ThrowMontageInvalidArgumentException(option,argv[i]);
1452 if (LocaleCompare("support",option+1) == 0)
1454 i++; /* deprecated */
1457 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1461 if (LocaleCompare("texture",option+1) == 0)
1463 (void) CloneString(&montage_info->texture,(char *) NULL);
1467 if (i == (long) argc)
1468 ThrowMontageException(OptionError,"MissingArgument",option);
1469 (void) CloneString(&montage_info->texture,argv[i]);
1472 if (LocaleCompare("thumbnail",option+1) == 0)
1477 if (i == (long) argc)
1478 ThrowMontageException(OptionError,"MissingArgument",option);
1479 if (IsGeometry(argv[i]) == MagickFalse)
1480 ThrowMontageInvalidArgumentException(option,argv[i]);
1483 if (LocaleCompare("tile",option+1) == 0)
1485 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1486 (void) CloneString(&montage_info->tile,(char *) NULL);
1490 if (i == (long) argc)
1491 ThrowMontageException(OptionError,"MissingArgument",option);
1492 if (IsGeometry(argv[i]) == MagickFalse)
1493 ThrowMontageInvalidArgumentException(option,argv[i]);
1494 (void) CloneString(&montage_info->tile,argv[i]);
1497 if (LocaleCompare("tile-offset",option+1) == 0)
1502 if (i == (long) (argc-1))
1503 ThrowMontageException(OptionError,"MissingArgument",option);
1504 if (IsGeometry(argv[i]) == MagickFalse)
1505 ThrowMontageInvalidArgumentException(option,argv[i]);
1508 if (LocaleCompare("tint",option+1) == 0)
1513 if (i == (long) argc)
1514 ThrowMontageException(OptionError,"MissingArgument",option);
1515 if (IsGeometry(argv[i]) == MagickFalse)
1516 ThrowMontageInvalidArgumentException(option,argv[i]);
1519 if (LocaleCompare("transform",option+1) == 0)
1521 if (LocaleCompare("transpose",option+1) == 0)
1523 if (LocaleCompare("title",option+1) == 0)
1525 (void) CloneString(&montage_info->title,(char *) NULL);
1529 if (i == (long) argc)
1530 ThrowMontageException(OptionError,"MissingArgument",option);
1531 (void) CloneString(&montage_info->title,argv[i]);
1534 if (LocaleCompare("transform",option+1) == 0)
1536 if (LocaleCompare("transparent",option+1) == 0)
1538 transparent_color=(char *) NULL;
1540 if (i == (long) argc)
1541 ThrowMontageException(OptionError,"MissingArgument",option);
1542 (void) CloneString(&transparent_color,argv[i]);
1545 if (LocaleCompare("transparent-color",option+1) == 0)
1550 if (i == (long) (argc-1))
1551 ThrowMontageException(OptionError,"MissingArgument",option);
1554 if (LocaleCompare("treedepth",option+1) == 0)
1559 if (i == (long) argc)
1560 ThrowMontageException(OptionError,"MissingArgument",option);
1561 if (IsGeometry(argv[i]) == MagickFalse)
1562 ThrowMontageInvalidArgumentException(option,argv[i]);
1565 if (LocaleCompare("trim",option+1) == 0)
1567 if (LocaleCompare("type",option+1) == 0)
1575 if (i == (long) argc)
1576 ThrowMontageException(OptionError,"MissingArgument",option);
1577 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
1579 ThrowMontageException(OptionError,"UnrecognizedImageType",
1583 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1587 if (LocaleCompare("units",option+1) == 0)
1595 if (i == (long) (argc-1))
1596 ThrowMontageException(OptionError,"MissingArgument",option);
1597 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
1600 ThrowMontageException(OptionError,"UnrecognizedUnitsType",
1604 if (LocaleCompare("unsharp",option+1) == 0)
1609 if (i == (long) (argc-1))
1610 ThrowMontageException(OptionError,"MissingArgument",option);
1611 if (IsGeometry(argv[i]) == MagickFalse)
1612 ThrowMontageInvalidArgumentException(option,argv[i]);
1615 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1619 if (LocaleCompare("verbose",option+1) == 0)
1623 if ((LocaleCompare("version",option+1) == 0) ||
1624 (LocaleCompare("-version",option+1) == 0))
1626 (void) fprintf(stdout,"Version: %s\n",
1627 GetMagickVersion((unsigned long *) NULL));
1628 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
1629 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
1632 if (LocaleCompare("virtual-pixel",option+1) == 0)
1640 if (i == (long) argc)
1641 ThrowMontageException(OptionError,"MissingArgument",option);
1642 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
1645 ThrowMontageException(OptionError,
1646 "UnrecognizedVirtualPixelMethod",argv[i]);
1649 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1653 if (LocaleCompare("white-point",option+1) == 0)
1658 if (i == (long) argc)
1659 ThrowMontageException(OptionError,"MissingArgument",option);
1660 if (IsGeometry(argv[i]) == MagickFalse)
1661 ThrowMontageInvalidArgumentException(option,argv[i]);
1664 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1669 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1671 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
1672 MagickFalse : MagickTrue;
1673 if (fire != MagickFalse)
1674 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1677 ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
1678 if (i-- != (long) (argc-1))
1679 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
1680 if (image == (Image *) NULL)
1681 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1682 FinalizeImageSettings(image_info,image,MagickTrue);
1683 if (image == (Image *) NULL)
1684 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1685 (void) CopyMagickString(montage_info->filename,argv[argc-1],MaxTextExtent);
1686 montage_image=MontageImageList(image_info,montage_info,image,exception);
1687 if (montage_image == (Image *) NULL)
1694 GetImageException(montage_image,exception);
1695 (void) CopyMagickString(image_info->filename,argv[argc-1],MaxTextExtent);
1696 (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1698 if (*montage_image->magick == '\0')
1699 (void) CopyMagickString(montage_image->magick,image->magick,
1701 status&=WriteImages(image_info,montage_image,argv[argc-1],exception);
1702 if (metadata != (char **) NULL)
1707 text=InterpretImageProperties(image_info,montage_image,format);
1708 if (text == (char *) NULL)
1709 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
1710 GetExceptionMessage(errno));
1711 (void) ConcatenateString(&(*metadata),text);
1712 (void) ConcatenateString(&(*metadata),"\n");
1713 text=DestroyString(text);
1716 montage_info=DestroyMontageInfo(montage_info);
1718 return(status != 0 ? MagickTrue : MagickFalse);