43#include "MagickWand/studio.h"
44#include "MagickWand/MagickWand.h"
45#include "MagickWand/mogrify-private.h"
46#include "MagickCore/composite-private.h"
47#include "MagickCore/string-private.h"
112static MagickBooleanType CompositeImageList(ImageInfo *image_info,Image **image,
113 Image *composite_image,Image *mask_image,
CompositeOptions *composite_options,
114 ExceptionInfo *exception)
122 assert(image_info != (ImageInfo *) NULL);
123 assert(image_info->signature == MagickCoreSignature);
124 assert(image != (Image **) NULL);
125 assert((*image)->signature == MagickCoreSignature);
126 assert(exception != (ExceptionInfo *) NULL);
127 if (IsEventLogging() != MagickFalse)
128 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
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);
139 if (composite_image != (Image *) NULL)
144 channel_mask=SetImageChannelMask(composite_image,
145 composite_options->channel);
146 assert(composite_image->signature == MagickCoreSignature);
147 switch (composite_options->compose)
149 case BlendCompositeOp:
150 case BlurCompositeOp:
151 case DisplaceCompositeOp:
152 case DistortCompositeOp:
153 case DissolveCompositeOp:
154 case ModulateCompositeOp:
155 case SaliencyBlendCompositeOp:
156 case SeamlessBlendCompositeOp:
157 case ThresholdCompositeOp:
159 (void) SetImageArtifact(*image,
"compose:args",
160 composite_options->compose_args);
169 if (composite_options->stegano != 0)
174 (*image)->offset=composite_options->stegano-1;
175 stegano_image=SteganoImage(*image,composite_image,exception);
176 if (stegano_image != (Image *) NULL)
178 *image=DestroyImageList(*image);
179 *image=stegano_image;
183 if (composite_options->stereo != MagickFalse)
188 stereo_image=StereoAnaglyphImage(*image,composite_image,
189 composite_options->offset.x,composite_options->offset.y,
191 if (stereo_image != (Image *) NULL)
193 *image=DestroyImageList(*image);
198 if (composite_options->tile != MagickFalse)
210 columns=composite_image->columns;
211 for (y=0; y < (ssize_t) (*image)->rows; y+=(ssize_t) composite_image->rows)
212 for (x=0; x < (ssize_t) (*image)->columns; x+=(ssize_t) columns)
213 status&=(MagickStatusType) CompositeImage(*image,
214 composite_image,composite_options->compose,MagickTrue,x,y,
225 SetGeometry(*image,&geometry);
226 (void) ParseAbsoluteGeometry(composite_options->geometry,
228 geometry.width=composite_image->columns;
229 geometry.height=composite_image->rows;
230 GravityAdjustGeometry((*image)->columns,(*image)->rows,
231 composite_options->gravity, &geometry);
232 (*image)->gravity=(GravityType) composite_options->gravity;
236 if (mask_image == (Image *) NULL)
237 status&=(MagickStatusType) CompositeImage(*image,
238 composite_image,composite_options->compose,
239 composite_options->clip_to_self,geometry.x,geometry.y,
246 clone_image=CloneImage(*image,0,0,MagickTrue,exception);
247 if (clone_image != (Image *) NULL)
249 status&=(MagickStatusType) CompositeImage(*image,
250 composite_image,composite_options->compose,
251 composite_options->clip_to_self,geometry.x,geometry.y,
253 status&=(MagickStatusType) CompositeImage(*image,
254 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,
256 status&=(MagickStatusType) CompositeImage(clone_image,
257 *image,OverCompositeOp,composite_options->clip_to_self,
259 *image=DestroyImageList(*image);
264 (void) SetPixelChannelMask(composite_image,channel_mask);
266 return(status != 0 ? MagickTrue : MagickFalse);
269static MagickBooleanType CompositeUsage(
void)
273 " -debug events display copious debugging information\n"
274 " -help print program options\n"
275 " -list type print a list of supported option arguments\n"
276 " -log format format of debugging information\n"
277 " -version print version information",
279 " -blend geometry blend images\n"
280 " -border geometry surround image with a border of color\n"
281 " -bordercolor color border color\n"
282 " -channel mask set the image channel mask\n"
283 " -colors value preferred number of colors in the image\n"
284 " -decipher filename convert cipher pixels to plain pixels\n"
285 " -displace geometry shift lookup according to a relative displacement map\n"
286 " -dissolve value dissolve the two images a given percent\n"
287 " -distort geometry shift lookup according to a absolute distortion map\n"
288 " -encipher filename convert plain pixels to cipher pixels\n"
289 " -extract geometry extract area from image\n"
290 " -geometry geometry location of the composite image\n"
291 " -identify identify the format and characteristics of the image\n"
292 " -monochrome transform image to black and white\n"
293 " -negate replace every pixel with its complementary color \n"
294 " -profile filename add ICM or IPTC information profile to image\n"
295 " -quantize colorspace reduce colors in this colorspace\n"
296 " -repage geometry size and location of an image canvas (operator)\n"
297 " -rotate degrees apply Paeth rotation to the image\n"
298 " -resize geometry resize the image\n"
299 " -sharpen geometry sharpen the image\n"
300 " -shave geometry shave pixels from the image edges\n"
301 " -stegano offset hide watermark within an image\n"
302 " -stereo geometry combine two image to create a stereo anaglyph\n"
303 " -strip strip image of all profiles and comments\n"
304 " -thumbnail geometry create a thumbnail of the image\n"
305 " -transform affine transform image\n"
306 " -type type image type\n"
307 " -unsharp geometry sharpen the image\n"
308 " -watermark geometry percent brightness and saturation of a watermark\n"
309 " -write filename write images to this file",
311 " -affine matrix affine transform matrix\n"
312 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
313 " transparent, extract, background, or shape\n"
314 " -authenticate password\n"
315 " decipher image with this password\n"
316 " -blue-primary point chromaticity blue primary point\n"
317 " -colorspace type alternate image colorspace\n"
318 " -comment string annotate image with comment\n"
319 " -compose operator composite operator\n"
320 " -compress type type of pixel compression when writing the image\n"
321 " -define format:option\n"
322 " define one or more image format options\n"
323 " -depth value image depth\n"
324 " -density geometry horizontal and vertical density of the image\n"
325 " -display server get image or font from this X server\n"
326 " -dispose method layer disposal method\n"
327 " -dither method apply error diffusion to image\n"
328 " -encoding type text encoding type\n"
329 " -endian type endianness (MSB or LSB) of the image\n"
330 " -filter type use this filter when resizing an image\n"
331 " -font name render text with this font\n"
332 " -format \"string\" output formatted image characteristics\n"
333 " -gravity type which direction to gravitate towards\n"
334 " -green-primary point chromaticity green primary point\n"
335 " -interlace type type of image interlacing scheme\n"
336 " -interpolate method pixel color interpolation method\n"
337 " -label string assign a label to an image\n"
338 " -limit type value pixel cache resource limit\n"
339 " -matte store matte channel if the image has one\n"
340 " -monitor monitor progress\n"
341 " -page geometry size and location of an image canvas (setting)\n"
342 " -pointsize value font point size\n"
343 " -quality value JPEG/MIFF/PNG compression level\n"
344 " -quiet suppress all warning messages\n"
345 " -red-primary point chromaticity red primary point\n"
346 " -regard-warnings pay attention to warning messages\n"
347 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
348 " -sampling-factor geometry\n"
349 " horizontal and vertical sampling factor\n"
350 " -scene value image scene number\n"
351 " -seed value seed a new sequence of pseudo-random numbers\n"
352 " -size geometry width and height of image\n"
353 " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
354 " -synchronize synchronize image to storage device\n"
355 " -taint declare the image as modified\n"
356 " -transparent-color color\n"
357 " transparent color\n"
358 " -treedepth value color tree depth\n"
359 " -tile repeat composite operation across and down image\n"
360 " -units type the units of image resolution\n"
361 " -verbose print detailed information about the image\n"
362 " -virtual-pixel method\n"
363 " virtual pixel access method\n"
364 " -white-point point chromaticity white point",
366 " -swap indexes swap two images in the image sequence";
368 ListMagickVersion(stdout);
369 (void) printf(
"Usage: %s [options ...] image [options ...] composite\n"
370 " [ [options ...] mask ] [options ...] composite\n",
372 (void) printf(
"\nImage Settings:\n");
373 (void) puts(settings);
374 (void) printf(
"\nImage Operators:\n");
375 (void) puts(operators);
376 (void) printf(
"\nImage Stack Operators:\n");
377 (void) puts(stack_operators);
378 (void) printf(
"\nMiscellaneous Options:\n");
379 (void) puts(miscellaneous);
381 "\nBy default, the image format of 'file' is determined by its magic\n");
383 "number. To specify a particular image format, precede the filename\n");
385 "with an image format name and a colon (i.e. ps:image) or specify the\n");
387 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
388 (void) printf(
"'-' for standard input or output.\n");
392static void GetCompositeOptions(
const ImageInfo *image_info,
396 (void) memset(composite_options,0,
sizeof(*composite_options));
397 composite_options->channel=DefaultChannels;
398 composite_options->compose=OverCompositeOp;
403 if (composite_options->compose_args != (
char *) NULL)
404 composite_options->compose_args=(
char *)
405 RelinquishMagickMemory(composite_options->compose_args);
406 if (composite_options->geometry != (
char *) NULL)
407 composite_options->geometry=(
char *)
408 RelinquishMagickMemory(composite_options->geometry);
411WandExport MagickBooleanType CompositeImageCommand(ImageInfo *image_info,
412 int argc,
char **argv,
char **metadata,ExceptionInfo *exception)
414#define NotInitialized (unsigned int) (~0)
415#define DestroyComposite() \
417 RelinquishCompositeOptions(&composite_options); \
418 DestroyImageStack(); \
419 for (i=0; i < (ssize_t) argc; i++) \
420 argv[i]=DestroyString(argv[i]); \
421 argv=(char **) RelinquishMagickMemory(argv); \
423#define ThrowCompositeException(asperity,tag,option) \
425 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
426 option == (char *) NULL ? GetExceptionMessage(errno) : option); \
427 DestroyComposite(); \
428 return(MagickFalse); \
430#define ThrowCompositeInvalidArgumentException(option,argument) \
432 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
433 "InvalidArgument","'%s': %s",option,argument); \
434 DestroyComposite(); \
435 return(MagickFalse); \
455 image_stack[MaxImageStackDepth+1];
475 assert(image_info != (ImageInfo *) NULL);
476 assert(image_info->signature == MagickCoreSignature);
477 assert(exception != (ExceptionInfo *) NULL);
478 if (IsEventLogging() != MagickFalse)
479 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
483 if ((LocaleCompare(
"version",option+1) == 0) ||
484 (LocaleCompare(
"-version",option+1) == 0))
486 ListMagickVersion(stdout);
492 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
493 "MissingArgument",
"%s",
"");
494 (void) CompositeUsage();
497 GetCompositeOptions(image_info,&composite_options);
498 filename=(
char *) NULL;
503 option=(
char *) NULL;
505 respect_parentheses=MagickFalse;
510 composite_image=NewImageList();
511 image=NewImageList();
512 mask_image=NewImageList();
513 ReadCommandlLine(argc,&argv);
514 status=ExpandFilenames(&argc,&argv);
515 if (status == MagickFalse)
516 ThrowCompositeException(ResourceLimitError,
"MemoryAllocationFailed",
517 GetExceptionMessage(errno));
518 for (i=1; i < (ssize_t) (argc-1); i++)
521 if (LocaleCompare(option,
"(") == 0)
523 FireImageStack(MagickFalse,MagickTrue,pend);
524 if (k == MaxImageStackDepth)
525 ThrowCompositeException(OptionError,
"ParenthesisNestedTooDeeply",
530 if (LocaleCompare(option,
")") == 0)
532 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
534 ThrowCompositeException(OptionError,
"UnableToParseExpression",option);
538 if (IsCommandOption(option) == MagickFalse)
543 FireImageStack(MagickFalse,MagickFalse,pend);
545 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
547 images=ReadImages(image_info,filename,exception);
548 status&=(MagickStatusType) (images != (Image *) NULL) &&
549 (exception->severity < ErrorException);
550 if (images == (Image *) NULL)
552 AppendImageStack(images);
555 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
560 if (LocaleCompare(
"affine",option+1) == 0)
565 if (i == (ssize_t) argc)
566 ThrowCompositeException(OptionError,
"MissingArgument",option);
567 if (IsGeometry(argv[i]) == MagickFalse)
568 ThrowCompositeInvalidArgumentException(option,argv[i]);
571 if (LocaleCompare(
"alpha",option+1) == 0)
579 if (i == (ssize_t) argc)
580 ThrowCompositeException(OptionError,
"MissingArgument",option);
581 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
583 ThrowCompositeException(OptionError,
584 "UnrecognizedAlphaChannelOption",argv[i]);
587 if (LocaleCompare(
"authenticate",option+1) == 0)
592 if (i == (ssize_t) argc)
593 ThrowCompositeException(OptionError,
"MissingArgument",option);
596 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
600 if (LocaleCompare(
"background",option+1) == 0)
605 if (i == (ssize_t) argc)
606 ThrowCompositeException(OptionError,
"MissingArgument",option);
609 if (LocaleCompare(
"blend",option+1) == 0)
611 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
615 if (i == (ssize_t) argc)
616 ThrowCompositeException(OptionError,
"MissingArgument",option);
617 if (IsGeometry(argv[i]) == MagickFalse)
618 ThrowCompositeInvalidArgumentException(option,argv[i]);
619 (void) CloneString(&composite_options.compose_args,argv[i]);
620 composite_options.compose=BlendCompositeOp;
623 if (LocaleCompare(
"blur",option+1) == 0)
625 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
629 if (i == (ssize_t) argc)
630 ThrowCompositeException(OptionError,
"MissingArgument",option);
631 if (IsGeometry(argv[i]) == MagickFalse)
632 ThrowCompositeInvalidArgumentException(option,argv[i]);
633 (void) CloneString(&composite_options.compose_args,argv[i]);
634 composite_options.compose=BlurCompositeOp;
637 if (LocaleCompare(
"blue-primary",option+1) == 0)
642 if (i == (ssize_t) argc)
643 ThrowCompositeException(OptionError,
"MissingArgument",option);
644 if (IsGeometry(argv[i]) == MagickFalse)
645 ThrowCompositeInvalidArgumentException(option,argv[i]);
648 if (LocaleCompare(
"border",option+1) == 0)
653 if (i == (ssize_t) argc)
654 ThrowCompositeException(OptionError,
"MissingArgument",option);
655 if (IsGeometry(argv[i]) == MagickFalse)
656 ThrowCompositeInvalidArgumentException(option,argv[i]);
659 if (LocaleCompare(
"bordercolor",option+1) == 0)
664 if (i == (ssize_t) argc)
665 ThrowCompositeException(OptionError,
"MissingArgument",option);
668 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
672 if (LocaleCompare(
"cache",option+1) == 0)
677 if (i == (ssize_t) argc)
678 ThrowCompositeException(OptionError,
"MissingArgument",option);
679 if (IsGeometry(argv[i]) == MagickFalse)
680 ThrowCompositeInvalidArgumentException(option,argv[i]);
683 if (LocaleCompare(
"channel",option+1) == 0)
690 composite_options.channel=DefaultChannels;
694 if (i == (ssize_t) argc)
695 ThrowCompositeException(OptionError,
"MissingArgument",option);
696 channel=ParseChannelOption(argv[i]);
698 ThrowCompositeException(OptionError,
"UnrecognizedChannelType",
700 composite_options.channel=(ChannelType) channel;
703 if (LocaleCompare(
"colors",option+1) == 0)
708 if (i == (ssize_t) argc)
709 ThrowCompositeException(OptionError,
"MissingArgument",option);
710 if (IsGeometry(argv[i]) == MagickFalse)
711 ThrowCompositeInvalidArgumentException(option,argv[i]);
714 if (LocaleCompare(
"colorspace",option+1) == 0)
722 if (i == (ssize_t) argc)
723 ThrowCompositeException(OptionError,
"MissingArgument",option);
724 colorspace=ParseCommandOption(MagickColorspaceOptions,
725 MagickFalse,argv[i]);
727 ThrowCompositeException(OptionError,
"UnrecognizedColorspace",
731 if (LocaleCompare(
"comment",option+1) == 0)
736 if (i == (ssize_t) argc)
737 ThrowCompositeException(OptionError,
"MissingArgument",option);
740 if (LocaleCompare(
"compose",option+1) == 0)
745 composite_options.compose=UndefinedCompositeOp;
749 if (i == (ssize_t) argc)
750 ThrowCompositeException(OptionError,
"MissingArgument",option);
751 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
754 ThrowCompositeException(OptionError,
"UnrecognizedComposeOperator",
756 composite_options.compose=(CompositeOperator) compose;
759 if (LocaleCompare(
"compress",option+1) == 0)
767 if (i == (ssize_t) argc)
768 ThrowCompositeException(OptionError,
"MissingArgument",option);
769 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
772 ThrowCompositeException(OptionError,
773 "UnrecognizedImageCompression",argv[i]);
776 if (LocaleCompare(
"concurrent",option+1) == 0)
778 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
782 if (LocaleCompare(
"debug",option+1) == 0)
790 if (i == (ssize_t) argc)
791 ThrowCompositeException(OptionError,
"MissingArgument",option);
792 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
794 ThrowCompositeException(OptionError,
"UnrecognizedEventType",
796 (void) SetLogEventMask(argv[i]);
799 if (LocaleCompare(
"decipher",option+1) == 0)
804 if (i == (ssize_t) argc)
805 ThrowCompositeException(OptionError,
"MissingArgument",option);
808 if (LocaleCompare(
"define",option+1) == 0)
811 if (i == (ssize_t) argc)
812 ThrowCompositeException(OptionError,
"MissingArgument",option);
818 define=GetImageOption(image_info,argv[i]);
819 if (define == (
const char *) NULL)
820 ThrowCompositeException(OptionError,
"NoSuchOption",argv[i]);
825 if (LocaleCompare(
"density",option+1) == 0)
830 if (i == (ssize_t) argc)
831 ThrowCompositeException(OptionError,
"MissingArgument",option);
832 if (IsGeometry(argv[i]) == MagickFalse)
833 ThrowCompositeInvalidArgumentException(option,argv[i]);
836 if (LocaleCompare(
"depth",option+1) == 0)
841 if (i == (ssize_t) argc)
842 ThrowCompositeException(OptionError,
"MissingArgument",option);
843 if (IsGeometry(argv[i]) == MagickFalse)
844 ThrowCompositeInvalidArgumentException(option,argv[i]);
847 if (LocaleCompare(
"displace",option+1) == 0)
849 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
853 if (i == (ssize_t) argc)
854 ThrowCompositeException(OptionError,
"MissingArgument",option);
855 if (IsGeometry(argv[i]) == MagickFalse)
856 ThrowCompositeInvalidArgumentException(option,argv[i]);
857 (void) CloneString(&composite_options.compose_args,argv[i]);
858 composite_options.compose=DisplaceCompositeOp;
861 if (LocaleCompare(
"display",option+1) == 0)
866 if (i == (ssize_t) argc)
867 ThrowCompositeException(OptionError,
"MissingArgument",option);
870 if (LocaleCompare(
"dispose",option+1) == 0)
878 if (i == (ssize_t) argc)
879 ThrowCompositeException(OptionError,
"MissingArgument",option);
880 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
882 ThrowCompositeException(OptionError,
"UnrecognizedDisposeMethod",
886 if (LocaleCompare(
"dissolve",option+1) == 0)
888 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
892 if (i == (ssize_t) argc)
893 ThrowCompositeException(OptionError,
"MissingArgument",option);
894 if (IsGeometry(argv[i]) == MagickFalse)
895 ThrowCompositeInvalidArgumentException(option,argv[i]);
896 (void) CloneString(&composite_options.compose_args,argv[i]);
897 composite_options.compose=DissolveCompositeOp;
900 if (LocaleCompare(
"distort",option+1) == 0)
902 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
906 if (i == (ssize_t) argc)
907 ThrowCompositeException(OptionError,
"MissingArgument",option);
908 if (IsGeometry(argv[i]) == MagickFalse)
909 ThrowCompositeInvalidArgumentException(option,argv[i]);
910 (void) CloneString(&composite_options.compose_args,argv[i]);
911 composite_options.compose=DistortCompositeOp;
914 if (LocaleCompare(
"dither",option+1) == 0)
922 if (i == (ssize_t) argc)
923 ThrowCompositeException(OptionError,
"MissingArgument",option);
924 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
926 ThrowCompositeException(OptionError,
"UnrecognizedDitherMethod",
930 if (LocaleCompare(
"duration",option+1) == 0)
935 if (i == (ssize_t) argc)
936 ThrowCompositeException(OptionError,
"MissingArgument",option);
937 if (IsGeometry(argv[i]) == MagickFalse)
938 ThrowCompositeInvalidArgumentException(option,argv[i]);
941 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
945 if (LocaleCompare(
"encipher",option+1) == 0)
950 if (i == (ssize_t) argc)
951 ThrowCompositeException(OptionError,
"MissingArgument",option);
954 if (LocaleCompare(
"encoding",option+1) == 0)
959 if (i == (ssize_t) argc)
960 ThrowCompositeException(OptionError,
"MissingArgument",option);
963 if (LocaleCompare(
"endian",option+1) == 0)
971 if (i == (ssize_t) argc)
972 ThrowCompositeException(OptionError,
"MissingArgument",option);
973 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
976 ThrowCompositeException(OptionError,
"UnrecognizedEndianType",
980 if (LocaleCompare(
"extract",option+1) == 0)
985 if (i == (ssize_t) argc)
986 ThrowCompositeException(OptionError,
"MissingArgument",option);
987 if (IsGeometry(argv[i]) == MagickFalse)
988 ThrowCompositeInvalidArgumentException(option,argv[i]);
991 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
995 if (LocaleCompare(
"filter",option+1) == 0)
1003 if (i == (ssize_t) argc)
1004 ThrowCompositeException(OptionError,
"MissingArgument",option);
1005 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
1007 ThrowCompositeException(OptionError,
"UnrecognizedImageFilter",
1011 if (LocaleCompare(
"font",option+1) == 0)
1016 if (i == (ssize_t) argc)
1017 ThrowCompositeException(OptionError,
"MissingArgument",option);
1020 if (LocaleCompare(
"format",option+1) == 0)
1025 if (i == (ssize_t) argc)
1026 ThrowCompositeException(OptionError,
"MissingArgument",option);
1030 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1034 if (LocaleCompare(
"geometry",option+1) == 0)
1036 (void) CloneString(&composite_options.geometry,(
char *) NULL);
1040 if (i == (ssize_t) argc)
1041 ThrowCompositeException(OptionError,
"MissingArgument",option);
1042 if (IsGeometry(argv[i]) == MagickFalse)
1043 ThrowCompositeInvalidArgumentException(option,argv[i]);
1044 (void) CloneString(&composite_options.geometry,argv[i]);
1047 if (LocaleCompare(
"gravity",option+1) == 0)
1052 composite_options.gravity=UndefinedGravity;
1056 if (i == (ssize_t) argc)
1057 ThrowCompositeException(OptionError,
"MissingArgument",option);
1058 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1061 ThrowCompositeException(OptionError,
"UnrecognizedGravityType",
1063 composite_options.gravity=(GravityType) gravity;
1066 if (LocaleCompare(
"green-primary",option+1) == 0)
1071 if (i == (ssize_t) argc)
1072 ThrowCompositeException(OptionError,
"MissingArgument",option);
1073 if (IsGeometry(argv[i]) == MagickFalse)
1074 ThrowCompositeInvalidArgumentException(option,argv[i]);
1077 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1081 if ((LocaleCompare(
"help",option+1) == 0) ||
1082 (LocaleCompare(
"-help",option+1) == 0))
1085 return(CompositeUsage());
1087 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1091 if (LocaleCompare(
"identify",option+1) == 0)
1093 if (LocaleCompare(
"interlace",option+1) == 0)
1101 if (i == (ssize_t) argc)
1102 ThrowCompositeException(OptionError,
"MissingArgument",option);
1103 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1106 ThrowCompositeException(OptionError,
1107 "UnrecognizedInterlaceType",argv[i]);
1110 if (LocaleCompare(
"interpolate",option+1) == 0)
1118 if (i == (ssize_t) argc)
1119 ThrowCompositeException(OptionError,
"MissingArgument",option);
1120 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1122 if (interpolate < 0)
1123 ThrowCompositeException(OptionError,
1124 "UnrecognizedInterpolateMethod",argv[i]);
1127 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1131 if (LocaleCompare(
"label",option+1) == 0)
1136 if (i == (ssize_t) argc)
1137 ThrowCompositeException(OptionError,
"MissingArgument",option);
1140 if (LocaleCompare(
"limit",option+1) == 0)
1154 if (i == (ssize_t) argc)
1155 ThrowCompositeException(OptionError,
"MissingArgument",option);
1156 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1159 ThrowCompositeException(OptionError,
"UnrecognizedResourceType",
1162 if (i == (ssize_t) argc)
1163 ThrowCompositeException(OptionError,
"MissingArgument",option);
1164 value=StringToDouble(argv[i],&p);
1166 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
1167 ThrowCompositeInvalidArgumentException(option,argv[i]);
1170 if (LocaleCompare(
"list",option+1) == 0)
1178 if (i == (ssize_t) argc)
1179 ThrowCompositeException(OptionError,
"MissingArgument",option);
1180 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1182 ThrowCompositeException(OptionError,
"UnrecognizedListType",
1184 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
1187 return(status == 0 ? MagickFalse : MagickTrue);
1189 if (LocaleCompare(
"log",option+1) == 0)
1194 if ((i == (ssize_t) argc) || (strchr(argv[i],
'%') == (
char *) NULL))
1195 ThrowCompositeException(OptionError,
"MissingArgument",option);
1198 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1202 if (LocaleCompare(
"matte",option+1) == 0)
1204 if (LocaleCompare(
"monitor",option+1) == 0)
1206 if (LocaleCompare(
"monochrome",option+1) == 0)
1208 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1212 if (LocaleCompare(
"negate",option+1) == 0)
1214 if (LocaleCompare(
"noop",option+1) == 0)
1216 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1220 if (LocaleCompare(
"page",option+1) == 0)
1225 if (i == (ssize_t) argc)
1226 ThrowCompositeException(OptionError,
"MissingArgument",option);
1229 if (LocaleCompare(
"pointsize",option+1) == 0)
1234 if (i == (ssize_t) argc)
1235 ThrowCompositeException(OptionError,
"MissingArgument",option);
1236 if (IsGeometry(argv[i]) == MagickFalse)
1237 ThrowCompositeInvalidArgumentException(option,argv[i]);
1240 if (LocaleCompare(
"process",option+1) == 0)
1245 if (i == (ssize_t) argc)
1246 ThrowCompositeException(OptionError,
"MissingArgument",option);
1249 if (LocaleCompare(
"profile",option+1) == 0)
1252 if (i == (ssize_t) argc)
1253 ThrowCompositeException(OptionError,
"MissingArgument",option);
1256 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1260 if (LocaleCompare(
"quality",option+1) == 0)
1265 if (i == (ssize_t) argc)
1266 ThrowCompositeException(OptionError,
"MissingArgument",option);
1267 if (IsGeometry(argv[i]) == MagickFalse)
1268 ThrowCompositeInvalidArgumentException(option,argv[i]);
1271 if (LocaleCompare(
"quantize",option+1) == 0)
1279 if (i == (ssize_t) argc)
1280 ThrowCompositeException(OptionError,
"MissingArgument",option);
1281 colorspace=ParseCommandOption(MagickColorspaceOptions,
1282 MagickFalse,argv[i]);
1284 ThrowCompositeException(OptionError,
"UnrecognizedColorspace",
1288 if (LocaleCompare(
"quiet",option+1) == 0)
1290 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1294 if (LocaleCompare(
"red-primary",option+1) == 0)
1299 if (i == (ssize_t) argc)
1300 ThrowCompositeException(OptionError,
"MissingArgument",option);
1301 if (IsGeometry(argv[i]) == MagickFalse)
1302 ThrowCompositeInvalidArgumentException(option,argv[i]);
1305 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1307 if (LocaleCompare(
"render",option+1) == 0)
1309 if (LocaleCompare(
"repage",option+1) == 0)
1314 if (i == (ssize_t) argc)
1315 ThrowCompositeException(OptionError,
"MissingArgument",option);
1316 if (IsGeometry(argv[i]) == MagickFalse)
1317 ThrowCompositeInvalidArgumentException(option,argv[i]);
1320 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
1322 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
1325 if (LocaleCompare(
"resize",option+1) == 0)
1330 if (i == (ssize_t) argc)
1331 ThrowCompositeException(OptionError,
"MissingArgument",option);
1332 if (IsGeometry(argv[i]) == MagickFalse)
1333 ThrowCompositeInvalidArgumentException(option,argv[i]);
1336 if (LocaleCompare(
"rotate",option+1) == 0)
1339 if (i == (ssize_t) argc)
1340 ThrowCompositeException(OptionError,
"MissingArgument",option);
1341 if (IsGeometry(argv[i]) == MagickFalse)
1342 ThrowCompositeInvalidArgumentException(option,argv[i]);
1345 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1349 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1354 if (i == (ssize_t) argc)
1355 ThrowCompositeException(OptionError,
"MissingArgument",option);
1356 if (IsGeometry(argv[i]) == MagickFalse)
1357 ThrowCompositeInvalidArgumentException(option,argv[i]);
1360 if (LocaleCompare(
"scene",option+1) == 0)
1365 if (i == (ssize_t) argc)
1366 ThrowCompositeException(OptionError,
"MissingArgument",option);
1367 if (IsGeometry(argv[i]) == MagickFalse)
1368 ThrowCompositeInvalidArgumentException(option,argv[i]);
1371 if (LocaleCompare(
"seed",option+1) == 0)
1376 if (i == (ssize_t) argc)
1377 ThrowCompositeException(OptionError,
"MissingArgument",option);
1378 if (IsGeometry(argv[i]) == MagickFalse)
1379 ThrowCompositeInvalidArgumentException(option,argv[i]);
1382 if (LocaleCompare(
"sharpen",option+1) == 0)
1385 if (i == (ssize_t) argc)
1386 ThrowCompositeException(OptionError,
"MissingArgument",option);
1387 if (IsGeometry(argv[i]) == MagickFalse)
1388 ThrowCompositeInvalidArgumentException(option,argv[i]);
1391 if (LocaleCompare(
"shave",option+1) == 0)
1396 if (i == (ssize_t) argc)
1397 ThrowCompositeException(OptionError,
"MissingArgument",option);
1398 if (IsGeometry(argv[i]) == MagickFalse)
1399 ThrowCompositeInvalidArgumentException(option,argv[i]);
1402 if (LocaleCompare(
"size",option+1) == 0)
1407 if (i == (ssize_t) argc)
1408 ThrowCompositeException(OptionError,
"MissingArgument",option);
1409 if (IsGeometry(argv[i]) == MagickFalse)
1410 ThrowCompositeInvalidArgumentException(option,argv[i]);
1413 if (LocaleCompare(
"stegano",option+1) == 0)
1415 composite_options.stegano=0;
1419 if (i == (ssize_t) argc)
1420 ThrowCompositeException(OptionError,
"MissingArgument",option);
1421 if (IsGeometry(argv[i]) == MagickFalse)
1422 ThrowCompositeInvalidArgumentException(option,argv[i]);
1423 composite_options.stegano=(ssize_t) StringToLong(argv[i])+1;
1426 if (LocaleCompare(
"stereo",option+1) == 0)
1431 composite_options.stereo=MagickFalse;
1435 if (i == (ssize_t) argc)
1436 ThrowCompositeException(OptionError,
"MissingArgument",option);
1437 if (IsGeometry(argv[i]) == MagickFalse)
1438 ThrowCompositeInvalidArgumentException(option,argv[i]);
1439 flags=ParseAbsoluteGeometry(argv[i],&composite_options.offset);
1440 if ((flags & YValue) == 0)
1441 composite_options.offset.y=composite_options.offset.x;
1442 composite_options.stereo=MagickTrue;
1445 if (LocaleCompare(
"strip",option+1) == 0)
1447 if (LocaleCompare(
"support",option+1) == 0)
1452 if (LocaleCompare(
"swap",option+1) == 0)
1457 if (i == (ssize_t) argc)
1458 ThrowCompositeException(OptionError,
"MissingArgument",option);
1459 if (IsGeometry(argv[i]) == MagickFalse)
1460 ThrowCompositeInvalidArgumentException(option,argv[i]);
1463 if (LocaleCompare(
"synchronize",option+1) == 0)
1465 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1469 if (LocaleCompare(
"taint",option+1) == 0)
1471 if (LocaleCompare(
"thumbnail",option+1) == 0)
1476 if (i == (ssize_t) argc)
1477 ThrowCompositeException(OptionError,
"MissingArgument",option);
1478 if (IsGeometry(argv[i]) == MagickFalse)
1479 ThrowCompositeInvalidArgumentException(option,argv[i]);
1482 if (LocaleCompare(
"tile",option+1) == 0)
1484 composite_options.tile=(*option ==
'-') ? MagickTrue : MagickFalse;
1485 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
1488 if (LocaleCompare(
"transform",option+1) == 0)
1490 if (LocaleCompare(
"transparent-color",option+1) == 0)
1495 if (i == (ssize_t) argc)
1496 ThrowCompositeException(OptionError,
"MissingArgument",option);
1499 if (LocaleCompare(
"treedepth",option+1) == 0)
1504 if (i == (ssize_t) argc)
1505 ThrowCompositeException(OptionError,
"MissingArgument",option);
1506 if (IsGeometry(argv[i]) == MagickFalse)
1507 ThrowCompositeInvalidArgumentException(option,argv[i]);
1510 if (LocaleCompare(
"type",option+1) == 0)
1518 if (i == (ssize_t) argc)
1519 ThrowCompositeException(OptionError,
"MissingArgument",option);
1520 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1522 ThrowCompositeException(OptionError,
"UnrecognizedImageType",
1526 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1530 if (LocaleCompare(
"units",option+1) == 0)
1538 if (i == (ssize_t) argc)
1539 ThrowCompositeException(OptionError,
"MissingArgument",option);
1540 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1543 ThrowCompositeException(OptionError,
"UnrecognizedUnitsType",
1547 if (LocaleCompare(
"unsharp",option+1) == 0)
1549 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
1553 if (i == (ssize_t) argc)
1554 ThrowCompositeException(OptionError,
"MissingArgument",option);
1555 if (IsGeometry(argv[i]) == MagickFalse)
1556 ThrowCompositeInvalidArgumentException(option,argv[i]);
1557 (void) CloneString(&composite_options.compose_args,argv[i]);
1558 composite_options.compose=ThresholdCompositeOp;
1561 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1565 if (LocaleCompare(
"verbose",option+1) == 0)
1567 if ((LocaleCompare(
"version",option+1) == 0) ||
1568 (LocaleCompare(
"-version",option+1) == 0))
1570 ListMagickVersion(stdout);
1573 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1581 if (i == (ssize_t) argc)
1582 ThrowCompositeException(OptionError,
"MissingArgument",option);
1583 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1586 ThrowCompositeException(OptionError,
1587 "UnrecognizedVirtualPixelMethod",argv[i]);
1590 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1594 if (LocaleCompare(
"watermark",option+1) == 0)
1596 (void) CloneString(&composite_options.compose_args,(
char *) NULL);
1600 if (i == (ssize_t) argc)
1601 ThrowCompositeException(OptionError,
"MissingArgument",option);
1602 if (IsGeometry(argv[i]) == MagickFalse)
1603 ThrowCompositeInvalidArgumentException(option,argv[i]);
1604 (void) CloneString(&composite_options.compose_args,argv[i]);
1605 composite_options.compose=ModulateCompositeOp;
1608 if (LocaleCompare(
"white-point",option+1) == 0)
1613 if (i == (ssize_t) argc)
1614 ThrowCompositeException(OptionError,
"MissingArgument",option);
1615 if (IsGeometry(argv[i]) == MagickFalse)
1616 ThrowCompositeInvalidArgumentException(option,argv[i]);
1619 if (LocaleCompare(
"write",option+1) == 0)
1622 if (i == (ssize_t) argc)
1623 ThrowCompositeException(OptionError,
"MissingArgument",option);
1626 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1631 ThrowCompositeException(OptionError,
"UnrecognizedOption",option)
1633 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1634 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1635 if (fire != MagickFalse)
1636 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1639 ThrowCompositeException(OptionError,
"UnbalancedParenthesis",argv[i]);
1640 if (i-- != (ssize_t) (argc-1))
1641 ThrowCompositeException(OptionError,
"MissingAnImageFilename",argv[i]);
1642 if ((image == (Image *) NULL) || (GetImageListLength(image) < 2))
1643 ThrowCompositeException(OptionError,
"MissingAnImageFilename",argv[argc-1]);
1644 FinalizeImageSettings(image_info,image,MagickTrue);
1645 if ((image == (Image *) NULL) || (GetImageListLength(image) < 2))
1646 ThrowCompositeException(OptionError,
"MissingAnImageFilename",argv[argc-1]);
1650 RemoveImageStack(composite_image);
1651 RemoveImageStack(images);
1652 if (composite_image->geometry != (
char *) NULL)
1657 (void) ParseRegionGeometry(composite_image,composite_image->geometry,
1658 &resize_geometry,exception);
1659 if ((composite_image->columns != resize_geometry.width) ||
1660 (composite_image->rows != resize_geometry.height))
1665 resize_image=ResizeImage(composite_image,resize_geometry.width,
1666 resize_geometry.height,composite_image->filter,exception);
1667 if (resize_image != (Image *) NULL)
1669 composite_image=DestroyImage(composite_image);
1670 composite_image=resize_image;
1674 RemoveImageStack(mask_image);
1675 status&=(MagickStatusType) CompositeImageList(image_info,&images,
1676 composite_image,mask_image,&composite_options,exception);
1677 composite_image=DestroyImage(composite_image);
1681 status&=(MagickStatusType) WriteImages(image_info,images,argv[argc-1],
1683 if (metadata != (
char **) NULL)
1688 text=InterpretImageProperties(image_info,images,format,exception);
1689 if (text == (
char *) NULL)
1690 ThrowCompositeException(ResourceLimitError,
"MemoryAllocationFailed",
1691 GetExceptionMessage(errno));
1692 (void) ConcatenateString(&(*metadata),text);
1693 text=DestroyString(text);
1695 images=DestroyImageList(images);
1696 RelinquishCompositeOptions(&composite_options);
1698 return(status != 0 ? MagickTrue : MagickFalse);