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-2012 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 "-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 "-synchronize synchronize image to storage device",
190 "-taint declare the image as modified",
191 "-texture filename name of texture to tile onto the image background",
192 "-thumbnail geometry create a thumbnail of the image",
193 "-tile geometry number of tiles per row and column",
194 "-title string decorate the montage image with a title",
195 "-transparent-color color",
196 " transparent color",
197 "-treedepth value color tree depth",
198 "-trim trim image edges",
199 "-units type the units of image resolution",
200 "-verbose print detailed information about the image",
201 "-virtual-pixel method",
202 " virtual pixel access method",
203 "-white-point point chromaticity white point",
206 *sequence_operators[]=
208 "-coalesce merge a sequence of images",
209 "-composite composite image",
214 "-clone indexes clone an image",
215 "-delete indexes delete the image from the image sequence",
216 "-duplicate count,indexes",
217 " duplicate an image one or more times",
218 "-insert index insert last image into the image sequence",
219 "-reverse reverse image sequence",
220 "-swap indexes swap two images in the image sequence",
224 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
225 (void) printf("Copyright: %s\n",GetMagickCopyright());
226 (void) printf("Features: %s\n\n",GetMagickFeatures());
227 (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n",
229 (void) printf("\nImage Settings:\n");
230 for (p=settings; *p != (char *) NULL; p++)
231 (void) printf(" %s\n",*p);
232 (void) printf("\nImage Operators:\n");
233 for (p=operators; *p != (char *) NULL; p++)
234 (void) printf(" %s\n",*p);
235 (void) printf("\nImage Sequence Operators:\n");
236 for (p=sequence_operators; *p != (char *) NULL; p++)
237 (void) printf(" %s\n",*p);
238 (void) printf("\nImage Stack Operators:\n");
239 for (p=stack_operators; *p != (char *) NULL; p++)
240 (void) printf(" %s\n",*p);
241 (void) printf("\nMiscellaneous Options:\n");
242 for (p=miscellaneous; *p != (char *) NULL; p++)
243 (void) printf(" %s\n",*p);
245 "\nIn addition to those listed above, you can specify these standard X\n");
247 "resources as command line options: -background, -bordercolor,\n");
249 "-borderwidth, -font, -mattecolor, or -title\n");
251 "\nBy default, the image format of 'file' is determined by its magic\n");
253 "number. To specify a particular image format, precede the filename\n");
255 "with an image format name and a colon (i.e. ps:image) or specify the\n");
257 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
258 (void) printf("'-' for standard input or output.\n");
262 WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
263 int argc,char **argv,char **metadata,ExceptionInfo *exception)
265 #define DestroyMontage() \
267 if (montage_image != (Image *) NULL) \
268 montage_image=DestroyImageList(montage_image); \
269 DestroyImageStack(); \
270 for (i=0; i < (ssize_t) argc; i++) \
271 argv[i]=DestroyString(argv[i]); \
272 argv=(char **) RelinquishMagickMemory(argv); \
274 #define ThrowMontageException(asperity,tag,option) \
276 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \
279 return(MagickFalse); \
281 #define ThrowMontageInvalidArgumentException(option,argument) \
283 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
284 "InvalidArgument","'%s': %s",option,argument); \
286 return(MagickFalse); \
301 image_stack[MaxImageStackDepth+1];
329 assert(image_info != (ImageInfo *) NULL);
330 assert(image_info->signature == MagickSignature);
331 if (image_info->debug != MagickFalse)
332 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
333 assert(exception != (ExceptionInfo *) NULL);
337 if ((LocaleCompare("version",option+1) == 0) ||
338 (LocaleCompare("-version",option+1) == 0))
340 (void) FormatLocaleFile(stdout,"Version: %s\n",
341 GetMagickVersion((size_t *) NULL));
342 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
343 GetMagickCopyright());
344 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
345 GetMagickFeatures());
350 return(MontageUsage());
356 montage_image=NewImageList();
357 montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
359 option=(char *) NULL;
361 respect_parenthesis=MagickFalse;
364 transparent_color=(char *) NULL;
368 ReadCommandlLine(argc,&argv);
369 status=ExpandFilenames(&argc,&argv);
370 if (status == MagickFalse)
371 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
372 GetExceptionMessage(errno));
373 for (i=1; i < (ssize_t) (argc-1); i++)
376 if (LocaleCompare(option,"(") == 0)
378 FireImageStack(MagickTrue,MagickTrue,pend);
379 if (k == MaxImageStackDepth)
380 ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply",
385 if (LocaleCompare(option,")") == 0)
387 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
389 ThrowMontageException(OptionError,"UnableToParseExpression",option);
393 if (IsCommandOption(option) == MagickFalse)
398 FireImageStack(MagickFalse,MagickFalse,pend);
399 for (scene=(ssize_t) first_scene; scene <= (ssize_t) last_scene ; scene++)
405 Option is a file name: begin by reading image from specified file.
408 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
410 (void) CloneString(&image_info->font,montage_info->font);
411 if (first_scene == last_scene)
412 images=ReadImages(image_info,filename,exception);
416 filename[MaxTextExtent];
419 Form filename for multi-part images.
421 (void) InterpretImageFilename(image_info,(Image *) NULL,
422 image_info->filename,(int) scene,filename,exception);
423 if (LocaleCompare(filename,image_info->filename) == 0)
424 (void) FormatLocaleString(filename,MaxTextExtent,"%s.%.20g",
425 image_info->filename,(double) scene);
426 images=ReadImages(image_info,filename,exception);
428 status&=(images != (Image *) NULL) &&
429 (exception->severity < ErrorException);
430 if (images == (Image *) NULL)
432 AppendImageStack(images);
436 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
441 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
444 if (i == (ssize_t) (argc-1))
445 ThrowMontageException(OptionError,"MissingArgument",option);
446 if (IsGeometry(argv[i]) == MagickFalse)
447 ThrowMontageInvalidArgumentException(option,argv[i]);
450 if (LocaleCompare("adjoin",option+1) == 0)
452 if (LocaleCompare("affine",option+1) == 0)
457 if (i == (ssize_t) (argc-1))
458 ThrowMontageException(OptionError,"MissingArgument",option);
459 if (IsGeometry(argv[i]) == MagickFalse)
460 ThrowMontageInvalidArgumentException(option,argv[i]);
463 if (LocaleCompare("alpha",option+1) == 0)
471 if (i == (ssize_t) argc)
472 ThrowMontageException(OptionError,"MissingArgument",option);
473 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
475 ThrowMontageException(OptionError,"UnrecognizedAlphaChannelType",
479 if (LocaleCompare("annotate",option+1) == 0)
484 if (i == (ssize_t) (argc-1))
485 ThrowMontageException(OptionError,"MissingArgument",option);
486 if (IsGeometry(argv[i]) == MagickFalse)
487 ThrowMontageInvalidArgumentException(option,argv[i]);
488 if (i == (ssize_t) (argc-1))
489 ThrowMontageException(OptionError,"MissingArgument",option);
493 if (LocaleCompare("auto-orient",option+1) == 0)
495 if (LocaleCompare("authenticate",option+1) == 0)
500 if (i == (ssize_t) argc)
501 ThrowMontageException(OptionError,"MissingArgument",option);
504 ThrowMontageException(OptionError,"UnrecognizedOption",option)
508 if (LocaleCompare("background",option+1) == 0)
513 if (i == (ssize_t) argc)
514 ThrowMontageException(OptionError,"MissingArgument",option);
515 (void) QueryColorCompliance(argv[i],AllCompliance,
516 &montage_info->background_color,exception);
519 if (LocaleCompare("blue-primary",option+1) == 0)
524 if (i == (ssize_t) argc)
525 ThrowMontageException(OptionError,"MissingArgument",option);
526 if (IsGeometry(argv[i]) == MagickFalse)
527 ThrowMontageInvalidArgumentException(option,argv[i]);
530 if (LocaleCompare("blur",option+1) == 0)
535 if (i == (ssize_t) argc)
536 ThrowMontageException(OptionError,"MissingArgument",option);
537 if (IsGeometry(argv[i]) == MagickFalse)
538 ThrowMontageInvalidArgumentException(option,argv[i]);
541 if (LocaleCompare("border",option+1) == 0)
545 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
546 montage_info->border_width=0;
551 if (i == (ssize_t) argc)
552 ThrowMontageException(OptionError,"MissingArgument",option);
553 if (IsGeometry(argv[i]) == MagickFalse)
554 ThrowMontageInvalidArgumentException(option,argv[i]);
556 montage_info->border_width=StringToUnsignedLong(argv[i]);
559 if (LocaleCompare("bordercolor",option+1) == 0)
564 if (i == (ssize_t) argc)
565 ThrowMontageException(OptionError,"MissingArgument",option);
566 (void) QueryColorCompliance(argv[i],AllCompliance,
567 &montage_info->border_color,exception);
570 if (LocaleCompare("borderwidth",option+1) == 0)
572 montage_info->border_width=0;
576 if (i == (ssize_t) argc)
577 ThrowMontageException(OptionError,"MissingArgument",option);
578 if (IsGeometry(argv[i]) == MagickFalse)
579 ThrowMontageInvalidArgumentException(option,argv[i]);
580 montage_info->border_width=StringToUnsignedLong(argv[i]);
583 ThrowMontageException(OptionError,"UnrecognizedOption",option)
587 if (LocaleCompare("cache",option+1) == 0)
592 if (i == (ssize_t) argc)
593 ThrowMontageException(OptionError,"MissingArgument",option);
594 if (IsGeometry(argv[i]) == MagickFalse)
595 ThrowMontageInvalidArgumentException(option,argv[i]);
598 if (LocaleCompare("caption",option+1) == 0)
603 if (i == (ssize_t) argc)
604 ThrowMontageException(OptionError,"MissingArgument",option);
607 if (LocaleCompare("channel",option+1) == 0)
615 if (i == (ssize_t) (argc-1))
616 ThrowMontageException(OptionError,"MissingArgument",option);
617 channel=ParseChannelOption(argv[i]);
619 ThrowMontageException(OptionError,"UnrecognizedChannelType",
623 if (LocaleCompare("clone",option+1) == 0)
630 clone_images=image_stack[k-1].image;
631 if (clone_images == (Image *) NULL)
632 ThrowMontageException(ImageError,"UnableToCloneImage",option);
633 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
635 clone_images=CloneImages(clone_images,"-1",exception);
639 if (i == (ssize_t) (argc-1))
640 ThrowMontageException(OptionError,"MissingArgument",option);
641 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
642 ThrowMontageInvalidArgumentException(option,argv[i]);
643 clone_images=CloneImages(clone_images,argv[i],exception);
645 if (clone_images == (Image *) NULL)
646 ThrowMontageException(OptionError,"NoSuchImage",option);
647 AppendImageStack(clone_images);
650 if (LocaleCompare("coalesce",option+1) == 0)
652 if (LocaleCompare("colors",option+1) == 0)
657 if (i == (ssize_t) argc)
658 ThrowMontageException(OptionError,"MissingArgument",option);
659 if (IsGeometry(argv[i]) == MagickFalse)
660 ThrowMontageInvalidArgumentException(option,argv[i]);
663 if (LocaleCompare("colorspace",option+1) == 0)
671 if (i == (ssize_t) argc)
672 ThrowMontageException(OptionError,"MissingArgument",option);
673 colorspace=ParseCommandOption(MagickColorspaceOptions,
674 MagickFalse,argv[i]);
676 ThrowMontageException(OptionError,"UnrecognizedColorspace",
680 if (LocaleCompare("comment",option+1) == 0)
685 if (i == (ssize_t) argc)
686 ThrowMontageException(OptionError,"MissingArgument",option);
689 if (LocaleCompare("compose",option+1) == 0)
697 if (i == (ssize_t) argc)
698 ThrowMontageException(OptionError,"MissingArgument",option);
699 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,argv[i]);
701 ThrowMontageException(OptionError,"UnrecognizedComposeOperator",
705 if (LocaleCompare("composite",option+1) == 0)
707 if (LocaleCompare("compress",option+1) == 0)
715 if (i == (ssize_t) argc)
716 ThrowMontageException(OptionError,"MissingArgument",option);
717 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
720 ThrowMontageException(OptionError,"UnrecognizedCompressType",
724 if (LocaleCompare("concurrent",option+1) == 0)
726 if (LocaleCompare("crop",option+1) == 0)
731 if (i == (ssize_t) argc)
732 ThrowMontageException(OptionError,"MissingArgument",option);
733 if (IsGeometry(argv[i]) == MagickFalse)
734 ThrowMontageInvalidArgumentException(option,argv[i]);
737 ThrowMontageException(OptionError,"UnrecognizedOption",option)
741 if (LocaleCompare("debug",option+1) == 0)
749 if (i == (ssize_t) argc)
750 ThrowMontageException(OptionError,"MissingArgument",option);
751 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
753 ThrowMontageException(OptionError,"UnrecognizedEventType",
755 (void) SetLogEventMask(argv[i]);
758 if (LocaleCompare("define",option+1) == 0)
761 if (i == (ssize_t) argc)
762 ThrowMontageException(OptionError,"MissingArgument",option);
768 define=GetImageOption(image_info,argv[i]);
769 if (define == (const char *) NULL)
770 ThrowMontageException(OptionError,"NoSuchOption",argv[i]);
775 if (LocaleCompare("delete",option+1) == 0)
780 if (i == (ssize_t) (argc-1))
781 ThrowMontageException(OptionError,"MissingArgument",option);
782 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
783 ThrowMontageInvalidArgumentException(option,argv[i]);
786 if (LocaleCompare("density",option+1) == 0)
791 if (i == (ssize_t) argc)
792 ThrowMontageException(OptionError,"MissingArgument",option);
793 if (IsGeometry(argv[i]) == MagickFalse)
794 ThrowMontageInvalidArgumentException(option,argv[i]);
797 if (LocaleCompare("depth",option+1) == 0)
802 if (i == (ssize_t) argc)
803 ThrowMontageException(OptionError,"MissingArgument",option);
804 if (IsGeometry(argv[i]) == MagickFalse)
805 ThrowMontageInvalidArgumentException(option,argv[i]);
808 if (LocaleCompare("display",option+1) == 0)
813 if (i == (ssize_t) argc)
814 ThrowMontageException(OptionError,"MissingArgument",option);
817 if (LocaleCompare("dispose",option+1) == 0)
825 if (i == (ssize_t) argc)
826 ThrowMontageException(OptionError,"MissingArgument",option);
827 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
829 ThrowMontageException(OptionError,"UnrecognizedDisposeMethod",
833 if (LocaleCompare("dither",option+1) == 0)
841 if (i == (ssize_t) argc)
842 ThrowMontageException(OptionError,"MissingArgument",option);
843 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
845 ThrowMontageException(OptionError,"UnrecognizedDitherMethod",
849 if (LocaleCompare("draw",option+1) == 0)
854 if (i == (ssize_t) argc)
855 ThrowMontageException(OptionError,"MissingArgument",option);
858 if (LocaleCompare("duplicate",option+1) == 0)
863 if (i == (ssize_t) (argc-1))
864 ThrowMontageException(OptionError,"MissingArgument",option);
865 if (IsGeometry(argv[i]) == MagickFalse)
866 ThrowMontageInvalidArgumentException(option,argv[i]);
869 if (LocaleCompare("duration",option+1) == 0)
874 if (i == (ssize_t) (argc-1))
875 ThrowMontageException(OptionError,"MissingArgument",option);
876 if (IsGeometry(argv[i]) == MagickFalse)
877 ThrowMontageInvalidArgumentException(option,argv[i]);
880 ThrowMontageException(OptionError,"UnrecognizedOption",option)
884 if (LocaleCompare("encoding",option+1) == 0)
889 if (i == (ssize_t) argc)
890 ThrowMontageException(OptionError,"MissingArgument",option);
893 if (LocaleCompare("endian",option+1) == 0)
901 if (i == (ssize_t) argc)
902 ThrowMontageException(OptionError,"MissingArgument",option);
903 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
906 ThrowMontageException(OptionError,"UnrecognizedEndianType",
910 if (LocaleCompare("extent",option+1) == 0)
915 if (i == (ssize_t) (argc-1))
916 ThrowMontageException(OptionError,"MissingArgument",option);
917 if (IsGeometry(argv[i]) == MagickFalse)
918 ThrowMontageInvalidArgumentException(option,argv[i]);
921 ThrowMontageException(OptionError,"UnrecognizedOption",option)
925 if (LocaleCompare("fill",option+1) == 0)
927 (void) QueryColorCompliance("none",AllCompliance,
928 &montage_info->fill,exception);
932 if (i == (ssize_t) argc)
933 ThrowMontageException(OptionError,"MissingArgument",option);
934 (void) QueryColorCompliance(argv[i],AllCompliance,
935 &montage_info->fill,exception);
938 if (LocaleCompare("filter",option+1) == 0)
946 if (i == (ssize_t) argc)
947 ThrowMontageException(OptionError,"MissingArgument",option);
948 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
950 ThrowMontageException(OptionError,"UnrecognizedImageFilter",
954 if (LocaleCompare("flatten",option+1) == 0)
956 if (LocaleCompare("flip",option+1) == 0)
958 if (LocaleCompare("flop",option+1) == 0)
960 if (LocaleCompare("font",option+1) == 0)
965 if (i == (ssize_t) argc)
966 ThrowMontageException(OptionError,"MissingArgument",option);
967 (void) CloneString(&montage_info->font,argv[i]);
970 if (LocaleCompare("format",option+1) == 0)
975 if (i == (ssize_t) argc)
976 ThrowMontageException(OptionError,"MissingArgument",option);
980 if (LocaleCompare("frame",option+1) == 0)
984 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
985 (void) CloneString(&montage_info->frame,(char *) NULL);
990 if (i == (ssize_t) argc)
991 ThrowMontageException(OptionError,"MissingArgument",option);
992 if (IsGeometry(argv[i]) == MagickFalse)
993 ThrowMontageInvalidArgumentException(option,argv[i]);
995 (void) CloneString(&montage_info->frame,argv[i]);
998 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1002 if (LocaleCompare("gamma",option+1) == 0)
1005 if (i == (ssize_t) argc)
1006 ThrowMontageException(OptionError,"MissingArgument",option);
1007 if (IsGeometry(argv[i]) == MagickFalse)
1008 ThrowMontageInvalidArgumentException(option,argv[i]);
1011 if (LocaleCompare("geometry",option+1) == 0)
1013 (void) CloneString(&montage_info->geometry,(char *) NULL);
1017 if (i == (ssize_t) argc)
1018 ThrowMontageException(OptionError,"MissingArgument",option);
1019 if (IsGeometry(argv[i]) == MagickFalse)
1020 ThrowMontageInvalidArgumentException(option,argv[i]);
1021 (void) CloneString(&montage_info->geometry,argv[i]);
1024 if (LocaleCompare("gravity",option+1) == 0)
1029 montage_info->gravity=UndefinedGravity;
1033 if (i == (ssize_t) argc)
1034 ThrowMontageException(OptionError,"MissingArgument",option);
1035 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1038 ThrowMontageException(OptionError,"UnrecognizedGravityType",
1040 montage_info->gravity=(GravityType) gravity;
1043 if (LocaleCompare("green-primary",option+1) == 0)
1048 if (i == (ssize_t) argc)
1049 ThrowMontageException(OptionError,"MissingArgument",option);
1050 if (IsGeometry(argv[i]) == MagickFalse)
1051 ThrowMontageInvalidArgumentException(option,argv[i]);
1054 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1058 if ((LocaleCompare("help",option+1) == 0) ||
1059 (LocaleCompare("-help",option+1) == 0))
1060 return(MontageUsage());
1061 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1065 if (LocaleCompare("identify",option+1) == 0)
1067 if (LocaleCompare("insert",option+1) == 0)
1072 if (i == (ssize_t) (argc-1))
1073 ThrowMontageException(OptionError,"MissingArgument",option);
1074 if (IsGeometry(argv[i]) == MagickFalse)
1075 ThrowMontageInvalidArgumentException(option,argv[i]);
1078 if (LocaleCompare("interlace",option+1) == 0)
1086 if (i == (ssize_t) argc)
1087 ThrowMontageException(OptionError,"MissingArgument",option);
1088 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1091 ThrowMontageException(OptionError,"UnrecognizedInterlaceType",
1095 if (LocaleCompare("interpolate",option+1) == 0)
1103 if (i == (ssize_t) argc)
1104 ThrowMontageException(OptionError,"MissingArgument",option);
1105 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1107 if (interpolate < 0)
1108 ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod",
1112 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1116 if (LocaleCompare("kerning",option+1) == 0)
1121 if (i == (ssize_t) (argc-1))
1122 ThrowMontageException(OptionError,"MissingArgument",option);
1123 if (IsGeometry(argv[i]) == MagickFalse)
1124 ThrowMontageInvalidArgumentException(option,argv[i]);
1127 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1131 if (LocaleCompare("label",option+1) == 0)
1136 if (i == (ssize_t) argc)
1137 ThrowMontageException(OptionError,"MissingArgument",option);
1140 if (LocaleCompare("limit",option+1) == 0)
1154 if (i == (ssize_t) argc)
1155 ThrowMontageException(OptionError,"MissingArgument",option);
1156 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1159 ThrowMontageException(OptionError,"UnrecognizedResourceType",
1162 if (i == (ssize_t) argc)
1163 ThrowMontageException(OptionError,"MissingArgument",option);
1164 value=StringToDouble(argv[i],&p);
1166 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1167 ThrowMontageInvalidArgumentException(option,argv[i]);
1170 if (LocaleCompare("list",option+1) == 0)
1178 if (i == (ssize_t) argc)
1179 ThrowMontageException(OptionError,"MissingArgument",option);
1180 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1182 ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]);
1183 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1186 return(status != 0 ? MagickFalse : MagickTrue);
1188 if (LocaleCompare("log",option+1) == 0)
1193 if ((i == (ssize_t) argc) ||
1194 (strchr(argv[i],'%') == (char *) NULL))
1195 ThrowMontageException(OptionError,"MissingArgument",option);
1198 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1202 if (LocaleCompare("matte",option+1) == 0)
1204 if (LocaleCompare("mattecolor",option+1) == 0)
1209 if (i == (ssize_t) argc)
1210 ThrowMontageException(OptionError,"MissingArgument",option);
1211 (void) QueryColorCompliance(argv[i],AllCompliance,
1212 &montage_info->matte_color,exception);
1215 if (LocaleCompare("mode",option+1) == 0)
1220 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1224 if (i == (ssize_t) argc)
1225 ThrowMontageException(OptionError,"MissingArgument",option);
1227 if (LocaleCompare("frame",argv[i]) == 0)
1230 (void) CloneString(&montage_info->frame,"15x15+3+3");
1231 montage_info->shadow=MagickTrue;
1234 if (LocaleCompare("unframe",argv[i]) == 0)
1237 montage_info->frame=(char *) NULL;
1238 montage_info->shadow=MagickFalse;
1239 montage_info->border_width=0;
1242 if (LocaleCompare("concatenate",argv[i]) == 0)
1244 mode=ConcatenateMode;
1245 montage_info->frame=(char *) NULL;
1246 montage_info->shadow=MagickFalse;
1247 montage_info->gravity=(GravityType) NorthWestGravity;
1248 (void) CloneString(&montage_info->geometry,"+0+0");
1249 montage_info->border_width=0;
1252 if (mode == UndefinedMode)
1253 ThrowMontageException(OptionError,"UnrecognizedImageMode",
1257 if (LocaleCompare("monitor",option+1) == 0)
1259 if (LocaleCompare("monochrome",option+1) == 0)
1265 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1269 if (LocaleCompare("noop",option+1) == 0)
1271 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1275 if (LocaleCompare("page",option+1) == 0)
1280 if (i == (ssize_t) argc)
1281 ThrowMontageException(OptionError,"MissingArgument",option);
1284 if (LocaleCompare("pointsize",option+1) == 0)
1286 montage_info->pointsize=12;
1290 if (i == (ssize_t) argc)
1291 ThrowMontageException(OptionError,"MissingArgument",option);
1292 if (IsGeometry(argv[i]) == MagickFalse)
1293 ThrowMontageInvalidArgumentException(option,argv[i]);
1294 montage_info->pointsize=StringToDouble(argv[i],(char **) NULL);
1297 if (LocaleCompare("polaroid",option+1) == 0)
1302 if (i == (ssize_t) (argc-1))
1303 ThrowMontageException(OptionError,"MissingArgument",option);
1304 if (IsGeometry(argv[i]) == MagickFalse)
1305 ThrowMontageInvalidArgumentException(option,argv[i]);
1308 if (LocaleCompare("profile",option+1) == 0)
1311 if (i == (ssize_t) (argc-1))
1312 ThrowMontageException(OptionError,"MissingArgument",option);
1315 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1319 if (LocaleCompare("quality",option+1) == 0)
1324 if (i == (ssize_t) argc)
1325 ThrowMontageException(OptionError,"MissingArgument",option);
1326 if (IsGeometry(argv[i]) == MagickFalse)
1327 ThrowMontageInvalidArgumentException(option,argv[i]);
1330 if (LocaleCompare("quantize",option+1) == 0)
1338 if (i == (ssize_t) (argc-1))
1339 ThrowMontageException(OptionError,"MissingArgument",option);
1340 colorspace=ParseCommandOption(MagickColorspaceOptions,
1341 MagickFalse,argv[i]);
1343 ThrowMontageException(OptionError,"UnrecognizedColorspace",
1347 if (LocaleCompare("quiet",option+1) == 0)
1349 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1353 if (LocaleCompare("red-primary",option+1) == 0)
1358 if (i == (ssize_t) argc)
1359 ThrowMontageException(OptionError,"MissingArgument",option);
1360 if (IsGeometry(argv[i]) == MagickFalse)
1361 ThrowMontageInvalidArgumentException(option,argv[i]);
1364 if (LocaleCompare("regard-warnings",option+1) == 0)
1366 if (LocaleCompare("render",option+1) == 0)
1368 if (LocaleCompare("repage",option+1) == 0)
1373 if (i == (ssize_t) argc)
1374 ThrowMontageException(OptionError,"MissingArgument",option);
1375 if (IsGeometry(argv[i]) == MagickFalse)
1376 ThrowMontageInvalidArgumentException(option,argv[i]);
1379 if (LocaleCompare("resize",option+1) == 0)
1384 if (i == (ssize_t) argc)
1385 ThrowMontageException(OptionError,"MissingArgument",option);
1386 if (IsGeometry(argv[i]) == MagickFalse)
1387 ThrowMontageInvalidArgumentException(option,argv[i]);
1390 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1392 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1395 if (LocaleCompare("reverse",option+1) == 0)
1397 if (LocaleCompare("rotate",option+1) == 0)
1400 if (i == (ssize_t) argc)
1401 ThrowMontageException(OptionError,"MissingArgument",option);
1402 if (IsGeometry(argv[i]) == MagickFalse)
1403 ThrowMontageInvalidArgumentException(option,argv[i]);
1406 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1410 if (LocaleCompare("sampling-factor",option+1) == 0)
1415 if (i == (ssize_t) argc)
1416 ThrowMontageException(OptionError,"MissingArgument",option);
1417 if (IsGeometry(argv[i]) == MagickFalse)
1418 ThrowMontageInvalidArgumentException(option,argv[i]);
1421 if (LocaleCompare("seed",option+1) == 0)
1426 if (i == (ssize_t) (argc-1))
1427 ThrowMontageException(OptionError,"MissingArgument",option);
1428 if (IsGeometry(argv[i]) == MagickFalse)
1429 ThrowMontageInvalidArgumentException(option,argv[i]);
1432 if (LocaleCompare("scenes",option+1) == 0)
1439 if (i == (ssize_t) argc)
1440 ThrowMontageException(OptionError,"MissingArgument",option);
1441 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1442 ThrowMontageInvalidArgumentException(option,argv[i]);
1443 first_scene=(int) StringToLong(argv[i]);
1444 last_scene=first_scene;
1445 (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene);
1448 if (LocaleCompare("set",option+1) == 0)
1451 if (i == (ssize_t) argc)
1452 ThrowMontageException(OptionError,"MissingArgument",option);
1456 if (i == (ssize_t) argc)
1457 ThrowMontageException(OptionError,"MissingArgument",option);
1460 if (LocaleCompare("shadow",option+1) == 0)
1464 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1465 montage_info->shadow=(*option == '-') ? MagickTrue :
1472 if (i == (ssize_t) (argc-1))
1473 ThrowMontageException(OptionError,"MissingArgument",option);
1474 if (IsGeometry(argv[i]) == MagickFalse)
1475 ThrowMontageInvalidArgumentException(option,argv[i]);
1478 if (LocaleCompare("sharpen",option+1) == 0)
1483 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
1484 ThrowMontageException(OptionError,"MissingArgument",option);
1487 if (LocaleCompare("size",option+1) == 0)
1492 if (i == (ssize_t) argc)
1493 ThrowMontageException(OptionError,"MissingArgument",option);
1494 if (IsGeometry(argv[i]) == MagickFalse)
1495 ThrowMontageInvalidArgumentException(option,argv[i]);
1498 if (LocaleCompare("stroke",option+1) == 0)
1500 (void) QueryColorCompliance("none",AllCompliance,
1501 &montage_info->stroke,exception);
1505 if (i == (ssize_t) argc)
1506 ThrowMontageException(OptionError,"MissingArgument",option);
1507 (void) QueryColorCompliance(argv[i],AllCompliance,
1508 &montage_info->stroke,exception);
1511 if (LocaleCompare("strip",option+1) == 0)
1513 if (LocaleCompare("strokewidth",option+1) == 0)
1518 if (i == (ssize_t) argc)
1519 ThrowMontageException(OptionError,"MissingArgument",option);
1520 if (IsGeometry(argv[i]) == MagickFalse)
1521 ThrowMontageInvalidArgumentException(option,argv[i]);
1524 if (LocaleCompare("support",option+1) == 0)
1526 i++; /* deprecated */
1529 if (LocaleCompare("swap",option+1) == 0)
1534 if (i == (ssize_t) (argc-1))
1535 ThrowMontageException(OptionError,"MissingArgument",option);
1536 if (IsGeometry(argv[i]) == MagickFalse)
1537 ThrowMontageInvalidArgumentException(option,argv[i]);
1540 if (LocaleCompare("synchronize",option+1) == 0)
1542 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1546 if (LocaleCompare("taint",option+1) == 0)
1548 if (LocaleCompare("texture",option+1) == 0)
1550 (void) CloneString(&montage_info->texture,(char *) NULL);
1554 if (i == (ssize_t) argc)
1555 ThrowMontageException(OptionError,"MissingArgument",option);
1556 (void) CloneString(&montage_info->texture,argv[i]);
1559 if (LocaleCompare("thumbnail",option+1) == 0)
1564 if (i == (ssize_t) argc)
1565 ThrowMontageException(OptionError,"MissingArgument",option);
1566 if (IsGeometry(argv[i]) == MagickFalse)
1567 ThrowMontageInvalidArgumentException(option,argv[i]);
1570 if (LocaleCompare("tile",option+1) == 0)
1574 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1575 (void) CloneString(&montage_info->tile,(char *) NULL);
1580 if (i == (ssize_t) argc)
1581 ThrowMontageException(OptionError,"MissingArgument",option);
1582 if (IsGeometry(argv[i]) == MagickFalse)
1583 ThrowMontageInvalidArgumentException(option,argv[i]);
1585 (void) CloneString(&montage_info->tile,argv[i]);
1588 if (LocaleCompare("tile-offset",option+1) == 0)
1593 if (i == (ssize_t) (argc-1))
1594 ThrowMontageException(OptionError,"MissingArgument",option);
1595 if (IsGeometry(argv[i]) == MagickFalse)
1596 ThrowMontageInvalidArgumentException(option,argv[i]);
1599 if (LocaleCompare("tint",option+1) == 0)
1604 if (i == (ssize_t) argc)
1605 ThrowMontageException(OptionError,"MissingArgument",option);
1606 if (IsGeometry(argv[i]) == MagickFalse)
1607 ThrowMontageInvalidArgumentException(option,argv[i]);
1610 if (LocaleCompare("transform",option+1) == 0)
1612 if (LocaleCompare("transpose",option+1) == 0)
1614 if (LocaleCompare("title",option+1) == 0)
1616 (void) CloneString(&montage_info->title,(char *) NULL);
1620 if (i == (ssize_t) argc)
1621 ThrowMontageException(OptionError,"MissingArgument",option);
1622 (void) CloneString(&montage_info->title,argv[i]);
1625 if (LocaleCompare("transform",option+1) == 0)
1627 if (LocaleCompare("transparent",option+1) == 0)
1629 transparent_color=(char *) NULL;
1631 if (i == (ssize_t) argc)
1632 ThrowMontageException(OptionError,"MissingArgument",option);
1633 (void) CloneString(&transparent_color,argv[i]);
1636 if (LocaleCompare("transparent-color",option+1) == 0)
1641 if (i == (ssize_t) (argc-1))
1642 ThrowMontageException(OptionError,"MissingArgument",option);
1645 if (LocaleCompare("treedepth",option+1) == 0)
1650 if (i == (ssize_t) argc)
1651 ThrowMontageException(OptionError,"MissingArgument",option);
1652 if (IsGeometry(argv[i]) == MagickFalse)
1653 ThrowMontageInvalidArgumentException(option,argv[i]);
1656 if (LocaleCompare("trim",option+1) == 0)
1658 if (LocaleCompare("type",option+1) == 0)
1666 if (i == (ssize_t) argc)
1667 ThrowMontageException(OptionError,"MissingArgument",option);
1668 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1670 ThrowMontageException(OptionError,"UnrecognizedImageType",
1674 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1678 if (LocaleCompare("units",option+1) == 0)
1686 if (i == (ssize_t) (argc-1))
1687 ThrowMontageException(OptionError,"MissingArgument",option);
1688 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1691 ThrowMontageException(OptionError,"UnrecognizedUnitsType",
1695 if (LocaleCompare("unsharp",option+1) == 0)
1700 if (i == (ssize_t) (argc-1))
1701 ThrowMontageException(OptionError,"MissingArgument",option);
1702 if (IsGeometry(argv[i]) == MagickFalse)
1703 ThrowMontageInvalidArgumentException(option,argv[i]);
1706 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1710 if (LocaleCompare("verbose",option+1) == 0)
1714 if ((LocaleCompare("version",option+1) == 0) ||
1715 (LocaleCompare("-version",option+1) == 0))
1717 (void) FormatLocaleFile(stdout,"Version: %s\n",
1718 GetMagickVersion((size_t *) NULL));
1719 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
1720 GetMagickCopyright());
1721 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
1722 GetMagickFeatures());
1725 if (LocaleCompare("virtual-pixel",option+1) == 0)
1733 if (i == (ssize_t) argc)
1734 ThrowMontageException(OptionError,"MissingArgument",option);
1735 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1738 ThrowMontageException(OptionError,
1739 "UnrecognizedVirtualPixelMethod",argv[i]);
1742 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1746 if (LocaleCompare("white-point",option+1) == 0)
1751 if (i == (ssize_t) argc)
1752 ThrowMontageException(OptionError,"MissingArgument",option);
1753 if (IsGeometry(argv[i]) == MagickFalse)
1754 ThrowMontageInvalidArgumentException(option,argv[i]);
1757 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1762 ThrowMontageException(OptionError,"UnrecognizedOption",option)
1764 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1765 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1766 if (fire != MagickFalse)
1767 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1770 ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
1771 if (i-- != (ssize_t) (argc-1))
1772 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
1773 if (image == (Image *) NULL)
1774 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1775 FinalizeImageSettings(image_info,image,MagickTrue);
1776 if (image == (Image *) NULL)
1777 ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1778 (void) CopyMagickString(montage_info->filename,argv[argc-1],MaxTextExtent);
1779 montage_image=MontageImageList(image_info,montage_info,image,exception);
1780 if (montage_image == (Image *) NULL)
1787 (void) CopyMagickString(image_info->filename,argv[argc-1],MaxTextExtent);
1788 (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1790 if (*montage_image->magick == '\0')
1791 (void) CopyMagickString(montage_image->magick,image->magick,
1793 status&=WriteImages(image_info,montage_image,argv[argc-1],exception);
1794 if (metadata != (char **) NULL)
1799 text=InterpretImageProperties(image_info,montage_image,format,
1801 if (text == (char *) NULL)
1802 ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
1803 GetExceptionMessage(errno));
1804 (void) ConcatenateString(&(*metadata),text);
1805 (void) ConcatenateString(&(*metadata),"\n");
1806 text=DestroyString(text);
1809 montage_info=DestroyMontageInfo(montage_info);
1811 return(status != 0 ? MagickTrue : MagickFalse);