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-parenthesis",option+1) == 0)
1321 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1324 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1328 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1331 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1332 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1333 (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL));
1336 if (LocaleCompare(
"scene",option+1) == 0)
1341 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1342 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1343 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1344 _image_info->scene=StringToUnsignedLong(ArgOption(
"0"));
1347 if (LocaleCompare(
"seed",option+1) == 0)
1349 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1350 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1352 IfSetOption ? (
unsigned long) StringToUnsignedLong(arg1)
1353 : (unsigned long) time((time_t *) NULL));
1356 if (LocaleCompare(
"size",option+1) == 0)
1361 (void) CloneString(&_image_info->size,ArgOption(NULL));
1364 if (LocaleCompare(
"stretch",option+1) == 0)
1366 arg1=ArgOption(
"undefined");
1367 parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1);
1369 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStretchType",
1371 _draw_info->stretch=(StretchType) parse;
1374 if (LocaleCompare(
"stroke",option+1) == 0)
1389 arg1 = ArgOption(
"none");
1390 (void) SetImageOption(_image_info,option+1,arg1);
1391 if (_draw_info->stroke_pattern != (Image *) NULL)
1392 _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern);
1395 sans=AcquireExceptionInfo();
1396 status=QueryColorCompliance(arg1,AllCompliance,&color,sans);
1397 sans=DestroyExceptionInfo(sans);
1399 if (status == MagickFalse)
1400 _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception);
1402 _draw_info->stroke=color;
1405 if (LocaleCompare(
"strokewidth",option+1) == 0)
1407 if (IfSetOption && (IsGeometry(arg1) == MagickFalse))
1408 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1409 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1410 _draw_info->stroke_width=StringToDouble(ArgOption(
"1.0"),
1414 if (LocaleCompare(
"style",option+1) == 0)
1416 arg1=ArgOption(
"undefined");
1417 parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1);
1419 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStyleType",
1421 _draw_info->style=(StyleType) parse;
1425 if (LocaleCompare(
"subimage-search",option+1) == 0)
1429 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1433 if (LocaleCompare(
"synchronize",option+1) == 0)
1436 _image_info->synchronize = ArgBoolean;
1439 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1443 if (LocaleCompare(
"taint",option+1) == 0)
1446 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1449 if (LocaleCompare(
"texture",option+1) == 0)
1455 (void) CloneString(&_image_info->texture,ArgOption(NULL));
1458 if (LocaleCompare(
"tile",option+1) == 0)
1461 _draw_info->fill_pattern=IfSetOption
1462 ?GetImageCache(_image_info,arg1,_exception)
1463 :DestroyImage(_draw_info->fill_pattern);
1466 if (LocaleCompare(
"tile-offset",option+1) == 0)
1469 arg1=ArgOption(
"0");
1470 if (IsGeometry(arg1) == MagickFalse)
1471 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1472 (void) SetImageOption(_image_info,option+1,arg1);
1475 if (LocaleCompare(
"transparent-color",option+1) == 0)
1484 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1485 (void) QueryColorCompliance(ArgOption(
"none"),AllCompliance,
1486 &_image_info->transparent_color,_exception);
1489 if (LocaleCompare(
"treedepth",option+1) == 0)
1491 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1492 _quantize_info->tree_depth=StringToUnsignedLong(ArgOption(
"0"));
1495 if (LocaleCompare(
"type",option+1) == 0)
1498 parse=ParseCommandOption(MagickTypeOptions,MagickFalse,
1499 ArgOption(
"undefined"));
1501 CLIWandExceptArgBreak(OptionError,
"UnrecognizedImageType",
1503 _image_info->type=(ImageType) parse;
1504 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1507 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1511 if (LocaleCompare(
"undercolor",option+1) == 0)
1513 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1514 (void) QueryColorCompliance(ArgOption(
"none"),AllCompliance,
1515 &_draw_info->undercolor,_exception);
1518 if (LocaleCompare(
"units",option+1) == 0)
1524 parse=ParseCommandOption(MagickResolutionOptions,MagickFalse,
1525 ArgOption(
"undefined"));
1527 CLIWandExceptArgBreak(OptionError,
"UnrecognizedUnitsType",
1529 _image_info->units=(ResolutionType) parse;
1530 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1533 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1537 if (LocaleCompare(
"verbose",option+1) == 0)
1542 (void) SetImageOption(_image_info,option+1,ArgBooleanString);
1543 _image_info->verbose= ArgBoolean;
1544 _image_info->ping=MagickFalse;
1547 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1552 parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1553 ArgOption(
"undefined"));
1555 CLIWandExceptArgBreak(OptionError,
"UnrecognizedVirtualPixelMethod",
1557 (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
1560 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1564 if (LocaleCompare(
"weight",option+1) == 0)
1569 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,arg1);
1571 weight=(ssize_t) StringToUnsignedLong(arg1);
1572 _draw_info->weight=(size_t) weight;
1575 if (LocaleCompare(
"white-point",option+1) == 0)
1580 arg1=ArgOption(
"0.0");
1581 if (IsGeometry(arg1) == MagickFalse)
1582 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1583 (void) SetImageOption(_image_info,option+1,arg1);
1586 if (LocaleCompare(
"word-break",option+1) == 0)
1588 parse=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
1589 ArgOption(
"undefined"));
1591 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1592 (void) SetImageOption(_image_info,option+1, ArgOption(NULL));
1595 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1598 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1602 if ((arg1 && arg1n) && (arg1 != arg1n ))
1603 arg1=DestroyString((
char *) arg1);
1604 if ((arg2 && arg2n) && (arg2 != arg2n ))
1605 arg2=DestroyString((
char *) arg2);
1610#undef _quantize_info
1614#undef ArgBooleanString
1669static MagickBooleanType CLISimpleOperatorImage(
MagickCLI *cli_wand,
1670 const char *option,
const char *arg1n,
const char *arg2n,
1671 ExceptionInfo *exception)
1692#define _image_info (cli_wand->wand.image_info)
1693#define _image (cli_wand->wand.images)
1694#define _exception (cli_wand->wand.exception)
1695#define _draw_info (cli_wand->draw_info)
1696#define _quantize_info (cli_wand->quantize_info)
1697#define _process_flags (cli_wand->process_flags)
1698#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
1699#define IfNormalOp (*option=='-')
1700#define IfPlusOp (*option!='-')
1701#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse
1702#define IsPlusOp IfNormalOp ? MagickFalse : MagickTrue
1705 assert(cli_wand->signature == MagickWandSignature);
1706 assert(cli_wand->wand.signature == MagickWandSignature);
1707 assert(_image != (Image *) NULL);
1708 if (cli_wand->wand.debug != MagickFalse)
1709 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",cli_wand->wand.name);
1715 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
1716 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
1717 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
1719 if (arg1n != (
char *) NULL) {
1720 arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception);
1721 if (arg1 == (
char *) NULL) {
1722 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
1726 if (arg2n != (
char *) NULL) {
1727 arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception);
1728 if (arg2 == (
char *) NULL) {
1729 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
1734#undef _process_flags
1738 (void) FormatLocaleFile(stderr,
1739 "CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2);
1742 new_image = (Image *) NULL;
1743 SetGeometryInfo(&geometry_info);
1745 switch (*(option+1))
1749 if (LocaleCompare(
"adaptive-blur",option+1) == 0)
1751 flags=ParseGeometry(arg1,&geometry_info);
1752 if ((flags & (RhoValue|SigmaValue)) == 0)
1753 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1754 if ((flags & SigmaValue) == 0)
1755 geometry_info.sigma=1.0;
1756 new_image=AdaptiveBlurImage(_image,geometry_info.rho,
1757 geometry_info.sigma,_exception);
1760 if (LocaleCompare(
"adaptive-resize",option+1) == 0)
1763 if (IsGeometry(arg1) == MagickFalse)
1764 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1765 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
1766 new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height,
1770 if (LocaleCompare(
"adaptive-sharpen",option+1) == 0)
1772 flags=ParseGeometry(arg1,&geometry_info);
1773 if ((flags & (RhoValue|SigmaValue)) == 0)
1774 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1775 if ((flags & SigmaValue) == 0)
1776 geometry_info.sigma=1.0;
1777 new_image=AdaptiveSharpenImage(_image,geometry_info.rho,
1778 geometry_info.sigma,_exception);
1781 if (LocaleCompare(
"alpha",option+1) == 0)
1783 parse=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,arg1);
1785 CLIWandExceptArgBreak(OptionError,
"UnrecognizedAlphaChannelOption",
1787 (void) SetImageAlphaChannel(_image,(AlphaChannelOption) parse,
1791 if (LocaleCompare(
"annotate",option+1) == 0)
1794 buffer[MagickPathExtent];
1796 SetGeometryInfo(&geometry_info);
1797 flags=ParseGeometry(arg1,&geometry_info);
1799 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1800 if ((flags & SigmaValue) == 0)
1801 geometry_info.sigma=geometry_info.rho;
1802 (void) CloneString(&_draw_info->text,arg2);
1803 (void) FormatLocaleString(buffer,MagickPathExtent,
"%+f%+f",
1804 geometry_info.xi,geometry_info.psi);
1805 (void) CloneString(&_draw_info->geometry,buffer);
1806 _draw_info->affine.sx=cos(DegreesToRadians(
1807 fmod(geometry_info.rho,360.0)));
1808 _draw_info->affine.rx=sin(DegreesToRadians(
1809 fmod(geometry_info.rho,360.0)));
1810 _draw_info->affine.ry=(-sin(DegreesToRadians(
1811 fmod(geometry_info.sigma,360.0))));
1812 _draw_info->affine.sy=cos(DegreesToRadians(
1813 fmod(geometry_info.sigma,360.0)));
1814 (void) AnnotateImage(_image,_draw_info,_exception);
1815 GetAffineMatrix(&_draw_info->affine);
1818 if (LocaleCompare(
"auto-gamma",option+1) == 0)
1820 (void) AutoGammaImage(_image,_exception);
1823 if (LocaleCompare(
"auto-level",option+1) == 0)
1825 (void) AutoLevelImage(_image,_exception);
1828 if (LocaleCompare(
"auto-orient",option+1) == 0)
1830 new_image=AutoOrientImage(_image,_image->orientation,_exception);
1833 if (LocaleCompare(
"auto-threshold",option+1) == 0)
1838 method=(AutoThresholdMethod) ParseCommandOption(
1839 MagickAutoThresholdOptions,MagickFalse,arg1);
1840 (void) AutoThresholdImage(_image,method,_exception);
1843 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1847 if (LocaleCompare(
"bilateral-blur",option+1) == 0)
1849 flags=ParseGeometry(arg1,&geometry_info);
1850 if ((flags & (RhoValue|SigmaValue)) == 0)
1851 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1852 if ((flags & SigmaValue) == 0)
1853 geometry_info.sigma=geometry_info.rho;
1854 if ((flags & XiValue) == 0)
1855 geometry_info.xi=1.0*sqrt(geometry_info.rho*geometry_info.rho+
1856 geometry_info.sigma*geometry_info.sigma);
1857 if ((flags & PsiValue) == 0)
1858 geometry_info.psi=0.25*sqrt(geometry_info.rho*geometry_info.rho+
1859 geometry_info.sigma*geometry_info.sigma);
1860 new_image=BilateralBlurImage(_image,(
size_t) geometry_info.rho,
1861 (
size_t) geometry_info.sigma,geometry_info.xi,geometry_info.psi,
1865 if (LocaleCompare(
"black-threshold",option+1) == 0)
1867 if (IsGeometry(arg1) == MagickFalse)
1868 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1869 (void) BlackThresholdImage(_image,arg1,_exception);
1872 if (LocaleCompare(
"blue-shift",option+1) == 0)
1874 geometry_info.rho=1.5;
1876 flags=ParseGeometry(arg1,&geometry_info);
1877 if ((flags & RhoValue) == 0)
1878 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1880 new_image=BlueShiftImage(_image,geometry_info.rho,_exception);
1883 if (LocaleCompare(
"blur",option+1) == 0)
1885 flags=ParseGeometry(arg1,&geometry_info);
1886 if ((flags & (RhoValue|SigmaValue)) == 0)
1887 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1888 if ((flags & SigmaValue) == 0)
1889 geometry_info.sigma=1.0;
1890 new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma,
1894 if (LocaleCompare(
"border",option+1) == 0)
1902 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
1903 if ((flags & (WidthValue | HeightValue)) == 0)
1904 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1905 compose=OverCompositeOp;
1906 value=GetImageOption(_image_info,
"compose");
1907 if (value != (
const char *) NULL)
1908 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1910 new_image=BorderImage(_image,&geometry,compose,_exception);
1913 if (LocaleCompare(
"brightness-contrast",option+1) == 0)
1919 flags=ParseGeometry(arg1,&geometry_info);
1920 if ((flags & RhoValue) == 0)
1921 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1922 brightness=geometry_info.rho;
1924 if ((flags & SigmaValue) != 0)
1925 contrast=geometry_info.sigma;
1926 (void) BrightnessContrastImage(_image,brightness,contrast,
1930 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
1934 if (LocaleCompare(
"canny",option+1) == 0)
1936 flags=ParseGeometry(arg1,&geometry_info);
1937 if ((flags & (RhoValue|SigmaValue)) == 0)
1938 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1939 if ((flags & SigmaValue) == 0)
1940 geometry_info.sigma=1.0;
1941 if ((flags & XiValue) == 0)
1942 geometry_info.xi=10;
1943 if ((flags & PsiValue) == 0)
1944 geometry_info.psi=30;
1945 if ((flags & PercentValue) != 0)
1947 geometry_info.xi/=100.0;
1948 geometry_info.psi/=100.0;
1950 new_image=CannyEdgeImage(_image,geometry_info.rho,geometry_info.sigma,
1951 geometry_info.xi,geometry_info.psi,_exception);
1954 if (LocaleCompare(
"cdl",option+1) == 0)
1957 *color_correction_collection;
1962 color_correction_collection=FileToString(arg1,~0UL,_exception);
1963 if (color_correction_collection == (
char *) NULL)
1965 (void) ColorDecisionListImage(_image,color_correction_collection,
1969 if (LocaleCompare(
"channel",option+1) == 0)
1973 (void) SetPixelChannelMask(_image,DefaultChannels);
1976 parse=ParseChannelOption(arg1);
1978 CLIWandExceptArgBreak(OptionError,
"UnrecognizedChannelType",option,
1980 (void) SetPixelChannelMask(_image,(ChannelType) parse);
1983 if (LocaleCompare(
"charcoal",option+1) == 0)
1985 flags=ParseGeometry(arg1,&geometry_info);
1986 if ((flags & (RhoValue|SigmaValue)) == 0)
1987 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
1988 if ((flags & SigmaValue) == 0)
1989 geometry_info.sigma=1.0;
1990 if ((flags & XiValue) == 0)
1991 geometry_info.xi=1.0;
1992 new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma,
1996 if (LocaleCompare(
"chop",option+1) == 0)
1998 if (IsGeometry(arg1) == MagickFalse)
1999 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2000 (void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
2001 new_image=ChopImage(_image,&geometry,_exception);
2004 if (LocaleCompare(
"clahe",option+1) == 0)
2006 if (IsGeometry(arg1) == MagickFalse)
2007 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2008 flags=ParseGeometry(arg1,&geometry_info);
2009 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2010 (void) CLAHEImage(_image,geometry.width,geometry.height,
2011 (
size_t) geometry.x,geometry_info.psi,_exception);
2014 if (LocaleCompare(
"clamp",option+1) == 0)
2016 (void) ClampImage(_image,_exception);
2019 if (LocaleCompare(
"clip",option+1) == 0)
2022 (void) ClipImage(_image,_exception);
2024 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2028 if (LocaleCompare(
"clip-mask",option+1) == 0)
2035 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2039 clip_mask=GetImageCache(_image_info,arg1,_exception);
2040 if (clip_mask == (Image *) NULL)
2042 (void) SetImageMask(_image,WritePixelMask,clip_mask,_exception);
2043 clip_mask=DestroyImage(clip_mask);
2046 if (LocaleCompare(
"clip-path",option+1) == 0)
2048 (void) ClipImagePath(_image,arg1,IsNormalOp,_exception);
2052 if (LocaleCompare(
"colorize",option+1) == 0)
2054 if (IsGeometry(arg1) == MagickFalse)
2055 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2056 new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception);
2059 if (LocaleCompare(
"color-matrix",option+1) == 0)
2064 kernel=AcquireKernelInfo(arg1,exception);
2065 if (kernel == (KernelInfo *) NULL)
2066 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2067 new_image=ColorMatrixImage(_image,kernel,_exception);
2068 kernel=DestroyKernelInfo(kernel);
2071 if (LocaleCompare(
"colors",option+1) == 0)
2076 _quantize_info->number_colors=StringToUnsignedLong(arg1);
2077 _quantize_info->measure_error=_image_info->verbose;
2078 if (_quantize_info->number_colors == 0)
2079 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2080 if ((_image->storage_class == DirectClass) ||
2081 _image->colors > _quantize_info->number_colors)
2082 (void) QuantizeImage(_quantize_info,_image,_exception);
2084 (
void) CompressImageColormap(_image,_exception);
2087 if (LocaleCompare(
"colorspace",option+1) == 0)
2099 (void) TransformImageColorspace(_image,
2100 IfNormalOp ? _image_info->colorspace : sRGBColorspace,
2104 if (LocaleCompare(
"color-threshold",option+1) == 0)
2114 (void) GetColorRange(
"white-black",&start,&stop,_exception);
2116 (
void) GetColorRange(arg1,&start,&stop,_exception);
2117 (void) ColorThresholdImage(_image,&start,&stop,_exception);
2120 if (LocaleCompare(
"connected-components",option+1) == 0)
2122 if (IsGeometry(arg1) == MagickFalse)
2123 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2124 new_image=ConnectedComponentsImage(_image,(
size_t)
2125 StringToInteger(arg1),(CCObjectInfo **) NULL,_exception);
2128 if (LocaleCompare(
"contrast",option+1) == 0)
2130 CLIWandWarnReplaced(IfNormalOp?
"-level":
"+level");
2131 (void) ContrastImage(_image,IsNormalOp,_exception);
2134 if (LocaleCompare(
"contrast-stretch",option+1) == 0)
2140 flags=ParseGeometry(arg1,&geometry_info);
2141 if ((flags & RhoValue) == 0)
2142 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2143 black_point=geometry_info.rho;
2144 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
2146 if ((flags & PercentValue) != 0)
2148 black_point*=(double) _image->columns*_image->rows/100.0;
2149 white_point*=(double) _image->columns*_image->rows/100.0;
2151 white_point=(double) _image->columns*_image->rows-white_point;
2152 (void) ContrastStretchImage(_image,black_point,white_point,
2156 if (LocaleCompare(
"convolve",option+1) == 0)
2167 kernel_info=AcquireKernelInfo(arg1,exception);
2168 if (kernel_info == (KernelInfo *) NULL)
2169 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2171 for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
2172 gamma+=kernel_info->values[j];
2173 gamma=1.0/(fabs((
double) gamma) <= MagickEpsilon ? 1.0 : gamma);
2174 for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
2175 kernel_info->values[j]*=gamma;
2176 new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info,
2178 kernel_info=DestroyKernelInfo(kernel_info);
2181 if (LocaleCompare(
"crop",option+1) == 0)
2184 if (IsGeometry(arg1) == MagickFalse)
2185 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2186 new_image=CropImageToTiles(_image,arg1,_exception);
2189 if (LocaleCompare(
"cycle",option+1) == 0)
2191 if (IsGeometry(arg1) == MagickFalse)
2192 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2193 (void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1),
2197 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2201 if (LocaleCompare(
"decipher",option+1) == 0)
2207 passkey=FileToStringInfo(arg1,~0UL,_exception);
2208 if (passkey == (StringInfo *) NULL)
2209 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2211 (void) PasskeyDecipherImage(_image,passkey,_exception);
2212 passkey=DestroyStringInfo(passkey);
2215 if (LocaleCompare(
"depth",option+1) == 0)
2225 (void) SetImageDepth(_image,_image_info->depth,_exception);
2228 if (LocaleCompare(
"deskew",option+1) == 0)
2234 if (IsGeometry(arg1) == MagickFalse)
2235 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2236 threshold=StringToDoubleInterval(arg1,(
double) QuantumRange+1.0);
2239 threshold=40.0*(double) QuantumRange/100.0;
2240 new_image=DeskewImage(_image,threshold,_exception);
2243 if (LocaleCompare(
"despeckle",option+1) == 0)
2245 new_image=DespeckleImage(_image,_exception);
2248 if (LocaleCompare(
"distort",option+1) == 0)
2256 parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1);
2258 CLIWandExceptArgBreak(OptionError,
"UnrecognizedDistortMethod",
2260 if ((DistortMethod) parse == ResizeDistortion)
2268 if (IsGeometry(arg2) == MagickFalse)
2269 CLIWandExceptArgBreak(OptionError,
"InvalidGeometry",
2271 (void) ParseRegionGeometry(_image,arg2,&geometry,_exception);
2272 resize_args[0]=(double) geometry.width;
2273 resize_args[1]=(double) geometry.height;
2274 new_image=DistortImage(_image,(DistortMethod) parse,
2275 (
size_t)2,resize_args,MagickTrue,_exception);
2279 args = StringToArrayOfDoubles(arg2,&count,_exception);
2280 if (args == (
double *) NULL )
2281 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg2);
2283 new_image=DistortImage(_image,(DistortMethod) parse,(
size_t)
2284 count,args,IsPlusOp,_exception);
2285 args=(
double *) RelinquishMagickMemory(args);
2288 if (LocaleCompare(
"draw",option+1) == 0)
2290 (void) CloneString(&_draw_info->primitive,arg1);
2291 (void) DrawImage(_image,_draw_info,_exception);
2292 (void) CloneString(&_draw_info->primitive,(
char *) NULL);
2295 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2299 if (LocaleCompare(
"edge",option+1) == 0)
2301 flags=ParseGeometry(arg1,&geometry_info);
2302 if ((flags & (RhoValue|SigmaValue)) == 0)
2303 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2304 new_image=EdgeImage(_image,geometry_info.rho,_exception);
2307 if (LocaleCompare(
"emboss",option+1) == 0)
2309 flags=ParseGeometry(arg1,&geometry_info);
2310 if ((flags & (RhoValue|SigmaValue)) == 0)
2311 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2312 if ((flags & SigmaValue) == 0)
2313 geometry_info.sigma=1.0;
2314 new_image=EmbossImage(_image,geometry_info.rho,
2315 geometry_info.sigma,_exception);
2318 if (LocaleCompare(
"encipher",option+1) == 0)
2324 passkey=FileToStringInfo(arg1,~0UL,_exception);
2325 if (passkey != (StringInfo *) NULL)
2327 (void) PasskeyEncipherImage(_image,passkey,_exception);
2328 passkey=DestroyStringInfo(passkey);
2332 if (LocaleCompare(
"enhance",option+1) == 0)
2334 new_image=EnhanceImage(_image,_exception);
2337 if (LocaleCompare(
"equalize",option+1) == 0)
2339 (void) EqualizeImage(_image,_exception);
2342 if (LocaleCompare(
"evaluate",option+1) == 0)
2347 parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
2349 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
2351 if (IsGeometry(arg2) == MagickFalse)
2352 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
2353 constant=StringToDoubleInterval(arg2,(
double) QuantumRange+1.0);
2354 (void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant,
2358 if (LocaleCompare(
"extent",option+1) == 0)
2360 if (IsGeometry(arg1) == MagickFalse)
2361 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2362 flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
2363 if (geometry.width == 0)
2364 geometry.width=_image->columns;
2365 if (geometry.height == 0)
2366 geometry.height=_image->rows;
2367 new_image=ExtentImage(_image,&geometry,_exception);
2370 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2374 if (LocaleCompare(
"features",option+1) == 0)
2376 CLIWandWarnReplaced(
"-verbose -define identify:features=");
2379 (void) DeleteImageArtifact(_image,
"identify:features");
2382 (void) SetImageArtifact(_image,
"identify:features",arg1);
2383 (void) SetImageArtifact(_image,
"verbose",
"true");
2386 if (LocaleCompare(
"flip",option+1) == 0)
2388 new_image=FlipImage(_image,_exception);
2391 if (LocaleCompare(
"flop",option+1) == 0)
2393 new_image=FlopImage(_image,_exception);
2396 if (LocaleCompare(
"floodfill",option+1) == 0)
2401 if (IsGeometry(arg1) == MagickFalse)
2402 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2403 (void) ParsePageGeometry(_image,arg1,&geometry,_exception);
2404 (void) QueryColorCompliance(arg2,AllCompliance,&target,_exception);
2405 (void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x,
2406 geometry.y,IsPlusOp,_exception);
2409 if (LocaleCompare(
"frame",option+1) == 0)
2420 value=GetImageOption(_image_info,
"compose");
2421 compose=OverCompositeOp;
2422 if (value != (
const char *) NULL)
2423 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
2425 if (IsGeometry(arg1) == MagickFalse)
2426 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2427 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
2428 frame_info.width=geometry.width;
2429 frame_info.height=geometry.height;
2430 frame_info.outer_bevel=geometry.x;
2431 frame_info.inner_bevel=geometry.y;
2432 frame_info.x=(ssize_t) frame_info.width;
2433 frame_info.y=(ssize_t) frame_info.height;
2434 frame_info.width=_image->columns+2*frame_info.width;
2435 frame_info.height=_image->rows+2*frame_info.height;
2436 new_image=FrameImage(_image,&frame_info,compose,_exception);
2439 if (LocaleCompare(
"function",option+1) == 0)
2447 parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1);
2449 CLIWandExceptArgBreak(OptionError,
"UnrecognizedFunction",
2452 args = StringToArrayOfDoubles(arg2,&count,_exception);
2453 if (args == (
double *) NULL )
2454 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg2);
2456 (void) FunctionImage(_image,(MagickFunction)parse,(size_t) count,args,
2458 args=(
double *) RelinquishMagickMemory(args);
2461 if (LocaleCompare(
"fx",option+1) == 0)
2463 new_image=FxImage(_image,arg1,_exception);
2466 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2470 if (LocaleCompare(
"gamma",option+1) == 0)
2475 if (IsGeometry(arg1) == MagickFalse)
2476 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2477 constant=StringToDouble(arg1,(
char **) NULL);
2481 constant=PerceptibleReciprocal(constant);
2482 (void) GammaImage(_image,constant,_exception);
2486 constant=PerceptibleReciprocal(constant);
2487 (void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception);
2488 _image->gamma*=StringToDouble(arg1,(
char **) NULL);
2495 if (LocaleCompare(
"gaussian-blur",option+1) == 0)
2497 flags=ParseGeometry(arg1,&geometry_info);
2498 if ((flags & (RhoValue|SigmaValue)) == 0)
2499 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2500 if ((flags & SigmaValue) == 0)
2501 geometry_info.sigma=1.0;
2502 new_image=GaussianBlurImage(_image,geometry_info.rho,
2503 geometry_info.sigma,_exception);
2506 if (LocaleCompare(
"gaussian",option+1) == 0)
2508 CLIWandWarnReplaced(
"-gaussian-blur");
2509 (void) CLISimpleOperatorImage(cli_wand,
"-gaussian-blur",arg1,NULL,exception);
2511 if (LocaleCompare(
"geometry",option+1) == 0)
2521 if (_image->geometry != (
char *) NULL)
2522 _image->geometry=DestroyString(_image->geometry);
2525 if (IsGeometry(arg1) == MagickFalse)
2526 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2527 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2528 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
2529 (void) CloneString(&_image->geometry,arg1);
2531 new_image=ResizeImage(_image,geometry.width,geometry.height,
2532 _image->filter,_exception);
2535 if (LocaleCompare(
"grayscale",option+1) == 0)
2537 parse=ParseCommandOption(MagickPixelIntensityOptions,
2540 CLIWandExceptArgBreak(OptionError,
"UnrecognizedIntensityMethod",
2542 (void) GrayscaleImage(_image,(PixelIntensityMethod) parse,_exception);
2545 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2549 if (LocaleCompare(
"hough-lines",option+1) == 0)
2551 flags=ParseGeometry(arg1,&geometry_info);
2552 if ((flags & (RhoValue|SigmaValue)) == 0)
2553 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2554 if ((flags & SigmaValue) == 0)
2555 geometry_info.sigma=geometry_info.rho;
2556 if ((flags & XiValue) == 0)
2557 geometry_info.xi=40;
2558 new_image=HoughLineImage(_image,(
size_t) geometry_info.rho,
2559 (
size_t) geometry_info.sigma,(
size_t) geometry_info.xi,_exception);
2562 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2566 if (LocaleCompare(
"identify",option+1) == 0)
2572 format=GetImageOption(_image_info,
"format");
2573 if (format == (
char *) NULL)
2575 (void) IdentifyImage(_image,stdout,_image_info->verbose,
2579 text=InterpretImageProperties(_image_info,_image,format,_exception);
2580 if (text == (
char *) NULL)
2581 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
2583 (void) fputs(text,stdout);
2584 text=DestroyString((
char *)text);
2587 if (LocaleCompare(
"implode",option+1) == 0)
2589 flags=ParseGeometry(arg1,&geometry_info);
2590 if ((flags & RhoValue) == 0)
2591 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2592 new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate,
2596 if (LocaleCompare(
"integral",option+1) == 0)
2598 new_image=IntegralImage(_image,_exception);
2601 if (LocaleCompare(
"interpolative-resize",option+1) == 0)
2605 if (IsGeometry(arg1) == MagickFalse)
2606 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2607 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
2608 new_image=InterpolativeResizeImage(_image,geometry.width,
2609 geometry.height,_image->interpolate,_exception);
2612 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2616 if (LocaleCompare(
"kmeans",option+1) == 0)
2621 flags=ParseGeometry(arg1,&geometry_info);
2622 if ((flags & (RhoValue|SigmaValue)) == 0)
2623 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2624 if ((flags & SigmaValue) == 0)
2625 geometry_info.sigma=300.0;
2626 if ((flags & XiValue) == 0)
2627 geometry_info.xi=0.0001;
2628 (void) KmeansImage(_image,(
size_t) geometry_info.rho,(size_t)
2629 geometry_info.sigma,geometry_info.xi,_exception);
2632 if (LocaleCompare(
"kuwahara",option+1) == 0)
2637 flags=ParseGeometry(arg1,&geometry_info);
2638 if ((flags & (RhoValue|SigmaValue)) == 0)
2639 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2640 if ((flags & SigmaValue) == 0)
2641 geometry_info.sigma=geometry_info.rho-0.5;
2642 new_image=KuwaharaImage(_image,geometry_info.rho,geometry_info.sigma,
2646 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2650 if (LocaleCompare(
"lat",option+1) == 0)
2652 flags=ParseGeometry(arg1,&geometry_info);
2653 if ((flags & (RhoValue|SigmaValue)) == 0)
2654 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2655 if ((flags & SigmaValue) == 0)
2656 geometry_info.sigma=1.0;
2657 if ((flags & PercentValue) != 0)
2658 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2659 new_image=AdaptiveThresholdImage(_image,(
size_t) geometry_info.rho,
2660 (
size_t) geometry_info.sigma,(
double) geometry_info.xi,
2664 if (LocaleCompare(
"level",option+1) == 0)
2671 flags=ParseGeometry(arg1,&geometry_info);
2672 if ((flags & RhoValue) == 0)
2673 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2674 black_point=geometry_info.rho;
2675 white_point=(double) QuantumRange;
2676 if ((flags & SigmaValue) != 0)
2677 white_point=geometry_info.sigma;
2679 if ((flags & XiValue) != 0)
2680 gamma=geometry_info.xi;
2681 if ((flags & PercentValue) != 0)
2683 black_point*=(double) QuantumRange/100.0;
2684 white_point*=(double) QuantumRange/100.0;
2686 if ((flags & SigmaValue) == 0)
2687 white_point=(
double) QuantumRange-black_point;
2688 if (IfPlusOp || ((flags & AspectValue) != 0))
2689 (void) LevelizeImage(_image,black_point,white_point,gamma,_exception);
2691 (
void) LevelImage(_image,black_point,white_point,gamma,_exception);
2694 if (LocaleCompare(
"level-colors",option+1) == 0)
2697 token[MagickPathExtent];
2706 p=(
const char *) arg1;
2707 (void) GetNextToken(p,&p,MagickPathExtent,token);
2708 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2709 (void) QueryColorCompliance(token,AllCompliance,
2710 &black_point,_exception);
2712 (
void) QueryColorCompliance(
"#000000",AllCompliance,
2713 &black_point,_exception);
2714 if (isalpha((
int) ((
unsigned char) *token)) || (*token ==
'#'))
2715 (void) GetNextToken(p,&p,MagickPathExtent,token);
2717 white_point=black_point;
2720 if ((isalpha((
int) ((
unsigned char) *token)) == 0) && ((*token ==
'#') == 0))
2721 (
void) GetNextToken(p,&p,MagickPathExtent,token);
2722 if ((isalpha((
int) ((
unsigned char) *token)) != 0) || ((*token ==
'#') != 0))
2723 (void) QueryColorCompliance(token,AllCompliance,
2724 &white_point,_exception);
2726 (
void) QueryColorCompliance(
"#ffffff",AllCompliance,
2727 &white_point,_exception);
2729 (void) LevelImageColors(_image,&black_point,&white_point,
2730 IsPlusOp,_exception);
2733 if (LocaleCompare(
"linear-stretch",option+1) == 0)
2739 flags=ParseGeometry(arg1,&geometry_info);
2740 if ((flags & RhoValue) == 0)
2741 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2742 black_point=geometry_info.rho;
2743 white_point=(double) _image->columns*_image->rows;
2744 if ((flags & SigmaValue) != 0)
2745 white_point=geometry_info.sigma;
2746 if ((flags & PercentValue) != 0)
2748 black_point*=(double) _image->columns*_image->rows/100.0;
2749 white_point*=(double) _image->columns*_image->rows/100.0;
2751 if ((flags & SigmaValue) == 0)
2752 white_point=(double) _image->columns*_image->rows-
2754 (void) LinearStretchImage(_image,black_point,white_point,_exception);
2757 if (LocaleCompare(
"liquid-rescale",option+1) == 0)
2760 if (IsGeometry(arg1) == MagickFalse)
2761 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2762 flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
2763 if ((flags & XValue) == 0)
2765 if ((flags & YValue) == 0)
2767 new_image=LiquidRescaleImage(_image,geometry.width,
2768 geometry.height,1.0*geometry.x,1.0*geometry.y,_exception);
2771 if (LocaleCompare(
"local-contrast",option+1) == 0)
2773 flags=ParseGeometry(arg1,&geometry_info);
2774 if ((flags & RhoValue) == 0)
2775 geometry_info.rho=10;
2776 if ((flags & SigmaValue) == 0)
2777 geometry_info.sigma=12.5;
2778 new_image=LocalContrastImage(_image,geometry_info.rho,
2779 geometry_info.sigma,exception);
2782 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2786 if (LocaleCompare(
"magnify",option+1) == 0)
2788 new_image=MagnifyImage(_image,_exception);
2791 if (LocaleCompare(
"map",option+1) == 0)
2793 CLIWandWarnReplaced(
"-remap");
2794 (void) CLISimpleOperatorImage(cli_wand,
"-remap",arg1,NULL,exception);
2797 if (LocaleCompare(
"mask",option+1) == 0)
2807 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
2814 mask=GetImageCache(_image_info,arg1,_exception);
2815 if (mask == (Image *) NULL)
2817 (void) SetImageMask(_image,WritePixelMask,mask,_exception);
2818 mask=DestroyImage(mask);
2821 if (LocaleCompare(
"matte",option+1) == 0)
2823 CLIWandWarnReplaced(IfNormalOp?
"-alpha Set":
"-alpha Off");
2824 (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel :
2825 DeactivateAlphaChannel, _exception);
2828 if (LocaleCompare(
"mean-shift",option+1) == 0)
2830 flags=ParseGeometry(arg1,&geometry_info);
2831 if ((flags & (RhoValue|SigmaValue)) == 0)
2832 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2833 if ((flags & SigmaValue) == 0)
2834 geometry_info.sigma=1.0;
2835 if ((flags & XiValue) == 0)
2836 geometry_info.xi=0.10*(double) QuantumRange;
2837 if ((flags & PercentValue) != 0)
2838 geometry_info.xi=(
double) QuantumRange*geometry_info.xi/100.0;
2839 new_image=MeanShiftImage(_image,(
size_t) geometry_info.rho,
2840 (
size_t) geometry_info.sigma,geometry_info.xi,_exception);
2843 if (LocaleCompare(
"median",option+1) == 0)
2845 CLIWandWarnReplaced(
"-statistic Median");
2846 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"Median",arg1,exception);
2849 if (LocaleCompare(
"mode",option+1) == 0)
2852 CLIWandWarnReplaced(
"-statistic Mode");
2853 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"Mode",arg1,
2857 if (LocaleCompare(
"modulate",option+1) == 0)
2859 if (IsGeometry(arg1) == MagickFalse)
2860 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2861 (void) ModulateImage(_image,arg1,_exception);
2864 if (LocaleCompare(
"monitor",option+1) == 0)
2866 (void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress :
2867 (MagickProgressMonitor) NULL,(void *) NULL);
2870 if (LocaleCompare(
"moments",option+1) == 0)
2872 CLIWandWarnReplaced(
"-verbose -define identify:moments=");
2875 (void) DeleteImageArtifact(_image,
"identify:moments");
2878 (void) SetImageArtifact(_image,
"identify:moments",
"true");
2879 (void) SetImageArtifact(_image,
"verbose",
"true");
2882 if (LocaleCompare(
"monochrome",option+1) == 0)
2884 (void) SetImageType(_image,BilevelType,_exception);
2887 if (LocaleCompare(
"morphology",option+1) == 0)
2890 token[MagickPathExtent];
2902 (void) GetNextToken(p,&p,MagickPathExtent,token);
2903 parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
2905 CLIWandExceptArgBreak(OptionError,
"UnrecognizedFunction",option,
2908 (void) GetNextToken(p,&p,MagickPathExtent,token);
2909 if ((*p ==
':') || (*p ==
','))
2910 (void) GetNextToken(p,&p,MagickPathExtent,token);
2912 iterations=(ssize_t) StringToLong(p);
2913 kernel=AcquireKernelInfo(arg2,exception);
2914 if (kernel == (KernelInfo *) NULL)
2915 CLIWandExceptArgBreak(OptionError,
"UnabletoParseKernel",option,arg2);
2916 new_image=MorphologyImage(_image,(MorphologyMethod)parse,iterations,
2918 kernel=DestroyKernelInfo(kernel);
2921 if (LocaleCompare(
"motion-blur",option+1) == 0)
2923 flags=ParseGeometry(arg1,&geometry_info);
2924 if ((flags & (RhoValue|SigmaValue)) == 0)
2925 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
2926 if ((flags & SigmaValue) == 0)
2927 geometry_info.sigma=1.0;
2928 new_image=MotionBlurImage(_image,geometry_info.rho,
2929 geometry_info.sigma,geometry_info.xi,_exception);
2932 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2936 if (LocaleCompare(
"negate",option+1) == 0)
2938 (void) NegateImage(_image, IsPlusOp, _exception);
2941 if (LocaleCompare(
"noise",option+1) == 0)
2951 CLIWandWarnReplaced(
"-statistic NonPeak");
2952 (void) CLISimpleOperatorImage(cli_wand,
"-statistic",
"NonPeak",arg1,exception);
2955 parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1);
2957 CLIWandExceptArgBreak(OptionError,
"UnrecognizedNoiseType",
2960 value=GetImageOption(_image_info,
"attenuate");
2961 if (value != (
const char *) NULL)
2962 attenuate=StringToDouble(value,(
char **) NULL);
2963 new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate,
2967 if (LocaleCompare(
"normalize",option+1) == 0)
2969 (void) NormalizeImage(_image,_exception);
2972 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2976 if (LocaleCompare(
"opaque",option+1) == 0)
2981 (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
2982 (void) OpaquePaintImage(_image,&target,&_draw_info->fill,IsPlusOp,
2986 if (LocaleCompare(
"ordered-dither",option+1) == 0)
2988 (void) OrderedDitherImage(_image,arg1,_exception);
2991 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
2995 if (LocaleCompare(
"paint",option+1) == 0)
2997 flags=ParseGeometry(arg1,&geometry_info);
2998 if ((flags & (RhoValue|SigmaValue)) == 0)
2999 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3000 new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma,
3004 if (LocaleCompare(
"perceptible",option+1) == 0)
3006 (void) PerceptibleImage(_image,StringToDouble(arg1,(
char **) NULL),
3010 if (LocaleCompare(
"polaroid",option+1) == 0)
3022 random_info=AcquireRandomInfo();
3023 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
3024 random_info=DestroyRandomInfo(random_info);
3027 flags=ParseGeometry(arg1,&geometry_info);
3028 if ((flags & RhoValue) == 0)
3029 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3030 angle=geometry_info.rho;
3032 caption=GetImageProperty(_image,
"caption",_exception);
3033 new_image=PolaroidImage(_image,_draw_info,caption,angle,
3034 _image->interpolate,_exception);
3037 if (LocaleCompare(
"posterize",option+1) == 0)
3039 flags=ParseGeometry(arg1,&geometry_info);
3040 if ((flags & RhoValue) == 0)
3041 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3042 (void) PosterizeImage(_image,(
size_t) geometry_info.rho,
3043 _quantize_info->dither_method,_exception);
3046 if (LocaleCompare(
"preview",option+1) == 0)
3052 parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1);
3054 CLIWandExceptArgBreak(OptionError,
"UnrecognizedPreviewType",
3056 new_image=PreviewImage(_image,(PreviewType)parse,_exception);
3059 if (LocaleCompare(
"profile",option+1) == 0)
3076 (void) ProfileImage(_image,arg1,(
const unsigned char *)
3081 profile_info=CloneImageInfo(_image_info);
3082 profile=GetImageProfile(_image,
"iptc");
3083 if (profile != (
const StringInfo *) NULL)
3084 profile_info->profile=(
void *) CloneStringInfo(profile);
3085 profile_image=GetImageCache(profile_info,arg1,_exception);
3086 profile_info=DestroyImageInfo(profile_info);
3087 if (profile_image == (Image *) NULL)
3092 profile_info=CloneImageInfo(_image_info);
3093 (void) CopyMagickString(profile_info->filename,arg1,
3095 new_profile=FileToStringInfo(profile_info->filename,~0UL,
3097 if (new_profile != (StringInfo *) NULL)
3099 (void) SetImageInfo(profile_info,0,_exception);
3100 (void) ProfileImage(_image,profile_info->magick,
3101 GetStringInfoDatum(new_profile),(size_t)
3102 GetStringInfoLength(new_profile),_exception);
3103 new_profile=DestroyStringInfo(new_profile);
3105 profile_info=DestroyImageInfo(profile_info);
3108 ResetImageProfileIterator(profile_image);
3109 name=GetNextImageProfile(profile_image);
3110 while (name != (
const char *) NULL)
3112 profile=GetImageProfile(profile_image,name);
3113 if (profile != (
const StringInfo *) NULL)
3114 (void) ProfileImage(_image,name,GetStringInfoDatum(profile),
3115 (size_t) GetStringInfoLength(profile),_exception);
3116 name=GetNextImageProfile(profile_image);
3118 profile_image=DestroyImage(profile_image);
3121 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3125 if (LocaleCompare(
"raise",option+1) == 0)
3127 if (IsGeometry(arg1) == MagickFalse)
3128 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3129 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3130 (void) RaiseImage(_image,&geometry,IsNormalOp,_exception);
3133 if (LocaleCompare(
"random-threshold",option+1) == 0)
3139 if (IsGeometry(arg1) == MagickFalse)
3140 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3142 max_threshold=(double) QuantumRange;
3143 flags=ParseGeometry(arg1,&geometry_info);
3144 min_threshold=geometry_info.rho;
3145 max_threshold=geometry_info.sigma;
3146 if ((flags & SigmaValue) == 0)
3147 max_threshold=min_threshold;
3148 if (arg1 == (
char *) NULL)
3150 if (strchr(arg1,
'%') != (
char *) NULL)
3152 max_threshold*=(0.01*(double) QuantumRange);
3153 min_threshold*=(0.01*(double) QuantumRange);
3155 (void) RandomThresholdImage(_image,min_threshold,max_threshold,
3159 if (LocaleCompare(
"range-threshold",option+1) == 0)
3164 if (IsGeometry(arg1) == MagickFalse)
3165 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3166 flags=ParseGeometry(arg1,&geometry_info);
3167 if ((flags & SigmaValue) == 0)
3168 geometry_info.sigma=geometry_info.rho;
3169 if ((flags & XiValue) == 0)
3170 geometry_info.xi=geometry_info.sigma;
3171 if ((flags & PsiValue) == 0)
3172 geometry_info.psi=geometry_info.xi;
3173 if (strchr(arg1,
'%') != (
char *) NULL)
3175 geometry_info.rho*=(0.01*(double) QuantumRange);
3176 geometry_info.sigma*=(0.01*(double) QuantumRange);
3177 geometry_info.xi*=(0.01*(double) QuantumRange);
3178 geometry_info.psi*=(0.01*(double) QuantumRange);
3180 (void) RangeThresholdImage(_image,geometry_info.rho,
3181 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3184 if (LocaleCompare(
"read-mask",option+1) == 0)
3192 (void) SetImageMask(_image,ReadPixelMask,(
const Image *) NULL,
3197 mask=GetImageCache(_image_info,arg1,_exception);
3198 if (mask == (Image *) NULL)
3200 (void) SetImageMask(_image,ReadPixelMask,mask,_exception);
3201 mask=DestroyImage(mask);
3204 if (LocaleCompare(
"recolor",option+1) == 0)
3206 CLIWandWarnReplaced(
"-color-matrix");
3207 (void) CLISimpleOperatorImage(cli_wand,
"-color-matrix",arg1,NULL,
3210 if (LocaleCompare(
"region",option+1) == 0)
3214 (void) SetImageRegionMask(_image,WritePixelMask,
3215 (
const RectangleInfo *) NULL,_exception);
3218 if (IsGeometry(arg1) == MagickFalse)
3219 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3220 (void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
3221 (void) SetImageRegionMask(_image,WritePixelMask,&geometry,_exception);
3224 if (LocaleCompare(
"remap",option+1) == 0)
3230 remap_image=GetImageCache(_image_info,arg1,_exception);
3231 if (remap_image == (Image *) NULL)
3233 (void) RemapImage(_quantize_info,_image,remap_image,_exception);
3234 remap_image=DestroyImage(remap_image);
3237 if (LocaleCompare(
"repage",option+1) == 0)
3241 if (IsGeometry(arg1) == MagickFalse)
3242 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,
3244 (void) ResetImagePage(_image,arg1);
3247 (
void) ParseAbsoluteGeometry(
"0x0+0+0",&_image->page);
3250 if (LocaleCompare(
"resample",option+1) == 0)
3253 flags=ParseGeometry(arg1,&geometry_info);
3254 if ((flags & (RhoValue|SigmaValue)) == 0)
3255 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3256 if ((flags & SigmaValue) == 0)
3257 geometry_info.sigma=geometry_info.rho;
3258 new_image=ResampleImage(_image,geometry_info.rho,
3259 geometry_info.sigma,_image->filter,_exception);
3262 if (LocaleCompare(
"reshape",option+1) == 0)
3264 if (IsGeometry(arg1) == MagickFalse)
3265 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3266 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3267 (void) ReshapePixelCache(_image,geometry.width,geometry.height,
3271 if (LocaleCompare(
"resize",option+1) == 0)
3273 if (IsGeometry(arg1) == MagickFalse)
3274 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3275 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3276 new_image=ResizeImage(_image,geometry.width,geometry.height,
3277 _image->filter,_exception);
3280 if (LocaleCompare(
"roll",option+1) == 0)
3282 if (IsGeometry(arg1) == MagickFalse)
3283 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3284 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3285 if ((flags & PercentValue) != 0)
3287 geometry.x*=(double) _image->columns/100.0;
3288 geometry.y*=(double) _image->rows/100.0;
3290 new_image=RollImage(_image,geometry.x,geometry.y,_exception);
3293 if (LocaleCompare(
"rotate",option+1) == 0)
3295 flags=ParseGeometry(arg1,&geometry_info);
3296 if ((flags & RhoValue) == 0)
3297 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3298 if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows))
3300 if ((flags & LessValue) != 0 && (_image->columns >= _image->rows))
3302 new_image=RotateImage(_image,geometry_info.rho,_exception);
3305 if (LocaleCompare(
"rotational-blur",option+1) == 0)
3307 flags=ParseGeometry(arg1,&geometry_info);
3308 if ((flags & RhoValue) == 0)
3309 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3310 new_image=RotationalBlurImage(_image,geometry_info.rho,_exception);
3313 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3317 if (LocaleCompare(
"sample",option+1) == 0)
3320 if (IsGeometry(arg1) == MagickFalse)
3321 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3322 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3323 new_image=SampleImage(_image,geometry.width,geometry.height,
3327 if (LocaleCompare(
"scale",option+1) == 0)
3330 if (IsGeometry(arg1) == MagickFalse)
3331 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3332 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3333 new_image=ScaleImage(_image,geometry.width,geometry.height,
3337 if (LocaleCompare(
"segment",option+1) == 0)
3339 flags=ParseGeometry(arg1,&geometry_info);
3340 if ((flags & (RhoValue|SigmaValue)) == 0)
3341 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3342 if ((flags & SigmaValue) == 0)
3343 geometry_info.sigma=1.0;
3344 (void) SegmentImage(_image,_image->colorspace,
3345 _image_info->verbose,geometry_info.rho,geometry_info.sigma,
3349 if (LocaleCompare(
"selective-blur",option+1) == 0)
3351 flags=ParseGeometry(arg1,&geometry_info);
3352 if ((flags & (RhoValue|SigmaValue)) == 0)
3353 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3354 if ((flags & SigmaValue) == 0)
3355 geometry_info.sigma=1.0;
3356 if ((flags & PercentValue) != 0)
3357 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
3358 new_image=SelectiveBlurImage(_image,geometry_info.rho,
3359 geometry_info.sigma,geometry_info.xi,_exception);
3362 if (LocaleCompare(
"separate",option+1) == 0)
3366 new_image=SeparateImages(_image,_exception);
3369 if (LocaleCompare(
"sepia-tone",option+1) == 0)
3371 if (IsGeometry(arg1) == MagickFalse)
3372 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3373 new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1,
3374 (
double) QuantumRange+1.0),_exception);
3377 if (LocaleCompare(
"shade",option+1) == 0)
3379 flags=ParseGeometry(arg1,&geometry_info);
3380 if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0))
3381 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3382 new_image=ShadeImage(_image,IsNormalOp,geometry_info.rho,
3383 geometry_info.sigma,_exception);
3386 if (LocaleCompare(
"shadow",option+1) == 0)
3388 flags=ParseGeometry(arg1,&geometry_info);
3389 if ((flags & (RhoValue|SigmaValue)) == 0)
3390 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3391 if ((flags & SigmaValue) == 0)
3392 geometry_info.sigma=1.0;
3393 if ((flags & XiValue) == 0)
3394 geometry_info.xi=4.0;
3395 if ((flags & PsiValue) == 0)
3396 geometry_info.psi=4.0;
3397 new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma,
3398 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3399 ceil(geometry_info.psi-0.5),_exception);
3402 if (LocaleCompare(
"sharpen",option+1) == 0)
3404 flags=ParseGeometry(arg1,&geometry_info);
3405 if ((flags & (RhoValue|SigmaValue)) == 0)
3406 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3407 if ((flags & SigmaValue) == 0)
3408 geometry_info.sigma=1.0;
3409 if ((flags & XiValue) == 0)
3410 geometry_info.xi=0.0;
3411 new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma,
3415 if (LocaleCompare(
"shave",option+1) == 0)
3417 if (IsGeometry(arg1) == MagickFalse)
3418 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3419 flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
3420 new_image=ShaveImage(_image,&geometry,_exception);
3423 if (LocaleCompare(
"shear",option+1) == 0)
3425 flags=ParseGeometry(arg1,&geometry_info);
3426 if ((flags & RhoValue) == 0)
3427 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3428 if ((flags & SigmaValue) == 0)
3429 geometry_info.sigma=geometry_info.rho;
3430 new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma,
3434 if (LocaleCompare(
"sigmoidal-contrast",option+1) == 0)
3436 flags=ParseGeometry(arg1,&geometry_info);
3437 if ((flags & RhoValue) == 0)
3438 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3439 if ((flags & SigmaValue) == 0)
3440 geometry_info.sigma=(double) QuantumRange/2.0;
3441 if ((flags & PercentValue) != 0)
3442 geometry_info.sigma=(
double) QuantumRange*geometry_info.sigma/
3444 (void) SigmoidalContrastImage(_image,IsNormalOp,geometry_info.rho,
3445 geometry_info.sigma,_exception);
3448 if (LocaleCompare(
"sketch",option+1) == 0)
3450 flags=ParseGeometry(arg1,&geometry_info);
3451 if ((flags & (RhoValue|SigmaValue)) == 0)
3452 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3453 if ((flags & SigmaValue) == 0)
3454 geometry_info.sigma=1.0;
3455 new_image=SketchImage(_image,geometry_info.rho,
3456 geometry_info.sigma,geometry_info.xi,_exception);
3459 if (LocaleCompare(
"solarize",option+1) == 0)
3461 if (IsGeometry(arg1) == MagickFalse)
3462 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3463 (void) SolarizeImage(_image,StringToDoubleInterval(arg1,(
double)
3464 QuantumRange+1.0),_exception);
3467 if (LocaleCompare(
"sort-pixels",option+1) == 0)
3469 (void) SortImagePixels(_image,_exception);
3472 if (LocaleCompare(
"sparse-color",option+1) == 0)
3474 parse=ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1);
3476 CLIWandExceptArgBreak(OptionError,
"UnrecognizedSparseColorMethod",
3478 new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2,
3482 if (LocaleCompare(
"splice",option+1) == 0)
3484 if (IsGeometry(arg1) == MagickFalse)
3485 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3486 flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
3487 new_image=SpliceImage(_image,&geometry,_exception);
3490 if (LocaleCompare(
"spread",option+1) == 0)
3492 flags=ParseGeometry(arg1,&geometry_info);
3493 if ((flags & RhoValue) == 0)
3494 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
3495 new_image=SpreadImage(_image,_image->interpolate,geometry_info.rho,
3499 if (LocaleCompare(
"statistic",option+1) == 0)
3501 parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1);
3503 CLIWandExceptArgBreak(OptionError,
"UnrecognizedStatisticType",
3505 flags=ParseGeometry(arg2,&geometry_info);
3506 if ((flags & RhoValue) == 0)
3507 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg2);
3508 if ((flags & SigmaValue) == 0)
3509 geometry_info.sigma=geometry_info.rho;
3510 new_image=StatisticImage(_image,(StatisticType)parse,
3511 (
size_t) geometry_info.rho,(
size_t) geometry_info.sigma,
3515 if (LocaleCompare(
"strip",option+1) == 0)
3517 (void) StripImage(_image,_exception);
3520 if (LocaleCompare(
"swirl",option+1) == 0)
3522 flags=ParseGeometry(arg1,&geometry_info);
3523 if ((flags & RhoValue) == 0)
3524 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3525 new_image=SwirlImage(_image,geometry_info.rho,
3526 _image->interpolate,_exception);
3529 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3533 if (LocaleCompare(
"threshold",option+1) == 0)
3538 threshold=(double) QuantumRange/2;
3540 if (IsGeometry(arg1) == MagickFalse)
3541 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3542 threshold=StringToDoubleInterval(arg1,(
double) QuantumRange+1.0);
3544 (void) BilevelImage(_image,threshold,_exception);
3547 if (LocaleCompare(
"thumbnail",option+1) == 0)
3549 if (IsGeometry(arg1) == MagickFalse)
3550 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3551 (void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
3552 new_image=ThumbnailImage(_image,geometry.width,geometry.height,
3556 if (LocaleCompare(
"tint",option+1) == 0)
3558 if (IsGeometry(arg1) == MagickFalse)
3559 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3560 new_image=TintImage(_image,arg1,&_draw_info->fill,_exception);
3563 if (LocaleCompare(
"transform",option+1) == 0)
3565 CLIWandWarnReplaced(
"+distort AffineProjection");
3566 new_image=AffineTransformImage(_image,&_draw_info->affine,_exception);
3569 if (LocaleCompare(
"transparent",option+1) == 0)
3574 (void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
3575 (void) TransparentPaintImage(_image,&target,(Quantum)
3576 TransparentAlpha,IsPlusOp,_exception);
3579 if (LocaleCompare(
"transpose",option+1) == 0)
3581 new_image=TransposeImage(_image,_exception);
3584 if (LocaleCompare(
"transverse",option+1) == 0)
3586 new_image=TransverseImage(_image,_exception);
3589 if (LocaleCompare(
"trim",option+1) == 0)
3591 new_image=TrimImage(_image,_exception);
3594 if (LocaleCompare(
"type",option+1) == 0)
3597 (void) SetImageType(_image,_image_info->type,_exception);
3600 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3604 if (LocaleCompare(
"unique",option+1) == 0)
3611 (void) DeleteImageArtifact(_image,
"identify:unique-colors");
3614 (void) SetImageArtifact(_image,
"identify:unique-colors",
"true");
3615 (void) SetImageArtifact(_image,
"verbose",
"true");
3618 if (LocaleCompare(
"unique-colors",option+1) == 0)
3620 new_image=UniqueImageColors(_image,_exception);
3623 if (LocaleCompare(
"unsharp",option+1) == 0)
3625 flags=ParseGeometry(arg1,&geometry_info);
3626 if ((flags & (RhoValue|SigmaValue)) == 0)
3627 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3628 if ((flags & SigmaValue) == 0)
3629 geometry_info.sigma=1.0;
3630 if ((flags & XiValue) == 0)
3631 geometry_info.xi=1.0;
3632 if ((flags & PsiValue) == 0)
3633 geometry_info.psi=0.05;
3634 new_image=UnsharpMaskImage(_image,geometry_info.rho,
3635 geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception);
3638 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3642 if (LocaleCompare(
"verbose",option+1) == 0)
3648 (void) SetImageArtifact(_image,option+1,IfNormalOp ?
"true" :
3652 if (LocaleCompare(
"vignette",option+1) == 0)
3654 flags=ParseGeometry(arg1,&geometry_info);
3655 if ((flags & (RhoValue|SigmaValue)) == 0)
3656 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3657 if ((flags & SigmaValue) == 0)
3658 geometry_info.sigma=1.0;
3659 if ((flags & XiValue) == 0)
3660 geometry_info.xi=0.1*_image->columns;
3661 if ((flags & PsiValue) == 0)
3662 geometry_info.psi=0.1*_image->rows;
3663 if ((flags & PercentValue) != 0)
3665 geometry_info.xi*=(double) _image->columns/100.0;
3666 geometry_info.psi*=(double) _image->rows/100.0;
3668 new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma,
3669 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3670 ceil(geometry_info.psi-0.5),_exception);
3673 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3677 if (LocaleCompare(
"wave",option+1) == 0)
3679 flags=ParseGeometry(arg1,&geometry_info);
3680 if ((flags & (RhoValue|SigmaValue)) == 0)
3681 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3682 if ((flags & SigmaValue) == 0)
3683 geometry_info.sigma=1.0;
3684 new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma,
3685 _image->interpolate,_exception);
3688 if (LocaleCompare(
"wavelet-denoise",option+1) == 0)
3690 flags=ParseGeometry(arg1,&geometry_info);
3691 if ((flags & RhoValue) == 0)
3692 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3693 if ((flags & PercentValue) != 0)
3695 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3696 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3699 if ((flags & SigmaValue) == 0)
3700 geometry_info.sigma=0.0;
3701 new_image=WaveletDenoiseImage(_image,geometry_info.rho,
3702 geometry_info.sigma,_exception);
3705 if (LocaleCompare(
"white-balance",option+1) == 0)
3707 (void) WhiteBalanceImage(_image,_exception);
3710 if (LocaleCompare(
"white-threshold",option+1) == 0)
3712 if (IsGeometry(arg1) == MagickFalse)
3713 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
3714 (void) WhiteThresholdImage(_image,arg1,_exception);
3717 if (LocaleCompare(
"write-mask",option+1) == 0)
3725 (void) SetImageMask(_image,WritePixelMask,(
const Image *) NULL,
3730 mask=GetImageCache(_image_info,arg1,_exception);
3731 if (mask == (Image *) NULL)
3733 (void) SetImageMask(_image,WritePixelMask,mask,_exception);
3734 mask=DestroyImage(mask);
3737 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3740 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3744 arg1=DestroyString((
char *)arg1);
3746 arg2=DestroyString((
char *)arg2);
3750 if (new_image != (Image *) NULL)
3751 ReplaceImageInListReturnLast(&_image,new_image);
3756#undef _quantize_info
3765static MagickBooleanType CLISimpleOperatorImages(
MagickCLI *cli_wand,
3766 const char *option,
const char *arg1,
const char *arg2,ExceptionInfo *exception)
3768#if !USE_WAND_METHODS
3775 assert(cli_wand->signature == MagickWandSignature);
3776 assert(cli_wand->wand.signature == MagickWandSignature);
3777 assert(cli_wand->wand.images != (Image *) NULL);
3779 if (cli_wand->wand.debug != MagickFalse)
3780 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
3781 "- Simple Operator: %s \"%s\" \"%s\"", option,arg1,arg2);
3783#if !USE_WAND_METHODS
3786 n=GetImageListLength(cli_wand->wand.images);
3787 cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
3790 CLISimpleOperatorImage(cli_wand, option, arg1, arg2,exception);
3791 if ( cli_wand->wand.images->next == (Image *) NULL )
3793 cli_wand->wand.images=cli_wand->wand.images->next;
3796 cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
3798 MagickResetIterator(&cli_wand->wand);
3799 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
3800 (void) CLISimpleOperatorImage(cli_wand, option, arg1, arg2,exception);
3801 MagickResetIterator(&cli_wand->wand);
3837static MagickBooleanType CLIListOperatorImages(
MagickCLI *cli_wand,
3838 const char *option,
const char *arg1n,
const char *arg2n)
3853#define _image_info (cli_wand->wand.image_info)
3854#define _images (cli_wand->wand.images)
3855#define _exception (cli_wand->wand.exception)
3856#define _draw_info (cli_wand->draw_info)
3857#define _quantize_info (cli_wand->quantize_info)
3858#define _process_flags (cli_wand->process_flags)
3859#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
3860#define IfNormalOp (*option=='-')
3861#define IfPlusOp (*option!='-')
3862#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse
3865 assert(cli_wand->signature == MagickWandSignature);
3866 assert(cli_wand->wand.signature == MagickWandSignature);
3867 assert(_images != (Image *) NULL);
3869 if (cli_wand->wand.debug != MagickFalse)
3870 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
3871 "- List Operator: %s \"%s\" \"%s\"", option,
3872 arg1n == (
const char *) NULL ?
"null" : arg1n,
3873 arg2n == (const char *) NULL ?
"null" : arg2n);
3879 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
3880 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
3881 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
3883 if (arg1n != (
char *) NULL) {
3884 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
3885 if (arg1 == (
char *) NULL) {
3886 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
3890 if (arg2n != (
char *) NULL) {
3891 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
3892 if (arg2 == (
char *) NULL) {
3893 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
3898#undef _process_flags
3902 new_images=NewImageList();
3904 switch (*(option+1))
3908 if (LocaleCompare(
"append",option+1) == 0)
3910 new_images=AppendImages(_images,IsNormalOp,_exception);
3913 if (LocaleCompare(
"average",option+1) == 0)
3915 CLIWandWarnReplaced(
"-evaluate-sequence Mean");
3916 (void) CLIListOperatorImages(cli_wand,
"-evaluate-sequence",
"Mean",
3920 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
3924 if (LocaleCompare(
"channel-fx",option+1) == 0)
3926 new_images=ChannelFxImage(_images,arg1,_exception);
3929 if (LocaleCompare(
"clut",option+1) == 0)
3938 new_images=RemoveFirstImageFromList(&_images);
3939 clut_image=RemoveFirstImageFromList(&_images);
3941 if (clut_image == (Image *) NULL)
3943 (void) ThrowMagickException(_exception,GetMagickModule(),
3944 OptionError,
"ImageSequenceRequired",
"`%s'",option);
3945 new_images=DestroyImage(new_images);
3949 (void) ClutImage(new_images,clut_image,new_images->interpolate,
3951 clut_image=DestroyImage(clut_image);
3954 if (LocaleCompare(
"coalesce",option+1) == 0)
3956 new_images=CoalesceImages(_images,_exception);
3959 if (LocaleCompare(
"combine",option+1) == 0)
3961 parse=(ssize_t) _images->colorspace;
3962 if (_images->number_channels < GetImageListLength(_images))
3963 parse=sRGBColorspace;
3965 parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);
3967 CLIWandExceptArgBreak(OptionError,
"UnrecognizedColorspace",option,
3969 new_images=CombineImages(_images,(ColorspaceType) parse,_exception);
3972 if (LocaleCompare(
"compare",option+1) == 0)
3988 image=RemoveFirstImageFromList(&_images);
3989 reconstruct_image=RemoveFirstImageFromList(&_images);
3991 if (reconstruct_image == (Image *) NULL)
3993 (void) ThrowMagickException(_exception,GetMagickModule(),
3994 OptionError,
"ImageSequenceRequired",
"`%s'",option);
3995 image=DestroyImage(image);
3999 metric=UndefinedErrorMetric;
4000 option=GetImageOption(_image_info,
"metric");
4001 if (option != (
const char *) NULL)
4002 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
4003 MagickFalse,option);
4004 new_images=CompareImages(image,reconstruct_image,metric,&distortion,
4007 reconstruct_image=DestroyImage(reconstruct_image);
4008 image=DestroyImage(image);
4011 if (LocaleCompare(
"complex",option+1) == 0)
4013 parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1);
4015 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
4017 new_images=ComplexImages(_images,(ComplexOperator) parse,_exception);
4020 if (LocaleCompare(
"composite",option+1) == 0)
4039 value=GetImageOption(_image_info,
"compose");
4040 if (value == (
const char *) NULL)
4041 compose=OverCompositeOp;
4043 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
4047 clip_to_self=GetCompositeClipToSelf(compose);
4048 value=GetImageOption(_image_info,
"compose:clip-to-self");
4049 if (value != (
const char *) NULL)
4050 clip_to_self=IsStringTrue(value);
4051 value=GetImageOption(_image_info,
"compose:outside-overlay");
4052 if (value != (
const char *) NULL)
4053 clip_to_self=IsStringFalse(value);
4055 new_images=RemoveFirstImageFromList(&_images);
4056 source_image=RemoveFirstImageFromList(&_images);
4057 if (source_image == (Image *) NULL)
4059 (void) ThrowMagickException(_exception,GetMagickModule(),
4060 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4061 new_images=DestroyImage(new_images);
4067 if (source_image->geometry != (
char *) NULL)
4072 (void) ParseRegionGeometry(source_image,source_image->geometry,
4073 &resize_geometry,_exception);
4074 if ((source_image->columns != resize_geometry.width) ||
4075 (source_image->rows != resize_geometry.height))
4080 resize_image=ResizeImage(source_image,resize_geometry.width,
4081 resize_geometry.height,source_image->filter,_exception);
4082 if (resize_image != (Image *) NULL)
4084 source_image=DestroyImage(source_image);
4085 source_image=resize_image;
4089 SetGeometry(source_image,&geometry);
4090 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
4091 GravityAdjustGeometry(new_images->columns,new_images->rows,
4092 new_images->gravity, &geometry);
4093 mask_image=RemoveFirstImageFromList(&_images);
4094 if (mask_image == (Image *) NULL)
4095 status&=(MagickStatusType) CompositeImage(new_images,source_image,
4096 compose,clip_to_self,geometry.x,geometry.y,_exception);
4102 canvas_image=CloneImage(new_images,0,0,MagickTrue,_exception);
4103 if (canvas_image == (Image *) NULL)
4107 case BlendCompositeOp:
4109 status&=(MagickStatusType) CompositeImage(new_images,
4110 source_image,compose,clip_to_self,geometry.x,geometry.y,
4112 status&=(MagickStatusType) CompositeImage(new_images,
4113 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4116 case DisplaceCompositeOp:
4117 case DistortCompositeOp:
4119 status&=(MagickStatusType) CompositeImage(source_image,
4120 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,_exception);
4121 (void) SetImageColorspace(source_image,sRGBColorspace,
4123 status&=(MagickStatusType) CompositeImage(new_images,
4124 source_image,compose,clip_to_self,geometry.x,geometry.y,
4128 case SaliencyBlendCompositeOp:
4129 case SeamlessBlendCompositeOp:
4131 status&=(MagickStatusType) CompositeImage(source_image,
4132 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4133 status&=(MagickStatusType) CompositeImage(new_images,
4134 source_image,compose,clip_to_self,geometry.x,geometry.y,
4143 clone_image=CloneImage(new_images,0,0,MagickTrue,_exception);
4144 if (clone_image == (Image *) NULL)
4146 status&=(MagickStatusType) CompositeImage(new_images,
4147 source_image,compose,clip_to_self,geometry.x,geometry.y,
4149 status&=(MagickStatusType) CompositeImage(new_images,
4150 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,_exception);
4151 status&=(MagickStatusType) CompositeImage(clone_image,
4152 new_images,OverCompositeOp,clip_to_self,0,0,_exception);
4153 new_images=DestroyImageList(new_images);
4154 new_images=clone_image;
4160 case DisplaceCompositeOp:
4161 case DistortCompositeOp:
4163 status&=(MagickStatusType) CompositeImage(canvas_image,
4164 new_images,CopyCompositeOp,clip_to_self,0,0,_exception);
4169 status&=(MagickStatusType) CompositeImage(canvas_image,
4170 new_images,OverCompositeOp,clip_to_self,0,0,_exception);
4174 new_images=DestroyImageList(new_images);
4175 new_images=canvas_image;
4176 mask_image=DestroyImage(mask_image);
4178 source_image=DestroyImage(source_image);
4181 if (LocaleCompare(
"copy",option+1) == 0)
4195 if (IsGeometry(arg1) == MagickFalse)
4196 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4197 if (IsGeometry(arg2) == MagickFalse)
4198 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4199 (void) ParsePageGeometry(_images,arg2,&geometry,_exception);
4200 offset.x=geometry.x;
4201 offset.y=geometry.y;
4202 source_image=_images;
4203 if (source_image->next != (Image *) NULL)
4204 source_image=source_image->next;
4205 (void) ParsePageGeometry(source_image,arg1,&geometry,_exception);
4206 (void) CopyImagePixels(_images,source_image,&geometry,&offset,
4210 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4214 if (LocaleCompare(
"deconstruct",option+1) == 0)
4216 CLIWandWarnReplaced(
"-layers CompareAny");
4217 (void) CLIListOperatorImages(cli_wand,
"-layers",
"CompareAny",NULL);
4220 if (LocaleCompare(
"delete",option+1) == 0)
4224 DeleteImages(&_images,
"-1",_exception);
4227 if (LocaleNCompare(arg1,
"registry:",9) == 0)
4229 (void) DeleteImageRegistry(arg1+9);
4232 if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
4233 CLIWandExceptionBreak(OptionError,
"InvalidArgument",option);
4234 DeleteImages(&_images,arg1,_exception);
4237 if (LocaleCompare(
"duplicate",option+1) == 0)
4240 new_images=DuplicateImages(_images,1,
"-1",_exception);
4249 if (IsGeometry(arg1) == MagickFalse)
4250 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,
4252 number_duplicates=(size_t) StringToLong(arg1);
4253 if (arg1 == (
char *) NULL)
4256 if (p == (
const char *) NULL)
4257 new_images=DuplicateImages(_images,number_duplicates,
"-1",
4260 new_images=DuplicateImages(_images,number_duplicates,p+1,
4263 AppendImageToList(&_images, new_images);
4264 new_images=(Image *) NULL;
4267 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4271 if (LocaleCompare(
"evaluate-sequence",option+1) == 0)
4273 parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
4275 CLIWandExceptArgBreak(OptionError,
"UnrecognizedEvaluateOperator",
4277 new_images=EvaluateImages(_images,(MagickEvaluateOperator) parse,
4281 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4285 if (LocaleCompare(
"fft",option+1) == 0)
4287 new_images=ForwardFourierTransformImage(_images,IsNormalOp,
4291 if (LocaleCompare(
"flatten",option+1) == 0)
4294 (void) CLIListOperatorImages(cli_wand,
"-layers",option+1,NULL);
4297 if (LocaleCompare(
"fx",option+1) == 0)
4299 new_images=FxImage(_images,arg1,_exception);
4302 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4306 if (LocaleCompare(
"hald-clut",option+1) == 0)
4314 new_images=RemoveFirstImageFromList(&_images);
4315 hald_image=RemoveLastImageFromList(&_images);
4316 if (hald_image == (Image *) NULL)
4318 (void) ThrowMagickException(_exception,GetMagickModule(),
4319 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4320 new_images=DestroyImage(new_images);
4324 (void) HaldClutImage(new_images,hald_image,_exception);
4325 hald_image=DestroyImage(hald_image);
4328 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4332 if (LocaleCompare(
"ift",option+1) == 0)
4338 magnitude_image=RemoveFirstImageFromList(&_images);
4339 phase_image=RemoveFirstImageFromList(&_images);
4340 if (phase_image == (Image *) NULL)
4342 (void) ThrowMagickException(_exception,GetMagickModule(),
4343 OptionError,
"ImageSequenceRequired",
"`%s'",option);
4344 magnitude_image=DestroyImage(magnitude_image);
4348 new_images=InverseFourierTransformImage(magnitude_image,phase_image,
4349 IsNormalOp,_exception);
4350 magnitude_image=DestroyImage(magnitude_image);
4351 phase_image=DestroyImage(phase_image);
4354 if (LocaleCompare(
"insert",option+1) == 0)
4363 if (IfNormalOp && (IsGeometry(arg1) == MagickFalse))
4364 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4366 insert_image=RemoveLastImageFromList(&_images);
4368 index=(ssize_t) StringToLong(arg1);
4369 index_image=insert_image;
4371 PrependImageToList(&_images,insert_image);
4372 else if (index == (ssize_t) GetImageListLength(_images))
4373 AppendImageToList(&_images,insert_image);
4376 index_image=GetImageFromList(_images,index-1);
4377 if (index_image == (Image *) NULL)
4379 insert_image=DestroyImage(insert_image);
4380 CLIWandExceptArgBreak(OptionError,
"NoSuchImage",option,arg1);
4382 InsertImageInList(&index_image,insert_image);
4384 _images=GetFirstImageInList(index_image);
4387 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4391 if (LocaleCompare(
"layers",option+1) == 0)
4393 parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1);
4395 CLIWandExceptArgBreak(OptionError,
"UnrecognizedLayerMethod",
4397 switch ((LayerMethod) parse)
4401 new_images=CoalesceImages(_images,_exception);
4404 case CompareAnyLayer:
4405 case CompareClearLayer:
4406 case CompareOverlayLayer:
4409 new_images=CompareImagesLayers(_images,(LayerMethod) parse,
4416 case TrimBoundsLayer:
4418 new_images=MergeImageLayers(_images,(LayerMethod) parse,
4424 new_images=DisposeImages(_images,_exception);
4427 case OptimizeImageLayer:
4429 new_images=OptimizeImageLayers(_images,_exception);
4432 case OptimizePlusLayer:
4434 new_images=OptimizePlusImageLayers(_images,_exception);
4437 case OptimizeTransLayer:
4439 OptimizeImageTransparency(_images,_exception);
4442 case RemoveDupsLayer:
4444 RemoveDuplicateLayers(&_images,_exception);
4447 case RemoveZeroLayer:
4449 RemoveZeroDelayLayers(&_images,_exception);
4454 new_images=CoalesceImages(_images,_exception);
4455 if (new_images == (Image *) NULL)
4457 _images=DestroyImageList(_images);
4458 _images=OptimizeImageLayers(new_images,_exception);
4459 if (_images == (Image *) NULL)
4461 new_images=DestroyImageList(new_images);
4462 OptimizeImageTransparency(_images,_exception);
4463 (void) RemapImages(_quantize_info,_images,(Image *) NULL,
4467 case CompositeLayer:
4481 value=GetImageOption(_image_info,
"compose");
4482 compose=OverCompositeOp;
4483 if (value != (
const char *) NULL)
4484 compose=(CompositeOperator) ParseCommandOption(
4485 MagickComposeOptions,MagickFalse,value);
4489 while (source != (Image *) NULL)
4491 source=GetNextImageInList(source);
4492 if ((source != (Image *) NULL) &&
4493 (LocaleCompare(source->magick,
"NULL") == 0))
4496 if (source != (Image *) NULL)
4498 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
4499 (GetNextImageInList(source) == (Image *) NULL))
4500 source=(Image *) NULL;
4503 source=SplitImageList(source->previous);
4504 DeleteImageFromList(&source);
4507 if (source == (Image *) NULL)
4509 (void) ThrowMagickException(_exception,GetMagickModule(),
4510 OptionError,
"MissingNullSeparator",
"layers Composite");
4514 SetGeometry(_images,&geometry);
4515 (void) ParseAbsoluteGeometry(_images->geometry,&geometry);
4516 geometry.width=source->page.width != 0 ?
4517 source->page.width : source->columns;
4518 geometry.height=source->page.height != 0 ?
4519 source->page.height : source->rows;
4520 GravityAdjustGeometry(_images->page.width != 0 ?
4521 _images->page.width : _images->columns,
4522 _images->page.height != 0 ? _images->page.height :
4523 _images->rows,_images->gravity,&geometry);
4526 CompositeLayers(_images,compose,source,geometry.x,geometry.y,
4528 source=DestroyImageList(source);
4534 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4538 if (LocaleCompare(
"map",option+1) == 0)
4540 CLIWandWarnReplaced(
"+remap");
4541 (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);
4544 if (LocaleCompare(
"metric",option+1) == 0)
4546 (void) SetImageOption(_image_info,option+1,arg1);
4549 if (LocaleCompare(
"morph",option+1) == 0)
4554 if (IsGeometry(arg1) == MagickFalse)
4555 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4556 morph_image=MorphImages(_images,StringToUnsignedLong(arg1),
4558 if (morph_image == (Image *) NULL)
4560 _images=DestroyImageList(_images);
4561 _images=morph_image;
4564 if (LocaleCompare(
"mosaic",option+1) == 0)
4567 (void) CLIListOperatorImages(cli_wand,
"-layers",option+1,NULL);
4570 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4574 if (LocaleCompare(
"poly",option+1) == 0)
4583 args = StringToArrayOfDoubles(arg1,&count,_exception);
4584 if (args == (
double *) NULL )
4585 CLIWandExceptArgBreak(OptionError,
"InvalidNumberList",option,arg1);
4586 new_images=PolynomialImage(_images,(
size_t) (count >> 1),args,
4588 args=(
double *) RelinquishMagickMemory(args);
4591 if (LocaleCompare(
"process",option+1) == 0)
4601 arguments=StringToArgv(arg1,&number_arguments);
4602 if ((arguments == (
char **) NULL) || (number_arguments == 1))
4604 if (strchr(arguments[1],
'=') != (
char *) NULL)
4627 assert(arg1 != (
const char *) NULL);
4628 length=strlen(arg1);
4629 token=(
char *) NULL;
4630 if (~length >= (MagickPathExtent-1))
4631 token=(
char *) AcquireQuantumMemory(length+MagickPathExtent,
4633 if (token == (
char *) NULL)
4637 token_info=AcquireTokenInfo();
4638 tokenizer_status=Tokenizer(token_info,0,token,length,p,
"",
"=",
4639 "\"",
'\0',&breaker,&next,"e);
4640 token_info=DestroyTokenInfo(token_info);
4641 if (tokenizer_status == 0)
4647 (void) InvokeDynamicImageFilter(token,&_images,1,&argv,
4650 token=DestroyString(token);
4653 (void) SubstituteString(&arguments[1],
"-",
"");
4654 (void) InvokeDynamicImageFilter(arguments[1],&_images,
4655 number_arguments-2,(
const char **) arguments+2,_exception);
4656 for (j=0; j < number_arguments; j++)
4657 arguments[j]=DestroyString(arguments[j]);
4658 arguments=(
char **) RelinquishMagickMemory(arguments);
4661 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4665 if (LocaleCompare(
"remap",option+1) == 0)
4667 (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);
4670 if (LocaleCompare(
"reverse",option+1) == 0)
4672 ReverseImageList(&_images);
4675 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4679 if (LocaleCompare(
"smush",option+1) == 0)
4685 if (IsGeometry(arg1) == MagickFalse)
4686 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4687 offset=(ssize_t) StringToLong(arg1);
4688 new_images=SmushImages(_images,IsNormalOp,offset,_exception);
4691 if (LocaleCompare(
"subimage",option+1) == 0)
4709 base_image=GetImageFromList(_images,0);
4710 compare_image=GetImageFromList(_images,1);
4713 metric=UndefinedErrorMetric;
4714 value=GetImageOption(_image_info,
"metric");
4715 if (value != (
const char *) NULL)
4716 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
4719 new_images=SimilarityImage(base_image,compare_image,metric,0.0,
4720 &offset,&similarity,_exception);
4722 if (new_images != (Image *) NULL)
4724 (void) FormatImageProperty(new_images,
"subimage:similarity",
4725 "%.*g",GetMagickPrecision(),similarity);
4726 (void) FormatImageProperty(new_images,
"subimage:x",
"%+ld",(
long)
4728 (void) FormatImageProperty(new_images,
"subimage:y",
"%+ld",(
long)
4730 (void) FormatImageProperty(new_images,
"subimage:offset",
4731 "%lux%lu%+ld%+ld",(
unsigned long) offset.width,(
unsigned long)
4732 offset.height,(
long) offset.x,(long) offset.y);
4736 if (LocaleCompare(
"swap",option+1) == 0)
4757 flags=ParseGeometry(arg1,&geometry_info);
4758 if ((flags & RhoValue) == 0)
4759 CLIWandExceptArgBreak(OptionError,
"InvalidArgument",option,arg1);
4760 index=(ssize_t) geometry_info.rho;
4761 if ((flags & SigmaValue) != 0)
4762 swap_index=(ssize_t) geometry_info.sigma;
4764 p=GetImageFromList(_images,index);
4765 q=GetImageFromList(_images,swap_index);
4766 if ((p == (Image *) NULL) || (q == (Image *) NULL)) {
4768 CLIWandExceptArgBreak(OptionError,
"InvalidImageIndex",option,arg1)
4770 CLIWandExceptionBreak(OptionError,
"TwoOrMoreImagesRequired",option);
4773 CLIWandExceptArgBreak(OptionError,
"InvalidImageIndex",option,arg1);
4774 swap=CloneImage(p,0,0,MagickTrue,_exception);
4775 if (swap == (Image *) NULL)
4776 CLIWandExceptArgBreak(ResourceLimitError,
"MemoryAllocationFailed",
4777 option,GetExceptionMessage(errno));
4778 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));
4779 ReplaceImageInList(&q,swap);
4780 _images=GetFirstImageInList(q);
4783 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4786 CLIWandExceptionBreak(OptionError,
"UnrecognizedOption",option);
4791 arg1=DestroyString((
char *)arg1);
4793 arg2=DestroyString((
char *)arg2);
4796 if (new_images == (Image *) NULL)
4797 return(status == 0 ? MagickFalse : MagickTrue);
4798 _images=DestroyImageList(_images);
4799 _images=GetFirstImageInList(new_images);
4800 return(status == 0 ? MagickFalse : MagickTrue);
4806#undef _quantize_info
4848static void CLINoImageOperator(
MagickCLI *cli_wand,
4849 const char *option,
const char *arg1n,
const char *arg2n)
4855#define _image_info (cli_wand->wand.image_info)
4856#define _images (cli_wand->wand.images)
4857#define _exception (cli_wand->wand.exception)
4858#define _process_flags (cli_wand->process_flags)
4859#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
4860#define IfNormalOp (*option=='-')
4861#define IfPlusOp (*option!='-')
4864 assert(cli_wand->signature == MagickWandSignature);
4865 assert(cli_wand->wand.signature == MagickWandSignature);
4867 if (cli_wand->wand.debug != MagickFalse)
4868 (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
4869 "- NoImage Operator: %s \"%s\" \"%s\"", option,
4870 arg1n != (
char *) NULL ? arg1n :
"",
4871 arg2n != (char *) NULL ? arg2n :
"");
4877 if ( (((_process_flags & ProcessInterpretProperties) != 0 )
4878 || ((_option_type & AlwaysInterpretArgsFlag) != 0)
4879 ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
4881 if (arg1n != (
char *) NULL) {
4882 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
4883 if (arg1 == (
char *) NULL) {
4884 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
4888 if (arg2n != (
char *) NULL) {
4889 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
4890 if (arg2 == (
char *) NULL) {
4891 CLIWandException(OptionWarning,
"InterpretPropertyFailure",option);
4896#undef _process_flags
4903 if (LocaleCompare(
"noop",option+1) == 0)
4905 if (LocaleCompare(
"sans",option+1) == 0)
4907 if (LocaleCompare(
"sans0",option+1) == 0)
4909 if (LocaleCompare(
"sans1",option+1) == 0)
4911 if (LocaleCompare(
"sans2",option+1) == 0)
4916 if ( ( LocaleCompare(
"read",option+1) == 0 ) ||
4917 ( LocaleCompare(
"--",option) == 0 ) ) {
4940 argv = (
char **) &arg1;
4946 if (ExpandFilenames(&argc,&argv) == MagickFalse)
4947 CLIWandExceptArgBreak(ResourceLimitError,
"MemoryAllocationFailed",
4948 option,GetExceptionMessage(errno));
4951 for (i=0; i < (ssize_t) argc; i++) {
4954 if (_image_info->ping != MagickFalse)
4955 new_images=PingImages(_image_info,argv[i],_exception);
4957 new_images=ReadImages(_image_info,argv[i],_exception);
4958 AppendImageToList(&_images, new_images);
4959 argv[i]=DestroyString(argv[i]);
4961 argv=(
char **) RelinquishMagickMemory(argv);
4968 if (LocaleCompare(
"write",option+1) == 0) {
4971 key[MagickPathExtent];
4980 if ( _images == (Image *) NULL ) {
4981 if ( LocaleCompare(arg1,
"null:") == 0 )
4983 CLIWandExceptArgBreak(OptionError,
"NoImagesForWrite",option,arg1);
4986 (void) FormatLocaleString(key,MagickPathExtent,
"cache:%s",arg1);
4987 (void) DeleteImageRegistry(key);
4988 write_images=CloneImageList(_images,_exception);
4989 write_info=CloneImageInfo(_image_info);
4990 if (write_images != (Image *) NULL)
4991 (void) WriteImages(write_info,write_images,arg1,_exception);
4992 write_info=DestroyImageInfo(write_info);
4993 write_images=DestroyImageList(write_images);
4999 if (LocaleCompare(
"(",option) == 0) {
5008 node=cli_wand->image_list_stack;
5009 for ( ; node != (
CLIStack *) NULL; node=node->next)
5011 if ( size >= MAX_STACK_DEPTH )
5012 CLIWandExceptionBreak(OptionError,
"ParenthesisNestedTooDeeply",option);
5013 node=(
CLIStack *) AcquireMagickMemory(
sizeof(*node));
5015 CLIWandExceptionBreak(ResourceLimitFatalError,
5016 "MemoryAllocationFailed",option);
5017 node->data = (
void *)cli_wand->wand.images;
5018 node->next = cli_wand->image_list_stack;
5019 cli_wand->image_list_stack = node;
5020 cli_wand->wand.images = NewImageList();
5023 if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,
5024 "respect-parenthesis")) != MagickFalse)
5030 if (LocaleCompare(
"{",option) == 0) {
5039 node=cli_wand->image_info_stack;
5040 for ( ; node != (
CLIStack *) NULL; node=node->next)
5042 if ( size >= MAX_STACK_DEPTH )
5043 CLIWandExceptionBreak(OptionError,
"CurlyBracesNestedTooDeeply",option);
5044 node=(
CLIStack *) AcquireMagickMemory(
sizeof(*node));
5046 CLIWandExceptionBreak(ResourceLimitFatalError,
5047 "MemoryAllocationFailed",option);
5049 node->data = (
void *)cli_wand->wand.image_info;
5050 node->next = cli_wand->image_info_stack;
5052 cli_wand->image_info_stack = node;
5053 cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
5054 if (cli_wand->wand.image_info == (ImageInfo *) NULL) {
5055 CLIWandException(ResourceLimitFatalError,
"MemoryAllocationFailed",
5057 cli_wand->wand.image_info = (ImageInfo *)node->data;
5058 node = (
CLIStack *)RelinquishMagickMemory(node);
5064 if (LocaleCompare(
")",option) == 0) {
5069 node = (
CLIStack *)cli_wand->image_list_stack;
5071 CLIWandExceptionBreak(OptionError,
"UnbalancedParenthesis",option);
5072 cli_wand->image_list_stack = node->next;
5074 AppendImageToList((Image **)&node->data,cli_wand->wand.images);
5075 cli_wand->wand.images= (Image *)node->data;
5076 node = (
CLIStack *)RelinquishMagickMemory(node);
5079 node = cli_wand->image_info_stack;
5082 if (IsStringTrue(GetImageOption(
5083 cli_wand->wand.image_info,
"respect-parenthesis")) != MagickFalse)
5092 if (LocaleCompare(
"}",option) == 0) {
5097 node = (
CLIStack *)cli_wand->image_info_stack;
5099 CLIWandExceptionBreak(OptionError,
"UnbalancedCurlyBraces",option);
5100 cli_wand->image_info_stack = node->next;
5102 (void) DestroyImageInfo(cli_wand->wand.image_info);
5103 cli_wand->wand.image_info = (ImageInfo *)node->data;
5104 node = (
CLIStack *)RelinquishMagickMemory(node);
5106 GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
5107 cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
5108 cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
5112 if (LocaleCompare(
"print",option+1) == 0)
5114 (void) FormatLocaleFile(stdout,
"%s",arg1);
5117 if (LocaleCompare(
"set",option+1) == 0)
5126 StringInfo *profile = (StringInfo *) NULL;
5127 arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
5128 if (arg1 == (
char *) NULL)
5129 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
5132 if (LocaleNCompare(arg1,
"registry:",9) == 0)
5136 (void) DeleteImageRegistry(arg1+9);
5137 arg1=DestroyString((
char *)arg1);
5140 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5141 if (arg2 == (
char *) NULL) {
5142 arg1=DestroyString((
char *)arg1);
5143 CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",
5146 (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);
5147 arg1=DestroyString((
char *)arg1);
5148 arg2=DestroyString((
char *)arg2);
5151 if (LocaleNCompare(arg1,
"option:",7) == 0)
5154 if (_images != (Image *) NULL)
5156 MagickResetIterator(&cli_wand->wand);
5157 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
5158 (void) DeleteImageArtifact(_images,arg1+7);
5159 MagickResetIterator(&cli_wand->wand);
5166 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5167 if (arg2 == (
char *) NULL)
5168 CLIWandExceptionBreak(OptionWarning,
5169 "InterpretPropertyFailure",option);
5171 (void) SetImageOption(_image_info,arg1+7,arg2);
5172 arg1=DestroyString((
char *) arg1);
5173 arg2=DestroyString((
char *) arg2);
5176 if (LocaleCompare(arg1,
"profile") == 0)
5178 if (arg2 != (
char *) NULL)
5179 (void) CopyMagickString(_image_info->filename,arg2,
5181 (void) SetImageInfo(_image_info,1,_exception);
5182 if (LocaleCompare(_image_info->filename,
"-") != 0)
5183 profile=FileToStringInfo(_image_info->filename,~0UL,_exception);
5186 if ( _images == (Image *) NULL )
5187 CLIWandExceptArgBreak(OptionWarning,
"NoImageForProperty",option,arg1);
5189 MagickResetIterator(&cli_wand->wand);
5190 while (MagickNextImage(&cli_wand->wand) != MagickFalse)
5195 arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
5196 if (arg2 == (
char *) NULL)
5197 CLIWandExceptionBreak(OptionWarning,
5198 "InterpretPropertyFailure",option);
5200 if (LocaleNCompare(arg1,
"artifact:",9) == 0)
5201 (void) SetImageArtifact(_images,arg1+9,arg2);
5202 else if (LocaleNCompare(arg1,
"property:",9) == 0)
5203 (
void) SetImageProperty(_images,arg1+9,arg2,_exception);
5205 (
void) SetImageProperty(_images,arg1,arg2,_exception);
5206 if (profile != (StringInfo *) NULL)
5207 (void) SetImageProfile(_images,_image_info->magick,profile,_exception);
5208 arg2=DestroyString((
char *)arg2);
5210 if (profile != (StringInfo *) NULL)
5211 profile=DestroyStringInfo(profile);
5212 MagickResetIterator(&cli_wand->wand);
5213 arg1=DestroyString((
char *)arg1);
5216 if (LocaleCompare(
"clone",option+1) == 0) {
5221 arg1=AcquireString(
"-1");
5222 if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
5223 CLIWandExceptionBreak(OptionError,
"InvalidArgument",option);
5224 if ( cli_wand->image_list_stack == (
CLIStack *) NULL)
5225 CLIWandExceptionBreak(OptionError,
"UnableToCloneImage",option);
5226 new_images = (Image *)cli_wand->image_list_stack->data;
5227 if (new_images == (Image *) NULL)
5228 CLIWandExceptionBreak(OptionError,
"UnableToCloneImage",option);
5229 new_images=CloneImages(new_images,arg1,_exception);
5230 if (new_images == (Image *) NULL)
5231 CLIWandExceptionBreak(OptionError,
"NoSuchImage",option);
5232 AppendImageToList(&_images,new_images);
5241 if (LocaleCompare(
"version",option+1) == 0)
5243 ListMagickVersion(stdout);
5246 if (LocaleCompare(
"list",option+1) == 0)
5254 list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
5257 CLIWandExceptionArg(OptionError,
"UnrecognizedListType",option,arg1);
5262 case MagickCoderOptions:
5264 (void) ListCoderInfo((FILE *) NULL,_exception);
5267 case MagickColorOptions:
5269 (void) ListColorInfo((FILE *) NULL,_exception);
5272 case MagickConfigureOptions:
5274 (void) ListConfigureInfo((FILE *) NULL,_exception);
5277 case MagickDelegateOptions:
5279 (void) ListDelegateInfo((FILE *) NULL,_exception);
5282 case MagickFontOptions:
5284 (void) ListTypeInfo((FILE *) NULL,_exception);
5287 case MagickFormatOptions:
5288 (void) ListMagickInfo((FILE *) NULL,_exception);
5290 case MagickLocaleOptions:
5291 (void) ListLocaleInfo((FILE *) NULL,_exception);
5293 case MagickLogOptions:
5294 (void) ListLogInfo((FILE *) NULL,_exception);
5296 case MagickMagicOptions:
5297 (void) ListMagicInfo((FILE *) NULL,_exception);
5299 case MagickMimeOptions:
5300 (void) ListMimeInfo((FILE *) NULL,_exception);
5302 case MagickModuleOptions:
5303 (void) ListModuleInfo((FILE *) NULL,_exception);
5305 case MagickPagesizeOptions:
5306 (void) ListPagesizes((FILE *) NULL,_exception);
5308 case MagickPolicyOptions:
5309 (void) ListPolicyInfo((FILE *) NULL,_exception);
5311 case MagickResourceOptions:
5312 (void) ListMagickResourceInfo((FILE *) NULL,_exception);
5314 case MagickThresholdOptions:
5315 (void) ListThresholdMaps((FILE *) NULL,_exception);
5318 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
5325 CLIWandException(OptionError,
"UnrecognizedOption",option);
5327DisableMSCWarning(4127)
5333 arg1=DestroyString((
char *)arg1);
5335 arg2=DestroyString((
char *)arg2);
5389WandExport
void CLIOption(
MagickCLI *cli_wand,
const char *option,...)
5399 assert(cli_wand->signature == MagickWandSignature);
5400 assert(cli_wand->wand.signature == MagickWandSignature);
5405 if ( cli_wand->command == (
const OptionInfo *) NULL )
5406 cli_wand->command = GetCommandOptionInfo(option);
5408 (void) FormatLocaleFile(stderr,
"CLIOption \"%s\" matched \"%s\"\n",
5409 option, cli_wand->command->mnemonic );
5411 option_type=(CommandOptionFlags) cli_wand->command->flags;
5413 if ( option_type == UndefinedOptionFlag )
5414 CLIWandExceptionReturn(OptionFatalError,
"UnrecognizedOption",option);
5416 assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 );
5419 if ( (option_type & DeprecateOptionFlag) != 0 )
5420 CLIWandExceptionBreak(OptionError,
"DeprecatedOptionNoCode",option);
5423 if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 )
5424 CLIWandExceptionBreak(OptionFatalError,
"InvalidUseOfOption",option);
5431 count = (size_t) cli_wand->command->type;
5436 va_start(operands,option);
5440 arg1=(
const char *) va_arg(operands,
const char *);
5442 arg2=(
const char *) va_arg(operands,
const char *);
5446 (void) FormatLocaleFile(stderr,
5447 "CLIOption: \"%s\" Count: %ld Flags: %04x Args: \"%s\" \"%s\"\n",
5448 option,(
long) count,option_type,arg1,arg2);
5458 if ( cli_wand->wand.images != (Image *) NULL )
5459 (
void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
5460 cli_wand->wand.exception);
5462 if ( (option_type & SettingOptionFlags) != 0 ) {
5463 CLISettingOptionInfo(cli_wand, option, arg1, arg2);
5470 if ((option_type & NoImageOperatorFlag) != 0)
5471 CLINoImageOperator(cli_wand, option, arg1, arg2);
5476 if ( cli_wand->wand.images == (Image *) NULL )
5477 if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) &&
5478 ((option_type & SettingOptionFlags) == 0 ))
5479 CLIWandExceptionBreak(OptionError,
"NoImagesFound",option);
5482 if ( (option_type & SimpleOperatorFlag) != 0 &&
5483 cli_wand->wand.images != (Image *) NULL)
5485 ExceptionInfo *exception=AcquireExceptionInfo();
5486 (void) CLISimpleOperatorImages(cli_wand, option, arg1, arg2,exception);
5487 exception=DestroyExceptionInfo(exception);
5491 if ( (option_type & ListOperatorFlag) != 0 )
5492 (void) CLIListOperatorImages(cli_wand, option, arg1, arg2);
5494DisableMSCWarning(4127)
5498 cli_wand->command = (
const OptionInfo *) NULL;