MagickWand  7.0.3
montage.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
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 %
11 % %
12 % %
13 % MagickWand Methods to Create Image Thumbnails %
14 % %
15 % Software Design %
16 % Cristy %
17 % July 1992 %
18 % %
19 % %
20 % Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % https://imagemagick.org/script/license.php %
27 % %
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. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
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.
39 %
40 */
41 
42 /*
43  Include declarations.
44 */
45 #include "MagickWand/studio.h"
46 #include "MagickWand/MagickWand.h"
48 #include "MagickCore/string-private.h"
49 
50 /*
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 % %
53 % %
54 % %
55 + M o n t a g e I m a g e C o m m a n d %
56 % %
57 % %
58 % %
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %
61 % MontageImageCommand() reads one or more images, applies one or more image
62 % processing operations, and writes out the image in the same or
63 % differing format.
64 %
65 % The format of the MontageImageCommand method is:
66 %
67 % MagickBooleanType MontageImageCommand(ImageInfo *image_info,int argc,
68 % char **argv,char **metadata,ExceptionInfo *exception)
69 %
70 % A description of each parameter follows:
71 %
72 % o image_info: the image info.
73 %
74 % o argc: the number of elements in the argument vector.
75 %
76 % o argv: A text array containing the command line arguments.
77 %
78 % o metadata: any metadata is returned here.
79 %
80 % o exception: return any errors or warnings in this structure.
81 %
82 */
83 
84 static MagickBooleanType MontageUsage(void)
85 {
86  static const char
87  miscellaneous[] =
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",
93  operators[] =
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  " -extent geometry set the image size\n"
104  " -flatten flatten a sequence of images\n"
105  " -flip flip image in the vertical direction\n"
106  " -flop flop image in the horizontal direction\n"
107  " -frame geometry surround image with an ornamental border\n"
108  " -monochrome transform image to black and white\n"
109  " -polaroid angle simulate a Polaroid picture\n"
110  " -repage geometry size and location of an image canvas (operator)\n"
111  " -resize geometry resize the image\n"
112  " -rotate degrees apply Paeth rotation to the image\n"
113  " -scale geometry scale the image\n"
114  " -strip strip image of all profiles and comments\n"
115  " -transform affine transform image\n"
116  " -transpose flip image vertically and rotate 90 degrees\n"
117  " -transparent color make this color transparent within the image\n"
118  " -type type image type\n"
119  " -unsharp geometry sharpen the image",
120  settings[] =
121  " -adjoin join images into a single multi-image file\n"
122  " -affine matrix affine transform matrix\n"
123  " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
124  " transparent, extract, background, or shape\n"
125  " -authenticate password\n"
126  " decipher image with this password\n"
127  " -blue-primary point chromaticity blue primary point\n"
128  " -bordercolor color border color\n"
129  " -caption string assign a caption to an image\n"
130  " -colors value preferred number of colors in the image\n"
131  " -colorspace type alternate image colorsapce\n"
132  " -comment string annotate image with comment\n"
133  " -compose operator composite operator\n"
134  " -compress type type of pixel compression when writing the image\n"
135  " -define format:option\n"
136  " define one or more image format options\n"
137  " -density geometry horizontal and vertical density of the image\n"
138  " -depth value image depth\n"
139  " -display server query font from this X server\n"
140  " -dispose method layer disposal method\n"
141  " -dither method apply error diffusion to image\n"
142  " -draw string annotate the image with a graphic primitive\n"
143  " -encoding type text encoding type\n"
144  " -endian type endianness (MSB or LSB) of the image\n"
145  " -extract geometry extract area from image\n"
146  " -fill color color to use when filling a graphic primitive\n"
147  " -filter type use this filter when resizing an image\n"
148  " -font name render text with this font\n"
149  " -format \"string\" output formatted image characteristics\n"
150  " -gamma value level of gamma correction\n"
151  " -geometry geometry preferred tile and border sizes\n"
152  " -gravity direction which direction to gravitate towards\n"
153  " -green-primary point chromaticity green primary point\n"
154  " -identify identify the format and characteristics of the image\n"
155  " -interlace type type of image interlacing scheme\n"
156  " -interpolate method pixel color interpolation method\n"
157  " -kerning value set the space between two letters\n"
158  " -label string assign a label to an image\n"
159  " -limit type value pixel cache resource limit\n"
160  " -matte store matte channel if the image has one\n"
161  " -mattecolor color frame color\n"
162  " -mode type framing style\n"
163  " -monitor monitor progress\n"
164  " -page geometry size and location of an image canvas (setting)\n"
165  " -pointsize value font point size\n"
166  " -profile filename add, delete, or apply an image profile\n"
167  " -quality value JPEG/MIFF/PNG compression level\n"
168  " -quantize colorspace reduce colors in this colorspace\n"
169  " -quiet suppress all warning messages\n"
170  " -red-primary point chromaticity red primary point\n"
171  " -regard-warnings pay attention to warning messages\n"
172  " -respect-parentheses settings remain in effect until parenthesis boundary\n"
173  " -sampling-factor geometry\n"
174  " horizontal and vertical sampling factor\n"
175  " -scenes range image scene range\n"
176  " -seed value seed a new sequence of pseudo-random numbers\n"
177  " -set attribute value set an image attribute\n"
178  " -shadow add a shadow beneath a tile to simulate depth\n"
179  " -size geometry width and height of image\n"
180  " -stroke color color to use when stroking a graphic primitive\n"
181  " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
182  " -synchronize synchronize image to storage device\n"
183  " -taint declare the image as modified\n"
184  " -texture filename name of texture to tile onto the image background\n"
185  " -thumbnail geometry create a thumbnail of the image\n"
186  " -tile geometry number of tiles per row and column\n"
187  " -title string decorate the montage image with a title\n"
188  " -transparent-color color\n"
189  " transparent color\n"
190  " -treedepth value color tree depth\n"
191  " -trim trim image edges\n"
192  " -units type the units of image resolution\n"
193  " -verbose print detailed information about the image\n"
194  " -virtual-pixel method\n"
195  " virtual pixel access method\n"
196  " -white-point point chromaticity white point",
197  sequence_operators[] =
198  " -coalesce merge a sequence of images\n"
199  " -composite composite image",
200  stack_operators[] =
201  " -clone indexes clone an image\n"
202  " -delete indexes delete the image from the image sequence\n"
203  " -duplicate count,indexes\n"
204  " duplicate an image one or more times\n"
205  " -insert index insert last image into the image sequence\n"
206  " -reverse reverse image sequence\n"
207  " -swap indexes swap two images in the image sequence";
208 
209  ListMagickVersion(stdout);
210  (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n",
211  GetClientName());
212  (void) printf("\nImage Settings:\n");
213  (void) puts(settings);
214  (void) printf("\nImage Operators:\n");
215  (void) puts(operators);
216  (void) printf("\nImage Sequence Operators:\n");
217  (void) puts(sequence_operators);
218  (void) printf("\nImage Stack Operators:\n");
219  (void) puts(stack_operators);
220  (void) printf("\nMiscellaneous Options:\n");
221  (void) puts(miscellaneous);
222  (void) printf(
223  "\nIn addition to those listed above, you can specify these standard X\n");
224  (void) printf(
225  "resources as command line options: -background, -bordercolor,\n");
226  (void) printf(
227  "-mattecolor, -borderwidth, -font, or -title\n");
228  (void) printf(
229  "\nBy default, the image format of 'file' is determined by its magic\n");
230  (void) printf(
231  "number. To specify a particular image format, precede the filename\n");
232  (void) printf(
233  "with an image format name and a colon (i.e. ps:image) or specify the\n");
234  (void) printf(
235  "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
236  (void) printf("'-' for standard input or output.\n");
237  return(MagickFalse);
238 }
239 
240 WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info,
241  int argc,char **argv,char **metadata,ExceptionInfo *exception)
242 {
243 #define DestroyMontage() \
244 { \
245  if (montage_image != (Image *) NULL) \
246  montage_image=DestroyImageList(montage_image); \
247  if (montage_info != (MontageInfo *) NULL) \
248  montage_info=DestroyMontageInfo(montage_info); \
249  DestroyImageStack(); \
250  for (i=0; i < (ssize_t) argc; i++) \
251  argv[i]=DestroyString(argv[i]); \
252  argv=(char **) RelinquishMagickMemory(argv); \
253 }
254 #define ThrowMontageException(asperity,tag,option) \
255 { \
256  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
257  option); \
258  DestroyMontage(); \
259  return(MagickFalse); \
260 }
261 #define ThrowMontageInvalidArgumentException(option,argument) \
262 { \
263  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
264  "InvalidArgument","'%s': %s",option,argument); \
265  DestroyMontage(); \
266  return(MagickFalse); \
267 }
268 
269  char
270  *option,
271  *transparent_color;
272 
273  const char
274  *format;
275 
276  Image
277  *image,
278  *montage_image;
279 
280  ImageStack
281  image_stack[MaxImageStackDepth+1];
282 
283  long
284  first_scene,
285  last_scene;
286 
287  MagickBooleanType
288  fire,
289  pend,
290  respect_parenthesis;
291 
292  MagickStatusType
293  status;
294 
295  MontageInfo
296  *montage_info;
297 
298  register ssize_t
299  i;
300 
301  ssize_t
302  j,
303  k,
304  scene;
305 
306  /*
307  Set defaults.
308  */
309  assert(image_info != (ImageInfo *) NULL);
310  assert(image_info->signature == MagickCoreSignature);
311  if (image_info->debug != MagickFalse)
312  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
313  assert(exception != (ExceptionInfo *) NULL);
314  if (argc == 2)
315  {
316  option=argv[1];
317  if ((LocaleCompare("version",option+1) == 0) ||
318  (LocaleCompare("-version",option+1) == 0))
319  {
320  ListMagickVersion(stdout);
321  return(MagickTrue);
322  }
323  }
324  if (argc < 3)
325  return(MontageUsage());
326  format="%w,%h,%m";
327  first_scene=0;
328  j=1;
329  k=0;
330  last_scene=0;
331  montage_image=NewImageList();
332  montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
333  NewImageStack();
334  option=(char *) NULL;
335  pend=MagickFalse;
336  respect_parenthesis=MagickFalse;
337  scene=0;
338  status=MagickFalse;
339  transparent_color=(char *) NULL;
340  /*
341  Parse command line.
342  */
343  ReadCommandlLine(argc,&argv);
344  status=ExpandFilenames(&argc,&argv);
345  if (status == MagickFalse)
346  ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
347  GetExceptionMessage(errno));
348  for (i=1; i < (ssize_t) (argc-1); i++)
349  {
350  option=argv[i];
351  if (LocaleCompare(option,"(") == 0)
352  {
353  FireImageStack(MagickTrue,MagickTrue,pend);
354  if (k == MaxImageStackDepth)
355  ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply",
356  option);
357  PushImageStack();
358  continue;
359  }
360  if (LocaleCompare(option,")") == 0)
361  {
362  FireImageStack(MagickTrue,MagickTrue,MagickTrue);
363  if (k == 0)
364  ThrowMontageException(OptionError,"UnableToParseExpression",option);
365  PopImageStack();
366  continue;
367  }
368  if (IsCommandOption(option) == MagickFalse)
369  {
370  Image
371  *images;
372 
373  FireImageStack(MagickFalse,MagickFalse,pend);
374  for (scene=(ssize_t) first_scene; scene <= (ssize_t) last_scene ; scene++)
375  {
376  char
377  *filename;
378 
379  /*
380  Option is a file name: begin by reading image from specified file.
381  */
382  filename=argv[i];
383  if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
384  filename=argv[++i];
385  (void) CloneString(&image_info->font,montage_info->font);
386  if (first_scene == last_scene)
387  images=ReadImages(image_info,filename,exception);
388  else
389  {
390  char
391  scene_filename[MagickPathExtent];
392 
393  /*
394  Form filename for multi-part images.
395  */
396  (void) InterpretImageFilename(image_info,(Image *) NULL,
397  image_info->filename,(int) scene,scene_filename,exception);
398  if (LocaleCompare(filename,image_info->filename) == 0)
399  (void) FormatLocaleString(scene_filename,MagickPathExtent,
400  "%s.%.20g",image_info->filename,(double) scene);
401  images=ReadImages(image_info,scene_filename,exception);
402  }
403  status&=(images != (Image *) NULL) &&
404  (exception->severity < ErrorException);
405  if (images == (Image *) NULL)
406  continue;
407  AppendImageStack(images);
408  }
409  continue;
410  }
411  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
412  switch (*(option+1))
413  {
414  case 'a':
415  {
416  if (LocaleCompare("adaptive-sharpen",option+1) == 0)
417  {
418  i++;
419  if (i == (ssize_t) argc)
420  ThrowMontageException(OptionError,"MissingArgument",option);
421  if (IsGeometry(argv[i]) == MagickFalse)
422  ThrowMontageInvalidArgumentException(option,argv[i]);
423  break;
424  }
425  if (LocaleCompare("adjoin",option+1) == 0)
426  break;
427  if (LocaleCompare("affine",option+1) == 0)
428  {
429  if (*option == '+')
430  break;
431  i++;
432  if (i == (ssize_t) argc)
433  ThrowMontageException(OptionError,"MissingArgument",option);
434  if (IsGeometry(argv[i]) == MagickFalse)
435  ThrowMontageInvalidArgumentException(option,argv[i]);
436  break;
437  }
438  if (LocaleCompare("alpha",option+1) == 0)
439  {
440  ssize_t
441  type;
442 
443  if (*option == '+')
444  break;
445  i++;
446  if (i == (ssize_t) argc)
447  ThrowMontageException(OptionError,"MissingArgument",option);
448  type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
449  argv[i]);
450  if (type < 0)
451  ThrowMontageException(OptionError,
452  "UnrecognizedAlphaChannelOption",argv[i]);
453  break;
454  }
455  if (LocaleCompare("annotate",option+1) == 0)
456  {
457  if (*option == '+')
458  break;
459  i++;
460  if (i == (ssize_t) argc)
461  ThrowMontageException(OptionError,"MissingArgument",option);
462  if (IsGeometry(argv[i]) == MagickFalse)
463  ThrowMontageInvalidArgumentException(option,argv[i]);
464  if (i == (ssize_t) argc)
465  ThrowMontageException(OptionError,"MissingArgument",option);
466  i++;
467  break;
468  }
469  if (LocaleCompare("auto-orient",option+1) == 0)
470  break;
471  if (LocaleCompare("authenticate",option+1) == 0)
472  {
473  if (*option == '+')
474  break;
475  i++;
476  if (i == (ssize_t) argc)
477  ThrowMontageException(OptionError,"MissingArgument",option);
478  break;
479  }
480  ThrowMontageException(OptionError,"UnrecognizedOption",option)
481  }
482  case 'b':
483  {
484  if (LocaleCompare("background",option+1) == 0)
485  {
486  if (*option == '+')
487  break;
488  i++;
489  if (i == (ssize_t) argc)
490  ThrowMontageException(OptionError,"MissingArgument",option);
491  (void) QueryColorCompliance(argv[i],AllCompliance,
492  &montage_info->background_color,exception);
493  break;
494  }
495  if (LocaleCompare("blue-primary",option+1) == 0)
496  {
497  if (*option == '+')
498  break;
499  i++;
500  if (i == (ssize_t) argc)
501  ThrowMontageException(OptionError,"MissingArgument",option);
502  if (IsGeometry(argv[i]) == MagickFalse)
503  ThrowMontageInvalidArgumentException(option,argv[i]);
504  break;
505  }
506  if (LocaleCompare("blur",option+1) == 0)
507  {
508  if (*option == '+')
509  break;
510  i++;
511  if (i == (ssize_t) argc)
512  ThrowMontageException(OptionError,"MissingArgument",option);
513  if (IsGeometry(argv[i]) == MagickFalse)
514  ThrowMontageInvalidArgumentException(option,argv[i]);
515  break;
516  }
517  if (LocaleCompare("border",option+1) == 0)
518  {
519  if (k == 0)
520  {
521  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
522  montage_info->border_width=0;
523  }
524  if (*option == '+')
525  break;
526  i++;
527  if (i == (ssize_t) argc)
528  ThrowMontageException(OptionError,"MissingArgument",option);
529  if (IsGeometry(argv[i]) == MagickFalse)
530  ThrowMontageInvalidArgumentException(option,argv[i]);
531  if (k == 0)
532  montage_info->border_width=StringToUnsignedLong(argv[i]);
533  break;
534  }
535  if (LocaleCompare("bordercolor",option+1) == 0)
536  {
537  if (*option == '+')
538  break;
539  i++;
540  if (i == (ssize_t) argc)
541  ThrowMontageException(OptionError,"MissingArgument",option);
542  (void) QueryColorCompliance(argv[i],AllCompliance,
543  &montage_info->border_color,exception);
544  break;
545  }
546  if (LocaleCompare("borderwidth",option+1) == 0)
547  {
548  montage_info->border_width=0;
549  if (*option == '+')
550  break;
551  i++;
552  if (i == (ssize_t) argc)
553  ThrowMontageException(OptionError,"MissingArgument",option);
554  if (IsGeometry(argv[i]) == MagickFalse)
555  ThrowMontageInvalidArgumentException(option,argv[i]);
556  montage_info->border_width=StringToUnsignedLong(argv[i]);
557  break;
558  }
559  ThrowMontageException(OptionError,"UnrecognizedOption",option)
560  }
561  case 'c':
562  {
563  if (LocaleCompare("cache",option+1) == 0)
564  {
565  if (*option == '+')
566  break;
567  i++;
568  if (i == (ssize_t) argc)
569  ThrowMontageException(OptionError,"MissingArgument",option);
570  if (IsGeometry(argv[i]) == MagickFalse)
571  ThrowMontageInvalidArgumentException(option,argv[i]);
572  break;
573  }
574  if (LocaleCompare("caption",option+1) == 0)
575  {
576  if (*option == '+')
577  break;
578  i++;
579  if (i == (ssize_t) argc)
580  ThrowMontageException(OptionError,"MissingArgument",option);
581  break;
582  }
583  if (LocaleCompare("channel",option+1) == 0)
584  {
585  ssize_t
586  channel;
587 
588  if (*option == '+')
589  break;
590  i++;
591  if (i == (ssize_t) argc)
592  ThrowMontageException(OptionError,"MissingArgument",option);
593  channel=ParseChannelOption(argv[i]);
594  if (channel < 0)
595  ThrowMontageException(OptionError,"UnrecognizedChannelType",
596  argv[i]);
597  break;
598  }
599  if (LocaleCompare("clone",option+1) == 0)
600  {
601  Image
602  *clone_images,
603  *clone_list;
604 
605  clone_list=CloneImageList(image,exception);
606  if (k != 0)
607  clone_list=CloneImageList(image_stack[k-1].image,exception);
608  if (clone_list == (Image *) NULL)
609  ThrowMontageException(ImageError,"ImageSequenceRequired",option);
610  FireImageStack(MagickTrue,MagickTrue,MagickTrue);
611  if (*option == '+')
612  clone_images=CloneImages(clone_list,"-1",exception);
613  else
614  {
615  i++;
616  if (i == (ssize_t) argc)
617  ThrowMontageException(OptionError,"MissingArgument",option);
618  if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
619  ThrowMontageInvalidArgumentException(option,argv[i]);
620  clone_images=CloneImages(clone_list,argv[i],exception);
621  }
622  if (clone_images == (Image *) NULL)
623  ThrowMontageException(OptionError,"NoSuchImage",option);
624  AppendImageStack(clone_images);
625  clone_list=DestroyImageList(clone_list);
626  break;
627  }
628  if (LocaleCompare("coalesce",option+1) == 0)
629  break;
630  if (LocaleCompare("colors",option+1) == 0)
631  {
632  if (*option == '+')
633  break;
634  i++;
635  if (i == (ssize_t) argc)
636  ThrowMontageException(OptionError,"MissingArgument",option);
637  if (IsGeometry(argv[i]) == MagickFalse)
638  ThrowMontageInvalidArgumentException(option,argv[i]);
639  break;
640  }
641  if (LocaleCompare("colorspace",option+1) == 0)
642  {
643  ssize_t
644  colorspace;
645 
646  if (*option == '+')
647  break;
648  i++;
649  if (i == (ssize_t) argc)
650  ThrowMontageException(OptionError,"MissingArgument",option);
651  colorspace=ParseCommandOption(MagickColorspaceOptions,
652  MagickFalse,argv[i]);
653  if (colorspace < 0)
654  ThrowMontageException(OptionError,"UnrecognizedColorspace",
655  argv[i]);
656  break;
657  }
658  if (LocaleCompare("comment",option+1) == 0)
659  {
660  if (*option == '+')
661  break;
662  i++;
663  if (i == (ssize_t) argc)
664  ThrowMontageException(OptionError,"MissingArgument",option);
665  break;
666  }
667  if (LocaleCompare("compose",option+1) == 0)
668  {
669  ssize_t
670  compose;
671 
672  if (*option == '+')
673  break;
674  i++;
675  if (i == (ssize_t) argc)
676  ThrowMontageException(OptionError,"MissingArgument",option);
677  compose=ParseCommandOption(MagickComposeOptions,MagickFalse,argv[i]);
678  if (compose < 0)
679  ThrowMontageException(OptionError,"UnrecognizedComposeOperator",
680  argv[i]);
681  break;
682  }
683  if (LocaleCompare("composite",option+1) == 0)
684  break;
685  if (LocaleCompare("compress",option+1) == 0)
686  {
687  ssize_t
688  compress;
689 
690  if (*option == '+')
691  break;
692  i++;
693  if (i == (ssize_t) argc)
694  ThrowMontageException(OptionError,"MissingArgument",option);
695  compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
696  argv[i]);
697  if (compress < 0)
698  ThrowMontageException(OptionError,"UnrecognizedCompressType",
699  argv[i]);
700  break;
701  }
702  if (LocaleCompare("concurrent",option+1) == 0)
703  break;
704  if (LocaleCompare("crop",option+1) == 0)
705  {
706  if (*option == '+')
707  break;
708  i++;
709  if (i == (ssize_t) argc)
710  ThrowMontageException(OptionError,"MissingArgument",option);
711  if (IsGeometry(argv[i]) == MagickFalse)
712  ThrowMontageInvalidArgumentException(option,argv[i]);
713  break;
714  }
715  ThrowMontageException(OptionError,"UnrecognizedOption",option)
716  }
717  case 'd':
718  {
719  if (LocaleCompare("debug",option+1) == 0)
720  {
721  ssize_t
722  event;
723 
724  if (*option == '+')
725  break;
726  i++;
727  if (i == (ssize_t) argc)
728  ThrowMontageException(OptionError,"MissingArgument",option);
729  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
730  if (event < 0)
731  ThrowMontageException(OptionError,"UnrecognizedEventType",
732  argv[i]);
733  (void) SetLogEventMask(argv[i]);
734  break;
735  }
736  if (LocaleCompare("define",option+1) == 0)
737  {
738  i++;
739  if (i == (ssize_t) argc)
740  ThrowMontageException(OptionError,"MissingArgument",option);
741  if (*option == '+')
742  {
743  const char
744  *define;
745 
746  define=GetImageOption(image_info,argv[i]);
747  if (define == (const char *) NULL)
748  ThrowMontageException(OptionError,"NoSuchOption",argv[i]);
749  break;
750  }
751  break;
752  }
753  if (LocaleCompare("delete",option+1) == 0)
754  {
755  if (*option == '+')
756  break;
757  i++;
758  if (i == (ssize_t) argc)
759  ThrowMontageException(OptionError,"MissingArgument",option);
760  if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
761  ThrowMontageInvalidArgumentException(option,argv[i]);
762  break;
763  }
764  if (LocaleCompare("density",option+1) == 0)
765  {
766  if (*option == '+')
767  break;
768  i++;
769  if (i == (ssize_t) argc)
770  ThrowMontageException(OptionError,"MissingArgument",option);
771  if (IsGeometry(argv[i]) == MagickFalse)
772  ThrowMontageInvalidArgumentException(option,argv[i]);
773  break;
774  }
775  if (LocaleCompare("depth",option+1) == 0)
776  {
777  if (*option == '+')
778  break;
779  i++;
780  if (i == (ssize_t) argc)
781  ThrowMontageException(OptionError,"MissingArgument",option);
782  if (IsGeometry(argv[i]) == MagickFalse)
783  ThrowMontageInvalidArgumentException(option,argv[i]);
784  break;
785  }
786  if (LocaleCompare("display",option+1) == 0)
787  {
788  if (*option == '+')
789  break;
790  i++;
791  if (i == (ssize_t) argc)
792  ThrowMontageException(OptionError,"MissingArgument",option);
793  break;
794  }
795  if (LocaleCompare("dispose",option+1) == 0)
796  {
797  ssize_t
798  dispose;
799 
800  if (*option == '+')
801  break;
802  i++;
803  if (i == (ssize_t) argc)
804  ThrowMontageException(OptionError,"MissingArgument",option);
805  dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
806  if (dispose < 0)
807  ThrowMontageException(OptionError,"UnrecognizedDisposeMethod",
808  argv[i]);
809  break;
810  }
811  if (LocaleCompare("dither",option+1) == 0)
812  {
813  ssize_t
814  method;
815 
816  if (*option == '+')
817  break;
818  i++;
819  if (i == (ssize_t) argc)
820  ThrowMontageException(OptionError,"MissingArgument",option);
821  method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
822  if (method < 0)
823  ThrowMontageException(OptionError,"UnrecognizedDitherMethod",
824  argv[i]);
825  break;
826  }
827  if (LocaleCompare("draw",option+1) == 0)
828  {
829  if (*option == '+')
830  break;
831  i++;
832  if (i == (ssize_t) argc)
833  ThrowMontageException(OptionError,"MissingArgument",option);
834  break;
835  }
836  if (LocaleCompare("duplicate",option+1) == 0)
837  {
838  if (*option == '+')
839  break;
840  i++;
841  if (i == (ssize_t) argc)
842  ThrowMontageException(OptionError,"MissingArgument",option);
843  if (IsGeometry(argv[i]) == MagickFalse)
844  ThrowMontageInvalidArgumentException(option,argv[i]);
845  break;
846  }
847  if (LocaleCompare("duration",option+1) == 0)
848  {
849  if (*option == '+')
850  break;
851  i++;
852  if (i == (ssize_t) argc)
853  ThrowMontageException(OptionError,"MissingArgument",option);
854  if (IsGeometry(argv[i]) == MagickFalse)
855  ThrowMontageInvalidArgumentException(option,argv[i]);
856  break;
857  }
858  ThrowMontageException(OptionError,"UnrecognizedOption",option)
859  }
860  case 'e':
861  {
862  if (LocaleCompare("encoding",option+1) == 0)
863  {
864  if (*option == '+')
865  break;
866  i++;
867  if (i == (ssize_t) argc)
868  ThrowMontageException(OptionError,"MissingArgument",option);
869  break;
870  }
871  if (LocaleCompare("endian",option+1) == 0)
872  {
873  ssize_t
874  endian;
875 
876  if (*option == '+')
877  break;
878  i++;
879  if (i == (ssize_t) argc)
880  ThrowMontageException(OptionError,"MissingArgument",option);
881  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
882  argv[i]);
883  if (endian < 0)
884  ThrowMontageException(OptionError,"UnrecognizedEndianType",
885  argv[i]);
886  break;
887  }
888  if (LocaleCompare("extent",option+1) == 0)
889  {
890  if (*option == '+')
891  break;
892  i++;
893  if (i == (ssize_t) argc)
894  ThrowMontageException(OptionError,"MissingArgument",option);
895  if (IsGeometry(argv[i]) == MagickFalse)
896  ThrowMontageInvalidArgumentException(option,argv[i]);
897  break;
898  }
899  ThrowMontageException(OptionError,"UnrecognizedOption",option)
900  }
901  case 'f':
902  {
903  if (LocaleCompare("fill",option+1) == 0)
904  {
905  (void) QueryColorCompliance("none",AllCompliance,
906  &montage_info->fill,exception);
907  if (*option == '+')
908  break;
909  i++;
910  if (i == (ssize_t) argc)
911  ThrowMontageException(OptionError,"MissingArgument",option);
912  (void) QueryColorCompliance(argv[i],AllCompliance,
913  &montage_info->fill,exception);
914  break;
915  }
916  if (LocaleCompare("filter",option+1) == 0)
917  {
918  ssize_t
919  filter;
920 
921  if (*option == '+')
922  break;
923  i++;
924  if (i == (ssize_t) argc)
925  ThrowMontageException(OptionError,"MissingArgument",option);
926  filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
927  if (filter < 0)
928  ThrowMontageException(OptionError,"UnrecognizedImageFilter",
929  argv[i]);
930  break;
931  }
932  if (LocaleCompare("flatten",option+1) == 0)
933  break;
934  if (LocaleCompare("flip",option+1) == 0)
935  break;
936  if (LocaleCompare("flop",option+1) == 0)
937  break;
938  if (LocaleCompare("font",option+1) == 0)
939  {
940  if (*option == '+')
941  break;
942  i++;
943  if (i == (ssize_t) argc)
944  ThrowMontageException(OptionError,"MissingArgument",option);
945  (void) CloneString(&montage_info->font,argv[i]);
946  break;
947  }
948  if (LocaleCompare("format",option+1) == 0)
949  {
950  if (*option == '+')
951  break;
952  i++;
953  if (i == (ssize_t) argc)
954  ThrowMontageException(OptionError,"MissingArgument",option);
955  format=argv[i];
956  break;
957  }
958  if (LocaleCompare("frame",option+1) == 0)
959  {
960  if (k == 0)
961  {
962  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
963  (void) CloneString(&montage_info->frame,(char *) NULL);
964  }
965  if (*option == '+')
966  break;
967  i++;
968  if (i == (ssize_t) argc)
969  ThrowMontageException(OptionError,"MissingArgument",option);
970  if (IsGeometry(argv[i]) == MagickFalse)
971  ThrowMontageInvalidArgumentException(option,argv[i]);
972  if (k == 0)
973  (void) CloneString(&montage_info->frame,argv[i]);
974  break;
975  }
976  ThrowMontageException(OptionError,"UnrecognizedOption",option)
977  }
978  case 'g':
979  {
980  if (LocaleCompare("gamma",option+1) == 0)
981  {
982  i++;
983  if (i == (ssize_t) argc)
984  ThrowMontageException(OptionError,"MissingArgument",option);
985  if (IsGeometry(argv[i]) == MagickFalse)
986  ThrowMontageInvalidArgumentException(option,argv[i]);
987  break;
988  }
989  if (LocaleCompare("geometry",option+1) == 0)
990  {
991  (void) CloneString(&montage_info->geometry,(char *) NULL);
992  if (*option == '+')
993  break;
994  i++;
995  if (i == (ssize_t) argc)
996  ThrowMontageException(OptionError,"MissingArgument",option);
997  if (IsGeometry(argv[i]) == MagickFalse)
998  ThrowMontageInvalidArgumentException(option,argv[i]);
999  (void) CloneString(&montage_info->geometry,argv[i]);
1000  break;
1001  }
1002  if (LocaleCompare("gravity",option+1) == 0)
1003  {
1004  ssize_t
1005  gravity;
1006 
1007  montage_info->gravity=UndefinedGravity;
1008  if (*option == '+')
1009  break;
1010  i++;
1011  if (i == (ssize_t) argc)
1012  ThrowMontageException(OptionError,"MissingArgument",option);
1013  gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1014  argv[i]);
1015  if (gravity < 0)
1016  ThrowMontageException(OptionError,"UnrecognizedGravityType",
1017  argv[i]);
1018  montage_info->gravity=(GravityType) gravity;
1019  break;
1020  }
1021  if (LocaleCompare("green-primary",option+1) == 0)
1022  {
1023  if (*option == '+')
1024  break;
1025  i++;
1026  if (i == (ssize_t) argc)
1027  ThrowMontageException(OptionError,"MissingArgument",option);
1028  if (IsGeometry(argv[i]) == MagickFalse)
1029  ThrowMontageInvalidArgumentException(option,argv[i]);
1030  break;
1031  }
1032  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1033  }
1034  case 'h':
1035  {
1036  if ((LocaleCompare("help",option+1) == 0) ||
1037  (LocaleCompare("-help",option+1) == 0))
1038  return(MontageUsage());
1039  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1040  }
1041  case 'i':
1042  {
1043  if (LocaleCompare("identify",option+1) == 0)
1044  break;
1045  if (LocaleCompare("insert",option+1) == 0)
1046  {
1047  if (*option == '+')
1048  break;
1049  i++;
1050  if (i == (ssize_t) argc)
1051  ThrowMontageException(OptionError,"MissingArgument",option);
1052  if (IsGeometry(argv[i]) == MagickFalse)
1053  ThrowMontageInvalidArgumentException(option,argv[i]);
1054  break;
1055  }
1056  if (LocaleCompare("interlace",option+1) == 0)
1057  {
1058  ssize_t
1059  interlace;
1060 
1061  if (*option == '+')
1062  break;
1063  i++;
1064  if (i == (ssize_t) argc)
1065  ThrowMontageException(OptionError,"MissingArgument",option);
1066  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1067  argv[i]);
1068  if (interlace < 0)
1069  ThrowMontageException(OptionError,"UnrecognizedInterlaceType",
1070  argv[i]);
1071  break;
1072  }
1073  if (LocaleCompare("interpolate",option+1) == 0)
1074  {
1075  ssize_t
1076  interpolate;
1077 
1078  if (*option == '+')
1079  break;
1080  i++;
1081  if (i == (ssize_t) argc)
1082  ThrowMontageException(OptionError,"MissingArgument",option);
1083  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1084  argv[i]);
1085  if (interpolate < 0)
1086  ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod",
1087  argv[i]);
1088  break;
1089  }
1090  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1091  }
1092  case 'k':
1093  {
1094  if (LocaleCompare("kerning",option+1) == 0)
1095  {
1096  if (*option == '+')
1097  break;
1098  i++;
1099  if (i == (ssize_t) argc)
1100  ThrowMontageException(OptionError,"MissingArgument",option);
1101  if (IsGeometry(argv[i]) == MagickFalse)
1102  ThrowMontageInvalidArgumentException(option,argv[i]);
1103  break;
1104  }
1105  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1106  }
1107  case 'l':
1108  {
1109  if (LocaleCompare("label",option+1) == 0)
1110  {
1111  if (*option == '+')
1112  break;
1113  i++;
1114  if (i == (ssize_t) argc)
1115  ThrowMontageException(OptionError,"MissingArgument",option);
1116  break;
1117  }
1118  if (LocaleCompare("limit",option+1) == 0)
1119  {
1120  char
1121  *p;
1122 
1123  double
1124  value;
1125 
1126  ssize_t
1127  resource;
1128 
1129  if (*option == '+')
1130  break;
1131  i++;
1132  if (i == (ssize_t) argc)
1133  ThrowMontageException(OptionError,"MissingArgument",option);
1134  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1135  argv[i]);
1136  if (resource < 0)
1137  ThrowMontageException(OptionError,"UnrecognizedResourceType",
1138  argv[i]);
1139  i++;
1140  if (i == (ssize_t) argc)
1141  ThrowMontageException(OptionError,"MissingArgument",option);
1142  value=StringToDouble(argv[i],&p);
1143  (void) value;
1144  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1145  ThrowMontageInvalidArgumentException(option,argv[i]);
1146  break;
1147  }
1148  if (LocaleCompare("list",option+1) == 0)
1149  {
1150  ssize_t
1151  list;
1152 
1153  if (*option == '+')
1154  break;
1155  i++;
1156  if (i == (ssize_t) argc)
1157  ThrowMontageException(OptionError,"MissingArgument",option);
1158  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1159  if (list < 0)
1160  ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]);
1161  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1162  argv+j,exception);
1163  DestroyMontage();
1164  return(status == 0 ? MagickFalse : MagickTrue);
1165  }
1166  if (LocaleCompare("log",option+1) == 0)
1167  {
1168  if (*option == '+')
1169  break;
1170  i++;
1171  if ((i == (ssize_t) argc) ||
1172  (strchr(argv[i],'%') == (char *) NULL))
1173  ThrowMontageException(OptionError,"MissingArgument",option);
1174  break;
1175  }
1176  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1177  }
1178  case 'm':
1179  {
1180  if (LocaleCompare("matte",option+1) == 0)
1181  break;
1182  if (LocaleCompare("mattecolor",option+1) == 0)
1183  {
1184  if (*option == '+')
1185  break;
1186  i++;
1187  if (i == (ssize_t) argc)
1188  ThrowMontageException(OptionError,"MissingArgument",option);
1189  (void) QueryColorCompliance(argv[i],AllCompliance,
1190  &montage_info->matte_color,exception);
1191  break;
1192  }
1193  if (LocaleCompare("mode",option+1) == 0)
1194  {
1195  MontageMode
1196  mode;
1197 
1198  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1199  if (*option == '+')
1200  break;
1201  i++;
1202  if (i == (ssize_t) argc)
1203  ThrowMontageException(OptionError,"MissingArgument",option);
1204  mode=UndefinedMode;
1205  if (LocaleCompare("frame",argv[i]) == 0)
1206  {
1207  mode=FrameMode;
1208  (void) CloneString(&montage_info->frame,"15x15+3+3");
1209  montage_info->shadow=MagickTrue;
1210  break;
1211  }
1212  if (LocaleCompare("unframe",argv[i]) == 0)
1213  {
1214  mode=UnframeMode;
1215  montage_info->frame=(char *) NULL;
1216  montage_info->shadow=MagickFalse;
1217  montage_info->border_width=0;
1218  break;
1219  }
1220  if (LocaleCompare("concatenate",argv[i]) == 0)
1221  {
1222  mode=ConcatenateMode;
1223  montage_info->frame=(char *) NULL;
1224  montage_info->shadow=MagickFalse;
1225  montage_info->gravity=(GravityType) NorthWestGravity;
1226  (void) CloneString(&montage_info->geometry,"+0+0");
1227  montage_info->border_width=0;
1228  break;
1229  }
1230  if (mode == UndefinedMode)
1231  ThrowMontageException(OptionError,"UnrecognizedImageMode",
1232  argv[i]);
1233  break;
1234  }
1235  if (LocaleCompare("monitor",option+1) == 0)
1236  break;
1237  if (LocaleCompare("monochrome",option+1) == 0)
1238  break;
1239  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1240  }
1241  case 'n':
1242  {
1243  if (LocaleCompare("noop",option+1) == 0)
1244  break;
1245  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1246  }
1247  case 'p':
1248  {
1249  if (LocaleCompare("page",option+1) == 0)
1250  {
1251  if (*option == '+')
1252  break;
1253  i++;
1254  if (i == (ssize_t) argc)
1255  ThrowMontageException(OptionError,"MissingArgument",option);
1256  break;
1257  }
1258  if (LocaleCompare("pointsize",option+1) == 0)
1259  {
1260  montage_info->pointsize=12;
1261  if (*option == '+')
1262  break;
1263  i++;
1264  if (i == (ssize_t) argc)
1265  ThrowMontageException(OptionError,"MissingArgument",option);
1266  if (IsGeometry(argv[i]) == MagickFalse)
1267  ThrowMontageInvalidArgumentException(option,argv[i]);
1268  montage_info->pointsize=StringToDouble(argv[i],(char **) NULL);
1269  break;
1270  }
1271  if (LocaleCompare("polaroid",option+1) == 0)
1272  {
1273  if (*option == '+')
1274  break;
1275  i++;
1276  if (i == (ssize_t) argc)
1277  ThrowMontageException(OptionError,"MissingArgument",option);
1278  if (IsGeometry(argv[i]) == MagickFalse)
1279  ThrowMontageInvalidArgumentException(option,argv[i]);
1280  break;
1281  }
1282  if (LocaleCompare("profile",option+1) == 0)
1283  {
1284  i++;
1285  if (i == (ssize_t) argc)
1286  ThrowMontageException(OptionError,"MissingArgument",option);
1287  break;
1288  }
1289  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1290  }
1291  case 'q':
1292  {
1293  if (LocaleCompare("quality",option+1) == 0)
1294  {
1295  if (*option == '+')
1296  break;
1297  i++;
1298  if (i == (ssize_t) argc)
1299  ThrowMontageException(OptionError,"MissingArgument",option);
1300  if (IsGeometry(argv[i]) == MagickFalse)
1301  ThrowMontageInvalidArgumentException(option,argv[i]);
1302  break;
1303  }
1304  if (LocaleCompare("quantize",option+1) == 0)
1305  {
1306  ssize_t
1307  colorspace;
1308 
1309  if (*option == '+')
1310  break;
1311  i++;
1312  if (i == (ssize_t) argc)
1313  ThrowMontageException(OptionError,"MissingArgument",option);
1314  colorspace=ParseCommandOption(MagickColorspaceOptions,
1315  MagickFalse,argv[i]);
1316  if (colorspace < 0)
1317  ThrowMontageException(OptionError,"UnrecognizedColorspace",
1318  argv[i]);
1319  break;
1320  }
1321  if (LocaleCompare("quiet",option+1) == 0)
1322  break;
1323  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1324  }
1325  case 'r':
1326  {
1327  if (LocaleCompare("red-primary",option+1) == 0)
1328  {
1329  if (*option == '+')
1330  break;
1331  i++;
1332  if (i == (ssize_t) argc)
1333  ThrowMontageException(OptionError,"MissingArgument",option);
1334  if (IsGeometry(argv[i]) == MagickFalse)
1335  ThrowMontageInvalidArgumentException(option,argv[i]);
1336  break;
1337  }
1338  if (LocaleCompare("regard-warnings",option+1) == 0)
1339  break;
1340  if (LocaleCompare("render",option+1) == 0)
1341  break;
1342  if (LocaleCompare("repage",option+1) == 0)
1343  {
1344  if (*option == '+')
1345  break;
1346  i++;
1347  if (i == (ssize_t) argc)
1348  ThrowMontageException(OptionError,"MissingArgument",option);
1349  if (IsGeometry(argv[i]) == MagickFalse)
1350  ThrowMontageInvalidArgumentException(option,argv[i]);
1351  break;
1352  }
1353  if (LocaleCompare("resize",option+1) == 0)
1354  {
1355  if (*option == '+')
1356  break;
1357  i++;
1358  if (i == (ssize_t) argc)
1359  ThrowMontageException(OptionError,"MissingArgument",option);
1360  if (IsGeometry(argv[i]) == MagickFalse)
1361  ThrowMontageInvalidArgumentException(option,argv[i]);
1362  break;
1363  }
1364  if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1365  {
1366  respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1367  break;
1368  }
1369  if (LocaleCompare("reverse",option+1) == 0)
1370  break;
1371  if (LocaleCompare("rotate",option+1) == 0)
1372  {
1373  i++;
1374  if (i == (ssize_t) argc)
1375  ThrowMontageException(OptionError,"MissingArgument",option);
1376  if (IsGeometry(argv[i]) == MagickFalse)
1377  ThrowMontageInvalidArgumentException(option,argv[i]);
1378  break;
1379  }
1380  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1381  }
1382  case 's':
1383  {
1384  if (LocaleCompare("sampling-factor",option+1) == 0)
1385  {
1386  if (*option == '+')
1387  break;
1388  i++;
1389  if (i == (ssize_t) argc)
1390  ThrowMontageException(OptionError,"MissingArgument",option);
1391  if (IsGeometry(argv[i]) == MagickFalse)
1392  ThrowMontageInvalidArgumentException(option,argv[i]);
1393  break;
1394  }
1395  if (LocaleCompare("scale",option+1) == 0)
1396  {
1397  if (*option == '+')
1398  break;
1399  i++;
1400  if (i == (ssize_t) argc)
1401  ThrowMontageException(OptionError,"MissingArgument",option);
1402  if (IsGeometry(argv[i]) == MagickFalse)
1403  ThrowMontageInvalidArgumentException(option,argv[i]);
1404  break;
1405  }
1406  if (LocaleCompare("scenes",option+1) == 0)
1407  {
1408  first_scene=0;
1409  last_scene=0;
1410  if (*option == '+')
1411  break;
1412  i++;
1413  if (i == (ssize_t) argc)
1414  ThrowMontageException(OptionError,"MissingArgument",option);
1415  if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1416  ThrowMontageInvalidArgumentException(option,argv[i]);
1417  first_scene=(int) StringToLong(argv[i]);
1418  last_scene=first_scene;
1419  (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene);
1420  break;
1421  }
1422  if (LocaleCompare("seed",option+1) == 0)
1423  {
1424  if (*option == '+')
1425  break;
1426  i++;
1427  if (i == (ssize_t) argc)
1428  ThrowMontageException(OptionError,"MissingArgument",option);
1429  if (IsGeometry(argv[i]) == MagickFalse)
1430  ThrowMontageInvalidArgumentException(option,argv[i]);
1431  break;
1432  }
1433  if (LocaleCompare("set",option+1) == 0)
1434  {
1435  i++;
1436  if (i == (ssize_t) argc)
1437  ThrowMontageException(OptionError,"MissingArgument",option);
1438  if (*option == '+')
1439  break;
1440  i++;
1441  if (i == (ssize_t) argc)
1442  ThrowMontageException(OptionError,"MissingArgument",option);
1443  break;
1444  }
1445  if (LocaleCompare("shadow",option+1) == 0)
1446  {
1447  if (k == 0)
1448  {
1449  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1450  montage_info->shadow=(*option == '-') ? MagickTrue :
1451  MagickFalse;
1452  break;
1453  }
1454  if (*option == '+')
1455  break;
1456  i++;
1457  if (i == (ssize_t) argc)
1458  ThrowMontageException(OptionError,"MissingArgument",option);
1459  if (IsGeometry(argv[i]) == MagickFalse)
1460  ThrowMontageInvalidArgumentException(option,argv[i]);
1461  break;
1462  }
1463  if (LocaleCompare("sharpen",option+1) == 0)
1464  {
1465  if (*option == '+')
1466  break;
1467  i++;
1468  if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
1469  ThrowMontageException(OptionError,"MissingArgument",option);
1470  break;
1471  }
1472  if (LocaleCompare("size",option+1) == 0)
1473  {
1474  if (*option == '+')
1475  break;
1476  i++;
1477  if (i == (ssize_t) argc)
1478  ThrowMontageException(OptionError,"MissingArgument",option);
1479  if (IsGeometry(argv[i]) == MagickFalse)
1480  ThrowMontageInvalidArgumentException(option,argv[i]);
1481  break;
1482  }
1483  if (LocaleCompare("stroke",option+1) == 0)
1484  {
1485  (void) QueryColorCompliance("none",AllCompliance,
1486  &montage_info->stroke,exception);
1487  if (*option == '+')
1488  break;
1489  i++;
1490  if (i == (ssize_t) argc)
1491  ThrowMontageException(OptionError,"MissingArgument",option);
1492  (void) QueryColorCompliance(argv[i],AllCompliance,
1493  &montage_info->stroke,exception);
1494  break;
1495  }
1496  if (LocaleCompare("strip",option+1) == 0)
1497  break;
1498  if (LocaleCompare("strokewidth",option+1) == 0)
1499  {
1500  if (*option == '+')
1501  break;
1502  i++;
1503  if (i == (ssize_t) argc)
1504  ThrowMontageException(OptionError,"MissingArgument",option);
1505  if (IsGeometry(argv[i]) == MagickFalse)
1506  ThrowMontageInvalidArgumentException(option,argv[i]);
1507  break;
1508  }
1509  if (LocaleCompare("support",option+1) == 0)
1510  {
1511  i++; /* deprecated */
1512  break;
1513  }
1514  if (LocaleCompare("swap",option+1) == 0)
1515  {
1516  if (*option == '+')
1517  break;
1518  i++;
1519  if (i == (ssize_t) argc)
1520  ThrowMontageException(OptionError,"MissingArgument",option);
1521  if (IsGeometry(argv[i]) == MagickFalse)
1522  ThrowMontageInvalidArgumentException(option,argv[i]);
1523  break;
1524  }
1525  if (LocaleCompare("synchronize",option+1) == 0)
1526  break;
1527  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1528  }
1529  case 't':
1530  {
1531  if (LocaleCompare("taint",option+1) == 0)
1532  break;
1533  if (LocaleCompare("texture",option+1) == 0)
1534  {
1535  (void) CloneString(&montage_info->texture,(char *) NULL);
1536  if (*option == '+')
1537  break;
1538  i++;
1539  if (i == (ssize_t) argc)
1540  ThrowMontageException(OptionError,"MissingArgument",option);
1541  (void) CloneString(&montage_info->texture,argv[i]);
1542  break;
1543  }
1544  if (LocaleCompare("thumbnail",option+1) == 0)
1545  {
1546  if (*option == '+')
1547  break;
1548  i++;
1549  if (i == (ssize_t) argc)
1550  ThrowMontageException(OptionError,"MissingArgument",option);
1551  if (IsGeometry(argv[i]) == MagickFalse)
1552  ThrowMontageInvalidArgumentException(option,argv[i]);
1553  break;
1554  }
1555  if (LocaleCompare("tile",option+1) == 0)
1556  {
1557  if (k == 0)
1558  {
1559  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1560  (void) CloneString(&montage_info->tile,(char *) NULL);
1561  }
1562  if (*option == '+')
1563  break;
1564  i++;
1565  if (i == (ssize_t) argc)
1566  ThrowMontageException(OptionError,"MissingArgument",option);
1567  if (IsGeometry(argv[i]) == MagickFalse)
1568  ThrowMontageInvalidArgumentException(option,argv[i]);
1569  if (k == 0)
1570  (void) CloneString(&montage_info->tile,argv[i]);
1571  break;
1572  }
1573  if (LocaleCompare("tile-offset",option+1) == 0)
1574  {
1575  if (*option == '+')
1576  break;
1577  i++;
1578  if (i == (ssize_t) argc)
1579  ThrowMontageException(OptionError,"MissingArgument",option);
1580  if (IsGeometry(argv[i]) == MagickFalse)
1581  ThrowMontageInvalidArgumentException(option,argv[i]);
1582  break;
1583  }
1584  if (LocaleCompare("tint",option+1) == 0)
1585  {
1586  if (*option == '+')
1587  break;
1588  i++;
1589  if (i == (ssize_t) argc)
1590  ThrowMontageException(OptionError,"MissingArgument",option);
1591  if (IsGeometry(argv[i]) == MagickFalse)
1592  ThrowMontageInvalidArgumentException(option,argv[i]);
1593  break;
1594  }
1595  if (LocaleCompare("transform",option+1) == 0)
1596  break;
1597  if (LocaleCompare("transpose",option+1) == 0)
1598  break;
1599  if (LocaleCompare("title",option+1) == 0)
1600  {
1601  (void) CloneString(&montage_info->title,(char *) NULL);
1602  if (*option == '+')
1603  break;
1604  i++;
1605  if (i == (ssize_t) argc)
1606  ThrowMontageException(OptionError,"MissingArgument",option);
1607  (void) CloneString(&montage_info->title,argv[i]);
1608  break;
1609  }
1610  if (LocaleCompare("transform",option+1) == 0)
1611  break;
1612  if (LocaleCompare("transparent",option+1) == 0)
1613  {
1614  transparent_color=(char *) NULL;
1615  i++;
1616  if (i == (ssize_t) argc)
1617  ThrowMontageException(OptionError,"MissingArgument",option);
1618  (void) CloneString(&transparent_color,argv[i]);
1619  break;
1620  }
1621  if (LocaleCompare("transparent-color",option+1) == 0)
1622  {
1623  if (*option == '+')
1624  break;
1625  i++;
1626  if (i == (ssize_t) argc)
1627  ThrowMontageException(OptionError,"MissingArgument",option);
1628  break;
1629  }
1630  if (LocaleCompare("treedepth",option+1) == 0)
1631  {
1632  if (*option == '+')
1633  break;
1634  i++;
1635  if (i == (ssize_t) argc)
1636  ThrowMontageException(OptionError,"MissingArgument",option);
1637  if (IsGeometry(argv[i]) == MagickFalse)
1638  ThrowMontageInvalidArgumentException(option,argv[i]);
1639  break;
1640  }
1641  if (LocaleCompare("trim",option+1) == 0)
1642  break;
1643  if (LocaleCompare("type",option+1) == 0)
1644  {
1645  ssize_t
1646  type;
1647 
1648  if (*option == '+')
1649  break;
1650  i++;
1651  if (i == (ssize_t) argc)
1652  ThrowMontageException(OptionError,"MissingArgument",option);
1653  type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1654  if (type < 0)
1655  ThrowMontageException(OptionError,"UnrecognizedImageType",
1656  argv[i]);
1657  break;
1658  }
1659  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1660  }
1661  case 'u':
1662  {
1663  if (LocaleCompare("units",option+1) == 0)
1664  {
1665  ssize_t
1666  units;
1667 
1668  if (*option == '+')
1669  break;
1670  i++;
1671  if (i == (ssize_t) argc)
1672  ThrowMontageException(OptionError,"MissingArgument",option);
1673  units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1674  argv[i]);
1675  if (units < 0)
1676  ThrowMontageException(OptionError,"UnrecognizedUnitsType",
1677  argv[i]);
1678  break;
1679  }
1680  if (LocaleCompare("unsharp",option+1) == 0)
1681  {
1682  if (*option == '+')
1683  break;
1684  i++;
1685  if (i == (ssize_t) argc)
1686  ThrowMontageException(OptionError,"MissingArgument",option);
1687  if (IsGeometry(argv[i]) == MagickFalse)
1688  ThrowMontageInvalidArgumentException(option,argv[i]);
1689  break;
1690  }
1691  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1692  }
1693  case 'v':
1694  {
1695  if (LocaleCompare("verbose",option+1) == 0)
1696  {
1697  break;
1698  }
1699  if ((LocaleCompare("version",option+1) == 0) ||
1700  (LocaleCompare("-version",option+1) == 0))
1701  {
1702  ListMagickVersion(stdout);
1703  break;
1704  }
1705  if (LocaleCompare("virtual-pixel",option+1) == 0)
1706  {
1707  ssize_t
1708  method;
1709 
1710  if (*option == '+')
1711  break;
1712  i++;
1713  if (i == (ssize_t) argc)
1714  ThrowMontageException(OptionError,"MissingArgument",option);
1715  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1716  argv[i]);
1717  if (method < 0)
1718  ThrowMontageException(OptionError,
1719  "UnrecognizedVirtualPixelMethod",argv[i]);
1720  break;
1721  }
1722  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1723  }
1724  case 'w':
1725  {
1726  if (LocaleCompare("white-point",option+1) == 0)
1727  {
1728  if (*option == '+')
1729  break;
1730  i++;
1731  if (i == (ssize_t) argc)
1732  ThrowMontageException(OptionError,"MissingArgument",option);
1733  if (IsGeometry(argv[i]) == MagickFalse)
1734  ThrowMontageInvalidArgumentException(option,argv[i]);
1735  break;
1736  }
1737  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1738  }
1739  case '?':
1740  break;
1741  default:
1742  ThrowMontageException(OptionError,"UnrecognizedOption",option)
1743  }
1744  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1745  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1746  if (fire != MagickFalse)
1747  FireImageStack(MagickTrue,MagickTrue,MagickTrue);
1748  }
1749  if (k != 0)
1750  ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
1751  if (i-- != (ssize_t) (argc-1))
1752  ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
1753  if (image == (Image *) NULL)
1754  ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1755  FinalizeImageSettings(image_info,image,MagickTrue);
1756  if (image == (Image *) NULL)
1757  ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1758  (void) CopyMagickString(montage_info->filename,argv[argc-1],MagickPathExtent);
1759  montage_image=MontageImageList(image_info,montage_info,image,exception);
1760  if (montage_image == (Image *) NULL)
1761  status=MagickFalse;
1762  else
1763  {
1764  /*
1765  Write image.
1766  */
1767  (void) CopyMagickString(image_info->filename,argv[argc-1],
1769  (void) CopyMagickString(montage_image->magick_filename,argv[argc-1],
1771  if (*montage_image->magick == '\0')
1772  (void) CopyMagickString(montage_image->magick,image->magick,
1774  status&=WriteImages(image_info,montage_image,argv[argc-1],exception);
1775  if (metadata != (char **) NULL)
1776  {
1777  char
1778  *text;
1779 
1780  text=InterpretImageProperties(image_info,montage_image,format,
1781  exception);
1782  if (text == (char *) NULL)
1783  ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
1784  GetExceptionMessage(errno));
1785  (void) ConcatenateString(&(*metadata),text);
1786  text=DestroyString(text);
1787  }
1788  }
1789  DestroyMontage();
1790  return(status != 0 ? MagickTrue : MagickFalse);
1791 }
#define FinalizeImageSettings(image_info, image, advance)
#define DestroyMontage()
#define NewImageStack()
#define WandExport
#define AppendImageStack(images)
WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, const int argc, const char **argv, ExceptionInfo *exception)
Definition: mogrify.c:6577
#define MagickPathExtent
#define ReadCommandlLine(argc, argv)
Definition: studio.h:260
#define ThrowMontageInvalidArgumentException(option, argument)
static MagickBooleanType MontageUsage(void)
Definition: montage.c:84
#define PopImageStack()
#define ThrowMontageException(asperity, tag, option)
WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info, int argc, char **argv, char **metadata, ExceptionInfo *exception)
Definition: montage.c:240
#define PushImageStack()
#define FireImageStack(postfix, advance, fire)
#define MaxImageStackDepth