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());
338 (void) MontageUsage();
346 montage_image=NewImageList();
347 montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
349 option=(char *) NULL;
353 transparent_color=(char *) NULL;
357 ReadCommandlLine(argc,&argv);
358 status=ExpandFilenames(&argc,&argv);
359 if (status == MagickFalse)
360 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
361 GetExceptionMessage(errno));
362 for (i=1; i < (long) (argc-1); i++)
365 if (LocaleCompare(option,"(") == 0)
367 FireImageStack(MagickTrue,MagickTrue,pend);
368 if (k == MaxImageStackDepth)
369 ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply",
374 if (LocaleCompare(option,")") == 0)
376 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
378 ThrowMontageException(OptionError,"UnableToParseExpression",option);
382 if (IsMagickOption(option) == MagickFalse)
387 FireImageStack(MagickFalse,MagickFalse,pend);
388 for (scene=first_scene; scene <= last_scene ; scene++)
394 Option is a file name: begin by reading image from specified file.
397 if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
399 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
400 if (first_scene != last_scene)
403 filename[MaxTextExtent];
406 Form filename for multi-part images.
408 (void) InterpretImageFilename(image_info,(Image *) NULL,
409 image_info->filename,(int) scene,filename);
410 if (LocaleCompare(filename,image_info->filename) == 0)
411 (void) FormatMagickString(filename,MaxTextExtent,"%s.%lu",
412 image_info->filename,scene);
413 (void) CopyMagickString(image_info->filename,filename,
416 (void) CloneString(&image_info->font,montage_info->font);
417 images=ReadImages(image_info,exception);
418 status&=(images != (Image *) NULL) &&
419 (exception->severity < ErrorException);
420 if (images == (Image *) NULL)
422 AppendImageStack(images);
426 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
431 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
434 if (i == (long) (argc-1))
435 ThrowMontageException(OptionError,"MissingArgument",option);
436 if (IsGeometry(argv[i]) == MagickFalse)
437 ThrowMontageInvalidArgumentException(option,argv[i]);
440 if (LocaleCompare("adjoin",option+1) == 0)
442 if (LocaleCompare("affine",option+1) == 0)
447 if (i == (long) (argc-1))
448 ThrowMontageException(OptionError,"MissingArgument",option);
449 if (IsGeometry(argv[i]) == MagickFalse)
450 ThrowMontageInvalidArgumentException(option,argv[i]);
453 if (LocaleCompare("alpha",option+1) == 0)
461 if (i == (long) argc)
462 ThrowMontageException(OptionError,"MissingArgument",option);
463 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
465 ThrowMontageException(OptionError,"UnrecognizedAlphaChannelType",
469 if (LocaleCompare("annotate",option+1) == 0)
474 if (i == (long) (argc-1))
475 ThrowMontageException(OptionError,"MissingArgument",option);
476 if (IsGeometry(argv[i]) == MagickFalse)
477 ThrowMontageInvalidArgumentException(option,argv[i]);
478 if (i == (long) (argc-1))
479 ThrowMontageException(OptionError,"MissingArgument",option);
483 if (LocaleCompare("auto-orient",option+1) == 0)
485 if (LocaleCompare("authenticate",option+1) == 0)
490 if (i == (long) argc)
491 ThrowMontageException(OptionError,"MissingArgument",option);
494 ThrowMontageException(OptionError,"UnrecognizedOption",option)
498 if (LocaleCompare("background",option+1) == 0)
503 if (i == (long) argc)
504 ThrowMontageException(OptionError,"MissingArgument",option);
505 (void) QueryColorDatabase(argv[i],
506 &montage_info->background_color,exception);
509 if (LocaleCompare("blue-primary",option+1) == 0)
514 if (i == (long) argc)
515 ThrowMontageException(OptionError,"MissingArgument",option);
516 if (IsGeometry(argv[i]) == MagickFalse)
517 ThrowMontageInvalidArgumentException(option,argv[i]);
520 if (LocaleCompare("blur",option+1) == 0)
525 if (i == (long) argc)
526 ThrowMontageException(OptionError,"MissingArgument",option);
527 if (IsGeometry(argv[i]) == MagickFalse)
528 ThrowMontageInvalidArgumentException(option,argv[i]);
531 if (LocaleCompare("border",option+1) == 0)
533 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
534 montage_info->border_width=0;
538 if (i == (long) argc)
539 ThrowMontageException(OptionError,"MissingArgument",option);
540 if (IsGeometry(argv[i]) == MagickFalse)
541 ThrowMontageInvalidArgumentException(option,argv[i]);
542 montage_info->border_width=StringToUnsignedLong(argv[i]);
545 if (LocaleCompare("bordercolor",option+1) == 0)
550 if (i == (long) argc)
551 ThrowMontageException(OptionError,"MissingArgument",option);
552 (void) QueryColorDatabase(argv[i],&montage_info->border_color,
556 if (LocaleCompare("borderwidth",option+1) == 0)
558 montage_info->border_width=0;
562 if (i == (long) argc)
563 ThrowMontageException(OptionError,"MissingArgument",option);
564 if (IsGeometry(argv[i]) == MagickFalse)
565 ThrowMontageInvalidArgumentException(option,argv[i]);
566 montage_info->border_width=StringToUnsignedLong(argv[i]);
569 ThrowMontageException(OptionError,"UnrecognizedOption",option)
573 if (LocaleCompare("cache",option+1) == 0)
578 if (i == (long) argc)
579 ThrowMontageException(OptionError,"MissingArgument",option);
580 if (IsGeometry(argv[i]) == MagickFalse)
581 ThrowMontageInvalidArgumentException(option,argv[i]);
584 if (LocaleCompare("caption",option+1) == 0)
589 if (i == (long) argc)
590 ThrowMontageException(OptionError,"MissingArgument",option);
593 if (LocaleCompare("channel",option+1) == 0)
601 if (i == (long) (argc-1))
602 ThrowMontageException(OptionError,"MissingArgument",option);
603 channel=ParseChannelOption(argv[i]);
605 ThrowMontageException(OptionError,"UnrecognizedChannelType",
609 if (LocaleCompare("clone",option+1) == 0)
616 clone_images=image_stack[k-1].image;
617 if (clone_images == (Image *) NULL)
618 ThrowMontageException(ImageError,"ImageSequenceRequired",option);
619 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
621 clone_images=CloneImages(clone_images,"-1",exception);
625 if (i == (long) (argc-1))
626 ThrowMontageException(OptionError,"MissingArgument",option);
627 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
628 ThrowMontageInvalidArgumentException(option,argv[i]);
629 clone_images=CloneImages(clone_images,argv[i],exception);
631 if (clone_images == (Image *) NULL)
632 ThrowMontageException(OptionError,"NoSuchImage",option);
633 AppendImageStack(clone_images);
636 if (LocaleCompare("coalesce",option+1) == 0)
638 if (LocaleCompare("colors",option+1) == 0)
643 if (i == (long) argc)
644 ThrowMontageException(OptionError,"MissingArgument",option);
645 if (IsGeometry(argv[i]) == MagickFalse)
646 ThrowMontageInvalidArgumentException(option,argv[i]);
649 if (LocaleCompare("colorspace",option+1) == 0)
657 if (i == (long) argc)
658 ThrowMontageException(OptionError,"MissingArgument",option);
659 colorspace=ParseMagickOption(MagickColorspaceOptions,
660 MagickFalse,argv[i]);
662 ThrowMontageException(OptionError,"UnrecognizedColorspace",
666 if (LocaleCompare("comment",option+1) == 0)
671 if (i == (long) argc)
672 ThrowMontageException(OptionError,"MissingArgument",option);
675 if (LocaleCompare("compose",option+1) == 0)
683 if (i == (long) argc)
684 ThrowMontageException(OptionError,"MissingArgument",option);
685 compose=ParseMagickOption(MagickComposeOptions,MagickFalse,argv[i]);
687 ThrowMontageException(OptionError,"UnrecognizedComposeOperator",
691 if (LocaleCompare("composite",option+1) == 0)
693 if (LocaleCompare("compress",option+1) == 0)
701 if (i == (long) argc)
702 ThrowMontageException(OptionError,"MissingArgument",option);
703 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
706 ThrowMontageException(OptionError,"UnrecognizedCompressType",
710 if (LocaleCompare("concurrent",option+1) == 0)
712 if (LocaleCompare("crop",option+1) == 0)
717 if (i == (long) argc)
718 ThrowMontageException(OptionError,"MissingArgument",option);
719 if (IsGeometry(argv[i]) == MagickFalse)
720 ThrowMontageInvalidArgumentException(option,argv[i]);
723 ThrowMontageException(OptionError,"UnrecognizedOption",option)
727 if (LocaleCompare("debug",option+1) == 0)
735 if (i == (long) argc)
736 ThrowMontageException(OptionError,"MissingArgument",option);
737 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
739 ThrowMontageException(OptionError,"UnrecognizedEventType",
741 (void) SetLogEventMask(argv[i]);
744 if (LocaleCompare("define",option+1) == 0)
747 if (i == (long) argc)
748 ThrowMontageException(OptionError,"MissingArgument",option);
754 define=GetImageOption(image_info,argv[i]);
755 if (define == (const char *) NULL)
756 ThrowMontageException(OptionError,"NoSuchOption",argv[i]);
761 if (LocaleCompare("density",option+1) == 0)
766 if (i == (long) argc)
767 ThrowMontageException(OptionError,"MissingArgument",option);
768 if (IsGeometry(argv[i]) == MagickFalse)
769 ThrowMontageInvalidArgumentException(option,argv[i]);
772 if (LocaleCompare("depth",option+1) == 0)
777 if (i == (long) argc)
778 ThrowMontageException(OptionError,"MissingArgument",option);
779 if (IsGeometry(argv[i]) == MagickFalse)
780 ThrowMontageInvalidArgumentException(option,argv[i]);
783 if (LocaleCompare("display",option+1) == 0)
788 if (i == (long) argc)
789 ThrowMontageException(OptionError,"MissingArgument",option);
792 if (LocaleCompare("dispose",option+1) == 0)
800 if (i == (long) argc)
801 ThrowMontageException(OptionError,"MissingArgument",option);
802 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
804 ThrowMontageException(OptionError,"UnrecognizedDisposeMethod",
808 if (LocaleCompare("dither",option+1) == 0)
816 if (i == (long) argc)
817 ThrowMontageException(OptionError,"MissingArgument",option);
818 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
820 ThrowMontageException(OptionError,"UnrecognizedDitherMethod",
824 if (LocaleCompare("draw",option+1) == 0)
829 if (i == (long) argc)
830 ThrowMontageException(OptionError,"MissingArgument",option);
833 if (LocaleCompare("duration",option+1) == 0)
838 if (i == (long) (argc-1))
839 ThrowMontageException(OptionError,"MissingArgument",option);
840 if (IsGeometry(argv[i]) == MagickFalse)
841 ThrowMontageInvalidArgumentException(option,argv[i]);
844 ThrowMontageException(OptionError,"UnrecognizedOption",option)
848 if (LocaleCompare("encoding",option+1) == 0)
853 if (i == (long) argc)
854 ThrowMontageException(OptionError,"MissingArgument",option);
857 if (LocaleCompare("endian",option+1) == 0)
865 if (i == (long) argc)
866 ThrowMontageException(OptionError,"MissingArgument",option);
867 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
870 ThrowMontageException(OptionError,"UnrecognizedEndianType",
874 if (LocaleCompare("extent",option+1) == 0)
879 if (i == (long) (argc-1))
880 ThrowMontageException(OptionError,"MissingArgument",option);
881 if (IsGeometry(argv[i]) == MagickFalse)
882 ThrowMontageInvalidArgumentException(option,argv[i]);
885 ThrowMontageException(OptionError,"UnrecognizedOption",option)
889 if (LocaleCompare("fill",option+1) == 0)
891 (void) QueryColorDatabase("none",&montage_info->fill,exception);
895 if (i == (long) argc)
896 ThrowMontageException(OptionError,"MissingArgument",option);
897 (void) QueryColorDatabase(argv[i],&montage_info->fill,
901 if (LocaleCompare("filter",option+1) == 0)
909 if (i == (long) argc)
910 ThrowMontageException(OptionError,"MissingArgument",option);
911 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
913 ThrowMontageException(OptionError,"UnrecognizedImageFilter",
917 if (LocaleCompare("flatten",option+1) == 0)
919 if (LocaleCompare("flip",option+1) == 0)
921 if (LocaleCompare("flop",option+1) == 0)
923 if (LocaleCompare("font",option+1) == 0)
928 if (i == (long) argc)
929 ThrowMontageException(OptionError,"MissingArgument",option);
930 (void) CloneString(&montage_info->font,argv[i]);
933 if (LocaleCompare("format",option+1) == 0)
938 if (i == (long) argc)
939 ThrowMontageException(OptionError,"MissingArgument",option);
943 if (LocaleCompare("frame",option+1) == 0)
945 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
946 (void) CloneString(&montage_info->frame,(char *) NULL);
950 if (i == (long) argc)
951 ThrowMontageException(OptionError,"MissingArgument",option);
952 if (IsGeometry(argv[i]) == MagickFalse)
953 ThrowMontageInvalidArgumentException(option,argv[i]);
954 (void) CloneString(&montage_info->frame,argv[i]);
957 ThrowMontageException(OptionError,"UnrecognizedOption",option)
961 if (LocaleCompare("gamma",option+1) == 0)
964 if (i == (long) argc)
965 ThrowMontageException(OptionError,"MissingArgument",option);
966 if (IsGeometry(argv[i]) == MagickFalse)
967 ThrowMontageInvalidArgumentException(option,argv[i]);
970 if (LocaleCompare("geometry",option+1) == 0)
972 (void) CloneString(&montage_info->geometry,(char *) NULL);
976 if (i == (long) argc)
977 ThrowMontageException(OptionError,"MissingArgument",option);
978 if (IsGeometry(argv[i]) == MagickFalse)
979 ThrowMontageInvalidArgumentException(option,argv[i]);
980 (void) CloneString(&montage_info->geometry,argv[i]);
983 if (LocaleCompare("gravity",option+1) == 0)
988 montage_info->gravity=UndefinedGravity;
992 if (i == (long) argc)
993 ThrowMontageException(OptionError,"MissingArgument",option);
994 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
997 ThrowMontageException(OptionError,"UnrecognizedGravityType",
999 montage_info->gravity=(GravityType) gravity;
1002 if (LocaleCompare("green-primary",option+1) == 0)
1007 if (i == (long) argc)
1008 ThrowMontageException(OptionError,"MissingArgument",option);
1009 if (IsGeometry(argv[i]) == MagickFalse)
1010 ThrowMontageInvalidArgumentException(option,argv[i]);
1013 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1017 if ((LocaleCompare("help",option+1) == 0) ||
1018 (LocaleCompare("-help",option+1) == 0))
1019 return(MontageUsage());
1020 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1024 if (LocaleCompare("identify",option+1) == 0)
1026 if (LocaleCompare("interlace",option+1) == 0)
1034 if (i == (long) argc)
1035 ThrowMontageException(OptionError,"MissingArgument",option);
1036 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
1039 ThrowMontageException(OptionError,"UnrecognizedInterlaceType",
1043 if (LocaleCompare("interpolate",option+1) == 0)
1051 if (i == (long) argc)
1052 ThrowMontageException(OptionError,"MissingArgument",option);
1053 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
1055 if (interpolate < 0)
1056 ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod",
1060 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1064 if (LocaleCompare("label",option+1) == 0)
1069 if (i == (long) argc)
1070 ThrowMontageException(OptionError,"MissingArgument",option);
1073 if (LocaleCompare("limit",option+1) == 0)
1087 if (i == (long) argc)
1088 ThrowMontageException(OptionError,"MissingArgument",option);
1089 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
1092 ThrowMontageException(OptionError,"UnrecognizedResourceType",
1095 if (i == (long) argc)
1096 ThrowMontageException(OptionError,"MissingArgument",option);
1097 value=strtod(argv[i],&p);
1098 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1099 ThrowMontageInvalidArgumentException(option,argv[i]);
1102 if (LocaleCompare("list",option+1) == 0)
1110 if (i == (long) argc)
1111 ThrowMontageException(OptionError,"MissingArgument",option);
1112 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
1114 ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]);
1115 (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1120 if (LocaleCompare("log",option+1) == 0)
1125 if ((i == (long) argc) ||
1126 (strchr(argv[i],'%') == (char *) NULL))
1127 ThrowMontageException(OptionError,"MissingArgument",option);
1130 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1134 if (LocaleCompare("matte",option+1) == 0)
1136 if (LocaleCompare("mattecolor",option+1) == 0)
1141 if (i == (long) argc)
1142 ThrowMontageException(OptionError,"MissingArgument",option);
1143 (void) QueryColorDatabase(argv[i],&montage_info->matte_color,
1147 if (LocaleCompare("mode",option+1) == 0)
1155 if (i == (long) argc)
1156 ThrowMontageException(OptionError,"MissingArgument",option);
1158 if (LocaleCompare("frame",argv[i]) == 0)
1161 (void) CloneString(&montage_info->frame,"15x15+3+3");
1162 montage_info->shadow=MagickTrue;
1165 if (LocaleCompare("unframe",argv[i]) == 0)
1168 montage_info->frame=(char *) NULL;
1169 montage_info->shadow=MagickFalse;
1170 montage_info->border_width=0;
1173 if (LocaleCompare("concatenate",argv[i]) == 0)
1175 mode=ConcatenateMode;
1176 montage_info->frame=(char *) NULL;
1177 montage_info->shadow=MagickFalse;
1178 montage_info->gravity=(GravityType) NorthWestGravity;
1179 (void) CloneString(&montage_info->geometry,"+0+0");
1180 montage_info->border_width=0;
1183 if (mode == UndefinedMode)
1184 ThrowMontageException(OptionError,"UnrecognizedImageMode",
1188 if (LocaleCompare("monitor",option+1) == 0)
1190 if (LocaleCompare("monochrome",option+1) == 0)
1196 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1200 if (LocaleCompare("noop",option+1) == 0)
1202 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1206 if (LocaleCompare("origin",option+1) == 0)
1211 if (i == (long) argc)
1212 ThrowMontageException(OptionError,"MissingArgument",option);
1213 if (IsGeometry(argv[i]) == MagickFalse)
1214 ThrowMontageInvalidArgumentException(option,argv[i]);
1217 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1221 if (LocaleCompare("page",option+1) == 0)
1226 if (i == (long) argc)
1227 ThrowMontageException(OptionError,"MissingArgument",option);
1230 if (LocaleCompare("pointsize",option+1) == 0)
1232 montage_info->pointsize=12;
1236 if (i == (long) argc)
1237 ThrowMontageException(OptionError,"MissingArgument",option);
1238 if (IsGeometry(argv[i]) == MagickFalse)
1239 ThrowMontageInvalidArgumentException(option,argv[i]);
1240 montage_info->pointsize=StringToDouble(argv[i]);
1243 if (LocaleCompare("polaroid",option+1) == 0)
1248 if (i == (long) (argc-1))
1249 ThrowMontageException(OptionError,"MissingArgument",option);
1250 if (IsGeometry(argv[i]) == MagickFalse)
1251 ThrowMontageInvalidArgumentException(option,argv[i]);
1254 if (LocaleCompare("profile",option+1) == 0)
1257 if (i == (long) (argc-1))
1258 ThrowMontageException(OptionError,"MissingArgument",option);
1261 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1265 if (LocaleCompare("quality",option+1) == 0)
1270 if (i == (long) argc)
1271 ThrowMontageException(OptionError,"MissingArgument",option);
1272 if (IsGeometry(argv[i]) == MagickFalse)
1273 ThrowMontageInvalidArgumentException(option,argv[i]);
1276 if (LocaleCompare("quantize",option+1) == 0)
1284 if (i == (long) (argc-1))
1285 ThrowMontageException(OptionError,"MissingArgument",option);
1286 colorspace=ParseMagickOption(MagickColorspaceOptions,
1287 MagickFalse,argv[i]);
1289 ThrowMontageException(OptionError,"UnrecognizedColorspace",
1293 if (LocaleCompare("quiet",option+1) == 0)
1295 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1299 if (LocaleCompare("red-primary",option+1) == 0)
1304 if (i == (long) argc)
1305 ThrowMontageException(OptionError,"MissingArgument",option);
1306 if (IsGeometry(argv[i]) == MagickFalse)
1307 ThrowMontageInvalidArgumentException(option,argv[i]);
1310 if (LocaleCompare("regard-warnings",option+1) == 0)
1312 if (LocaleCompare("render",option+1) == 0)
1314 if (LocaleCompare("repage",option+1) == 0)
1319 if (i == (long) argc)
1320 ThrowMontageException(OptionError,"MissingArgument",option);
1321 if (IsGeometry(argv[i]) == MagickFalse)
1322 ThrowMontageInvalidArgumentException(option,argv[i]);
1325 if (LocaleCompare("resize",option+1) == 0)
1330 if (i == (long) argc)
1331 ThrowMontageException(OptionError,"MissingArgument",option);
1332 if (IsGeometry(argv[i]) == MagickFalse)
1333 ThrowMontageInvalidArgumentException(option,argv[i]);
1336 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1338 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1341 if (LocaleCompare("rotate",option+1) == 0)
1344 if (i == (long) argc)
1345 ThrowMontageException(OptionError,"MissingArgument",option);
1346 if (IsGeometry(argv[i]) == MagickFalse)
1347 ThrowMontageInvalidArgumentException(option,argv[i]);
1350 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1354 if (LocaleCompare("sampling-factor",option+1) == 0)
1359 if (i == (long) argc)
1360 ThrowMontageException(OptionError,"MissingArgument",option);
1361 if (IsGeometry(argv[i]) == MagickFalse)
1362 ThrowMontageInvalidArgumentException(option,argv[i]);
1365 if (LocaleCompare("seed",option+1) == 0)
1370 if (i == (long) (argc-1))
1371 ThrowMontageException(OptionError,"MissingArgument",option);
1372 if (IsGeometry(argv[i]) == MagickFalse)
1373 ThrowMontageInvalidArgumentException(option,argv[i]);
1376 if (LocaleCompare("scenes",option+1) == 0)
1383 if (i == (long) argc)
1384 ThrowMontageException(OptionError,"MissingArgument",option);
1385 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1386 ThrowMontageInvalidArgumentException(option,argv[i]);
1387 first_scene=StringToLong(argv[i]);
1388 last_scene=first_scene;
1389 (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene);
1392 if (LocaleCompare("set",option+1) == 0)
1395 if (i == (long) argc)
1396 ThrowMontageException(OptionError,"MissingArgument",option);
1400 if (i == (long) argc)
1401 ThrowMontageException(OptionError,"MissingArgument",option);
1404 if (LocaleCompare("shadow",option+1) == 0)
1406 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1407 montage_info->shadow=(*option == '-') ? MagickTrue : MagickFalse;
1410 if (LocaleCompare("sharpen",option+1) == 0)
1415 if ((i == (long) argc) || (IsGeometry(argv[i]) == MagickFalse))
1416 ThrowMontageException(OptionError,"MissingArgument",option);
1419 if (LocaleCompare("size",option+1) == 0)
1424 if (i == (long) argc)
1425 ThrowMontageException(OptionError,"MissingArgument",option);
1426 if (IsGeometry(argv[i]) == MagickFalse)
1427 ThrowMontageInvalidArgumentException(option,argv[i]);
1430 if (LocaleCompare("stroke",option+1) == 0)
1432 (void) QueryColorDatabase("none",&montage_info->stroke,exception);
1436 if (i == (long) argc)
1437 ThrowMontageException(OptionError,"MissingArgument",option);
1438 (void) QueryColorDatabase(argv[i],&montage_info->stroke,
1442 if (LocaleCompare("strip",option+1) == 0)
1444 if (LocaleCompare("strokewidth",option+1) == 0)
1449 if (i == (long) argc)
1450 ThrowMontageException(OptionError,"MissingArgument",option);
1451 if (IsGeometry(argv[i]) == MagickFalse)
1452 ThrowMontageInvalidArgumentException(option,argv[i]);
1455 if (LocaleCompare("support",option+1) == 0)
1457 i++; /* deprecated */
1460 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1464 if (LocaleCompare("texture",option+1) == 0)
1466 (void) CloneString(&montage_info->texture,(char *) NULL);
1470 if (i == (long) argc)
1471 ThrowMontageException(OptionError,"MissingArgument",option);
1472 (void) CloneString(&montage_info->texture,argv[i]);
1475 if (LocaleCompare("thumbnail",option+1) == 0)
1480 if (i == (long) argc)
1481 ThrowMontageException(OptionError,"MissingArgument",option);
1482 if (IsGeometry(argv[i]) == MagickFalse)
1483 ThrowMontageInvalidArgumentException(option,argv[i]);
1486 if (LocaleCompare("tile",option+1) == 0)
1488 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1489 (void) CloneString(&montage_info->tile,(char *) NULL);
1493 if (i == (long) argc)
1494 ThrowMontageException(OptionError,"MissingArgument",option);
1495 if (IsGeometry(argv[i]) == MagickFalse)
1496 ThrowMontageInvalidArgumentException(option,argv[i]);
1497 (void) CloneString(&montage_info->tile,argv[i]);
1500 if (LocaleCompare("tile-offset",option+1) == 0)
1505 if (i == (long) (argc-1))
1506 ThrowMontageException(OptionError,"MissingArgument",option);
1507 if (IsGeometry(argv[i]) == MagickFalse)
1508 ThrowMontageInvalidArgumentException(option,argv[i]);
1511 if (LocaleCompare("tint",option+1) == 0)
1516 if (i == (long) argc)
1517 ThrowMontageException(OptionError,"MissingArgument",option);
1518 if (IsGeometry(argv[i]) == MagickFalse)
1519 ThrowMontageInvalidArgumentException(option,argv[i]);
1522 if (LocaleCompare("transform",option+1) == 0)
1524 if (LocaleCompare("transpose",option+1) == 0)
1526 if (LocaleCompare("title",option+1) == 0)
1528 (void) CloneString(&montage_info->title,(char *) NULL);
1532 if (i == (long) argc)
1533 ThrowMontageException(OptionError,"MissingArgument",option);
1534 (void) CloneString(&montage_info->title,argv[i]);
1537 if (LocaleCompare("transform",option+1) == 0)
1539 if (LocaleCompare("transparent",option+1) == 0)
1541 transparent_color=(char *) NULL;
1543 if (i == (long) argc)
1544 ThrowMontageException(OptionError,"MissingArgument",option);
1545 (void) CloneString(&transparent_color,argv[i]);
1548 if (LocaleCompare("transparent-color",option+1) == 0)
1553 if (i == (long) (argc-1))
1554 ThrowMontageException(OptionError,"MissingArgument",option);
1557 if (LocaleCompare("treedepth",option+1) == 0)
1562 if (i == (long) argc)
1563 ThrowMontageException(OptionError,"MissingArgument",option);
1564 if (IsGeometry(argv[i]) == MagickFalse)
1565 ThrowMontageInvalidArgumentException(option,argv[i]);
1568 if (LocaleCompare("trim",option+1) == 0)
1570 if (LocaleCompare("type",option+1) == 0)
1578 if (i == (long) argc)
1579 ThrowMontageException(OptionError,"MissingArgument",option);
1580 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
1582 ThrowMontageException(OptionError,"UnrecognizedImageType",
1586 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1590 if (LocaleCompare("units",option+1) == 0)
1598 if (i == (long) (argc-1))
1599 ThrowMontageException(OptionError,"MissingArgument",option);
1600 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
1603 ThrowMontageException(OptionError,"UnrecognizedUnitsType",
1607 if (LocaleCompare("unsharp",option+1) == 0)
1612 if (i == (long) (argc-1))
1613 ThrowMontageException(OptionError,"MissingArgument",option);
1614 if (IsGeometry(argv[i]) == MagickFalse)
1615 ThrowMontageInvalidArgumentException(option,argv[i]);
1618 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1622 if (LocaleCompare("verbose",option+1) == 0)
1626 if ((LocaleCompare("version",option+1) == 0) ||
1627 (LocaleCompare("-version",option+1) == 0))
1629 (void) fprintf(stdout,"Version: %s\n",
1630 GetMagickVersion((unsigned long *) NULL));
1631 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
1632 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
1635 if (LocaleCompare("virtual-pixel",option+1) == 0)
1643 if (i == (long) argc)
1644 ThrowMontageException(OptionError,"MissingArgument",option);
1645 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
1648 ThrowMontageException(OptionError,
1649 "UnrecognizedVirtualPixelMethod",argv[i]);
1652 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1656 if (LocaleCompare("white-point",option+1) == 0)
1661 if (i == (long) argc)
1662 ThrowMontageException(OptionError,"MissingArgument",option);
1663 if (IsGeometry(argv[i]) == MagickFalse)
1664 ThrowMontageInvalidArgumentException(option,argv[i]);
1667 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1672 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1674 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
1675 MagickFalse : MagickTrue;
1676 if (fire != MagickFalse)
1677 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1680 ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
1681 if (i-- != (long) (argc-1))
1682 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
1683 if (image == (Image *) NULL)
1684 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1685 FinalizeImageSettings(image_info,image,MagickTrue);
1686 if (image == (Image *) NULL)
1687 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1688 (void) CopyMagickString(montage_info->filename,argv[argc-1],MaxTextExtent);
1689 montage_image=MontageImageList(image_info,montage_info,image,exception);
1690 if (montage_image == (Image *) NULL)
1697 GetImageException(montage_image,exception);
1698 (void) CopyMagickString(image_info->filename,argv[argc-1],MaxTextExtent);
1699 (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1701 if (*montage_image->magick == '\0')
1702 (void) CopyMagickString(montage_image->magick,image->magick,
1704 status&=WriteImages(image_info,montage_image,argv[argc-1],exception);
1705 if (metadata != (char **) NULL)
1710 text=InterpretImageProperties(image_info,montage_image,format);
1711 if (text == (char *) NULL)
1712 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
1713 GetExceptionMessage(errno));
1714 (void) ConcatenateString(&(*metadata),text);
1715 (void) ConcatenateString(&(*metadata),"\n");
1716 text=DestroyString(text);
1719 montage_info=DestroyMontageInfo(montage_info);
1721 return(status != 0 ? MagickTrue : MagickFalse);