53#include "MagickWand/studio.h"
54#include "MagickWand/MagickWand.h"
55#include "MagickWand/magick-wand-private.h"
56#include "MagickWand/mogrify.h"
57#include "MagickWand/operation.h"
58#include "MagickWand/wand.h"
59#include "MagickWand/wandcli.h"
60#include "MagickWand/wandcli-private.h"
61#include "MagickCore/color-private.h"
62#include "MagickCore/composite-private.h"
63#include "MagickCore/geometry-private.h"
64#include "MagickCore/image-private.h"
65#include "MagickCore/monitor-private.h"
66#include "MagickCore/string-private.h"
67#include "MagickCore/thread-private.h"
68#include "MagickCore/timer-private.h"
74 MogrifyAlphaColor[] =
"#bdbdbd",
75 MogrifyBackgroundColor[] =
"#fff",
76 MogrifyBorderColor[] =
"#dfdfdf";
81#define USE_WAND_METHODS 1
82#define MAX_STACK_DEPTH 32
83#define UNDEFINED_COMPRESSION_QUALITY 0UL
86#define DEFAULT_DISSIMILARITY_THRESHOLD "0.31830988618379067154"
89#define ReportGeometry(flags,info) \
90 (void) FormatLocaleFile(stderr, "Geometry = 0x%04X : %lg x %lg %+lg %+lg\n", \
91 flags, info.rho, info.sigma, info.xi, info.psi )
96static MagickBooleanType MonitorProgress(
const char *text,
97 const MagickOffsetType offset,
const MagickSizeType extent,
98 void *wand_unused(client_data))
101 message[MagickPathExtent],
102 tag[MagickPathExtent];
110 magick_unreferenced(client_data);
112 (void) CopyMagickString(tag,text == (
const char *) NULL ?
"null" : text,
115 if (p != (
char *) NULL)
117 (void) FormatLocaleString(message,MagickPathExtent,
"Monitor/%s",tag);
118 locale_message=GetLocaleMessage(message);
119 if (locale_message == message)
121 if (p == (
char *) NULL)
122 (void) FormatLocaleFile(stderr,
"%s: %ld of %lu, %02ld%% complete\r",
123 locale_message,(
long) offset,(
unsigned long) extent,(
long)
124 (100.0*offset*MagickSafeReciprocal((
double) extent-1.0)));
126 (
void) FormatLocaleFile(stderr,
"%s[%s]: %ld of %lu, %02ld%% complete\r",
127 locale_message,p+1,(
long) offset,(
unsigned long) extent,(
long)
128 (100.0*offset*MagickSafeReciprocal((
double) extent-1.0)));
129 if (offset == (MagickOffsetType) (extent-1))
130 (void) FormatLocaleFile(stderr,
"\n");
131 (void) fflush(stderr);
139static inline Image *GetImageCache(
const ImageInfo *image_info,
const char *path,
140 ExceptionInfo *exception)
143 key[MagickPathExtent];
154 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",path);
155 sans_exception=AcquireExceptionInfo();
156 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
157 sans_exception=DestroyExceptionInfo(sans_exception);
158 if (image != (Image *) NULL)
160 read_info=CloneImageInfo(image_info);
161 if (path != (
const char *) NULL)
162 (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
163 image=ReadImage(read_info,exception);
164 read_info=DestroyImageInfo(read_info);
165 if (image != (Image *) NULL)
166 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
180static Image *SparseColorOption(
const Image *image,
181 const SparseColorMethod method,
const char *arguments,ExceptionInfo *exception)
184 token[MagickPathExtent];
206 assert(image != (Image *) NULL);
207 assert(image->signature == MagickCoreSignature);
208 assert(exception != (ExceptionInfo *) NULL);
209 assert(exception->signature == MagickCoreSignature);
210 if (IsEventLogging() != MagickFalse)
211 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
217 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
219 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
221 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
223 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
224 (image->colorspace == CMYKColorspace))
226 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
227 image->alpha_trait != UndefinedPixelTrait)
237 (void) GetNextToken(p,&p,MagickPathExtent,token);
238 if (*token ==
',')
continue;
239 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
245 if ((x % (2+number_colors)) != 0)
247 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
248 "InvalidArgument",
"'%s': %s",
"sparse-color",
249 "Invalid number of Arguments");
250 return( (Image *) NULL);
256 sparse_arguments=(
double *) AcquireQuantumMemory(number_arguments,
257 sizeof(*sparse_arguments));
258 if (sparse_arguments == (
double *) NULL) {
259 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
260 "MemoryAllocationFailed",
"%s",
"SparseColorOption");
261 return( (Image *) NULL);
263 (void) memset(sparse_arguments,0,number_arguments*
264 sizeof(*sparse_arguments));
267 while ((*p !=
'\0') && (x < number_arguments))
271 while (*token ==
',')
272 (void) GetNextToken(p,&p,MagickPathExtent,token);
275 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
276 (void) ThrowMagickException(exception,GetMagickModule(),
277 OptionError,
"InvalidArgument",
"'%s': %s",
"sparse-color",
278 "Color found, instead of X-coord");
282 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
285 while (*token ==
',')
286 (void) GetNextToken(p,&p,MagickPathExtent,token);
289 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
290 (void) ThrowMagickException(exception,GetMagickModule(),
291 OptionError,
"InvalidArgument",
"'%s': %s",
"sparse-color",
292 "Color found, instead of Y-coord");
296 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
299 while (*token ==
',')
300 (void) GetNextToken(p,&p,MagickPathExtent,token);
301 if (*token ==
'\0')
break;
302 if ( isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' ) {
304 (void) QueryColorCompliance(token,AllCompliance,&color,
306 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
307 sparse_arguments[x++] = QuantumScale*color.red;
308 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
309 sparse_arguments[x++] = QuantumScale*color.green;
310 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
311 sparse_arguments[x++] = QuantumScale*color.blue;
312 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
313 (image->colorspace == CMYKColorspace))
314 sparse_arguments[x++] = QuantumScale*color.black;
315 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
316 image->alpha_trait != UndefinedPixelTrait)
317 sparse_arguments[x++] = QuantumScale*color.alpha;
322 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
324 while (*token ==
',')
325 (void) GetNextToken(p,&p,MagickPathExtent,token);
326 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
328 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
331 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
333 while (*token ==
',')
334 (void) GetNextToken(p,&p,MagickPathExtent,token);
335 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
337 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
340 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
342 while (*token ==
',')
343 (void) GetNextToken(p,&p,MagickPathExtent,token);
344 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
346 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
349 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
350 (image->colorspace == CMYKColorspace))
352 while (*token ==
',')
353 (void) GetNextToken(p,&p,MagickPathExtent,token);
354 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
356 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
359 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
360 image->alpha_trait != UndefinedPixelTrait)
362 while (*token ==
',')
363 (void) GetNextToken(p,&p,MagickPathExtent,token);
364 if ((*token ==
'\0') || isalpha((
int) ((
unsigned char) *token)) || *token ==
'#' )
366 sparse_arguments[x++]=StringToDouble(token,(
char **) NULL);
371 if (error != MagickFalse)
373 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
374 return((Image *) NULL);
376 if (number_arguments != x)
378 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
379 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
380 "InvalidArgument",
"'%s': %s",
"sparse-color",
"Argument Parsing Error");
381 return((Image *) NULL);
384 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
386 sparse_arguments=(
double *) RelinquishMagickMemory(sparse_arguments);
387 return( sparse_image );
427static void CLISettingOptionInfo(MagickCLI *cli_wand,
428 const char *option,
const char *arg1n,
const char *arg2n)
437#define _image_info (cli_wand->wand.image_info)
438#define _image (cli_wand->wand.images)
439#define _exception (cli_wand->wand.exception)
440#define _draw_info (cli_wand->draw_info)
441#define _quantize_info (cli_wand->quantize_info)
442#define IfSetOption (*option=='-')
443#define ArgBoolean IfSetOption ? MagickTrue : MagickFalse
444#define ArgBooleanNot IfSetOption ? MagickFalse : MagickTrue
445#define ArgBooleanString (IfSetOption?"true":"false")
446#define ArgOption(def) (IfSetOption?arg1:(const char *)(def))
448 assert(cli_wand != (MagickCLI *) NULL);
449 assert(cli_wand->signature == MagickWandSignature);
450 assert(cli_wand->wand.signature == MagickWandSignature);
452 if (cli_wand->wand.debug != MagickFalse)
453 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
454 "- Setting Option: %s \"%s\" \"%s\"", option,arg1n,arg2n);
460#define _process_flags (cli_wand->process_flags)
461#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
463 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
464 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
465 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
467 if (arg1n != (
char *) NULL) {
468 arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception);
469 if (arg1 == (
char *) NULL) {
470 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
474 if (arg2n != (
char *) NULL) {
475 arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception);
476 if (arg2 == (
char *) NULL) {
477 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
490 if (LocaleCompare(
"adjoin",option+1) == 0)
492 _image_info->adjoin = ArgBoolean;
495 if (LocaleCompare(
"affine",option+1) == 0)
497 CLIWandWarnReplaced(
"-draw 'affine ...'");
499 (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception);
501 GetAffineMatrix(&_draw_info->affine);
504 if (LocaleCompare(
"antialias",option+1) == 0)
506 _image_info->antialias =
507 _draw_info->stroke_antialias =
508 _draw_info->text_antialias = ArgBoolean;
511 if (LocaleCompare(
"attenuate",option+1) == 0)
513 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
514 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
515 (void) SetImageOption(_image_info,option+1,ArgOption(
"1.0"));
518 if (LocaleCompare(
"authenticate",option+1) == 0)
520 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
523 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
527 if (LocaleCompare(
"background",option+1) == 0)
541 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
542 (void) QueryColorCompliance(ArgOption(MogrifyBackgroundColor),AllCompliance,
543 &_image_info->background_color,_exception);
546 if (LocaleCompare(
"bias",option+1) == 0)
554 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
555 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
556 (void) SetImageOption(_image_info,
"convolve:bias",ArgOption(NULL));
559 if (LocaleCompare(
"black-point-compensation",option+1) == 0)
564 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
567 if (LocaleCompare(
"blue-primary",option+1) == 0)
573 arg1=ArgOption(
"0.0");
574 if (IsGeometry(arg1) == MagickFalse)
575 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
576 (void) SetImageOption(_image_info,option+1,arg1);
579 if (LocaleCompare(
"bordercolor",option+1) == 0)
587 (void) SetImageOption(_image_info,option+1,arg1);
588 (void) QueryColorCompliance(arg1,AllCompliance,
589 &_image_info->border_color,_exception);
590 (void) QueryColorCompliance(arg1,AllCompliance,
591 &_draw_info->border_color,_exception);
594 (void) DeleteImageOption(_image_info,option+1);
595 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
596 &_image_info->border_color,_exception);
597 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
598 &_draw_info->border_color,_exception);
601 if (LocaleCompare(
"box",option+1) == 0)
603 CLIWandWarnReplaced(
"-undercolor");
604 CLISettingOptionInfo(cli_wand,
"-undercolor",arg1, arg2);
607 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
611 if (LocaleCompare(
"cache",option+1) == 0)
616 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
617 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
618 limit=MagickResourceInfinity;
619 if (LocaleCompare(
"unlimited",arg1) != 0)
620 limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0);
621 (void) SetMagickResourceLimit(MemoryResource,limit);
622 (void) SetMagickResourceLimit(MapResource,2*limit);
625 if (LocaleCompare(
"caption",option+1) == 0)
627 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
630 if (LocaleCompare(
"colorspace",option+1) == 0)
636 parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
637 ArgOption(
"undefined"));
639 CLIWandExceptArgBreak(OptionError,
"UnrecognizedColorspace",option,
641 _image_info->colorspace=(ColorspaceType) parse;
644 if (LocaleCompare(
"comment",option+1) == 0)
646 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
649 if (LocaleCompare(
"compose",option+1) == 0)
658 parse = ParseCommandOption(MagickComposeOptions,MagickFalse,
659 ArgOption(
"undefined"));
661 CLIWandExceptArgBreak(OptionError,
"UnrecognizedComposeOperator",
663 _image_info->compose=(CompositeOperator) parse;
664 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
667 if (LocaleCompare(
"compress",option+1) == 0)
679 parse = ParseCommandOption(MagickCompressOptions,MagickFalse,
680 ArgOption(
"undefined"));
682 CLIWandExceptArgBreak(OptionError,
"UnrecognizedImageCompression",
684 _image_info->compression=(CompressionType) parse;
685 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
688 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
692 if (LocaleCompare(
"debug",option+1) == 0)
695 arg1=ArgOption(
"none");
696 parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1);
698 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEventType",
700 (void) SetLogEventMask(arg1);
701 _image_info->debug=IsEventLogging();
702 cli_wand->wand.debug=IsEventLogging();
705 if (LocaleCompare(
"define",option+1) == 0)
707 if (LocaleNCompare(arg1,
"registry:",9) == 0)
710 (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception);
712 (
void) DeleteImageRegistry(arg1+9);
717 (void) DefineImageOption(_image_info,arg1);
718 else if (DeleteImageOption(_image_info,arg1) == MagickFalse)
719 CLIWandExceptArgBreak(OptionError,
"NoSuchOption",option,arg1);
722 if (LocaleCompare(
"delay",option+1) == 0)
728 if (IsGeometry(arg1) == MagickFalse)
729 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
730 (void) SetImageOption(_image_info,option+1,arg1);
733 if (LocaleCompare(
"density",option+1) == 0)
740 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
741 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
742 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
743 (void) CloneString(&_image_info->density,ArgOption(NULL));
744 (void) CloneString(&_draw_info->density,_image_info->density);
747 if (LocaleCompare(
"depth",option+1) == 0)
752 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
753 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
754 _image_info->depth=IfSetOption?StringToUnsignedLong(arg1)
755 :MAGICKCORE_QUANTUM_DEPTH;
758 if (LocaleCompare(
"direction",option+1) == 0)
761 arg1=ArgOption(
"undefined");
762 parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1);
764 CLIWandExceptArgBreak(OptionError,
"UnrecognizedDirectionType",
766 _draw_info->direction=(DirectionType) parse;
767 (void) SetImageOption(_image_info,option+1,arg1);
770 if (LocaleCompare(
"display",option+1) == 0)
772 (void) CloneString(&_image_info->server_name,ArgOption(NULL));
773 (void) CloneString(&_draw_info->server_name,_image_info->server_name);
776 if (LocaleCompare(
"dispose",option+1) == 0)
779 arg1=ArgOption(
"undefined");
780 parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1);
782 CLIWandExceptArgBreak(OptionError,
"UnrecognizedDisposeMethod",
784 (void) SetImageOption(_image_info,option+1,ArgOption(
"undefined"));
787 if (LocaleCompare(
"dissimilarity-threshold",option+1) == 0)
791 arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD);
792 if (IsGeometry(arg1) == MagickFalse)
793 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
794 (void) SetImageOption(_image_info,option+1,arg1);
797 if (LocaleCompare(
"dither",option+1) == 0)
803 _image_info->dither = ArgBoolean;
804 (void) SetImageOption(_image_info,option+1,ArgOption(
"none"));
805 _quantize_info->dither_method=(DitherMethod) ParseCommandOption(
806 MagickDitherOptions,MagickFalse,ArgOption(
"none"));
807 if (_quantize_info->dither_method == NoDitherMethod)
808 _image_info->dither = MagickFalse;
811 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
815 if (LocaleCompare(
"encoding",option+1) == 0)
817 (void) CloneString(&_draw_info->encoding,ArgOption(
"undefined"));
818 (void) SetImageOption(_image_info,option+1,_draw_info->encoding);
821 if (LocaleCompare(
"endian",option+1) == 0)
824 arg1 = ArgOption(
"undefined");
825 parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1);
827 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEndianType",
830 _image_info->endian=(EndianType) (*arg1);
831 (void) SetImageOption(_image_info,option+1,arg1);
834 if (LocaleCompare(
"extract",option+1) == 0)
836 (void) CloneString(&_image_info->extract,ArgOption(NULL));
839 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
843 if (LocaleCompare(
"family",option+1) == 0)
845 (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
846 (void) CloneString(&_draw_info->family,ArgOption(NULL));
849 if (LocaleCompare(
"features",option+1) == 0)
851 (void) SetImageOption(_image_info,
"identify:features",
854 (void) SetImageArtifact(_image,
"verbose",
"true");
857 if (LocaleCompare(
"fill",option+1) == 0)
873 arg1 = ArgOption(
"none");
874 (void) SetImageOption(_image_info,option+1,arg1);
875 if (_draw_info->fill_pattern != (Image *) NULL)
876 _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern);
879 sans=AcquireExceptionInfo();
880 status=QueryColorCompliance(arg1,AllCompliance,&color,sans);
881 sans=DestroyExceptionInfo(sans);
883 if (status == MagickFalse)
884 _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception);
886 _draw_info->fill=color;
889 if (LocaleCompare(
"filter",option+1) == 0)
892 arg1 = ArgOption(
"undefined");
893 parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1);
895 CLIWandExceptArgBreak(OptionError,
"UnrecognizedImageFilter",
897 (void) SetImageOption(_image_info,option+1,arg1);
900 if (LocaleCompare(
"font",option+1) == 0)
902 (void) CloneString(&_draw_info->font,ArgOption(NULL));
903 (void) CloneString(&_image_info->font,_draw_info->font);
906 if (LocaleCompare(
"format",option+1) == 0)
908 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
911 if (LocaleCompare(
"fuzz",option+1) == 0)
921 if (IsGeometry(arg1) == MagickFalse)
922 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
923 _image_info->fuzz=StringToDoubleInterval(arg1,(
double)
925 (void) SetImageOption(_image_info,option+1,arg1);
928 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
932 if (LocaleCompare(
"gravity",option+1) == 0)
935 arg1 = ArgOption(
"none");
936 parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1);
938 CLIWandExceptArgBreak(OptionError,
"UnrecognizedGravityType",
940 _draw_info->gravity=(GravityType) parse;
941 (void) SetImageOption(_image_info,option+1,arg1);
944 if (LocaleCompare(
"green-primary",option+1) == 0)
950 arg1=ArgOption(
"0.0");
951 if (IsGeometry(arg1) == MagickFalse)
952 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
953 (void) SetImageOption(_image_info,option+1,arg1);
956 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
960 if (LocaleCompare(
"highlight-color",option+1) == 0)
964 (void) SetImageOption(_image_info,
"compare:highlight-color",
968 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
972 if (LocaleCompare(
"illuminant",option+1) == 0)
974 (void) SetImageOption(_image_info,
"color:illuminant",
978 if (LocaleCompare(
"intensity",option+1) == 0)
980 arg1 = ArgOption(
"undefined");
981 parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
984 CLIWandExceptArgBreak(OptionError,
"UnrecognizedIntensityType",
986 (void) SetImageOption(_image_info,option+1,arg1);
989 if (LocaleCompare(
"intent",option+1) == 0)
995 arg1 = ArgOption(
"undefined");
996 parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1);
998 CLIWandExceptArgBreak(OptionError,
"UnrecognizedIntentType",
1000 (void) SetImageOption(_image_info,option+1,arg1);
1003 if (LocaleCompare(
"interlace",option+1) == 0)
1008 arg1 = ArgOption(
"undefined");
1009 parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1);
1011 CLIWandExceptArgBreak(OptionError,
"UnrecognizedInterlaceType",
1013 _image_info->interlace=(InterlaceType) parse;
1014 (void) SetImageOption(_image_info,option+1,arg1);
1017 if (LocaleCompare(
"interline-spacing",option+1) == 0)
1019 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1020 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1021 (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
1022 _draw_info->interline_spacing=StringToDouble(ArgOption(
"0"),
1026 if (LocaleCompare(
"interpolate",option+1) == 0)
1029 arg1 = ArgOption(
"undefined");
1030 parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1);
1032 CLIWandExceptArgBreak(OptionError,
"UnrecognizedInterpolateMethod",
1034 (void) SetImageOption(_image_info,option+1,arg1);
1037 if (LocaleCompare(
"interword-spacing",option+1) == 0)
1039 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1040 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1041 (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
1042 _draw_info->interword_spacing=StringToDouble(ArgOption(
"0"),(
char **) NULL);
1045 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1049 if (LocaleCompare(
"kerning",option+1) == 0)
1051 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1052 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1053 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1054 _draw_info->kerning=StringToDouble(ArgOption(
"0"),(
char **) NULL);
1057 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1061 if (LocaleCompare(
"label",option+1) == 0)
1064 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1067 if (LocaleCompare(
"limit",option+1) == 0)
1072 limit=MagickResourceInfinity;
1073 parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1);
1075 CLIWandExceptArgBreak(OptionError,
"UnrecognizedResourceType",
1077 if (LocaleCompare(
"unlimited",arg2) != 0)
1078 limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0);
1079 if ((ResourceType) parse == TimeResource)
1080 limit=(MagickSizeType) ParseMagickTimeToLive(arg2);
1081 (void) SetMagickResourceLimit((ResourceType) parse,limit);
1084 if (LocaleCompare(
"log",option+1) == 0)
1087 if (arg1 == (
char *) NULL)
1089 if ((strchr(arg1,
'%') == (
char *) NULL))
1090 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1091 (void) SetLogFormat(arg1);
1095 if (LocaleCompare(
"lowlight-color",option+1) == 0)
1099 (void) SetImageOption(_image_info,
"compare:lowlight-color",
1103 if (LocaleCompare(
"loop",option+1) == 0)
1106 arg1=ArgOption(
"0");
1107 if (IsGeometry(arg1) == MagickFalse)
1108 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1109 (void) SetImageOption(_image_info,option+1,arg1);
1112 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1116 if (LocaleCompare(
"mattecolor",option+1) == 0)
1119 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1120 (void) QueryColorCompliance(ArgOption(MogrifyAlphaColor),
1121 AllCompliance,&_image_info->matte_color,_exception);
1124 if (LocaleCompare(
"metric",option+1) == 0)
1128 parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1);
1130 CLIWandExceptArgBreak(OptionError,
"UnrecognizedMetricType",
1132 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1135 if (LocaleCompare(
"moments",option+1) == 0)
1137 (void) SetImageOption(_image_info,
"identify:moments",
1140 (void) SetImageArtifact(_image,
"verbose",
"true");
1143 if (LocaleCompare(
"monitor",option+1) == 0)
1145 (void) SetImageInfoProgressMonitor(_image_info,IfSetOption ?
1146 MonitorProgress: (MagickProgressMonitor) NULL,(
void *) NULL);
1149 if (LocaleCompare(
"monochrome",option+1) == 0)
1154 _image_info->monochrome= ArgBoolean;
1157 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1161 if (LocaleCompare(
"orient",option+1) == 0)
1168 parse=ParseCommandOption(MagickOrientationOptions,MagickFalse,
1169 ArgOption(
"undefined"));
1171 CLIWandExceptArgBreak(OptionError,
"UnrecognizedImageOrientation",
1173 _image_info->orientation=(OrientationType)parse;
1174 (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
1177 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1181 if (LocaleCompare(
"page",option+1) == 0)
1190 page[MagickPathExtent];
1203 (void) DeleteImageOption(_image_info,option+1);
1204 (void) CloneString(&_image_info->page,(
char *) NULL);
1207 (void) memset(&geometry,0,
sizeof(geometry));
1208 image_option=GetImageOption(_image_info,
"page");
1209 if (image_option != (
const char *) NULL)
1210 flags=ParseAbsoluteGeometry(image_option,&geometry);
1211 canonical_page=GetPageGeometry(arg1);
1212 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
1213 canonical_page=DestroyString(canonical_page);
1214 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu",
1215 (
unsigned long) geometry.width,(
unsigned long) geometry.height);
1216 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1217 (void) FormatLocaleString(page,MagickPathExtent,
"%lux%lu%+ld%+ld",
1218 (
unsigned long) geometry.width,(
unsigned long) geometry.height,
1219 (
long) geometry.x,(
long) geometry.y);
1220 (void) SetImageOption(_image_info,option+1,page);
1221 (void) CloneString(&_image_info->page,page);
1224 if (LocaleCompare(
"ping",option+1) == 0)
1226 _image_info->ping=ArgBoolean;
1229 if (LocaleCompare(
"pointsize",option+1) == 0)
1232 if (IsGeometry(arg1) == MagickFalse)
1233 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1234 _image_info->pointsize =
1235 _draw_info->pointsize =
1236 StringToDouble(arg1,(
char **) NULL);
1239 _image_info->pointsize=0.0;
1240 _draw_info->pointsize=12.0;
1244 if (LocaleCompare(
"precision",option+1) == 0)
1246 arg1=ArgOption(
"-1");
1247 if (IsGeometry(arg1) == MagickFalse)
1248 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1249 (void) SetMagickPrecision(StringToInteger(arg1));
1252 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1256 if (LocaleCompare(
"quality",option+1) == 0)
1258 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1259 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1260 _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1)
1261 : UNDEFINED_COMPRESSION_QUALITY;
1262 (void) SetImageOption(_image_info,option+1,ArgOption(
"0"));
1265 if (LocaleCompare(
"quantize",option+1) == 0)
1268 arg1=ArgOption(
"undefined");
1269 parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);
1271 CLIWandExceptArgBreak(OptionError,
"UnrecognizedColorspace",
1273 _quantize_info->colorspace=(ColorspaceType)parse;
1276 if (LocaleCompare(
"quiet",option+1) == 0)
1281 static WarningHandler
1282 warning_handler = (WarningHandler) NULL;
1285 tmp = SetWarningHandler((WarningHandler) NULL);
1287 if ( tmp != (WarningHandler) NULL)
1288 warning_handler = tmp;
1290 warning_handler=SetWarningHandler(warning_handler);
1293 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1297 if (LocaleCompare(
"red-primary",option+1) == 0)
1303 arg1=ArgOption(
"0.0");
1304 if (IsGeometry(arg1) == MagickFalse)
1305 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1306 (void) SetImageOption(_image_info,option+1,arg1);
1309 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1312 if (LocaleCompare(
"render",option+1) == 0)
1315 _draw_info->render= ArgBooleanNot;
1318 if ((LocaleCompare(
"respect-parentheses",option+1) == 0) ||
1319 (LocaleCompare(
"respect-parenthesis",option+1) == 0))
1322 (void) SetImageOption(_image_info,
"respect-parentheses",
1326 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1330 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1333 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1334 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1335 (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL));
1338 if (LocaleCompare(
"scene",option+1) == 0)
1343 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1344 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1345 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1346 _image_info->scene=StringToUnsignedLong(ArgOption(
"0"));
1349 if (LocaleCompare(
"seed",option+1) == 0)
1351 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1352 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1354 IfSetOption ? (
unsigned long) StringToUnsignedLong(arg1)
1355 : (
unsigned long) time((time_t *) NULL));
1358 if (LocaleCompare(
"size",option+1) == 0)
1363 (void) CloneString(&_image_info->size,ArgOption(NULL));
1366 if (LocaleCompare(
"stretch",option+1) == 0)
1368 arg1=ArgOption(
"undefined");
1369 parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1);
1371 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStretchType",
1373 _draw_info->stretch=(StretchType) parse;
1376 if (LocaleCompare(
"stroke",option+1) == 0)
1391 arg1 = ArgOption(
"none");
1392 (void) SetImageOption(_image_info,option+1,arg1);
1393 if (_draw_info->stroke_pattern != (Image *) NULL)
1394 _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern);
1397 sans=AcquireExceptionInfo();
1398 status=QueryColorCompliance(arg1,AllCompliance,&color,sans);
1399 sans=DestroyExceptionInfo(sans);
1401 if (status == MagickFalse)
1402 _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception);
1404 _draw_info->stroke=color;
1407 if (LocaleCompare(
"strokewidth",option+1) == 0)
1409 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1410 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1411 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1412 _draw_info->stroke_width=StringToDouble(ArgOption(
"1.0"),
1416 if (LocaleCompare(
"style",option+1) == 0)
1418 arg1=ArgOption(
"undefined");
1419 parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1);
1421 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStyleType",
1423 _draw_info->style=(StyleType) parse;
1427 if (LocaleCompare(
"subimage-search",option+1) == 0)
1431 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1435 if (LocaleCompare(
"synchronize",option+1) == 0)
1438 _image_info->synchronize = ArgBoolean;
1441 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1445 if (LocaleCompare(
"taint",option+1) == 0)
1448 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1451 if (LocaleCompare(
"texture",option+1) == 0)
1457 (void) CloneString(&_image_info->texture,ArgOption(NULL));
1460 if (LocaleCompare(
"tile",option+1) == 0)
1463 _draw_info->fill_pattern=IfSetOption
1464 ?GetImageCache(_image_info,arg1,_exception)
1465 :DestroyImage(_draw_info->fill_pattern);
1468 if (LocaleCompare(
"tile-offset",option+1) == 0)
1471 arg1=ArgOption(
"0");
1472 if (IsGeometry(arg1) == MagickFalse)
1473 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1474 (void) SetImageOption(_image_info,option+1,arg1);
1477 if (LocaleCompare(
"transparent-color",option+1) == 0)
1486 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1487 (void) QueryColorCompliance(ArgOption(
"none"),AllCompliance,
1488 &_image_info->transparent_color,_exception);
1491 if (LocaleCompare(
"treedepth",option+1) == 0)
1493 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1494 _quantize_info->tree_depth=StringToUnsignedLong(ArgOption(
"0"));
1497 if (LocaleCompare(
"type",option+1) == 0)
1500 parse=ParseCommandOption(MagickTypeOptions,MagickFalse,
1501 ArgOption(
"undefined"));
1503 CLIWandExceptArgBreak(OptionError,
"UnrecognizedImageType",
1505 _image_info->type=(ImageType) parse;
1506 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1509 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1513 if (LocaleCompare(
"undercolor",option+1) == 0)
1515 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1516 (void) QueryColorCompliance(ArgOption(
"none"),AllCompliance,
1517 &_draw_info->undercolor,_exception);
1520 if (LocaleCompare(
"units",option+1) == 0)
1526 parse=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1527 ArgOption(
"undefined"));
1529 CLIWandExceptArgBreak(OptionError,
"UnrecognizedUnitsType",
1531 _image_info->units=(ResolutionType) parse;
1532 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1535 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1539 if (LocaleCompare(
"verbose",option+1) == 0)
1544 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1545 _image_info->verbose= ArgBoolean;
1546 _image_info->ping=MagickFalse;
1549 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1554 parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1555 ArgOption(
"undefined"));
1557 CLIWandExceptArgBreak(OptionError,
"UnrecognizedVirtualPixelMethod",
1559 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1562 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1566 if (LocaleCompare(
"weight",option+1) == 0)
1571 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,arg1);
1573 weight=(ssize_t) StringToUnsignedLong(arg1);
1574 _draw_info->weight=(size_t) weight;
1577 if (LocaleCompare(
"white-point",option+1) == 0)
1582 arg1=ArgOption(
"0.0");
1583 if (IsGeometry(arg1) == MagickFalse)
1584 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1585 (void) SetImageOption(_image_info,option+1,arg1);
1588 if (LocaleCompare(
"word-break",option+1) == 0)
1590 parse=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
1591 ArgOption(
"undefined"));
1593 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1594 (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
1597 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1600 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1604 if ((arg1 && arg1n) && (arg1 != arg1n ))
1605 arg1=DestroyString((
char *) arg1);
1606 if ((arg2 && arg2n) && (arg2 != arg2n ))
1607 arg2=DestroyString((
char *) arg2);
1612#undef _quantize_info
1616#undef ArgBooleanString
1671static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
1672 const char *option,
const char *arg1n,
const char *arg2n,
1673 ExceptionInfo *exception)
1694#define _image_info (cli_wand->wand.image_info)
1695#define _image (cli_wand->wand.images)
1696#define _exception (cli_wand->wand.exception)
1697#define _draw_info (cli_wand->draw_info)
1698#define _quantize_info (cli_wand->quantize_info)
1699#define _process_flags (cli_wand->process_flags)
1700#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
1701#define IfNormalOp (*option=='-')
1702#define IfPlusOp (*option!='-')
1703#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse
1704#define IsPlusOp IfNormalOp ? MagickFalse : MagickTrue
1706 assert(cli_wand != (MagickCLI *) NULL);
1707 assert(cli_wand->signature == MagickWandSignature);
1708 assert(cli_wand->wand.signature == MagickWandSignature);
1709 assert(_image != (Image *) NULL);
1710 if (cli_wand->wand.debug != MagickFalse)
1711 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",cli_wand->wand.name);
1717 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
1718 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
1719 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
1721 if (arg1n != (
char *) NULL) {
1722 arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception);
1723 if (arg1 == (
char *) NULL) {
1724 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
1728 if (arg2n != (
char *) NULL) {
1729 arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception);
1730 if (arg2 == (
char *) NULL) {
1731 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
1736#undef _process_flags
1740 (void) FormatLocaleFile(stderr,
1741 "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2);
1744 new_image = (Image *) NULL;
1745 SetGeometryInfo(&geometry_info);
1747 switch (*(option+1))
1751 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
1753 flags=ParseGeometry(arg1,&geometry_info);
1754 if ((flags & (RhoValue|SigmaValue)) == 0)
1755 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1756 if ((flags & SigmaValue) == 0)
1757 geometry_info.sigma=1.0;
1758 new_image=AdaptiveBlurImage(_image,geometry_info.rho,
1759 geometry_info.sigma,_exception);
1762 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
1765 if (IsGeometry(arg1) == MagickFalse)
1766 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1767 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
1768 new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height,
1772 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
1774 flags=ParseGeometry(arg1,&geometry_info);
1775 if ((flags & (RhoValue|SigmaValue)) == 0)
1776 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1777 if ((flags & SigmaValue) == 0)
1778 geometry_info.sigma=1.0;
1779 new_image=AdaptiveSharpenImage(_image,geometry_info.rho,
1780 geometry_info.sigma,_exception);
1783 if (LocaleCompare(
"alpha",option+1) == 0)
1785 parse=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,arg1);
1787 CLIWandExceptArgBreak(OptionError,
"UnrecognizedAlphaChannelOption",
1789 (void) SetImageAlphaChannel(_image,(AlphaChannelOption) parse,
1793 if (LocaleCompare(
"annotate",option+1) == 0)
1796 buffer[MagickPathExtent];
1798 SetGeometryInfo(&geometry_info);
1799 flags=ParseGeometry(arg1,&geometry_info);
1801 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1802 if ((flags & SigmaValue) == 0)
1803 geometry_info.sigma=geometry_info.rho;
1804 (void) CloneString(&_draw_info->text,arg2);
1805 (void) FormatLocaleString(buffer,MagickPathExtent,
"%+f%+f",
1806 geometry_info.xi,geometry_info.psi);
1807 (void) CloneString(&_draw_info->geometry,buffer);
1808 _draw_info->affine.sx=cos(DegreesToRadians(
1809 fmod(geometry_info.rho,360.0)));
1810 _draw_info->affine.rx=sin(DegreesToRadians(
1811 fmod(geometry_info.rho,360.0)));
1812 _draw_info->affine.ry=(-sin(DegreesToRadians(
1813 fmod(geometry_info.sigma,360.0))));
1814 _draw_info->affine.sy=cos(DegreesToRadians(
1815 fmod(geometry_info.sigma,360.0)));
1816 (void) AnnotateImage(_image,_draw_info,_exception);
1817 GetAffineMatrix(&_draw_info->affine);
1820 if (LocaleCompare(
"auto-gamma",option+1) == 0)
1822 (void) AutoGammaImage(_image,_exception);
1825 if (LocaleCompare(
"auto-level",option+1) == 0)
1827 (void) AutoLevelImage(_image,_exception);
1830 if (LocaleCompare(
"auto-orient",option+1) == 0)
1832 new_image=AutoOrientImage(_image,_image->orientation,_exception);
1835 if (LocaleCompare(
"auto-threshold",option+1) == 0)
1840 method=(AutoThresholdMethod) ParseCommandOption(
1841 MagickAutoThresholdOptions,MagickFalse,arg1);
1842 (void) AutoThresholdImage(_image,method,_exception);
1845 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1849 if (LocaleCompare(
"bilateral-blur",option+1) == 0)
1851 flags=ParseGeometry(arg1,&geometry_info);
1852 if ((flags & (RhoValue|SigmaValue)) == 0)
1853 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1854 if ((flags & SigmaValue) == 0)
1855 geometry_info.sigma=geometry_info.rho;
1856 if ((flags & XiValue) == 0)
1857 geometry_info.xi=1.0*sqrt(geometry_info.rho*geometry_info.rho+
1858 geometry_info.sigma*geometry_info.sigma);
1859 if ((flags & PsiValue) == 0)
1860 geometry_info.psi=0.25*sqrt(geometry_info.rho*geometry_info.rho+
1861 geometry_info.sigma*geometry_info.sigma);
1862 new_image=BilateralBlurImage(_image,(
size_t) geometry_info.rho,
1863 (
size_t) geometry_info.sigma,geometry_info.xi,geometry_info.psi,
1867 if (LocaleCompare(
"black-threshold",option+1) == 0)
1869 if (IsGeometry(arg1) == MagickFalse)
1870 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1871 (void) BlackThresholdImage(_image,arg1,_exception);
1874 if (LocaleCompare(
"blue-shift",option+1) == 0)
1876 geometry_info.rho=1.5;
1878 flags=ParseGeometry(arg1,&geometry_info);
1879 if ((flags & RhoValue) == 0)
1880 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1882 new_image=BlueShiftImage(_image,geometry_info.rho,_exception);
1885 if (LocaleCompare(
"blur",option+1) == 0)
1887 flags=ParseGeometry(arg1,&geometry_info);
1888 if ((flags & (RhoValue|SigmaValue)) == 0)
1889 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1890 if ((flags & SigmaValue) == 0)
1891 geometry_info.sigma=1.0;
1892 new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma,
1896 if (LocaleCompare(
"border",option+1) == 0)
1904 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
1905 if ((flags & (WidthValue | HeightValue)) == 0)
1906 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1907 compose=OverCompositeOp;
1908 value=GetImageOption(_image_info,
"compose");
1909 if (value != (
const char *) NULL)
1910 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1912 new_image=BorderImage(_image,&geometry,compose,_exception);
1915 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
1921 flags=ParseGeometry(arg1,&geometry_info);
1922 if ((flags & RhoValue) == 0)
1923 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1924 brightness=geometry_info.rho;
1926 if ((flags & SigmaValue) != 0)
1927 contrast=geometry_info.sigma;
1928 (void) BrightnessContrastImage(_image,brightness,contrast,
1932 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1936 if (LocaleCompare(
"canny",option+1) == 0)
1938 flags=ParseGeometry(arg1,&geometry_info);
1939 if ((flags & (RhoValue|SigmaValue)) == 0)
1940 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1941 if ((flags & SigmaValue) == 0)
1942 geometry_info.sigma=1.0;
1943 if ((flags & XiValue) == 0)
1944 geometry_info.xi=10;
1945 if ((flags & PsiValue) == 0)
1946 geometry_info.psi=30;
1947 if ((flags & PercentValue) != 0)
1949 geometry_info.xi/=100.0;
1950 geometry_info.psi/=100.0;
1952 new_image=CannyEdgeImage(_image,geometry_info.rho,geometry_info.sigma,
1953 geometry_info.xi,geometry_info.psi,_exception);
1956 if (LocaleCompare(
"cdl",option+1) == 0)
1959 *color_correction_collection;
1964 color_correction_collection=FileToString(arg1,~0UL,_exception);
1965 if (color_correction_collection == (
char *) NULL)
1967 (void) ColorDecisionListImage(_image,color_correction_collection,
1969 color_correction_collection=DestroyString(color_correction_collection);
1972 if (LocaleCompare(
"channel",option+1) == 0)
1976 (void) SetPixelChannelMask(_image,DefaultChannels);
1979 parse=ParseChannelOption(arg1);
1981 CLIWandExceptArgBreak(OptionError,
"UnrecognizedChannelType",option,
1983 (void) SetPixelChannelMask(_image,(ChannelType) parse);
1986 if (LocaleCompare(
"charcoal",option+1) == 0)
1988 flags=ParseGeometry(arg1,&geometry_info);
1989 if ((flags & (RhoValue|SigmaValue)) == 0)
1990 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1991 if ((flags & SigmaValue) == 0)
1992 geometry_info.sigma=1.0;
1993 if ((flags & XiValue) == 0)
1994 geometry_info.xi=1.0;
1995 new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma,
1999 if (LocaleCompare(
"chop",option+1) == 0)
2001 if (IsGeometry(arg1) == MagickFalse)
2002 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2003 (void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
2004 new_image=ChopImage(_image,&geometry,_exception);
2007 if (LocaleCompare(
"clahe",option+1) == 0)
2009 if (IsGeometry(arg1) == MagickFalse)
2010 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2011 flags=ParseGeometry(arg1,&geometry_info);
2012 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2013 (void) CLAHEImage(_image,geometry.width,geometry.height,
2014 (
size_t) geometry.x,geometry_info.psi,_exception);
2017 if (LocaleCompare(
"clamp",option+1) == 0)
2019 (void) ClampImage(_image,_exception);
2022 if (LocaleCompare(
"clip",option+1) == 0)
2025 (void) ClipImage(_image,_exception);
2027 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2031 if (LocaleCompare(
"clip-mask",option+1) == 0)
2038 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2042 clip_mask=GetImageCache(_image_info,arg1,_exception);
2043 if (clip_mask == (Image *) NULL)
2045 (void) SetImageMask(_image,WritePixelMask,clip_mask,_exception);
2046 clip_mask=DestroyImage(clip_mask);
2049 if (LocaleCompare(
"clip-path",option+1) == 0)
2051 (void) ClipImagePath(_image,arg1,IsNormalOp,_exception);
2055 if (LocaleCompare(
"colorize",option+1) == 0)
2057 if (IsGeometry(arg1) == MagickFalse)
2058 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2059 new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception);
2062 if (LocaleCompare(
"color-matrix",option+1) == 0)
2067 kernel=AcquireKernelInfo(arg1,exception);
2068 if (kernel == (KernelInfo *) NULL)
2069 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2070 new_image=ColorMatrixImage(_image,kernel,_exception);
2071 kernel=DestroyKernelInfo(kernel);
2074 if (LocaleCompare(
"colors",option+1) == 0)
2079 _quantize_info->number_colors=StringToUnsignedLong(arg1);
2080 _quantize_info->measure_error=_image_info->verbose;
2081 if (_quantize_info->number_colors == 0)
2082 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2083 if ((_image->storage_class == DirectClass) ||
2084 _image->colors > _quantize_info->number_colors)
2085 (void) QuantizeImage(_quantize_info,_image,_exception);
2087 (
void) CompressImageColormap(_image,_exception);
2090 if (LocaleCompare(
"colorspace",option+1) == 0)
2102 (void) TransformImageColorspace(_image,
2103 IfNormalOp ? _image_info->colorspace : sRGBColorspace,
2107 if (LocaleCompare(
"color-threshold",option+1) == 0)
2117 (void) GetColorRange(
"white-black",&start,&stop,_exception);
2119 (
void) GetColorRange(arg1,&start,&stop,_exception);
2120 (void) ColorThresholdImage(_image,&start,&stop,_exception);
2123 if (LocaleCompare(
"connected-components",option+1) == 0)
2125 if (IsGeometry(arg1) == MagickFalse)
2126 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2127 new_image=ConnectedComponentsImage(_image,(
size_t)
2128 StringToInteger(arg1),(CCObjectInfo **) NULL,_exception);
2131 if (LocaleCompare(
"contrast",option+1) == 0)
2133 CLIWandWarnReplaced(IfNormalOp?
"-level":
"+level");
2134 (void) ContrastImage(_image,IsNormalOp,_exception);
2137 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
2143 flags=ParseGeometry(arg1,&geometry_info);
2144 if ((flags & RhoValue) == 0)
2145 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2146 black_point=geometry_info.rho;
2147 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2149 if ((flags & PercentValue) != 0)
2151 black_point*=(double) _image->columns*_image->rows/100.0;
2152 white_point*=(double) _image->columns*_image->rows/100.0;
2154 white_point=(double) _image->columns*_image->rows-white_point;
2155 (void) ContrastStretchImage(_image,black_point,white_point,
2159 if (LocaleCompare(
"convolve",option+1) == 0)
2170 kernel_info=AcquireKernelInfo(arg1,exception);
2171 if (kernel_info == (KernelInfo *) NULL)
2172 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2174 for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
2175 gamma+=kernel_info->values[j];
2176 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
2177 for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
2178 kernel_info->values[j]*=gamma;
2179 new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info,
2181 kernel_info=DestroyKernelInfo(kernel_info);
2184 if (LocaleCompare(
"crop",option+1) == 0)
2187 if (IsGeometry(arg1) == MagickFalse)
2188 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2189 new_image=CropImageToTiles(_image,arg1,_exception);
2192 if (LocaleCompare(
"cycle",option+1) == 0)
2194 if (IsGeometry(arg1) == MagickFalse)
2195 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2196 (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1),
2200 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2204 if (LocaleCompare(
"decipher",option+1) == 0)
2210 passkey=FileToStringInfo(arg1,~0UL,_exception);
2211 if (passkey == (StringInfo *) NULL)
2212 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2214 (void) PasskeyDecipherImage(_image,passkey,_exception);
2215 passkey=DestroyStringInfo(passkey);
2218 if (LocaleCompare(
"depth",option+1) == 0)
2228 (void) SetImageDepth(_image,_image_info->depth,_exception);
2231 if (LocaleCompare(
"deskew",option+1) == 0)
2237 if (IsGeometry(arg1) == MagickFalse)
2238 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2239 threshold=StringToDoubleInterval(arg1,(
double) QuantumRange+1.0);
2242 threshold=40.0*(double) QuantumRange/100.0;
2243 new_image=DeskewImage(_image,threshold,_exception);
2246 if (LocaleCompare(
"despeckle",option+1) == 0)
2248 new_image=DespeckleImage(_image,_exception);
2251 if (LocaleCompare(
"distort",option+1) == 0)
2259 parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1);
2261 CLIWandExceptArgBreak(OptionError,
"UnrecognizedDistortMethod",
2263 if ((DistortMethod) parse == ResizeDistortion)
2271 if (IsGeometry(arg2) == MagickFalse)
2272 CLIWandExceptArgBreak(OptionError,
"InvalidGeometry",
2274 (void) ParseRegionGeometry(_image,arg2,&geometry,_exception);
2275 resize_args[0]=(double) geometry.width;
2276 resize_args[1]=(double) geometry.height;
2277 new_image=DistortImage(_image,(DistortMethod) parse,
2278 (
size_t)2,resize_args,MagickTrue,_exception);
2282 args = StringToArrayOfDoubles(arg2,&count,_exception);
2283 if (args == (
double *) NULL )
2284 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg2);
2286 new_image=DistortImage(_image,(DistortMethod) parse,(
size_t)
2287 count,args,IsPlusOp,_exception);
2288 args=(
double *) RelinquishMagickMemory(args);
2291 if (LocaleCompare(
"draw",option+1) == 0)
2293 (void) CloneString(&_draw_info->primitive,arg1);
2294 (void) DrawImage(_image,_draw_info,_exception);
2295 (void) CloneString(&_draw_info->primitive,(
char *) NULL);
2298 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2302 if (LocaleCompare(
"edge",option+1) == 0)
2304 flags=ParseGeometry(arg1,&geometry_info);
2305 if ((flags & (RhoValue|SigmaValue)) == 0)
2306 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2307 new_image=EdgeImage(_image,geometry_info.rho,_exception);
2310 if (LocaleCompare(
"emboss",option+1) == 0)
2312 flags=ParseGeometry(arg1,&geometry_info);
2313 if ((flags & (RhoValue|SigmaValue)) == 0)
2314 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2315 if ((flags & SigmaValue) == 0)
2316 geometry_info.sigma=1.0;
2317 new_image=EmbossImage(_image,geometry_info.rho,
2318 geometry_info.sigma,_exception);
2321 if (LocaleCompare(
"encipher",option+1) == 0)
2327 passkey=FileToStringInfo(arg1,~0UL,_exception);
2328 if (passkey != (StringInfo *) NULL)
2330 (void) PasskeyEncipherImage(_image,passkey,_exception);
2331 passkey=DestroyStringInfo(passkey);
2335 if (LocaleCompare(
"enhance",option+1) == 0)
2337 new_image=EnhanceImage(_image,_exception);
2340 if (LocaleCompare(
"equalize",option+1) == 0)
2342 (void) EqualizeImage(_image,_exception);
2345 if (LocaleCompare(
"evaluate",option+1) == 0)
2350 parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
2352 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
2354 if (IsGeometry(arg2) == MagickFalse)
2355 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
2356 constant=StringToDoubleInterval(arg2,(
double) QuantumRange+1.0);
2357 (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant,
2361 if (LocaleCompare(
"extent",option+1) == 0)
2363 if (IsGeometry(arg1) == MagickFalse)
2364 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2365 flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
2366 if (geometry.width == 0)
2367 geometry.width=_image->columns;
2368 if (geometry.height == 0)
2369 geometry.height=_image->rows;
2370 new_image=ExtentImage(_image,&geometry,_exception);
2373 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2377 if (LocaleCompare(
"features",option+1) == 0)
2379 CLIWandWarnReplaced(
"-verbose -define identify:features=");
2382 (void) DeleteImageArtifact(_image,
"identify:features");
2385 (void) SetImageArtifact(_image,
"identify:features",arg1);
2386 (void) SetImageArtifact(_image,
"verbose",
"true");
2389 if (LocaleCompare(
"flip",option+1) == 0)
2391 new_image=FlipImage(_image,_exception);
2394 if (LocaleCompare(
"flop",option+1) == 0)
2396 new_image=FlopImage(_image,_exception);
2399 if (LocaleCompare(
"floodfill",option+1) == 0)
2404 if (IsGeometry(arg1) == MagickFalse)
2405 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2406 (void) ParsePageGeometry(_image,arg1,&geometry,_exception);
2407 (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception);
2408 (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x,
2409 geometry.y,IsPlusOp,_exception);
2412 if (LocaleCompare(
"frame",option+1) == 0)
2423 value=GetImageOption(_image_info,
"compose");
2424 compose=OverCompositeOp;
2425 if (value != (
const char *) NULL)
2426 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
2428 if (IsGeometry(arg1) == MagickFalse)
2429 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2430 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
2431 frame_info.width=geometry.width;
2432 frame_info.height=geometry.height;
2433 frame_info.outer_bevel=geometry.x;
2434 frame_info.inner_bevel=geometry.y;
2435 frame_info.x=(ssize_t) frame_info.width;
2436 frame_info.y=(ssize_t) frame_info.height;
2437 frame_info.width=_image->columns+2*frame_info.width;
2438 frame_info.height=_image->rows+2*frame_info.height;
2439 new_image=FrameImage(_image,&frame_info,compose,_exception);
2442 if (LocaleCompare(
"function",option+1) == 0)
2450 parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1);
2452 CLIWandExceptArgBreak(OptionError,
"UnrecognizedFunction",
2455 args = StringToArrayOfDoubles(arg2,&count,_exception);
2456 if (args == (
double *) NULL )
2457 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg2);
2459 (void) FunctionImage(_image,(MagickFunction)parse,(
size_t) count,args,
2461 args=(
double *) RelinquishMagickMemory(args);
2464 if (LocaleCompare(
"fx",option+1) == 0)
2466 new_image=FxImage(_image,arg1,_exception);
2469 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2473 if (LocaleCompare(
"gamma",option+1) == 0)
2478 if (IsGeometry(arg1) == MagickFalse)
2479 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2480 constant=StringToDouble(arg1,(
char **) NULL);
2484 constant=MagickSafeReciprocal(constant);
2485 (void) GammaImage(_image,constant,_exception);
2489 constant=MagickSafeReciprocal(constant);
2490 (void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception);
2491 _image->gamma*=StringToDouble(arg1,(
char **) NULL);
2498 if (LocaleCompare(
"gaussian-blur",option+1) == 0)
2500 flags=ParseGeometry(arg1,&geometry_info);
2501 if ((flags & (RhoValue|SigmaValue)) == 0)
2502 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2503 if ((flags & SigmaValue) == 0)
2504 geometry_info.sigma=1.0;
2505 new_image=GaussianBlurImage(_image,geometry_info.rho,
2506 geometry_info.sigma,_exception);
2509 if (LocaleCompare(
"gaussian",option+1) == 0)
2511 CLIWandWarnReplaced(
"-gaussian-blur");
2512 (void) CLISimpleOperatorImage(cli_wand,
"-gaussian-blur",arg1,NULL,exception);
2514 if (LocaleCompare(
"geometry",option+1) == 0)
2524 if (_image->geometry != (
char *) NULL)
2525 _image->geometry=DestroyString(_image->geometry);
2528 if (IsGeometry(arg1) == MagickFalse)
2529 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2530 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2531 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2532 (void) CloneString(&_image->geometry,arg1);
2534 new_image=ResizeImage(_image,geometry.width,geometry.height,
2535 _image->filter,_exception);
2538 if (LocaleCompare(
"grayscale",option+1) == 0)
2540 parse=ParseCommandOption(MagickPixelIntensityOptions,
2543 CLIWandExceptArgBreak(OptionError,
"UnrecognizedIntensityMethod",
2545 (void) GrayscaleImage(_image,(PixelIntensityMethod) parse,_exception);
2548 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2552 if (LocaleCompare(
"hough-lines",option+1) == 0)
2554 flags=ParseGeometry(arg1,&geometry_info);
2555 if ((flags & (RhoValue|SigmaValue)) == 0)
2556 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2557 if ((flags & SigmaValue) == 0)
2558 geometry_info.sigma=geometry_info.rho;
2559 if ((flags & XiValue) == 0)
2560 geometry_info.xi=40;
2561 new_image=HoughLineImage(_image,(
size_t) geometry_info.rho,
2562 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,_exception);
2565 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2569 if (LocaleCompare(
"identify",option+1) == 0)
2575 format=GetImageOption(_image_info,
"format");
2576 if (format == (
char *) NULL)
2578 (void) IdentifyImage(_image,stdout,_image_info->verbose,
2582 text=InterpretImageProperties(_image_info,_image,format,_exception);
2583 if (text == (
char *) NULL)
2584 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
2586 (void) fputs(text,stdout);
2587 text=DestroyString((
char *)text);
2590 if (LocaleCompare(
"implode",option+1) == 0)
2592 flags=ParseGeometry(arg1,&geometry_info);
2593 if ((flags & RhoValue) == 0)
2594 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2595 new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate,
2599 if (LocaleCompare(
"integral",option+1) == 0)
2601 new_image=IntegralImage(_image,_exception);
2604 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
2608 if (IsGeometry(arg1) == MagickFalse)
2609 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2610 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
2611 new_image=InterpolativeResizeImage(_image,geometry.width,
2612 geometry.height,_image->interpolate,_exception);
2615 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2619 if (LocaleCompare(
"kmeans",option+1) == 0)
2624 flags=ParseGeometry(arg1,&geometry_info);
2625 if ((flags & (RhoValue|SigmaValue)) == 0)
2626 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2627 if ((flags & SigmaValue) == 0)
2628 geometry_info.sigma=300.0;
2629 if ((flags & XiValue) == 0)
2630 geometry_info.xi=0.0001;
2631 (void) KmeansImage(_image,(
size_t) geometry_info.rho,(
size_t)
2632 geometry_info.sigma,geometry_info.xi,_exception);
2635 if (LocaleCompare(
"kuwahara",option+1) == 0)
2640 flags=ParseGeometry(arg1,&geometry_info);
2641 if ((flags & (RhoValue|SigmaValue)) == 0)
2642 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2643 if ((flags & SigmaValue) == 0)
2644 geometry_info.sigma=geometry_info.rho-0.5;
2645 new_image=KuwaharaImage(_image,geometry_info.rho,geometry_info.sigma,
2649 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2653 if (LocaleCompare(
"lat",option+1) == 0)
2655 flags=ParseGeometry(arg1,&geometry_info);
2656 if ((flags & (RhoValue|SigmaValue)) == 0)
2657 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2658 if ((flags & SigmaValue) == 0)
2659 geometry_info.sigma=1.0;
2660 if ((flags & PercentValue) != 0)
2661 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2662 new_image=AdaptiveThresholdImage(_image,(
size_t) geometry_info.rho,
2663 (
size_t) geometry_info.sigma,(
double) geometry_info.xi,
2667 if (LocaleCompare(
"level",option+1) == 0)
2674 flags=ParseGeometry(arg1,&geometry_info);
2675 if ((flags & RhoValue) == 0)
2676 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2677 black_point=geometry_info.rho;
2678 white_point=(double) QuantumRange;
2679 if ((flags & SigmaValue) != 0)
2680 white_point=geometry_info.sigma;
2682 if ((flags & XiValue) != 0)
2683 gamma=geometry_info.xi;
2684 if ((flags & PercentValue) != 0)
2686 black_point*=(double) QuantumRange/100.0;
2687 white_point*=(double) QuantumRange/100.0;
2689 if ((flags & SigmaValue) == 0)
2690 white_point=(double) QuantumRange-black_point;
2691 if (IfPlusOp || ((flags & AspectValue) != 0))
2692 (void) LevelizeImage(_image,black_point,white_point,gamma,_exception);
2694 (
void) LevelImage(_image,black_point,white_point,gamma,_exception);
2697 if (LocaleCompare(
"level-colors",option+1) == 0)
2700 token[MagickPathExtent];
2709 p=(
const char *) arg1;
2710 (void) GetNextToken(p,&p,MagickPathExtent,token);
2711 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2712 (void) QueryColorCompliance(token,AllCompliance,
2713 &black_point,_exception);
2715 (
void) QueryColorCompliance(
"#000000",AllCompliance,
2716 &black_point,_exception);
2717 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2718 (void) GetNextToken(p,&p,MagickPathExtent,token);
2720 white_point=black_point;
2723 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2724 (void) GetNextToken(p,&p,MagickPathExtent,token);
2725 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2726 (void) QueryColorCompliance(token,AllCompliance,
2727 &white_point,_exception);
2729 (
void) QueryColorCompliance(
"#ffffff",AllCompliance,
2730 &white_point,_exception);
2732 (void) LevelImageColors(_image,&black_point,&white_point,
2733 IsPlusOp,_exception);
2736 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2742 flags=ParseGeometry(arg1,&geometry_info);
2743 if ((flags & RhoValue) == 0)
2744 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2745 black_point=geometry_info.rho;
2746 white_point=(double) _image->columns*_image->rows;
2747 if ((flags & SigmaValue) != 0)
2748 white_point=geometry_info.sigma;
2749 if ((flags & PercentValue) != 0)
2751 black_point*=(double) _image->columns*_image->rows/100.0;
2752 white_point*=(double) _image->columns*_image->rows/100.0;
2754 if ((flags & SigmaValue) == 0)
2755 white_point=(double) _image->columns*_image->rows-
2757 (void) LinearStretchImage(_image,black_point,white_point,_exception);
2760 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2763 if (IsGeometry(arg1) == MagickFalse)
2764 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2765 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2766 if ((flags & XValue) == 0)
2768 if ((flags & YValue) == 0)
2770 new_image=LiquidRescaleImage(_image,geometry.width,
2771 geometry.height,1.0*geometry.x,1.0*geometry.y,_exception);
2774 if (LocaleCompare(
"local-contrast",option+1) == 0)
2776 flags=ParseGeometry(arg1,&geometry_info);
2777 if ((flags & RhoValue) == 0)
2778 geometry_info.rho=10;
2779 if ((flags & SigmaValue) == 0)
2780 geometry_info.sigma=12.5;
2781 new_image=LocalContrastImage(_image,geometry_info.rho,
2782 geometry_info.sigma,exception);
2785 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2789 if (LocaleCompare(
"magnify",option+1) == 0)
2791 new_image=MagnifyImage(_image,_exception);
2794 if (LocaleCompare(
"map",option+1) == 0)
2796 CLIWandWarnReplaced(
"-remap");
2797 (void) CLISimpleOperatorImage(cli_wand,
"-remap",arg1,NULL,exception);
2800 if (LocaleCompare(
"mask",option+1) == 0)
2810 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2817 mask=GetImageCache(_image_info,arg1,_exception);
2818 if (mask == (Image *) NULL)
2820 (void) SetImageMask(_image,WritePixelMask,mask,_exception);
2821 mask=DestroyImage(mask);
2824 if (LocaleCompare(
"matte",option+1) == 0)
2826 CLIWandWarnReplaced(IfNormalOp?
"-alpha Set":
"-alpha Off");
2827 (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel :
2828 DeactivateAlphaChannel, _exception);
2831 if (LocaleCompare(
"mean-shift",option+1) == 0)
2833 flags=ParseGeometry(arg1,&geometry_info);
2834 if ((flags & (RhoValue|SigmaValue)) == 0)
2835 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2836 if ((flags & SigmaValue) == 0)
2837 geometry_info.sigma=1.0;
2838 if ((flags & XiValue) == 0)
2839 geometry_info.xi=0.10*(double) QuantumRange;
2840 if ((flags & PercentValue) != 0)
2841 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2842 new_image=MeanShiftImage(_image,(
size_t) geometry_info.rho,
2843 (
size_t) geometry_info.sigma,geometry_info.xi,_exception);
2846 if (LocaleCompare(
"median",option+1) == 0)
2848 CLIWandWarnReplaced(
"-statistic Median");
2849 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"Median",arg1,exception);
2852 if (LocaleCompare(
"mode",option+1) == 0)
2855 CLIWandWarnReplaced(
"-statistic Mode");
2856 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"Mode",arg1,
2860 if (LocaleCompare(
"modulate",option+1) == 0)
2862 if (IsGeometry(arg1) == MagickFalse)
2863 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2864 (void) ModulateImage(_image,arg1,_exception);
2867 if (LocaleCompare(
"monitor",option+1) == 0)
2869 (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress :
2870 (MagickProgressMonitor) NULL,(
void *) NULL);
2873 if (LocaleCompare(
"moments",option+1) == 0)
2875 CLIWandWarnReplaced(
"-verbose -define identify:moments=");
2878 (void) DeleteImageArtifact(_image,
"identify:moments");
2881 (void) SetImageArtifact(_image,
"identify:moments",
"true");
2882 (void) SetImageArtifact(_image,
"verbose",
"true");
2885 if (LocaleCompare(
"monochrome",option+1) == 0)
2887 (void) SetImageType(_image,BilevelType,_exception);
2890 if (LocaleCompare(
"morphology",option+1) == 0)
2893 token[MagickPathExtent];
2905 (void) GetNextToken(p,&p,MagickPathExtent,token);
2906 parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
2908 CLIWandExceptArgBreak(OptionError,
"UnrecognizedFunction",option,
2911 (void) GetNextToken(p,&p,MagickPathExtent,token);
2912 if ((*p ==
':') || (*p ==
','))
2913 (void) GetNextToken(p,&p,MagickPathExtent,token);
2915 iterations=(ssize_t) StringToLong(p);
2916 kernel=AcquireKernelInfo(arg2,exception);
2917 if (kernel == (KernelInfo *) NULL)
2918 CLIWandExceptArgBreak(OptionError,
"UnabletoParseKernel",option,arg2);
2919 new_image=MorphologyImage(_image,(MorphologyMethod)parse,iterations,
2921 kernel=DestroyKernelInfo(kernel);
2924 if (LocaleCompare(
"motion-blur",option+1) == 0)
2926 flags=ParseGeometry(arg1,&geometry_info);
2927 if ((flags & (RhoValue|SigmaValue)) == 0)
2928 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2929 if ((flags & SigmaValue) == 0)
2930 geometry_info.sigma=1.0;
2931 new_image=MotionBlurImage(_image,geometry_info.rho,
2932 geometry_info.sigma,geometry_info.xi,_exception);
2935 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2939 if (LocaleCompare(
"negate",option+1) == 0)
2941 (void) NegateImage(_image, IsPlusOp, _exception);
2944 if (LocaleCompare(
"noise",option+1) == 0)
2954 CLIWandWarnReplaced(
"-statistic NonPeak");
2955 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"NonPeak",arg1,exception);
2958 parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1);
2960 CLIWandExceptArgBreak(OptionError,
"UnrecognizedNoiseType",
2963 value=GetImageOption(_image_info,
"attenuate");
2964 if (value != (
const char *) NULL)
2965 attenuate=StringToDouble(value,(
char **) NULL);
2966 new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate,
2970 if (LocaleCompare(
"normalize",option+1) == 0)
2972 (void) NormalizeImage(_image,_exception);
2975 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2979 if (LocaleCompare(
"opaque",option+1) == 0)
2984 (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
2985 (void) OpaquePaintImage(_image,&target,&_draw_info->fill,IsPlusOp,
2989 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2991 (void) OrderedDitherImage(_image,arg1,_exception);
2994 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2998 if (LocaleCompare(
"paint",option+1) == 0)
3000 flags=ParseGeometry(arg1,&geometry_info);
3001 if ((flags & (RhoValue|SigmaValue)) == 0)
3002 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3003 new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma,
3007 if (LocaleCompare(
"perceptible",option+1) == 0)
3009 (void) PerceptibleImage(_image,StringToDouble(arg1,(
char **) NULL),
3013 if (LocaleCompare(
"polaroid",option+1) == 0)
3025 random_info=AcquireRandomInfo();
3026 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
3027 random_info=DestroyRandomInfo(random_info);
3030 flags=ParseGeometry(arg1,&geometry_info);
3031 if ((flags & RhoValue) == 0)
3032 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3033 angle=geometry_info.rho;
3035 caption=GetImageProperty(_image,
"caption",_exception);
3036 new_image=PolaroidImage(_image,_draw_info,caption,angle,
3037 _image->interpolate,_exception);
3040 if (LocaleCompare(
"posterize",option+1) == 0)
3042 flags=ParseGeometry(arg1,&geometry_info);
3043 if ((flags & RhoValue) == 0)
3044 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3045 (void) PosterizeImage(_image,(
size_t) geometry_info.rho,
3046 _quantize_info->dither_method,_exception);
3049 if (LocaleCompare(
"preview",option+1) == 0)
3055 parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1);
3057 CLIWandExceptArgBreak(OptionError,
"UnrecognizedPreviewType",
3059 new_image=PreviewImage(_image,(PreviewType)parse,_exception);
3062 if (LocaleCompare(
"profile",option+1) == 0)
3079 (void) ProfileImage(_image,arg1,(
const unsigned char *)
3084 profile_info=CloneImageInfo(_image_info);
3085 profile=GetImageProfile(_image,
"iptc");
3086 if (profile != (
const StringInfo *) NULL)
3087 profile_info->profile=(
void *) CloneStringInfo(profile);
3088 profile_image=GetImageCache(profile_info,arg1,_exception);
3089 profile_info=DestroyImageInfo(profile_info);
3090 if (profile_image == (Image *) NULL)
3095 profile_info=CloneImageInfo(_image_info);
3096 (void) CopyMagickString(profile_info->filename,arg1,
3098 new_profile=FileToStringInfo(profile_info->filename,~0UL,
3100 if (new_profile != (StringInfo *) NULL)
3102 (void) SetImageInfo(profile_info,0,_exception);
3103 (void) ProfileImage(_image,profile_info->magick,
3104 GetStringInfoDatum(new_profile),(
size_t)
3105 GetStringInfoLength(new_profile),_exception);
3106 new_profile=DestroyStringInfo(new_profile);
3108 profile_info=DestroyImageInfo(profile_info);
3111 ResetImageProfileIterator(profile_image);
3112 name=GetNextImageProfile(profile_image);
3113 while (name != (
const char *) NULL)
3115 profile=GetImageProfile(profile_image,name);
3116 if (profile != (
const StringInfo *) NULL)
3117 (void) ProfileImage(_image,name,GetStringInfoDatum(profile),
3118 (
size_t) GetStringInfoLength(profile),_exception);
3119 name=GetNextImageProfile(profile_image);
3121 profile_image=DestroyImage(profile_image);
3124 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3128 if (LocaleCompare(
"raise",option+1) == 0)
3130 if (IsGeometry(arg1) == MagickFalse)
3131 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3132 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3133 (void) RaiseImage(_image,&geometry,IsNormalOp,_exception);
3136 if (LocaleCompare(
"random-threshold",option+1) == 0)
3142 if (IsGeometry(arg1) == MagickFalse)
3143 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3145 max_threshold=(double) QuantumRange;
3146 flags=ParseGeometry(arg1,&geometry_info);
3147 min_threshold=geometry_info.rho;
3148 max_threshold=geometry_info.sigma;
3149 if ((flags & SigmaValue) == 0)
3150 max_threshold=min_threshold;
3151 if (arg1 == (
char *) NULL)
3153 if (strchr(arg1,
'%') != (
char *) NULL)
3155 max_threshold*=(0.01*(double) QuantumRange);
3156 min_threshold*=(0.01*(double) QuantumRange);
3158 (void) RandomThresholdImage(_image,min_threshold,max_threshold,
3162 if (LocaleCompare(
"range-threshold",option+1) == 0)
3167 if (IsGeometry(arg1) == MagickFalse)
3168 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3169 flags=ParseGeometry(arg1,&geometry_info);
3170 if ((flags & SigmaValue) == 0)
3171 geometry_info.sigma=geometry_info.rho;
3172 if ((flags & XiValue) == 0)
3173 geometry_info.xi=geometry_info.sigma;
3174 if ((flags & PsiValue) == 0)
3175 geometry_info.psi=geometry_info.xi;
3176 if (strchr(arg1,
'%') != (
char *) NULL)
3178 geometry_info.rho*=(0.01*(double) QuantumRange);
3179 geometry_info.sigma*=(0.01*(double) QuantumRange);
3180 geometry_info.xi*=(0.01*(double) QuantumRange);
3181 geometry_info.psi*=(0.01*(double) QuantumRange);
3183 (void) RangeThresholdImage(_image,geometry_info.rho,
3184 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3187 if (LocaleCompare(
"read-mask",option+1) == 0)
3195 (void) SetImageMask(_image,ReadPixelMask,(
const Image *) NULL,
3200 mask=GetImageCache(_image_info,arg1,_exception);
3201 if (mask == (Image *) NULL)
3203 (void) SetImageMask(_image,ReadPixelMask,mask,_exception);
3204 mask=DestroyImage(mask);
3207 if (LocaleCompare(
"recolor",option+1) == 0)
3209 CLIWandWarnReplaced(
"-color-matrix");
3210 (void) CLISimpleOperatorImage(cli_wand,
"-color-matrix",arg1,NULL,
3213 if (LocaleCompare(
"region",option+1) == 0)
3217 (void) SetImageRegionMask(_image,WritePixelMask,
3218 (
const RectangleInfo *) NULL,_exception);
3221 if (IsGeometry(arg1) == MagickFalse)
3222 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3223 (void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
3224 (void) SetImageRegionMask(_image,WritePixelMask,&geometry,_exception);
3227 if (LocaleCompare(
"remap",option+1) == 0)
3233 remap_image=GetImageCache(_image_info,arg1,_exception);
3234 if (remap_image == (Image *) NULL)
3236 (void) RemapImage(_quantize_info,_image,remap_image,_exception);
3237 remap_image=DestroyImage(remap_image);
3240 if (LocaleCompare(
"repage",option+1) == 0)
3244 if (IsGeometry(arg1) == MagickFalse)
3245 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,
3247 (void) ResetImagePage(_image,arg1);
3250 (
void) ParseAbsoluteGeometry(
"0x0+0+0",&_image->page);
3253 if (LocaleCompare(
"resample",option+1) == 0)
3256 flags=ParseGeometry(arg1,&geometry_info);
3257 if ((flags & (RhoValue|SigmaValue)) == 0)
3258 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3259 if ((flags & SigmaValue) == 0)
3260 geometry_info.sigma=geometry_info.rho;
3261 new_image=ResampleImage(_image,geometry_info.rho,
3262 geometry_info.sigma,_image->filter,_exception);
3265 if (LocaleCompare(
"reshape",option+1) == 0)
3267 if (IsGeometry(arg1) == MagickFalse)
3268 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3269 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3270 (void) ReshapePixelCache(_image,geometry.width,geometry.height,
3274 if (LocaleCompare(
"resize",option+1) == 0)
3276 if (IsGeometry(arg1) == MagickFalse)
3277 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3278 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3279 new_image=ResizeImage(_image,geometry.width,geometry.height,
3280 _image->filter,_exception);
3283 if (LocaleCompare(
"roll",option+1) == 0)
3285 if (IsGeometry(arg1) == MagickFalse)
3286 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3287 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3288 if ((flags & PercentValue) != 0)
3290 geometry.x*=(ssize_t) (_image->columns/100.0);
3291 geometry.y*=(ssize_t) (_image->rows/100.0);
3293 new_image=RollImage(_image,geometry.x,geometry.y,_exception);
3296 if (LocaleCompare(
"rotate",option+1) == 0)
3298 flags=ParseGeometry(arg1,&geometry_info);
3299 if ((flags & RhoValue) == 0)
3300 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3301 if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows))
3303 if ((flags & LessValue) != 0 && (_image->columns >= _image->rows))
3305 new_image=RotateImage(_image,geometry_info.rho,_exception);
3308 if (LocaleCompare(
"rotational-blur",option+1) == 0)
3310 flags=ParseGeometry(arg1,&geometry_info);
3311 if ((flags & RhoValue) == 0)
3312 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3313 new_image=RotationalBlurImage(_image,geometry_info.rho,_exception);
3316 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3320 if (LocaleCompare(
"sample",option+1) == 0)
3323 if (IsGeometry(arg1) == MagickFalse)
3324 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3325 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3326 new_image=SampleImage(_image,geometry.width,geometry.height,
3330 if (LocaleCompare(
"scale",option+1) == 0)
3333 if (IsGeometry(arg1) == MagickFalse)
3334 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3335 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3336 new_image=ScaleImage(_image,geometry.width,geometry.height,
3340 if (LocaleCompare(
"segment",option+1) == 0)
3342 flags=ParseGeometry(arg1,&geometry_info);
3343 if ((flags & (RhoValue|SigmaValue)) == 0)
3344 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3345 if ((flags & SigmaValue) == 0)
3346 geometry_info.sigma=1.0;
3347 (void) SegmentImage(_image,_image->colorspace,
3348 _image_info->verbose,geometry_info.rho,geometry_info.sigma,
3352 if (LocaleCompare(
"selective-blur",option+1) == 0)
3354 flags=ParseGeometry(arg1,&geometry_info);
3355 if ((flags & (RhoValue|SigmaValue)) == 0)
3356 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3357 if ((flags & SigmaValue) == 0)
3358 geometry_info.sigma=1.0;
3359 if ((flags & PercentValue) != 0)
3360 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3361 new_image=SelectiveBlurImage(_image,geometry_info.rho,
3362 geometry_info.sigma,geometry_info.xi,_exception);
3365 if (LocaleCompare(
"separate",option+1) == 0)
3369 new_image=SeparateImages(_image,_exception);
3372 if (LocaleCompare(
"sepia-tone",option+1) == 0)
3374 if (IsGeometry(arg1) == MagickFalse)
3375 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3376 new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1,
3377 (
double) QuantumRange+1.0),_exception);
3380 if (LocaleCompare(
"shade",option+1) == 0)
3382 flags=ParseGeometry(arg1,&geometry_info);
3383 if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0))
3384 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3385 new_image=ShadeImage(_image,IsNormalOp,geometry_info.rho,
3386 geometry_info.sigma,_exception);
3389 if (LocaleCompare(
"shadow",option+1) == 0)
3391 flags=ParseGeometry(arg1,&geometry_info);
3392 if ((flags & (RhoValue|SigmaValue)) == 0)
3393 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3394 if ((flags & SigmaValue) == 0)
3395 geometry_info.sigma=1.0;
3396 if ((flags & XiValue) == 0)
3397 geometry_info.xi=4.0;
3398 if ((flags & PsiValue) == 0)
3399 geometry_info.psi=4.0;
3400 new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma,
3401 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3402 ceil(geometry_info.psi-0.5),_exception);
3405 if (LocaleCompare(
"sharpen",option+1) == 0)
3407 flags=ParseGeometry(arg1,&geometry_info);
3408 if ((flags & (RhoValue|SigmaValue)) == 0)
3409 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3410 if ((flags & SigmaValue) == 0)
3411 geometry_info.sigma=1.0;
3412 if ((flags & XiValue) == 0)
3413 geometry_info.xi=0.0;
3414 new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma,
3418 if (LocaleCompare(
"shave",option+1) == 0)
3420 if (IsGeometry(arg1) == MagickFalse)
3421 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3422 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3423 new_image=ShaveImage(_image,&geometry,_exception);
3426 if (LocaleCompare(
"shear",option+1) == 0)
3428 flags=ParseGeometry(arg1,&geometry_info);
3429 if ((flags & RhoValue) == 0)
3430 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3431 if ((flags & SigmaValue) == 0)
3432 geometry_info.sigma=geometry_info.rho;
3433 new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma,
3437 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
3439 flags=ParseGeometry(arg1,&geometry_info);
3440 if ((flags & RhoValue) == 0)
3441 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3442 if ((flags & SigmaValue) == 0)
3443 geometry_info.sigma=(double) QuantumRange/2.0;
3444 if ((flags & PercentValue) != 0)
3445 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3447 (void) SigmoidalContrastImage(_image,IsNormalOp,geometry_info.rho,
3448 geometry_info.sigma,_exception);
3451 if (LocaleCompare(
"sketch",option+1) == 0)
3453 flags=ParseGeometry(arg1,&geometry_info);
3454 if ((flags & (RhoValue|SigmaValue)) == 0)
3455 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3456 if ((flags & SigmaValue) == 0)
3457 geometry_info.sigma=1.0;
3458 new_image=SketchImage(_image,geometry_info.rho,
3459 geometry_info.sigma,geometry_info.xi,_exception);
3462 if (LocaleCompare(
"solarize",option+1) == 0)
3464 if (IsGeometry(arg1) == MagickFalse)
3465 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3466 (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(
double)
3467 QuantumRange+1.0),_exception);
3470 if (LocaleCompare(
"sort-pixels",option+1) == 0)
3472 (void) SortImagePixels(_image,_exception);
3475 if (LocaleCompare(
"sparse-color",option+1) == 0)
3477 parse=ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1);
3479 CLIWandExceptArgBreak(OptionError,
"UnrecognizedSparseColorMethod",
3481 new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2,
3485 if (LocaleCompare(
"splice",option+1) == 0)
3487 if (IsGeometry(arg1) == MagickFalse)
3488 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3489 flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
3490 new_image=SpliceImage(_image,&geometry,_exception);
3493 if (LocaleCompare(
"spread",option+1) == 0)
3495 flags=ParseGeometry(arg1,&geometry_info);
3496 if ((flags & RhoValue) == 0)
3497 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
3498 new_image=SpreadImage(_image,_image->interpolate,geometry_info.rho,
3502 if (LocaleCompare(
"statistic",option+1) == 0)
3504 parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1);
3506 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStatisticType",
3508 flags=ParseGeometry(arg2,&geometry_info);
3509 if ((flags & RhoValue) == 0)
3510 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
3511 if ((flags & SigmaValue) == 0)
3512 geometry_info.sigma=geometry_info.rho;
3513 new_image=StatisticImage(_image,(StatisticType)parse,
3514 (
size_t) geometry_info.rho,(
size_t) geometry_info.sigma,
3518 if (LocaleCompare(
"strip",option+1) == 0)
3520 (void) StripImage(_image,_exception);
3523 if (LocaleCompare(
"swirl",option+1) == 0)
3525 flags=ParseGeometry(arg1,&geometry_info);
3526 if ((flags & RhoValue) == 0)
3527 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3528 new_image=SwirlImage(_image,geometry_info.rho,
3529 _image->interpolate,_exception);
3532 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3536 if (LocaleCompare(
"threshold",option+1) == 0)
3541 threshold=(double) QuantumRange/2;
3543 if (IsGeometry(arg1) == MagickFalse)
3544 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3545 threshold=StringToDoubleInterval(arg1,(
double) QuantumRange+1.0);
3547 (void) BilevelImage(_image,threshold,_exception);
3550 if (LocaleCompare(
"thumbnail",option+1) == 0)
3552 if (IsGeometry(arg1) == MagickFalse)
3553 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3554 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3555 new_image=ThumbnailImage(_image,geometry.width,geometry.height,
3559 if (LocaleCompare(
"tint",option+1) == 0)
3561 if (IsGeometry(arg1) == MagickFalse)
3562 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3563 new_image=TintImage(_image,arg1,&_draw_info->fill,_exception);
3566 if (LocaleCompare(
"transform",option+1) == 0)
3568 CLIWandWarnReplaced(
"+distort AffineProjection");
3569 new_image=AffineTransformImage(_image,&_draw_info->affine,_exception);
3572 if (LocaleCompare(
"transparent",option+1) == 0)
3577 (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
3578 (void) TransparentPaintImage(_image,&target,(Quantum)
3579 TransparentAlpha,IsPlusOp,_exception);
3582 if (LocaleCompare(
"transpose",option+1) == 0)
3584 new_image=TransposeImage(_image,_exception);
3587 if (LocaleCompare(
"transverse",option+1) == 0)
3589 new_image=TransverseImage(_image,_exception);
3592 if (LocaleCompare(
"trim",option+1) == 0)
3594 new_image=TrimImage(_image,_exception);
3597 if (LocaleCompare(
"type",option+1) == 0)
3600 (void) SetImageType(_image,_image_info->type,_exception);
3603 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3607 if (LocaleCompare(
"unique",option+1) == 0)
3614 (void) DeleteImageArtifact(_image,
"identify:unique-colors");
3617 (void) SetImageArtifact(_image,
"identify:unique-colors",
"true");
3618 (void) SetImageArtifact(_image,
"verbose",
"true");
3621 if (LocaleCompare(
"unique-colors",option+1) == 0)
3623 new_image=UniqueImageColors(_image,_exception);
3626 if (LocaleCompare(
"unsharp",option+1) == 0)
3628 flags=ParseGeometry(arg1,&geometry_info);
3629 if ((flags & (RhoValue|SigmaValue)) == 0)
3630 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3631 if ((flags & SigmaValue) == 0)
3632 geometry_info.sigma=1.0;
3633 if ((flags & XiValue) == 0)
3634 geometry_info.xi=1.0;
3635 if ((flags & PsiValue) == 0)
3636 geometry_info.psi=0.05;
3637 new_image=UnsharpMaskImage(_image,geometry_info.rho,
3638 geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception);
3641 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3645 if (LocaleCompare(
"verbose",option+1) == 0)
3651 (void) SetImageArtifact(_image,option+1,IfNormalOp ?
"true" :
3655 if (LocaleCompare(
"vignette",option+1) == 0)
3657 flags=ParseGeometry(arg1,&geometry_info);
3658 if ((flags & (RhoValue|SigmaValue)) == 0)
3659 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3660 if ((flags & SigmaValue) == 0)
3661 geometry_info.sigma=1.0;
3662 if ((flags & XiValue) == 0)
3663 geometry_info.xi=0.1*_image->columns;
3664 if ((flags & PsiValue) == 0)
3665 geometry_info.psi=0.1*_image->rows;
3666 if ((flags & PercentValue) != 0)
3668 geometry_info.xi*=(double) _image->columns/100.0;
3669 geometry_info.psi*=(double) _image->rows/100.0;
3671 new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma,
3672 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3673 ceil(geometry_info.psi-0.5),_exception);
3676 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3680 if (LocaleCompare(
"wave",option+1) == 0)
3682 flags=ParseGeometry(arg1,&geometry_info);
3683 if ((flags & (RhoValue|SigmaValue)) == 0)
3684 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3685 if ((flags & SigmaValue) == 0)
3686 geometry_info.sigma=1.0;
3687 new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma,
3688 _image->interpolate,_exception);
3691 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3693 flags=ParseGeometry(arg1,&geometry_info);
3694 if ((flags & RhoValue) == 0)
3695 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3696 if ((flags & PercentValue) != 0)
3698 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3699 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3702 if ((flags & SigmaValue) == 0)
3703 geometry_info.sigma=0.0;
3704 new_image=WaveletDenoiseImage(_image,geometry_info.rho,
3705 geometry_info.sigma,_exception);
3708 if (LocaleCompare(
"white-balance",option+1) == 0)
3710 (void) WhiteBalanceImage(_image,_exception);
3713 if (LocaleCompare(
"white-threshold",option+1) == 0)
3715 if (IsGeometry(arg1) == MagickFalse)
3716 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3717 (void) WhiteThresholdImage(_image,arg1,_exception);
3720 if (LocaleCompare(
"write-mask",option+1) == 0)
3728 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
3733 mask=GetImageCache(_image_info,arg1,_exception);
3734 if (mask == (Image *) NULL)
3736 (void) SetImageMask(_image,WritePixelMask,mask,_exception);
3737 mask=DestroyImage(mask);
3740 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3743 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3747 arg1=DestroyString((
char *)arg1);
3749 arg2=DestroyString((
char *)arg2);
3753 if (new_image != (Image *) NULL)
3754 ReplaceImageInListReturnLast(&_image,new_image);
3759#undef _quantize_info
3768static MagickBooleanType CLISimpleOperatorImages(MagickCLI *cli_wand,
3769 const char *option,
const char *arg1,
const char *arg2,ExceptionInfo *exception)
3771#if !USE_WAND_METHODS
3777 assert(cli_wand != (MagickCLI *) NULL);
3778 assert(cli_wand->signature == MagickWandSignature);
3779 assert(cli_wand->wand.signature == MagickWandSignature);
3780 assert(cli_wand->wand.images != (Image *) NULL);
3782 if (cli_wand->wand.debug != MagickFalse)
3783 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
3784 "- Simple Operator: %s \"%s\" \"%s\"", option,arg1,arg2);
3786#if !USE_WAND_METHODS
3789 n=GetImageListLength(cli_wand->wand.images);
3790 cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
3793 CLISimpleOperatorImage(cli_wand, option, arg1, arg2,exception);
3794 if ( cli_wand->wand.images->next == (Image *) NULL )
3796 cli_wand->wand.images=cli_wand->wand.images->next;
3799 cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
3801 MagickResetIterator(&cli_wand->wand);
3802 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
3803 (void) CLISimpleOperatorImage(cli_wand, option, arg1, arg2,exception);
3804 MagickResetIterator(&cli_wand->wand);
3840static MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand,
3841 const char *option,
const char *arg1n,
const char *arg2n)
3856#define _image_info (cli_wand->wand.image_info)
3857#define _images (cli_wand->wand.images)
3858#define _exception (cli_wand->wand.exception)
3859#define _draw_info (cli_wand->draw_info)
3860#define _quantize_info (cli_wand->quantize_info)
3861#define _process_flags (cli_wand->process_flags)
3862#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
3863#define IfNormalOp (*option=='-')
3864#define IfPlusOp (*option!='-')
3865#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse
3867 assert(cli_wand != (MagickCLI *) NULL);
3868 assert(cli_wand->signature == MagickWandSignature);
3869 assert(cli_wand->wand.signature == MagickWandSignature);
3870 assert(_images != (Image *) NULL);
3872 if (cli_wand->wand.debug != MagickFalse)
3873 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
3874 "- List Operator: %s \"%s\" \"%s\"", option,
3875 arg1n == (
const char *) NULL ?
"null" : arg1n,
3876 arg2n == (
const char *) NULL ?
"null" : arg2n);
3882 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
3883 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
3884 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
3886 if (arg1n != (
char *) NULL) {
3887 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
3888 if (arg1 == (
char *) NULL) {
3889 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
3893 if (arg2n != (
char *) NULL) {
3894 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
3895 if (arg2 == (
char *) NULL) {
3896 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
3901#undef _process_flags
3905 new_images=NewImageList();
3907 switch (*(option+1))
3911 if (LocaleCompare(
"append",option+1) == 0)
3913 new_images=AppendImages(_images,IsNormalOp,_exception);
3916 if (LocaleCompare(
"average",option+1) == 0)
3918 CLIWandWarnReplaced(
"-evaluate-sequence Mean");
3919 (void) CLIListOperatorImages(cli_wand,
"-evaluate-sequence",
"Mean",
3923 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3927 if (LocaleCompare(
"channel-fx",option+1) == 0)
3929 new_images=ChannelFxImage(_images,arg1,_exception);
3932 if (LocaleCompare(
"clut",option+1) == 0)
3941 new_images=RemoveFirstImageFromList(&_images);
3942 clut_image=RemoveFirstImageFromList(&_images);
3944 if (clut_image == (Image *) NULL)
3946 (void) ThrowMagickException(_exception,GetMagickModule(),
3947 OptionError,
"ImageSequenceRequired",
"`%s'",option);
3948 new_images=DestroyImage(new_images);
3952 (void) ClutImage(new_images,clut_image,new_images->interpolate,
3954 clut_image=DestroyImage(clut_image);
3957 if (LocaleCompare(
"coalesce",option+1) == 0)
3959 new_images=CoalesceImages(_images,_exception);
3962 if (LocaleCompare(
"combine",option+1) == 0)
3964 parse=(ssize_t) _images->colorspace;
3965 if (_images->number_channels < GetImageListLength(_images))
3966 parse=sRGBColorspace;
3968 parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);
3970 CLIWandExceptArgBreak(OptionError,
"UnrecognizedColorspace",option,
3972 new_images=CombineImages(_images,(ColorspaceType) parse,_exception);
3975 if (LocaleCompare(
"compare",option+1) == 0)
3991 image=RemoveFirstImageFromList(&_images);
3992 reconstruct_image=RemoveFirstImageFromList(&_images);
3994 if (reconstruct_image == (Image *) NULL)
3996 (void) ThrowMagickException(_exception,GetMagickModule(),
3997 OptionError,
"ImageSequenceRequired",
"`%s'",option);
3998 image=DestroyImage(image);
4002 metric=UndefinedErrorMetric;
4003 option=GetImageOption(_image_info,
"metric");
4004 if (option != (
const char *) NULL)
4005 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
4006 MagickFalse,option);
4007 new_images=CompareImages(image,reconstruct_image,metric,&distortion,
4010 reconstruct_image=DestroyImage(reconstruct_image);
4011 image=DestroyImage(image);
4014 if (LocaleCompare(
"complex",option+1) == 0)
4016 parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1);
4018 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
4020 new_images=ComplexImages(_images,(ComplexOperator) parse,_exception);
4023 if (LocaleCompare(
"composite",option+1) == 0)
4042 value=GetImageOption(_image_info,
"compose");
4043 if (value == (
const char *) NULL)
4044 compose=OverCompositeOp;
4046 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
4050 clip_to_self=GetCompositeClipToSelf(compose);
4051 value=GetImageOption(_image_info,
"compose:clip-to-self");
4052 if (value != (
const char *) NULL)
4053 clip_to_self=IsStringTrue(value);
4054 value=GetImageOption(_image_info,
"compose:outside-overlay");
4055 if (value != (
const char *) NULL)
4056 clip_to_self=IsStringFalse(value);
4058 new_images=RemoveFirstImageFromList(&_images);
4059 source_image=RemoveFirstImageFromList(&_images);
4060 if (source_image == (Image *) NULL)
4062 (void) ThrowMagickException(_exception,GetMagickModule(),
4063 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4064 new_images=DestroyImage(new_images);
4070 if (source_image->geometry != (
char *) NULL)
4075 (void) ParseRegionGeometry(source_image,source_image->geometry,
4076 &resize_geometry,_exception);
4077 if ((source_image->columns != resize_geometry.width) ||
4078 (source_image->rows != resize_geometry.height))
4083 resize_image=ResizeImage(source_image,resize_geometry.width,
4084 resize_geometry.height,source_image->filter,_exception);
4085 if (resize_image != (Image *) NULL)
4087 source_image=DestroyImage(source_image);
4088 source_image=resize_image;
4092 SetGeometry(source_image,&geometry);
4093 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
4094 GravityAdjustGeometry(new_images->columns,new_images->rows,
4095 new_images->gravity, &geometry);
4096 mask_image=RemoveFirstImageFromList(&_images);
4097 if (mask_image == (Image *) NULL)
4098 status&=(MagickStatusType) CompositeImage(new_images,source_image,
4099 compose,clip_to_self,geometry.x,geometry.y,_exception);
4105 canvas_image=CloneImage(new_images,0,0,MagickTrue,_exception);
4106 if (canvas_image == (Image *) NULL)
4110 case BlendCompositeOp:
4112 status&=(MagickStatusType) CompositeImage(new_images,
4113 source_image,compose,clip_to_self,geometry.x,geometry.y,
4115 status&=(MagickStatusType) CompositeImage(new_images,
4116 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4119 case DisplaceCompositeOp:
4120 case DistortCompositeOp:
4122 status&=(MagickStatusType) CompositeImage(source_image,
4123 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,_exception);
4124 (void) SetImageColorspace(source_image,sRGBColorspace,
4126 status&=(MagickStatusType) CompositeImage(new_images,
4127 source_image,compose,clip_to_self,geometry.x,geometry.y,
4131 case SaliencyBlendCompositeOp:
4132 case SeamlessBlendCompositeOp:
4134 status&=(MagickStatusType) CompositeImage(source_image,
4135 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4136 status&=(MagickStatusType) CompositeImage(new_images,
4137 source_image,compose,clip_to_self,geometry.x,geometry.y,
4146 clone_image=CloneImage(new_images,0,0,MagickTrue,_exception);
4147 if (clone_image == (Image *) NULL)
4149 status&=(MagickStatusType) CompositeImage(new_images,
4150 source_image,compose,clip_to_self,geometry.x,geometry.y,
4152 status&=(MagickStatusType) CompositeImage(new_images,
4153 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4154 status&=(MagickStatusType) CompositeImage(clone_image,
4155 new_images,OverCompositeOp,clip_to_self,0,0,_exception);
4156 new_images=DestroyImageList(new_images);
4157 new_images=clone_image;
4163 case DisplaceCompositeOp:
4164 case DistortCompositeOp:
4166 status&=(MagickStatusType) CompositeImage(canvas_image,
4167 new_images,CopyCompositeOp,clip_to_self,0,0,_exception);
4172 status&=(MagickStatusType) CompositeImage(canvas_image,
4173 new_images,OverCompositeOp,clip_to_self,0,0,_exception);
4177 new_images=DestroyImageList(new_images);
4178 new_images=canvas_image;
4179 mask_image=DestroyImage(mask_image);
4181 source_image=DestroyImage(source_image);
4184 if (LocaleCompare(
"copy",option+1) == 0)
4198 if (IsGeometry(arg1) == MagickFalse)
4199 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4200 if (IsGeometry(arg2) == MagickFalse)
4201 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4202 (void) ParsePageGeometry(_images,arg2,&geometry,_exception);
4203 offset.x=geometry.x;
4204 offset.y=geometry.y;
4205 source_image=_images;
4206 if (source_image->next != (Image *) NULL)
4207 source_image=source_image->next;
4208 (void) ParsePageGeometry(source_image,arg1,&geometry,_exception);
4209 (void) CopyImagePixels(_images,source_image,&geometry,&offset,
4213 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4217 if (LocaleCompare(
"deconstruct",option+1) == 0)
4219 CLIWandWarnReplaced(
"-layers CompareAny");
4220 (void) CLIListOperatorImages(cli_wand,
"-layers",
"CompareAny",NULL);
4223 if (LocaleCompare(
"delete",option+1) == 0)
4227 DeleteImages(&_images,
"-1",_exception);
4230 if (LocaleNCompare(arg1,
"registry:",9) == 0)
4232 (void) DeleteImageRegistry(arg1+9);
4235 if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
4236 CLIWandExceptionBreak(OptionError,
"InvalidArgument",option);
4237 DeleteImages(&_images,arg1,_exception);
4240 if (LocaleCompare(
"duplicate",option+1) == 0)
4243 new_images=DuplicateImages(_images,1,
"-1",_exception);
4252 if (IsGeometry(arg1) == MagickFalse)
4253 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,
4255 number_duplicates=(size_t) StringToLong(arg1);
4256 if (arg1 == (
char *) NULL)
4259 if (p == (
const char *) NULL)
4260 new_images=DuplicateImages(_images,number_duplicates,
"-1",
4263 new_images=DuplicateImages(_images,number_duplicates,p+1,
4266 AppendImageToList(&_images, new_images);
4267 new_images=(Image *) NULL;
4270 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4274 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4276 parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
4278 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
4280 new_images=EvaluateImages(_images,(MagickEvaluateOperator) parse,
4284 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4288 if (LocaleCompare(
"fft",option+1) == 0)
4290 new_images=ForwardFourierTransformImage(_images,IsNormalOp,
4294 if (LocaleCompare(
"flatten",option+1) == 0)
4297 (void) CLIListOperatorImages(cli_wand,
"-layers",option+1,NULL);
4300 if (LocaleCompare(
"fx",option+1) == 0)
4302 new_images=FxImage(_images,arg1,_exception);
4305 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4309 if (LocaleCompare(
"hald-clut",option+1) == 0)
4317 new_images=RemoveFirstImageFromList(&_images);
4318 hald_image=RemoveLastImageFromList(&_images);
4319 if (hald_image == (Image *) NULL)
4321 (void) ThrowMagickException(_exception,GetMagickModule(),
4322 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4323 new_images=DestroyImage(new_images);
4327 (void) HaldClutImage(new_images,hald_image,_exception);
4328 hald_image=DestroyImage(hald_image);
4331 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4335 if (LocaleCompare(
"ift",option+1) == 0)
4341 magnitude_image=RemoveFirstImageFromList(&_images);
4342 phase_image=RemoveFirstImageFromList(&_images);
4343 if (phase_image == (Image *) NULL)
4345 (void) ThrowMagickException(_exception,GetMagickModule(),
4346 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4347 magnitude_image=DestroyImage(magnitude_image);
4351 new_images=InverseFourierTransformImage(magnitude_image,phase_image,
4352 IsNormalOp,_exception);
4353 magnitude_image=DestroyImage(magnitude_image);
4354 phase_image=DestroyImage(phase_image);
4357 if (LocaleCompare(
"insert",option+1) == 0)
4366 if (IfNormalOp && (IsGeometry(arg1) == MagickFalse))
4367 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4369 insert_image=RemoveLastImageFromList(&_images);
4371 index=(ssize_t) StringToLong(arg1);
4372 index_image=insert_image;
4374 PrependImageToList(&_images,insert_image);
4375 else if (index == (ssize_t) GetImageListLength(_images))
4376 AppendImageToList(&_images,insert_image);
4379 index_image=GetImageFromList(_images,index-1);
4380 if (index_image == (Image *) NULL)
4382 insert_image=DestroyImage(insert_image);
4383 CLIWandExceptArgBreak(OptionError,
"NoSuchImage",option,arg1);
4385 InsertImageInList(&index_image,insert_image);
4387 _images=GetFirstImageInList(index_image);
4390 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4394 if (LocaleCompare(
"layers",option+1) == 0)
4396 parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1);
4398 CLIWandExceptArgBreak(OptionError,
"UnrecognizedLayerMethod",
4400 switch ((LayerMethod) parse)
4404 new_images=CoalesceImages(_images,_exception);
4407 case CompareAnyLayer:
4408 case CompareClearLayer:
4409 case CompareOverlayLayer:
4412 new_images=CompareImagesLayers(_images,(LayerMethod) parse,
4419 case TrimBoundsLayer:
4421 new_images=MergeImageLayers(_images,(LayerMethod) parse,
4427 new_images=DisposeImages(_images,_exception);
4430 case OptimizeImageLayer:
4432 new_images=OptimizeImageLayers(_images,_exception);
4435 case OptimizePlusLayer:
4437 new_images=OptimizePlusImageLayers(_images,_exception);
4440 case OptimizeTransLayer:
4442 OptimizeImageTransparency(_images,_exception);
4445 case RemoveDupsLayer:
4447 RemoveDuplicateLayers(&_images,_exception);
4450 case RemoveZeroLayer:
4452 RemoveZeroDelayLayers(&_images,_exception);
4457 new_images=CoalesceImages(_images,_exception);
4458 if (new_images == (Image *) NULL)
4460 _images=DestroyImageList(_images);
4461 _images=OptimizeImageLayers(new_images,_exception);
4462 if (_images == (Image *) NULL)
4464 new_images=DestroyImageList(new_images);
4465 OptimizeImageTransparency(_images,_exception);
4466 (void) RemapImages(_quantize_info,_images,(Image *) NULL,
4470 case CompositeLayer:
4484 value=GetImageOption(_image_info,
"compose");
4485 compose=OverCompositeOp;
4486 if (value != (
const char *) NULL)
4487 compose=(CompositeOperator) ParseCommandOption(
4488 MagickComposeOptions,MagickFalse,value);
4492 while (source != (Image *) NULL)
4494 source=GetNextImageInList(source);
4495 if ((source != (Image *) NULL) &&
4496 (LocaleCompare(source->magick,
"NULL") == 0))
4499 if (source != (Image *) NULL)
4501 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4502 (GetNextImageInList(source) == (Image *) NULL))
4503 source=(Image *) NULL;
4506 source=SplitImageList(source->previous);
4507 DeleteImageFromList(&source);
4510 if (source == (Image *) NULL)
4512 (void) ThrowMagickException(_exception,GetMagickModule(),
4513 OptionError,
"MissingNullSeparator",
"layers Composite");
4517 SetGeometry(_images,&geometry);
4518 (void) ParseAbsoluteGeometry(_images->geometry,&geometry);
4519 geometry.width=source->page.width != 0 ?
4520 source->page.width : source->columns;
4521 geometry.height=source->page.height != 0 ?
4522 source->page.height : source->rows;
4523 GravityAdjustGeometry(_images->page.width != 0 ?
4524 _images->page.width : _images->columns,
4525 _images->page.height != 0 ? _images->page.height :
4526 _images->rows,_images->gravity,&geometry);
4529 CompositeLayers(_images,compose,source,geometry.x,geometry.y,
4531 source=DestroyImageList(source);
4537 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4541 if (LocaleCompare(
"map",option+1) == 0)
4543 CLIWandWarnReplaced(
"+remap");
4544 (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);
4547 if (LocaleCompare(
"metric",option+1) == 0)
4549 (void) SetImageOption(_image_info,option+1,arg1);
4552 if (LocaleCompare(
"morph",option+1) == 0)
4557 if (IsGeometry(arg1) == MagickFalse)
4558 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4559 morph_image=MorphImages(_images,StringToUnsignedLong(arg1),
4561 if (morph_image == (Image *) NULL)
4563 _images=DestroyImageList(_images);
4564 _images=morph_image;
4567 if (LocaleCompare(
"mosaic",option+1) == 0)
4570 (void) CLIListOperatorImages(cli_wand,
"-layers",option+1,NULL);
4573 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4577 if (LocaleCompare(
"poly",option+1) == 0)
4586 args = StringToArrayOfDoubles(arg1,&count,_exception);
4587 if (args == (
double *) NULL )
4588 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg1);
4589 new_images=PolynomialImage(_images,(
size_t) (count >> 1),args,
4591 args=(
double *) RelinquishMagickMemory(args);
4594 if (LocaleCompare(
"process",option+1) == 0)
4596#define DestroyArguments(arguments,number_arguments) \
4600 for ( ; j < (ssize_t) (number_arguments); j++) \
4601 (arguments)[j]=DestroyString((arguments)[j]); \
4602 (arguments)=(char **) RelinquishMagickMemory(arguments); \
4611 arguments=StringToArgv(arg1,&number_arguments);
4612 if ((arguments == (
char **) NULL) || (number_arguments == 1))
4614 DestroyArguments(arguments,number_arguments);
4617 if (strchr(arguments[1],
'=') != (
char *) NULL)
4640 assert(arg1 != (
const char *) NULL);
4641 length=strlen(arg1);
4642 token=(
char *) NULL;
4643 if (~length >= (MagickPathExtent-1))
4644 token=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
4646 if (token == (
char *) NULL)
4648 DestroyArguments(arguments,number_arguments);
4653 token_info=AcquireTokenInfo();
4654 tokenizer_status=Tokenizer(token_info,0,token,length,p,
"",
"=",
4655 "\"",
'\0',&breaker,&next,"e);
4656 token_info=DestroyTokenInfo(token_info);
4657 if (tokenizer_status == 0)
4663 (void) InvokeDynamicImageFilter(token,&_images,1,&argv,
4666 token=DestroyString(token);
4667 DestroyArguments(arguments,number_arguments);
4670 (void) SubstituteString(&arguments[1],
"-",
"");
4671 (void) InvokeDynamicImageFilter(arguments[1],&_images,
4672 number_arguments-2,(
const char **) arguments+2,_exception);
4673 DestroyArguments(arguments,number_arguments);
4676 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4680 if (LocaleCompare(
"remap",option+1) == 0)
4682 (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);
4685 if (LocaleCompare(
"reverse",option+1) == 0)
4687 ReverseImageList(&_images);
4690 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4694 if (LocaleCompare(
"smush",option+1) == 0)
4700 if (IsGeometry(arg1) == MagickFalse)
4701 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4702 offset=(ssize_t) StringToLong(arg1);
4703 new_images=SmushImages(_images,IsNormalOp,offset,_exception);
4706 if (LocaleCompare(
"subimage",option+1) == 0)
4724 base_image=GetImageFromList(_images,0);
4725 compare_image=GetImageFromList(_images,1);
4728 metric=UndefinedErrorMetric;
4729 value=GetImageOption(_image_info,
"metric");
4730 if (value != (
const char *) NULL)
4731 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
4734 new_images=SimilarityImage(base_image,compare_image,metric,0.0,
4735 &offset,&similarity,_exception);
4737 if (new_images != (Image *) NULL)
4739 (void) FormatImageProperty(new_images,
"subimage:similarity",
4740 "%.*g",GetMagickPrecision(),similarity);
4741 (void) FormatImageProperty(new_images,
"subimage:x",
"%+ld",(
long)
4743 (void) FormatImageProperty(new_images,
"subimage:y",
"%+ld",(
long)
4745 (void) FormatImageProperty(new_images,
"subimage:offset",
4746 "%lux%lu%+ld%+ld",(
unsigned long) offset.width,(
unsigned long)
4747 offset.height,(
long) offset.x,(
long) offset.y);
4751 if (LocaleCompare(
"swap",option+1) == 0)
4772 flags=ParseGeometry(arg1,&geometry_info);
4773 if ((flags & RhoValue) == 0)
4774 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4775 index=(ssize_t) geometry_info.rho;
4776 if ((flags & SigmaValue) != 0)
4777 swap_index=(ssize_t) geometry_info.sigma;
4779 p=GetImageFromList(_images,index);
4780 q=GetImageFromList(_images,swap_index);
4781 if ((p == (Image *) NULL) || (q == (Image *) NULL)) {
4783 CLIWandExceptArgBreak(OptionError,
"InvalidImageIndex",option,arg1)
4785 CLIWandExceptionBreak(OptionError,
"TwoOrMoreImagesRequired",option);
4788 CLIWandExceptArgBreak(OptionError,
"InvalidImageIndex",option,arg1);
4789 swap=CloneImage(p,0,0,MagickTrue,_exception);
4790 if (swap == (Image *) NULL)
4791 CLIWandExceptArgBreak(ResourceLimitError,
"MemoryAllocationFailed",
4792 option,(
char *) NULL);
4793 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));
4794 ReplaceImageInList(&q,swap);
4795 _images=GetFirstImageInList(q);
4798 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4801 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4806 arg1=DestroyString((
char *)arg1);
4808 arg2=DestroyString((
char *)arg2);
4811 if (new_images == (Image *) NULL)
4812 return(status == 0 ? MagickFalse : MagickTrue);
4813 _images=DestroyImageList(_images);
4814 _images=GetFirstImageInList(new_images);
4815 return(status == 0 ? MagickFalse : MagickTrue);
4821#undef _quantize_info
4863static void CLINoImageOperator(MagickCLI *cli_wand,
const char *option,
4864 const char *arg1n,
const char *arg2n)
4870#define _image_info (cli_wand->wand.image_info)
4871#define _images (cli_wand->wand.images)
4872#define _exception (cli_wand->wand.exception)
4873#define _process_flags (cli_wand->process_flags)
4874#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
4875#define IfNormalOp (*option=='-')
4876#define IfPlusOp (*option!='-')
4878 assert(cli_wand != (MagickCLI *) NULL);
4879 assert(cli_wand->signature == MagickWandSignature);
4880 assert(cli_wand->wand.signature == MagickWandSignature);
4882 if (cli_wand->wand.debug != MagickFalse)
4883 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
4884 "- NoImage Operator: %s \"%s\" \"%s\"", option,
4885 arg1n != (
char *) NULL ? arg1n :
"",
4886 arg2n != (
char *) NULL ? arg2n :
"");
4889 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
4890 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
4891 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
4893 if (arg1n != (
char *) NULL) {
4894 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
4895 if (arg1 == (
char *) NULL) {
4896 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
4900 if (arg2n != (
char *) NULL) {
4901 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
4902 if (arg2 == (
char *) NULL) {
4903 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
4908#undef _process_flags
4915 if (LocaleCompare(
"noop",option+1) == 0)
4917 if (LocaleCompare(
"sans",option+1) == 0)
4919 if (LocaleCompare(
"sans0",option+1) == 0)
4921 if (LocaleCompare(
"sans1",option+1) == 0)
4923 if (LocaleCompare(
"sans2",option+1) == 0)
4928 if ( ( LocaleCompare(
"read",option+1) == 0 ) ||
4929 ( LocaleCompare(
"--",option) == 0 ) ) {
4935 argv = (
char **) &arg1;
4937 if (ExpandFilenames(&argc,&argv) == MagickFalse)
4938 CLIWandExceptArgBreak(ResourceLimitError,
"MemoryAllocationFailed",
4939 option,(
char *) NULL);
4941 for (i=0; i < (ssize_t) argc; i++) {
4943 if (_image_info->ping != MagickFalse)
4944 new_images=PingImages(_image_info,argv[i],_exception);
4946 new_images=ReadImages(_image_info,argv[i],_exception);
4947 AppendImageToList(&_images, new_images);
4948 argv[i]=DestroyString(argv[i]);
4950 argv=(
char **) RelinquishMagickMemory(argv);
4957 if (LocaleCompare(
"write",option+1) == 0) {
4958 char key[MagickPathExtent];
4959 Image *write_images;
4960 ImageInfo *write_info;
4962 if ( _images == (Image *) NULL ) {
4963 if ( LocaleCompare(arg1,
"null:") == 0 )
4965 CLIWandExceptArgBreak(OptionError,
"NoImagesForWrite",option,arg1);
4968 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",arg1);
4969 (void) DeleteImageRegistry(key);
4970 write_images=CloneImageList(_images,_exception);
4971 write_info=CloneImageInfo(_image_info);
4972 if (write_images != (Image *) NULL)
4973 (void) WriteImages(write_info,write_images,arg1,_exception);
4974 write_info=DestroyImageInfo(write_info);
4975 write_images=DestroyImageList(write_images);
4981 if (LocaleCompare(
"(",option) == 0) {
4986 node=cli_wand->image_list_stack;
4987 for ( ; node != (CLIStack *) NULL; node=node->next)
4989 if ( size >= MAX_STACK_DEPTH )
4990 CLIWandExceptionBreak(OptionError,
"ParenthesisNestedTooDeeply",option);
4991 node=(CLIStack *) AcquireMagickMemory(
sizeof(*node));
4992 if (node == (CLIStack *) NULL)
4993 CLIWandExceptionBreak(ResourceLimitFatalError,
4994 "MemoryAllocationFailed",option);
4995 node->data = (
void *)cli_wand->wand.images;
4996 node->next = cli_wand->image_list_stack;
4997 cli_wand->image_list_stack = node;
4998 cli_wand->wand.images = NewImageList();
5000 if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,
5001 "respect-parentheses")) != MagickFalse)
5007 if (LocaleCompare(
"{",option) == 0) {
5012 node=cli_wand->image_info_stack;
5013 for ( ; node != (CLIStack *) NULL; node=node->next)
5015 if ( size >= MAX_STACK_DEPTH )
5016 CLIWandExceptionBreak(OptionError,
"CurlyBracesNestedTooDeeply",option);
5017 node=(CLIStack *) AcquireMagickMemory(
sizeof(*node));
5018 if (node == (CLIStack *) NULL)
5019 CLIWandExceptionBreak(ResourceLimitFatalError,
5020 "MemoryAllocationFailed",option);
5022 node->data = (
void *)cli_wand->wand.image_info;
5023 node->next = cli_wand->image_info_stack;
5025 cli_wand->image_info_stack = node;
5026 cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
5027 if (cli_wand->wand.image_info == (ImageInfo *) NULL) {
5028 CLIWandException(ResourceLimitFatalError,
"MemoryAllocationFailed",
5030 cli_wand->wand.image_info = (ImageInfo *)node->data;
5031 node = (CLIStack *)RelinquishMagickMemory(node);
5037 if (LocaleCompare(
")",option) == 0) {
5040 node = (CLIStack *)cli_wand->image_list_stack;
5041 if ( node == (CLIStack *) NULL)
5042 CLIWandExceptionBreak(OptionError,
"UnbalancedParenthesis",option);
5043 cli_wand->image_list_stack = node->next;
5045 AppendImageToList((Image **)&node->data,cli_wand->wand.images);
5046 cli_wand->wand.images= (Image *)node->data;
5047 node = (CLIStack *)RelinquishMagickMemory(node);
5049 node = cli_wand->image_info_stack;
5050 if ( node != (CLIStack *) NULL)
5052 if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,
"respect-parentheses")) != MagickFalse)
5061 if (LocaleCompare(
"}",option) == 0) {
5064 node = (CLIStack *)cli_wand->image_info_stack;
5065 if ( node == (CLIStack *) NULL)
5066 CLIWandExceptionBreak(OptionError,
"UnbalancedCurlyBraces",option);
5067 cli_wand->image_info_stack = node->next;
5069 (void) DestroyImageInfo(cli_wand->wand.image_info);
5070 cli_wand->wand.image_info = (ImageInfo *)node->data;
5071 node = (CLIStack *)RelinquishMagickMemory(node);
5073 GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
5074 cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
5075 cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
5079 if (LocaleCompare(
"print",option+1) == 0)
5081 (void) FormatLocaleFile(stdout,
"%s",arg1);
5084 if (LocaleCompare(
"set",option+1) == 0)
5092 StringInfo *profile = (StringInfo *) NULL;
5096 arg1 = DestroyString((
char *) arg1);
5099 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
5100 if (arg1 == (
char *) NULL)
5101 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
5104 if (LocaleNCompare(arg1,
"registry:",9) == 0)
5108 (void) DeleteImageRegistry(arg1+9);
5109 arg1=DestroyString((
char *)arg1);
5115 arg2 = DestroyString((
char *) arg2);
5117 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5118 if (arg2 == (
char *) NULL) {
5119 arg1=DestroyString((
char *)arg1);
5120 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
5123 (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);
5124 arg1=DestroyString((
char *)arg1);
5125 arg2=DestroyString((
char *)arg2);
5128 if (LocaleNCompare(arg1,
"option:",7) == 0)
5131 if (_images != (Image *) NULL)
5133 MagickResetIterator(&cli_wand->wand);
5134 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
5135 (void) DeleteImageArtifact(_images,arg1+7);
5136 MagickResetIterator(&cli_wand->wand);
5145 arg2 = DestroyString((
char *) arg2);
5147 arg2=InterpretImageProperties(_image_info,_images,arg2n,
5149 if (arg2 == (
char *) NULL)
5150 CLIWandExceptionBreak(OptionWarning,
5151 "InterpretPropertyFailure",option);
5153 (void) SetImageOption(_image_info,arg1+7,arg2);
5154 arg1=DestroyString((
char *) arg1);
5155 arg2=DestroyString((
char *) arg2);
5158 if (LocaleCompare(arg1,
"profile") == 0)
5160 if (arg2 != (
char *) NULL)
5161 (void) CopyMagickString(_image_info->filename,arg2,
5163 (void) SetImageInfo(_image_info,1,_exception);
5164 if (LocaleCompare(_image_info->filename,
"-") != 0)
5165 profile=FileToStringInfo(_image_info->filename,~0UL,_exception);
5168 if ( _images == (Image *) NULL )
5170 if (profile != (StringInfo *) NULL)
5171 profile=DestroyStringInfo(profile);
5172 CLIWandExceptArgBreak(OptionWarning,
"NoImageForProperty",option,arg1);
5175 MagickResetIterator(&cli_wand->wand);
5176 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
5183 arg2 = DestroyString((
char *) arg2);
5185 arg2=InterpretImageProperties(_image_info,_images,arg2n,
5187 if (arg2 == (
char *) NULL)
5189 if (profile != (StringInfo *) NULL)
5190 profile=DestroyStringInfo(profile);
5191 CLIWandExceptionBreak(OptionWarning,
5192 "InterpretPropertyFailure",option);
5195 if (LocaleNCompare(arg1,
"artifact:",9) == 0)
5196 (void) SetImageArtifact(_images,arg1+9,arg2);
5197 else if (LocaleNCompare(arg1,
"property:",9) == 0)
5198 (void) SetImageProperty(_images,arg1+9,arg2,_exception);
5200 (
void) SetImageProperty(_images,arg1,arg2,_exception);
5201 if (profile != (StringInfo *) NULL)
5202 (void) SetImageProfile(_images,_image_info->magick,profile,
5204 arg2=DestroyString((
char *)arg2);
5206 if (profile != (StringInfo *) NULL)
5207 profile=DestroyStringInfo(profile);
5208 MagickResetIterator(&cli_wand->wand);
5209 arg1=DestroyString((
char *)arg1);
5212 if (LocaleCompare(
"clone",option+1) == 0) {
5215 if (*option ==
'+') {
5218 arg1 = DestroyString((
char *)arg1);
5219 arg1=AcquireString(
"-1");
5221 if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
5222 CLIWandExceptionBreak(OptionError,
"InvalidArgument",option);
5223 new_images=cli_wand->wand.images;
5224 if (cli_wand->image_list_stack != (CLIStack *) NULL)
5225 new_images=(Image *) cli_wand->image_list_stack->data;
5226 if (new_images == (Image *) NULL)
5227 CLIWandExceptionBreak(OptionError,
"UnableToCloneImage",option);
5228 new_images=CloneImages(new_images,arg1,_exception);
5229 if (new_images == (Image *) NULL)
5230 CLIWandExceptionBreak(OptionError,
"NoSuchImage",option);
5231 AppendImageToList(&_images,new_images);
5240 if (LocaleCompare(
"version",option+1) == 0)
5242 ListMagickVersion(stdout);
5245 if (LocaleCompare(
"list",option+1) == 0)
5252 list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
5255 CLIWandExceptionArg(OptionError,
"UnrecognizedListType",option,arg1);
5260 case MagickCoderOptions:
5262 (void) ListCoderInfo((FILE *) NULL,_exception);
5265 case MagickColorOptions:
5267 (void) ListColorInfo((FILE *) NULL,_exception);
5270 case MagickConfigureOptions:
5272 (void) ListConfigureInfo((FILE *) NULL,_exception);
5275 case MagickDelegateOptions:
5277 (void) ListDelegateInfo((FILE *) NULL,_exception);
5280 case MagickFontOptions:
5282 (void) ListTypeInfo((FILE *) NULL,_exception);
5285 case MagickFormatOptions:
5286 (void) ListMagickInfo((FILE *) NULL,_exception);
5288 case MagickLocaleOptions:
5289 (void) ListLocaleInfo((FILE *) NULL,_exception);
5291 case MagickLogOptions:
5292 (void) ListLogInfo((FILE *) NULL,_exception);
5294 case MagickMagicOptions:
5295 (void) ListMagicInfo((FILE *) NULL,_exception);
5297 case MagickMimeOptions:
5298 (void) ListMimeInfo((FILE *) NULL,_exception);
5300 case MagickModuleOptions:
5301 (void) ListModuleInfo((FILE *) NULL,_exception);
5303 case MagickPagesizeOptions:
5304 (void) ListPagesizes((FILE *) NULL,_exception);
5306 case MagickPolicyOptions:
5307 (void) ListPolicyInfo((FILE *) NULL,_exception);
5309 case MagickResourceOptions:
5310 (void) ListMagickResourceInfo((FILE *) NULL,_exception);
5312 case MagickThresholdOptions:
5313 (void) ListThresholdMaps((FILE *) NULL,_exception);
5316 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
5323 CLIWandException(OptionError,
"UnrecognizedOption",option);
5325DisableMSCWarning(4127)
5331 arg1=DestroyString((
char *)arg1);
5333 arg2=DestroyString((
char *)arg2);
5387WandExport
void CLIOption(MagickCLI *cli_wand,
const char *option,...)
5396 assert(cli_wand != (MagickCLI *) NULL);
5397 assert(cli_wand->signature == MagickWandSignature);
5398 assert(cli_wand->wand.signature == MagickWandSignature);
5403 if ( cli_wand->command == (
const OptionInfo *) NULL )
5404 cli_wand->command = GetCommandOptionInfo(option);
5406 (void) FormatLocaleFile(stderr,
"CLIOption \"%s\" matched \"%s\"\n",
5407 option, cli_wand->command->mnemonic );
5409 option_type=(CommandOptionFlags) cli_wand->command->flags;
5411 if ( option_type == UndefinedOptionFlag )
5412 CLIWandExceptionReturn(OptionFatalError,
"UnrecognizedOption",option);
5414 assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 );
5417 if ( (option_type & DeprecateOptionFlag) != 0 )
5418 CLIWandExceptionBreak(OptionError,
"DeprecatedOptionNoCode",option);
5421 if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 )
5422 CLIWandExceptionBreak(OptionFatalError,
"InvalidUseOfOption",option);
5429 count = (size_t) cli_wand->command->type;
5434 va_start(operands,option);
5438 arg1=(
const char *) va_arg(operands,
const char *);
5440 arg2=(
const char *) va_arg(operands,
const char *);
5444 (void) FormatLocaleFile(stderr,
5445 "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n",
5446 option,(
long) count,option_type,arg1,arg2);
5456 if ( cli_wand->wand.images != (Image *) NULL )
5457 (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
5458 cli_wand->wand.exception);
5460 if ( (option_type & SettingOptionFlags) != 0 ) {
5461 CLISettingOptionInfo(cli_wand, option, arg1, arg2);
5468 if ((option_type & NoImageOperatorFlag) != 0)
5469 CLINoImageOperator(cli_wand, option, arg1, arg2);
5474 if ( cli_wand->wand.images == (Image *) NULL )
5475 if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) &&
5476 ((option_type & SettingOptionFlags) == 0 ))
5477 CLIWandExceptionBreak(OptionError,
"NoImagesFound",option);
5480 if ( (option_type & SimpleOperatorFlag) != 0 &&
5481 cli_wand->wand.images != (Image *) NULL)
5483 ExceptionInfo *exception=AcquireExceptionInfo();
5484 (void) CLISimpleOperatorImages(cli_wand, option, arg1, arg2,exception);
5485 exception=DestroyExceptionInfo(exception);
5489 if ( (option_type & ListOperatorFlag) != 0 )
5490 (void) CLIListOperatorImages(cli_wand, option, arg1, arg2);
5492DisableMSCWarning(4127)
5496 cli_wand->command = (
const OptionInfo *) NULL;