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-2011 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 "MagickWand/studio.h"
46 #include "MagickWand/MagickWand.h"
47 #include "MagickWand/mogrify-private.h"
48 #include "MagickCore/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 "-kerning value set the space between two letters",
167 "-label string assign a label to an image",
168 "-limit type value pixel cache resource limit",
169 "-mattecolor color frame color",
170 "-mode type framing style",
171 "-monitor monitor progress",
172 "-origin geometry image origin",
173 "-page geometry size and location of an image canvas (setting)",
174 "-pointsize value font point size",
175 "-profile filename add, delete, or apply an image profile",
176 "-quality value JPEG/MIFF/PNG compression level",
177 "-quantize colorspace reduce colors in this colorspace",
178 "-quiet suppress all warning messages",
179 "-red-primary point chromaticity red primary point",
180 "-regard-warnings pay attention to warning messages",
181 "-respect-parentheses settings remain in effect until parenthesis boundary",
182 "-sampling-factor geometry",
183 " horizontal and vertical sampling factor",
184 "-scenes range image scene range",
185 "-seed value seed a new sequence of pseudo-random numbers",
186 "-set attribute value set an image attribute",
187 "-shadow add a shadow beneath a tile to simulate depth",
188 "-size geometry width and height of image",
189 "-stroke color color to use when stroking a graphic primitive",
190 "-synchronize synchronize image to storage device",
191 "-taint declare the image as modified",
192 "-texture filename name of texture to tile onto the image background",
193 "-thumbnail geometry create a thumbnail of the image",
194 "-tile geometry number of tiles per row and column",
195 "-title string decorate the montage image with a title",
196 "-transparent-color color",
197 " transparent color",
198 "-treedepth value color tree depth",
199 "-trim trim image edges",
200 "-units type the units of image resolution",
201 "-verbose print detailed information about the image",
202 "-virtual-pixel method",
203 " virtual pixel access method",
204 "-white-point point chromaticity white point",
207 *sequence_operators[]=
209 "-coalesce merge a sequence of images",
210 "-composite composite image",
215 "-clone indexes clone an image",
216 "-duplicate count,indexes",
217 " duplicate an image one or more times",
221 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
222 (void) printf("Copyright: %s\n",GetMagickCopyright());
223 (void) printf("Features: %s\n\n",GetMagickFeatures());
224 (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n",
226 (void) printf("\nImage Settings:\n");
227 for (p=settings; *p != (char *) NULL; p++)
228 (void) printf(" %s\n",*p);
229 (void) printf("\nImage Operators:\n");
230 for (p=operators; *p != (char *) NULL; p++)
231 (void) printf(" %s\n",*p);
232 (void) printf("\nImage Sequence Operators:\n");
233 for (p=sequence_operators; *p != (char *) NULL; p++)
234 (void) printf(" %s\n",*p);
235 (void) printf("\nImage Stack Operators:\n");
236 for (p=stack_operators; *p != (char *) NULL; p++)
237 (void) printf(" %s\n",*p);
238 (void) printf("\nMiscellaneous Options:\n");
239 for (p=miscellaneous; *p != (char *) NULL; p++)
240 (void) printf(" %s\n",*p);
242 "\nIn addition to those listed above, you can specify these standard X\n");
244 "resources as command line options: -background, -bordercolor,\n");
246 "-borderwidth, -font, -mattecolor, or -title\n");
248 "\nBy default, the image format of `file' is determined by its magic\n");
250 "number. To specify a particular image format, precede the filename\n");
252 "with an image format name and a colon (i.e. ps:image) or specify the\n");
254 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
255 (void) printf("'-' for standard input or output.\n");
259 WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
260 int argc,char **argv,char **metadata,ExceptionInfo *exception)
262 #define DestroyMontage() \
264 if (montage_image != (Image *) NULL) \
265 montage_image=DestroyImageList(montage_image); \
266 DestroyImageStack(); \
267 for (i=0; i < (ssize_t) argc; i++) \
268 argv[i]=DestroyString(argv[i]); \
269 argv=(char **) RelinquishMagickMemory(argv); \
271 #define ThrowMontageException(asperity,tag,option) \
273 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
276 return(MagickFalse); \
278 #define ThrowMontageInvalidArgumentException(option,argument) \
280 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
281 "InvalidArgument","`%s': %s",option,argument); \
283 return(MagickFalse); \
298 image_stack[MaxImageStackDepth+1];
326 assert(image_info != (ImageInfo *) NULL);
327 assert(image_info->signature == MagickSignature);
328 if (image_info->debug != MagickFalse)
329 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
330 assert(exception != (ExceptionInfo *) NULL);
334 if ((LocaleCompare("version",option+1) == 0) ||
335 (LocaleCompare("-version",option+1) == 0))
337 (void) FormatLocaleFile(stdout,"Version: %s\n",
338 GetMagickVersion((size_t *) NULL));
339 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
340 GetMagickCopyright());
341 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
342 GetMagickFeatures());
347 return(MontageUsage());
353 montage_image=NewImageList();
354 montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
356 option=(char *) NULL;
358 respect_parenthesis=MagickFalse;
361 transparent_color=(char *) NULL;
365 ReadCommandlLine(argc,&argv);
366 status=ExpandFilenames(&argc,&argv);
367 if (status == MagickFalse)
368 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
369 GetExceptionMessage(errno));
370 for (i=1; i < (ssize_t) (argc-1); i++)
373 if (LocaleCompare(option,"(") == 0)
375 FireImageStack(MagickTrue,MagickTrue,pend);
376 if (k == MaxImageStackDepth)
377 ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply",
382 if (LocaleCompare(option,")") == 0)
384 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
386 ThrowMontageException(OptionError,"UnableToParseExpression",option);
390 if (IsCommandOption(option) == MagickFalse)
395 FireImageStack(MagickFalse,MagickFalse,pend);
396 for (scene=(ssize_t) first_scene; scene <= (ssize_t) last_scene ; scene++)
402 Option is a file name: begin by reading image from specified file.
405 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
407 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
408 if (first_scene != last_scene)
411 filename[MaxTextExtent];
414 Form filename for multi-part images.
416 (void) InterpretImageFilename(image_info,(Image *) NULL,
417 image_info->filename,(int) scene,filename);
418 if (LocaleCompare(filename,image_info->filename) == 0)
419 (void) FormatLocaleString(filename,MaxTextExtent,"%s.%.20g",
420 image_info->filename,(double) scene);
421 (void) CopyMagickString(image_info->filename,filename,
424 (void) CloneString(&image_info->font,montage_info->font);
425 images=ReadImages(image_info,exception);
426 status&=(images != (Image *) NULL) &&
427 (exception->severity < ErrorException);
428 if (images == (Image *) NULL)
430 AppendImageStack(images);
434 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
439 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
442 if (i == (ssize_t) (argc-1))
443 ThrowMontageException(OptionError,"MissingArgument",option);
444 if (IsGeometry(argv[i]) == MagickFalse)
445 ThrowMontageInvalidArgumentException(option,argv[i]);
448 if (LocaleCompare("adjoin",option+1) == 0)
450 if (LocaleCompare("affine",option+1) == 0)
455 if (i == (ssize_t) (argc-1))
456 ThrowMontageException(OptionError,"MissingArgument",option);
457 if (IsGeometry(argv[i]) == MagickFalse)
458 ThrowMontageInvalidArgumentException(option,argv[i]);
461 if (LocaleCompare("alpha",option+1) == 0)
469 if (i == (ssize_t) argc)
470 ThrowMontageException(OptionError,"MissingArgument",option);
471 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
473 ThrowMontageException(OptionError,"UnrecognizedAlphaChannelType",
477 if (LocaleCompare("annotate",option+1) == 0)
482 if (i == (ssize_t) (argc-1))
483 ThrowMontageException(OptionError,"MissingArgument",option);
484 if (IsGeometry(argv[i]) == MagickFalse)
485 ThrowMontageInvalidArgumentException(option,argv[i]);
486 if (i == (ssize_t) (argc-1))
487 ThrowMontageException(OptionError,"MissingArgument",option);
491 if (LocaleCompare("auto-orient",option+1) == 0)
493 if (LocaleCompare("authenticate",option+1) == 0)
498 if (i == (ssize_t) argc)
499 ThrowMontageException(OptionError,"MissingArgument",option);
502 ThrowMontageException(OptionError,"UnrecognizedOption",option)
506 if (LocaleCompare("background",option+1) == 0)
511 if (i == (ssize_t) argc)
512 ThrowMontageException(OptionError,"MissingArgument",option);
513 (void) QueryColorCompliance(argv[i],AllCompliance,
514 &montage_info->background_color,exception);
517 if (LocaleCompare("blue-primary",option+1) == 0)
522 if (i == (ssize_t) argc)
523 ThrowMontageException(OptionError,"MissingArgument",option);
524 if (IsGeometry(argv[i]) == MagickFalse)
525 ThrowMontageInvalidArgumentException(option,argv[i]);
528 if (LocaleCompare("blur",option+1) == 0)
533 if (i == (ssize_t) argc)
534 ThrowMontageException(OptionError,"MissingArgument",option);
535 if (IsGeometry(argv[i]) == MagickFalse)
536 ThrowMontageInvalidArgumentException(option,argv[i]);
539 if (LocaleCompare("border",option+1) == 0)
543 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
544 montage_info->border_width=0;
549 if (i == (ssize_t) argc)
550 ThrowMontageException(OptionError,"MissingArgument",option);
551 if (IsGeometry(argv[i]) == MagickFalse)
552 ThrowMontageInvalidArgumentException(option,argv[i]);
554 montage_info->border_width=StringToUnsignedLong(argv[i]);
557 if (LocaleCompare("bordercolor",option+1) == 0)
562 if (i == (ssize_t) argc)
563 ThrowMontageException(OptionError,"MissingArgument",option);
564 (void) QueryColorCompliance(argv[i],AllCompliance,
565 &montage_info->border_color,exception);
568 if (LocaleCompare("borderwidth",option+1) == 0)
570 montage_info->border_width=0;
574 if (i == (ssize_t) argc)
575 ThrowMontageException(OptionError,"MissingArgument",option);
576 if (IsGeometry(argv[i]) == MagickFalse)
577 ThrowMontageInvalidArgumentException(option,argv[i]);
578 montage_info->border_width=StringToUnsignedLong(argv[i]);
581 ThrowMontageException(OptionError,"UnrecognizedOption",option)
585 if (LocaleCompare("cache",option+1) == 0)
590 if (i == (ssize_t) argc)
591 ThrowMontageException(OptionError,"MissingArgument",option);
592 if (IsGeometry(argv[i]) == MagickFalse)
593 ThrowMontageInvalidArgumentException(option,argv[i]);
596 if (LocaleCompare("caption",option+1) == 0)
601 if (i == (ssize_t) argc)
602 ThrowMontageException(OptionError,"MissingArgument",option);
605 if (LocaleCompare("channel",option+1) == 0)
613 if (i == (ssize_t) (argc-1))
614 ThrowMontageException(OptionError,"MissingArgument",option);
615 channel=ParseChannelOption(argv[i]);
617 ThrowMontageException(OptionError,"UnrecognizedChannelType",
621 if (LocaleCompare("clone",option+1) == 0)
628 clone_images=image_stack[k-1].image;
629 if (clone_images == (Image *) NULL)
630 ThrowMontageException(ImageError,"ImageSequenceRequired",option);
631 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
633 clone_images=CloneImages(clone_images,"-1",exception);
637 if (i == (ssize_t) (argc-1))
638 ThrowMontageException(OptionError,"MissingArgument",option);
639 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
640 ThrowMontageInvalidArgumentException(option,argv[i]);
641 clone_images=CloneImages(clone_images,argv[i],exception);
643 if (clone_images == (Image *) NULL)
644 ThrowMontageException(OptionError,"NoSuchImage",option);
645 AppendImageStack(clone_images);
648 if (LocaleCompare("coalesce",option+1) == 0)
650 if (LocaleCompare("colors",option+1) == 0)
655 if (i == (ssize_t) argc)
656 ThrowMontageException(OptionError,"MissingArgument",option);
657 if (IsGeometry(argv[i]) == MagickFalse)
658 ThrowMontageInvalidArgumentException(option,argv[i]);
661 if (LocaleCompare("colorspace",option+1) == 0)
669 if (i == (ssize_t) argc)
670 ThrowMontageException(OptionError,"MissingArgument",option);
671 colorspace=ParseCommandOption(MagickColorspaceOptions,
672 MagickFalse,argv[i]);
674 ThrowMontageException(OptionError,"UnrecognizedColorspace",
678 if (LocaleCompare("comment",option+1) == 0)
683 if (i == (ssize_t) argc)
684 ThrowMontageException(OptionError,"MissingArgument",option);
687 if (LocaleCompare("compose",option+1) == 0)
695 if (i == (ssize_t) argc)
696 ThrowMontageException(OptionError,"MissingArgument",option);
697 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,argv[i]);
699 ThrowMontageException(OptionError,"UnrecognizedComposeOperator",
703 if (LocaleCompare("composite",option+1) == 0)
705 if (LocaleCompare("compress",option+1) == 0)
713 if (i == (ssize_t) argc)
714 ThrowMontageException(OptionError,"MissingArgument",option);
715 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
718 ThrowMontageException(OptionError,"UnrecognizedCompressType",
722 if (LocaleCompare("concurrent",option+1) == 0)
724 if (LocaleCompare("crop",option+1) == 0)
729 if (i == (ssize_t) argc)
730 ThrowMontageException(OptionError,"MissingArgument",option);
731 if (IsGeometry(argv[i]) == MagickFalse)
732 ThrowMontageInvalidArgumentException(option,argv[i]);
735 ThrowMontageException(OptionError,"UnrecognizedOption",option)
739 if (LocaleCompare("debug",option+1) == 0)
747 if (i == (ssize_t) argc)
748 ThrowMontageException(OptionError,"MissingArgument",option);
749 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
751 ThrowMontageException(OptionError,"UnrecognizedEventType",
753 (void) SetLogEventMask(argv[i]);
756 if (LocaleCompare("define",option+1) == 0)
759 if (i == (ssize_t) argc)
760 ThrowMontageException(OptionError,"MissingArgument",option);
766 define=GetImageOption(image_info,argv[i]);
767 if (define == (const char *) NULL)
768 ThrowMontageException(OptionError,"NoSuchOption",argv[i]);
773 if (LocaleCompare("density",option+1) == 0)
778 if (i == (ssize_t) argc)
779 ThrowMontageException(OptionError,"MissingArgument",option);
780 if (IsGeometry(argv[i]) == MagickFalse)
781 ThrowMontageInvalidArgumentException(option,argv[i]);
784 if (LocaleCompare("depth",option+1) == 0)
789 if (i == (ssize_t) argc)
790 ThrowMontageException(OptionError,"MissingArgument",option);
791 if (IsGeometry(argv[i]) == MagickFalse)
792 ThrowMontageInvalidArgumentException(option,argv[i]);
795 if (LocaleCompare("display",option+1) == 0)
800 if (i == (ssize_t) argc)
801 ThrowMontageException(OptionError,"MissingArgument",option);
804 if (LocaleCompare("dispose",option+1) == 0)
812 if (i == (ssize_t) argc)
813 ThrowMontageException(OptionError,"MissingArgument",option);
814 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
816 ThrowMontageException(OptionError,"UnrecognizedDisposeMethod",
820 if (LocaleCompare("dither",option+1) == 0)
828 if (i == (ssize_t) argc)
829 ThrowMontageException(OptionError,"MissingArgument",option);
830 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
832 ThrowMontageException(OptionError,"UnrecognizedDitherMethod",
836 if (LocaleCompare("draw",option+1) == 0)
841 if (i == (ssize_t) argc)
842 ThrowMontageException(OptionError,"MissingArgument",option);
845 if (LocaleCompare("duplicate",option+1) == 0)
850 if (i == (ssize_t) (argc-1))
851 ThrowMontageException(OptionError,"MissingArgument",option);
852 if (IsGeometry(argv[i]) == MagickFalse)
853 ThrowMontageInvalidArgumentException(option,argv[i]);
856 if (LocaleCompare("duration",option+1) == 0)
861 if (i == (ssize_t) (argc-1))
862 ThrowMontageException(OptionError,"MissingArgument",option);
863 if (IsGeometry(argv[i]) == MagickFalse)
864 ThrowMontageInvalidArgumentException(option,argv[i]);
867 ThrowMontageException(OptionError,"UnrecognizedOption",option)
871 if (LocaleCompare("encoding",option+1) == 0)
876 if (i == (ssize_t) argc)
877 ThrowMontageException(OptionError,"MissingArgument",option);
880 if (LocaleCompare("endian",option+1) == 0)
888 if (i == (ssize_t) argc)
889 ThrowMontageException(OptionError,"MissingArgument",option);
890 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
893 ThrowMontageException(OptionError,"UnrecognizedEndianType",
897 if (LocaleCompare("extent",option+1) == 0)
902 if (i == (ssize_t) (argc-1))
903 ThrowMontageException(OptionError,"MissingArgument",option);
904 if (IsGeometry(argv[i]) == MagickFalse)
905 ThrowMontageInvalidArgumentException(option,argv[i]);
908 ThrowMontageException(OptionError,"UnrecognizedOption",option)
912 if (LocaleCompare("fill",option+1) == 0)
914 (void) QueryColorCompliance("none",AllCompliance,
915 &montage_info->fill,exception);
919 if (i == (ssize_t) argc)
920 ThrowMontageException(OptionError,"MissingArgument",option);
921 (void) QueryColorCompliance(argv[i],AllCompliance,
922 &montage_info->fill,exception);
925 if (LocaleCompare("filter",option+1) == 0)
933 if (i == (ssize_t) argc)
934 ThrowMontageException(OptionError,"MissingArgument",option);
935 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
937 ThrowMontageException(OptionError,"UnrecognizedImageFilter",
941 if (LocaleCompare("flatten",option+1) == 0)
943 if (LocaleCompare("flip",option+1) == 0)
945 if (LocaleCompare("flop",option+1) == 0)
947 if (LocaleCompare("font",option+1) == 0)
952 if (i == (ssize_t) argc)
953 ThrowMontageException(OptionError,"MissingArgument",option);
954 (void) CloneString(&montage_info->font,argv[i]);
957 if (LocaleCompare("format",option+1) == 0)
962 if (i == (ssize_t) argc)
963 ThrowMontageException(OptionError,"MissingArgument",option);
967 if (LocaleCompare("frame",option+1) == 0)
971 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
972 (void) CloneString(&montage_info->frame,(char *) NULL);
977 if (i == (ssize_t) argc)
978 ThrowMontageException(OptionError,"MissingArgument",option);
979 if (IsGeometry(argv[i]) == MagickFalse)
980 ThrowMontageInvalidArgumentException(option,argv[i]);
982 (void) CloneString(&montage_info->frame,argv[i]);
985 ThrowMontageException(OptionError,"UnrecognizedOption",option)
989 if (LocaleCompare("gamma",option+1) == 0)
992 if (i == (ssize_t) argc)
993 ThrowMontageException(OptionError,"MissingArgument",option);
994 if (IsGeometry(argv[i]) == MagickFalse)
995 ThrowMontageInvalidArgumentException(option,argv[i]);
998 if (LocaleCompare("geometry",option+1) == 0)
1000 (void) CloneString(&montage_info->geometry,(char *) NULL);
1004 if (i == (ssize_t) argc)
1005 ThrowMontageException(OptionError,"MissingArgument",option);
1006 if (IsGeometry(argv[i]) == MagickFalse)
1007 ThrowMontageInvalidArgumentException(option,argv[i]);
1008 (void) CloneString(&montage_info->geometry,argv[i]);
1011 if (LocaleCompare("gravity",option+1) == 0)
1016 montage_info->gravity=UndefinedGravity;
1020 if (i == (ssize_t) argc)
1021 ThrowMontageException(OptionError,"MissingArgument",option);
1022 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1025 ThrowMontageException(OptionError,"UnrecognizedGravityType",
1027 montage_info->gravity=(GravityType) gravity;
1030 if (LocaleCompare("green-primary",option+1) == 0)
1035 if (i == (ssize_t) argc)
1036 ThrowMontageException(OptionError,"MissingArgument",option);
1037 if (IsGeometry(argv[i]) == MagickFalse)
1038 ThrowMontageInvalidArgumentException(option,argv[i]);
1041 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1045 if ((LocaleCompare("help",option+1) == 0) ||
1046 (LocaleCompare("-help",option+1) == 0))
1047 return(MontageUsage());
1048 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1052 if (LocaleCompare("identify",option+1) == 0)
1054 if (LocaleCompare("interlace",option+1) == 0)
1062 if (i == (ssize_t) argc)
1063 ThrowMontageException(OptionError,"MissingArgument",option);
1064 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1067 ThrowMontageException(OptionError,"UnrecognizedInterlaceType",
1071 if (LocaleCompare("interpolate",option+1) == 0)
1079 if (i == (ssize_t) argc)
1080 ThrowMontageException(OptionError,"MissingArgument",option);
1081 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1083 if (interpolate < 0)
1084 ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod",
1088 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1092 if (LocaleCompare("kerning",option+1) == 0)
1097 if (i == (ssize_t) (argc-1))
1098 ThrowMontageException(OptionError,"MissingArgument",option);
1099 if (IsGeometry(argv[i]) == MagickFalse)
1100 ThrowMontageInvalidArgumentException(option,argv[i]);
1103 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1107 if (LocaleCompare("label",option+1) == 0)
1112 if (i == (ssize_t) argc)
1113 ThrowMontageException(OptionError,"MissingArgument",option);
1116 if (LocaleCompare("limit",option+1) == 0)
1130 if (i == (ssize_t) argc)
1131 ThrowMontageException(OptionError,"MissingArgument",option);
1132 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1135 ThrowMontageException(OptionError,"UnrecognizedResourceType",
1138 if (i == (ssize_t) argc)
1139 ThrowMontageException(OptionError,"MissingArgument",option);
1140 value=InterpretLocaleValue(argv[i],&p);
1142 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1143 ThrowMontageInvalidArgumentException(option,argv[i]);
1146 if (LocaleCompare("list",option+1) == 0)
1154 if (i == (ssize_t) argc)
1155 ThrowMontageException(OptionError,"MissingArgument",option);
1156 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1158 ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]);
1159 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1162 return(status != 0 ? MagickFalse : MagickTrue);
1164 if (LocaleCompare("log",option+1) == 0)
1169 if ((i == (ssize_t) argc) ||
1170 (strchr(argv[i],'%') == (char *) NULL))
1171 ThrowMontageException(OptionError,"MissingArgument",option);
1174 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1178 if (LocaleCompare("matte",option+1) == 0)
1180 if (LocaleCompare("mattecolor",option+1) == 0)
1185 if (i == (ssize_t) argc)
1186 ThrowMontageException(OptionError,"MissingArgument",option);
1187 (void) QueryColorCompliance(argv[i],AllCompliance,
1188 &montage_info->matte_color,exception);
1191 if (LocaleCompare("mode",option+1) == 0)
1196 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1200 if (i == (ssize_t) argc)
1201 ThrowMontageException(OptionError,"MissingArgument",option);
1203 if (LocaleCompare("frame",argv[i]) == 0)
1206 (void) CloneString(&montage_info->frame,"15x15+3+3");
1207 montage_info->shadow=MagickTrue;
1210 if (LocaleCompare("unframe",argv[i]) == 0)
1213 montage_info->frame=(char *) NULL;
1214 montage_info->shadow=MagickFalse;
1215 montage_info->border_width=0;
1218 if (LocaleCompare("concatenate",argv[i]) == 0)
1220 mode=ConcatenateMode;
1221 montage_info->frame=(char *) NULL;
1222 montage_info->shadow=MagickFalse;
1223 montage_info->gravity=(GravityType) NorthWestGravity;
1224 (void) CloneString(&montage_info->geometry,"+0+0");
1225 montage_info->border_width=0;
1228 if (mode == UndefinedMode)
1229 ThrowMontageException(OptionError,"UnrecognizedImageMode",
1233 if (LocaleCompare("monitor",option+1) == 0)
1235 if (LocaleCompare("monochrome",option+1) == 0)
1241 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1245 if (LocaleCompare("noop",option+1) == 0)
1247 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1251 if (LocaleCompare("origin",option+1) == 0)
1256 if (i == (ssize_t) argc)
1257 ThrowMontageException(OptionError,"MissingArgument",option);
1258 if (IsGeometry(argv[i]) == MagickFalse)
1259 ThrowMontageInvalidArgumentException(option,argv[i]);
1262 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1266 if (LocaleCompare("page",option+1) == 0)
1271 if (i == (ssize_t) argc)
1272 ThrowMontageException(OptionError,"MissingArgument",option);
1275 if (LocaleCompare("pointsize",option+1) == 0)
1277 montage_info->pointsize=12;
1281 if (i == (ssize_t) argc)
1282 ThrowMontageException(OptionError,"MissingArgument",option);
1283 if (IsGeometry(argv[i]) == MagickFalse)
1284 ThrowMontageInvalidArgumentException(option,argv[i]);
1285 montage_info->pointsize=InterpretLocaleValue(argv[i],
1289 if (LocaleCompare("polaroid",option+1) == 0)
1294 if (i == (ssize_t) (argc-1))
1295 ThrowMontageException(OptionError,"MissingArgument",option);
1296 if (IsGeometry(argv[i]) == MagickFalse)
1297 ThrowMontageInvalidArgumentException(option,argv[i]);
1300 if (LocaleCompare("profile",option+1) == 0)
1303 if (i == (ssize_t) (argc-1))
1304 ThrowMontageException(OptionError,"MissingArgument",option);
1307 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1311 if (LocaleCompare("quality",option+1) == 0)
1316 if (i == (ssize_t) argc)
1317 ThrowMontageException(OptionError,"MissingArgument",option);
1318 if (IsGeometry(argv[i]) == MagickFalse)
1319 ThrowMontageInvalidArgumentException(option,argv[i]);
1322 if (LocaleCompare("quantize",option+1) == 0)
1330 if (i == (ssize_t) (argc-1))
1331 ThrowMontageException(OptionError,"MissingArgument",option);
1332 colorspace=ParseCommandOption(MagickColorspaceOptions,
1333 MagickFalse,argv[i]);
1335 ThrowMontageException(OptionError,"UnrecognizedColorspace",
1339 if (LocaleCompare("quiet",option+1) == 0)
1341 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1345 if (LocaleCompare("red-primary",option+1) == 0)
1350 if (i == (ssize_t) argc)
1351 ThrowMontageException(OptionError,"MissingArgument",option);
1352 if (IsGeometry(argv[i]) == MagickFalse)
1353 ThrowMontageInvalidArgumentException(option,argv[i]);
1356 if (LocaleCompare("regard-warnings",option+1) == 0)
1358 if (LocaleCompare("render",option+1) == 0)
1360 if (LocaleCompare("repage",option+1) == 0)
1365 if (i == (ssize_t) argc)
1366 ThrowMontageException(OptionError,"MissingArgument",option);
1367 if (IsGeometry(argv[i]) == MagickFalse)
1368 ThrowMontageInvalidArgumentException(option,argv[i]);
1371 if (LocaleCompare("resize",option+1) == 0)
1376 if (i == (ssize_t) argc)
1377 ThrowMontageException(OptionError,"MissingArgument",option);
1378 if (IsGeometry(argv[i]) == MagickFalse)
1379 ThrowMontageInvalidArgumentException(option,argv[i]);
1382 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1384 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1387 if (LocaleCompare("rotate",option+1) == 0)
1390 if (i == (ssize_t) argc)
1391 ThrowMontageException(OptionError,"MissingArgument",option);
1392 if (IsGeometry(argv[i]) == MagickFalse)
1393 ThrowMontageInvalidArgumentException(option,argv[i]);
1396 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1400 if (LocaleCompare("sampling-factor",option+1) == 0)
1405 if (i == (ssize_t) argc)
1406 ThrowMontageException(OptionError,"MissingArgument",option);
1407 if (IsGeometry(argv[i]) == MagickFalse)
1408 ThrowMontageInvalidArgumentException(option,argv[i]);
1411 if (LocaleCompare("seed",option+1) == 0)
1416 if (i == (ssize_t) (argc-1))
1417 ThrowMontageException(OptionError,"MissingArgument",option);
1418 if (IsGeometry(argv[i]) == MagickFalse)
1419 ThrowMontageInvalidArgumentException(option,argv[i]);
1422 if (LocaleCompare("scenes",option+1) == 0)
1429 if (i == (ssize_t) argc)
1430 ThrowMontageException(OptionError,"MissingArgument",option);
1431 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1432 ThrowMontageInvalidArgumentException(option,argv[i]);
1433 first_scene=(int) StringToLong(argv[i]);
1434 last_scene=first_scene;
1435 (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene);
1438 if (LocaleCompare("set",option+1) == 0)
1441 if (i == (ssize_t) argc)
1442 ThrowMontageException(OptionError,"MissingArgument",option);
1446 if (i == (ssize_t) argc)
1447 ThrowMontageException(OptionError,"MissingArgument",option);
1450 if (LocaleCompare("shadow",option+1) == 0)
1454 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1455 montage_info->shadow=(*option == '-') ? MagickTrue :
1462 if (i == (ssize_t) (argc-1))
1463 ThrowMontageException(OptionError,"MissingArgument",option);
1464 if (IsGeometry(argv[i]) == MagickFalse)
1465 ThrowMontageInvalidArgumentException(option,argv[i]);
1468 if (LocaleCompare("sharpen",option+1) == 0)
1473 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
1474 ThrowMontageException(OptionError,"MissingArgument",option);
1477 if (LocaleCompare("size",option+1) == 0)
1482 if (i == (ssize_t) argc)
1483 ThrowMontageException(OptionError,"MissingArgument",option);
1484 if (IsGeometry(argv[i]) == MagickFalse)
1485 ThrowMontageInvalidArgumentException(option,argv[i]);
1488 if (LocaleCompare("stroke",option+1) == 0)
1490 (void) QueryColorCompliance("none",AllCompliance,
1491 &montage_info->stroke,exception);
1495 if (i == (ssize_t) argc)
1496 ThrowMontageException(OptionError,"MissingArgument",option);
1497 (void) QueryColorCompliance(argv[i],AllCompliance,
1498 &montage_info->stroke,exception);
1501 if (LocaleCompare("strip",option+1) == 0)
1503 if (LocaleCompare("strokewidth",option+1) == 0)
1508 if (i == (ssize_t) argc)
1509 ThrowMontageException(OptionError,"MissingArgument",option);
1510 if (IsGeometry(argv[i]) == MagickFalse)
1511 ThrowMontageInvalidArgumentException(option,argv[i]);
1514 if (LocaleCompare("support",option+1) == 0)
1516 i++; /* deprecated */
1519 if (LocaleCompare("synchronize",option+1) == 0)
1521 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1525 if (LocaleCompare("taint",option+1) == 0)
1527 if (LocaleCompare("texture",option+1) == 0)
1529 (void) CloneString(&montage_info->texture,(char *) NULL);
1533 if (i == (ssize_t) argc)
1534 ThrowMontageException(OptionError,"MissingArgument",option);
1535 (void) CloneString(&montage_info->texture,argv[i]);
1538 if (LocaleCompare("thumbnail",option+1) == 0)
1543 if (i == (ssize_t) argc)
1544 ThrowMontageException(OptionError,"MissingArgument",option);
1545 if (IsGeometry(argv[i]) == MagickFalse)
1546 ThrowMontageInvalidArgumentException(option,argv[i]);
1549 if (LocaleCompare("tile",option+1) == 0)
1553 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1554 (void) CloneString(&montage_info->tile,(char *) NULL);
1559 if (i == (ssize_t) argc)
1560 ThrowMontageException(OptionError,"MissingArgument",option);
1561 if (IsGeometry(argv[i]) == MagickFalse)
1562 ThrowMontageInvalidArgumentException(option,argv[i]);
1564 (void) CloneString(&montage_info->tile,argv[i]);
1567 if (LocaleCompare("tile-offset",option+1) == 0)
1572 if (i == (ssize_t) (argc-1))
1573 ThrowMontageException(OptionError,"MissingArgument",option);
1574 if (IsGeometry(argv[i]) == MagickFalse)
1575 ThrowMontageInvalidArgumentException(option,argv[i]);
1578 if (LocaleCompare("tint",option+1) == 0)
1583 if (i == (ssize_t) argc)
1584 ThrowMontageException(OptionError,"MissingArgument",option);
1585 if (IsGeometry(argv[i]) == MagickFalse)
1586 ThrowMontageInvalidArgumentException(option,argv[i]);
1589 if (LocaleCompare("transform",option+1) == 0)
1591 if (LocaleCompare("transpose",option+1) == 0)
1593 if (LocaleCompare("title",option+1) == 0)
1595 (void) CloneString(&montage_info->title,(char *) NULL);
1599 if (i == (ssize_t) argc)
1600 ThrowMontageException(OptionError,"MissingArgument",option);
1601 (void) CloneString(&montage_info->title,argv[i]);
1604 if (LocaleCompare("transform",option+1) == 0)
1606 if (LocaleCompare("transparent",option+1) == 0)
1608 transparent_color=(char *) NULL;
1610 if (i == (ssize_t) argc)
1611 ThrowMontageException(OptionError,"MissingArgument",option);
1612 (void) CloneString(&transparent_color,argv[i]);
1615 if (LocaleCompare("transparent-color",option+1) == 0)
1620 if (i == (ssize_t) (argc-1))
1621 ThrowMontageException(OptionError,"MissingArgument",option);
1624 if (LocaleCompare("treedepth",option+1) == 0)
1629 if (i == (ssize_t) argc)
1630 ThrowMontageException(OptionError,"MissingArgument",option);
1631 if (IsGeometry(argv[i]) == MagickFalse)
1632 ThrowMontageInvalidArgumentException(option,argv[i]);
1635 if (LocaleCompare("trim",option+1) == 0)
1637 if (LocaleCompare("type",option+1) == 0)
1645 if (i == (ssize_t) argc)
1646 ThrowMontageException(OptionError,"MissingArgument",option);
1647 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1649 ThrowMontageException(OptionError,"UnrecognizedImageType",
1653 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1657 if (LocaleCompare("units",option+1) == 0)
1665 if (i == (ssize_t) (argc-1))
1666 ThrowMontageException(OptionError,"MissingArgument",option);
1667 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1670 ThrowMontageException(OptionError,"UnrecognizedUnitsType",
1674 if (LocaleCompare("unsharp",option+1) == 0)
1679 if (i == (ssize_t) (argc-1))
1680 ThrowMontageException(OptionError,"MissingArgument",option);
1681 if (IsGeometry(argv[i]) == MagickFalse)
1682 ThrowMontageInvalidArgumentException(option,argv[i]);
1685 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1689 if (LocaleCompare("verbose",option+1) == 0)
1693 if ((LocaleCompare("version",option+1) == 0) ||
1694 (LocaleCompare("-version",option+1) == 0))
1696 (void) FormatLocaleFile(stdout,"Version: %s\n",
1697 GetMagickVersion((size_t *) NULL));
1698 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
1699 GetMagickCopyright());
1700 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
1701 GetMagickFeatures());
1704 if (LocaleCompare("virtual-pixel",option+1) == 0)
1712 if (i == (ssize_t) argc)
1713 ThrowMontageException(OptionError,"MissingArgument",option);
1714 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1717 ThrowMontageException(OptionError,
1718 "UnrecognizedVirtualPixelMethod",argv[i]);
1721 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1725 if (LocaleCompare("white-point",option+1) == 0)
1730 if (i == (ssize_t) argc)
1731 ThrowMontageException(OptionError,"MissingArgument",option);
1732 if (IsGeometry(argv[i]) == MagickFalse)
1733 ThrowMontageInvalidArgumentException(option,argv[i]);
1736 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1741 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1743 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1744 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1745 if (fire != MagickFalse)
1746 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1749 ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
1750 if (i-- != (ssize_t) (argc-1))
1751 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
1752 if (image == (Image *) NULL)
1753 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1754 FinalizeImageSettings(image_info,image,MagickTrue);
1755 if (image == (Image *) NULL)
1756 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1757 (void) CopyMagickString(montage_info->filename,argv[argc-1],MaxTextExtent);
1758 montage_image=MontageImageList(image_info,montage_info,image,exception);
1759 if (montage_image == (Image *) NULL)
1766 GetImageException(montage_image,exception);
1767 (void) CopyMagickString(image_info->filename,argv[argc-1],MaxTextExtent);
1768 (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1770 if (*montage_image->magick == '\0')
1771 (void) CopyMagickString(montage_image->magick,image->magick,
1773 status&=WriteImages(image_info,montage_image,argv[argc-1],exception);
1774 if (metadata != (char **) NULL)
1779 text=InterpretImageProperties(image_info,montage_image,format,
1781 if (text == (char *) NULL)
1782 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
1783 GetExceptionMessage(errno));
1784 (void) ConcatenateString(&(*metadata),text);
1785 (void) ConcatenateString(&(*metadata),"\n");
1786 text=DestroyString(text);
1789 montage_info=DestroyMontageInfo(montage_info);
1791 return(status != 0 ? MagickTrue : MagickFalse);