45#include "MagickWand/studio.h"
46#include "MagickWand/MagickWand.h"
47#include "MagickWand/mogrify-private.h"
48#include "MagickCore/string-private.h"
84static MagickBooleanType MontageUsage(
void)
88 " -debug events display copious debugging information\n"
89 " -help print program options\n"
90 " -list type print a list of supported option arguments\n"
91 " -log format format of debugging information\n"
92 " -version print version information",
94 " -adaptive-sharpen geometry\n"
95 " adaptively sharpen pixels; increase effect near edges\n"
96 " -annotate geometry text\n"
97 " annotate the image with text\n"
98 " -auto-orient automagically orient image\n"
99 " -blur geometry reduce image noise and reduce detail levels\n"
100 " -border geometry surround image with a border of color\n"
101 " -channel mask set the image channel mask\n"
102 " -crop geometry preferred size and location of the cropped image\n"
103 " -distort method args\n"
104 " distort images according to given method and args\n"
105 " -extent geometry set the image size\n"
106 " -flatten flatten a sequence of images\n"
107 " -flip flip image in the vertical direction\n"
108 " -flop flop image in the horizontal direction\n"
109 " -frame geometry surround image with an ornamental border\n"
110 " -layers method optimize, merge, or compare image layers\n"
111 " -monochrome transform image to black and white\n"
112 " -polaroid angle simulate a Polaroid picture\n"
113 " -repage geometry size and location of an image canvas (operator)\n"
114 " -resize geometry resize the image\n"
115 " -rotate degrees apply Paeth rotation to the image\n"
116 " -scale geometry scale the image\n"
117 " -strip strip image of all profiles and comments\n"
118 " -transform affine transform image\n"
119 " -transpose flip image vertically and rotate 90 degrees\n"
120 " -transparent color make this color transparent within the image\n"
121 " -type type image type\n"
122 " -unsharp geometry sharpen the image",
124 " -adjoin join images into a single multi-image file\n"
125 " -affine matrix affine transform matrix\n"
126 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
127 " transparent, extract, background, or shape\n"
128 " -authenticate password\n"
129 " decipher image with this password\n"
130 " -blue-primary point chromaticity blue primary point\n"
131 " -bordercolor color border color\n"
132 " -caption string assign a caption to an image\n"
133 " -colors value preferred number of colors in the image\n"
134 " -colorspace type alternate image colorspace\n"
135 " -comment string annotate image with comment\n"
136 " -compose operator composite operator\n"
137 " -compress type type of pixel compression when writing the image\n"
138 " -define format:option\n"
139 " define one or more image format options\n"
140 " -delay value display the next image after pausing\n"
141 " -density geometry horizontal and vertical density of the image\n"
142 " -depth value image depth\n"
143 " -display server query font from this X server\n"
144 " -dispose method layer disposal method\n"
145 " -dither method apply error diffusion to image\n"
146 " -draw string annotate the image with a graphic primitive\n"
147 " -encoding type text encoding type\n"
148 " -endian type endianness (MSB or LSB) of the image\n"
149 " -extract geometry extract area from image\n"
150 " -family name render text with this font family\n"
151 " -fill color color to use when filling a graphic primitive\n"
152 " -filter type use this filter when resizing an image\n"
153 " -font name render text with this font\n"
154 " -format \"string\" output formatted image characteristics\n"
155 " -gamma value level of gamma correction\n"
156 " -geometry geometry preferred tile and border sizes\n"
157 " -gravity direction which direction to gravitate towards\n"
158 " -green-primary point chromaticity green primary point\n"
159 " -identify identify the format and characteristics of the image\n"
160 " -interlace type type of image interlacing scheme\n"
161 " -interpolate method pixel color interpolation method\n"
162 " -kerning value set the space between two letters\n"
163 " -label string assign a label to an image\n"
164 " -limit type value pixel cache resource limit\n"
165 " -matte store matte channel if the image has one\n"
166 " -mattecolor color frame color\n"
167 " -mode type framing style\n"
168 " -monitor monitor progress\n"
169 " -page geometry size and location of an image canvas (setting)\n"
170 " -pointsize value font point size\n"
171 " -profile filename add, delete, or apply an image profile\n"
172 " -quality value JPEG/MIFF/PNG compression level\n"
173 " -quantize colorspace reduce colors in this colorspace\n"
174 " -quiet suppress all warning messages\n"
175 " -red-primary point chromaticity red primary point\n"
176 " -regard-warnings pay attention to warning messages\n"
177 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
178 " -sampling-factor geometry\n"
179 " horizontal and vertical sampling factor\n"
180 " -scenes range image scene range\n"
181 " -seed value seed a new sequence of pseudo-random numbers\n"
182 " -set attribute value set an image attribute\n"
183 " -shadow add a shadow beneath a tile to simulate depth\n"
184 " -size geometry width and height of image\n"
185 " -stroke color color to use when stroking a graphic primitive\n"
186 " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
187 " -synchronize synchronize image to storage device\n"
188 " -taint declare the image as modified\n"
189 " -texture filename name of texture to tile onto the image background\n"
190 " -thumbnail geometry create a thumbnail of the image\n"
191 " -tile geometry number of tiles per row and column\n"
192 " -title string decorate the montage image with a title\n"
193 " -transparent-color color\n"
194 " transparent color\n"
195 " -treedepth value color tree depth\n"
196 " -trim trim image edges\n"
197 " -units type the units of image resolution\n"
198 " -verbose print detailed information about the image\n"
199 " -virtual-pixel method\n"
200 " virtual pixel access method\n"
201 " -white-point point chromaticity white point",
202 sequence_operators[] =
203 " -coalesce merge a sequence of images\n"
204 " -composite composite image",
206 " -clone indexes clone an image\n"
207 " -delete indexes delete the image from the image sequence\n"
208 " -duplicate count,indexes\n"
209 " duplicate an image one or more times\n"
210 " -insert index insert last image into the image sequence\n"
211 " -reverse reverse image sequence\n"
212 " -swap indexes swap two images in the image sequence";
214 ListMagickVersion(stdout);
215 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...] file\n",
217 (void) printf(
"\nImage Settings:\n");
218 (void) puts(settings);
219 (void) printf(
"\nImage Operators:\n");
220 (void) puts(operators);
221 (void) printf(
"\nImage Sequence Operators:\n");
222 (void) puts(sequence_operators);
223 (void) printf(
"\nImage Stack Operators:\n");
224 (void) puts(stack_operators);
225 (void) printf(
"\nMiscellaneous Options:\n");
226 (void) puts(miscellaneous);
228 "\nIn addition to those listed above, you can specify these standard X\n");
230 "resources as command line options: -background, -bordercolor,\n");
232 "-mattecolor, -borderwidth, -font, or -title\n");
234 "\nBy default, the image format of 'file' is determined by its magic\n");
236 "number. To specify a particular image format, precede the filename\n");
238 "with an image format name and a colon (i.e. ps:image) or specify the\n");
240 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
241 (void) printf(
"'-' for standard input or output.\n");
245WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
246 int argc,
char **argv,
char **metadata,ExceptionInfo *exception)
248#define DestroyMontage() \
250 if (montage_image != (Image *) NULL) \
251 montage_image=DestroyImageList(montage_image); \
252 if (montage_info != (MontageInfo *) NULL) \
253 montage_info=DestroyMontageInfo(montage_info); \
254 DestroyImageStack(); \
255 for (i=0; i < (ssize_t) argc; i++) \
256 argv[i]=DestroyString(argv[i]); \
257 argv=(char **) RelinquishMagickMemory(argv); \
259#define ThrowMontageException(asperity,tag,option) \
261 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
264 return(MagickFalse); \
266#define ThrowMontageInvalidArgumentException(option,argument) \
268 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
269 "InvalidArgument","'%s': %s",option,argument); \
271 return(MagickFalse); \
282 *image = (Image *) NULL,
286 image_stack[MaxImageStackDepth+1];
314 assert(image_info != (ImageInfo *) NULL);
315 assert(image_info->signature == MagickCoreSignature);
316 assert(exception != (ExceptionInfo *) NULL);
317 if (IsEventLogging() != MagickFalse)
318 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
322 if ((LocaleCompare(
"help",option+1) == 0) ||
323 (LocaleCompare(
"-help",option+1) == 0))
324 return(MontageUsage());
325 if ((LocaleCompare(
"version",option+1) == 0) ||
326 (LocaleCompare(
"-version",option+1) == 0))
328 ListMagickVersion(stdout);
334 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
335 "MissingArgument",
"%s",
"");
336 (void) MontageUsage();
344 montage_image=NewImageList();
345 montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
347 option=(
char *) NULL;
349 respect_parentheses=MagickFalse;
352 transparent_color=(
char *) NULL;
356 ReadCommandlLine(argc,&argv);
357 status=ExpandFilenames(&argc,&argv);
358 if (status == MagickFalse)
359 ThrowMontageException(ResourceLimitError,
"MemoryAllocationFailed",
360 GetExceptionMessage(errno));
361 for (i=1; i < (ssize_t) (argc-1); i++)
364 if (LocaleCompare(option,
"(") == 0)
366 FireImageStack(MagickTrue,MagickTrue,pend);
367 if (k == MaxImageStackDepth)
368 ThrowMontageException(OptionError,
"ParenthesisNestedTooDeeply",
373 if (LocaleCompare(option,
")") == 0)
375 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
377 ThrowMontageException(OptionError,
"UnableToParseExpression",option);
381 if (IsCommandOption(option) == MagickFalse)
386 FireImageStack(MagickFalse,MagickFalse,pend);
387 for (scene=(ssize_t) first_scene; scene <= (ssize_t) last_scene ; scene++)
396 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
398 (void) CloneString(&image_info->font,montage_info->font);
399 if (first_scene == last_scene)
400 images=ReadImages(image_info,filename,exception);
404 scene_filename[MagickPathExtent];
409 (void) InterpretImageFilename(image_info,(Image *) NULL,
410 image_info->filename,(
int) scene,scene_filename,exception);
411 if (LocaleCompare(filename,image_info->filename) == 0)
412 (void) FormatLocaleString(scene_filename,MagickPathExtent,
413 "%s.%.20g",image_info->filename,(
double) scene);
414 images=ReadImages(image_info,scene_filename,exception);
416 status&=(MagickStatusType) (images != (Image *) NULL) &&
417 (exception->severity < ErrorException);
418 if (images == (Image *) NULL)
420 AppendImageStack(images);
424 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
429 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
432 if (i == (ssize_t) argc)
433 ThrowMontageException(OptionError,
"MissingArgument",option);
434 if (IsGeometry(argv[i]) == MagickFalse)
435 ThrowMontageInvalidArgumentException(option,argv[i]);
438 if (LocaleCompare(
"adjoin",option+1) == 0)
440 if (LocaleCompare(
"affine",option+1) == 0)
445 if (i == (ssize_t) argc)
446 ThrowMontageException(OptionError,
"MissingArgument",option);
447 if (IsGeometry(argv[i]) == MagickFalse)
448 ThrowMontageInvalidArgumentException(option,argv[i]);
451 if (LocaleCompare(
"alpha",option+1) == 0)
459 if (i == (ssize_t) argc)
460 ThrowMontageException(OptionError,
"MissingArgument",option);
461 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
464 ThrowMontageException(OptionError,
465 "UnrecognizedAlphaChannelOption",argv[i]);
468 if (LocaleCompare(
"annotate",option+1) == 0)
473 if (i == (ssize_t) argc)
474 ThrowMontageException(OptionError,
"MissingArgument",option);
475 if (IsGeometry(argv[i]) == MagickFalse)
476 ThrowMontageInvalidArgumentException(option,argv[i]);
477 if (i == (ssize_t) argc)
478 ThrowMontageException(OptionError,
"MissingArgument",option);
482 if (LocaleCompare(
"auto-orient",option+1) == 0)
484 if (LocaleCompare(
"authenticate",option+1) == 0)
489 if (i == (ssize_t) argc)
490 ThrowMontageException(OptionError,
"MissingArgument",option);
493 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
497 if (LocaleCompare(
"background",option+1) == 0)
502 if (i == (ssize_t) argc)
503 ThrowMontageException(OptionError,
"MissingArgument",option);
504 (void) QueryColorCompliance(argv[i],AllCompliance,
505 &montage_info->background_color,exception);
508 if (LocaleCompare(
"blue-primary",option+1) == 0)
513 if (i == (ssize_t) argc)
514 ThrowMontageException(OptionError,
"MissingArgument",option);
515 if (IsGeometry(argv[i]) == MagickFalse)
516 ThrowMontageInvalidArgumentException(option,argv[i]);
519 if (LocaleCompare(
"blur",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(
"border",option+1) == 0)
534 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
535 montage_info->border_width=0;
540 if (i == (ssize_t) argc)
541 ThrowMontageException(OptionError,
"MissingArgument",option);
542 if (IsGeometry(argv[i]) == MagickFalse)
543 ThrowMontageInvalidArgumentException(option,argv[i]);
545 montage_info->border_width=StringToUnsignedLong(argv[i]);
548 if (LocaleCompare(
"bordercolor",option+1) == 0)
553 if (i == (ssize_t) argc)
554 ThrowMontageException(OptionError,
"MissingArgument",option);
555 (void) QueryColorCompliance(argv[i],AllCompliance,
556 &montage_info->border_color,exception);
559 if (LocaleCompare(
"borderwidth",option+1) == 0)
561 montage_info->border_width=0;
565 if (i == (ssize_t) argc)
566 ThrowMontageException(OptionError,
"MissingArgument",option);
567 if (IsGeometry(argv[i]) == MagickFalse)
568 ThrowMontageInvalidArgumentException(option,argv[i]);
569 montage_info->border_width=StringToUnsignedLong(argv[i]);
572 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
576 if (LocaleCompare(
"cache",option+1) == 0)
581 if (i == (ssize_t) argc)
582 ThrowMontageException(OptionError,
"MissingArgument",option);
583 if (IsGeometry(argv[i]) == MagickFalse)
584 ThrowMontageInvalidArgumentException(option,argv[i]);
587 if (LocaleCompare(
"caption",option+1) == 0)
592 if (i == (ssize_t) argc)
593 ThrowMontageException(OptionError,
"MissingArgument",option);
596 if (LocaleCompare(
"channel",option+1) == 0)
604 if (i == (ssize_t) argc)
605 ThrowMontageException(OptionError,
"MissingArgument",option);
606 channel=ParseChannelOption(argv[i]);
608 ThrowMontageException(OptionError,
"UnrecognizedChannelType",
612 if (LocaleCompare(
"clone",option+1) == 0)
618 clone_list=CloneImageList(image,exception);
620 clone_list=CloneImageList(image_stack[k-1].image,exception);
621 if (clone_list == (Image *) NULL)
622 ThrowMontageException(ImageError,
"ImageSequenceRequired",option);
623 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
625 clone_images=CloneImages(clone_list,
"-1",exception);
629 if (i == (ssize_t) argc)
630 ThrowMontageException(OptionError,
"MissingArgument",option);
631 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
632 ThrowMontageInvalidArgumentException(option,argv[i]);
633 clone_images=CloneImages(clone_list,argv[i],exception);
635 if (clone_images == (Image *) NULL)
636 ThrowMontageException(OptionError,
"NoSuchImage",option);
637 AppendImageStack(clone_images);
638 clone_list=DestroyImageList(clone_list);
641 if (LocaleCompare(
"coalesce",option+1) == 0)
643 if (LocaleCompare(
"colors",option+1) == 0)
648 if (i == (ssize_t) argc)
649 ThrowMontageException(OptionError,
"MissingArgument",option);
650 if (IsGeometry(argv[i]) == MagickFalse)
651 ThrowMontageInvalidArgumentException(option,argv[i]);
654 if (LocaleCompare(
"colorspace",option+1) == 0)
662 if (i == (ssize_t) argc)
663 ThrowMontageException(OptionError,
"MissingArgument",option);
664 colorspace=ParseCommandOption(MagickColorspaceOptions,
665 MagickFalse,argv[i]);
667 ThrowMontageException(OptionError,
"UnrecognizedColorspace",
671 if (LocaleCompare(
"comment",option+1) == 0)
676 if (i == (ssize_t) argc)
677 ThrowMontageException(OptionError,
"MissingArgument",option);
680 if (LocaleCompare(
"compose",option+1) == 0)
688 if (i == (ssize_t) argc)
689 ThrowMontageException(OptionError,
"MissingArgument",option);
690 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,argv[i]);
692 ThrowMontageException(OptionError,
"UnrecognizedComposeOperator",
696 if (LocaleCompare(
"composite",option+1) == 0)
698 if (LocaleCompare(
"compress",option+1) == 0)
706 if (i == (ssize_t) argc)
707 ThrowMontageException(OptionError,
"MissingArgument",option);
708 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
711 ThrowMontageException(OptionError,
"UnrecognizedCompressType",
715 if (LocaleCompare(
"concurrent",option+1) == 0)
717 if (LocaleCompare(
"crop",option+1) == 0)
722 if (i == (ssize_t) argc)
723 ThrowMontageException(OptionError,
"MissingArgument",option);
724 if (IsGeometry(argv[i]) == MagickFalse)
725 ThrowMontageInvalidArgumentException(option,argv[i]);
728 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
732 if (LocaleCompare(
"debug",option+1) == 0)
740 if (i == (ssize_t) argc)
741 ThrowMontageException(OptionError,
"MissingArgument",option);
742 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
744 ThrowMontageException(OptionError,
"UnrecognizedEventType",
746 (void) SetLogEventMask(argv[i]);
749 if (LocaleCompare(
"define",option+1) == 0)
752 if (i == (ssize_t) argc)
753 ThrowMontageException(OptionError,
"MissingArgument",option);
759 define=GetImageOption(image_info,argv[i]);
760 if (define == (
const char *) NULL)
761 ThrowMontageException(OptionError,
"NoSuchOption",argv[i]);
766 if (LocaleCompare(
"delay",option+1) == 0)
771 if (i == (ssize_t) argc)
772 ThrowMontageException(OptionError,
"MissingArgument",option);
773 if (IsGeometry(argv[i]) == MagickFalse)
774 ThrowMontageInvalidArgumentException(option,argv[i]);
777 if (LocaleCompare(
"delete",option+1) == 0)
782 if (i == (ssize_t) argc)
783 ThrowMontageException(OptionError,
"MissingArgument",option);
784 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
785 ThrowMontageInvalidArgumentException(option,argv[i]);
788 if (LocaleCompare(
"density",option+1) == 0)
793 if (i == (ssize_t) argc)
794 ThrowMontageException(OptionError,
"MissingArgument",option);
795 if (IsGeometry(argv[i]) == MagickFalse)
796 ThrowMontageInvalidArgumentException(option,argv[i]);
799 if (LocaleCompare(
"depth",option+1) == 0)
804 if (i == (ssize_t) argc)
805 ThrowMontageException(OptionError,
"MissingArgument",option);
806 if (IsGeometry(argv[i]) == MagickFalse)
807 ThrowMontageInvalidArgumentException(option,argv[i]);
810 if (LocaleCompare(
"display",option+1) == 0)
815 if (i == (ssize_t) argc)
816 ThrowMontageException(OptionError,
"MissingArgument",option);
819 if (LocaleCompare(
"dispose",option+1) == 0)
827 if (i == (ssize_t) argc)
828 ThrowMontageException(OptionError,
"MissingArgument",option);
829 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
832 ThrowMontageException(OptionError,
"UnrecognizedDisposeMethod",
836 if (LocaleCompare(
"distort",option+1) == 0)
842 if (i == (ssize_t) argc)
843 ThrowMontageException(OptionError,
"MissingArgument",option);
844 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
846 ThrowMontageException(OptionError,
"UnrecognizedDistortMethod",
849 if (i == (ssize_t) argc)
850 ThrowMontageException(OptionError,
"MissingArgument",option);
853 if (LocaleCompare(
"dither",option+1) == 0)
861 if (i == (ssize_t) argc)
862 ThrowMontageException(OptionError,
"MissingArgument",option);
863 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
865 ThrowMontageException(OptionError,
"UnrecognizedDitherMethod",
869 if (LocaleCompare(
"draw",option+1) == 0)
874 if (i == (ssize_t) argc)
875 ThrowMontageException(OptionError,
"MissingArgument",option);
878 if (LocaleCompare(
"duplicate",option+1) == 0)
883 if (i == (ssize_t) argc)
884 ThrowMontageException(OptionError,
"MissingArgument",option);
885 if (IsGeometry(argv[i]) == MagickFalse)
886 ThrowMontageInvalidArgumentException(option,argv[i]);
889 if (LocaleCompare(
"duration",option+1) == 0)
894 if (i == (ssize_t) argc)
895 ThrowMontageException(OptionError,
"MissingArgument",option);
896 if (IsGeometry(argv[i]) == MagickFalse)
897 ThrowMontageInvalidArgumentException(option,argv[i]);
900 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
904 if (LocaleCompare(
"encoding",option+1) == 0)
909 if (i == (ssize_t) argc)
910 ThrowMontageException(OptionError,
"MissingArgument",option);
913 if (LocaleCompare(
"endian",option+1) == 0)
921 if (i == (ssize_t) argc)
922 ThrowMontageException(OptionError,
"MissingArgument",option);
923 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
926 ThrowMontageException(OptionError,
"UnrecognizedEndianType",
930 if (LocaleCompare(
"extent",option+1) == 0)
935 if (i == (ssize_t) argc)
936 ThrowMontageException(OptionError,
"MissingArgument",option);
937 if (IsGeometry(argv[i]) == MagickFalse)
938 ThrowMontageInvalidArgumentException(option,argv[i]);
941 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
945 if (LocaleCompare(
"family",option+1) == 0)
950 if (i == (ssize_t) argc)
951 ThrowMontageException(OptionError,
"MissingArgument",option);
954 if (LocaleCompare(
"fill",option+1) == 0)
956 (void) QueryColorCompliance(
"none",AllCompliance,
957 &montage_info->fill,exception);
961 if (i == (ssize_t) argc)
962 ThrowMontageException(OptionError,
"MissingArgument",option);
963 (void) QueryColorCompliance(argv[i],AllCompliance,
964 &montage_info->fill,exception);
967 if (LocaleCompare(
"filter",option+1) == 0)
975 if (i == (ssize_t) argc)
976 ThrowMontageException(OptionError,
"MissingArgument",option);
977 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
979 ThrowMontageException(OptionError,
"UnrecognizedImageFilter",
983 if (LocaleCompare(
"flatten",option+1) == 0)
985 if (LocaleCompare(
"flip",option+1) == 0)
987 if (LocaleCompare(
"flop",option+1) == 0)
989 if (LocaleCompare(
"font",option+1) == 0)
994 if (i == (ssize_t) argc)
995 ThrowMontageException(OptionError,
"MissingArgument",option);
996 (void) CloneString(&montage_info->font,argv[i]);
999 if (LocaleCompare(
"format",option+1) == 0)
1004 if (i == (ssize_t) argc)
1005 ThrowMontageException(OptionError,
"MissingArgument",option);
1009 if (LocaleCompare(
"frame",option+1) == 0)
1013 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
1014 (void) CloneString(&montage_info->frame,(
char *) NULL);
1019 if (i == (ssize_t) argc)
1020 ThrowMontageException(OptionError,
"MissingArgument",option);
1021 if (IsGeometry(argv[i]) == MagickFalse)
1022 ThrowMontageInvalidArgumentException(option,argv[i]);
1024 (void) CloneString(&montage_info->frame,argv[i]);
1027 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1031 if (LocaleCompare(
"gamma",option+1) == 0)
1034 if (i == (ssize_t) argc)
1035 ThrowMontageException(OptionError,
"MissingArgument",option);
1036 if (IsGeometry(argv[i]) == MagickFalse)
1037 ThrowMontageInvalidArgumentException(option,argv[i]);
1040 if (LocaleCompare(
"geometry",option+1) == 0)
1042 (void) CloneString(&montage_info->geometry,(
char *) NULL);
1046 if (i == (ssize_t) argc)
1047 ThrowMontageException(OptionError,
"MissingArgument",option);
1048 if (IsGeometry(argv[i]) == MagickFalse)
1049 ThrowMontageInvalidArgumentException(option,argv[i]);
1050 (void) CloneString(&montage_info->geometry,argv[i]);
1053 if (LocaleCompare(
"gravity",option+1) == 0)
1058 montage_info->gravity=UndefinedGravity;
1062 if (i == (ssize_t) argc)
1063 ThrowMontageException(OptionError,
"MissingArgument",option);
1064 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1067 ThrowMontageException(OptionError,
"UnrecognizedGravityType",
1069 montage_info->gravity=(GravityType) gravity;
1072 if (LocaleCompare(
"green-primary",option+1) == 0)
1077 if (i == (ssize_t) argc)
1078 ThrowMontageException(OptionError,
"MissingArgument",option);
1079 if (IsGeometry(argv[i]) == MagickFalse)
1080 ThrowMontageInvalidArgumentException(option,argv[i]);
1083 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1087 if ((LocaleCompare(
"help",option+1) == 0) ||
1088 (LocaleCompare(
"-help",option+1) == 0))
1091 return(MontageUsage());
1093 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1097 if (LocaleCompare(
"identify",option+1) == 0)
1099 if (LocaleCompare(
"insert",option+1) == 0)
1104 if (i == (ssize_t) argc)
1105 ThrowMontageException(OptionError,
"MissingArgument",option);
1106 if (IsGeometry(argv[i]) == MagickFalse)
1107 ThrowMontageInvalidArgumentException(option,argv[i]);
1110 if (LocaleCompare(
"interlace",option+1) == 0)
1118 if (i == (ssize_t) argc)
1119 ThrowMontageException(OptionError,
"MissingArgument",option);
1120 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1123 ThrowMontageException(OptionError,
"UnrecognizedInterlaceType",
1127 if (LocaleCompare(
"interpolate",option+1) == 0)
1135 if (i == (ssize_t) argc)
1136 ThrowMontageException(OptionError,
"MissingArgument",option);
1137 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1139 if (interpolate < 0)
1140 ThrowMontageException(OptionError,
"UnrecognizedInterpolateMethod",
1144 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1148 if (LocaleCompare(
"kerning",option+1) == 0)
1153 if (i == (ssize_t) argc)
1154 ThrowMontageException(OptionError,
"MissingArgument",option);
1155 if (IsGeometry(argv[i]) == MagickFalse)
1156 ThrowMontageInvalidArgumentException(option,argv[i]);
1159 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1163 if (LocaleCompare(
"label",option+1) == 0)
1168 if (i == (ssize_t) argc)
1169 ThrowMontageException(OptionError,
"MissingArgument",option);
1172 if (LocaleCompare(
"layers",option+1) == 0)
1180 if (i == (ssize_t) argc)
1181 ThrowMontageException(OptionError,
"MissingArgument",option);
1182 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
1184 ThrowMontageException(OptionError,
"UnrecognizedLayerMethod",
1188 if (LocaleCompare(
"limit",option+1) == 0)
1202 if (i == (ssize_t) argc)
1203 ThrowMontageException(OptionError,
"MissingArgument",option);
1204 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1207 ThrowMontageException(OptionError,
"UnrecognizedResourceType",
1210 if (i == (ssize_t) argc)
1211 ThrowMontageException(OptionError,
"MissingArgument",option);
1212 value=StringToDouble(argv[i],&p);
1214 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
1215 ThrowMontageInvalidArgumentException(option,argv[i]);
1218 if (LocaleCompare(
"list",option+1) == 0)
1226 if (i == (ssize_t) argc)
1227 ThrowMontageException(OptionError,
"MissingArgument",option);
1228 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1230 ThrowMontageException(OptionError,
"UnrecognizedListType",argv[i]);
1231 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
1234 return(status == 0 ? MagickFalse : MagickTrue);
1236 if (LocaleCompare(
"log",option+1) == 0)
1241 if ((i == (ssize_t) argc) ||
1242 (strchr(argv[i],
'%') == (
char *) NULL))
1243 ThrowMontageException(OptionError,
"MissingArgument",option);
1246 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1250 if (LocaleCompare(
"matte",option+1) == 0)
1252 if (LocaleCompare(
"mattecolor",option+1) == 0)
1257 if (i == (ssize_t) argc)
1258 ThrowMontageException(OptionError,
"MissingArgument",option);
1259 (void) QueryColorCompliance(argv[i],AllCompliance,
1260 &montage_info->matte_color,exception);
1263 if (LocaleCompare(
"mode",option+1) == 0)
1268 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
1272 if (i == (ssize_t) argc)
1273 ThrowMontageException(OptionError,
"MissingArgument",option);
1275 if (LocaleCompare(
"frame",argv[i]) == 0)
1278 (void) CloneString(&montage_info->frame,
"15x15+3+3");
1279 montage_info->shadow=MagickTrue;
1282 if (LocaleCompare(
"unframe",argv[i]) == 0)
1285 montage_info->frame=(
char *) NULL;
1286 montage_info->shadow=MagickFalse;
1287 montage_info->border_width=0;
1290 if (LocaleCompare(
"concatenate",argv[i]) == 0)
1292 mode=ConcatenateMode;
1293 montage_info->frame=(
char *) NULL;
1294 montage_info->shadow=MagickFalse;
1295 montage_info->gravity=(GravityType) NorthWestGravity;
1296 (void) CloneString(&montage_info->geometry,
"+0+0");
1297 montage_info->border_width=0;
1300 if (mode == UndefinedMode)
1301 ThrowMontageException(OptionError,
"UnrecognizedImageMode",
1305 if (LocaleCompare(
"monitor",option+1) == 0)
1307 if (LocaleCompare(
"monochrome",option+1) == 0)
1309 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1313 if (LocaleCompare(
"noop",option+1) == 0)
1315 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1319 if (LocaleCompare(
"page",option+1) == 0)
1324 if (i == (ssize_t) argc)
1325 ThrowMontageException(OptionError,
"MissingArgument",option);
1328 if (LocaleCompare(
"pointsize",option+1) == 0)
1330 montage_info->pointsize=12;
1334 if (i == (ssize_t) argc)
1335 ThrowMontageException(OptionError,
"MissingArgument",option);
1336 if (IsGeometry(argv[i]) == MagickFalse)
1337 ThrowMontageInvalidArgumentException(option,argv[i]);
1338 montage_info->pointsize=StringToDouble(argv[i],(
char **) NULL);
1341 if (LocaleCompare(
"polaroid",option+1) == 0)
1346 if (i == (ssize_t) argc)
1347 ThrowMontageException(OptionError,
"MissingArgument",option);
1348 if (IsGeometry(argv[i]) == MagickFalse)
1349 ThrowMontageInvalidArgumentException(option,argv[i]);
1352 if (LocaleCompare(
"profile",option+1) == 0)
1355 if (i == (ssize_t) argc)
1356 ThrowMontageException(OptionError,
"MissingArgument",option);
1359 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1363 if (LocaleCompare(
"quality",option+1) == 0)
1368 if (i == (ssize_t) argc)
1369 ThrowMontageException(OptionError,
"MissingArgument",option);
1370 if (IsGeometry(argv[i]) == MagickFalse)
1371 ThrowMontageInvalidArgumentException(option,argv[i]);
1374 if (LocaleCompare(
"quantize",option+1) == 0)
1382 if (i == (ssize_t) argc)
1383 ThrowMontageException(OptionError,
"MissingArgument",option);
1384 colorspace=ParseCommandOption(MagickColorspaceOptions,
1385 MagickFalse,argv[i]);
1387 ThrowMontageException(OptionError,
"UnrecognizedColorspace",
1391 if (LocaleCompare(
"quiet",option+1) == 0)
1393 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1397 if (LocaleCompare(
"red-primary",option+1) == 0)
1402 if (i == (ssize_t) argc)
1403 ThrowMontageException(OptionError,
"MissingArgument",option);
1404 if (IsGeometry(argv[i]) == MagickFalse)
1405 ThrowMontageInvalidArgumentException(option,argv[i]);
1408 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1410 if (LocaleCompare(
"render",option+1) == 0)
1412 if (LocaleCompare(
"repage",option+1) == 0)
1417 if (i == (ssize_t) argc)
1418 ThrowMontageException(OptionError,
"MissingArgument",option);
1419 if (IsGeometry(argv[i]) == MagickFalse)
1420 ThrowMontageInvalidArgumentException(option,argv[i]);
1423 if (LocaleCompare(
"resize",option+1) == 0)
1428 if (i == (ssize_t) argc)
1429 ThrowMontageException(OptionError,
"MissingArgument",option);
1430 if (IsGeometry(argv[i]) == MagickFalse)
1431 ThrowMontageInvalidArgumentException(option,argv[i]);
1434 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
1436 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
1439 if (LocaleCompare(
"reverse",option+1) == 0)
1441 if (LocaleCompare(
"rotate",option+1) == 0)
1444 if (i == (ssize_t) argc)
1445 ThrowMontageException(OptionError,
"MissingArgument",option);
1446 if (IsGeometry(argv[i]) == MagickFalse)
1447 ThrowMontageInvalidArgumentException(option,argv[i]);
1450 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1454 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1459 if (i == (ssize_t) argc)
1460 ThrowMontageException(OptionError,
"MissingArgument",option);
1461 if (IsGeometry(argv[i]) == MagickFalse)
1462 ThrowMontageInvalidArgumentException(option,argv[i]);
1465 if (LocaleCompare(
"scale",option+1) == 0)
1470 if (i == (ssize_t) argc)
1471 ThrowMontageException(OptionError,
"MissingArgument",option);
1472 if (IsGeometry(argv[i]) == MagickFalse)
1473 ThrowMontageInvalidArgumentException(option,argv[i]);
1476 if (LocaleCompare(
"scenes",option+1) == 0)
1483 if (i == (ssize_t) argc)
1484 ThrowMontageException(OptionError,
"MissingArgument",option);
1485 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1486 ThrowMontageInvalidArgumentException(option,argv[i]);
1487 first_scene=StringToLong(argv[i]);
1488 last_scene=first_scene;
1489 (void) sscanf(argv[i],
"%ld-%ld",&first_scene,&last_scene);
1492 if (LocaleCompare(
"seed",option+1) == 0)
1497 if (i == (ssize_t) argc)
1498 ThrowMontageException(OptionError,
"MissingArgument",option);
1499 if (IsGeometry(argv[i]) == MagickFalse)
1500 ThrowMontageInvalidArgumentException(option,argv[i]);
1503 if (LocaleCompare(
"set",option+1) == 0)
1506 if (i == (ssize_t) argc)
1507 ThrowMontageException(OptionError,
"MissingArgument",option);
1511 if (i == (ssize_t) argc)
1512 ThrowMontageException(OptionError,
"MissingArgument",option);
1515 if (LocaleCompare(
"shadow",option+1) == 0)
1519 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
1520 montage_info->shadow=(*option ==
'-') ? MagickTrue :
1527 if (i == (ssize_t) argc)
1528 ThrowMontageException(OptionError,
"MissingArgument",option);
1529 if (IsGeometry(argv[i]) == MagickFalse)
1530 ThrowMontageInvalidArgumentException(option,argv[i]);
1533 if (LocaleCompare(
"sharpen",option+1) == 0)
1538 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
1539 ThrowMontageException(OptionError,
"MissingArgument",option);
1542 if (LocaleCompare(
"size",option+1) == 0)
1547 if (i == (ssize_t) argc)
1548 ThrowMontageException(OptionError,
"MissingArgument",option);
1549 if (IsGeometry(argv[i]) == MagickFalse)
1550 ThrowMontageInvalidArgumentException(option,argv[i]);
1553 if (LocaleCompare(
"stroke",option+1) == 0)
1555 (void) QueryColorCompliance(
"none",AllCompliance,
1556 &montage_info->stroke,exception);
1560 if (i == (ssize_t) argc)
1561 ThrowMontageException(OptionError,
"MissingArgument",option);
1562 (void) QueryColorCompliance(argv[i],AllCompliance,
1563 &montage_info->stroke,exception);
1566 if (LocaleCompare(
"strip",option+1) == 0)
1568 if (LocaleCompare(
"strokewidth",option+1) == 0)
1573 if (i == (ssize_t) argc)
1574 ThrowMontageException(OptionError,
"MissingArgument",option);
1575 if (IsGeometry(argv[i]) == MagickFalse)
1576 ThrowMontageInvalidArgumentException(option,argv[i]);
1579 if (LocaleCompare(
"support",option+1) == 0)
1584 if (LocaleCompare(
"swap",option+1) == 0)
1589 if (i == (ssize_t) argc)
1590 ThrowMontageException(OptionError,
"MissingArgument",option);
1591 if (IsGeometry(argv[i]) == MagickFalse)
1592 ThrowMontageInvalidArgumentException(option,argv[i]);
1595 if (LocaleCompare(
"synchronize",option+1) == 0)
1597 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1601 if (LocaleCompare(
"taint",option+1) == 0)
1603 if (LocaleCompare(
"texture",option+1) == 0)
1605 (void) CloneString(&montage_info->texture,(
char *) NULL);
1609 if (i == (ssize_t) argc)
1610 ThrowMontageException(OptionError,
"MissingArgument",option);
1611 (void) CloneString(&montage_info->texture,argv[i]);
1614 if (LocaleCompare(
"thumbnail",option+1) == 0)
1619 if (i == (ssize_t) argc)
1620 ThrowMontageException(OptionError,
"MissingArgument",option);
1621 if (IsGeometry(argv[i]) == MagickFalse)
1622 ThrowMontageInvalidArgumentException(option,argv[i]);
1625 if (LocaleCompare(
"tile",option+1) == 0)
1629 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
1630 (void) CloneString(&montage_info->tile,(
char *) NULL);
1635 if (i == (ssize_t) argc)
1636 ThrowMontageException(OptionError,
"MissingArgument",option);
1637 if (IsGeometry(argv[i]) == MagickFalse)
1638 ThrowMontageInvalidArgumentException(option,argv[i]);
1640 (void) CloneString(&montage_info->tile,argv[i]);
1643 if (LocaleCompare(
"tile-offset",option+1) == 0)
1648 if (i == (ssize_t) argc)
1649 ThrowMontageException(OptionError,
"MissingArgument",option);
1650 if (IsGeometry(argv[i]) == MagickFalse)
1651 ThrowMontageInvalidArgumentException(option,argv[i]);
1654 if (LocaleCompare(
"tint",option+1) == 0)
1659 if (i == (ssize_t) argc)
1660 ThrowMontageException(OptionError,
"MissingArgument",option);
1661 if (IsGeometry(argv[i]) == MagickFalse)
1662 ThrowMontageInvalidArgumentException(option,argv[i]);
1665 if (LocaleCompare(
"transform",option+1) == 0)
1667 if (LocaleCompare(
"transpose",option+1) == 0)
1669 if (LocaleCompare(
"title",option+1) == 0)
1671 (void) CloneString(&montage_info->title,(
char *) NULL);
1675 if (i == (ssize_t) argc)
1676 ThrowMontageException(OptionError,
"MissingArgument",option);
1677 (void) CloneString(&montage_info->title,argv[i]);
1680 if (LocaleCompare(
"transform",option+1) == 0)
1682 if (LocaleCompare(
"transparent",option+1) == 0)
1684 transparent_color=(
char *) NULL;
1686 if (i == (ssize_t) argc)
1687 ThrowMontageException(OptionError,
"MissingArgument",option);
1688 (void) CloneString(&transparent_color,argv[i]);
1691 if (LocaleCompare(
"transparent-color",option+1) == 0)
1696 if (i == (ssize_t) argc)
1697 ThrowMontageException(OptionError,
"MissingArgument",option);
1700 if (LocaleCompare(
"treedepth",option+1) == 0)
1705 if (i == (ssize_t) argc)
1706 ThrowMontageException(OptionError,
"MissingArgument",option);
1707 if (IsGeometry(argv[i]) == MagickFalse)
1708 ThrowMontageInvalidArgumentException(option,argv[i]);
1711 if (LocaleCompare(
"trim",option+1) == 0)
1713 if (LocaleCompare(
"type",option+1) == 0)
1721 if (i == (ssize_t) argc)
1722 ThrowMontageException(OptionError,
"MissingArgument",option);
1723 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1725 ThrowMontageException(OptionError,
"UnrecognizedImageType",
1729 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1733 if (LocaleCompare(
"units",option+1) == 0)
1741 if (i == (ssize_t) argc)
1742 ThrowMontageException(OptionError,
"MissingArgument",option);
1743 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1746 ThrowMontageException(OptionError,
"UnrecognizedUnitsType",
1750 if (LocaleCompare(
"unsharp",option+1) == 0)
1755 if (i == (ssize_t) argc)
1756 ThrowMontageException(OptionError,
"MissingArgument",option);
1757 if (IsGeometry(argv[i]) == MagickFalse)
1758 ThrowMontageInvalidArgumentException(option,argv[i]);
1761 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1765 if (LocaleCompare(
"verbose",option+1) == 0)
1769 if ((LocaleCompare(
"version",option+1) == 0) ||
1770 (LocaleCompare(
"-version",option+1) == 0))
1772 ListMagickVersion(stdout);
1775 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1783 if (i == (ssize_t) argc)
1784 ThrowMontageException(OptionError,
"MissingArgument",option);
1785 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1788 ThrowMontageException(OptionError,
1789 "UnrecognizedVirtualPixelMethod",argv[i]);
1792 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1796 if (LocaleCompare(
"white-point",option+1) == 0)
1801 if (i == (ssize_t) argc)
1802 ThrowMontageException(OptionError,
"MissingArgument",option);
1803 if (IsGeometry(argv[i]) == MagickFalse)
1804 ThrowMontageInvalidArgumentException(option,argv[i]);
1807 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1812 ThrowMontageException(OptionError,
"UnrecognizedOption",option)
1814 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1815 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1816 if (fire != MagickFalse)
1817 FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1820 ThrowMontageException(OptionError,
"UnbalancedParenthesis",argv[i]);
1821 if (i-- != (ssize_t) (argc-1))
1822 ThrowMontageException(OptionError,
"MissingAnImageFilename",argv[i]);
1823 if (image == (Image *) NULL)
1824 ThrowMontageException(OptionError,
"MissingAnImageFilename",argv[argc-1]);
1825 FinalizeImageSettings(image_info,image,MagickTrue);
1826 if (image == (Image *) NULL)
1827 ThrowMontageException(OptionError,
"MissingAnImageFilename",argv[argc-1]);
1828 (void) CopyMagickString(montage_info->filename,argv[argc-1],MagickPathExtent);
1829 montage_image=MontageImageList(image_info,montage_info,image,exception);
1830 if (montage_image == (Image *) NULL)
1837 (void) CopyMagickString(image_info->filename,argv[argc-1],
1839 (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1841 if (*montage_image->magick ==
'\0')
1842 (void) CopyMagickString(montage_image->magick,image->magick,
1844 status&=(MagickStatusType) WriteImages(image_info,montage_image,
1845 argv[argc-1],exception);
1846 if (metadata != (
char **) NULL)
1851 text=InterpretImageProperties(image_info,montage_image,format,
1853 if (text == (
char *) NULL)
1854 ThrowMontageException(ResourceLimitError,
"MemoryAllocationFailed",
1855 GetExceptionMessage(errno));
1856 (void) ConcatenateString(&(*metadata),text);
1857 text=DestroyString(text);
1861 return(status != 0 ? MagickTrue : MagickFalse);