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*PerceptibleReciprocal(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*PerceptibleReciprocal(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))
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
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,
1971 if (LocaleCompare(
"channel",option+1) == 0)
1975 (void) SetPixelChannelMask(_image,DefaultChannels);
1978 parse=ParseChannelOption(arg1);
1980 CLIWandExceptArgBreak(OptionError,
"UnrecognizedChannelType",option,
1982 (void) SetPixelChannelMask(_image,(ChannelType) parse);
1985 if (LocaleCompare(
"charcoal",option+1) == 0)
1987 flags=ParseGeometry(arg1,&geometry_info);
1988 if ((flags & (RhoValue|SigmaValue)) == 0)
1989 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1990 if ((flags & SigmaValue) == 0)
1991 geometry_info.sigma=1.0;
1992 if ((flags & XiValue) == 0)
1993 geometry_info.xi=1.0;
1994 new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma,
1998 if (LocaleCompare(
"chop",option+1) == 0)
2000 if (IsGeometry(arg1) == MagickFalse)
2001 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2002 (void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
2003 new_image=ChopImage(_image,&geometry,_exception);
2006 if (LocaleCompare(
"clahe",option+1) == 0)
2008 if (IsGeometry(arg1) == MagickFalse)
2009 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2010 flags=ParseGeometry(arg1,&geometry_info);
2011 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2012 (void) CLAHEImage(_image,geometry.width,geometry.height,
2013 (
size_t) geometry.x,geometry_info.psi,_exception);
2016 if (LocaleCompare(
"clamp",option+1) == 0)
2018 (void) ClampImage(_image,_exception);
2021 if (LocaleCompare(
"clip",option+1) == 0)
2024 (void) ClipImage(_image,_exception);
2026 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2030 if (LocaleCompare(
"clip-mask",option+1) == 0)
2037 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2041 clip_mask=GetImageCache(_image_info,arg1,_exception);
2042 if (clip_mask == (Image *) NULL)
2044 (void) SetImageMask(_image,WritePixelMask,clip_mask,_exception);
2045 clip_mask=DestroyImage(clip_mask);
2048 if (LocaleCompare(
"clip-path",option+1) == 0)
2050 (void) ClipImagePath(_image,arg1,IsNormalOp,_exception);
2054 if (LocaleCompare(
"colorize",option+1) == 0)
2056 if (IsGeometry(arg1) == MagickFalse)
2057 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2058 new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception);
2061 if (LocaleCompare(
"color-matrix",option+1) == 0)
2066 kernel=AcquireKernelInfo(arg1,exception);
2067 if (kernel == (KernelInfo *) NULL)
2068 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2069 new_image=ColorMatrixImage(_image,kernel,_exception);
2070 kernel=DestroyKernelInfo(kernel);
2073 if (LocaleCompare(
"colors",option+1) == 0)
2078 _quantize_info->number_colors=StringToUnsignedLong(arg1);
2079 _quantize_info->measure_error=_image_info->verbose;
2080 if (_quantize_info->number_colors == 0)
2081 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2082 if ((_image->storage_class == DirectClass) ||
2083 _image->colors > _quantize_info->number_colors)
2084 (void) QuantizeImage(_quantize_info,_image,_exception);
2086 (
void) CompressImageColormap(_image,_exception);
2089 if (LocaleCompare(
"colorspace",option+1) == 0)
2101 (void) TransformImageColorspace(_image,
2102 IfNormalOp ? _image_info->colorspace : sRGBColorspace,
2106 if (LocaleCompare(
"color-threshold",option+1) == 0)
2116 (void) GetColorRange(
"white-black",&start,&stop,_exception);
2118 (
void) GetColorRange(arg1,&start,&stop,_exception);
2119 (void) ColorThresholdImage(_image,&start,&stop,_exception);
2122 if (LocaleCompare(
"connected-components",option+1) == 0)
2124 if (IsGeometry(arg1) == MagickFalse)
2125 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2126 new_image=ConnectedComponentsImage(_image,(
size_t)
2127 StringToInteger(arg1),(CCObjectInfo **) NULL,_exception);
2130 if (LocaleCompare(
"contrast",option+1) == 0)
2132 CLIWandWarnReplaced(IfNormalOp?
"-level":
"+level");
2133 (void) ContrastImage(_image,IsNormalOp,_exception);
2136 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
2142 flags=ParseGeometry(arg1,&geometry_info);
2143 if ((flags & RhoValue) == 0)
2144 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2145 black_point=geometry_info.rho;
2146 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2148 if ((flags & PercentValue) != 0)
2150 black_point*=(double) _image->columns*_image->rows/100.0;
2151 white_point*=(double) _image->columns*_image->rows/100.0;
2153 white_point=(double) _image->columns*_image->rows-white_point;
2154 (void) ContrastStretchImage(_image,black_point,white_point,
2158 if (LocaleCompare(
"convolve",option+1) == 0)
2169 kernel_info=AcquireKernelInfo(arg1,exception);
2170 if (kernel_info == (KernelInfo *) NULL)
2171 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2173 for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
2174 gamma+=kernel_info->values[j];
2175 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
2176 for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
2177 kernel_info->values[j]*=gamma;
2178 new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info,
2180 kernel_info=DestroyKernelInfo(kernel_info);
2183 if (LocaleCompare(
"crop",option+1) == 0)
2186 if (IsGeometry(arg1) == MagickFalse)
2187 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2188 new_image=CropImageToTiles(_image,arg1,_exception);
2191 if (LocaleCompare(
"cycle",option+1) == 0)
2193 if (IsGeometry(arg1) == MagickFalse)
2194 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2195 (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1),
2199 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2203 if (LocaleCompare(
"decipher",option+1) == 0)
2209 passkey=FileToStringInfo(arg1,~0UL,_exception);
2210 if (passkey == (StringInfo *) NULL)
2211 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2213 (void) PasskeyDecipherImage(_image,passkey,_exception);
2214 passkey=DestroyStringInfo(passkey);
2217 if (LocaleCompare(
"depth",option+1) == 0)
2227 (void) SetImageDepth(_image,_image_info->depth,_exception);
2230 if (LocaleCompare(
"deskew",option+1) == 0)
2236 if (IsGeometry(arg1) == MagickFalse)
2237 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2238 threshold=StringToDoubleInterval(arg1,(
double) QuantumRange+1.0);
2241 threshold=40.0*(double) QuantumRange/100.0;
2242 new_image=DeskewImage(_image,threshold,_exception);
2245 if (LocaleCompare(
"despeckle",option+1) == 0)
2247 new_image=DespeckleImage(_image,_exception);
2250 if (LocaleCompare(
"distort",option+1) == 0)
2258 parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1);
2260 CLIWandExceptArgBreak(OptionError,
"UnrecognizedDistortMethod",
2262 if ((DistortMethod) parse == ResizeDistortion)
2270 if (IsGeometry(arg2) == MagickFalse)
2271 CLIWandExceptArgBreak(OptionError,
"InvalidGeometry",
2273 (void) ParseRegionGeometry(_image,arg2,&geometry,_exception);
2274 resize_args[0]=(double) geometry.width;
2275 resize_args[1]=(double) geometry.height;
2276 new_image=DistortImage(_image,(DistortMethod) parse,
2277 (
size_t)2,resize_args,MagickTrue,_exception);
2281 args = StringToArrayOfDoubles(arg2,&count,_exception);
2282 if (args == (
double *) NULL )
2283 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg2);
2285 new_image=DistortImage(_image,(DistortMethod) parse,(
size_t)
2286 count,args,IsPlusOp,_exception);
2287 args=(
double *) RelinquishMagickMemory(args);
2290 if (LocaleCompare(
"draw",option+1) == 0)
2292 (void) CloneString(&_draw_info->primitive,arg1);
2293 (void) DrawImage(_image,_draw_info,_exception);
2294 (void) CloneString(&_draw_info->primitive,(
char *) NULL);
2297 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2301 if (LocaleCompare(
"edge",option+1) == 0)
2303 flags=ParseGeometry(arg1,&geometry_info);
2304 if ((flags & (RhoValue|SigmaValue)) == 0)
2305 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2306 new_image=EdgeImage(_image,geometry_info.rho,_exception);
2309 if (LocaleCompare(
"emboss",option+1) == 0)
2311 flags=ParseGeometry(arg1,&geometry_info);
2312 if ((flags & (RhoValue|SigmaValue)) == 0)
2313 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2314 if ((flags & SigmaValue) == 0)
2315 geometry_info.sigma=1.0;
2316 new_image=EmbossImage(_image,geometry_info.rho,
2317 geometry_info.sigma,_exception);
2320 if (LocaleCompare(
"encipher",option+1) == 0)
2326 passkey=FileToStringInfo(arg1,~0UL,_exception);
2327 if (passkey != (StringInfo *) NULL)
2329 (void) PasskeyEncipherImage(_image,passkey,_exception);
2330 passkey=DestroyStringInfo(passkey);
2334 if (LocaleCompare(
"enhance",option+1) == 0)
2336 new_image=EnhanceImage(_image,_exception);
2339 if (LocaleCompare(
"equalize",option+1) == 0)
2341 (void) EqualizeImage(_image,_exception);
2344 if (LocaleCompare(
"evaluate",option+1) == 0)
2349 parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
2351 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
2353 if (IsGeometry(arg2) == MagickFalse)
2354 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
2355 constant=StringToDoubleInterval(arg2,(
double) QuantumRange+1.0);
2356 (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant,
2360 if (LocaleCompare(
"extent",option+1) == 0)
2362 if (IsGeometry(arg1) == MagickFalse)
2363 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2364 flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
2365 if (geometry.width == 0)
2366 geometry.width=_image->columns;
2367 if (geometry.height == 0)
2368 geometry.height=_image->rows;
2369 new_image=ExtentImage(_image,&geometry,_exception);
2372 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2376 if (LocaleCompare(
"features",option+1) == 0)
2378 CLIWandWarnReplaced(
"-verbose -define identify:features=");
2381 (void) DeleteImageArtifact(_image,
"identify:features");
2384 (void) SetImageArtifact(_image,
"identify:features",arg1);
2385 (void) SetImageArtifact(_image,
"verbose",
"true");
2388 if (LocaleCompare(
"flip",option+1) == 0)
2390 new_image=FlipImage(_image,_exception);
2393 if (LocaleCompare(
"flop",option+1) == 0)
2395 new_image=FlopImage(_image,_exception);
2398 if (LocaleCompare(
"floodfill",option+1) == 0)
2403 if (IsGeometry(arg1) == MagickFalse)
2404 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2405 (void) ParsePageGeometry(_image,arg1,&geometry,_exception);
2406 (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception);
2407 (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x,
2408 geometry.y,IsPlusOp,_exception);
2411 if (LocaleCompare(
"frame",option+1) == 0)
2422 value=GetImageOption(_image_info,
"compose");
2423 compose=OverCompositeOp;
2424 if (value != (
const char *) NULL)
2425 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
2427 if (IsGeometry(arg1) == MagickFalse)
2428 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2429 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
2430 frame_info.width=geometry.width;
2431 frame_info.height=geometry.height;
2432 frame_info.outer_bevel=geometry.x;
2433 frame_info.inner_bevel=geometry.y;
2434 frame_info.x=(ssize_t) frame_info.width;
2435 frame_info.y=(ssize_t) frame_info.height;
2436 frame_info.width=_image->columns+2*frame_info.width;
2437 frame_info.height=_image->rows+2*frame_info.height;
2438 new_image=FrameImage(_image,&frame_info,compose,_exception);
2441 if (LocaleCompare(
"function",option+1) == 0)
2449 parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1);
2451 CLIWandExceptArgBreak(OptionError,
"UnrecognizedFunction",
2454 args = StringToArrayOfDoubles(arg2,&count,_exception);
2455 if (args == (
double *) NULL )
2456 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg2);
2458 (void) FunctionImage(_image,(MagickFunction)parse,(
size_t) count,args,
2460 args=(
double *) RelinquishMagickMemory(args);
2463 if (LocaleCompare(
"fx",option+1) == 0)
2465 new_image=FxImage(_image,arg1,_exception);
2468 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2472 if (LocaleCompare(
"gamma",option+1) == 0)
2477 if (IsGeometry(arg1) == MagickFalse)
2478 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2479 constant=StringToDouble(arg1,(
char **) NULL);
2483 constant=PerceptibleReciprocal(constant);
2484 (void) GammaImage(_image,constant,_exception);
2488 constant=PerceptibleReciprocal(constant);
2489 (void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception);
2490 _image->gamma*=StringToDouble(arg1,(
char **) NULL);
2497 if (LocaleCompare(
"gaussian-blur",option+1) == 0)
2499 flags=ParseGeometry(arg1,&geometry_info);
2500 if ((flags & (RhoValue|SigmaValue)) == 0)
2501 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2502 if ((flags & SigmaValue) == 0)
2503 geometry_info.sigma=1.0;
2504 new_image=GaussianBlurImage(_image,geometry_info.rho,
2505 geometry_info.sigma,_exception);
2508 if (LocaleCompare(
"gaussian",option+1) == 0)
2510 CLIWandWarnReplaced(
"-gaussian-blur");
2511 (void) CLISimpleOperatorImage(cli_wand,
"-gaussian-blur",arg1,NULL,exception);
2513 if (LocaleCompare(
"geometry",option+1) == 0)
2523 if (_image->geometry != (
char *) NULL)
2524 _image->geometry=DestroyString(_image->geometry);
2527 if (IsGeometry(arg1) == MagickFalse)
2528 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2529 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2530 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2531 (void) CloneString(&_image->geometry,arg1);
2533 new_image=ResizeImage(_image,geometry.width,geometry.height,
2534 _image->filter,_exception);
2537 if (LocaleCompare(
"grayscale",option+1) == 0)
2539 parse=ParseCommandOption(MagickPixelIntensityOptions,
2542 CLIWandExceptArgBreak(OptionError,
"UnrecognizedIntensityMethod",
2544 (void) GrayscaleImage(_image,(PixelIntensityMethod) parse,_exception);
2547 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2551 if (LocaleCompare(
"hough-lines",option+1) == 0)
2553 flags=ParseGeometry(arg1,&geometry_info);
2554 if ((flags & (RhoValue|SigmaValue)) == 0)
2555 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2556 if ((flags & SigmaValue) == 0)
2557 geometry_info.sigma=geometry_info.rho;
2558 if ((flags & XiValue) == 0)
2559 geometry_info.xi=40;
2560 new_image=HoughLineImage(_image,(
size_t) geometry_info.rho,
2561 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,_exception);
2564 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2568 if (LocaleCompare(
"identify",option+1) == 0)
2574 format=GetImageOption(_image_info,
"format");
2575 if (format == (
char *) NULL)
2577 (void) IdentifyImage(_image,stdout,_image_info->verbose,
2581 text=InterpretImageProperties(_image_info,_image,format,_exception);
2582 if (text == (
char *) NULL)
2583 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
2585 (void) fputs(text,stdout);
2586 text=DestroyString((
char *)text);
2589 if (LocaleCompare(
"implode",option+1) == 0)
2591 flags=ParseGeometry(arg1,&geometry_info);
2592 if ((flags & RhoValue) == 0)
2593 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2594 new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate,
2598 if (LocaleCompare(
"integral",option+1) == 0)
2600 new_image=IntegralImage(_image,_exception);
2603 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
2607 if (IsGeometry(arg1) == MagickFalse)
2608 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2609 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
2610 new_image=InterpolativeResizeImage(_image,geometry.width,
2611 geometry.height,_image->interpolate,_exception);
2614 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2618 if (LocaleCompare(
"kmeans",option+1) == 0)
2623 flags=ParseGeometry(arg1,&geometry_info);
2624 if ((flags & (RhoValue|SigmaValue)) == 0)
2625 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2626 if ((flags & SigmaValue) == 0)
2627 geometry_info.sigma=300.0;
2628 if ((flags & XiValue) == 0)
2629 geometry_info.xi=0.0001;
2630 (void) KmeansImage(_image,(
size_t) geometry_info.rho,(
size_t)
2631 geometry_info.sigma,geometry_info.xi,_exception);
2634 if (LocaleCompare(
"kuwahara",option+1) == 0)
2639 flags=ParseGeometry(arg1,&geometry_info);
2640 if ((flags & (RhoValue|SigmaValue)) == 0)
2641 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2642 if ((flags & SigmaValue) == 0)
2643 geometry_info.sigma=geometry_info.rho-0.5;
2644 new_image=KuwaharaImage(_image,geometry_info.rho,geometry_info.sigma,
2648 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2652 if (LocaleCompare(
"lat",option+1) == 0)
2654 flags=ParseGeometry(arg1,&geometry_info);
2655 if ((flags & (RhoValue|SigmaValue)) == 0)
2656 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2657 if ((flags & SigmaValue) == 0)
2658 geometry_info.sigma=1.0;
2659 if ((flags & PercentValue) != 0)
2660 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2661 new_image=AdaptiveThresholdImage(_image,(
size_t) geometry_info.rho,
2662 (
size_t) geometry_info.sigma,(
double) geometry_info.xi,
2666 if (LocaleCompare(
"level",option+1) == 0)
2673 flags=ParseGeometry(arg1,&geometry_info);
2674 if ((flags & RhoValue) == 0)
2675 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2676 black_point=geometry_info.rho;
2677 white_point=(double) QuantumRange;
2678 if ((flags & SigmaValue) != 0)
2679 white_point=geometry_info.sigma;
2681 if ((flags & XiValue) != 0)
2682 gamma=geometry_info.xi;
2683 if ((flags & PercentValue) != 0)
2685 black_point*=(double) QuantumRange/100.0;
2686 white_point*=(double) QuantumRange/100.0;
2688 if ((flags & SigmaValue) == 0)
2689 white_point=(double) QuantumRange-black_point;
2690 if (IfPlusOp || ((flags & AspectValue) != 0))
2691 (void) LevelizeImage(_image,black_point,white_point,gamma,_exception);
2693 (
void) LevelImage(_image,black_point,white_point,gamma,_exception);
2696 if (LocaleCompare(
"level-colors",option+1) == 0)
2699 token[MagickPathExtent];
2708 p=(
const char *) arg1;
2709 (void) GetNextToken(p,&p,MagickPathExtent,token);
2710 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2711 (void) QueryColorCompliance(token,AllCompliance,
2712 &black_point,_exception);
2714 (
void) QueryColorCompliance(
"#000000",AllCompliance,
2715 &black_point,_exception);
2716 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2717 (void) GetNextToken(p,&p,MagickPathExtent,token);
2719 white_point=black_point;
2722 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2723 (void) GetNextToken(p,&p,MagickPathExtent,token);
2724 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2725 (void) QueryColorCompliance(token,AllCompliance,
2726 &white_point,_exception);
2728 (
void) QueryColorCompliance(
"#ffffff",AllCompliance,
2729 &white_point,_exception);
2731 (void) LevelImageColors(_image,&black_point,&white_point,
2732 IsPlusOp,_exception);
2735 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2741 flags=ParseGeometry(arg1,&geometry_info);
2742 if ((flags & RhoValue) == 0)
2743 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2744 black_point=geometry_info.rho;
2745 white_point=(double) _image->columns*_image->rows;
2746 if ((flags & SigmaValue) != 0)
2747 white_point=geometry_info.sigma;
2748 if ((flags & PercentValue) != 0)
2750 black_point*=(double) _image->columns*_image->rows/100.0;
2751 white_point*=(double) _image->columns*_image->rows/100.0;
2753 if ((flags & SigmaValue) == 0)
2754 white_point=(double) _image->columns*_image->rows-
2756 (void) LinearStretchImage(_image,black_point,white_point,_exception);
2759 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2762 if (IsGeometry(arg1) == MagickFalse)
2763 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2764 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2765 if ((flags & XValue) == 0)
2767 if ((flags & YValue) == 0)
2769 new_image=LiquidRescaleImage(_image,geometry.width,
2770 geometry.height,1.0*geometry.x,1.0*geometry.y,_exception);
2773 if (LocaleCompare(
"local-contrast",option+1) == 0)
2775 flags=ParseGeometry(arg1,&geometry_info);
2776 if ((flags & RhoValue) == 0)
2777 geometry_info.rho=10;
2778 if ((flags & SigmaValue) == 0)
2779 geometry_info.sigma=12.5;
2780 new_image=LocalContrastImage(_image,geometry_info.rho,
2781 geometry_info.sigma,exception);
2784 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2788 if (LocaleCompare(
"magnify",option+1) == 0)
2790 new_image=MagnifyImage(_image,_exception);
2793 if (LocaleCompare(
"map",option+1) == 0)
2795 CLIWandWarnReplaced(
"-remap");
2796 (void) CLISimpleOperatorImage(cli_wand,
"-remap",arg1,NULL,exception);
2799 if (LocaleCompare(
"mask",option+1) == 0)
2809 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2816 mask=GetImageCache(_image_info,arg1,_exception);
2817 if (mask == (Image *) NULL)
2819 (void) SetImageMask(_image,WritePixelMask,mask,_exception);
2820 mask=DestroyImage(mask);
2823 if (LocaleCompare(
"matte",option+1) == 0)
2825 CLIWandWarnReplaced(IfNormalOp?
"-alpha Set":
"-alpha Off");
2826 (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel :
2827 DeactivateAlphaChannel, _exception);
2830 if (LocaleCompare(
"mean-shift",option+1) == 0)
2832 flags=ParseGeometry(arg1,&geometry_info);
2833 if ((flags & (RhoValue|SigmaValue)) == 0)
2834 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2835 if ((flags & SigmaValue) == 0)
2836 geometry_info.sigma=1.0;
2837 if ((flags & XiValue) == 0)
2838 geometry_info.xi=0.10*(double) QuantumRange;
2839 if ((flags & PercentValue) != 0)
2840 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2841 new_image=MeanShiftImage(_image,(
size_t) geometry_info.rho,
2842 (
size_t) geometry_info.sigma,geometry_info.xi,_exception);
2845 if (LocaleCompare(
"median",option+1) == 0)
2847 CLIWandWarnReplaced(
"-statistic Median");
2848 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"Median",arg1,exception);
2851 if (LocaleCompare(
"mode",option+1) == 0)
2854 CLIWandWarnReplaced(
"-statistic Mode");
2855 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"Mode",arg1,
2859 if (LocaleCompare(
"modulate",option+1) == 0)
2861 if (IsGeometry(arg1) == MagickFalse)
2862 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2863 (void) ModulateImage(_image,arg1,_exception);
2866 if (LocaleCompare(
"monitor",option+1) == 0)
2868 (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress :
2869 (MagickProgressMonitor) NULL,(
void *) NULL);
2872 if (LocaleCompare(
"moments",option+1) == 0)
2874 CLIWandWarnReplaced(
"-verbose -define identify:moments=");
2877 (void) DeleteImageArtifact(_image,
"identify:moments");
2880 (void) SetImageArtifact(_image,
"identify:moments",
"true");
2881 (void) SetImageArtifact(_image,
"verbose",
"true");
2884 if (LocaleCompare(
"monochrome",option+1) == 0)
2886 (void) SetImageType(_image,BilevelType,_exception);
2889 if (LocaleCompare(
"morphology",option+1) == 0)
2892 token[MagickPathExtent];
2904 (void) GetNextToken(p,&p,MagickPathExtent,token);
2905 parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
2907 CLIWandExceptArgBreak(OptionError,
"UnrecognizedFunction",option,
2910 (void) GetNextToken(p,&p,MagickPathExtent,token);
2911 if ((*p ==
':') || (*p ==
','))
2912 (void) GetNextToken(p,&p,MagickPathExtent,token);
2914 iterations=(ssize_t) StringToLong(p);
2915 kernel=AcquireKernelInfo(arg2,exception);
2916 if (kernel == (KernelInfo *) NULL)
2917 CLIWandExceptArgBreak(OptionError,
"UnabletoParseKernel",option,arg2);
2918 new_image=MorphologyImage(_image,(MorphologyMethod)parse,iterations,
2920 kernel=DestroyKernelInfo(kernel);
2923 if (LocaleCompare(
"motion-blur",option+1) == 0)
2925 flags=ParseGeometry(arg1,&geometry_info);
2926 if ((flags & (RhoValue|SigmaValue)) == 0)
2927 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2928 if ((flags & SigmaValue) == 0)
2929 geometry_info.sigma=1.0;
2930 new_image=MotionBlurImage(_image,geometry_info.rho,
2931 geometry_info.sigma,geometry_info.xi,_exception);
2934 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2938 if (LocaleCompare(
"negate",option+1) == 0)
2940 (void) NegateImage(_image, IsPlusOp, _exception);
2943 if (LocaleCompare(
"noise",option+1) == 0)
2953 CLIWandWarnReplaced(
"-statistic NonPeak");
2954 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"NonPeak",arg1,exception);
2957 parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1);
2959 CLIWandExceptArgBreak(OptionError,
"UnrecognizedNoiseType",
2962 value=GetImageOption(_image_info,
"attenuate");
2963 if (value != (
const char *) NULL)
2964 attenuate=StringToDouble(value,(
char **) NULL);
2965 new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate,
2969 if (LocaleCompare(
"normalize",option+1) == 0)
2971 (void) NormalizeImage(_image,_exception);
2974 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2978 if (LocaleCompare(
"opaque",option+1) == 0)
2983 (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
2984 (void) OpaquePaintImage(_image,&target,&_draw_info->fill,IsPlusOp,
2988 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2990 (void) OrderedDitherImage(_image,arg1,_exception);
2993 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2997 if (LocaleCompare(
"paint",option+1) == 0)
2999 flags=ParseGeometry(arg1,&geometry_info);
3000 if ((flags & (RhoValue|SigmaValue)) == 0)
3001 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3002 new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma,
3006 if (LocaleCompare(
"perceptible",option+1) == 0)
3008 (void) PerceptibleImage(_image,StringToDouble(arg1,(
char **) NULL),
3012 if (LocaleCompare(
"polaroid",option+1) == 0)
3024 random_info=AcquireRandomInfo();
3025 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
3026 random_info=DestroyRandomInfo(random_info);
3029 flags=ParseGeometry(arg1,&geometry_info);
3030 if ((flags & RhoValue) == 0)
3031 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3032 angle=geometry_info.rho;
3034 caption=GetImageProperty(_image,
"caption",_exception);
3035 new_image=PolaroidImage(_image,_draw_info,caption,angle,
3036 _image->interpolate,_exception);
3039 if (LocaleCompare(
"posterize",option+1) == 0)
3041 flags=ParseGeometry(arg1,&geometry_info);
3042 if ((flags & RhoValue) == 0)
3043 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3044 (void) PosterizeImage(_image,(
size_t) geometry_info.rho,
3045 _quantize_info->dither_method,_exception);
3048 if (LocaleCompare(
"preview",option+1) == 0)
3054 parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1);
3056 CLIWandExceptArgBreak(OptionError,
"UnrecognizedPreviewType",
3058 new_image=PreviewImage(_image,(PreviewType)parse,_exception);
3061 if (LocaleCompare(
"profile",option+1) == 0)
3078 (void) ProfileImage(_image,arg1,(
const unsigned char *)
3083 profile_info=CloneImageInfo(_image_info);
3084 profile=GetImageProfile(_image,
"iptc");
3085 if (profile != (
const StringInfo *) NULL)
3086 profile_info->profile=(
void *) CloneStringInfo(profile);
3087 profile_image=GetImageCache(profile_info,arg1,_exception);
3088 profile_info=DestroyImageInfo(profile_info);
3089 if (profile_image == (Image *) NULL)
3094 profile_info=CloneImageInfo(_image_info);
3095 (void) CopyMagickString(profile_info->filename,arg1,
3097 new_profile=FileToStringInfo(profile_info->filename,~0UL,
3099 if (new_profile != (StringInfo *) NULL)
3101 (void) SetImageInfo(profile_info,0,_exception);
3102 (void) ProfileImage(_image,profile_info->magick,
3103 GetStringInfoDatum(new_profile),(
size_t)
3104 GetStringInfoLength(new_profile),_exception);
3105 new_profile=DestroyStringInfo(new_profile);
3107 profile_info=DestroyImageInfo(profile_info);
3110 ResetImageProfileIterator(profile_image);
3111 name=GetNextImageProfile(profile_image);
3112 while (name != (
const char *) NULL)
3114 profile=GetImageProfile(profile_image,name);
3115 if (profile != (
const StringInfo *) NULL)
3116 (void) ProfileImage(_image,name,GetStringInfoDatum(profile),
3117 (
size_t) GetStringInfoLength(profile),_exception);
3118 name=GetNextImageProfile(profile_image);
3120 profile_image=DestroyImage(profile_image);
3123 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3127 if (LocaleCompare(
"raise",option+1) == 0)
3129 if (IsGeometry(arg1) == MagickFalse)
3130 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3131 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3132 (void) RaiseImage(_image,&geometry,IsNormalOp,_exception);
3135 if (LocaleCompare(
"random-threshold",option+1) == 0)
3141 if (IsGeometry(arg1) == MagickFalse)
3142 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3144 max_threshold=(double) QuantumRange;
3145 flags=ParseGeometry(arg1,&geometry_info);
3146 min_threshold=geometry_info.rho;
3147 max_threshold=geometry_info.sigma;
3148 if ((flags & SigmaValue) == 0)
3149 max_threshold=min_threshold;
3150 if (arg1 == (
char *) NULL)
3152 if (strchr(arg1,
'%') != (
char *) NULL)
3154 max_threshold*=(0.01*(double) QuantumRange);
3155 min_threshold*=(0.01*(double) QuantumRange);
3157 (void) RandomThresholdImage(_image,min_threshold,max_threshold,
3161 if (LocaleCompare(
"range-threshold",option+1) == 0)
3166 if (IsGeometry(arg1) == MagickFalse)
3167 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3168 flags=ParseGeometry(arg1,&geometry_info);
3169 if ((flags & SigmaValue) == 0)
3170 geometry_info.sigma=geometry_info.rho;
3171 if ((flags & XiValue) == 0)
3172 geometry_info.xi=geometry_info.sigma;
3173 if ((flags & PsiValue) == 0)
3174 geometry_info.psi=geometry_info.xi;
3175 if (strchr(arg1,
'%') != (
char *) NULL)
3177 geometry_info.rho*=(0.01*(double) QuantumRange);
3178 geometry_info.sigma*=(0.01*(double) QuantumRange);
3179 geometry_info.xi*=(0.01*(double) QuantumRange);
3180 geometry_info.psi*=(0.01*(double) QuantumRange);
3182 (void) RangeThresholdImage(_image,geometry_info.rho,
3183 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3186 if (LocaleCompare(
"read-mask",option+1) == 0)
3194 (void) SetImageMask(_image,ReadPixelMask,(
const Image *) NULL,
3199 mask=GetImageCache(_image_info,arg1,_exception);
3200 if (mask == (Image *) NULL)
3202 (void) SetImageMask(_image,ReadPixelMask,mask,_exception);
3203 mask=DestroyImage(mask);
3206 if (LocaleCompare(
"recolor",option+1) == 0)
3208 CLIWandWarnReplaced(
"-color-matrix");
3209 (void) CLISimpleOperatorImage(cli_wand,
"-color-matrix",arg1,NULL,
3212 if (LocaleCompare(
"region",option+1) == 0)
3216 (void) SetImageRegionMask(_image,WritePixelMask,
3217 (
const RectangleInfo *) NULL,_exception);
3220 if (IsGeometry(arg1) == MagickFalse)
3221 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3222 (void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
3223 (void) SetImageRegionMask(_image,WritePixelMask,&geometry,_exception);
3226 if (LocaleCompare(
"remap",option+1) == 0)
3232 remap_image=GetImageCache(_image_info,arg1,_exception);
3233 if (remap_image == (Image *) NULL)
3235 (void) RemapImage(_quantize_info,_image,remap_image,_exception);
3236 remap_image=DestroyImage(remap_image);
3239 if (LocaleCompare(
"repage",option+1) == 0)
3243 if (IsGeometry(arg1) == MagickFalse)
3244 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,
3246 (void) ResetImagePage(_image,arg1);
3249 (
void) ParseAbsoluteGeometry(
"0x0+0+0",&_image->page);
3252 if (LocaleCompare(
"resample",option+1) == 0)
3255 flags=ParseGeometry(arg1,&geometry_info);
3256 if ((flags & (RhoValue|SigmaValue)) == 0)
3257 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3258 if ((flags & SigmaValue) == 0)
3259 geometry_info.sigma=geometry_info.rho;
3260 new_image=ResampleImage(_image,geometry_info.rho,
3261 geometry_info.sigma,_image->filter,_exception);
3264 if (LocaleCompare(
"reshape",option+1) == 0)
3266 if (IsGeometry(arg1) == MagickFalse)
3267 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3268 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3269 (void) ReshapePixelCache(_image,geometry.width,geometry.height,
3273 if (LocaleCompare(
"resize",option+1) == 0)
3275 if (IsGeometry(arg1) == MagickFalse)
3276 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3277 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3278 new_image=ResizeImage(_image,geometry.width,geometry.height,
3279 _image->filter,_exception);
3282 if (LocaleCompare(
"roll",option+1) == 0)
3284 if (IsGeometry(arg1) == MagickFalse)
3285 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3286 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3287 if ((flags & PercentValue) != 0)
3289 geometry.x*=(double) _image->columns/100.0;
3290 geometry.y*=(double) _image->rows/100.0;
3292 new_image=RollImage(_image,geometry.x,geometry.y,_exception);
3295 if (LocaleCompare(
"rotate",option+1) == 0)
3297 flags=ParseGeometry(arg1,&geometry_info);
3298 if ((flags & RhoValue) == 0)
3299 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3300 if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows))
3302 if ((flags & LessValue) != 0 && (_image->columns >= _image->rows))
3304 new_image=RotateImage(_image,geometry_info.rho,_exception);
3307 if (LocaleCompare(
"rotational-blur",option+1) == 0)
3309 flags=ParseGeometry(arg1,&geometry_info);
3310 if ((flags & RhoValue) == 0)
3311 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3312 new_image=RotationalBlurImage(_image,geometry_info.rho,_exception);
3315 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3319 if (LocaleCompare(
"sample",option+1) == 0)
3322 if (IsGeometry(arg1) == MagickFalse)
3323 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3324 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3325 new_image=SampleImage(_image,geometry.width,geometry.height,
3329 if (LocaleCompare(
"scale",option+1) == 0)
3332 if (IsGeometry(arg1) == MagickFalse)
3333 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3334 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3335 new_image=ScaleImage(_image,geometry.width,geometry.height,
3339 if (LocaleCompare(
"segment",option+1) == 0)
3341 flags=ParseGeometry(arg1,&geometry_info);
3342 if ((flags & (RhoValue|SigmaValue)) == 0)
3343 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3344 if ((flags & SigmaValue) == 0)
3345 geometry_info.sigma=1.0;
3346 (void) SegmentImage(_image,_image->colorspace,
3347 _image_info->verbose,geometry_info.rho,geometry_info.sigma,
3351 if (LocaleCompare(
"selective-blur",option+1) == 0)
3353 flags=ParseGeometry(arg1,&geometry_info);
3354 if ((flags & (RhoValue|SigmaValue)) == 0)
3355 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3356 if ((flags & SigmaValue) == 0)
3357 geometry_info.sigma=1.0;
3358 if ((flags & PercentValue) != 0)
3359 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3360 new_image=SelectiveBlurImage(_image,geometry_info.rho,
3361 geometry_info.sigma,geometry_info.xi,_exception);
3364 if (LocaleCompare(
"separate",option+1) == 0)
3368 new_image=SeparateImages(_image,_exception);
3371 if (LocaleCompare(
"sepia-tone",option+1) == 0)
3373 if (IsGeometry(arg1) == MagickFalse)
3374 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3375 new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1,
3376 (
double) QuantumRange+1.0),_exception);
3379 if (LocaleCompare(
"shade",option+1) == 0)
3381 flags=ParseGeometry(arg1,&geometry_info);
3382 if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0))
3383 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3384 new_image=ShadeImage(_image,IsNormalOp,geometry_info.rho,
3385 geometry_info.sigma,_exception);
3388 if (LocaleCompare(
"shadow",option+1) == 0)
3390 flags=ParseGeometry(arg1,&geometry_info);
3391 if ((flags & (RhoValue|SigmaValue)) == 0)
3392 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3393 if ((flags & SigmaValue) == 0)
3394 geometry_info.sigma=1.0;
3395 if ((flags & XiValue) == 0)
3396 geometry_info.xi=4.0;
3397 if ((flags & PsiValue) == 0)
3398 geometry_info.psi=4.0;
3399 new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma,
3400 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3401 ceil(geometry_info.psi-0.5),_exception);
3404 if (LocaleCompare(
"sharpen",option+1) == 0)
3406 flags=ParseGeometry(arg1,&geometry_info);
3407 if ((flags & (RhoValue|SigmaValue)) == 0)
3408 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3409 if ((flags & SigmaValue) == 0)
3410 geometry_info.sigma=1.0;
3411 if ((flags & XiValue) == 0)
3412 geometry_info.xi=0.0;
3413 new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma,
3417 if (LocaleCompare(
"shave",option+1) == 0)
3419 if (IsGeometry(arg1) == MagickFalse)
3420 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3421 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3422 new_image=ShaveImage(_image,&geometry,_exception);
3425 if (LocaleCompare(
"shear",option+1) == 0)
3427 flags=ParseGeometry(arg1,&geometry_info);
3428 if ((flags & RhoValue) == 0)
3429 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3430 if ((flags & SigmaValue) == 0)
3431 geometry_info.sigma=geometry_info.rho;
3432 new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma,
3436 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
3438 flags=ParseGeometry(arg1,&geometry_info);
3439 if ((flags & RhoValue) == 0)
3440 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3441 if ((flags & SigmaValue) == 0)
3442 geometry_info.sigma=(double) QuantumRange/2.0;
3443 if ((flags & PercentValue) != 0)
3444 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3446 (void) SigmoidalContrastImage(_image,IsNormalOp,geometry_info.rho,
3447 geometry_info.sigma,_exception);
3450 if (LocaleCompare(
"sketch",option+1) == 0)
3452 flags=ParseGeometry(arg1,&geometry_info);
3453 if ((flags & (RhoValue|SigmaValue)) == 0)
3454 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3455 if ((flags & SigmaValue) == 0)
3456 geometry_info.sigma=1.0;
3457 new_image=SketchImage(_image,geometry_info.rho,
3458 geometry_info.sigma,geometry_info.xi,_exception);
3461 if (LocaleCompare(
"solarize",option+1) == 0)
3463 if (IsGeometry(arg1) == MagickFalse)
3464 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3465 (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(
double)
3466 QuantumRange+1.0),_exception);
3469 if (LocaleCompare(
"sort-pixels",option+1) == 0)
3471 (void) SortImagePixels(_image,_exception);
3474 if (LocaleCompare(
"sparse-color",option+1) == 0)
3476 parse=ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1);
3478 CLIWandExceptArgBreak(OptionError,
"UnrecognizedSparseColorMethod",
3480 new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2,
3484 if (LocaleCompare(
"splice",option+1) == 0)
3486 if (IsGeometry(arg1) == MagickFalse)
3487 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3488 flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
3489 new_image=SpliceImage(_image,&geometry,_exception);
3492 if (LocaleCompare(
"spread",option+1) == 0)
3494 flags=ParseGeometry(arg1,&geometry_info);
3495 if ((flags & RhoValue) == 0)
3496 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
3497 new_image=SpreadImage(_image,_image->interpolate,geometry_info.rho,
3501 if (LocaleCompare(
"statistic",option+1) == 0)
3503 parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1);
3505 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStatisticType",
3507 flags=ParseGeometry(arg2,&geometry_info);
3508 if ((flags & RhoValue) == 0)
3509 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
3510 if ((flags & SigmaValue) == 0)
3511 geometry_info.sigma=geometry_info.rho;
3512 new_image=StatisticImage(_image,(StatisticType)parse,
3513 (
size_t) geometry_info.rho,(
size_t) geometry_info.sigma,
3517 if (LocaleCompare(
"strip",option+1) == 0)
3519 (void) StripImage(_image,_exception);
3522 if (LocaleCompare(
"swirl",option+1) == 0)
3524 flags=ParseGeometry(arg1,&geometry_info);
3525 if ((flags & RhoValue) == 0)
3526 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3527 new_image=SwirlImage(_image,geometry_info.rho,
3528 _image->interpolate,_exception);
3531 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3535 if (LocaleCompare(
"threshold",option+1) == 0)
3540 threshold=(double) QuantumRange/2;
3542 if (IsGeometry(arg1) == MagickFalse)
3543 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3544 threshold=StringToDoubleInterval(arg1,(
double) QuantumRange+1.0);
3546 (void) BilevelImage(_image,threshold,_exception);
3549 if (LocaleCompare(
"thumbnail",option+1) == 0)
3551 if (IsGeometry(arg1) == MagickFalse)
3552 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3553 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3554 new_image=ThumbnailImage(_image,geometry.width,geometry.height,
3558 if (LocaleCompare(
"tint",option+1) == 0)
3560 if (IsGeometry(arg1) == MagickFalse)
3561 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3562 new_image=TintImage(_image,arg1,&_draw_info->fill,_exception);
3565 if (LocaleCompare(
"transform",option+1) == 0)
3567 CLIWandWarnReplaced(
"+distort AffineProjection");
3568 new_image=AffineTransformImage(_image,&_draw_info->affine,_exception);
3571 if (LocaleCompare(
"transparent",option+1) == 0)
3576 (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
3577 (void) TransparentPaintImage(_image,&target,(Quantum)
3578 TransparentAlpha,IsPlusOp,_exception);
3581 if (LocaleCompare(
"transpose",option+1) == 0)
3583 new_image=TransposeImage(_image,_exception);
3586 if (LocaleCompare(
"transverse",option+1) == 0)
3588 new_image=TransverseImage(_image,_exception);
3591 if (LocaleCompare(
"trim",option+1) == 0)
3593 new_image=TrimImage(_image,_exception);
3596 if (LocaleCompare(
"type",option+1) == 0)
3599 (void) SetImageType(_image,_image_info->type,_exception);
3602 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3606 if (LocaleCompare(
"unique",option+1) == 0)
3613 (void) DeleteImageArtifact(_image,
"identify:unique-colors");
3616 (void) SetImageArtifact(_image,
"identify:unique-colors",
"true");
3617 (void) SetImageArtifact(_image,
"verbose",
"true");
3620 if (LocaleCompare(
"unique-colors",option+1) == 0)
3622 new_image=UniqueImageColors(_image,_exception);
3625 if (LocaleCompare(
"unsharp",option+1) == 0)
3627 flags=ParseGeometry(arg1,&geometry_info);
3628 if ((flags & (RhoValue|SigmaValue)) == 0)
3629 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3630 if ((flags & SigmaValue) == 0)
3631 geometry_info.sigma=1.0;
3632 if ((flags & XiValue) == 0)
3633 geometry_info.xi=1.0;
3634 if ((flags & PsiValue) == 0)
3635 geometry_info.psi=0.05;
3636 new_image=UnsharpMaskImage(_image,geometry_info.rho,
3637 geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception);
3640 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3644 if (LocaleCompare(
"verbose",option+1) == 0)
3650 (void) SetImageArtifact(_image,option+1,IfNormalOp ?
"true" :
3654 if (LocaleCompare(
"vignette",option+1) == 0)
3656 flags=ParseGeometry(arg1,&geometry_info);
3657 if ((flags & (RhoValue|SigmaValue)) == 0)
3658 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3659 if ((flags & SigmaValue) == 0)
3660 geometry_info.sigma=1.0;
3661 if ((flags & XiValue) == 0)
3662 geometry_info.xi=0.1*_image->columns;
3663 if ((flags & PsiValue) == 0)
3664 geometry_info.psi=0.1*_image->rows;
3665 if ((flags & PercentValue) != 0)
3667 geometry_info.xi*=(double) _image->columns/100.0;
3668 geometry_info.psi*=(double) _image->rows/100.0;
3670 new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma,
3671 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3672 ceil(geometry_info.psi-0.5),_exception);
3675 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3679 if (LocaleCompare(
"wave",option+1) == 0)
3681 flags=ParseGeometry(arg1,&geometry_info);
3682 if ((flags & (RhoValue|SigmaValue)) == 0)
3683 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3684 if ((flags & SigmaValue) == 0)
3685 geometry_info.sigma=1.0;
3686 new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma,
3687 _image->interpolate,_exception);
3690 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3692 flags=ParseGeometry(arg1,&geometry_info);
3693 if ((flags & RhoValue) == 0)
3694 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3695 if ((flags & PercentValue) != 0)
3697 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3698 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3701 if ((flags & SigmaValue) == 0)
3702 geometry_info.sigma=0.0;
3703 new_image=WaveletDenoiseImage(_image,geometry_info.rho,
3704 geometry_info.sigma,_exception);
3707 if (LocaleCompare(
"white-balance",option+1) == 0)
3709 (void) WhiteBalanceImage(_image,_exception);
3712 if (LocaleCompare(
"white-threshold",option+1) == 0)
3714 if (IsGeometry(arg1) == MagickFalse)
3715 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3716 (void) WhiteThresholdImage(_image,arg1,_exception);
3719 if (LocaleCompare(
"write-mask",option+1) == 0)
3727 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
3732 mask=GetImageCache(_image_info,arg1,_exception);
3733 if (mask == (Image *) NULL)
3735 (void) SetImageMask(_image,WritePixelMask,mask,_exception);
3736 mask=DestroyImage(mask);
3739 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3742 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3746 arg1=DestroyString((
char *)arg1);
3748 arg2=DestroyString((
char *)arg2);
3752 if (new_image != (Image *) NULL)
3753 ReplaceImageInListReturnLast(&_image,new_image);
3758#undef _quantize_info
3767static MagickBooleanType CLISimpleOperatorImages(
MagickCLI *cli_wand,
3768 const char *option,
const char *arg1,
const char *arg2,ExceptionInfo *exception)
3770#if !USE_WAND_METHODS
3777 assert(cli_wand->signature == MagickWandSignature);
3778 assert(cli_wand->wand.signature == MagickWandSignature);
3779 assert(cli_wand->wand.images != (Image *) NULL);
3781 if (cli_wand->wand.debug != MagickFalse)
3782 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
3783 "- Simple Operator: %s \"%s\" \"%s\"", option,arg1,arg2);
3785#if !USE_WAND_METHODS
3788 n=GetImageListLength(cli_wand->wand.images);
3789 cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
3792 CLISimpleOperatorImage(cli_wand, option, arg1, arg2,exception);
3793 if ( cli_wand->wand.images->next == (Image *) NULL )
3795 cli_wand->wand.images=cli_wand->wand.images->next;
3798 cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
3800 MagickResetIterator(&cli_wand->wand);
3801 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
3802 (void) CLISimpleOperatorImage(cli_wand, option, arg1, arg2,exception);
3803 MagickResetIterator(&cli_wand->wand);
3839static MagickBooleanType CLIListOperatorImages(
MagickCLI *cli_wand,
3840 const char *option,
const char *arg1n,
const char *arg2n)
3855#define _image_info (cli_wand->wand.image_info)
3856#define _images (cli_wand->wand.images)
3857#define _exception (cli_wand->wand.exception)
3858#define _draw_info (cli_wand->draw_info)
3859#define _quantize_info (cli_wand->quantize_info)
3860#define _process_flags (cli_wand->process_flags)
3861#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
3862#define IfNormalOp (*option=='-')
3863#define IfPlusOp (*option!='-')
3864#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse
3867 assert(cli_wand->signature == MagickWandSignature);
3868 assert(cli_wand->wand.signature == MagickWandSignature);
3869 assert(_images != (Image *) NULL);
3871 if (cli_wand->wand.debug != MagickFalse)
3872 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
3873 "- List Operator: %s \"%s\" \"%s\"", option,
3874 arg1n == (
const char *) NULL ?
"null" : arg1n,
3875 arg2n == (
const char *) NULL ?
"null" : arg2n);
3881 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
3882 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
3883 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
3885 if (arg1n != (
char *) NULL) {
3886 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
3887 if (arg1 == (
char *) NULL) {
3888 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
3892 if (arg2n != (
char *) NULL) {
3893 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
3894 if (arg2 == (
char *) NULL) {
3895 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
3900#undef _process_flags
3904 new_images=NewImageList();
3906 switch (*(option+1))
3910 if (LocaleCompare(
"append",option+1) == 0)
3912 new_images=AppendImages(_images,IsNormalOp,_exception);
3915 if (LocaleCompare(
"average",option+1) == 0)
3917 CLIWandWarnReplaced(
"-evaluate-sequence Mean");
3918 (void) CLIListOperatorImages(cli_wand,
"-evaluate-sequence",
"Mean",
3922 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3926 if (LocaleCompare(
"channel-fx",option+1) == 0)
3928 new_images=ChannelFxImage(_images,arg1,_exception);
3931 if (LocaleCompare(
"clut",option+1) == 0)
3940 new_images=RemoveFirstImageFromList(&_images);
3941 clut_image=RemoveFirstImageFromList(&_images);
3943 if (clut_image == (Image *) NULL)
3945 (void) ThrowMagickException(_exception,GetMagickModule(),
3946 OptionError,
"ImageSequenceRequired",
"`%s'",option);
3947 new_images=DestroyImage(new_images);
3951 (void) ClutImage(new_images,clut_image,new_images->interpolate,
3953 clut_image=DestroyImage(clut_image);
3956 if (LocaleCompare(
"coalesce",option+1) == 0)
3958 new_images=CoalesceImages(_images,_exception);
3961 if (LocaleCompare(
"combine",option+1) == 0)
3963 parse=(ssize_t) _images->colorspace;
3964 if (_images->number_channels < GetImageListLength(_images))
3965 parse=sRGBColorspace;
3967 parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);
3969 CLIWandExceptArgBreak(OptionError,
"UnrecognizedColorspace",option,
3971 new_images=CombineImages(_images,(ColorspaceType) parse,_exception);
3974 if (LocaleCompare(
"compare",option+1) == 0)
3990 image=RemoveFirstImageFromList(&_images);
3991 reconstruct_image=RemoveFirstImageFromList(&_images);
3993 if (reconstruct_image == (Image *) NULL)
3995 (void) ThrowMagickException(_exception,GetMagickModule(),
3996 OptionError,
"ImageSequenceRequired",
"`%s'",option);
3997 image=DestroyImage(image);
4001 metric=UndefinedErrorMetric;
4002 option=GetImageOption(_image_info,
"metric");
4003 if (option != (
const char *) NULL)
4004 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
4005 MagickFalse,option);
4006 new_images=CompareImages(image,reconstruct_image,metric,&distortion,
4009 reconstruct_image=DestroyImage(reconstruct_image);
4010 image=DestroyImage(image);
4013 if (LocaleCompare(
"complex",option+1) == 0)
4015 parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1);
4017 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
4019 new_images=ComplexImages(_images,(ComplexOperator) parse,_exception);
4022 if (LocaleCompare(
"composite",option+1) == 0)
4041 value=GetImageOption(_image_info,
"compose");
4042 if (value == (
const char *) NULL)
4043 compose=OverCompositeOp;
4045 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
4049 clip_to_self=GetCompositeClipToSelf(compose);
4050 value=GetImageOption(_image_info,
"compose:clip-to-self");
4051 if (value != (
const char *) NULL)
4052 clip_to_self=IsStringTrue(value);
4053 value=GetImageOption(_image_info,
"compose:outside-overlay");
4054 if (value != (
const char *) NULL)
4055 clip_to_self=IsStringFalse(value);
4057 new_images=RemoveFirstImageFromList(&_images);
4058 source_image=RemoveFirstImageFromList(&_images);
4059 if (source_image == (Image *) NULL)
4061 (void) ThrowMagickException(_exception,GetMagickModule(),
4062 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4063 new_images=DestroyImage(new_images);
4069 if (source_image->geometry != (
char *) NULL)
4074 (void) ParseRegionGeometry(source_image,source_image->geometry,
4075 &resize_geometry,_exception);
4076 if ((source_image->columns != resize_geometry.width) ||
4077 (source_image->rows != resize_geometry.height))
4082 resize_image=ResizeImage(source_image,resize_geometry.width,
4083 resize_geometry.height,source_image->filter,_exception);
4084 if (resize_image != (Image *) NULL)
4086 source_image=DestroyImage(source_image);
4087 source_image=resize_image;
4091 SetGeometry(source_image,&geometry);
4092 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
4093 GravityAdjustGeometry(new_images->columns,new_images->rows,
4094 new_images->gravity, &geometry);
4095 mask_image=RemoveFirstImageFromList(&_images);
4096 if (mask_image == (Image *) NULL)
4097 status&=(MagickStatusType) CompositeImage(new_images,source_image,
4098 compose,clip_to_self,geometry.x,geometry.y,_exception);
4104 canvas_image=CloneImage(new_images,0,0,MagickTrue,_exception);
4105 if (canvas_image == (Image *) NULL)
4109 case BlendCompositeOp:
4111 status&=(MagickStatusType) CompositeImage(new_images,
4112 source_image,compose,clip_to_self,geometry.x,geometry.y,
4114 status&=(MagickStatusType) CompositeImage(new_images,
4115 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4118 case DisplaceCompositeOp:
4119 case DistortCompositeOp:
4121 status&=(MagickStatusType) CompositeImage(source_image,
4122 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,_exception);
4123 (void) SetImageColorspace(source_image,sRGBColorspace,
4125 status&=(MagickStatusType) CompositeImage(new_images,
4126 source_image,compose,clip_to_self,geometry.x,geometry.y,
4130 case SaliencyBlendCompositeOp:
4131 case SeamlessBlendCompositeOp:
4133 status&=(MagickStatusType) CompositeImage(source_image,
4134 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4135 status&=(MagickStatusType) CompositeImage(new_images,
4136 source_image,compose,clip_to_self,geometry.x,geometry.y,
4145 clone_image=CloneImage(new_images,0,0,MagickTrue,_exception);
4146 if (clone_image == (Image *) NULL)
4148 status&=(MagickStatusType) CompositeImage(new_images,
4149 source_image,compose,clip_to_self,geometry.x,geometry.y,
4151 status&=(MagickStatusType) CompositeImage(new_images,
4152 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4153 status&=(MagickStatusType) CompositeImage(clone_image,
4154 new_images,OverCompositeOp,clip_to_self,0,0,_exception);
4155 new_images=DestroyImageList(new_images);
4156 new_images=clone_image;
4162 case DisplaceCompositeOp:
4163 case DistortCompositeOp:
4165 status&=(MagickStatusType) CompositeImage(canvas_image,
4166 new_images,CopyCompositeOp,clip_to_self,0,0,_exception);
4171 status&=(MagickStatusType) CompositeImage(canvas_image,
4172 new_images,OverCompositeOp,clip_to_self,0,0,_exception);
4176 new_images=DestroyImageList(new_images);
4177 new_images=canvas_image;
4178 mask_image=DestroyImage(mask_image);
4180 source_image=DestroyImage(source_image);
4183 if (LocaleCompare(
"copy",option+1) == 0)
4197 if (IsGeometry(arg1) == MagickFalse)
4198 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4199 if (IsGeometry(arg2) == MagickFalse)
4200 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4201 (void) ParsePageGeometry(_images,arg2,&geometry,_exception);
4202 offset.x=geometry.x;
4203 offset.y=geometry.y;
4204 source_image=_images;
4205 if (source_image->next != (Image *) NULL)
4206 source_image=source_image->next;
4207 (void) ParsePageGeometry(source_image,arg1,&geometry,_exception);
4208 (void) CopyImagePixels(_images,source_image,&geometry,&offset,
4212 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4216 if (LocaleCompare(
"deconstruct",option+1) == 0)
4218 CLIWandWarnReplaced(
"-layers CompareAny");
4219 (void) CLIListOperatorImages(cli_wand,
"-layers",
"CompareAny",NULL);
4222 if (LocaleCompare(
"delete",option+1) == 0)
4226 DeleteImages(&_images,
"-1",_exception);
4229 if (LocaleNCompare(arg1,
"registry:",9) == 0)
4231 (void) DeleteImageRegistry(arg1+9);
4234 if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
4235 CLIWandExceptionBreak(OptionError,
"InvalidArgument",option);
4236 DeleteImages(&_images,arg1,_exception);
4239 if (LocaleCompare(
"duplicate",option+1) == 0)
4242 new_images=DuplicateImages(_images,1,
"-1",_exception);
4251 if (IsGeometry(arg1) == MagickFalse)
4252 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,
4254 number_duplicates=(size_t) StringToLong(arg1);
4255 if (arg1 == (
char *) NULL)
4258 if (p == (
const char *) NULL)
4259 new_images=DuplicateImages(_images,number_duplicates,
"-1",
4262 new_images=DuplicateImages(_images,number_duplicates,p+1,
4265 AppendImageToList(&_images, new_images);
4266 new_images=(Image *) NULL;
4269 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4273 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4275 parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
4277 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
4279 new_images=EvaluateImages(_images,(MagickEvaluateOperator) parse,
4283 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4287 if (LocaleCompare(
"fft",option+1) == 0)
4289 new_images=ForwardFourierTransformImage(_images,IsNormalOp,
4293 if (LocaleCompare(
"flatten",option+1) == 0)
4296 (void) CLIListOperatorImages(cli_wand,
"-layers",option+1,NULL);
4299 if (LocaleCompare(
"fx",option+1) == 0)
4301 new_images=FxImage(_images,arg1,_exception);
4304 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4308 if (LocaleCompare(
"hald-clut",option+1) == 0)
4316 new_images=RemoveFirstImageFromList(&_images);
4317 hald_image=RemoveLastImageFromList(&_images);
4318 if (hald_image == (Image *) NULL)
4320 (void) ThrowMagickException(_exception,GetMagickModule(),
4321 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4322 new_images=DestroyImage(new_images);
4326 (void) HaldClutImage(new_images,hald_image,_exception);
4327 hald_image=DestroyImage(hald_image);
4330 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4334 if (LocaleCompare(
"ift",option+1) == 0)
4340 magnitude_image=RemoveFirstImageFromList(&_images);
4341 phase_image=RemoveFirstImageFromList(&_images);
4342 if (phase_image == (Image *) NULL)
4344 (void) ThrowMagickException(_exception,GetMagickModule(),
4345 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4346 magnitude_image=DestroyImage(magnitude_image);
4350 new_images=InverseFourierTransformImage(magnitude_image,phase_image,
4351 IsNormalOp,_exception);
4352 magnitude_image=DestroyImage(magnitude_image);
4353 phase_image=DestroyImage(phase_image);
4356 if (LocaleCompare(
"insert",option+1) == 0)
4365 if (IfNormalOp && (IsGeometry(arg1) == MagickFalse))
4366 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4368 insert_image=RemoveLastImageFromList(&_images);
4370 index=(ssize_t) StringToLong(arg1);
4371 index_image=insert_image;
4373 PrependImageToList(&_images,insert_image);
4374 else if (index == (ssize_t) GetImageListLength(_images))
4375 AppendImageToList(&_images,insert_image);
4378 index_image=GetImageFromList(_images,index-1);
4379 if (index_image == (Image *) NULL)
4381 insert_image=DestroyImage(insert_image);
4382 CLIWandExceptArgBreak(OptionError,
"NoSuchImage",option,arg1);
4384 InsertImageInList(&index_image,insert_image);
4386 _images=GetFirstImageInList(index_image);
4389 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4393 if (LocaleCompare(
"layers",option+1) == 0)
4395 parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1);
4397 CLIWandExceptArgBreak(OptionError,
"UnrecognizedLayerMethod",
4399 switch ((LayerMethod) parse)
4403 new_images=CoalesceImages(_images,_exception);
4406 case CompareAnyLayer:
4407 case CompareClearLayer:
4408 case CompareOverlayLayer:
4411 new_images=CompareImagesLayers(_images,(LayerMethod) parse,
4418 case TrimBoundsLayer:
4420 new_images=MergeImageLayers(_images,(LayerMethod) parse,
4426 new_images=DisposeImages(_images,_exception);
4429 case OptimizeImageLayer:
4431 new_images=OptimizeImageLayers(_images,_exception);
4434 case OptimizePlusLayer:
4436 new_images=OptimizePlusImageLayers(_images,_exception);
4439 case OptimizeTransLayer:
4441 OptimizeImageTransparency(_images,_exception);
4444 case RemoveDupsLayer:
4446 RemoveDuplicateLayers(&_images,_exception);
4449 case RemoveZeroLayer:
4451 RemoveZeroDelayLayers(&_images,_exception);
4456 new_images=CoalesceImages(_images,_exception);
4457 if (new_images == (Image *) NULL)
4459 _images=DestroyImageList(_images);
4460 _images=OptimizeImageLayers(new_images,_exception);
4461 if (_images == (Image *) NULL)
4463 new_images=DestroyImageList(new_images);
4464 OptimizeImageTransparency(_images,_exception);
4465 (void) RemapImages(_quantize_info,_images,(Image *) NULL,
4469 case CompositeLayer:
4483 value=GetImageOption(_image_info,
"compose");
4484 compose=OverCompositeOp;
4485 if (value != (
const char *) NULL)
4486 compose=(CompositeOperator) ParseCommandOption(
4487 MagickComposeOptions,MagickFalse,value);
4491 while (source != (Image *) NULL)
4493 source=GetNextImageInList(source);
4494 if ((source != (Image *) NULL) &&
4495 (LocaleCompare(source->magick,
"NULL") == 0))
4498 if (source != (Image *) NULL)
4500 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4501 (GetNextImageInList(source) == (Image *) NULL))
4502 source=(Image *) NULL;
4505 source=SplitImageList(source->previous);
4506 DeleteImageFromList(&source);
4509 if (source == (Image *) NULL)
4511 (void) ThrowMagickException(_exception,GetMagickModule(),
4512 OptionError,
"MissingNullSeparator",
"layers Composite");
4516 SetGeometry(_images,&geometry);
4517 (void) ParseAbsoluteGeometry(_images->geometry,&geometry);
4518 geometry.width=source->page.width != 0 ?
4519 source->page.width : source->columns;
4520 geometry.height=source->page.height != 0 ?
4521 source->page.height : source->rows;
4522 GravityAdjustGeometry(_images->page.width != 0 ?
4523 _images->page.width : _images->columns,
4524 _images->page.height != 0 ? _images->page.height :
4525 _images->rows,_images->gravity,&geometry);
4528 CompositeLayers(_images,compose,source,geometry.x,geometry.y,
4530 source=DestroyImageList(source);
4536 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4540 if (LocaleCompare(
"map",option+1) == 0)
4542 CLIWandWarnReplaced(
"+remap");
4543 (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);
4546 if (LocaleCompare(
"metric",option+1) == 0)
4548 (void) SetImageOption(_image_info,option+1,arg1);
4551 if (LocaleCompare(
"morph",option+1) == 0)
4556 if (IsGeometry(arg1) == MagickFalse)
4557 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4558 morph_image=MorphImages(_images,StringToUnsignedLong(arg1),
4560 if (morph_image == (Image *) NULL)
4562 _images=DestroyImageList(_images);
4563 _images=morph_image;
4566 if (LocaleCompare(
"mosaic",option+1) == 0)
4569 (void) CLIListOperatorImages(cli_wand,
"-layers",option+1,NULL);
4572 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4576 if (LocaleCompare(
"poly",option+1) == 0)
4585 args = StringToArrayOfDoubles(arg1,&count,_exception);
4586 if (args == (
double *) NULL )
4587 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg1);
4588 new_images=PolynomialImage(_images,(
size_t) (count >> 1),args,
4590 args=(
double *) RelinquishMagickMemory(args);
4593 if (LocaleCompare(
"process",option+1) == 0)
4603 arguments=StringToArgv(arg1,&number_arguments);
4604 if ((arguments == (
char **) NULL) || (number_arguments == 1))
4606 if (strchr(arguments[1],
'=') != (
char *) NULL)
4629 assert(arg1 != (
const char *) NULL);
4630 length=strlen(arg1);
4631 token=(
char *) NULL;
4632 if (~length >= (MagickPathExtent-1))
4633 token=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
4635 if (token == (
char *) NULL)
4639 token_info=AcquireTokenInfo();
4640 tokenizer_status=Tokenizer(token_info,0,token,length,p,
"",
"=",
4641 "\"",
'\0',&breaker,&next,"e);
4642 token_info=DestroyTokenInfo(token_info);
4643 if (tokenizer_status == 0)
4649 (void) InvokeDynamicImageFilter(token,&_images,1,&argv,
4652 token=DestroyString(token);
4655 (void) SubstituteString(&arguments[1],
"-",
"");
4656 (void) InvokeDynamicImageFilter(arguments[1],&_images,
4657 number_arguments-2,(
const char **) arguments+2,_exception);
4658 for (j=0; j < number_arguments; j++)
4659 arguments[j]=DestroyString(arguments[j]);
4660 arguments=(
char **) RelinquishMagickMemory(arguments);
4663 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4667 if (LocaleCompare(
"remap",option+1) == 0)
4669 (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);
4672 if (LocaleCompare(
"reverse",option+1) == 0)
4674 ReverseImageList(&_images);
4677 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4681 if (LocaleCompare(
"smush",option+1) == 0)
4687 if (IsGeometry(arg1) == MagickFalse)
4688 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4689 offset=(ssize_t) StringToLong(arg1);
4690 new_images=SmushImages(_images,IsNormalOp,offset,_exception);
4693 if (LocaleCompare(
"subimage",option+1) == 0)
4711 base_image=GetImageFromList(_images,0);
4712 compare_image=GetImageFromList(_images,1);
4715 metric=UndefinedErrorMetric;
4716 value=GetImageOption(_image_info,
"metric");
4717 if (value != (
const char *) NULL)
4718 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
4721 new_images=SimilarityImage(base_image,compare_image,metric,0.0,
4722 &offset,&similarity,_exception);
4724 if (new_images != (Image *) NULL)
4726 (void) FormatImageProperty(new_images,
"subimage:similarity",
4727 "%.*g",GetMagickPrecision(),similarity);
4728 (void) FormatImageProperty(new_images,
"subimage:x",
"%+ld",(
long)
4730 (void) FormatImageProperty(new_images,
"subimage:y",
"%+ld",(
long)
4732 (void) FormatImageProperty(new_images,
"subimage:offset",
4733 "%lux%lu%+ld%+ld",(
unsigned long) offset.width,(
unsigned long)
4734 offset.height,(
long) offset.x,(
long) offset.y);
4738 if (LocaleCompare(
"swap",option+1) == 0)
4759 flags=ParseGeometry(arg1,&geometry_info);
4760 if ((flags & RhoValue) == 0)
4761 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4762 index=(ssize_t) geometry_info.rho;
4763 if ((flags & SigmaValue) != 0)
4764 swap_index=(ssize_t) geometry_info.sigma;
4766 p=GetImageFromList(_images,index);
4767 q=GetImageFromList(_images,swap_index);
4768 if ((p == (Image *) NULL) || (q == (Image *) NULL)) {
4770 CLIWandExceptArgBreak(OptionError,
"InvalidImageIndex",option,arg1)
4772 CLIWandExceptionBreak(OptionError,
"TwoOrMoreImagesRequired",option);
4775 CLIWandExceptArgBreak(OptionError,
"InvalidImageIndex",option,arg1);
4776 swap=CloneImage(p,0,0,MagickTrue,_exception);
4777 if (swap == (Image *) NULL)
4778 CLIWandExceptArgBreak(ResourceLimitError,
"MemoryAllocationFailed",
4779 option,GetExceptionMessage(errno));
4780 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));
4781 ReplaceImageInList(&q,swap);
4782 _images=GetFirstImageInList(q);
4785 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4788 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4793 arg1=DestroyString((
char *)arg1);
4795 arg2=DestroyString((
char *)arg2);
4798 if (new_images == (Image *) NULL)
4799 return(status == 0 ? MagickFalse : MagickTrue);
4800 _images=DestroyImageList(_images);
4801 _images=GetFirstImageInList(new_images);
4802 return(status == 0 ? MagickFalse : MagickTrue);
4808#undef _quantize_info
4850static void CLINoImageOperator(
MagickCLI *cli_wand,
4851 const char *option,
const char *arg1n,
const char *arg2n)
4857#define _image_info (cli_wand->wand.image_info)
4858#define _images (cli_wand->wand.images)
4859#define _exception (cli_wand->wand.exception)
4860#define _process_flags (cli_wand->process_flags)
4861#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
4862#define IfNormalOp (*option=='-')
4863#define IfPlusOp (*option!='-')
4866 assert(cli_wand->signature == MagickWandSignature);
4867 assert(cli_wand->wand.signature == MagickWandSignature);
4869 if (cli_wand->wand.debug != MagickFalse)
4870 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
4871 "- NoImage Operator: %s \"%s\" \"%s\"", option,
4872 arg1n != (
char *) NULL ? arg1n :
"",
4873 arg2n != (
char *) NULL ? arg2n :
"");
4879 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
4880 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
4881 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
4883 if (arg1n != (
char *) NULL) {
4884 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
4885 if (arg1 == (
char *) NULL) {
4886 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
4890 if (arg2n != (
char *) NULL) {
4891 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
4892 if (arg2 == (
char *) NULL) {
4893 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
4898#undef _process_flags
4905 if (LocaleCompare(
"noop",option+1) == 0)
4907 if (LocaleCompare(
"sans",option+1) == 0)
4909 if (LocaleCompare(
"sans0",option+1) == 0)
4911 if (LocaleCompare(
"sans1",option+1) == 0)
4913 if (LocaleCompare(
"sans2",option+1) == 0)
4918 if ( ( LocaleCompare(
"read",option+1) == 0 ) ||
4919 ( LocaleCompare(
"--",option) == 0 ) ) {
4942 argv = (
char **) &arg1;
4948 if (ExpandFilenames(&argc,&argv) == MagickFalse)
4949 CLIWandExceptArgBreak(ResourceLimitError,
"MemoryAllocationFailed",
4950 option,GetExceptionMessage(errno));
4953 for (i=0; i < (ssize_t) argc; i++) {
4956 if (_image_info->ping != MagickFalse)
4957 new_images=PingImages(_image_info,argv[i],_exception);
4959 new_images=ReadImages(_image_info,argv[i],_exception);
4960 AppendImageToList(&_images, new_images);
4961 argv[i]=DestroyString(argv[i]);
4963 argv=(
char **) RelinquishMagickMemory(argv);
4970 if (LocaleCompare(
"write",option+1) == 0) {
4973 key[MagickPathExtent];
4982 if ( _images == (Image *) NULL ) {
4983 if ( LocaleCompare(arg1,
"null:") == 0 )
4985 CLIWandExceptArgBreak(OptionError,
"NoImagesForWrite",option,arg1);
4988 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",arg1);
4989 (void) DeleteImageRegistry(key);
4990 write_images=CloneImageList(_images,_exception);
4991 write_info=CloneImageInfo(_image_info);
4992 if (write_images != (Image *) NULL)
4993 (void) WriteImages(write_info,write_images,arg1,_exception);
4994 write_info=DestroyImageInfo(write_info);
4995 write_images=DestroyImageList(write_images);
5001 if (LocaleCompare(
"(",option) == 0) {
5010 node=cli_wand->image_list_stack;
5011 for ( ; node != (
CLIStack *) NULL; node=node->next)
5013 if ( size >= MAX_STACK_DEPTH )
5014 CLIWandExceptionBreak(OptionError,
"ParenthesisNestedTooDeeply",option);
5015 node=(
CLIStack *) AcquireMagickMemory(
sizeof(*node));
5017 CLIWandExceptionBreak(ResourceLimitFatalError,
5018 "MemoryAllocationFailed",option);
5019 node->data = (
void *)cli_wand->wand.images;
5020 node->next = cli_wand->image_list_stack;
5021 cli_wand->image_list_stack = node;
5022 cli_wand->wand.images = NewImageList();
5025 if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,
5026 "respect-parentheses")) != MagickFalse)
5032 if (LocaleCompare(
"{",option) == 0) {
5041 node=cli_wand->image_info_stack;
5042 for ( ; node != (
CLIStack *) NULL; node=node->next)
5044 if ( size >= MAX_STACK_DEPTH )
5045 CLIWandExceptionBreak(OptionError,
"CurlyBracesNestedTooDeeply",option);
5046 node=(
CLIStack *) AcquireMagickMemory(
sizeof(*node));
5048 CLIWandExceptionBreak(ResourceLimitFatalError,
5049 "MemoryAllocationFailed",option);
5051 node->data = (
void *)cli_wand->wand.image_info;
5052 node->next = cli_wand->image_info_stack;
5054 cli_wand->image_info_stack = node;
5055 cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
5056 if (cli_wand->wand.image_info == (ImageInfo *) NULL) {
5057 CLIWandException(ResourceLimitFatalError,
"MemoryAllocationFailed",
5059 cli_wand->wand.image_info = (ImageInfo *)node->data;
5060 node = (
CLIStack *)RelinquishMagickMemory(node);
5066 if (LocaleCompare(
")",option) == 0) {
5071 node = (
CLIStack *)cli_wand->image_list_stack;
5073 CLIWandExceptionBreak(OptionError,
"UnbalancedParenthesis",option);
5074 cli_wand->image_list_stack = node->next;
5076 AppendImageToList((Image **)&node->data,cli_wand->wand.images);
5077 cli_wand->wand.images= (Image *)node->data;
5078 node = (
CLIStack *)RelinquishMagickMemory(node);
5081 node = cli_wand->image_info_stack;
5084 if (IsStringTrue(GetImageOption(
5085 cli_wand->wand.image_info,
"respect-parentheses")) != MagickFalse)
5094 if (LocaleCompare(
"}",option) == 0) {
5099 node = (
CLIStack *)cli_wand->image_info_stack;
5101 CLIWandExceptionBreak(OptionError,
"UnbalancedCurlyBraces",option);
5102 cli_wand->image_info_stack = node->next;
5104 (void) DestroyImageInfo(cli_wand->wand.image_info);
5105 cli_wand->wand.image_info = (ImageInfo *)node->data;
5106 node = (
CLIStack *)RelinquishMagickMemory(node);
5108 GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
5109 cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
5110 cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
5114 if (LocaleCompare(
"print",option+1) == 0)
5116 (void) FormatLocaleFile(stdout,
"%s",arg1);
5119 if (LocaleCompare(
"set",option+1) == 0)
5128 StringInfo *profile = (StringInfo *) NULL;
5129 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
5130 if (arg1 == (
char *) NULL)
5131 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
5134 if (LocaleNCompare(arg1,
"registry:",9) == 0)
5138 (void) DeleteImageRegistry(arg1+9);
5139 arg1=DestroyString((
char *)arg1);
5142 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5143 if (arg2 == (
char *) NULL) {
5144 arg1=DestroyString((
char *)arg1);
5145 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
5148 (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);
5149 arg1=DestroyString((
char *)arg1);
5150 arg2=DestroyString((
char *)arg2);
5153 if (LocaleNCompare(arg1,
"option:",7) == 0)
5156 if (_images != (Image *) NULL)
5158 MagickResetIterator(&cli_wand->wand);
5159 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
5160 (void) DeleteImageArtifact(_images,arg1+7);
5161 MagickResetIterator(&cli_wand->wand);
5168 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5169 if (arg2 == (
char *) NULL)
5170 CLIWandExceptionBreak(OptionWarning,
5171 "InterpretPropertyFailure",option);
5173 (void) SetImageOption(_image_info,arg1+7,arg2);
5174 arg1=DestroyString((
char *) arg1);
5175 arg2=DestroyString((
char *) arg2);
5178 if (LocaleCompare(arg1,
"profile") == 0)
5180 if (arg2 != (
char *) NULL)
5181 (void) CopyMagickString(_image_info->filename,arg2,
5183 (void) SetImageInfo(_image_info,1,_exception);
5184 if (LocaleCompare(_image_info->filename,
"-") != 0)
5185 profile=FileToStringInfo(_image_info->filename,~0UL,_exception);
5188 if ( _images == (Image *) NULL )
5189 CLIWandExceptArgBreak(OptionWarning,
"NoImageForProperty",option,arg1);
5191 MagickResetIterator(&cli_wand->wand);
5192 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
5197 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5198 if (arg2 == (
char *) NULL)
5199 CLIWandExceptionBreak(OptionWarning,
5200 "InterpretPropertyFailure",option);
5202 if (LocaleNCompare(arg1,
"artifact:",9) == 0)
5203 (void) SetImageArtifact(_images,arg1+9,arg2);
5204 else if (LocaleNCompare(arg1,
"property:",9) == 0)
5205 (void) SetImageProperty(_images,arg1+9,arg2,_exception);
5207 (
void) SetImageProperty(_images,arg1,arg2,_exception);
5208 if (profile != (StringInfo *) NULL)
5209 (void) SetImageProfile(_images,_image_info->magick,profile,_exception);
5210 arg2=DestroyString((
char *)arg2);
5212 if (profile != (StringInfo *) NULL)
5213 profile=DestroyStringInfo(profile);
5214 MagickResetIterator(&cli_wand->wand);
5215 arg1=DestroyString((
char *)arg1);
5218 if (LocaleCompare(
"clone",option+1) == 0) {
5223 arg1=AcquireString(
"-1");
5224 if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
5225 CLIWandExceptionBreak(OptionError,
"InvalidArgument",option);
5226 if ( cli_wand->image_list_stack == (
CLIStack *) NULL)
5227 CLIWandExceptionBreak(OptionError,
"UnableToCloneImage",option);
5228 new_images = (Image *)cli_wand->image_list_stack->data;
5229 if (new_images == (Image *) NULL)
5230 CLIWandExceptionBreak(OptionError,
"UnableToCloneImage",option);
5231 new_images=CloneImages(new_images,arg1,_exception);
5232 if (new_images == (Image *) NULL)
5233 CLIWandExceptionBreak(OptionError,
"NoSuchImage",option);
5234 AppendImageToList(&_images,new_images);
5243 if (LocaleCompare(
"version",option+1) == 0)
5245 ListMagickVersion(stdout);
5248 if (LocaleCompare(
"list",option+1) == 0)
5256 list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
5259 CLIWandExceptionArg(OptionError,
"UnrecognizedListType",option,arg1);
5264 case MagickCoderOptions:
5266 (void) ListCoderInfo((FILE *) NULL,_exception);
5269 case MagickColorOptions:
5271 (void) ListColorInfo((FILE *) NULL,_exception);
5274 case MagickConfigureOptions:
5276 (void) ListConfigureInfo((FILE *) NULL,_exception);
5279 case MagickDelegateOptions:
5281 (void) ListDelegateInfo((FILE *) NULL,_exception);
5284 case MagickFontOptions:
5286 (void) ListTypeInfo((FILE *) NULL,_exception);
5289 case MagickFormatOptions:
5290 (void) ListMagickInfo((FILE *) NULL,_exception);
5292 case MagickLocaleOptions:
5293 (void) ListLocaleInfo((FILE *) NULL,_exception);
5295 case MagickLogOptions:
5296 (void) ListLogInfo((FILE *) NULL,_exception);
5298 case MagickMagicOptions:
5299 (void) ListMagicInfo((FILE *) NULL,_exception);
5301 case MagickMimeOptions:
5302 (void) ListMimeInfo((FILE *) NULL,_exception);
5304 case MagickModuleOptions:
5305 (void) ListModuleInfo((FILE *) NULL,_exception);
5307 case MagickPagesizeOptions:
5308 (void) ListPagesizes((FILE *) NULL,_exception);
5310 case MagickPolicyOptions:
5311 (void) ListPolicyInfo((FILE *) NULL,_exception);
5313 case MagickResourceOptions:
5314 (void) ListMagickResourceInfo((FILE *) NULL,_exception);
5316 case MagickThresholdOptions:
5317 (void) ListThresholdMaps((FILE *) NULL,_exception);
5320 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
5327 CLIWandException(OptionError,
"UnrecognizedOption",option);
5329DisableMSCWarning(4127)
5335 arg1=DestroyString((
char *)arg1);
5337 arg2=DestroyString((
char *)arg2);
5391WandExport
void CLIOption(
MagickCLI *cli_wand,
const char *option,...)
5401 assert(cli_wand->signature == MagickWandSignature);
5402 assert(cli_wand->wand.signature == MagickWandSignature);
5407 if ( cli_wand->command == (
const OptionInfo *) NULL )
5408 cli_wand->command = GetCommandOptionInfo(option);
5410 (void) FormatLocaleFile(stderr,
"CLIOption \"%s\" matched \"%s\"\n",
5411 option, cli_wand->command->mnemonic );
5413 option_type=(CommandOptionFlags) cli_wand->command->flags;
5415 if ( option_type == UndefinedOptionFlag )
5416 CLIWandExceptionReturn(OptionFatalError,
"UnrecognizedOption",option);
5418 assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 );
5421 if ( (option_type & DeprecateOptionFlag) != 0 )
5422 CLIWandExceptionBreak(OptionError,
"DeprecatedOptionNoCode",option);
5425 if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 )
5426 CLIWandExceptionBreak(OptionFatalError,
"InvalidUseOfOption",option);
5433 count = (size_t) cli_wand->command->type;
5438 va_start(operands,option);
5442 arg1=(
const char *) va_arg(operands,
const char *);
5444 arg2=(
const char *) va_arg(operands,
const char *);
5448 (void) FormatLocaleFile(stderr,
5449 "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n",
5450 option,(
long) count,option_type,arg1,arg2);
5460 if ( cli_wand->wand.images != (Image *) NULL )
5461 (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
5462 cli_wand->wand.exception);
5464 if ( (option_type & SettingOptionFlags) != 0 ) {
5465 CLISettingOptionInfo(cli_wand, option, arg1, arg2);
5472 if ((option_type & NoImageOperatorFlag) != 0)
5473 CLINoImageOperator(cli_wand, option, arg1, arg2);
5478 if ( cli_wand->wand.images == (Image *) NULL )
5479 if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) &&
5480 ((option_type & SettingOptionFlags) == 0 ))
5481 CLIWandExceptionBreak(OptionError,
"NoImagesFound",option);
5484 if ( (option_type & SimpleOperatorFlag) != 0 &&
5485 cli_wand->wand.images != (Image *) NULL)
5487 ExceptionInfo *exception=AcquireExceptionInfo();
5488 (void) CLISimpleOperatorImages(cli_wand, option, arg1, arg2,exception);
5489 exception=DestroyExceptionInfo(exception);
5493 if ( (option_type & ListOperatorFlag) != 0 )
5494 (void) CLIListOperatorImages(cli_wand, option, arg1, arg2);
5496DisableMSCWarning(4127)
5500 cli_wand->command = (
const OptionInfo *) NULL;