{ "-auto-orient", 0L, SimpleOperatorFlag, MagickFalse },
{ "+average", 0L, DeprecateOptionFlag, MagickTrue },
{ "-average", 0L, ReplacedOptionFlag | ListOperatorFlag | FireOptionFlag, MagickTrue },
- { "+backdrop", 0L, NonMagickOptionFlag, MagickFalse },
- { "-backdrop", 1L, NonMagickOptionFlag, MagickFalse },
+ { "+backdrop", 0L, NonMagickOptionFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-backdrop", 1L, NonMagickOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+background", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-background", 1L, ImageInfoOptionFlag, MagickFalse },
{ "+bench", 1L, DeprecateOptionFlag, MagickTrue },
{ "-brightness-contrast", 1L, SimpleOperatorFlag, MagickFalse },
{ "+cache", 0L, GlobalOptionFlag, MagickFalse },
{ "-cache", 1L, GlobalOptionFlag, MagickFalse },
- { "+caption", 0L, ImageInfoOptionFlag, MagickFalse },
- { "-caption", 1L, ImageInfoOptionFlag, MagickFalse },
+ { "+caption", 0L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-caption", 1L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+cdl", 1L, DeprecateOptionFlag, MagickTrue },
- { "-cdl", 1L, SimpleOperatorFlag, MagickFalse },
+ { "-cdl", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+channel", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-channel", 1L, ImageInfoOptionFlag, MagickFalse },
{ "-channel-fx", 1L, ListOperatorFlag | FireOptionFlag, MagickFalse },
{ "-clamp", 0L, SimpleOperatorFlag, MagickFalse },
{ "+clip", 0L, SimpleOperatorFlag, MagickFalse },
{ "-clip", 0L, SimpleOperatorFlag, MagickFalse },
- { "+clip-mask", 0L, SimpleOperatorFlag, MagickFalse },
- { "-clip-mask", 1L, SimpleOperatorFlag, MagickFalse },
+ { "+clip-mask", 0L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-clip-mask", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+clip-path", 1L, SimpleOperatorFlag, MagickFalse },
{ "-clip-path", 1L, SimpleOperatorFlag, MagickFalse },
{ "+clone", 0L, NoImageOperatorFlag, MagickFalse },
{ "-colorspace", 1L, ImageInfoOptionFlag | SimpleOperatorFlag, MagickFalse },
{ "+combine", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue },
{ "-combine", 0L, ListOperatorFlag | FireOptionFlag, MagickFalse },
- { "+comment", 0L, ImageInfoOptionFlag, MagickFalse },
- { "-comment", 1L, ImageInfoOptionFlag, MagickFalse },
+ { "+comment", 0L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-comment", 1L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+compose", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-compose", 1L, ImageInfoOptionFlag, MagickFalse },
{ "+composite", 0L, DeprecateOptionFlag | FireOptionFlag, MagickTrue },
{ "+debug", 0L, GlobalOptionFlag | FireOptionFlag, MagickFalse },
{ "-debug", 1L, GlobalOptionFlag | FireOptionFlag, MagickFalse },
{ "+decipher", 1L, DeprecateOptionFlag, MagickTrue },
- { "-decipher", 1L, SimpleOperatorFlag, MagickFalse },
+ { "-decipher", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+deconstruct", 0L, DeprecateOptionFlag, MagickTrue },
{ "-deconstruct", 0L, ReplacedOptionFlag | ListOperatorFlag | FireOptionFlag, MagickTrue },
{ "+define", 1L, ImageInfoOptionFlag, MagickFalse },
{ "+emboss", 1L, DeprecateOptionFlag, MagickTrue },
{ "-emboss", 1L, SimpleOperatorFlag, MagickFalse },
{ "+encipher", 1L, DeprecateOptionFlag, MagickTrue },
- { "-encipher", 1L, SimpleOperatorFlag, MagickFalse },
+ { "-encipher", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+encoding", 0L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse },
{ "-encoding", 1L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse },
{ "+endian", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-interword-spacing", 1L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse },
{ "+kerning", 0L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse },
{ "-kerning", 1L, ImageInfoOptionFlag | DrawInfoOptionFlag, MagickFalse },
- { "+label", 0L, ImageInfoOptionFlag, MagickFalse },
- { "-label", 1L, ImageInfoOptionFlag, MagickFalse },
+ { "+label", 0L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-label", 1L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+lat", 1L, DeprecateOptionFlag, MagickTrue },
{ "-lat", 1L, SimpleOperatorFlag, MagickFalse },
{ "+layers", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue },
{ "-magnify", 1L, NonMagickOptionFlag, MagickFalse },
{ "+map", 0L, ReplacedOptionFlag | ListOperatorFlag | FireOptionFlag, MagickTrue },
{ "-map", 1L, ReplacedOptionFlag | SimpleOperatorFlag, MagickTrue },
- { "+mask", 0L, SimpleOperatorFlag, MagickFalse },
- { "-mask", 1L, SimpleOperatorFlag, MagickFalse },
+ { "+mask", 0L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-mask", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+matte", 0L, ReplacedOptionFlag | SimpleOperatorFlag, MagickTrue },
{ "-matte", 0L, ReplacedOptionFlag | SimpleOperatorFlag, MagickTrue },
{ "+mattecolor", 0L, ImageInfoOptionFlag, MagickFalse },
{ "+process", 1L, DeprecateOptionFlag | FireOptionFlag, MagickTrue },
{ "-process", 1L, ListOperatorFlag | FireOptionFlag, MagickFalse },
{ "+profile", 1L, SimpleOperatorFlag, MagickFalse },
- { "-profile", 1L, SimpleOperatorFlag, MagickFalse },
+ { "-profile", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+quality", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-quality", 1L, ImageInfoOptionFlag, MagickFalse },
{ "+quantize", 0L, QuantizeInfoOptionFlag, MagickFalse },
{ "-raise", 1L, SimpleOperatorFlag, MagickFalse },
{ "+random-threshold", 1L, DeprecateOptionFlag, MagickTrue },
{ "-random-threshold", 1L, SimpleOperatorFlag, MagickFalse },
- { "-read", 1L, NoImageOperatorFlag, MagickFalse },
+ { "-read", 1L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+recolor", 1L, DeprecateOptionFlag, MagickTrue },
{ "-recolor", 1L, ReplacedOptionFlag | SimpleOperatorFlag, MagickTrue },
{ "+red-primary", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-regard-warnings", 0L, ImageInfoOptionFlag, MagickFalse },
{ "+region", 0L, NoImageOperatorFlag, MagickFalse },
{ "-region", 1L, NoImageOperatorFlag, MagickFalse },
- { "+remap", 0L, ListOperatorFlag | FireOptionFlag, MagickFalse },
- { "-remap", 1L, SimpleOperatorFlag, MagickFalse },
+ { "+remap", 0L, ListOperatorFlag | NeverInterpretArgsFlag | FireOptionFlag, MagickFalse },
+ { "-remap", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+remote", 0L, NonMagickOptionFlag, MagickFalse },
{ "-remote", 1L, NonMagickOptionFlag, MagickFalse },
{ "+render", 0L, DrawInfoOptionFlag, MagickFalse },
{ "-sample", 1L, SimpleOperatorFlag, MagickFalse },
{ "+sampling-factor", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-sampling-factor", 1L, ImageInfoOptionFlag, MagickFalse },
- { "+sans", 1L, NoImageOperatorFlag, MagickTrue },
- { "-sans", 1L, NoImageOperatorFlag, MagickTrue },
- { "+sans0", 0L, NoImageOperatorFlag, MagickTrue }, /* equivelent to 'noop' */
- { "-sans0", 0L, NoImageOperatorFlag, MagickTrue },
- { "+sans2", 2L, NoImageOperatorFlag, MagickTrue },
- { "-sans2", 2L, NoImageOperatorFlag, MagickTrue },
+ { "+sans", 1L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickTrue },
+ { "-sans", 1L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickTrue },
+ { "+sans0", 0L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickTrue }, /* equivelent to 'noop' */
+ { "-sans0", 0L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickTrue },
+ { "+sans2", 2L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickTrue },
+ { "-sans2", 2L, NoImageOperatorFlag | NeverInterpretArgsFlag, MagickTrue },
{ "+scale", 1L, DeprecateOptionFlag, MagickTrue },
{ "-scale", 1L, SimpleOperatorFlag, MagickFalse },
{ "+scene", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-scenes", 1L, NonMagickOptionFlag, MagickFalse },
{ "+screen", 0L, NonMagickOptionFlag, MagickFalse },
{ "-screen", 1L, NonMagickOptionFlag, MagickFalse },
- { "-script", 1L, SpecialOptionFlag, MagickFalse },
+ { "-script", 1L, SpecialOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+seed", 0L, GlobalOptionFlag, MagickFalse },
{ "-seed", 1L, GlobalOptionFlag, MagickFalse },
{ "+segment", 1L, DeprecateOptionFlag, MagickTrue },
{ "+text-font", 0L, NonMagickOptionFlag, MagickFalse },
{ "-text-font", 1L, NonMagickOptionFlag, MagickFalse },
{ "+texture", 0L, ImageInfoOptionFlag, MagickFalse },
- { "-texture", 1L, ImageInfoOptionFlag, MagickFalse },
+ { "-texture", 1L, ImageInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+threshold", 0L, SimpleOperatorFlag, MagickFalse },
{ "-threshold", 1L, SimpleOperatorFlag, MagickFalse },
{ "+thumbnail", 1L, DeprecateOptionFlag, MagickTrue },
{ "-thumbnail", 1L, SimpleOperatorFlag, MagickFalse },
- { "+tile", 0L, DrawInfoOptionFlag, MagickFalse },
- { "-tile", 1L, DrawInfoOptionFlag, MagickFalse },
+ { "+tile", 0L, DrawInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
+ { "-tile", 1L, DrawInfoOptionFlag | NeverInterpretArgsFlag, MagickFalse },
{ "+tile-offset", 0L, ImageInfoOptionFlag, MagickFalse },
{ "-tile-offset", 1L, ImageInfoOptionFlag, MagickFalse },
{ "+tint", 1L, SimpleOperatorFlag, MagickFalse },
{ "-window", 1L, NonMagickOptionFlag, MagickFalse },
{ "+window-group", 0L, NonMagickOptionFlag, MagickFalse },
{ "-window-group", 1L, NonMagickOptionFlag, MagickFalse },
- { "+write", 1L, NoImageOperatorFlag | FireOptionFlag, MagickFalse },
- { "-write", 1L, NoImageOperatorFlag | FireOptionFlag, MagickFalse },
+ { "+write", 1L, NoImageOperatorFlag | NeverInterpretArgsFlag | FireOptionFlag, MagickFalse },
+ { "-write", 1L, NoImageOperatorFlag | NeverInterpretArgsFlag | FireOptionFlag, MagickFalse },
{ (char *) NULL, 0L, UndefinedOptionFlag, MagickFalse }
},
ComposeOptions[] =
#define ArgBooleanString (IfSetOption?"true":"false")
#define ArgOption(def) (IfSetOption?arg1:(const char *)(def))
+#if 0
+Setting are not directly involved with images, so can not
+interpret Percent Escapes in Arguments, At least not yet */
+
+#define _process_flags (cli_wand->process_flags)
+#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
+ /* Interpret Percent Escapes in Arguments - using first image */
+ arg1 = arg1n,
+ arg2 = arg2n;
+ if ( (((_process_flags & ProcessInterpretProperities) != 0 )
+ || ((_option_type & AlwaysInterpretArgsFlag) != 0)
+ ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
+ /* Interpret Percent escapes in argument 1 */
+ if (arg1n != (char *) NULL) {
+ arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception);
+ if (arg1 == (char *) NULL) {
+ CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
+ arg1=arg1n; /* use the given argument as is */
+ }
+ }
+ if (arg2n != (char *) NULL) {
+ arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception);
+ if (arg2 == (char *) NULL) {
+ CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
+ arg2=arg2n; /* use the given argument as is */
+ }
+ }
+ }
+#undef _process_flags
+#undef _option_type
+#endif
+
switch (*(option+1))
{
case 'a':
}
if (LocaleCompare("texture",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
/* FUTURE: move _image_info string to option splay-tree
Other than "montage" what uses "texture" ????
*/
}
if (LocaleCompare("tile",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
_draw_info->fill_pattern=IfSetOption
?GetImageCache(_image_info,arg1,_exception)
:DestroyImage(_draw_info->fill_pattern);
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
+#if 0
+ /* clean up percent escape interpreted strings */
+ if (arg1 != arg1n )
+ arg1=DestroyString((char *)arg1);
+ if (arg2 != arg2n )
+ arg2=DestroyString((char *)arg2);
+#endif
+
#undef _image_info
#undef _exception
#undef _draw_info
}
}
}
+#undef _process_flags
#undef _option_type
#if 0
{
if (LocaleCompare("cdl",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
char
*color_correction_collection;
}
if (LocaleCompare("clip-mask",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
CacheView
*mask_view;
y;
if (IfPlusOp) {
- /* "+clip-mask" Remove the write mask */
+ /* use "+clip-mask" Remove the write mask for -clip-path */
(void) SetImageMask(_image,(Image *) NULL,_exception);
break;
}
if (LocaleCompare("clip-path",option+1) == 0)
{
(void) ClipImagePath(_image,arg1,normal_op,_exception);
+ /* Note: Use "+clip-mask" remove the write mask added */
break;
}
if (LocaleCompare("colorize",option+1) == 0)
{
if (LocaleCompare("decipher",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
StringInfo
*passkey;
}
if (LocaleCompare("encipher",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
StringInfo
*passkey;
}
if (LocaleCompare("mask",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
Image
*mask;
}
if (LocaleCompare("profile",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
const char
*name;
}
if (LocaleCompare("remap",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
Image
*remap_image;
}
if (LocaleCompare("set",option+1) == 0)
{
+ /* Note: arguments do not have percent escapes expanded */
char
*value;
}
}
}
+#undef _process_flags
#undef _option_type
#if 0
% CLINoImageOperator() Applies operations that may not actually need images
% in an image list.
%
-% The classic operators of this type is -read, which actually creates images
-% even when no images are present. Or image stack operators, which can be
-% applied (push or pop) to an empty image list.
+% The classic operators of this type is "-read", which actually creates
+% images even when no images are present. Or image stack operators, which
+% can be applied (push or pop) to an empty image list.
%
-% Note: unlike other Operators, these may involve other special 'option'
-% characters other than '-' or '+', namely parenthesis and braces.
+% Note that these operators may involve other special 'option' prefix
+% characters other than '-' or '+', namely parenthesis and braces.
%
% The format of the CLINoImageOption method is:
%
WandExport void CLINoImageOperator(MagickCLI *cli_wand,
const char *option, const char *arg1, const char *magick_unused(arg2))
{
+#if 0
+ const char /* For percent escape interpretImageProperties() */
+ *arg1,
+ *arg2;
+#endif
+
#define _image_info (cli_wand->wand.image_info)
#define _images (cli_wand->wand.images)
#define _exception (cli_wand->wand.exception)
if (IfMagickTrue(cli_wand->wand.debug))
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
- /*
- No-op options (ignore these)
- */
- if (LocaleCompare("noop",option+1) == 0) /* no argument */
- return;
- if (LocaleCompare("sans",option+1) == 0) /* one argument */
- return;
- if (LocaleCompare("sans0",option+1) == 0) /* no argument */
- return;
- if (LocaleCompare("sans2",option+1) == 0) /* two arguments */
- return;
- /*
- Image Reading
- */
- if ( ( LocaleCompare("read",option+1) == 0 ) ||
- ( LocaleCompare("--",option) == 0 ) ) {
#if 0
- /* Directly read 'arg1' without filename expansion handling (see below).
- */
-# if !USE_WAND_METHODS
- Image *new_images;
+ Not able to be used as their may not be any images!
+ Also the only option that may have arguments that can be percent escaped is
+ "-clone".
- if (IfMagickTrue(_image_info->ping))
- new_images=PingImages(_image_info,arg1,_exception);
- else
- new_images=ReadImages(_image_info,arg1,_exception);
- AppendImageToList(&_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,arg1);
- MagickSetFirstIterator(&cli_wand->wand);
-# endif
-#else
- /* Do Filename Expansion for 'arg1' then read all images.
- *
- * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring
- * (but attaching to generated argument list) any [...] read modifiers
- * that may be present.
- *
- * For example: correctly expand '*.gif[20x20]' into a list such as
- * 'abc.gif[20x20', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]'
- *
- * NOTE: In IMv6 this was done globally across all images. This
- * meant you could include IM options in '@filename' lists, but you
- * could not include comments. Doing it only for image read makes
- * it far more secure.
- */
- int argc;
- char **argv;
- ssize_t i;
-
- argc = 1;
- argv = (char **) &arg1;
-
- /* Expand 'glob' expressions in the given filename.
- Expansion handles any 'coder:' prefix, or read modifiers attached
- to the filename, including them in the resulting expanded list.
- */
- if (IfMagickFalse( ExpandFilenames(&argc,&argv) ))
- CLIWandExceptArgReturn(ResourceLimitError,"MemoryAllocationFailed",
- option,GetExceptionMessage(errno));
-
- /* loop over expanded filename list, and read then all in */
- for (i=0; i<argc; i++) {
- Image *
- new_images;
-#if 0
- fprintf(stderr, "DEBUG: Reading image: \"%s\"\n", argv[i]);
-#endif
- if (IfMagickTrue(_image_info->ping))
- new_images=PingImages(_image_info,argv[i],_exception);
- else
- new_images=ReadImages(_image_info,argv[i],_exception);
- AppendImageToList(&_images, new_images);
+#define _process_flags (cli_wand->process_flags)
+#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
+ /* Interpret Percent Escapes in Arguments - using first image */
+ arg1 = arg1n;
+ arg2 = arg2n;
+ if ( (((_process_flags & ProcessInterpretProperities) != 0 )
+ || ((_option_type & AlwaysInterpretArgsFlag) != 0)
+ ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
+ /* Interpret Percent escapes in argument 1 */
+ if (arg1n != (char *) NULL) {
+ arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
+ if (arg1 == (char *) NULL) {
+ CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
+ arg1=arg1n; /* use the given argument as is */
+ }
}
- argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */
-#endif
- return;
- }
- /*
- Image Writing
- Note: Writing a empty image list is valid in specific cases
- */
- if (LocaleCompare("write",option+1) == 0) {
- char
- key[MaxTextExtent];
-
- Image
- *write_images;
-
- ImageInfo
- *write_info;
-
- /* Need images, unless a "null:" output coder is used */
- if ( cli_wand->wand.images == (Image *) NULL ) {
- if ( LocaleCompare(arg1,"null:") == 0 )
- return;
- CLIWandExceptArgReturn(OptionError,"NoImagesForWrite",option,arg1);
+ if (arg2n != (char *) NULL) {
+ arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
+ if (arg2 == (char *) NULL) {
+ CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
+ arg2=arg2n; /* use the given argument as is */
+ }
}
-
- (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1);
- (void) DeleteImageRegistry(key);
- write_images=_images;
- 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 (IfPlusOp)
- write_images=DestroyImageList(write_images);
- return;
}
- /*
- Parenthesis and Brace operations
- */
- if (LocaleCompare("(",option) == 0) {
- /* stack 'push' images */
- Stack
- *node;
-
- size_t
- size;
-
- size=0;
- node=cli_wand->image_list_stack;
- for ( ; node != (Stack *)NULL; node=node->next)
- size++;
- if ( size >= MAX_STACK_DEPTH )
- CLIWandExceptionReturn(OptionError,"ParenthesisNestedTooDeeply",option);
- node=(Stack *) AcquireMagickMemory(sizeof(*node));
- if (node == (Stack *) NULL)
- CLIWandExceptionReturn(ResourceLimitFatalError,
- "MemoryAllocationFailed",option);
- node->data = (void *)cli_wand->wand.images;
- cli_wand->wand.images = NewImageList();
- node->next = cli_wand->image_list_stack;
- cli_wand->image_list_stack = node;
-
- /* handle respect-parenthesis */
- if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info,
- "respect-parenthesis"))))
- option="{"; /* fall-thru so as to push image settings too */
- else
- return;
- }
- if (LocaleCompare("{",option) == 0) {
- /* stack 'push' of image_info settings */
- Stack
- *node;
-
- size_t
- size;
-
- size=0;
- node=cli_wand->image_info_stack;
- for ( ; node != (Stack *)NULL; node=node->next)
- size++;
- if ( size >= MAX_STACK_DEPTH )
- CLIWandExceptionReturn(OptionError,"CurlyBracesNestedTooDeeply",option);
- node=(Stack *) AcquireMagickMemory(sizeof(*node));
- if (node == (Stack *) NULL)
- CLIWandExceptionReturn(ResourceLimitFatalError,
- "MemoryAllocationFailed",option);
-
- 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) {
- CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed",
- option);
- cli_wand->wand.image_info = (ImageInfo *)node->data;
- node = (Stack *)RelinquishMagickMemory(node);
- return;
- }
+#undef _process_flags
+#undef _option_type
+#endif
- node->next = cli_wand->image_info_stack;
- cli_wand->image_info_stack = node;
+ do { /* break to exit code */
+ /*
+ No-op options (ignore these)
+ */
+ if (LocaleCompare("noop",option+1) == 0) /* no argument */
+ break;
+ if (LocaleCompare("sans",option+1) == 0) /* one argument */
+ break;
+ if (LocaleCompare("sans0",option+1) == 0) /* no argument */
+ break;
+ if (LocaleCompare("sans2",option+1) == 0) /* two arguments */
+ break;
+ /*
+ Image Reading
+ */
+ if ( ( LocaleCompare("read",option+1) == 0 ) ||
+ ( LocaleCompare("--",option) == 0 ) ) {
+ /* Do Glob filename Expansion for 'arg1' then read all images.
+ *
+ * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring
+ * (but attaching to the filenames in the generated argument list) any
+ * [...] read modifiers that may be present.
+ *
+ * For example: It will expand '*.gif[20x20]' into a list such as
+ * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]'
+ *
+ * NOTE: In IMv6 this was done globally across all images. This
+ * meant you could include IM options in '@filename' lists, but you
+ * could not include comments. Doing it only for image read makes
+ * it far more secure.
+ *
+ * Note: arguments do not have percent escapes expanded for security
+ * reasons.
+ */
+ int argc;
+ char **argv;
+ ssize_t i;
- return;
- }
- if (LocaleCompare(")",option) == 0) {
- /* pop images from stack */
- Stack
- *node;
-
- node = (Stack *)cli_wand->image_list_stack;
- if ( node == (Stack *)NULL)
- CLIWandExceptionReturn(OptionError,"UnbalancedParenthesis",option);
- cli_wand->image_list_stack = node->next;
-
- AppendImageToList((Image **)&node->data,cli_wand->wand.images);
- cli_wand->wand.images= (Image *)node->data;
- node = (Stack *)RelinquishMagickMemory(node);
-
- /* handle respect-parenthesis - of the previous 'pushed' settings */
- node = cli_wand->image_info_stack;
- if ( node != (Stack *)NULL)
- {
- if (IfMagickTrue(IsStringTrue(GetImageOption(
- cli_wand->wand.image_info,"respect-parenthesis"))))
- option="}"; /* fall-thru so as to pop image settings too */
+ argc = 1;
+ argv = (char **) &arg1;
+
+ /* Expand 'glob' expressions in the given filename.
+ Expansion handles any 'coder:' prefix, or read modifiers attached
+ to the filename, including them in the resulting expanded list.
+ */
+ if (IfMagickFalse( ExpandFilenames(&argc,&argv) ))
+ CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed",
+ option,GetExceptionMessage(errno));
+
+ /* loop over expanded filename list, and read then all in */
+ for (i=0; i<argc; i++) {
+ Image *
+ new_images;
+ if (IfMagickTrue(_image_info->ping))
+ new_images=PingImages(_image_info,argv[i],_exception);
else
- return;
+ new_images=ReadImages(_image_info,argv[i],_exception);
+ AppendImageToList(&_images, new_images);
}
- else
- return;
- }
- if (LocaleCompare("}",option) == 0) {
- /* pop image_info settings from stack */
- Stack
- *node;
+ argv=DestroyStringList(argv); /* Destroy the Expanded Filename list */
+ break;
+ }
+ /*
+ Image Writing
+ Note: Writing a empty image list is valid in specific cases
+ */
+ if (LocaleCompare("write",option+1) == 0) {
+ /* Note: arguments do not have percent escapes expanded */
+ char
+ key[MaxTextExtent];
- node = (Stack *)cli_wand->image_info_stack;
- if ( node == (Stack *)NULL)
- CLIWandExceptionReturn(OptionError,"UnbalancedCurlyBraces",option);
- cli_wand->image_info_stack = node->next;
+ Image
+ *write_images;
- (void) DestroyImageInfo(cli_wand->wand.image_info);
- cli_wand->wand.image_info = (ImageInfo *)node->data;
- node = (Stack *)RelinquishMagickMemory(node);
+ ImageInfo
+ *write_info;
- GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
- cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
- cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
+ /* Need images, unless a "null:" output coder is used */
+ if ( cli_wand->wand.images == (Image *) NULL ) {
+ if ( LocaleCompare(arg1,"null:") == 0 )
+ break;
+ CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1);
+ }
- return;
- }
- if (LocaleCompare("clone",option+1) == 0) {
- Image
- *new_images;
-
- if (*option == '+')
- arg1="-1";
- if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse)))
- CLIWandExceptionReturn(OptionError,"InvalidArgument",option);
- if ( cli_wand->image_list_stack == (Stack *)NULL)
- CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option);
- new_images = (Image *)cli_wand->image_list_stack->data;
- if (new_images == (Image *) NULL)
- CLIWandExceptionReturn(OptionError,"UnableToCloneImage",option);
- new_images=CloneImages(new_images,arg1,_exception);
- if (new_images == (Image *) NULL)
- CLIWandExceptionReturn(OptionError,"NoSuchImage",option);
- AppendImageToList(&_images,new_images);
- return;
+ (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",arg1);
+ (void) DeleteImageRegistry(key);
+ write_images=_images;
+ 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 (IfPlusOp)
+ write_images=DestroyImageList(write_images);
+ break;
}
- /*
- Informational Operations
- */
- if (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;
- }
- if (LocaleCompare("list",option+1) == 0) {
- /* FUTURE: This should really be built into the MagickCore
- It does not actually require a cli-wand or and images!
- */
- ssize_t
- list;
-
- list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
- if ( list < 0 ) {
- CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
- return;
+ /*
+ Parenthesis and Brace operations
+ */
+ if (LocaleCompare("(",option) == 0) {
+ /* stack 'push' images */
+ Stack
+ *node;
+
+ size_t
+ size;
+
+ size=0;
+ node=cli_wand->image_list_stack;
+ for ( ; node != (Stack *)NULL; node=node->next)
+ size++;
+ if ( size >= MAX_STACK_DEPTH )
+ CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option);
+ node=(Stack *) AcquireMagickMemory(sizeof(*node));
+ if (node == (Stack *) NULL)
+ CLIWandExceptionBreak(ResourceLimitFatalError,
+ "MemoryAllocationFailed",option);
+ node->data = (void *)cli_wand->wand.images;
+ cli_wand->wand.images = NewImageList();
+ node->next = cli_wand->image_list_stack;
+ cli_wand->image_list_stack = node;
+
+ /* handle respect-parenthesis */
+ if (IfMagickTrue(IsStringTrue(GetImageOption(cli_wand->wand.image_info,
+ "respect-parenthesis"))))
+ option="{"; /* fall-thru so as to push image settings too */
+ else
+ break;
+ /* fall thru to next if */
}
- switch (list)
- {
- case MagickCoderOptions:
- {
- (void) ListCoderInfo((FILE *) NULL,_exception);
+ if (LocaleCompare("{",option) == 0) {
+ /* stack 'push' of image_info settings */
+ Stack
+ *node;
+
+ size_t
+ size;
+
+ size=0;
+ node=cli_wand->image_info_stack;
+ for ( ; node != (Stack *)NULL; node=node->next)
+ size++;
+ if ( size >= MAX_STACK_DEPTH )
+ CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option);
+ node=(Stack *) AcquireMagickMemory(sizeof(*node));
+ if (node == (Stack *) NULL)
+ CLIWandExceptionBreak(ResourceLimitFatalError,
+ "MemoryAllocationFailed",option);
+
+ 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) {
+ CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed",
+ option);
+ cli_wand->wand.image_info = (ImageInfo *)node->data;
+ node = (Stack *)RelinquishMagickMemory(node);
break;
}
- case MagickColorOptions:
- {
- (void) ListColorInfo((FILE *) NULL,_exception);
+
+ node->next = cli_wand->image_info_stack;
+ cli_wand->image_info_stack = node;
+
+ break;
+ }
+ if (LocaleCompare(")",option) == 0) {
+ /* pop images from stack */
+ Stack
+ *node;
+
+ node = (Stack *)cli_wand->image_list_stack;
+ if ( node == (Stack *)NULL)
+ CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option);
+ cli_wand->image_list_stack = node->next;
+
+ AppendImageToList((Image **)&node->data,cli_wand->wand.images);
+ cli_wand->wand.images= (Image *)node->data;
+ node = (Stack *)RelinquishMagickMemory(node);
+
+ /* handle respect-parenthesis - of the previous 'pushed' settings */
+ node = cli_wand->image_info_stack;
+ if ( node != (Stack *)NULL)
+ {
+ if (IfMagickTrue(IsStringTrue(GetImageOption(
+ cli_wand->wand.image_info,"respect-parenthesis"))))
+ option="}"; /* fall-thru so as to pop image settings too */
+ else
+ break;
+ }
+ else
break;
- }
- case MagickConfigureOptions:
- {
- (void) ListConfigureInfo((FILE *) NULL,_exception);
+ /* fall thru to next if */
+ }
+ if (LocaleCompare("}",option) == 0) {
+ /* pop image_info settings from stack */
+ Stack
+ *node;
+
+ node = (Stack *)cli_wand->image_info_stack;
+ if ( node == (Stack *)NULL)
+ CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option);
+ cli_wand->image_info_stack = node->next;
+
+ (void) DestroyImageInfo(cli_wand->wand.image_info);
+ cli_wand->wand.image_info = (ImageInfo *)node->data;
+ node = (Stack *)RelinquishMagickMemory(node);
+
+ GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
+ cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
+ cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
+
+ break;
+ }
+ if (LocaleCompare("clone",option+1) == 0) {
+ Image
+ *new_images;
+
+ if (*option == '+')
+ arg1="-1";
+ if (IfMagickFalse(IsSceneGeometry(arg1,MagickFalse)))
+ CLIWandExceptionBreak(OptionError,"InvalidArgument",option);
+ if ( cli_wand->image_list_stack == (Stack *)NULL)
+ CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option);
+ new_images = (Image *)cli_wand->image_list_stack->data;
+ if (new_images == (Image *) NULL)
+ CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option);
+ new_images=CloneImages(new_images,arg1,_exception);
+ if (new_images == (Image *) NULL)
+ CLIWandExceptionBreak(OptionError,"NoSuchImage",option);
+ AppendImageToList(&_images,new_images);
break;
}
- case MagickDelegateOptions:
- {
- (void) ListDelegateInfo((FILE *) NULL,_exception);
+ /*
+ Informational Operations
+
+ Note that these do not require either cli-wand or images!
+ */
+ if (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());
+ break;
+ }
+ if (LocaleCompare("list",option+1) == 0) {
+ /*
+ FUTURE: This 'switch' should really be built into the MagickCore
+ */
+ ssize_t
+ list;
+
+ list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
+ if ( list < 0 ) {
+ CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
break;
}
- case MagickFontOptions:
+ switch (list)
{
- (void) ListTypeInfo((FILE *) NULL,_exception);
- break;
+ case MagickCoderOptions:
+ {
+ (void) ListCoderInfo((FILE *) NULL,_exception);
+ break;
+ }
+ case MagickColorOptions:
+ {
+ (void) ListColorInfo((FILE *) NULL,_exception);
+ break;
+ }
+ case MagickConfigureOptions:
+ {
+ (void) ListConfigureInfo((FILE *) NULL,_exception);
+ break;
+ }
+ case MagickDelegateOptions:
+ {
+ (void) ListDelegateInfo((FILE *) NULL,_exception);
+ break;
+ }
+ case MagickFontOptions:
+ {
+ (void) ListTypeInfo((FILE *) NULL,_exception);
+ break;
+ }
+ case MagickFormatOptions:
+ (void) ListMagickInfo((FILE *) NULL,_exception);
+ break;
+ case MagickLocaleOptions:
+ (void) ListLocaleInfo((FILE *) NULL,_exception);
+ break;
+ case MagickLogOptions:
+ (void) ListLogInfo((FILE *) NULL,_exception);
+ break;
+ case MagickMagicOptions:
+ (void) ListMagicInfo((FILE *) NULL,_exception);
+ break;
+ case MagickMimeOptions:
+ (void) ListMimeInfo((FILE *) NULL,_exception);
+ break;
+ case MagickModuleOptions:
+ (void) ListModuleInfo((FILE *) NULL,_exception);
+ break;
+ case MagickPolicyOptions:
+ (void) ListPolicyInfo((FILE *) NULL,_exception);
+ break;
+ case MagickResourceOptions:
+ (void) ListMagickResourceInfo((FILE *) NULL,_exception);
+ break;
+ case MagickThresholdOptions:
+ (void) ListThresholdMaps((FILE *) NULL,_exception);
+ break;
+ default:
+ (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
+ _exception);
+ break;
}
- case MagickFormatOptions:
- (void) ListMagickInfo((FILE *) NULL,_exception);
- break;
- case MagickLocaleOptions:
- (void) ListLocaleInfo((FILE *) NULL,_exception);
- break;
- case MagickLogOptions:
- (void) ListLogInfo((FILE *) NULL,_exception);
- break;
- case MagickMagicOptions:
- (void) ListMagicInfo((FILE *) NULL,_exception);
- break;
- case MagickMimeOptions:
- (void) ListMimeInfo((FILE *) NULL,_exception);
- break;
- case MagickModuleOptions:
- (void) ListModuleInfo((FILE *) NULL,_exception);
- break;
- case MagickPolicyOptions:
- (void) ListPolicyInfo((FILE *) NULL,_exception);
- break;
- case MagickResourceOptions:
- (void) ListMagickResourceInfo((FILE *) NULL,_exception);
- break;
- case MagickThresholdOptions:
- (void) ListThresholdMaps((FILE *) NULL,_exception);
- break;
- default:
- (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
- _exception);
- break;
+ break;
}
- return;
- }
+
+ CLIWandException(OptionError,"UnrecognizedOption",option);
+
+ } while (0); /* break to exit code. */
#if 0
- // Other 'special' options this should handle
- // "region" "reset" "arg"
- if ( ( process_flags & ProcessUnknownOptionError ) != 0 )
+ /* clean up percent escape interpreted strings */
+ if (arg1 != arg1n )
+ arg1=DestroyString((char *)arg1);
+ if (arg2 != arg2n )
+ arg2=DestroyString((char *)arg2);
#endif
- CLIWandException(OptionError,"UnrecognizedOption",option);
#undef _image_info
#undef _images