MagickWand  7.0.3
composite.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % CCCC OOO M M PPPP OOO SSSSS IIIII TTTTT EEEEE %
7 % C O O MM MM P P O O SS I T E %
8 % C O O M M M PPPP O O SSS I T EEE %
9 % C O O M M P O O SS I T E %
10 % CCCC OOO M M P OOO SSSSS IIIII T EEEEE %
11 % %
12 % %
13 % MagickWand Image Composite Methods %
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 composite program to overlap one image over another.
37 %
38 */
39 
40 /*
41  Include declarations.
42 */
43 #include "MagickWand/studio.h"
44 #include "MagickWand/MagickWand.h"
46 #include "MagickCore/composite-private.h"
47 #include "MagickCore/string-private.h"
48 
49 /*
50  Typedef declarations.
51 */
52 typedef struct _CompositeOptions
53 {
54  ChannelType
56 
57  char
59  *geometry;
60 
61  CompositeOperator
63 
64  GravityType
66 
67  ssize_t
69 
70  RectangleInfo
72 
73  MagickBooleanType
75  stereo,
76  tile;
78 
79 /*
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % %
82 % %
83 % %
84 % C o m p o s i t e I m a g e C o m m a n d %
85 % %
86 % %
87 % %
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 %
90 % CompositeImageCommand() reads one or more images and an optional mask and
91 % composites them into a new image.
92 %
93 % The format of the CompositeImageCommand method is:
94 %
95 % MagickBooleanType CompositeImageCommand(ImageInfo *image_info,int argc,
96 % char **argv,char **metadata,ExceptionInfo *exception)
97 %
98 % A description of each parameter follows:
99 %
100 % o image_info: the image info.
101 %
102 % o argc: the number of elements in the argument vector.
103 %
104 % o argv: A text array containing the command line arguments.
105 %
106 % o metadata: any metadata is returned here.
107 %
108 % o exception: return any errors or warnings in this structure.
109 %
110 */
111 
112 static MagickBooleanType CompositeImageList(ImageInfo *image_info,Image **image,
113  Image *composite_image,CompositeOptions *composite_options,
114  ExceptionInfo *exception)
115 {
116  const char
117  *value;
118 
119  MagickStatusType
120  status;
121 
122  assert(image_info != (ImageInfo *) NULL);
123  assert(image_info->signature == MagickCoreSignature);
124  assert(image != (Image **) NULL);
125  assert((*image)->signature == MagickCoreSignature);
126  if ((*image)->debug != MagickFalse)
127  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
128  assert(exception != (ExceptionInfo *) NULL);
129  (void) image_info;
130  status=MagickTrue;
131  composite_options->clip_to_self=GetCompositeClipToSelf(
132  composite_options->compose);
133  value=GetImageOption(image_info,"compose:clip-to-self");
134  if (value != (const char *) NULL)
135  composite_options->clip_to_self=IsStringTrue(value);
136  value=GetImageOption(image_info,"compose:outside-overlay");
137  if (value != (const char *) NULL)
138  composite_options->clip_to_self=IsStringFalse(value); /* deprecated */
139  if (composite_image != (Image *) NULL)
140  {
141  ChannelType
142  channel_mask;
143 
144  channel_mask=SetImageChannelMask(composite_image,
145  composite_options->channel);
146  assert(composite_image->signature == MagickCoreSignature);
147  switch (composite_options->compose)
148  {
149  case BlendCompositeOp:
150  case BlurCompositeOp:
151  case DisplaceCompositeOp:
152  case DistortCompositeOp:
153  case DissolveCompositeOp:
154  case ModulateCompositeOp:
155  case ThresholdCompositeOp:
156  {
157  (void) SetImageArtifact(*image,"compose:args",
158  composite_options->compose_args);
159  break;
160  }
161  default:
162  break;
163  }
164  /*
165  Composite image.
166  */
167  if (composite_options->stegano != 0)
168  {
169  Image
170  *stegano_image;
171 
172  (*image)->offset=composite_options->stegano-1;
173  stegano_image=SteganoImage(*image,composite_image,exception);
174  if (stegano_image != (Image *) NULL)
175  {
176  *image=DestroyImageList(*image);
177  *image=stegano_image;
178  }
179  }
180  else
181  if (composite_options->stereo != MagickFalse)
182  {
183  Image
184  *stereo_image;
185 
186  stereo_image=StereoAnaglyphImage(*image,composite_image,
187  composite_options->offset.x,composite_options->offset.y,
188  exception);
189  if (stereo_image != (Image *) NULL)
190  {
191  *image=DestroyImageList(*image);
192  *image=stereo_image;
193  }
194  }
195  else
196  if (composite_options->tile != MagickFalse)
197  {
198  size_t
199  columns;
200 
201  ssize_t
202  x,
203  y;
204 
205  /*
206  Tile the composite image.
207  */
208  columns=composite_image->columns;
209  for (y=0; y < (ssize_t) (*image)->rows; y+=(ssize_t) composite_image->rows)
210  for (x=0; x < (ssize_t) (*image)->columns; x+=(ssize_t) columns)
211  status&=CompositeImage(*image,composite_image,
212  composite_options->compose,MagickTrue,x,y,exception);
213  }
214  else
215  {
216  RectangleInfo
217  geometry;
218 
219  /*
220  Work out gravity Adjustment of Offset
221  */
222  SetGeometry(*image,&geometry);
223  (void) ParseAbsoluteGeometry(composite_options->geometry,
224  &geometry);
225  geometry.width=composite_image->columns;
226  geometry.height=composite_image->rows;
227  GravityAdjustGeometry((*image)->columns,(*image)->rows,
228  composite_options->gravity, &geometry);
229  (*image)->gravity=(GravityType) composite_options->gravity;
230  /*
231  Digitally composite image.
232  */
233  status&=CompositeImage(*image,composite_image,
234  composite_options->compose,composite_options->clip_to_self,
235  geometry.x,geometry.y,exception);
236  }
237  (void) SetPixelChannelMask(composite_image,channel_mask);
238  }
239  return(status != 0 ? MagickTrue : MagickFalse);
240 }
241 
242 static MagickBooleanType CompositeUsage(void)
243 {
244  static const char
245  miscellaneous[] =
246  " -debug events display copious debugging information\n"
247  " -help print program options\n"
248  " -list type print a list of supported option arguments\n"
249  " -log format format of debugging information\n"
250  " -version print version information",
251  operators[] =
252  " -blend geometry blend images\n"
253  " -border geometry surround image with a border of color\n"
254  " -bordercolor color border color\n"
255  " -channel mask set the image channel mask\n"
256  " -colors value preferred number of colors in the image\n"
257  " -decipher filename convert cipher pixels to plain pixels\n"
258  " -displace geometry shift lookup according to a relative displacement map\n"
259  " -dissolve value dissolve the two images a given percent\n"
260  " -distort geometry shift lookup according to a absolute distortion map\n"
261  " -encipher filename convert plain pixels to cipher pixels\n"
262  " -extract geometry extract area from image\n"
263  " -geometry geometry location of the composite image\n"
264  " -identify identify the format and characteristics of the image\n"
265  " -monochrome transform image to black and white\n"
266  " -negate replace every pixel with its complementary color \n"
267  " -profile filename add ICM or IPTC information profile to image\n"
268  " -quantize colorspace reduce colors in this colorspace\n"
269  " -repage geometry size and location of an image canvas (operator)\n"
270  " -rotate degrees apply Paeth rotation to the image\n"
271  " -resize geometry resize the image\n"
272  " -sharpen geometry sharpen the image\n"
273  " -shave geometry shave pixels from the image edges\n"
274  " -stegano offset hide watermark within an image\n"
275  " -stereo geometry combine two image to create a stereo anaglyph\n"
276  " -strip strip image of all profiles and comments\n"
277  " -thumbnail geometry create a thumbnail of the image\n"
278  " -transform affine transform image\n"
279  " -type type image type\n"
280  " -unsharp geometry sharpen the image\n"
281  " -watermark geometry percent brightness and saturation of a watermark\n"
282  " -write filename write images to this file",
283  settings[] =
284  " -affine matrix affine transform matrix\n"
285  " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
286  " transparent, extract, background, or shape\n"
287  " -authenticate password\n"
288  " decipher image with this password\n"
289  " -blue-primary point chromaticity blue primary point\n"
290  " -colorspace type alternate image colorspace\n"
291  " -comment string annotate image with comment\n"
292  " -compose operator composite operator\n"
293  " -compress type type of pixel compression when writing the image\n"
294  " -define format:option\n"
295  " define one or more image format options\n"
296  " -depth value image depth\n"
297  " -density geometry horizontal and vertical density of the image\n"
298  " -display server get image or font from this X server\n"
299  " -dispose method layer disposal method\n"
300  " -dither method apply error diffusion to image\n"
301  " -encoding type text encoding type\n"
302  " -endian type endianness (MSB or LSB) of the image\n"
303  " -filter type use this filter when resizing an image\n"
304  " -font name render text with this font\n"
305  " -format \"string\" output formatted image characteristics\n"
306  " -gravity type which direction to gravitate towards\n"
307  " -green-primary point chromaticity green primary point\n"
308  " -interlace type type of image interlacing scheme\n"
309  " -interpolate method pixel color interpolation method\n"
310  " -label string assign a label to an image\n"
311  " -limit type value pixel cache resource limit\n"
312  " -matte store matte channel if the image has one\n"
313  " -monitor monitor progress\n"
314  " -page geometry size and location of an image canvas (setting)\n"
315  " -pointsize value font point size\n"
316  " -quality value JPEG/MIFF/PNG compression level\n"
317  " -quiet suppress all warning messages\n"
318  " -red-primary point chromaticity red primary point\n"
319  " -regard-warnings pay attention to warning messages\n"
320  " -respect-parentheses settings remain in effect until parenthesis boundary\n"
321  " -sampling-factor geometry\n"
322  " horizontal and vertical sampling factor\n"
323  " -scene value image scene number\n"
324  " -seed value seed a new sequence of pseudo-random numbers\n"
325  " -size geometry width and height of image\n"
326  " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
327  " -synchronize synchronize image to storage device\n"
328  " -taint declare the image as modified\n"
329  " -transparent-color color\n"
330  " transparent color\n"
331  " -treedepth value color tree depth\n"
332  " -tile repeat composite operation across and down image\n"
333  " -units type the units of image resolution\n"
334  " -verbose print detailed information about the image\n"
335  " -virtual-pixel method\n"
336  " virtual pixel access method\n"
337  " -white-point point chromaticity white point",
338  stack_operators[] =
339  " -swap indexes swap two images in the image sequence";
340 
341  ListMagickVersion(stdout);
342  (void) printf("Usage: %s [options ...] image [options ...] composite\n"
343  " [ [options ...] mask ] [options ...] composite\n",
344  GetClientName());
345  (void) printf("\nImage Settings:\n");
346  (void) puts(settings);
347  (void) printf("\nImage Operators:\n");
348  (void) puts(operators);
349  (void) printf("\nImage Stack Operators:\n");
350  (void) puts(stack_operators);
351  (void) printf("\nMiscellaneous Options:\n");
352  (void) puts(miscellaneous);
353  (void) printf(
354  "\nBy default, the image format of 'file' is determined by its magic\n");
355  (void) printf(
356  "number. To specify a particular image format, precede the filename\n");
357  (void) printf(
358  "with an image format name and a colon (i.e. ps:image) or specify the\n");
359  (void) printf(
360  "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
361  (void) printf("'-' for standard input or output.\n");
362  return(MagickFalse);
363 }
364 
365 static void GetCompositeOptions(const ImageInfo *image_info,
366  CompositeOptions *composite_options)
367 {
368  (void) image_info;
369  (void) memset(composite_options,0,sizeof(*composite_options));
370  composite_options->channel=DefaultChannels;
371  composite_options->compose=OverCompositeOp;
372 }
373 
374 static void RelinquishCompositeOptions(CompositeOptions *composite_options)
375 {
376  if (composite_options->compose_args != (char *) NULL)
377  composite_options->compose_args=(char *)
378  RelinquishMagickMemory(composite_options->compose_args);
379  if (composite_options->geometry != (char *) NULL)
380  composite_options->geometry=(char *)
381  RelinquishMagickMemory(composite_options->geometry);
382 }
383 
384 WandExport MagickBooleanType CompositeImageCommand(ImageInfo *image_info,
385  int argc,char **argv,char **metadata,ExceptionInfo *exception)
386 {
387 #define NotInitialized (unsigned int) (~0)
388 #define DestroyComposite() \
389 { \
390  RelinquishCompositeOptions(&composite_options); \
391  DestroyImageStack(); \
392  for (i=0; i < (ssize_t) argc; i++) \
393  argv[i]=DestroyString(argv[i]); \
394  argv=(char **) RelinquishMagickMemory(argv); \
395 }
396 #define ThrowCompositeException(asperity,tag,option) \
397 { \
398  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
399  option == (char *) NULL ? GetExceptionMessage(errno) : option); \
400  DestroyComposite(); \
401  return(MagickFalse); \
402 }
403 #define ThrowCompositeInvalidArgumentException(option,argument) \
404 { \
405  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
406  "InvalidArgument","'%s': %s",option,argument); \
407  DestroyComposite(); \
408  return(MagickFalse); \
409 }
410 
411  char
412  *filename,
413  *option;
414 
416  composite_options;
417 
418  const char
419  *format;
420 
421  Image
422  *composite_image,
423  *image,
424  *images,
425  *mask_image;
426 
427  ImageStack
428  image_stack[MaxImageStackDepth+1];
429 
430  MagickBooleanType
431  fire,
432  pend,
433  respect_parenthesis;
434 
435  MagickStatusType
436  status;
437 
438  register ssize_t
439  i;
440 
441  ssize_t
442  j,
443  k;
444 
445  /*
446  Set default.
447  */
448  assert(image_info != (ImageInfo *) NULL);
449  assert(image_info->signature == MagickCoreSignature);
450  if (image_info->debug != MagickFalse)
451  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
452  assert(exception != (ExceptionInfo *) NULL);
453  if (argc == 2)
454  {
455  option=argv[1];
456  if ((LocaleCompare("version",option+1) == 0) ||
457  (LocaleCompare("-version",option+1) == 0))
458  {
459  ListMagickVersion(stdout);
460  return(MagickTrue);
461  }
462  }
463  if (argc < 4)
464  return(CompositeUsage());
465  GetCompositeOptions(image_info,&composite_options);
466  filename=(char *) NULL;
467  format="%w,%h,%m";
468  j=1;
469  k=0;
470  NewImageStack();
471  option=(char *) NULL;
472  pend=MagickFalse;
473  respect_parenthesis=MagickFalse;
474  status=MagickTrue;
475  /*
476  Check command syntax.
477  */
478  composite_image=NewImageList();
479  image=NewImageList();
480  mask_image=NewImageList();
481  ReadCommandlLine(argc,&argv);
482  status=ExpandFilenames(&argc,&argv);
483  if (status == MagickFalse)
484  ThrowCompositeException(ResourceLimitError,"MemoryAllocationFailed",
485  GetExceptionMessage(errno));
486  for (i=1; i < (ssize_t) (argc-1); i++)
487  {
488  option=argv[i];
489  if (LocaleCompare(option,"(") == 0)
490  {
491  FireImageStack(MagickFalse,MagickTrue,pend);
492  if (k == MaxImageStackDepth)
493  ThrowCompositeException(OptionError,"ParenthesisNestedTooDeeply",
494  option);
495  PushImageStack();
496  continue;
497  }
498  if (LocaleCompare(option,")") == 0)
499  {
500  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
501  if (k == 0)
502  ThrowCompositeException(OptionError,"UnableToParseExpression",option);
503  PopImageStack();
504  continue;
505  }
506  if (IsCommandOption(option) == MagickFalse)
507  {
508  /*
509  Read input image.
510  */
511  FireImageStack(MagickFalse,MagickFalse,pend);
512  filename=argv[i];
513  if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
514  filename=argv[++i];
515  images=ReadImages(image_info,filename,exception);
516  status&=(images != (Image *) NULL) &&
517  (exception->severity < ErrorException);
518  if (images == (Image *) NULL)
519  continue;
520  AppendImageStack(images);
521  continue;
522  }
523  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
524  switch (*(option+1))
525  {
526  case 'a':
527  {
528  if (LocaleCompare("affine",option+1) == 0)
529  {
530  if (*option == '+')
531  break;
532  i++;
533  if (i == (ssize_t) argc)
534  ThrowCompositeException(OptionError,"MissingArgument",option);
535  if (IsGeometry(argv[i]) == MagickFalse)
537  break;
538  }
539  if (LocaleCompare("alpha",option+1) == 0)
540  {
541  ssize_t
542  type;
543 
544  if (*option == '+')
545  break;
546  i++;
547  if (i == (ssize_t) argc)
548  ThrowCompositeException(OptionError,"MissingArgument",option);
549  type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
550  if (type < 0)
551  ThrowCompositeException(OptionError,
552  "UnrecognizedAlphaChannelOption",argv[i]);
553  break;
554  }
555  if (LocaleCompare("authenticate",option+1) == 0)
556  {
557  if (*option == '+')
558  break;
559  i++;
560  if (i == (ssize_t) argc)
561  ThrowCompositeException(OptionError,"MissingArgument",option);
562  break;
563  }
564  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
565  }
566  case 'b':
567  {
568  if (LocaleCompare("background",option+1) == 0)
569  {
570  if (*option == '+')
571  break;
572  i++;
573  if (i == (ssize_t) argc)
574  ThrowCompositeException(OptionError,"MissingArgument",option);
575  break;
576  }
577  if (LocaleCompare("blend",option+1) == 0)
578  {
579  (void) CloneString(&composite_options.compose_args,(char *) NULL);
580  if (*option == '+')
581  break;
582  i++;
583  if (i == (ssize_t) argc)
584  ThrowCompositeException(OptionError,"MissingArgument",option);
585  if (IsGeometry(argv[i]) == MagickFalse)
587  (void) CloneString(&composite_options.compose_args,argv[i]);
588  composite_options.compose=BlendCompositeOp;
589  break;
590  }
591  if (LocaleCompare("blur",option+1) == 0)
592  {
593  (void) CloneString(&composite_options.compose_args,(char *) NULL);
594  if (*option == '+')
595  break;
596  i++;
597  if (i == (ssize_t) argc)
598  ThrowCompositeException(OptionError,"MissingArgument",option);
599  if (IsGeometry(argv[i]) == MagickFalse)
601  (void) CloneString(&composite_options.compose_args,argv[i]);
602  composite_options.compose=BlurCompositeOp;
603  break;
604  }
605  if (LocaleCompare("blue-primary",option+1) == 0)
606  {
607  if (*option == '+')
608  break;
609  i++;
610  if (i == (ssize_t) argc)
611  ThrowCompositeException(OptionError,"MissingArgument",option);
612  if (IsGeometry(argv[i]) == MagickFalse)
614  break;
615  }
616  if (LocaleCompare("border",option+1) == 0)
617  {
618  if (*option == '+')
619  break;
620  i++;
621  if (i == (ssize_t) argc)
622  ThrowCompositeException(OptionError,"MissingArgument",option);
623  if (IsGeometry(argv[i]) == MagickFalse)
625  break;
626  }
627  if (LocaleCompare("bordercolor",option+1) == 0)
628  {
629  if (*option == '+')
630  break;
631  i++;
632  if (i == (ssize_t) argc)
633  ThrowCompositeException(OptionError,"MissingArgument",option);
634  break;
635  }
636  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
637  }
638  case 'c':
639  {
640  if (LocaleCompare("cache",option+1) == 0)
641  {
642  if (*option == '+')
643  break;
644  i++;
645  if (i == (ssize_t) argc)
646  ThrowCompositeException(OptionError,"MissingArgument",option);
647  if (IsGeometry(argv[i]) == MagickFalse)
649  break;
650  }
651  if (LocaleCompare("channel",option+1) == 0)
652  {
653  ssize_t
654  channel;
655 
656  if (*option == '+')
657  {
658  composite_options.channel=DefaultChannels;
659  break;
660  }
661  i++;
662  if (i == (ssize_t) argc)
663  ThrowCompositeException(OptionError,"MissingArgument",option);
664  channel=ParseChannelOption(argv[i]);
665  if (channel < 0)
666  ThrowCompositeException(OptionError,"UnrecognizedChannelType",
667  argv[i]);
668  composite_options.channel=(ChannelType) channel;
669  break;
670  }
671  if (LocaleCompare("colors",option+1) == 0)
672  {
673  if (*option == '+')
674  break;
675  i++;
676  if (i == (ssize_t) argc)
677  ThrowCompositeException(OptionError,"MissingArgument",option);
678  if (IsGeometry(argv[i]) == MagickFalse)
680  break;
681  }
682  if (LocaleCompare("colorspace",option+1) == 0)
683  {
684  ssize_t
685  colorspace;
686 
687  if (*option == '+')
688  break;
689  i++;
690  if (i == (ssize_t) argc)
691  ThrowCompositeException(OptionError,"MissingArgument",option);
692  colorspace=ParseCommandOption(MagickColorspaceOptions,
693  MagickFalse,argv[i]);
694  if (colorspace < 0)
695  ThrowCompositeException(OptionError,"UnrecognizedColorspace",
696  argv[i]);
697  break;
698  }
699  if (LocaleCompare("comment",option+1) == 0)
700  {
701  if (*option == '+')
702  break;
703  i++;
704  if (i == (ssize_t) argc)
705  ThrowCompositeException(OptionError,"MissingArgument",option);
706  break;
707  }
708  if (LocaleCompare("compose",option+1) == 0)
709  {
710  ssize_t
711  compose;
712 
713  composite_options.compose=UndefinedCompositeOp;
714  if (*option == '+')
715  break;
716  i++;
717  if (i == (ssize_t) argc)
718  ThrowCompositeException(OptionError,"MissingArgument",option);
719  compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
720  argv[i]);
721  if (compose < 0)
722  ThrowCompositeException(OptionError,"UnrecognizedComposeOperator",
723  argv[i]);
724  composite_options.compose=(CompositeOperator) compose;
725  break;
726  }
727  if (LocaleCompare("compress",option+1) == 0)
728  {
729  ssize_t
730  compress;
731 
732  if (*option == '+')
733  break;
734  i++;
735  if (i == (ssize_t) argc)
736  ThrowCompositeException(OptionError,"MissingArgument",option);
737  compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
738  argv[i]);
739  if (compress < 0)
740  ThrowCompositeException(OptionError,
741  "UnrecognizedImageCompression",argv[i]);
742  break;
743  }
744  if (LocaleCompare("concurrent",option+1) == 0)
745  break;
746  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
747  }
748  case 'd':
749  {
750  if (LocaleCompare("debug",option+1) == 0)
751  {
752  ssize_t
753  event;
754 
755  if (*option == '+')
756  break;
757  i++;
758  if (i == (ssize_t) argc)
759  ThrowCompositeException(OptionError,"MissingArgument",option);
760  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
761  if (event < 0)
762  ThrowCompositeException(OptionError,"UnrecognizedEventType",
763  argv[i]);
764  (void) SetLogEventMask(argv[i]);
765  break;
766  }
767  if (LocaleCompare("decipher",option+1) == 0)
768  {
769  if (*option == '+')
770  break;
771  i++;
772  if (i == (ssize_t) argc)
773  ThrowCompositeException(OptionError,"MissingArgument",option);
774  break;
775  }
776  if (LocaleCompare("define",option+1) == 0)
777  {
778  i++;
779  if (i == (ssize_t) argc)
780  ThrowCompositeException(OptionError,"MissingArgument",option);
781  if (*option == '+')
782  {
783  const char
784  *define;
785 
786  define=GetImageOption(image_info,argv[i]);
787  if (define == (const char *) NULL)
788  ThrowCompositeException(OptionError,"NoSuchOption",argv[i]);
789  break;
790  }
791  break;
792  }
793  if (LocaleCompare("density",option+1) == 0)
794  {
795  if (*option == '+')
796  break;
797  i++;
798  if (i == (ssize_t) argc)
799  ThrowCompositeException(OptionError,"MissingArgument",option);
800  if (IsGeometry(argv[i]) == MagickFalse)
802  break;
803  }
804  if (LocaleCompare("depth",option+1) == 0)
805  {
806  if (*option == '+')
807  break;
808  i++;
809  if (i == (ssize_t) argc)
810  ThrowCompositeException(OptionError,"MissingArgument",option);
811  if (IsGeometry(argv[i]) == MagickFalse)
813  break;
814  }
815  if (LocaleCompare("displace",option+1) == 0)
816  {
817  (void) CloneString(&composite_options.compose_args,(char *) NULL);
818  if (*option == '+')
819  break;
820  i++;
821  if (i == (ssize_t) argc)
822  ThrowCompositeException(OptionError,"MissingArgument",option);
823  if (IsGeometry(argv[i]) == MagickFalse)
825  (void) CloneString(&composite_options.compose_args,argv[i]);
826  composite_options.compose=DisplaceCompositeOp;
827  break;
828  }
829  if (LocaleCompare("display",option+1) == 0)
830  {
831  if (*option == '+')
832  break;
833  i++;
834  if (i == (ssize_t) argc)
835  ThrowCompositeException(OptionError,"MissingArgument",option);
836  break;
837  }
838  if (LocaleCompare("dispose",option+1) == 0)
839  {
840  ssize_t
841  dispose;
842 
843  if (*option == '+')
844  break;
845  i++;
846  if (i == (ssize_t) argc)
847  ThrowCompositeException(OptionError,"MissingArgument",option);
848  dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
849  if (dispose < 0)
850  ThrowCompositeException(OptionError,"UnrecognizedDisposeMethod",
851  argv[i]);
852  break;
853  }
854  if (LocaleCompare("dissolve",option+1) == 0)
855  {
856  (void) CloneString(&composite_options.compose_args,(char *) NULL);
857  if (*option == '+')
858  break;
859  i++;
860  if (i == (ssize_t) argc)
861  ThrowCompositeException(OptionError,"MissingArgument",option);
862  if (IsGeometry(argv[i]) == MagickFalse)
864  (void) CloneString(&composite_options.compose_args,argv[i]);
865  composite_options.compose=DissolveCompositeOp;
866  break;
867  }
868  if (LocaleCompare("distort",option+1) == 0)
869  {
870  (void) CloneString(&composite_options.compose_args,(char *) NULL);
871  if (*option == '+')
872  break;
873  i++;
874  if (i == (ssize_t) argc)
875  ThrowCompositeException(OptionError,"MissingArgument",option);
876  if (IsGeometry(argv[i]) == MagickFalse)
878  (void) CloneString(&composite_options.compose_args,argv[i]);
879  composite_options.compose=DistortCompositeOp;
880  break;
881  }
882  if (LocaleCompare("dither",option+1) == 0)
883  {
884  ssize_t
885  method;
886 
887  if (*option == '+')
888  break;
889  i++;
890  if (i == (ssize_t) argc)
891  ThrowCompositeException(OptionError,"MissingArgument",option);
892  method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
893  if (method < 0)
894  ThrowCompositeException(OptionError,"UnrecognizedDitherMethod",
895  argv[i]);
896  break;
897  }
898  if (LocaleCompare("duration",option+1) == 0)
899  {
900  if (*option == '+')
901  break;
902  i++;
903  if (i == (ssize_t) argc)
904  ThrowCompositeException(OptionError,"MissingArgument",option);
905  if (IsGeometry(argv[i]) == MagickFalse)
907  break;
908  }
909  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
910  }
911  case 'e':
912  {
913  if (LocaleCompare("encipher",option+1) == 0)
914  {
915  if (*option == '+')
916  break;
917  i++;
918  if (i == (ssize_t) argc)
919  ThrowCompositeException(OptionError,"MissingArgument",option);
920  break;
921  }
922  if (LocaleCompare("encoding",option+1) == 0)
923  {
924  if (*option == '+')
925  break;
926  i++;
927  if (i == (ssize_t) argc)
928  ThrowCompositeException(OptionError,"MissingArgument",option);
929  break;
930  }
931  if (LocaleCompare("endian",option+1) == 0)
932  {
933  ssize_t
934  endian;
935 
936  if (*option == '+')
937  break;
938  i++;
939  if (i == (ssize_t) argc)
940  ThrowCompositeException(OptionError,"MissingArgument",option);
941  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
942  argv[i]);
943  if (endian < 0)
944  ThrowCompositeException(OptionError,"UnrecognizedEndianType",
945  argv[i]);
946  break;
947  }
948  if (LocaleCompare("extract",option+1) == 0)
949  {
950  if (*option == '+')
951  break;
952  i++;
953  if (i == (ssize_t) argc)
954  ThrowCompositeException(OptionError,"MissingArgument",option);
955  if (IsGeometry(argv[i]) == MagickFalse)
957  break;
958  }
959  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
960  }
961  case 'f':
962  {
963  if (LocaleCompare("filter",option+1) == 0)
964  {
965  ssize_t
966  filter;
967 
968  if (*option == '+')
969  break;
970  i++;
971  if (i == (ssize_t) argc)
972  ThrowCompositeException(OptionError,"MissingArgument",option);
973  filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
974  if (filter < 0)
975  ThrowCompositeException(OptionError,"UnrecognizedImageFilter",
976  argv[i]);
977  break;
978  }
979  if (LocaleCompare("font",option+1) == 0)
980  {
981  if (*option == '+')
982  break;
983  i++;
984  if (i == (ssize_t) argc)
985  ThrowCompositeException(OptionError,"MissingArgument",option);
986  break;
987  }
988  if (LocaleCompare("format",option+1) == 0)
989  {
990  if (*option == '+')
991  break;
992  i++;
993  if (i == (ssize_t) argc)
994  ThrowCompositeException(OptionError,"MissingArgument",option);
995  format=argv[i];
996  break;
997  }
998  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
999  }
1000  case 'g':
1001  {
1002  if (LocaleCompare("geometry",option+1) == 0)
1003  {
1004  (void) CloneString(&composite_options.geometry,(char *) NULL);
1005  if (*option == '+')
1006  break;
1007  i++;
1008  if (i == (ssize_t) argc)
1009  ThrowCompositeException(OptionError,"MissingArgument",option);
1010  if (IsGeometry(argv[i]) == MagickFalse)
1012  (void) CloneString(&composite_options.geometry,argv[i]);
1013  break;
1014  }
1015  if (LocaleCompare("gravity",option+1) == 0)
1016  {
1017  ssize_t
1018  gravity;
1019 
1020  composite_options.gravity=UndefinedGravity;
1021  if (*option == '+')
1022  break;
1023  i++;
1024  if (i == (ssize_t) argc)
1025  ThrowCompositeException(OptionError,"MissingArgument",option);
1026  gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1027  argv[i]);
1028  if (gravity < 0)
1029  ThrowCompositeException(OptionError,"UnrecognizedGravityType",
1030  argv[i]);
1031  composite_options.gravity=(GravityType) gravity;
1032  break;
1033  }
1034  if (LocaleCompare("green-primary",option+1) == 0)
1035  {
1036  if (*option == '+')
1037  break;
1038  i++;
1039  if (i == (ssize_t) argc)
1040  ThrowCompositeException(OptionError,"MissingArgument",option);
1041  if (IsGeometry(argv[i]) == MagickFalse)
1043  break;
1044  }
1045  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1046  }
1047  case 'h':
1048  {
1049  if ((LocaleCompare("help",option+1) == 0) ||
1050  (LocaleCompare("-help",option+1) == 0))
1051  return(CompositeUsage());
1052  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1053  }
1054  case 'i':
1055  {
1056  if (LocaleCompare("identify",option+1) == 0)
1057  break;
1058  if (LocaleCompare("interlace",option+1) == 0)
1059  {
1060  ssize_t
1061  interlace;
1062 
1063  if (*option == '+')
1064  break;
1065  i++;
1066  if (i == (ssize_t) argc)
1067  ThrowCompositeException(OptionError,"MissingArgument",option);
1068  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1069  argv[i]);
1070  if (interlace < 0)
1071  ThrowCompositeException(OptionError,
1072  "UnrecognizedInterlaceType",argv[i]);
1073  break;
1074  }
1075  if (LocaleCompare("interpolate",option+1) == 0)
1076  {
1077  ssize_t
1078  interpolate;
1079 
1080  if (*option == '+')
1081  break;
1082  i++;
1083  if (i == (ssize_t) argc)
1084  ThrowCompositeException(OptionError,"MissingArgument",option);
1085  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1086  argv[i]);
1087  if (interpolate < 0)
1088  ThrowCompositeException(OptionError,
1089  "UnrecognizedInterpolateMethod",argv[i]);
1090  break;
1091  }
1092  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1093  }
1094  case 'l':
1095  {
1096  if (LocaleCompare("label",option+1) == 0)
1097  {
1098  if (*option == '+')
1099  break;
1100  i++;
1101  if (i == (ssize_t) argc)
1102  ThrowCompositeException(OptionError,"MissingArgument",option);
1103  break;
1104  }
1105  if (LocaleCompare("limit",option+1) == 0)
1106  {
1107  char
1108  *p;
1109 
1110  double
1111  value;
1112 
1113  ssize_t
1114  resource;
1115 
1116  if (*option == '+')
1117  break;
1118  i++;
1119  if (i == (ssize_t) argc)
1120  ThrowCompositeException(OptionError,"MissingArgument",option);
1121  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1122  argv[i]);
1123  if (resource < 0)
1124  ThrowCompositeException(OptionError,"UnrecognizedResourceType",
1125  argv[i]);
1126  i++;
1127  if (i == (ssize_t) argc)
1128  ThrowCompositeException(OptionError,"MissingArgument",option);
1129  value=StringToDouble(argv[i],&p);
1130  (void) value;
1131  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1133  break;
1134  }
1135  if (LocaleCompare("list",option+1) == 0)
1136  {
1137  ssize_t
1138  list;
1139 
1140  if (*option == '+')
1141  break;
1142  i++;
1143  if (i == (ssize_t) argc)
1144  ThrowCompositeException(OptionError,"MissingArgument",option);
1145  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1146  if (list < 0)
1147  ThrowCompositeException(OptionError,"UnrecognizedListType",
1148  argv[i]);
1149  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1150  argv+j,exception);
1151  DestroyComposite();
1152  return(status == 0 ? MagickFalse : MagickTrue);
1153  }
1154  if (LocaleCompare("log",option+1) == 0)
1155  {
1156  if (*option == '+')
1157  break;
1158  i++;
1159  if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
1160  ThrowCompositeException(OptionError,"MissingArgument",option);
1161  break;
1162  }
1163  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1164  }
1165  case 'm':
1166  {
1167  if (LocaleCompare("matte",option+1) == 0)
1168  break;
1169  if (LocaleCompare("monitor",option+1) == 0)
1170  break;
1171  if (LocaleCompare("monochrome",option+1) == 0)
1172  break;
1173  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1174  }
1175  case 'n':
1176  {
1177  if (LocaleCompare("negate",option+1) == 0)
1178  break;
1179  if (LocaleCompare("noop",option+1) == 0)
1180  break;
1181  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1182  }
1183  case 'p':
1184  {
1185  if (LocaleCompare("page",option+1) == 0)
1186  {
1187  if (*option == '+')
1188  break;
1189  i++;
1190  if (i == (ssize_t) argc)
1191  ThrowCompositeException(OptionError,"MissingArgument",option);
1192  break;
1193  }
1194  if (LocaleCompare("pointsize",option+1) == 0)
1195  {
1196  if (*option == '+')
1197  break;
1198  i++;
1199  if (i == (ssize_t) argc)
1200  ThrowCompositeException(OptionError,"MissingArgument",option);
1201  if (IsGeometry(argv[i]) == MagickFalse)
1203  break;
1204  }
1205  if (LocaleCompare("process",option+1) == 0)
1206  {
1207  if (*option == '+')
1208  break;
1209  i++;
1210  if (i == (ssize_t) argc)
1211  ThrowCompositeException(OptionError,"MissingArgument",option);
1212  break;
1213  }
1214  if (LocaleCompare("profile",option+1) == 0)
1215  {
1216  i++;
1217  if (i == (ssize_t) argc)
1218  ThrowCompositeException(OptionError,"MissingArgument",option);
1219  break;
1220  }
1221  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1222  }
1223  case 'q':
1224  {
1225  if (LocaleCompare("quality",option+1) == 0)
1226  {
1227  if (*option == '+')
1228  break;
1229  i++;
1230  if (i == (ssize_t) argc)
1231  ThrowCompositeException(OptionError,"MissingArgument",option);
1232  if (IsGeometry(argv[i]) == MagickFalse)
1234  break;
1235  }
1236  if (LocaleCompare("quantize",option+1) == 0)
1237  {
1238  ssize_t
1239  colorspace;
1240 
1241  if (*option == '+')
1242  break;
1243  i++;
1244  if (i == (ssize_t) argc)
1245  ThrowCompositeException(OptionError,"MissingArgument",option);
1246  colorspace=ParseCommandOption(MagickColorspaceOptions,
1247  MagickFalse,argv[i]);
1248  if (colorspace < 0)
1249  ThrowCompositeException(OptionError,"UnrecognizedColorspace",
1250  argv[i]);
1251  break;
1252  }
1253  if (LocaleCompare("quiet",option+1) == 0)
1254  break;
1255  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1256  }
1257  case 'r':
1258  {
1259  if (LocaleCompare("red-primary",option+1) == 0)
1260  {
1261  if (*option == '+')
1262  break;
1263  i++;
1264  if (i == (ssize_t) argc)
1265  ThrowCompositeException(OptionError,"MissingArgument",option);
1266  if (IsGeometry(argv[i]) == MagickFalse)
1268  break;
1269  }
1270  if (LocaleCompare("regard-warnings",option+1) == 0)
1271  break;
1272  if (LocaleCompare("render",option+1) == 0)
1273  break;
1274  if (LocaleCompare("repage",option+1) == 0)
1275  {
1276  if (*option == '+')
1277  break;
1278  i++;
1279  if (i == (ssize_t) argc)
1280  ThrowCompositeException(OptionError,"MissingArgument",option);
1281  if (IsGeometry(argv[i]) == MagickFalse)
1283  break;
1284  }
1285  if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1286  {
1287  respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1288  break;
1289  }
1290  if (LocaleCompare("resize",option+1) == 0)
1291  {
1292  if (*option == '+')
1293  break;
1294  i++;
1295  if (i == (ssize_t) argc)
1296  ThrowCompositeException(OptionError,"MissingArgument",option);
1297  if (IsGeometry(argv[i]) == MagickFalse)
1299  break;
1300  }
1301  if (LocaleCompare("rotate",option+1) == 0)
1302  {
1303  i++;
1304  if (i == (ssize_t) argc)
1305  ThrowCompositeException(OptionError,"MissingArgument",option);
1306  if (IsGeometry(argv[i]) == MagickFalse)
1308  break;
1309  }
1310  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1311  }
1312  case 's':
1313  {
1314  if (LocaleCompare("sampling-factor",option+1) == 0)
1315  {
1316  if (*option == '+')
1317  break;
1318  i++;
1319  if (i == (ssize_t) argc)
1320  ThrowCompositeException(OptionError,"MissingArgument",option);
1321  if (IsGeometry(argv[i]) == MagickFalse)
1323  break;
1324  }
1325  if (LocaleCompare("scene",option+1) == 0)
1326  {
1327  if (*option == '+')
1328  break;
1329  i++;
1330  if (i == (ssize_t) argc)
1331  ThrowCompositeException(OptionError,"MissingArgument",option);
1332  if (IsGeometry(argv[i]) == MagickFalse)
1334  break;
1335  }
1336  if (LocaleCompare("seed",option+1) == 0)
1337  {
1338  if (*option == '+')
1339  break;
1340  i++;
1341  if (i == (ssize_t) argc)
1342  ThrowCompositeException(OptionError,"MissingArgument",option);
1343  if (IsGeometry(argv[i]) == MagickFalse)
1345  break;
1346  }
1347  if (LocaleCompare("sharpen",option+1) == 0)
1348  {
1349  i++;
1350  if (i == (ssize_t) argc)
1351  ThrowCompositeException(OptionError,"MissingArgument",option);
1352  if (IsGeometry(argv[i]) == MagickFalse)
1354  break;
1355  }
1356  if (LocaleCompare("shave",option+1) == 0)
1357  {
1358  if (*option == '+')
1359  break;
1360  i++;
1361  if (i == (ssize_t) argc)
1362  ThrowCompositeException(OptionError,"MissingArgument",option);
1363  if (IsGeometry(argv[i]) == MagickFalse)
1365  break;
1366  }
1367  if (LocaleCompare("size",option+1) == 0)
1368  {
1369  if (*option == '+')
1370  break;
1371  i++;
1372  if (i == (ssize_t) argc)
1373  ThrowCompositeException(OptionError,"MissingArgument",option);
1374  if (IsGeometry(argv[i]) == MagickFalse)
1376  break;
1377  }
1378  if (LocaleCompare("stegano",option+1) == 0)
1379  {
1380  composite_options.stegano=0;
1381  if (*option == '+')
1382  break;
1383  i++;
1384  if (i == (ssize_t) argc)
1385  ThrowCompositeException(OptionError,"MissingArgument",option);
1386  if (IsGeometry(argv[i]) == MagickFalse)
1388  composite_options.stegano=(ssize_t) StringToLong(argv[i])+1;
1389  break;
1390  }
1391  if (LocaleCompare("stereo",option+1) == 0)
1392  {
1393  MagickStatusType
1394  flags;
1395 
1396  composite_options.stereo=MagickFalse;
1397  if (*option == '+')
1398  break;
1399  i++;
1400  if (i == (ssize_t) argc)
1401  ThrowCompositeException(OptionError,"MissingArgument",option);
1402  if (IsGeometry(argv[i]) == MagickFalse)
1404  flags=ParseAbsoluteGeometry(argv[i],&composite_options.offset);
1405  if ((flags & YValue) == 0)
1406  composite_options.offset.y=composite_options.offset.x;
1407  composite_options.stereo=MagickTrue;
1408  break;
1409  }
1410  if (LocaleCompare("strip",option+1) == 0)
1411  break;
1412  if (LocaleCompare("support",option+1) == 0)
1413  {
1414  i++; /* deprecated */
1415  break;
1416  }
1417  if (LocaleCompare("swap",option+1) == 0)
1418  {
1419  if (*option == '+')
1420  break;
1421  i++;
1422  if (i == (ssize_t) argc)
1423  ThrowCompositeException(OptionError,"MissingArgument",option);
1424  if (IsGeometry(argv[i]) == MagickFalse)
1426  break;
1427  }
1428  if (LocaleCompare("synchronize",option+1) == 0)
1429  break;
1430  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1431  }
1432  case 't':
1433  {
1434  if (LocaleCompare("taint",option+1) == 0)
1435  break;
1436  if (LocaleCompare("thumbnail",option+1) == 0)
1437  {
1438  if (*option == '+')
1439  break;
1440  i++;
1441  if (i == (ssize_t) argc)
1442  ThrowCompositeException(OptionError,"MissingArgument",option);
1443  if (IsGeometry(argv[i]) == MagickFalse)
1445  break;
1446  }
1447  if (LocaleCompare("tile",option+1) == 0)
1448  {
1449  composite_options.tile=(*option == '-') ? MagickTrue : MagickFalse;
1450  (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1451  break;
1452  }
1453  if (LocaleCompare("transform",option+1) == 0)
1454  break;
1455  if (LocaleCompare("transparent-color",option+1) == 0)
1456  {
1457  if (*option == '+')
1458  break;
1459  i++;
1460  if (i == (ssize_t) argc)
1461  ThrowCompositeException(OptionError,"MissingArgument",option);
1462  break;
1463  }
1464  if (LocaleCompare("treedepth",option+1) == 0)
1465  {
1466  if (*option == '+')
1467  break;
1468  i++;
1469  if (i == (ssize_t) argc)
1470  ThrowCompositeException(OptionError,"MissingArgument",option);
1471  if (IsGeometry(argv[i]) == MagickFalse)
1473  break;
1474  }
1475  if (LocaleCompare("type",option+1) == 0)
1476  {
1477  ssize_t
1478  type;
1479 
1480  if (*option == '+')
1481  break;
1482  i++;
1483  if (i == (ssize_t) argc)
1484  ThrowCompositeException(OptionError,"MissingArgument",option);
1485  type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1486  if (type < 0)
1487  ThrowCompositeException(OptionError,"UnrecognizedImageType",
1488  argv[i]);
1489  break;
1490  }
1491  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1492  }
1493  case 'u':
1494  {
1495  if (LocaleCompare("units",option+1) == 0)
1496  {
1497  ssize_t
1498  units;
1499 
1500  if (*option == '+')
1501  break;
1502  i++;
1503  if (i == (ssize_t) argc)
1504  ThrowCompositeException(OptionError,"MissingArgument",option);
1505  units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1506  argv[i]);
1507  if (units < 0)
1508  ThrowCompositeException(OptionError,"UnrecognizedUnitsType",
1509  argv[i]);
1510  break;
1511  }
1512  if (LocaleCompare("unsharp",option+1) == 0)
1513  {
1514  (void) CloneString(&composite_options.compose_args,(char *) NULL);
1515  if (*option == '+')
1516  break;
1517  i++;
1518  if (i == (ssize_t) argc)
1519  ThrowCompositeException(OptionError,"MissingArgument",option);
1520  if (IsGeometry(argv[i]) == MagickFalse)
1522  (void) CloneString(&composite_options.compose_args,argv[i]);
1523  composite_options.compose=ThresholdCompositeOp;
1524  break;
1525  }
1526  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1527  }
1528  case 'v':
1529  {
1530  if (LocaleCompare("verbose",option+1) == 0)
1531  break;
1532  if ((LocaleCompare("version",option+1) == 0) ||
1533  (LocaleCompare("-version",option+1) == 0))
1534  {
1535  ListMagickVersion(stdout);
1536  break;
1537  }
1538  if (LocaleCompare("virtual-pixel",option+1) == 0)
1539  {
1540  ssize_t
1541  method;
1542 
1543  if (*option == '+')
1544  break;
1545  i++;
1546  if (i == (ssize_t) argc)
1547  ThrowCompositeException(OptionError,"MissingArgument",option);
1548  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1549  argv[i]);
1550  if (method < 0)
1551  ThrowCompositeException(OptionError,
1552  "UnrecognizedVirtualPixelMethod",argv[i]);
1553  break;
1554  }
1555  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1556  }
1557  case 'w':
1558  {
1559  if (LocaleCompare("watermark",option+1) == 0)
1560  {
1561  (void) CloneString(&composite_options.compose_args,(char *) NULL);
1562  if (*option == '+')
1563  break;
1564  i++;
1565  if (i == (ssize_t) argc)
1566  ThrowCompositeException(OptionError,"MissingArgument",option);
1567  if (IsGeometry(argv[i]) == MagickFalse)
1569  (void) CloneString(&composite_options.compose_args,argv[i]);
1570  composite_options.compose=ModulateCompositeOp;
1571  break;
1572  }
1573  if (LocaleCompare("white-point",option+1) == 0)
1574  {
1575  if (*option == '+')
1576  break;
1577  i++;
1578  if (i == (ssize_t) argc)
1579  ThrowCompositeException(OptionError,"MissingArgument",option);
1580  if (IsGeometry(argv[i]) == MagickFalse)
1582  break;
1583  }
1584  if (LocaleCompare("write",option+1) == 0)
1585  {
1586  i++;
1587  if (i == (ssize_t) argc)
1588  ThrowCompositeException(OptionError,"MissingArgument",option);
1589  break;
1590  }
1591  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1592  }
1593  case '?':
1594  break;
1595  default:
1596  ThrowCompositeException(OptionError,"UnrecognizedOption",option)
1597  }
1598  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1599  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1600  if (fire != MagickFalse)
1601  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1602  }
1603  if (k != 0)
1604  ThrowCompositeException(OptionError,"UnbalancedParenthesis",argv[i]);
1605  if (i-- != (ssize_t) (argc-1))
1606  ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[i]);
1607  if ((image == (Image *) NULL) || (GetImageListLength(image) < 2))
1608  ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1609  FinalizeImageSettings(image_info,image,MagickTrue);
1610  if ((image == (Image *) NULL) || (GetImageListLength(image) < 2))
1611  ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1612  /*
1613  Composite images.
1614  */
1615  RemoveImageStack(composite_image);
1616  RemoveImageStack(images);
1617  if (composite_image->geometry != (char *) NULL)
1618  {
1619  RectangleInfo
1620  resize_geometry;
1621 
1622  (void) ParseRegionGeometry(composite_image,composite_image->geometry,
1623  &resize_geometry,exception);
1624  if ((composite_image->columns != resize_geometry.width) ||
1625  (composite_image->rows != resize_geometry.height))
1626  {
1627  Image
1628  *resize_image;
1629 
1630  resize_image=ResizeImage(composite_image,resize_geometry.width,
1631  resize_geometry.height,composite_image->filter,exception);
1632  if (resize_image != (Image *) NULL)
1633  {
1634  composite_image=DestroyImage(composite_image);
1635  composite_image=resize_image;
1636  }
1637  }
1638  }
1639  RemoveImageStack(mask_image);
1640  if (mask_image != (Image *) NULL)
1641  {
1642  if ((composite_options.compose == DisplaceCompositeOp) ||
1643  (composite_options.compose == DistortCompositeOp))
1644  status&=CompositeImage(composite_image,mask_image,
1645  CopyGreenCompositeOp,MagickTrue,0,0,exception);
1646  else
1647  status&=CompositeImage(composite_image,mask_image,IntensityCompositeOp,
1648  MagickTrue,0,0,exception);
1649  mask_image=DestroyImage(mask_image);
1650  }
1651  status&=CompositeImageList(image_info,&images,composite_image,
1652  &composite_options,exception);
1653  composite_image=DestroyImage(composite_image);
1654  /*
1655  Write composite images.
1656  */
1657  status&=WriteImages(image_info,images,argv[argc-1],exception);
1658  if (metadata != (char **) NULL)
1659  {
1660  char
1661  *text;
1662 
1663  text=InterpretImageProperties(image_info,images,format,exception);
1664  if (text == (char *) NULL)
1665  ThrowCompositeException(ResourceLimitError,"MemoryAllocationFailed",
1666  GetExceptionMessage(errno));
1667  (void) ConcatenateString(&(*metadata),text);
1668  text=DestroyString(text);
1669  }
1670  images=DestroyImageList(images);
1671  RelinquishCompositeOptions(&composite_options);
1672  DestroyComposite();
1673  return(status != 0 ? MagickTrue : MagickFalse);
1674 }
#define FinalizeImageSettings(image_info, image, advance)
#define DestroyComposite()
#define NewImageStack()
#define WandExport
#define AppendImageStack(images)
GravityType gravity
Definition: composite.c:65
static MagickBooleanType CompositeUsage(void)
Definition: composite.c:242
char * compose_args
Definition: composite.c:58
#define RemoveImageStack(images)
#define ThrowCompositeInvalidArgumentException(option, argument)
WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, const int argc, const char **argv, ExceptionInfo *exception)
Definition: mogrify.c:6577
#define ThrowCompositeException(asperity, tag, option)
RectangleInfo offset
Definition: composite.c:71
MagickBooleanType stereo
Definition: composite.c:74
#define MagickPathExtent
static MagickBooleanType CompositeImageList(ImageInfo *image_info, Image **image, Image *composite_image, CompositeOptions *composite_options, ExceptionInfo *exception)
Definition: composite.c:112
struct _CompositeOptions CompositeOptions
MagickBooleanType tile
Definition: composite.c:74
#define ReadCommandlLine(argc, argv)
Definition: studio.h:254
MagickBooleanType clip_to_self
Definition: composite.c:74
ssize_t stegano
Definition: composite.c:68
CompositeOperator compose
Definition: composite.c:62
#define PopImageStack()
WandExport MagickBooleanType CompositeImageCommand(ImageInfo *image_info, int argc, char **argv, char **metadata, ExceptionInfo *exception)
Definition: composite.c:384
static void GetCompositeOptions(const ImageInfo *image_info, CompositeOptions *composite_options)
Definition: composite.c:365
ChannelType channel
Definition: composite.c:55
#define PushImageStack()
#define FireImageStack(postfix, advance, fire)
static void RelinquishCompositeOptions(CompositeOptions *composite_options)
Definition: composite.c:374
#define MaxImageStackDepth