#define ThrowFileException(exception,severity,tag,context) \
{ \
- char \
- *message; \
- \
- message=GetExceptionMessage(errno); \
- (void) ThrowMagickException(exception,GetMagickModule(),severity, \
- tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \
- message=DestroyString(message); \
+ char \
+ *message; \
+ \
+ message=GetExceptionMessage(errno); \
+ (void) ThrowMagickException(exception,GetMagickModule(),severity, \
+ tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \
+ message=DestroyString(message); \
}
\f
/*
% o argv: A text array containing the command line arguments.
%
*/
-#define MagickExceptionScript(severity,tag,arg,line,col) \
- (void) ThrowMagickException(cli_wand->wand.exception,GetMagickModule(), \
- severity,tag, "'%s' : Line %u Column %u of script \"%s\"", \
- arg, line, col, cli_wand->wand.name);
-
WandExport void ProcessScriptOptions(MagickCLI *cli_wand,int argc,char **argv)
{
ScriptTokenInfo
*token_info;
- size_t
- option_line, /* line and column of current option */
- option_column;
-
CommandOptionFlags
option_type;
ssize_t
count;
- MagickBooleanType
- plus_alt_op;
-
char
*option,
*arg1,
*arg2;
-
assert(argc>0 && argv[argc-1] != (char *)NULL);
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
token_info = AcquireScriptTokenInfo(argv[0]);
if (token_info->token == (char *) NULL) {
- ThrowFileException(cli_wand->wand.exception,OptionError,
+ ThrowFileException(cli_wand->wand.exception,OptionFatalError,
"UnableToOpenScript",argv[0]);
return;
}
+ /* Process Options from Script */
+ cli_wand->location="'%s' in \"%s\" line %d column %d";
+ cli_wand->filename=cli_wand->wand.name;
option = arg1 = arg2 = (char*)NULL;
- /* Process Options from Script */
while (1) {
/* Get a option */
if( GetScriptToken(token_info) == MagickFalse )
break;
+ cli_wand->line=token_info->token_line;
+ cli_wand->column=token_info->token_column;
+
/* Sanity check: option is larger than what should be posible */
if( strlen(token_info->token) > INITAL_TOKEN_LENGTH-1 ) {
token_info->token[INITAL_TOKEN_LENGTH-4] = '.';
token_info->token[INITAL_TOKEN_LENGTH-3] = '.';
token_info->token[INITAL_TOKEN_LENGTH-2] = '.';
token_info->token[INITAL_TOKEN_LENGTH-1] = '\0';
- MagickExceptionScript(OptionFatalError,"UnrecognizedOption",
- token_info->token,token_info->token_line,token_info->token_column);
+ CLIWandException(OptionFatalError,"UnrecognizedOption",token_info->token);
break;
- }
+ }
/* save option details */
CloneString(&option,token_info->token);
- option_line=token_info->token_line;
- option_column=token_info->token_column;
#if MagickCommandDebug >=2
(void) FormatLocaleFile(stderr, "Script Option Token: %u,%u: \"%s\"\n",
option_line, option_column, option );
if ( option_type == UndefinedOptionFlag ||
(option_type & NonMagickOptionFlag) != 0 ) {
#if MagickCommandDebug
- (void) FormatLocaleFile(stderr, "Script Non-Option: \"%s\"\n", option);
+ (void) FormatLocaleFile(stderr, "Script Non-Option: \"%s\"\n", option);
#endif
- if ( IsCommandOption(option) == MagickFalse) {
- /* non-option -- treat as a image read */
- CLISpecialOperator(cli_wand,"-read",option);
- count = 0;
- }
- else
- MagickExceptionScript(OptionFatalError,"UnrecognizedOption",
- option,option_line,option_column);
-
- if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
- break;
- continue;
+ if ( IsCommandOption(option) == MagickFalse) {
+ /* non-option -- treat as a image read */
+ CLISpecialOperator(cli_wand,"-read",option);
+ count = 0;
}
+ else
+ CLIWandExceptionBreak(OptionFatalError,"UnrecognizedOption",option);
- plus_alt_op = MagickFalse;
- if (*option=='+') plus_alt_op = MagickTrue;
+ if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+ break;
+ continue;
+ }
if ( count >= 1 ) {
- if( GetScriptToken(token_info) == MagickFalse ) {
- MagickExceptionScript(OptionError,"MissingArgument",option,
- option_line,option_column);
- break;
- }
- CloneString(&arg1,token_info->token);
- }
+ if( GetScriptToken(token_info) == MagickFalse )
+ CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option);
+ CloneString(&arg1,token_info->token);
+ }
else
- CloneString(&arg1,(*option!='+')?"true":(char *)NULL);
+ CloneString(&arg1,(char *)NULL);
if ( count >= 2 ) {
- if( GetScriptToken(token_info) == MagickFalse ) {
- MagickExceptionScript(OptionError,"MissingArgument",option,
- option_line,option_column);
- break;
- }
- CloneString(&arg2,token_info->token);
- }
+ if( GetScriptToken(token_info) == MagickFalse )
+ CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option);
+ CloneString(&arg2,token_info->token);
+ }
else
CloneString(&arg2,(char *)NULL);
- /* handle script special options */
+ /* handle script special options here */
//either continue processing command line
// or making use of the command line options.
//CLICommandOptions(cli_wand,count+1,argv, MagickScriptArgsFlags);
#endif
/* Process non-script specific option from file */
- if ( (option_type & SpecialOptionFlag) != 0 )
- {
- if ( LocaleCompare(option,"-exit") == 0 )
- break;
- /* No "-script" from script at this time */
- CLISpecialOperator(cli_wand,option,arg1);
- }
+ if ( (option_type & SpecialOptionFlag) != 0 ) {
+ if ( LocaleCompare(option,"-exit") == 0 )
+ break;
+ /* No "-script" from script at this time */
+ CLISpecialOperator(cli_wand,option,arg1);
+ }
- if ( (option_type & SettingOptionFlags) != 0 )
- {
- CLISettingOptionInfo(cli_wand, option+1, arg1);
- // FUTURE: Sync Specific Settings into Images
- }
+ if ( (option_type & SettingOptionFlags) != 0 ) {
+ CLISettingOptionInfo(cli_wand, option, arg1);
+ // FUTURE: Sync Specific Settings into Images
+ }
if ( (option_type & SimpleOperatorOptionFlag) != 0)
- CLISimpleOperatorImages(cli_wand, plus_alt_op, option+1, arg1, arg2);
+ CLISimpleOperatorImages(cli_wand, option, arg1, arg2);
if ( (option_type & ListOperatorOptionFlag) != 0 )
- CLIListOperatorImages(cli_wand, plus_alt_op, option+1, arg1, arg2);
+ CLIListOperatorImages(cli_wand, option, arg1, arg2);
if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
break;
token_info->token[INITAL_TOKEN_LENGTH-2] = '.';
token_info->token[INITAL_TOKEN_LENGTH-1] = '\0';
}
- MagickExceptionScript(OptionFatalError,"ScriptUnbalancedQuotes",
- token_info->token,token_info->token_line,token_info->token_column);
+ CLIWandException(OptionFatalError,"ScriptUnbalancedQuotes",
+ token_info->token);
break;
case TokenStatusMemoryFailed:
- MagickExceptionScript(OptionFatalError,"ScriptTokenMemoryFailed","",
- token_info->token_line,token_info->token_column);
+ CLIWandException(OptionFatalError,"ScriptTokenMemoryFailed","");
break;
case TokenStatusBinary:
- MagickExceptionScript(OptionFatalError,"ScriptIsBinary","",
- token_info->curr_line,token_info->curr_column);
+ CLIWandException(OptionFatalError,"ScriptIsBinary","");
break;
}
% The format of the ProcessCommandOptions method is:
%
% int ProcessCommandOptions(MagickCLI *cli_wand,int argc,char **argv,
-% int *index, ProcessOptionFlags process_flags )
+% ProcessOptionFlags process_flags )
%
% A description of each parameter follows:
%
% o process_flags: What type of arguments we are allowed to process
%
*/
-/* FUTURE: correctly identify option... CLI arg, Script line,column */
-#define MagickExceptionContinue(severity,tag,arg,index) \
- (void) ThrowMagickException(cli_wand->wand.exception,GetMagickModule(),severity,tag, \
- "'%s' : CLI Arg #%d", arg, (int) index); \
-
-#define MagickExceptionReturn(severity,tag,option,arg) \
-{ \
- MagickExceptionContinue(severity,tag,option,arg); \
- return; \
-}
-
WandExport void ProcessCommandOptions(MagickCLI *cli_wand,int argc,
char **argv, ProcessOptionFlags process_flags )
{
*arg1,
*arg2;
- MagickBooleanType
- plus_alt_op;
-
ssize_t
i,
end,
/*
Parse command-line options.
*/
+ cli_wand->location="'%s' %s arg %d";
+ cli_wand->filename="CLI";
+
end = argc;
if ( ( process_flags & ProcessOutputFile ) != 0 )
end--;
for (i=0; i < end; i += count +1) {
- /* Finished processing one option? */
- if ( ( process_flags & ProcessOneOptionOnly ) != 0 && i != 0 )
- return;
+ /* Finished processing one option? */
+ if ( ( process_flags & ProcessOneOptionOnly ) != 0 && i != 0 )
+ return;
- option=argv[i];
- plus_alt_op = MagickFalse;
- arg1=(char *)NULL;
- arg2=(char *)NULL;
+ option=argv[i];
+ cli_wand->line=i;
-
- { const OptionInfo *option_info = GetCommandOptionInfo(argv[i]);
- count=option_info->type;
- option_type=option_info->flags;
+ { const OptionInfo *option_info = GetCommandOptionInfo(argv[i]);
+ count=option_info->type;
+ option_type=option_info->flags;
#if MagickCommandDebug >= 3
- (void) FormatLocaleFile(stderr, "option \"%s\" matched \"%s\"\n",
- argv[i], option_info->mnemonic );
+ (void) FormatLocaleFile(stderr, "option \"%s\" matched \"%s\"\n",
+ argv[i], option_info->mnemonic );
#endif
- }
+ }
- if ( option_type == UndefinedOptionFlag ||
- (option_type & NonMagickOptionFlag) != 0 ) {
+ if ( option_type == UndefinedOptionFlag ||
+ (option_type & NonMagickOptionFlag) != 0 ) {
#if MagickCommandDebug
- (void) FormatLocaleFile(stderr, "CLI Non-Option: \"%s\"\n", option);
+ (void) FormatLocaleFile(stderr, "CLI Non-Option: \"%s\"\n", option);
#endif
- if ( ( IsCommandOption(option) == MagickFalse ) &&
- ( (process_flags & ProcessNonOptionImageRead) != 0 ) ) {
- /* non-option -- treat as a image read */
- CLISpecialOperator(cli_wand,"-read",option);
- count = 0;
- }
- else if ( (process_flags & ProcessUnknownOptionError) != 0 )
- MagickExceptionReturn(OptionFatalError,"UnrecognizedOption",
- option,i);
-
- if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
- break;
-
- continue;
+ if ( ( IsCommandOption(option) == MagickFalse ) &&
+ ( (process_flags & ProcessNonOptionImageRead) != 0 ) ) {
+ /* non-option -- treat as a image read */
+ CLISpecialOperator(cli_wand,"-read",option);
+ count = 0;
}
+ else if ( (process_flags & ProcessUnknownOptionError) != 0 )
+ CLIWandException(OptionFatalError,"UnrecognizedOption",option);
+ if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+ break;
- if ( (option_type & DeprecateOptionFlag) != 0 ) {
- MagickExceptionContinue(OptionWarning,"DeprecatedOption",option,i);
- if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
- break;
- /* FALLTHRU - continue processing depreciated option */
- }
+ continue;
+ }
- if ((i+count) >= end ) {
- MagickExceptionReturn(OptionError,"MissingArgument",option,i);
- if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
- break;
- continue; /* no arguments unable to proceed */
- }
+ if ( (option_type & DeprecateOptionFlag) != 0 ) {
+ CLIWandException(OptionWarning,"DeprecatedOption",option);
+ if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+ break;
+ }
+ if ((i+count) >= end ) {
+ CLIWandException(OptionError,"MissingArgument",option);
+ if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+ break;
+ continue; /* no arguments unable to proceed */
+ }
- if (*option=='+') plus_alt_op = MagickTrue;
- if (*option!='+') arg1 = "true";
- if ( count >= 1 ) arg1 = argv[i+1];
- if ( count >= 2 ) arg2 = argv[i+2];
+ arg1 = ( count >= 1 ) ? argv[i+1] : (char *)NULL;
+ arg2 = ( count >= 2 ) ? argv[i+2] : (char *)NULL;
#if MagickCommandDebug
- (void) FormatLocaleFile(stderr,
- "CLI Option: \"%s\" \tCount: %d Flags: %04x Args: \"%s\" \"%s\"\n",
- option,(int) count,option_type,arg1,arg2);
+ (void) FormatLocaleFile(stderr,
+ "CLI Option: \"%s\" \tCount: %d Flags: %04x Args: \"%s\" \"%s\"\n",
+ option,(int) count,option_type,arg1,arg2);
#endif
- if ( (option_type & SpecialOptionFlag) != 0 ) {
- if ( ( process_flags & ProcessExitOption ) != 0
- && LocaleCompare(option,"-exit") == 0 )
- return;
- if ( ( process_flags & ProcessScriptOption ) != 0
- && LocaleCompare(option,"-script") == 0)
- {
- // Unbalanced Parenthesis if stack not empty
- // Call Script, with a filename as a zeroth argument
- ProcessScriptOptions(cli_wand,argc-(i+1),argv+(i+1));
- return;
- }
- CLISpecialOperator(cli_wand,option,arg1);
+ if ( (option_type & SpecialOptionFlag) != 0 ) {
+ if ( ( process_flags & ProcessExitOption ) != 0
+ && LocaleCompare(option,"-exit") == 0 )
+ return;
+ if ( ( process_flags & ProcessScriptOption ) != 0
+ && LocaleCompare(option,"-script") == 0)
+ {
+ // Unbalanced Parenthesis if stack not empty
+ // Call Script, with a filename as a zeroth argument
+ ProcessScriptOptions(cli_wand,argc-(i+1),argv+(i+1));
+ return;
}
+ CLISpecialOperator(cli_wand,option,arg1);
+ }
- if ( (option_type & SettingOptionFlags) != 0 ) {
- CLISettingOptionInfo(cli_wand, option+1, arg1);
- // FUTURE: Sync Specific Settings into Images
- }
+ if ( (option_type & SettingOptionFlags) != 0 ) {
+ CLISettingOptionInfo(cli_wand, option, arg1);
+ // FUTURE: Sync Specific Settings into Images
+ }
- if ( (option_type & SimpleOperatorOptionFlag) != 0)
- CLISimpleOperatorImages(cli_wand, plus_alt_op, option+1, arg1, arg2);
+ if ( (option_type & SimpleOperatorOptionFlag) != 0)
+ CLISimpleOperatorImages(cli_wand, option, arg1, arg2);
- if ( (option_type & ListOperatorOptionFlag) != 0 )
- CLIListOperatorImages(cli_wand, plus_alt_op, option+1, arg1, arg2);
+ if ( (option_type & ListOperatorOptionFlag) != 0 )
+ CLIListOperatorImages(cli_wand, option, arg1, arg2);
- if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
- break;
- }
+ if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
+ break;
+ }
if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
return;
/* If there is an option -- produce an error */
if (IsCommandOption(option) != MagickFalse)
- /* FUTURE: Better Error - Output Filename not Found */
- MagickExceptionReturn(OptionError,"MissingOutputFilename",option,i);
+ CLIWandExceptionReturn(OptionError,"MissingOutputFilename",option);
/* If no images in MagickCLI */
if ( cli_wand->wand.images == (Image *) NULL ) {
- /* a "null:" output coder with no images is not an error! */
- if ( LocaleCompare(option,"null:") == 0 )
- return;
- MagickExceptionReturn(OptionError,"NoImagesForFinalWrite",option,i);
- }
+ /* a "null:" output coder with no images is not an error! */
+ if ( LocaleCompare(option,"null:") == 0 )
+ return;
+ CLIWandExceptionReturn(OptionError,"NoImagesForFinalWrite",option);
+ }
#if 0
- WandListOperatorImages(cli_wand,MagickFalse,"write",option,(const char *)NULL);
+ WandListOperatorImages(cli_wand,"-write",option,(const char *)NULL);
#else
(void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
cli_wand->wand.exception);
This is much like the UNIX "cat" command, but for both UNIX and Windows,
however the last argument provides the output filename.
*/
-#define ThrowFileException(exception,severity,tag,context) \
-{ \
- char \
- *message; \
- \
- message=GetExceptionMessage(errno); \
- (void) ThrowMagickException(exception,GetMagickModule(),severity, \
- tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \
- message=DestroyString(message); \
-}
-
static MagickBooleanType ConcatenateImages(int argc,char **argv,
ExceptionInfo *exception)
{
i;
output=fopen_utf8(argv[argc-1],"wb");
- if (output == (FILE *) NULL)
- {
- ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
- argv[argc-1]);
- return(MagickFalse);
- }
- for (i=2; i < (ssize_t) (argc-1); i++)
- {
+ if (output == (FILE *) NULL) {
+ ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
+ argv[argc-1]);
+ return(MagickFalse);
+ }
+ for (i=2; i < (ssize_t) (argc-1); i++) {
input=fopen_utf8(argv[i],"rb");
if (input == (FILE *) NULL)
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]);
*option;
/* Handle special single use options */
- if (argc == 2)
- {
- option=argv[1];
- if ((LocaleCompare("-version",option+1) == 0) ||
- (LocaleCompare("--version",option+1) == 0) )
- {
- (void) FormatLocaleFile(stdout,"Version: %s\n",
- GetMagickVersion((size_t *) NULL));
- (void) FormatLocaleFile(stdout,"Copyright: %s\n",
- GetMagickCopyright());
- (void) FormatLocaleFile(stdout,"Features: %s\n\n",
- GetMagickFeatures());
- return(MagickFalse);
- }
+ if (argc == 2) {
+ option=argv[1];
+ if ((LocaleCompare("-version",option+1) == 0) ||
+ (LocaleCompare("--version",option+1) == 0) ) {
+ (void) FormatLocaleFile(stdout,"Version: %s\n",
+ GetMagickVersion((size_t *) NULL));
+ (void) FormatLocaleFile(stdout,"Copyright: %s\n",
+ GetMagickCopyright());
+ (void) FormatLocaleFile(stdout,"Features: %s\n\n",
+ GetMagickFeatures());
+ return(MagickFalse);
}
+ }
/* The "magick" command must have at least two arguments */
if (argc < 3)
return(MagickUsage());
FUTURE: this should be a MagickCore option,
especially as no wand is actually needed!
*/
- CLISpecialOperator(cli_wand, argv[1]+1, argv[2]);
- else if (LocaleCompare("-script",argv[1]) == 0)
- {
- /* Start processing directly from script, no pre-script options
- Replace wand command name with script name
- */
- GetPathComponent(argv[2],TailPath,cli_wand->wand.name);
- ProcessScriptOptions(cli_wand,argc-2,argv+2);
- }
+ CLISpecialOperator(cli_wand, argv[1], argv[2]);
+ else if (LocaleCompare("-script",argv[1]) == 0) {
+ /* Start processing directly from script, no pre-script options
+ Replace wand command name with script name
+ */
+ GetPathComponent(argv[2],TailPath,cli_wand->wand.name);
+ ProcessScriptOptions(cli_wand,argc-2,argv+2);
+ }
else
/* Processing Command line, assuming output file as last option */
ProcessCommandOptions(cli_wand,argc-1,argv+1,MagickCommandOptionFlags);
assert(cli_wand->wand.exception == exception);
/* Handle metadata for ImageMagickObject COM object for Windows VBS */
- if (metadata != (char **) NULL)
- {
- const char
- *format;
-
- char
- *text;
-
- format="%w,%h,%m"; // Get this from image_info Option splaytree
-
- text=InterpretImageProperties(image_info,cli_wand->wand.images,format,
- exception);
- if (text == (char *) NULL)
- ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
- "MemoryAllocationFailed","`%s'", GetExceptionMessage(errno));
- else
- {
- (void) ConcatenateString(&(*metadata),text);
- text=DestroyString(text);
- }
+ if (metadata != (char **) NULL) {
+ const char
+ *format;
+
+ char
+ *text;
+
+ format="%w,%h,%m"; // Get this from image_info Option splaytree
+
+ text=InterpretImageProperties(image_info,cli_wand->wand.images,format,
+ exception);
+ if (text == (char *) NULL)
+ ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
+ "MemoryAllocationFailed","`%s'", GetExceptionMessage(errno));
+ else {
+ (void) ConcatenateString(&(*metadata),text);
+ text=DestroyString(text);
}
+ }
/* Destroy the special CLI Wand */
cli_wand->wand.image_info = (ImageInfo *)NULL; /* not these */
cli_wand->wand.exception = (ExceptionInfo *)NULL;
/*
Define declarations.
*/
-#define UndefinedCompressionQuality 0UL
+#define USE_WAND_METHODS 0
+#define MAX_STACK_DEPTH 32
+#define UNDEFINED_COMPRESSION_QUALITY 0UL
+
/*
Constant declaration. (temporary exports)
*/
% needed.
%
% The format of the NewMagickWand method is:
-%
+%
% MagickCLI *AcquireMagickCLI(ImageInfo *image_info,
% ExceptionInfo *exception)
%
cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
cli_wand->image_list_stack=(Stack *)NULL;
cli_wand->image_info_stack=(Stack *)NULL;
- cli_wand->location="'%s' @ unset location";
+ cli_wand->location="'%s' at unknown location";
cli_wand->filename="";
cli_wand->line=0;
cli_wand->column=0;
% and any exceptions, if still present in the wand.
%
% The format of the NewMagickWand method is:
-%
+%
% MagickWand *DestroyMagickCLI()
% Exception *exception)
%
%
% The format of the CLISettingOptionInfo method is:
%
-% void CLISettingOptionInfo(MagickCLI *cli_wand,const char *option,
-% const char *arg)
+% void CLISettingOptionInfo(MagickCLI *cli_wand,
+% const char *option, const char *arg)
%
% A description of each parameter follows:
%
% o option: The option string to be set
%
% o arg: The single argument used to set this option.
-% If NULL the setting is reset to its default value.
-% For boolean (no argument) settings false=NULL, true=any_string
%
% Example usage...
%
-% CLISettingOptionInfo(cli_wand, "background", "Red");
-% CLISettingOptionInfo(cli_wand, "adjoin", "true");
-% CLISettingOptionInfo(cli_wand, "adjoin", NULL);
+% CLISettingOptionInfo(cli_wand, "-background", "Red"); // set value
+% CLISettingOptionInfo(cli_wand, "-adjoin", NULL); // set boolean
+% CLISettingOptionInfo(cli_wand, "+adjoin", NULL); // unset
%
% Or for handling command line arguments EG: +/-option ["arg"]
%
% option_type=option_info->flags;
%
% if ( (option_type & SettingOperatorOptionFlags) != 0 )
-% CLISettingOptionInfo(cli_wand, argv[i]+1,
-% (((*argv[i])!='-') ? (char *)NULL
-% : (count>0) ? argv[i+1] : "true") );
+% CLISettingOptionInfo(cli_wand, argv[i],
+% (count>0) ? argv[i+1] : (char *)NULL);
% i += count+1;
%
*/
-WandExport void CLISettingOptionInfo(MagickCLI *cli_wand,const char *option,
- const char *arg)
+WandExport void CLISettingOptionInfo(MagickCLI *cli_wand,
+ const char *option,const char *arg)
{
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
#define exception (cli_wand->wand.exception)
#define draw_info (cli_wand->draw_info)
#define quantize_info (cli_wand->quantize_info)
-#define IfSetOption (arg!=(char *)NULL)
+#define IfSetOption (*option=='-')
#define ArgOption(def) (IfSetOption?arg:(const char *)(def))
#define ArgBoolean (IfSetOption?MagickTrue:MagickFalse)
+#define ArgBooleanNot (IfSetOption?MagickFalse:MagickTrue)
- switch (*option)
+ switch (*(option+1))
{
case 'a':
{
- if (LocaleCompare("adjoin",option) == 0)
+ if (LocaleCompare("adjoin",option+1) == 0)
{
image_info->adjoin = ArgBoolean;
break;
}
- if (LocaleCompare("affine",option) == 0)
+ if (LocaleCompare("affine",option+1) == 0)
{
/* DEPRECIATED: draw_info setting only: for -draw and -transform */
if (IfSetOption)
GetAffineMatrix(&draw_info->affine);
break;
}
- if (LocaleCompare("antialias",option) == 0)
+ if (LocaleCompare("antialias",option+1) == 0)
{
image_info->antialias =
draw_info->stroke_antialias =
}
if (LocaleCompare("attenuate",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
- if (LocaleCompare("authenticate",option) == 0)
+ if (LocaleCompare("authenticate",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
break;
}
case 'b':
{
- if (LocaleCompare("background",option) == 0)
+ if (LocaleCompare("background",option+1) == 0)
{
/* FUTURE: both image_info attribute & ImageOption in use!
image_info only used directly for generating new images.
Note that +background, means fall-back to image background
and only if not set fall back to BackgroundColor const.
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
(void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance,
&image_info->background_color,exception);
break;
}
- if (LocaleCompare("bias",option) == 0)
+ if (LocaleCompare("bias",option+1) == 0)
{
/* FUTURE: bias OBSOLETED, replaced by "convolve:bias"
as it is actually rarely used except in direct convolve operations
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption("0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0"));
break;
}
- if (LocaleCompare("black-point-compensation",option) == 0)
+ if (LocaleCompare("black-point-compensation",option+1) == 0)
{
/* Used as a image chromaticity setting
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,
- IfSetOption ? "true" : "false" );
+ (void) SetImageOption(image_info,option+1,
+ IfSetOption ? "true" : "false" );
break;
}
- if (LocaleCompare("blue-primary",option) == 0)
+ if (LocaleCompare("blue-primary",option+1) == 0)
{
/* Image chromaticity X,Y NB: Y=X if Y not defined
Used by many coders including PNG
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption("0.0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0.0"));
break;
}
- if (LocaleCompare("bordercolor",option) == 0)
+ if (LocaleCompare("bordercolor",option+1) == 0)
{
/* FUTURE: both image_info attribute & ImageOption in use!
SyncImageSettings() used to set per-image attribute.
*/
if (IfSetOption)
{
- (void) SetImageOption(image_info,option,arg);
+ (void) SetImageOption(image_info,option+1,arg);
(void) QueryColorCompliance(arg,AllCompliance,
&image_info->border_color,exception);
(void) QueryColorCompliance(arg,AllCompliance,
&draw_info->border_color,exception);
break;
}
- (void) DeleteImageOption(image_info,option);
+ (void) DeleteImageOption(image_info,option+1);
(void) QueryColorCompliance(BorderColor,AllCompliance,
&image_info->border_color,exception);
(void) QueryColorCompliance(BorderColor,AllCompliance,
&draw_info->border_color,exception);
break;
}
- if (LocaleCompare("box",option) == 0)
+ if (LocaleCompare("box",option+1) == 0)
{
/* DEPRECIATED - now "undercolor" */
CLISettingOptionInfo(cli_wand,"undercolor",arg);
}
case 'c':
{
- if (LocaleCompare("cache",option) == 0)
+ if (LocaleCompare("cache",option+1) == 0)
{
MagickSizeType
limit;
(void) SetMagickResourceLimit(MapResource,2*limit);
break;
}
- if (LocaleCompare("caption",option) == 0)
+ if (LocaleCompare("caption",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
- if (LocaleCompare("channel",option) == 0)
+ if (LocaleCompare("channel",option+1) == 0)
{
/* FUTURE: -channel mask {vaules}
This is applied to images in SimpleImageOperator!!!
IfSetOption ? ParseChannelOption(arg) : DefaultChannels );
break;
}
- if (LocaleCompare("colorspace",option) == 0)
+ if (LocaleCompare("colorspace",option+1) == 0)
{
/* Setting used for new images via AquireImage()
But also used as a SimpleImageOperator
MagickColorspaceOptions,MagickFalse,ArgOption("undefined"));
break;
}
- if (LocaleCompare("comment",option) == 0)
+ if (LocaleCompare("comment",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
- if (LocaleCompare("compose",option) == 0)
+ if (LocaleCompare("compose",option+1) == 0)
{
/* FUTURE: image_info should be used,
SyncImageSettings() used to set per-image attribute. - REMOVE
"-layer" operators shoud use image_info if defined otherwise
they should use a per-image compose setting.
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->compose=(CompositeOperator) ParseCommandOption(
MagickComposeOptions,MagickFalse,ArgOption("undefined"));
break;
}
- if (LocaleCompare("compress",option) == 0)
+ if (LocaleCompare("compress",option+1) == 0)
{
/* FUTURE: What should be used? image_info or ImageOption ???
The former is more efficent, but Crisy prefers the latter!
Note that "undefined" is a different setting to "none".
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->compression=(CompressionType) ParseCommandOption(
MagickCompressOptions,MagickFalse,ArgOption("undefined"));
break;
}
case 'd':
{
- if (LocaleCompare("debug",option) == 0)
+ if (LocaleCompare("debug",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
(void) SetLogEventMask(ArgOption("none"));
cli_wand->wand.debug=IsEventLogging();
break;
}
- if (LocaleCompare("define",option) == 0)
+ if (LocaleCompare("define",option+1) == 0)
{
/* DefineImageOption() equals SetImageOption() but with '='
It does not however set individual image options.
- -set will set individual image options as well!
+ "-set" will set individual image options as well!
*/
if (LocaleNCompare(arg,"registry:",9) == 0)
{
if (IfSetOption)
- (void) DefineImageRegistry(StringRegistryType,arg+9,
- exception);
+ (void) DefineImageRegistry(StringRegistryType,arg+9,exception);
else
(void) DeleteImageRegistry(arg+9);
break;
(void) DeleteImageOption(image_info,arg);
break;
}
- if (LocaleCompare("delay",option) == 0)
+ if (LocaleCompare("delay",option+1) == 0)
{
/* Only used for new images via AcquireImage()
FUTURE: Option should also be used for "-morph" (color morphing)
*/
- (void) SetImageOption(image_info,option,ArgOption("0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0"));
break;
}
- if (LocaleCompare("density",option) == 0)
+ if (LocaleCompare("density",option+1) == 0)
{
/* FUTURE: strings used in image_info attr and draw_info!
Basically as density can be in a XxY form!
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
(void) CloneString(&image_info->density,ArgOption(NULL));
(void) CloneString(&draw_info->density,image_info->density);
break;
}
- if (LocaleCompare("depth",option) == 0)
+ if (LocaleCompare("depth",option+1) == 0)
{
/* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!!
SyncImageSettings() used to set per-image attribute.
:MAGICKCORE_QUANTUM_DEPTH;
break;
}
- if (LocaleCompare("direction",option) == 0)
+ if (LocaleCompare("direction",option+1) == 0)
{
/* Image Option is only used to set draw_info */
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
draw_info->direction=(DirectionType) ParseCommandOption(
MagickDirectionOptions,MagickFalse,
ArgOption("undefined"));
break;
}
- if (LocaleCompare("display",option) == 0)
+ if (LocaleCompare("display",option+1) == 0)
{
(void) CloneString(&image_info->server_name,ArgOption(NULL));
(void) CloneString(&draw_info->server_name,image_info->server_name);
break;
}
- if (LocaleCompare("dispose",option) == 0)
+ if (LocaleCompare("dispose",option+1) == 0)
{
/* only used in setting new images */
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
break;
}
- if (LocaleCompare("dither",option) == 0)
+ if (LocaleCompare("dither",option+1) == 0)
{
/* image_info attr (on/off), quantize_info attr (on/off)
but also ImageInfo and quantize_info method!
FUTURE: merge the duality of the dithering options
*/
image_info->dither = quantize_info->dither = ArgBoolean;
- (void) SetImageOption(image_info,option,ArgOption("none"));
+ (void) SetImageOption(image_info,option+1,ArgOption("none"));
quantize_info->dither_method=(DitherMethod) ParseCommandOption(
MagickDitherOptions,MagickFalse,ArgOption("none"));
if (quantize_info->dither_method == NoDitherMethod)
}
case 'e':
{
- if (LocaleCompare("encoding",option) == 0)
+ if (LocaleCompare("encoding",option+1) == 0)
{
(void) CloneString(&draw_info->encoding,ArgOption("undefined"));
- (void) SetImageOption(image_info,option,draw_info->encoding);
+ (void) SetImageOption(image_info,option+1,draw_info->encoding);
break;
}
- if (LocaleCompare("endian",option) == 0)
+ if (LocaleCompare("endian",option+1) == 0)
{
/* Both image_info attr and ImageInfo */
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
image_info->endian=(EndianType) ParseCommandOption(
MagickEndianOptions,MagickFalse,ArgOption("undefined"));
break;
}
- if (LocaleCompare("extract",option) == 0)
+ if (LocaleCompare("extract",option+1) == 0)
{
(void) CloneString(&image_info->extract,ArgOption(NULL));
break;
}
case 'f':
{
- if (LocaleCompare("family",option) == 0)
+ if (LocaleCompare("family",option+1) == 0)
{
(void) CloneString(&draw_info->family,ArgOption(NULL));
break;
}
- if (LocaleCompare("fill",option) == 0)
+ if (LocaleCompare("fill",option+1) == 0)
{
/* Set "fill" OR "fill-pattern" in draw_info
The original fill color is preserved if a fill-pattern is given.
color;
value = ArgOption("none");
- (void) SetImageOption(image_info,option,value);
+ (void) SetImageOption(image_info,option+1,value);
if (draw_info->fill_pattern != (Image *) NULL)
draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
draw_info->fill=color;
break;
}
- if (LocaleCompare("filter",option) == 0)
+ if (LocaleCompare("filter",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
break;
}
- if (LocaleCompare("font",option) == 0)
+ if (LocaleCompare("font",option+1) == 0)
{
(void) CloneString(&draw_info->font,ArgOption(NULL));
(void) CloneString(&image_info->font,draw_info->font);
break;
}
- if (LocaleCompare("format",option) == 0)
+ if (LocaleCompare("format",option+1) == 0)
{
/* FUTURE: why the ping test, you could set ping after this! */
/*
if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
image_info->ping=MagickFalse;
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
- if (LocaleCompare("fuzz",option) == 0)
+ if (LocaleCompare("fuzz",option+1) == 0)
{
/* Option used to set image fuzz! unless blank canvas (from color)
Image attribute used for color compare operations
{
image_info->fuzz=StringToDoubleInterval(arg,(double)
QuantumRange+1.0);
- (void) SetImageOption(image_info,option,arg);
+ (void) SetImageOption(image_info,option+1,arg);
break;
}
image_info->fuzz=0.0;
- (void) SetImageOption(image_info,option,"0");
+ (void) SetImageOption(image_info,option+1,"0");
break;
}
break;
}
case 'g':
{
- if (LocaleCompare("gravity",option) == 0)
+ if (LocaleCompare("gravity",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,ArgOption("none"));
+ (void) SetImageOption(image_info,option+1,ArgOption("none"));
draw_info->gravity=(GravityType) ParseCommandOption(
MagickGravityOptions,MagickFalse,ArgOption("none"));
break;
}
- if (LocaleCompare("green-primary",option) == 0)
+ if (LocaleCompare("green-primary",option+1) == 0)
{
/* Image chromaticity X,Y NB: Y=X if Y not defined
SyncImageSettings() used to set per-image attribute.
Used directly by many coders
*/
- (void) SetImageOption(image_info,option,ArgOption("0.0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0.0"));
break;
}
break;
}
case 'i':
{
- if (LocaleCompare("intent",option) == 0)
+ if (LocaleCompare("intent",option+1) == 0)
{
/* Only used by coders: MIFF, MPC, BMP, PNG
and for image profile call to AcquireTransformThreadSet()
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
break;
}
- if (LocaleCompare("interlace",option) == 0)
+ if (LocaleCompare("interlace",option+1) == 0)
{
/* image_info is directly used by coders (so why an image setting?)
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
image_info->interlace=(InterlaceType) ParseCommandOption(
MagickInterlaceOptions,MagickFalse,ArgOption("undefined"));
break;
}
- if (LocaleCompare("interline-spacing",option) == 0)
+ if (LocaleCompare("interline-spacing",option+1) == 0)
{
- (void) SetImageOption(image_info,option, ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1, ArgOption(NULL));
draw_info->interline_spacing=StringToDouble(ArgOption("0"),
(char **) NULL);
break;
}
- if (LocaleCompare("interpolate",option) == 0)
+ if (LocaleCompare("interpolate",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,ArgOption("undefined"));
+ (void) SetImageOption(image_info,option+1,ArgOption("undefined"));
break;
}
- if (LocaleCompare("interword-spacing",option) == 0)
+ if (LocaleCompare("interword-spacing",option+1) == 0)
{
- (void) SetImageOption(image_info,option, ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1, ArgOption(NULL));
draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL);
break;
}
}
case 'k':
{
- if (LocaleCompare("kerning",option) == 0)
+ if (LocaleCompare("kerning",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL);
break;
}
}
case 'l':
{
- if (LocaleCompare("label",option) == 0)
+ if (LocaleCompare("label",option+1) == 0)
{
/* only used for new images - not in SyncImageOptions() */
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
- if (LocaleCompare("log",option) == 0)
+ if (LocaleCompare("log",option+1) == 0)
{
if (IfSetOption)
(void) SetLogFormat(arg);
break;
}
- if (LocaleCompare("loop",option) == 0)
+ if (LocaleCompare("loop",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,ArgOption("0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0"));
break;
}
break;
}
case 'm':
{
- if (LocaleCompare("mattecolor",option) == 0)
+ if (LocaleCompare("mattecolor",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
(void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance,
&image_info->matte_color,exception);
break;
}
- if (LocaleCompare("monitor",option) == 0)
+ if (LocaleCompare("monitor",option+1) == 0)
{
(void) SetImageInfoProgressMonitor(image_info, IfSetOption?
MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL);
break;
}
- if (LocaleCompare("monochrome",option) == 0)
+ if (LocaleCompare("monochrome",option+1) == 0)
{
/* Setting (for some input coders)
But also a special 'type' operator
}
case 'o':
{
- if (LocaleCompare("orient",option) == 0)
+ if (LocaleCompare("orient",option+1) == 0)
{
/* Is not used when defining for new images.
This makes it more of a 'operation' than a setting
FUTURE: make set meta-data operator instead.
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option, ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1, ArgOption(NULL));
image_info->orientation=(InterlaceType) ParseCommandOption(
MagickOrientationOptions,MagickFalse,ArgOption("undefined"));
break;
}
case 'p':
{
- if (LocaleCompare("page",option) == 0)
+ if (LocaleCompare("page",option+1) == 0)
{
/* Only used for new images and image generators
SyncImageSettings() used to set per-image attribute. ?????
if (!IfSetOption)
{
- (void) DeleteImageOption(image_info,option);
+ (void) DeleteImageOption(image_info,option+1);
(void) CloneString(&image_info->page,(char *) NULL);
break;
}
(void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
(unsigned long) geometry.width,(unsigned long) geometry.height,
(long) geometry.x,(long) geometry.y);
- (void) SetImageOption(image_info,option,page);
+ (void) SetImageOption(image_info,option+1,page);
(void) CloneString(&image_info->page,page);
break;
}
- if (LocaleCompare("ping",option) == 0)
+ if (LocaleCompare("ping",option+1) == 0)
{
image_info->ping = ArgBoolean;
break;
}
- if (LocaleCompare("pointsize",option) == 0)
+ if (LocaleCompare("pointsize",option+1) == 0)
{
image_info->pointsize=draw_info->pointsize=
StringToDouble(ArgOption("12"),(char **) NULL);
break;
}
- if (LocaleCompare("precision",option) == 0)
+ if (LocaleCompare("precision",option+1) == 0)
{
(void) SetMagickPrecision(StringToInteger(ArgOption("-1")));
break;
}
/* FUTURE: Only the 'preview' coder appears to use this
* Depreciate the coder? Leaving only the 'preview' operator.
- if (LocaleCompare("preview",option) == 0)
+ if (LocaleCompare("preview",option+1) == 0)
{
image_info->preview_type=UndefinedPreview;
if (IfSetOption)
}
case 'q':
{
- if (LocaleCompare("quality",option) == 0)
+ if (LocaleCompare("quality",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
- image_info->quality=UndefinedCompressionQuality;
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
+ image_info->quality=UNDEFINED_COMPRESSION_QUALITY;
if (IfSetOption)
image_info->quality=StringToUnsignedLong(arg);
break;
}
- if (LocaleCompare("quantize",option) == 0)
+ if (LocaleCompare("quantize",option+1) == 0)
{
/* Just a set direct in quantize_info */
quantize_info->colorspace=UndefinedColorspace;
MagickColorspaceOptions,MagickFalse,arg);
break;
}
- if (LocaleCompare("quiet",option) == 0)
+ if (LocaleCompare("quiet",option+1) == 0)
{
/* FUTURE: if two -quiet is performed you can not do +quiet! */
static WarningHandler
}
case 'r':
{
- if (LocaleCompare("red-primary",option) == 0)
+ if (LocaleCompare("red-primary",option+1) == 0)
{
/* Image chromaticity X,Y NB: Y=X if Y not defined
Used by many coders
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption("0.0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0.0"));
break;
}
- if (LocaleCompare("render",option) == 0)
+ if (LocaleCompare("render",option+1) == 0)
{
/* draw_info only setting */
- draw_info->render= IfSetOption ? MagickFalse : MagickTrue;
+ draw_info->render= ArgBooleanNot;
break;
}
- if (LocaleCompare("respect-parenthesis",option) == 0)
+ if (LocaleCompare("respect-parenthesis",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
break;
}
case 's':
{
- if (LocaleCompare("sampling-factor",option) == 0)
+ if (LocaleCompare("sampling-factor",option+1) == 0)
{
/* FUTURE: should be converted to jpeg:sampling_factor */
(void) CloneString(&image_info->sampling_factor,ArgOption(NULL));
break;
}
- if (LocaleCompare("scene",option) == 0)
+ if (LocaleCompare("scene",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute.
What ??? Why ????
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->scene=StringToUnsignedLong(ArgOption("0"));
break;
}
- if (LocaleCompare("seed",option) == 0)
+ if (LocaleCompare("seed",option+1) == 0)
{
SeedPseudoRandomGenerator(
IfSetOption ? (size_t) StringToUnsignedLong(arg)
: (size_t) time((time_t *) NULL) );
break;
}
- if (LocaleCompare("size",option) == 0)
+ if (LocaleCompare("size",option+1) == 0)
{
/* FUTURE: string in image_info -- convert to Option ???
Look at the special handling for "size" in SetImageOption()
(void) CloneString(&image_info->size,ArgOption(NULL));
break;
}
- if (LocaleCompare("stretch",option) == 0)
+ if (LocaleCompare("stretch",option+1) == 0)
{
draw_info->stretch=(StretchType) ParseCommandOption(
MagickStretchOptions,MagickFalse,ArgOption("undefined"));
break;
}
- if (LocaleCompare("stroke",option) == 0)
+ if (LocaleCompare("stroke",option+1) == 0)
{
/* set stroke color OR stroke-pattern
UPDATE: ensure stroke color is not destroyed is a pattern
color;
value = ArgOption("none");
- (void) SetImageOption(image_info,option,value);
+ (void) SetImageOption(image_info,option+1,value);
if (draw_info->stroke_pattern != (Image *) NULL)
draw_info->stroke_pattern=DestroyImage(draw_info->stroke_pattern);
draw_info->stroke=color;
break;
}
- if (LocaleCompare("strokewidth",option) == 0)
+ if (LocaleCompare("strokewidth",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
draw_info->stroke_width=StringToDouble(ArgOption("1.0"),
(char **) NULL);
break;
}
- if (LocaleCompare("style",option) == 0)
+ if (LocaleCompare("style",option+1) == 0)
{
draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
MagickFalse,ArgOption("undefined"));
break;
}
- if (LocaleCompare("synchronize",option) == 0)
+ if (LocaleCompare("synchronize",option+1) == 0)
{
image_info->synchronize = ArgBoolean;
break;
}
case 't':
{
- if (LocaleCompare("taint",option) == 0)
+ if (LocaleCompare("taint",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,
+ (void) SetImageOption(image_info,option+1,
IfSetOption ? "true" : "false");
break;
}
- if (LocaleCompare("texture",option) == 0)
+ if (LocaleCompare("texture",option+1) == 0)
{
/* FUTURE: move image_info string to option splay-tree */
(void) CloneString(&image_info->texture,ArgOption(NULL));
break;
}
- if (LocaleCompare("tile",option) == 0)
+ if (LocaleCompare("tile",option+1) == 0)
{
draw_info->fill_pattern=IfSetOption
?GetImageCache(image_info,arg,exception)
:DestroyImage(draw_info->fill_pattern);
break;
}
- if (LocaleCompare("tile-offset",option) == 0)
+ if (LocaleCompare("tile-offset",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. ??? */
- (void) SetImageOption(image_info,option,ArgOption("0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0"));
break;
}
- if (LocaleCompare("transparent-color",option) == 0)
+ if (LocaleCompare("transparent-color",option+1) == 0)
{
/* FUTURE: both image_info attribute & ImageOption in use!
image_info only used for generating new images.
Note that +transparent-color, means fall-back to image
attribute so ImageOption is deleted, not set to a default.
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
(void) QueryColorCompliance(ArgOption("none"),AllCompliance,
&image_info->transparent_color,exception);
break;
}
- if (LocaleCompare("treedepth",option) == 0)
+ if (LocaleCompare("treedepth",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0"));
break;
}
- if (LocaleCompare("type",option) == 0)
+ if (LocaleCompare("type",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
MagickFalse,ArgOption("undefined"));
break;
}
case 'u':
{
- if (LocaleCompare("undercolor",option) == 0)
+ if (LocaleCompare("undercolor",option+1) == 0)
{
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
(void) QueryColorCompliance(ArgOption("none"),AllCompliance,
&draw_info->undercolor,exception);
break;
}
- if (LocaleCompare("units",option) == 0)
+ if (LocaleCompare("units",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute.
Should this effect draw_info X and Y resolution?
FUTURE: this probably should be part of the density setting
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->units=(ResolutionType) ParseCommandOption(
MagickResolutionOptions,MagickFalse,ArgOption("undefined"));
break;
}
case 'v':
{
- if (LocaleCompare("verbose",option) == 0)
+ if (LocaleCompare("verbose",option+1) == 0)
{
/* FUTURE: Also an image artifact, set in Simple Operators.
But artifact is only used in verbose output.
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->verbose= ArgBoolean;
image_info->ping=MagickFalse; /* verbose can't be a ping */
break;
}
- if (LocaleCompare("view",option) == 0)
+ if (LocaleCompare("view",option+1) == 0)
{
/* FUTURE: Convert from image_info to ImageOption
Only used by coder FPX
(void) CloneString(&image_info->view,ArgOption(NULL));
break;
}
- if (LocaleCompare("virtual-pixel",option) == 0)
+ if (LocaleCompare("virtual-pixel",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute.
This is VERY deep in the image caching structure.
*/
- (void) SetImageOption(image_info,option,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgOption(NULL));
break;
}
break;
}
case 'w':
{
- if (LocaleCompare("weight",option) == 0)
+ if (LocaleCompare("weight",option+1) == 0)
{
/* Just what does using a font 'weight' do ???
There is no "-list weight" output (reference manual says there is)
draw_info->weight=400;
break;
}
- if (LocaleCompare("white-point",option) == 0)
+ if (LocaleCompare("white-point",option+1) == 0)
{
/* Used as a image chromaticity setting
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option,ArgOption("0.0"));
+ (void) SetImageOption(image_info,option+1,ArgOption("0.0"));
break;
}
break;
% The format of the WandSimpleOperatorImage method is:
%
% void CLISimpleOperatorImages(MagickCLI *cli_wand,
-% const MagickBooleanType plus_alt_op, const char *option,
-% const char *arg1, const char *arg2)
+% const char *option, const char *arg1, const char *arg2)
%
% A description of each parameter follows:
%
% o cli_wand: structure holding settings and images to be operated on
%
-% o plus_alt_op: request the 'plus' or alturnative form of the operation
-%
% o option: The option string for the operation
%
% o arg1, arg2: optional argument strings to the operation
%
% Example usage...
%
-% CLISimpleOperatorImages(cli_wand, MagickFalse,"crop","100x100+20+30",NULL);
-% CLISimpleOperatorImages(cli_wand, MagickTrue, "repage",NULL,NULL);
-% CLISimpleOperatorImages(cli_wand, MagickTrue, "distort","SRT","45");
-% if ( cli_wand->wand.exception->severity != UndefinedException ) {
-% CatchException(exception);
-% exit(1);
-% }
+% CLISimpleOperatorImages(cli_wand, "-crop","100x100+20+30",NULL);
+% CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL);
+% CLISimpleOperatorImages(cli_wand, "+distort","SRT","45");
%
% Or for handling command line arguments EG: +/-option ["arg"]
%
% option_type=option_info->flags;
%
% if ( (option_type & SimpleOperatorOptionFlag) != 0 )
-% CLISimpleOperatorImages(cli_wand,
-% ((*argv[i])=='+')?MagickTrue:MagickFalse,argv[i]+1,
+% CLISimpleOperatorImages(cli_wand, argv[i],
% count>=1 ? argv[i+1] : (char *)NULL,
% count>=2 ? argv[i+2] : (char *)NULL );
% i += count+1;
* replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
* one image replace by a list of images (-separate and -crop only!)
- In each case the result replaces the original image in the list, as well as
- the pointer to the modified image (last image added if replaced by a list
- of images) is returned.
+ In each case the result replaces the single original image in the list, as
+ well as the pointer to the modified image (last image added if replaced by a
+ list of images) is returned.
As the image pointed to may be replaced, the first image in the list may
also change. GetFirstImageInList() should be used by caller if they wish
return the Image pointer to the first image in list.
*/
static void CLISimpleOperatorImage(MagickCLI *cli_wand,
- const MagickBooleanType plus_alt_op, const char *option,
- const char *arg1, const char *arg2)
+ const char *option, const char *arg1, const char *arg2)
{
Image *
new_image;
#define exception (cli_wand->wand.exception)
#define draw_info (cli_wand->draw_info)
#define quantize_info (cli_wand->quantize_info)
-#define normal_op (plus_alt_op?MagickFalse:MagickTrue)
+#define IfNormalOp (*option=='-')
+#define IfPlusOp (*option!='-')
+#define normal_op (IfNormalOp?MagickTrue:MagickFalse)
+#define plus_alt_op (IfNormalOp?MagickFalse:MagickTrue)
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
*/
(void) SyncImageSettings(image_info,image,exception);
- switch (*option)
+ switch (*(option+1))
{
case 'a':
{
- if (LocaleCompare("adaptive-blur",option) == 0)
+ if (LocaleCompare("adaptive-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,geometry_info.xi,exception);
break;
}
- if (LocaleCompare("adaptive-resize",option) == 0)
+ if (LocaleCompare("adaptive-resize",option+1) == 0)
{
(void) ParseRegionGeometry(image,arg1,&geometry,exception);
new_image=AdaptiveResizeImage(image,geometry.width,geometry.height,
exception);
break;
}
- if (LocaleCompare("adaptive-sharpen",option) == 0)
+ if (LocaleCompare("adaptive-sharpen",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,geometry_info.xi,exception);
break;
}
- if (LocaleCompare("alpha",option) == 0)
+ if (LocaleCompare("alpha",option+1) == 0)
{
AlphaChannelType
alpha_type;
(void) SetImageAlphaChannel(image,alpha_type,exception);
break;
}
- if (LocaleCompare("annotate",option) == 0)
+ if (LocaleCompare("annotate",option+1) == 0)
{
char
*text,
GetAffineMatrix(&draw_info->affine);
break;
}
- if (LocaleCompare("auto-gamma",option) == 0)
+ if (LocaleCompare("auto-gamma",option+1) == 0)
{
(void) AutoGammaImage(image,exception);
break;
}
- if (LocaleCompare("auto-level",option) == 0)
+ if (LocaleCompare("auto-level",option+1) == 0)
{
(void) AutoLevelImage(image,exception);
break;
}
- if (LocaleCompare("auto-orient",option) == 0)
+ if (LocaleCompare("auto-orient",option+1) == 0)
{
+ /* This should probbaly be a MagickCore function */
switch (image->orientation)
{
case TopRightOrientation:
}
case 'b':
{
- if (LocaleCompare("black-threshold",option) == 0)
+ if (LocaleCompare("black-threshold",option+1) == 0)
{
(void) BlackThresholdImage(image,arg1,exception);
break;
}
- if (LocaleCompare("blue-shift",option) == 0)
+ if (LocaleCompare("blue-shift",option+1) == 0)
{
geometry_info.rho=1.5;
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
flags=ParseGeometry(arg1,&geometry_info);
new_image=BlueShiftImage(image,geometry_info.rho,exception);
break;
}
- if (LocaleCompare("blur",option) == 0)
+ if (LocaleCompare("blur",option+1) == 0)
{
/* FUTURE: use of "bias" in a blur is non-sensible */
flags=ParseGeometry(arg1,&geometry_info);
geometry_info.sigma,geometry_info.xi,exception);
break;
}
- if (LocaleCompare("border",option) == 0)
+ if (LocaleCompare("border",option+1) == 0)
{
CompositeOperator
compose;
new_image=BorderImage(image,&geometry,compose,exception);
break;
}
- if (LocaleCompare("brightness-contrast",option) == 0)
+ if (LocaleCompare("brightness-contrast",option+1) == 0)
{
double
brightness,
}
case 'c':
{
- if (LocaleCompare("cdl",option) == 0)
+ if (LocaleCompare("cdl",option+1) == 0)
{
char
*color_correction_collection;
exception);
break;
}
- if (LocaleCompare("channel",option) == 0)
+ if (LocaleCompare("channel",option+1) == 0)
{
/* The "channel" setting has already been set
FUTURE: This probably should be part of WandSettingOptionInfo()
SetPixelChannelMapMask(image,image_info->channel);
break;
}
- if (LocaleCompare("channel-extract",option) == 0)
+ if (LocaleCompare("channel-extract",option+1) == 0)
{
puts("stand by...");
break;
}
- if (LocaleCompare("channel-swap",option) == 0)
+ if (LocaleCompare("channel-swap",option+1) == 0)
{
puts("stand by...");
break;
}
- if (LocaleCompare("charcoal",option) == 0)
+ if (LocaleCompare("charcoal",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,geometry_info.xi,exception);
break;
}
- if (LocaleCompare("chop",option) == 0)
+ if (LocaleCompare("chop",option+1) == 0)
{
(void) ParseGravityGeometry(image,arg1,&geometry,exception);
new_image=ChopImage(image,&geometry,exception);
break;
}
- if (LocaleCompare("clamp",option) == 0)
+ if (LocaleCompare("clamp",option+1) == 0)
{
(void) ClampImage(image,exception);
break;
}
- if (LocaleCompare("cli_wandp",option) == 0)
+ if (LocaleCompare("clip",option+1) == 0)
{
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
(void) ClipImage(image,exception);
else /* "+mask" remove the write mask */
(void) SetImageMask(image,(Image *) NULL,exception);
break;
}
- if (LocaleCompare("cli_wandp-mask",option) == 0)
+ if (LocaleCompare("clip-mask",option+1) == 0)
{
CacheView
*mask_view;
ssize_t
y;
- if (plus_alt_op != MagickFalse)
- { /* "+cli_wandp-mask" Remove the write mask */
- (void) SetImageMask(image,(Image *) NULL,exception);
- break;
- }
+ if (IfPlusOp) {
+ /* "+clip-mask" Remove the write mask */
+ (void) SetImageMask(image,(Image *) NULL,exception);
+ break;
+ }
mask_image=GetImageCache(image_info,arg1,exception);
if (mask_image == (Image *) NULL)
break;
mask_image=DestroyImage(mask_image);
break;
}
- if (LocaleCompare("cli_wandp-path",option) == 0)
+ if (LocaleCompare("clip-path",option+1) == 0)
{
- (void) ClipImagePath(image,arg1,
- (MagickBooleanType)(!(int)plus_alt_op),exception);
+ (void) ClipImagePath(image,arg1,normal_op,exception);
break;
}
- if (LocaleCompare("colorize",option) == 0)
+ if (LocaleCompare("colorize",option+1) == 0)
{
new_image=ColorizeImage(image,arg1,&draw_info->fill,exception);
break;
}
- if (LocaleCompare("color-matrix",option) == 0)
+ if (LocaleCompare("color-matrix",option+1) == 0)
{
KernelInfo
*kernel;
kernel=DestroyKernelInfo(kernel);
break;
}
- if (LocaleCompare("colors",option) == 0)
+ if (LocaleCompare("colors",option+1) == 0)
{
/* Reduce the number of colors in the image.
FUTURE: also provide 'plus version with image 'color counts'
(void) CompressImageColormap(image,exception);
break;
}
- if (LocaleCompare("colorspace",option) == 0)
+ if (LocaleCompare("colorspace",option+1) == 0)
{
/* WARNING: this is both a image_info setting (already done)
and a operator to change image colorspace.
That seems to be a little strange!
*/
(void) TransformImageColorspace(image,
- plus_alt_op ? RGBColorspace : image_info->colorspace,
+ IfNormalOp ? image_info->colorspace : RGBColorspace,
exception);
break;
}
- if (LocaleCompare("contrast",option) == 0)
+ if (LocaleCompare("contrast",option+1) == 0)
{
- (void) ContrastImage(image,
- (MagickBooleanType)(!(int)plus_alt_op),exception);
+ (void) ContrastImage(image,normal_op,exception);
break;
}
- if (LocaleCompare("contrast-stretch",option) == 0)
+ if (LocaleCompare("contrast-stretch",option+1) == 0)
{
double
black_point,
exception);
break;
}
- if (LocaleCompare("convolve",option) == 0)
+ if (LocaleCompare("convolve",option+1) == 0)
{
KernelInfo
*kernel_info;
kernel_info=DestroyKernelInfo(kernel_info);
break;
}
- if (LocaleCompare("crop",option) == 0)
+ if (LocaleCompare("crop",option+1) == 0)
{
/* WARNING: This can generate multiple images! */
new_image=CropImageToTiles(image,arg1,exception);
break;
}
- if (LocaleCompare("cycle",option) == 0)
+ if (LocaleCompare("cycle",option+1) == 0)
{
(void) CycleColormapImage(image,(ssize_t) StringToLong(arg1),
exception);
}
case 'd':
{
- if (LocaleCompare("decipher",option) == 0)
+ if (LocaleCompare("decipher",option+1) == 0)
{
StringInfo
*passkey;
}
break;
}
- if (LocaleCompare("depth",option) == 0)
+ if (LocaleCompare("depth",option+1) == 0)
{
/* The image_info->depth setting has already been set
We just need to apply it to all images in current sequence
(void) SetImageDepth(image,image_info->depth,exception);
break;
}
- if (LocaleCompare("deskew",option) == 0)
+ if (LocaleCompare("deskew",option+1) == 0)
{
double
threshold;
- if (plus_alt_op != MagickFalse)
- threshold=40.0*QuantumRange/100.0;
- else
+ if (IfNormalOp)
threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0);
+ else
+ threshold=40.0*QuantumRange/100.0;
new_image=DeskewImage(image,threshold,exception);
break;
}
- if (LocaleCompare("despeckle",option) == 0)
+ if (LocaleCompare("despeckle",option+1) == 0)
{
new_image=DespeckleImage(image,exception);
break;
}
- if (LocaleCompare("distort",option) == 0)
+ if (LocaleCompare("distort",option+1) == 0)
{
char
*args,
arguments=(double *) RelinquishMagickMemory(arguments);
break;
}
- if (LocaleCompare("draw",option) == 0)
+ if (LocaleCompare("draw",option+1) == 0)
{
(void) CloneString(&draw_info->primitive,arg1);
(void) DrawImage(image,draw_info,exception);
}
case 'e':
{
- if (LocaleCompare("edge",option) == 0)
+ if (LocaleCompare("edge",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("emboss",option) == 0)
+ if (LocaleCompare("emboss",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("encipher",option) == 0)
+ if (LocaleCompare("encipher",option+1) == 0)
{
StringInfo
*passkey;
}
break;
}
- if (LocaleCompare("enhance",option) == 0)
+ if (LocaleCompare("enhance",option+1) == 0)
{
new_image=EnhanceImage(image,exception);
break;
}
- if (LocaleCompare("equalize",option) == 0)
+ if (LocaleCompare("equalize",option+1) == 0)
{
(void) EqualizeImage(image,exception);
break;
}
- if (LocaleCompare("evaluate",option) == 0)
+ if (LocaleCompare("evaluate",option+1) == 0)
{
double
constant;
(void) EvaluateImage(image,op,constant,exception);
break;
}
- if (LocaleCompare("extent",option) == 0)
+ if (LocaleCompare("extent",option+1) == 0)
{
flags=ParseGravityGeometry(image,arg1,&geometry,exception);
if (geometry.width == 0)
}
case 'f':
{
- if (LocaleCompare("features",option) == 0)
+ if (LocaleCompare("features",option+1) == 0)
{
/* FUTURE: move to SyncImageSettings() and AcqireImage()??? */
- if (plus_alt_op != MagickFalse)
- {
+ if (IfPlusOp) {
(void) DeleteImageArtifact(image,"identify:features");
break;
}
(void) SetImageArtifact(image,"verbose","true");
break;
}
- if (LocaleCompare("flip",option) == 0)
+ if (LocaleCompare("flip",option+1) == 0)
{
new_image=FlipImage(image,exception);
break;
}
- if (LocaleCompare("flop",option) == 0)
+ if (LocaleCompare("flop",option+1) == 0)
{
new_image=FlopImage(image,exception);
break;
}
- if (LocaleCompare("floodfill",option) == 0)
+ if (LocaleCompare("floodfill",option+1) == 0)
{
PixelInfo
target;
geometry.y,plus_alt_op,exception);
break;
}
- if (LocaleCompare("frame",option) == 0)
+ if (LocaleCompare("frame",option+1) == 0)
{
FrameInfo
frame_info;
new_image=FrameImage(image,&frame_info,compose,exception);
break;
}
- if (LocaleCompare("function",option) == 0)
+ if (LocaleCompare("function",option+1) == 0)
{
char
*arguments,
}
case 'g':
{
- if (LocaleCompare("gamma",option) == 0)
+ if (LocaleCompare("gamma",option+1) == 0)
{
- if (plus_alt_op != MagickFalse)
- image->gamma=StringToDouble(arg1,(char **) NULL);
- else
+ if (IfNormalOp)
(void) GammaImage(image,StringToDouble(arg1,(char **) NULL),
exception);
+ else
+ image->gamma=StringToDouble(arg1,(char **) NULL);
break;
}
- if ((LocaleCompare("gaussian-blur",option) == 0) ||
- (LocaleCompare("gaussian",option) == 0))
+ if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
+ (LocaleCompare("gaussian",option+1) == 0))
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("geometry",option) == 0)
+ if (LocaleCompare("geometry",option+1) == 0)
{
/*
Record Image offset for composition. (A Setting)
FUTURE: Why if no 'offset' does this resize ALL images?
Also why is the setting recorded in the IMAGE non-sense!
*/
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
{ /* remove the previous composition geometry offset! */
if (image->geometry != (char *) NULL)
image->geometry=DestroyString(image->geometry);
}
case 'h':
{
- if (LocaleCompare("highlight-color",option) == 0)
+ if (LocaleCompare("highlight-color",option+1) == 0)
{
- (void) SetImageArtifact(image,option,arg1);
+ (void) SetImageArtifact(image,option+1,arg1);
break;
}
break;
}
case 'i':
{
- if (LocaleCompare("identify",option) == 0)
+ if (LocaleCompare("identify",option+1) == 0)
{
const char
*format,
text=DestroyString((char *)text);
break;
}
- if (LocaleCompare("implode",option) == 0)
+ if (LocaleCompare("implode",option+1) == 0)
{
(void) ParseGeometry(arg1,&geometry_info);
new_image=ImplodeImage(image,geometry_info.rho,
image->interpolate,exception);
break;
}
- if (LocaleCompare("interpolative-resize",option) == 0)
+ if (LocaleCompare("interpolative-resize",option+1) == 0)
{
(void) ParseRegionGeometry(image,arg1,&geometry,exception);
new_image=InterpolativeResizeImage(image,geometry.width,
}
case 'l':
{
- if (LocaleCompare("lat",option) == 0)
+ if (LocaleCompare("lat",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & PercentValue) != 0)
exception);
break;
}
- if (LocaleCompare("level",option) == 0)
+ if (LocaleCompare("level",option+1) == 0)
{
MagickRealType
black_point,
}
if ((flags & SigmaValue) == 0)
white_point=(MagickRealType) QuantumRange-black_point;
- if (plus_alt_op || ((flags & AspectValue) != 0))
- (void) LevelizeImage(image,black_point,white_point,gamma,
- exception);
+ if (IfPlusOp || ((flags & AspectValue) != 0))
+ (void) LevelizeImage(image,black_point,white_point,gamma,exception);
else
- (void) LevelImage(image,black_point,white_point,gamma,
- exception);
+ (void) LevelImage(image,black_point,white_point,gamma,exception);
break;
}
- if (LocaleCompare("level-colors",option) == 0)
+ if (LocaleCompare("level-colors",option+1) == 0)
{
char
token[MaxTextExtent];
plus_alt_op,exception);
break;
}
- if (LocaleCompare("linear-stretch",option) == 0)
+ if (LocaleCompare("linear-stretch",option+1) == 0)
{
double
black_point,
(void) LinearStretchImage(image,black_point,white_point,exception);
break;
}
- if (LocaleCompare("liquid-rescale",option) == 0)
+ if (LocaleCompare("liquid-rescale",option+1) == 0)
{
flags=ParseRegionGeometry(image,arg1,&geometry,exception);
if ((flags & XValue) == 0)
geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
break;
}
- if (LocaleCompare("lowlight-color",option) == 0)
+ if (LocaleCompare("lowlight-color",option+1) == 0)
{
- (void) SetImageArtifact(image,option,arg1);
+ (void) SetImageArtifact(image,option+1,arg1);
break;
}
break;
}
case 'm':
{
- if (LocaleCompare("map",option) == 0)
+ if (LocaleCompare("map",option+1) == 0)
{
Image
*remap_image;
remap_image=DestroyImage(remap_image);
break;
}
- if (LocaleCompare("mask",option) == 0)
+ if (LocaleCompare("mask",option+1) == 0)
{
Image
*mask;
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
{ /* Remove a mask. */
(void) SetImageMask(image,(Image *) NULL,exception);
break;
mask=DestroyImage(mask);
break;
}
- if (LocaleCompare("matte",option) == 0)
+ if (LocaleCompare("matte",option+1) == 0)
{
/* DEPRECIATED */
- (void) SetImageAlphaChannel(image,plus_alt_op ?
- DeactivateAlphaChannel:SetAlphaChannel ,exception);
+ (void) SetImageAlphaChannel(image,IfNormalOp ? SetAlphaChannel :
+ DeactivateAlphaChannel, exception);
break;
}
- if (LocaleCompare("mode",option) == 0)
+ if (LocaleCompare("mode",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.rho,(size_t) geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("modulate",option) == 0)
+ if (LocaleCompare("modulate",option+1) == 0)
{
(void) ModulateImage(image,arg1,exception);
break;
}
- if (LocaleCompare("monitor",option) == 0)
+ if (LocaleCompare("monitor",option+1) == 0)
{
- (void) SetImageProgressMonitor(image, plus_alt_op?
- (MagickProgressMonitor) NULL:MonitorProgress,(void *) NULL);
+ (void) SetImageProgressMonitor(image, IfNormalOp ? MonitorProgress :
+ (MagickProgressMonitor) NULL,(void *) NULL);
break;
}
- if (LocaleCompare("monochrome",option) == 0)
+ if (LocaleCompare("monochrome",option+1) == 0)
{
(void) SetImageType(image,BilevelType,exception);
break;
}
- if (LocaleCompare("morphology",option) == 0)
+ if (LocaleCompare("morphology",option+1) == 0)
{
char
token[MaxTextExtent];
kernel=DestroyKernelInfo(kernel);
break;
}
- if (LocaleCompare("motion-blur",option) == 0)
+ if (LocaleCompare("motion-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
}
case 'n':
{
- if (LocaleCompare("negate",option) == 0)
+ if (LocaleCompare("negate",option+1) == 0)
{
(void) NegateImage(image, plus_alt_op, exception);
break;
}
- if (LocaleCompare("noise",option) == 0)
+ if (LocaleCompare("noise",option+1) == 0)
{
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
}
break;
}
- if (LocaleCompare("normalize",option) == 0)
+ if (LocaleCompare("normalize",option+1) == 0)
{
(void) NormalizeImage(image,exception);
break;
}
case 'o':
{
- if (LocaleCompare("opaque",option) == 0)
+ if (LocaleCompare("opaque",option+1) == 0)
{
PixelInfo
target;
exception);
break;
}
- if (LocaleCompare("ordered-dither",option) == 0)
+ if (LocaleCompare("ordered-dither",option+1) == 0)
{
(void) OrderedPosterizeImage(image,arg1,exception);
break;
}
case 'p':
{
- if (LocaleCompare("paint",option) == 0)
+ if (LocaleCompare("paint",option+1) == 0)
{
(void) ParseGeometry(arg1,&geometry_info);
new_image=OilPaintImage(image,geometry_info.rho,geometry_info.sigma,
exception);
break;
}
- if (LocaleCompare("polaroid",option) == 0)
+ if (LocaleCompare("polaroid",option+1) == 0)
{
const char
*caption;
double
angle;
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
{
RandomInfo
*random_info;
image->interpolate,exception);
break;
}
- if (LocaleCompare("posterize",option) == 0)
+ if (LocaleCompare("posterize",option+1) == 0)
{
(void) ParseGeometry(arg1,&geometry_info);
(void) PosterizeImage(image,(size_t) geometry_info.rho,
quantize_info->dither,exception);
break;
}
- if (LocaleCompare("preview",option) == 0)
+ if (LocaleCompare("preview",option+1) == 0)
{
PreviewType
preview_type;
Option however is also in WandSettingOptionInfo()
*/
preview_type=UndefinedPreview;
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
MagickFalse,arg1);
new_image=PreviewImage(image,preview_type,exception);
break;
}
- if (LocaleCompare("profile",option) == 0)
+ if (LocaleCompare("profile",option+1) == 0)
{
const char
*name;
ImageInfo
*profile_info;
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
{ /* Remove a profile from the image. */
(void) ProfileImage(image,arg1,(const unsigned char *)
NULL,0,exception);
}
case 'r':
{
- if (LocaleCompare("radial-blur",option) == 0)
+ if (LocaleCompare("radial-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
new_image=RadialBlurImage(image,geometry_info.rho,
geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("raise",option) == 0)
+ if (LocaleCompare("raise",option+1) == 0)
{
flags=ParsePageGeometry(image,arg1,&geometry,exception);
if ((flags & SigmaValue) == 0)
(void) RaiseImage(image,&geometry,normal_op,exception);
break;
}
- if (LocaleCompare("random-threshold",option) == 0)
+ if (LocaleCompare("random-threshold",option+1) == 0)
{
(void) RandomThresholdImage(image,arg1,exception);
break;
}
- if (LocaleCompare("remap",option) == 0)
+ if (LocaleCompare("remap",option+1) == 0)
{
Image
*remap_image;
remap_image=DestroyImage(remap_image);
break;
}
- if (LocaleCompare("repage",option) == 0)
+ if (LocaleCompare("repage",option+1) == 0)
{
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
(void) ResetImagePage(image,arg1);
else
(void) ParseAbsoluteGeometry("0x0+0+0",&image->page);
break;
}
- if (LocaleCompare("resample",option) == 0)
+ if (LocaleCompare("resample",option+1) == 0)
{
/* FUTURE: remove blur arguemnt - no longer used */
flags=ParseGeometry(arg1,&geometry_info);
geometry_info.sigma,image->filter,image->blur,exception);
break;
}
- if (LocaleCompare("resize",option) == 0)
+ if (LocaleCompare("resize",option+1) == 0)
{
/* FUTURE: remove blur argument - no longer used */
(void) ParseRegionGeometry(image,arg1,&geometry,exception);
image->filter,image->blur,exception);
break;
}
- if (LocaleCompare("roll",option) == 0)
+ if (LocaleCompare("roll",option+1) == 0)
{
(void) ParsePageGeometry(image,arg1,&geometry,exception);
new_image=RollImage(image,geometry.x,geometry.y,exception);
break;
}
- if (LocaleCompare("rotate",option) == 0)
+ if (LocaleCompare("rotate",option+1) == 0)
{
if (strchr(arg1,'>') != (char *) NULL)
if (image->columns <= image->rows)
}
case 's':
{
- if (LocaleCompare("sample",option) == 0)
+ if (LocaleCompare("sample",option+1) == 0)
{
(void) ParseRegionGeometry(image,arg1,&geometry,exception);
new_image=SampleImage(image,geometry.width,geometry.height,
exception);
break;
}
- if (LocaleCompare("scale",option) == 0)
+ if (LocaleCompare("scale",option+1) == 0)
{
(void) ParseRegionGeometry(image,arg1,&geometry,exception);
new_image=ScaleImage(image,geometry.width,geometry.height,
exception);
break;
}
- if (LocaleCompare("selective-blur",option) == 0)
+ if (LocaleCompare("selective-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & PercentValue) != 0)
geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
break;
}
- if (LocaleCompare("separate",option) == 0)
+ if (LocaleCompare("separate",option+1) == 0)
{
/* WARNING: This can generate multiple images! */
/* FUTURE - this may be replaced by a "-channel" method */
new_image=SeparateImages(image,exception);
break;
}
- if (LocaleCompare("sepia-tone",option) == 0)
+ if (LocaleCompare("sepia-tone",option+1) == 0)
{
double
threshold;
new_image=SepiaToneImage(image,threshold,exception);
break;
}
- if (LocaleCompare("segment",option) == 0)
+ if (LocaleCompare("segment",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
exception);
break;
}
- if (LocaleCompare("set",option) == 0)
+ if (LocaleCompare("set",option+1) == 0)
{
char
*value;
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
{
if (LocaleNCompare(arg1,"registry:",9) == 0)
(void) DeleteImageRegistry(arg1+9);
value=DestroyString(value);
break;
}
- if (LocaleCompare("shade",option) == 0)
+ if (LocaleCompare("shade",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("shadow",option) == 0)
+ if (LocaleCompare("shadow",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
exception);
break;
}
- if (LocaleCompare("sharpen",option) == 0)
+ if (LocaleCompare("sharpen",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,geometry_info.xi,exception);
break;
}
- if (LocaleCompare("shave",option) == 0)
+ if (LocaleCompare("shave",option+1) == 0)
{
flags=ParsePageGeometry(image,arg1,&geometry,exception);
new_image=ShaveImage(image,&geometry,exception);
break;
}
- if (LocaleCompare("shear",option) == 0)
+ if (LocaleCompare("shear",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("sigmoidal-contrast",option) == 0)
+ if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
exception);
break;
}
- if (LocaleCompare("sketch",option) == 0)
+ if (LocaleCompare("sketch",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
break;
}
- if (LocaleCompare("solarize",option) == 0)
+ if (LocaleCompare("solarize",option+1) == 0)
{
(void) SolarizeImage(image,StringToDoubleInterval(arg1,(double)
QuantumRange+1.0),exception);
break;
}
- if (LocaleCompare("sparse-color",option) == 0)
+ if (LocaleCompare("sparse-color",option+1) == 0)
{
SparseColorMethod
method;
arguments=DestroyString(arguments);
break;
}
- if (LocaleCompare("splice",option) == 0)
+ if (LocaleCompare("splice",option+1) == 0)
{
(void) ParseGravityGeometry(image,arg1,&geometry,exception);
new_image=SpliceImage(image,&geometry,exception);
break;
}
- if (LocaleCompare("spread",option) == 0)
+ if (LocaleCompare("spread",option+1) == 0)
{
(void) ParseGeometry(arg1,&geometry_info);
new_image=SpreadImage(image,geometry_info.rho,image->interpolate,
exception);
break;
}
- if (LocaleCompare("statistic",option) == 0)
+ if (LocaleCompare("statistic",option+1) == 0)
{
StatisticType
type;
(size_t) geometry_info.sigma,exception);
break;
}
- if (LocaleCompare("strip",option) == 0)
+ if (LocaleCompare("strip",option+1) == 0)
{
(void) StripImage(image,exception);
break;
}
- if (LocaleCompare("swirl",option) == 0)
+ if (LocaleCompare("swirl",option+1) == 0)
{
(void) ParseGeometry(arg1,&geometry_info);
new_image=SwirlImage(image,geometry_info.rho,
}
case 't':
{
- if (LocaleCompare("threshold",option) == 0)
+ if (LocaleCompare("threshold",option+1) == 0)
{
double
threshold;
- if (plus_alt_op != MagickFalse)
+ if (!normal_op)
threshold=(double) QuantumRange/2;
else
threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0);
(void) BilevelImage(image,threshold,exception);
break;
}
- if (LocaleCompare("thumbnail",option) == 0)
+ if (LocaleCompare("thumbnail",option+1) == 0)
{
(void) ParseRegionGeometry(image,arg1,&geometry,exception);
new_image=ThumbnailImage(image,geometry.width,geometry.height,
exception);
break;
}
- if (LocaleCompare("tint",option) == 0)
+ if (LocaleCompare("tint",option+1) == 0)
{
new_image=TintImage(image,arg1,&draw_info->fill,exception);
break;
}
- if (LocaleCompare("transform",option) == 0)
+ if (LocaleCompare("transform",option+1) == 0)
{
/* DEPRECIATED */
new_image=AffineTransformImage(image,&draw_info->affine,
exception);
break;
}
- if (LocaleCompare("transparent",option) == 0)
+ if (LocaleCompare("transparent",option+1) == 0)
{
PixelInfo
target;
TransparentAlpha,plus_alt_op,exception);
break;
}
- if (LocaleCompare("transpose",option) == 0)
+ if (LocaleCompare("transpose",option+1) == 0)
{
new_image=TransposeImage(image,exception);
break;
}
- if (LocaleCompare("transverse",option) == 0)
+ if (LocaleCompare("transverse",option+1) == 0)
{
new_image=TransverseImage(image,exception);
break;
}
- if (LocaleCompare("trim",option) == 0)
+ if (LocaleCompare("trim",option+1) == 0)
{
new_image=TrimImage(image,exception);
break;
}
- if (LocaleCompare("type",option) == 0)
+ if (LocaleCompare("type",option+1) == 0)
{
/* Note that "type" setting should have already been defined */
(void) SetImageType(image,image_info->type,exception);
}
case 'u':
{
- if (LocaleCompare("unique",option) == 0)
+ if (LocaleCompare("unique",option+1) == 0)
{
/* FUTURE: move to SyncImageSettings() and AcqireImage()??? */
- if (plus_alt_op != MagickFalse)
+ if (!normal_op)
{
(void) DeleteImageArtifact(image,"identify:unique-colors");
break;
(void) SetImageArtifact(image,"verbose","true");
break;
}
- if (LocaleCompare("unique-colors",option) == 0)
+ if (LocaleCompare("unique-colors",option+1) == 0)
{
new_image=UniqueImageColors(image,exception);
break;
}
- if (LocaleCompare("unsharp",option) == 0)
+ if (LocaleCompare("unsharp",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
}
case 'v':
{
- if (LocaleCompare("verbose",option) == 0)
+ if (LocaleCompare("verbose",option+1) == 0)
{
- /* FUTURE: move to SyncImageSettings() and AcqireImage()???
+ /* FUTURE: move to SyncImageSettings() and AcquireImage()???
three places! ImageArtifact ImageOption image_info->verbose
- Some how new images also get this artifact -- how???
+ Some how new images also get this artifact presumably here
*/
- (void) SetImageArtifact(image,option,
- (plus_alt_op != MagickFalse) ? "false" : "true" );
+ (void) SetImageArtifact(image,option+1,
+ IfNormalOp ? "true" : "false" );
break;
}
- if (LocaleCompare("vignette",option) == 0)
+ if (LocaleCompare("vignette",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
}
case 'w':
{
- if (LocaleCompare("wave",option) == 0)
+ if (LocaleCompare("wave",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
image->interpolate,exception);
break;
}
- if (LocaleCompare("white-threshold",option) == 0)
+ if (LocaleCompare("white-threshold",option+1) == 0)
{
(void) WhiteThresholdImage(image,arg1,exception);
break;
#undef quantize_info
#undef image
#undef exception
+#undef IfNormalOp
+#undef IfPlusOp
#undef normal_op
+#undef plus_alt_op
}
WandExport void CLISimpleOperatorImages(MagickCLI *cli_wand,
- const MagickBooleanType plus_alt_op, const char *option,
- const char *arg1, const char *arg2)
+ const char *option, const char *arg1, const char *arg2)
{
size_t
n,
if (cli_wand->wand.debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
+#if !USE_WAND_METHODS
+ /* FUTURE add appropriate tracing */
i=0;
n=GetImageListLength(cli_wand->wand.images);
cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
- while (1)
- {
+ while (1) {
i++;
- CLISimpleOperatorImage(cli_wand, plus_alt_op, option, arg1, arg2);
+ CLISimpleOperatorImage(cli_wand, option, arg1, arg2);
if ( cli_wand->wand.images->next == (Image *) NULL )
break;
cli_wand->wand.images=cli_wand->wand.images->next;
}
assert( i == n );
cli_wand->wand.images=GetFirstImageInList(cli_wand->wand.images);
+#else
+ MagickResetIterator(&cli_wand->wand);
+ while ( MagickNextImage(&cli_wand->wand) != MagickFalse )
+ CLISimpleOperatorImage(cli_wand, option, arg1, arg2);
+ MagickResetIterator(&cli_wand->wand);
+#endif
return;
}
\f
% The format of the MogrifyImage method is:
%
% void CLIListOperatorImages(MagickCLI *cli_wand,
-% const MagickBooleanType plus_alt_op,const char *option,
-% const char *arg1, const char *arg2)
+% const char *option, const char *arg1, const char *arg2)
%
% A description of each parameter follows:
%
% o cli_wand: structure holding settings to be applied
%
-% o plus_alt_op: request the 'plus' or alturnative form of the operation
-%
% o option: The option string for the operation
%
% o arg1, arg2: optional argument strings to the operation
%
% Example usage...
%
-% CLIListOperatorImages(cli_wand,MagickFalse,"duplicate", "3", NULL);
-% CLIListOperatorImages(cli_wand,MagickTrue, "append", NULL, NULL);
-% if ( cli_wand->wand.exception->severity != UndefinedException ) {
-% CatchException(exception);
-% exit(1);
-% }
+% CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL);
+% CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL);
%
% Or for handling command line arguments EG: +/-option ["arg"]
%
% option_type=option_info->flags;
%
% if ( (option_type & ListOperatorOptionFlag) != 0 )
-% CLIListOperatorImages(cli_wand,
-% ((*argv[i])=='+')?MagickTrue:MagickFalse,argv[i]+1,
+% CLIListOperatorImages(cli_wand,argv[i],
% count>=1 ? argv[i+1] : (char *)NULL,
% count>=2 ? argv[i+2] : (char *)NULL );
% i += count+1;
%
*/
WandExport void CLIListOperatorImages(MagickCLI *cli_wand,
- const MagickBooleanType plus_alt_op,const char *option,
- const char *arg1, const char *arg2)
+ const char *option,const char *arg1, const char *arg2)
{
Image
*new_images;
#define exception (cli_wand->wand.exception)
#define draw_info (cli_wand->draw_info)
#define quantize_info (cli_wand->quantize_info)
-#define normal_op (plus_alt_op?MagickFalse:MagickTrue)
+#define IfNormalOp (*option=='-')
+#define IfPlusOp (*option!='-')
+#define normal_op (IfNormalOp?MagickTrue:MagickFalse)
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
new_images=NewImageList();
- switch (*option)
+ switch (*(option+1))
{
case 'a':
{
- if (LocaleCompare("append",option) == 0)
+ if (LocaleCompare("append",option+1) == 0)
{
new_images=AppendImages(images,normal_op,exception);
break;
}
- if (LocaleCompare("average",option) == 0)
+ if (LocaleCompare("average",option+1) == 0)
{
/* DEPRECIATED - use -evaluate-sequence Mean */
- CLIListOperatorImages(cli_wand,plus_alt_op,"evaluate-sequence","Mean",
- NULL);
+ CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL);
break;
}
break;
}
case 'c':
{
- if (LocaleCompare("channel-inject",option) == 0)
+ if (LocaleCompare("channel-inject",option+1) == 0)
{
puts("stand by...");
break;
}
- if (LocaleCompare("clut",option) == 0)
+ if (LocaleCompare("clut",option+1) == 0)
{
Image
*clut_image;
- /* FUTURE - make this a compose option (and thus layers compose )
- or perhaps compose last image over all other images.
+ /* FUTURE - make this a compose option, and thus can be used
+ with layers compose or even compose last image over all other
+ images.
*/
new_images=RemoveFirstImageFromList(&images);
clut_image=RemoveLastImageFromList(&images);
clut_image=DestroyImage(clut_image);
break;
}
- if (LocaleCompare("coalesce",option) == 0)
+ if (LocaleCompare("coalesce",option+1) == 0)
{
new_images=CoalesceImages(images,exception);
break;
}
- if (LocaleCompare("combine",option) == 0)
+ if (LocaleCompare("combine",option+1) == 0)
{
/* FUTURE - this may be replaced by a 'channel' method */
new_images=CombineImages(images,exception);
break;
}
- if (LocaleCompare("composite",option) == 0)
+ if (LocaleCompare("composite",option+1) == 0)
{
Image
*mask_image,
}
case 'd':
{
- if (LocaleCompare("deconstruct",option) == 0)
+ if (LocaleCompare("deconstruct",option+1) == 0)
{
/* DEPRECIATED - use -layers CompareAny */
- CLIListOperatorImages(cli_wand,plus_alt_op,"layer","CompareAny",NULL);
+ CLIListOperatorImages(cli_wand,"-layer","CompareAny",NULL);
break;
}
- if (LocaleCompare("delete",option) == 0)
+ if (LocaleCompare("delete",option+1) == 0)
{
- if (plus_alt_op != MagickFalse)
- DeleteImages(&images,"-1",exception);
- else
+ if (IfNormalOp)
DeleteImages(&images,arg1,exception);
+ else
+ DeleteImages(&images,"-1",exception);
break;
}
- if (LocaleCompare("duplicate",option) == 0)
+ if (LocaleCompare("duplicate",option+1) == 0)
{
- if (plus_alt_op != MagickFalse)
- new_images=DuplicateImages(images,1,"-1",exception);
- else
+ if (IfNormalOp)
{
const char
*p;
new_images=DuplicateImages(images,number_duplicates,p,
exception);
}
+ else
+ new_images=DuplicateImages(images,1,"-1",exception);
AppendImageToList(&images, new_images);
new_images=(Image *)NULL;
break;
}
case 'e':
{
- if (LocaleCompare("evaluate-sequence",option) == 0)
+ if (LocaleCompare("evaluate-sequence",option+1) == 0)
{
MagickEvaluateOperator
method;
}
case 'f':
{
- if (LocaleCompare("fft",option) == 0)
+ if (LocaleCompare("fft",option+1) == 0)
{
new_images=ForwardFourierTransformImage(images,normal_op,exception);
break;
}
- if (LocaleCompare("flatten",option) == 0)
+ if (LocaleCompare("flatten",option+1) == 0)
{
/* DEPRECIATED use -layers mosaic instead */
- CLIListOperatorImages(cli_wand,plus_alt_op,"layer",option,NULL);
+ CLIListOperatorImages(cli_wand,"-layer",option+1,NULL);
break;
}
- if (LocaleCompare("fx",option) == 0)
+ if (LocaleCompare("fx",option+1) == 0)
{
new_images=FxImage(images,arg1,exception);
break;
}
case 'h':
{
- if (LocaleCompare("hald-clut",option) == 0)
+ if (LocaleCompare("hald-clut",option+1) == 0)
{
/* FUTURE - make this a compose option (and thus layers compose )
or perhaps compose last image over all other images.
}
case 'i':
{
- if (LocaleCompare("ift",option) == 0)
+ if (LocaleCompare("ift",option+1) == 0)
{
Image
*magnitude_image,
phase_image=DestroyImage(phase_image);
break;
}
- if (LocaleCompare("insert",option) == 0)
+ if (LocaleCompare("insert",option+1) == 0)
{
Image
*insert_image,
index=0;
insert_image=RemoveLastImageFromList(&images);
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
index=(ssize_t) StringToLong(arg1);
index_image=insert_image;
if (index == 0)
}
case 'l':
{
- if (LocaleCompare("layers",option) == 0)
+ if (LocaleCompare("layers",option+1) == 0)
{
ImageLayerMethod
method;
}
break;
}
- if (LocaleCompare("limit",option) == 0)
+ if (LocaleCompare("limit",option+1) == 0)
{
MagickSizeType
limit;
}
case 'm':
{
- if (LocaleCompare("map",option) == 0)
+ if (LocaleCompare("map",option+1) == 0)
{
/* DEPRECIATED use +remap */
(void) RemapImages(quantize_info,images,(Image *) NULL,exception);
break;
}
- if (LocaleCompare("morph",option) == 0)
+ if (LocaleCompare("morph",option+1) == 0)
{
Image
*morph_image;
images=morph_image;
break;
}
- if (LocaleCompare("mosaic",option) == 0)
+ if (LocaleCompare("mosaic",option+1) == 0)
{
/* DEPRECIATED use -layers mosaic instead */
- CLIListOperatorImages(cli_wand,plus_alt_op,"layer",option,NULL);
+ CLIListOperatorImages(cli_wand,"-layer",option+1,NULL);
break;
}
break;
}
case 'p':
{
- if (LocaleCompare("print",option) == 0)
+ if (LocaleCompare("print",option+1) == 0)
{
char
*string;
(void) FormatLocaleFile(stdout,"%s",string);
string=DestroyString(string);
}
- if (LocaleCompare("process",option) == 0)
+ if (LocaleCompare("process",option+1) == 0)
{
char
**arguments;
}
case 'r':
{
- if (LocaleCompare("remap",option) == 0)
+ if (LocaleCompare("remap",option+1) == 0)
{
(void) RemapImages(quantize_info,images,(Image *) NULL,exception);
(void) RemapImages(quantize_info,images,(Image *) NULL,exception);
break;
}
- if (LocaleCompare("reverse",option) == 0)
+ if (LocaleCompare("reverse",option+1) == 0)
{
ReverseImageList(&images);
break;
}
case 's':
{
- if (LocaleCompare("smush",option) == 0)
+ if (LocaleCompare("smush",option+1) == 0)
{
Image
*smush_image;
images=smush_image;
break;
}
- if (LocaleCompare("swap",option) == 0)
+ if (LocaleCompare("swap",option+1) == 0)
{
Image
*p,
index=-1;
swap_index=-2;
- if (plus_alt_op == MagickFalse)
+ if (IfNormalOp)
{
GeometryInfo
geometry_info;
}
case 'w':
{
- if (LocaleCompare("write",option) == 0)
+ if (LocaleCompare("write",option+1) == 0)
{
char
key[MaxTextExtent];
(void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1);
(void) DeleteImageRegistry(key);
write_images=images;
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
write_images=CloneImageList(images,exception);
write_info=CloneImageInfo(image_info);
(void) WriteImages(write_info,write_images,arg1,exception);
write_info=DestroyImageInfo(write_info);
- if (plus_alt_op != MagickFalse)
+ if (IfPlusOp)
write_images=DestroyImageList(write_images);
break;
}
#undef exception
#undef draw_info
#undef quantize_info
+#undef IfNormalOp
+#undef IfPlusOp
#undef normal_op
}
\f
% CLISpecialOption() Applies operations that may involve empty image lists
% and or stacks of image lists or image_info settings.
%
-% Note: inlike other Operators, these may involve other special 'option'
-% character prefixes, other than simply '-' or '+' and as such the full
-% original otpion must be passed.
+% The classic operators of this type is -read, and image stack operators,
+% which can be applied to empty image lists.
+%
+% Note: unlike other Operators, these may involve other special 'option'
+% character prefixes, other than simply '-' or '+'.
%
% The format of the CLISpecialOption method is:
%
% o option: The special option (with any switch char) to process
%
% o arg: Argument for option, if required
-%
+%
% Example Usage...
%
% CLISpecialOperator(cli_wand,"-read", "rose:");
-% if ( cli_wand->wand.exception->severity != UndefinedException ) {
-% CatchException(exception);
-% exit(1);
-% }
%
% Or for handling command line arguments EG: +/-option ["arg"]
%
%
*/
-#define MaxImageStackDepth 32
-
WandExport void CLISpecialOperator(MagickCLI *cli_wand,
const char *option, const char *arg)
{
if (cli_wand->wand.debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
- if (LocaleCompare(option,"(") == 0)
+ if (LocaleCompare("(",option) == 0)
{
/* stack 'push' images */
Stack
node=cli_wand->image_list_stack;
for ( ; node != (Stack *)NULL; node=node->next)
size++;
- if ( size >= MaxImageStackDepth )
+ if ( size >= MAX_STACK_DEPTH )
{
ThrowMagickException(exception,GetMagickModule(),
OptionError,"ParenthesisNestedTooDeeply", option);
else
return;
}
- if (LocaleCompare(option,"{") == 0)
+ if (LocaleCompare("{",option) == 0)
{
/* stack 'push' of image_info settings */
Stack
node=cli_wand->image_info_stack;
for ( ; node != (Stack *)NULL; node=node->next)
size++;
- if ( size >= MaxImageStackDepth )
- {
- ThrowMagickException(exception,GetMagickModule(),
- OptionError,"ParenthesisNestedTooDeeply", option);
- return;
- }
+ if ( size >= MAX_STACK_DEPTH ) {
+ ThrowMagickException(exception,GetMagickModule(),
+ OptionError,"ParenthesisNestedTooDeeply", option);
+ return;
+ }
node=(Stack *) AcquireMagickMemory(sizeof(*node));
- if (node == (Stack *) NULL)
- {
- ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitFatalError,"MemoryAllocationFailed", "PushSettings");
- return;
- }
+ if (node == (Stack *) NULL) {
+ ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitFatalError,"MemoryAllocationFailed", "PushSettings");
+ return;
+ }
node->data = (void *)cli_wand->wand.image_info;
cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
- if (cli_wand->wand.image_info == (ImageInfo *)NULL)
- {
- ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitFatalError,"MemoryAllocationFailed", "PushSettings");
- cli_wand->wand.image_info = (ImageInfo *)node->data;
- node = (Stack *)RelinquishMagickMemory(node);
- return;
- }
+ if (cli_wand->wand.image_info == (ImageInfo *)NULL) {
+ ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitFatalError,"MemoryAllocationFailed", "PushSettings");
+ cli_wand->wand.image_info = (ImageInfo *)node->data;
+ node = (Stack *)RelinquishMagickMemory(node);
+ return;
+ }
node->next = cli_wand->image_info_stack;
cli_wand->image_info_stack = node;
return;
}
- if (LocaleCompare(option,")") == 0)
+ if (LocaleCompare(")",option) == 0)
{
/* pop images from stack */
Stack
else
return;
}
- if (LocaleCompare(option,"}") == 0)
+ if (LocaleCompare("}",option) == 0)
{
/* pop image_info settings from stack */
Stack
return;
}
- if (LocaleCompare(option+1,"clone") == 0)
+ if (LocaleCompare("clone",option+1) == 0)
{
Image
*new_images;
AppendImageToList(&cli_wand->wand.images,new_images);
return;
}
- if ( LocaleCompare("-read",option) == 0 )
+ if ( LocaleCompare("read",option+1) == 0 )
{
-#if 0
+#if !USE_WAND_METHODS
Image *
new_images;
- CopyMagickString(cli_wand->wand.image_info->filename,arg,MaxTextExtent);
if (cli_wand->wand.image_info->ping != MagickFalse)
- new_images=PingImages(cli_wand->wand.image_info,exception);
+ new_images=PingImages(cli_wand->wand.image_info,arg,exception);
else
- new_images=ReadImages(cli_wand->wand.image_info,exception);
+ new_images=ReadImages(cli_wand->wand.image_info,arg,exception);
AppendImageToList(&cli_wand->wand.images, new_images);
#else
/* read images using MagickWand method - no ping */
#endif
return;
}
- if (LocaleCompare("-noop",option) == 0)
+ /* No-op options */
+ if (LocaleCompare("noop",option+1) == 0)
return;
- if (LocaleCompare("-sans",option) == 0)
+ if (LocaleCompare("sans",option+1) == 0)
return;
- if (LocaleCompare("-sans0",option) == 0)
+ if (LocaleCompare("sans0",option+1) == 0)
return;
- if (LocaleCompare("-sans2",option) == 0)
+ if (LocaleCompare("sans2",option+1) == 0)
return;
- if (LocaleCompare("-list",option) == 0)
+ if (LocaleCompare("list",option+1) == 0)
{
/* FUTURE: This should really be built into the MagickCore
It does not actually require any wand or images at all!