/* verbose debugging,
1 - option type
2 - source of option
- 3 - mnemonic lookup */
+ 3 - mnemonic lookup
+ 4 - output options/artifacts
+*/
#define MagickCommandDebug 0
#define ThrowFileException(exception,severity,tag,context) \
tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \
message=DestroyString(message); \
}
+
+#if MagickCommandDebug >= 4
+static void OutputOptions(ImageInfo *image_info)
+{
+ const char
+ *option,
+ *value;
+
+ (void) FormatLocaleFile(stdout," Image_Info Options:\n");
+ ResetImageOptionIterator(image_info);
+ while ((option=GetNextImageOption(image_info)) != (const char *) NULL ) {
+ (void) FormatLocaleFile(stdout," %s: ",option);
+ value=GetImageOption(image_info,option);
+ if (value != (const char *) NULL)
+ (void) FormatLocaleFile(stdout,"%s\n",value);
+ }
+ ResetImageOptionIterator(image_info);
+}
+
+static void OutputArtifacts(Image *image)
+{
+ const char
+ *artifact,
+ *value;
+
+ (void) FormatLocaleFile(stdout," Image Artifacts:\n");
+ ResetImageArtifactIterator(image);
+ while ((artifact=GetNextImageArtifact(image)) != (const char *) NULL ) {
+ (void) FormatLocaleFile(stdout," %s: ",artifact);
+ value=GetImageArtifact(image,artifact);
+ if (value != (const char *) NULL)
+ (void) FormatLocaleFile(stdout,"%s\n",value);
+ }
+ ResetImageArtifactIterator(image);
+}
+#endif
+
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#if MagickCommandDebug
(void) FormatLocaleFile(stderr, "Script Non-Option: \"%s\"\n", option);
#endif
- if ( IsCommandOption(option) == MagickFalse) {
+ if ( IsCommandOption(option) == MagickFalse)
/* non-option -- treat as a image read */
CLISpecialOperator(cli_wand,"-read",option);
- count = 0;
- }
else
CLIWandExceptionBreak(OptionFatalError,"UnrecognizedOption",option);
-
- if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
- break;
- continue;
+ count = 0;
+ goto next_token;
}
if ( count >= 1 ) {
if( GetScriptToken(token_info) == MagickFalse )
- CLIWandExceptionBreak(OptionFatalError,"MissingArgument",option);
+ CLIWandException(OptionFatalError,"MissingArgument",option);
CloneString(&arg1,token_info->token);
}
else
if ( (option_type & SettingOptionFlags) != 0 ) {
CLISettingOptionInfo(cli_wand, option, arg1);
- // FUTURE: Sync Specific Settings into Images
+ // FUTURE: Sync Specific Settings into Image Properities (not global)
}
if ( (option_type & SimpleOperatorOptionFlag) != 0)
if ( (option_type & ListOperatorOptionFlag) != 0 )
CLIListOperatorImages(cli_wand, option, arg1, arg2);
+next_token:
+#if MagickCommandDebug >= 4
+ OutputOptions(cli_wand->wand.image_info);
+ if ( cli_wand->wand.images != (Image *)NULL )
+ OutputArtifacts(cli_wand->wand.images);
+#endif
if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
break;
}
(void) FormatLocaleFile(stderr, "CLI Non-Option: \"%s\"\n", option);
#endif
if ( ( IsCommandOption(option) == MagickFalse ) &&
- ( (process_flags & ProcessNonOptionImageRead) != 0 ) ) {
+ ( (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 )
- return(i+1);
-
- continue;
+ count = 0;
+ goto next_argument;
}
if ( (option_type & DeprecateOptionFlag) != 0 ) {
CLIWandException(OptionFatalError,"MissingArgument",option);
if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
return(end);
- continue; /* no arguments unable to proceed */
+ goto next_argument; /* no more arguments unable to proceed */
}
arg1 = ( count >= 1 ) ? argv[i+1] : (char *)NULL;
if ( (option_type & SettingOptionFlags) != 0 ) {
CLISettingOptionInfo(cli_wand, option, arg1);
- // FUTURE: Sync Specific Settings into Images
+ // FUTURE: Sync Specific Settings into Image Properities (not global)
}
if ( (option_type & SimpleOperatorOptionFlag) != 0)
if ( (option_type & ListOperatorOptionFlag) != 0 )
CLIListOperatorImages(cli_wand, option, arg1, arg2);
+next_argument:
+#if MagickCommandDebug >= 4
+ OutputOptions(cli_wand->wand.image_info);
+ if ( cli_wand->wand.images != (Image *)NULL )
+ OutputArtifacts(cli_wand->wand.images);
+#endif
if ( CLICatchException(cli_wand, MagickFalse) != MagickFalse )
return(i+count);
}
% The format of the CLISettingOptionInfo method is:
%
% void CLISettingOptionInfo(MagickCLI *cli_wand,
-% const char *option, const char *arg)
+% const char *option, const char *arg1)
%
% A description of each parameter follows:
%
%
% o option: The option string to be set
%
-% o arg: The single argument used to set this option.
+% o arg1: The single argument used to set this option.
%
% Example usage...
%
% CLISettingOptionInfo(cli_wand, "-adjoin", NULL); // set boolean
% CLISettingOptionInfo(cli_wand, "+adjoin", NULL); // unset
%
-% Or for handling command line arguments EG: +/-option ["arg"]
+% Or for handling command line arguments EG: +/-option ["arg1"]
%
% argc,argv
% i=index in argv
%
*/
WandExport void CLISettingOptionInfo(MagickCLI *cli_wand,
- const char *option,const char *arg)
+ const char *option,const char *arg1)
{
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
if (cli_wand->wand.debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
-#define image_info (cli_wand->wand.image_info)
-#define exception (cli_wand->wand.exception)
-#define draw_info (cli_wand->draw_info)
-#define quantize_info (cli_wand->quantize_info)
-#define IfSetOption (*option=='-')
-#define ArgOption(def) (IfSetOption?arg:(const char *)(def))
-#define ArgBoolean (IfSetOption?MagickTrue:MagickFalse)
-#define ArgBooleanNot (IfSetOption?MagickFalse:MagickTrue)
+#define image_info (cli_wand->wand.image_info)
+#define exception (cli_wand->wand.exception)
+#define draw_info (cli_wand->draw_info)
+#define quantize_info (cli_wand->quantize_info)
+#define IfSetOption (*option=='-')
+#define ArgBoolean (IfSetOption?MagickTrue:MagickFalse)
+#define ArgBooleanNot (IfSetOption?MagickFalse:MagickTrue)
+#define ArgBooleanString (IfSetOption?"true":"false")
+#define ArgOption(def) (IfSetOption?arg1:(const char *)(def))
switch (*(option+1))
{
{
/* DEPRECIATED: draw_info setting only: for -draw and -transform */
if (IfSetOption)
- (void) ParseAffineGeometry(arg,&draw_info->affine,exception);
+ (void) ParseAffineGeometry(arg1,&draw_info->affine,exception);
else
GetAffineMatrix(&draw_info->affine);
break;
}
if (LocaleCompare("attenuate",option+1) == 0)
{
- (void) SetImageOption(image_info,option+1,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgBooleanString);
break;
}
if (LocaleCompare("authenticate",option+1) == 0)
/* Used as a image chromaticity setting
SyncImageSettings() used to set per-image attribute.
*/
- (void) SetImageOption(image_info,option+1,
- IfSetOption ? "true" : "false" );
+ (void) SetImageOption(image_info,option+1,ArgBooleanString);
break;
}
if (LocaleCompare("blue-primary",option+1) == 0)
*/
if (IfSetOption)
{
- (void) SetImageOption(image_info,option+1,arg);
- (void) QueryColorCompliance(arg,AllCompliance,
+ (void) SetImageOption(image_info,option+1,arg1);
+ (void) QueryColorCompliance(arg1,AllCompliance,
&image_info->border_color,exception);
- (void) QueryColorCompliance(arg,AllCompliance,
+ (void) QueryColorCompliance(arg1,AllCompliance,
&draw_info->border_color,exception);
break;
}
if (LocaleCompare("box",option+1) == 0)
{
/* DEPRECIATED - now "undercolor" */
- CLISettingOptionInfo(cli_wand,"undercolor",arg);
+ CLISettingOptionInfo(cli_wand,"undercolor",arg1);
break;
}
break;
limit;
limit=MagickResourceInfinity;
- if (LocaleCompare("unlimited",arg) != 0)
- limit=(MagickSizeType) SiPrefixToDoubleInterval(arg,100.0);
+ if (LocaleCompare("unlimited",arg1) != 0)
+ limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0);
(void) SetMagickResourceLimit(MemoryResource,limit);
(void) SetMagickResourceLimit(MapResource,2*limit);
break;
if (LocaleCompare("channel",option+1) == 0)
{
/* FUTURE: -channel mask {vaules}
- This is applied to images in SimpleImageOperator!!!
+ This is also applied to images in SimpleImageOperator!!!
Move it to SyncImageSettings() - or alternative
*/
image_info->channel=(ChannelType) (
- IfSetOption ? ParseChannelOption(arg) : DefaultChannels );
+ IfSetOption ? ParseChannelOption(arg1) : DefaultChannels );
break;
}
if (LocaleCompare("colorspace",option+1) == 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!
- */
- if (LocaleNCompare(arg,"registry:",9) == 0)
+ if (LocaleNCompare(arg1,"registry:",9) == 0)
{
if (IfSetOption)
- (void) DefineImageRegistry(StringRegistryType,arg+9,exception);
+ (void) DefineImageRegistry(StringRegistryType,arg1+9,exception);
else
- (void) DeleteImageRegistry(arg+9);
+ (void) DeleteImageRegistry(arg1+9);
break;
}
+ /* DefineImageOption() equals SetImageOption() but with '=' */
if (IfSetOption)
- (void) DefineImageOption(image_info,arg);
+ (void) DefineImageOption(image_info,arg1);
else
- (void) DeleteImageOption(image_info,arg);
+ (void) DeleteImageOption(image_info,arg1);
break;
}
if (LocaleCompare("delay",option+1) == 0)
/* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!!
SyncImageSettings() used to set per-image attribute.
*/
- image_info->depth=IfSetOption?StringToUnsignedLong(arg)
+ image_info->depth=IfSetOption?StringToUnsignedLong(arg1)
:MAGICKCORE_QUANTUM_DEPTH;
break;
}
register const char
*q;
- for (q=strchr(arg,'%'); q != (char *) NULL; q=strchr(q+1,'%'))
+ for (q=strchr(arg1,'%'); q != (char *) NULL; q=strchr(q+1,'%'))
if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
image_info->ping=MagickFalse;
*/
*/
if (IfSetOption)
{
- image_info->fuzz=StringToDoubleInterval(arg,(double)
+ image_info->fuzz=StringToDoubleInterval(arg1,(double)
QuantumRange+1.0);
- (void) SetImageOption(image_info,option+1,arg);
+ (void) SetImageOption(image_info,option+1,arg1);
break;
}
image_info->fuzz=0.0;
if (LocaleCompare("log",option+1) == 0)
{
if (IfSetOption)
- (void) SetLogFormat(arg);
+ (void) SetLogFormat(arg1);
break;
}
if (LocaleCompare("loop",option+1) == 0)
}
if (LocaleCompare("monochrome",option+1) == 0)
{
- /* Setting (for some input coders)
- But also a special 'type' operator
+ /* Setting (used by some input coders!) -- why?
+ Warning: This is also Special '-type' SimpleOperator
*/
image_info->monochrome= ArgBoolean;
break;
image_option=GetImageOption(image_info,"page");
if (image_option != (const char *) NULL)
flags=ParseAbsoluteGeometry(image_option,&geometry);
- canonical_page=GetPageGeometry(arg);
+ canonical_page=GetPageGeometry(arg1);
flags=ParseAbsoluteGeometry(canonical_page,&geometry);
canonical_page=DestroyString(canonical_page);
(void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
image_info->preview_type=UndefinedPreview;
if (IfSetOption)
image_info->preview_type=(PreviewType) ParseCommandOption(
- MagickPreviewOptions,MagickFalse,arg);
+ MagickPreviewOptions,MagickFalse,arg1);
break;
}
*/
(void) SetImageOption(image_info,option+1,ArgOption(NULL));
image_info->quality=UNDEFINED_COMPRESSION_QUALITY;
if (IfSetOption)
- image_info->quality=StringToUnsignedLong(arg);
+ image_info->quality=StringToUnsignedLong(arg1);
break;
}
if (LocaleCompare("quantize",option+1) == 0)
quantize_info->colorspace=UndefinedColorspace;
if (IfSetOption)
quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
- MagickColorspaceOptions,MagickFalse,arg);
+ MagickColorspaceOptions,MagickFalse,arg1);
break;
}
if (LocaleCompare("quiet",option+1) == 0)
if (LocaleCompare("seed",option+1) == 0)
{
SeedPseudoRandomGenerator(
- IfSetOption ? (size_t) StringToUnsignedLong(arg)
+ IfSetOption ? (size_t) StringToUnsignedLong(arg1)
: (size_t) time((time_t *) NULL) );
break;
}
if (LocaleCompare("taint",option+1) == 0)
{
/* SyncImageSettings() used to set per-image attribute. */
- (void) SetImageOption(image_info,option+1,
- IfSetOption ? "true" : "false");
+ (void) SetImageOption(image_info,option+1,ArgBooleanString);
break;
}
if (LocaleCompare("texture",option+1) == 0)
if (LocaleCompare("tile",option+1) == 0)
{
draw_info->fill_pattern=IfSetOption
- ?GetImageCache(image_info,arg,exception)
+ ?GetImageCache(image_info,arg1,exception)
:DestroyImage(draw_info->fill_pattern);
break;
}
{
if (LocaleCompare("verbose",option+1) == 0)
{
- /* FUTURE: Also an image artifact, set in Simple Operators.
- But artifact is only used in verbose output.
+ /* FUTURE: Remember all options become image artifacts
+ image_info->verbose is only used by coders.
*/
- (void) SetImageOption(image_info,option+1,ArgOption(NULL));
+ (void) SetImageOption(image_info,option+1,ArgBooleanString);
image_info->verbose= ArgBoolean;
image_info->ping=MagickFalse; /* verbose can't be a ping */
break;
*/
if (!IfSetOption)
break;
- draw_info->weight=StringToUnsignedLong(arg);
- if (LocaleCompare(arg,"all") == 0)
+ draw_info->weight=StringToUnsignedLong(arg1);
+ if (LocaleCompare(arg1,"all") == 0)
draw_info->weight=0;
- if (LocaleCompare(arg,"bold") == 0)
+ if (LocaleCompare(arg1,"bold") == 0)
draw_info->weight=700;
- if (LocaleCompare(arg,"bolder") == 0)
+ if (LocaleCompare(arg1,"bolder") == 0)
if (draw_info->weight <= 800)
draw_info->weight+=100;
- if (LocaleCompare(arg,"lighter") == 0)
+ if (LocaleCompare(arg1,"lighter") == 0)
if (draw_info->weight >= 100)
draw_info->weight-=100;
- if (LocaleCompare(arg,"normal") == 0)
+ if (LocaleCompare(arg1,"normal") == 0)
draw_info->weight=400;
break;
}
default:
break;
}
+
#undef image_info
#undef exception
#undef draw_info
#undef quantize_info
#undef IfSetOption
-#undef ArgOption
#undef ArgBoolean
+#undef ArgBooleanNot
+#undef ArgBooleanString
+#undef ArgOption
return;
}
% CLISimpleOperatorImages(cli_wand, "+repage",NULL,NULL);
% CLISimpleOperatorImages(cli_wand, "+distort","SRT","45");
%
-% Or for handling command line arguments EG: +/-option ["arg"]
+% Or for handling command line arguments EG: +/-option ["arg1"]
%
% cli_wand
% argc,argv
if (cli_wand->wand.debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
+ (void) SyncImageSettings(image_info,image,exception);
+
SetGeometryInfo(&geometry_info);
new_image = (Image *)NULL; /* the replacement image, if not null at end */
/* FUTURE: We may need somthing a little more optimized than this!
Perhaps, do the 'sync' if 'settings tainted' before next operator.
*/
- (void) SyncImageSettings(image_info,image,exception);
-
switch (*(option+1))
{
case 'a':
if (LocaleCompare("channel",option+1) == 0)
{
/* The "channel" setting has already been set
- FUTURE: This probably should be part of WandSettingOptionInfo()
- or SyncImageSettings().
+ FUTURE: This probably should be part of SyncImageSettings().
*/
SetPixelChannelMapMask(image,image_info->channel);
break;
if (LocaleCompare("unique",option+1) == 0)
{
/* FUTURE: move to SyncImageSettings() and AcqireImage()??? */
+ /* FUTURE: This option is not documented!!!!! */
if (!normal_op)
{
(void) DeleteImageArtifact(image,"identify:unique-colors");
% CLIListOperatorImages(cli_wand,MagickFalse,"-duplicate", "3", NULL);
% CLIListOperatorImages(cli_wand,MagickTrue, "+append", NULL, NULL);
%
-% Or for handling command line arguments EG: +/-option ["arg"]
+% Or for handling command line arguments EG: +/-option ["arg1"]
%
% cli_wand
% argc,argv
char
*string;
- string=InterpretImageProperties(image_info,images,arg1,
- exception);
+ string=InterpretImageProperties(image_info,images,arg1,exception);
if (string == (char *) NULL)
break;
(void) FormatLocaleFile(stdout,"%s",string);
string=DestroyString(string);
+ break;
}
if (LocaleCompare("process",option+1) == 0)
{
*token_info;
/*
- Support old style syntax, filter="-option arg".
+ Support old style syntax, filter="-option arg1".
*/
length=strlen(arg1);
token=(char *) NULL;
% The format of the CLISpecialOption method is:
%
% void CLISpecialOption(MagickCLI *cli_wand,const char *option,
-% const char *arg)
+% const char *arg1)
%
% A description of each parameter follows:
%
%
% o option: The special option (with any switch char) to process
%
-% o arg: Argument for option, if required
+% o arg1: Argument for option, if required
%
% Example Usage...
%
% CLISpecialOperator(cli_wand,"-read", "rose:");
%
-% Or for handling command line arguments EG: +/-option ["arg"]
+% Or for handling command line arguments EG: +/-option ["arg1"]
%
% cli_wand
% argc,argv
*/
WandExport void CLISpecialOperator(MagickCLI *cli_wand,
- const char *option, const char *arg)
+ const char *option, const char *arg1)
{
#define exception (cli_wand->wand.exception)
if (cli_wand->wand.debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
+ if(cli_wand->wand.images != (Image *)NULL)
+ (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images,
+ exception);
+
if (LocaleCompare("(",option) == 0)
{
/* stack 'push' images */
*new_images;
if (*option == '+')
- arg="-1";
- if (IsSceneGeometry(arg,MagickFalse) == MagickFalse)
+ arg1="-1";
+ if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
{
ThrowMagickException(exception,GetMagickModule(),
- OptionError,"InvalidArgument", "'%s': %s", option, arg);
+ OptionError,"InvalidArgument", "'%s': %s", option, arg1);
return;
}
if ( cli_wand->image_list_stack == (Stack *)NULL)
OptionError,"UnableToCloneImage", option);
return;
}
- new_images=CloneImages(new_images,arg,exception);
+ new_images=CloneImages(new_images,arg1,exception);
if (new_images == (Image *) NULL)
{
ThrowMagickException(exception,GetMagickModule(),
new_images;
if (cli_wand->wand.image_info->ping != MagickFalse)
- new_images=PingImages(cli_wand->wand.image_info,arg,exception);
+ new_images=PingImages(cli_wand->wand.image_info,arg1,exception);
else
- new_images=ReadImages(cli_wand->wand.image_info,arg,exception);
+ new_images=ReadImages(cli_wand->wand.image_info,arg1,exception);
AppendImageToList(&cli_wand->wand.images, new_images);
#else
/* read images using MagickWand method - no ping */
/* This is not working! - it locks up in a CPU loop! */
MagickSetLastIterator(&cli_wand->wand);
- MagickReadImage(&cli_wand->wand,arg);
+ MagickReadImage(&cli_wand->wand,arg1);
MagickSetFirstIterator(&cli_wand->wand);
#endif
return;
ssize_t
list;
- list=ParseCommandOption(MagickListOptions,MagickFalse, arg);
+ list=ParseCommandOption(MagickListOptions,MagickFalse, arg1);
switch (list)
{
case MagickCoderOptions: