%
% o argv: A text array containing the command line arguments.
%
-% o process_flags: What type of arguments we are allowed to process
+% o process_flags: What type of arguments will be processed, ignored
+% or return errors.
%
% o index: index in the argv array to start processing from
%
%
% o argv: A text array containing the command line arguments.
%
-% o metadata: any metadata is returned here.
+% o metadata: any metadata (for VBS) is returned here.
% (for compatibilty with MagickCommandGenisis())
%
% o exception: return any errors or warnings in this structure.
static MagickBooleanType MagickUsage(void)
{
- printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
- printf("Copyright: %s\n",GetMagickCopyright());
- printf("Features: %s\n\n",GetMagickFeatures());
- printf("\n");
-
printf("Usage: %s [(options|images) ...] output_image\n", GetClientName());
printf(" %s -script filename [script args...]\n", GetClientName());
- printf(" ... | %s -script - | ...\n", GetClientName());
printf("\n");
-
printf(" For more information on usage, options, examples, and technqiues\n");
printf(" see the ImageMagick website at\n %s\n", MagickAuthoritativeURL);
- printf(" Or the web pages in ImageMagick Sources\n");
return(MagickFalse);
}
const char
*option;
+ ProcessOptionFlags
+ process_flags = MagickCommandOptionFlags;
+
/* For specific OS command line requirements */
ReadCommandlLine(argc,&argv);
#if 0
- /* FUTURE: This does not make sense! Remove it.
- Only "-read" needs to expand file name glob patterns
- */
status=ExpandFilenames(&argc,&argv);
- if ( IfMagickFalse(status))
+ if ( IfMagickFalse(status) )
ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
#endif
GetPathComponent(argv[0],TailPath,cli_wand->wand.name);
ConcatenateMagickString(cli_wand->wand.name,"-CLI",MaxTextExtent);
-#if 0
/* "convert" command - give a "depreciation" warning" */
- if ( (LocaleCompare("convert",argv[0]+strlen((argv[0])-7) == 0) ||
+ if ( (LocaleCompare("convert",argv[0]+strlen((argv[0])-7)) == 0) ||
(LocaleNCompare("convert",argv[0],7) == 0) ||
(LocaleNCompare("lt-convert",argv[0],10) == 0) ) {
- /* output warning */
+ process_flags = ConvertCommandOptionFlags;
+ /*(void) FormatLocaleFile(stderr,"WARNING: %s\n",
+ "The convert is depreciated in IMv7, use \"magick\"\n");*/
}
-#endif
/* Special Case: If command name ends with "script" then run it as is
a "-script" option is implied. This allows you to name the "magick"
/* not enough arguments -- including -help */
if (argc < 3) {
+ CLISpecialOperator(cli_wand, "-version", (char *)NULL);
MagickUsage();
goto Magick_Command_Exit;
}
- /* Special "concatenate option (hidden) for delegate usage */
- if (LocaleCompare("-concatenate",argv[1]) == 0) {
- ConcatenateImages(argc,argv,exception);
- goto Magick_Command_Exit;
- }
-
/* List Information and Abort */
if (LocaleCompare("-list",argv[1]) == 0) {
CLISpecialOperator(cli_wand, argv[1], argv[2]);
goto Magick_Command_Exit;
}
+ /* Special "concatenate option (hidden) for delegate usage */
+ if (LocaleCompare("-concatenate",argv[1]) == 0) {
+ ConcatenateImages(argc,argv,exception);
+ goto Magick_Command_Exit;
+ }
+
/* ------------- */
/* The Main Call */
}
else {
/* Normal Command Line, assumes output file as last option */
- ProcessCommandOptions(cli_wand,argc,argv,1,
- (LocaleCompare("magick",argv[0]+strlen(argv[0])-6) == 0)?
- MagickCommandOptionFlags : ConvertCommandOptionFlags);
+ ProcessCommandOptions(cli_wand,argc,argv,1, process_flags);
}
/* ------------- */
#define CLIWandExceptArgBreak(severity,tag,option,arg) \
{ CLIWandExceptionArg(severity,tag,option,arg); break; }
+#define CLIWandExceptArgReturn(severity,tag,option,arg) \
+ { CLIWandExceptionArg(severity,tag,option,arg); return; }
+
/* Define a generic stack linked list, for pushing and popping
user defined ImageInfo settings, and Image lists.
_images=smush_image;
break;
}
- if (LocaleCompare("swap",option+1) == 0)
- {
- Image
- *p,
- *q,
- *swap;
+ if (LocaleCompare("swap",option+1) == 0) {
+ Image
+ *p,
+ *q,
+ *swap;
+
+ ssize_t
+ index,
+ swap_index;
+
+ index=-1;
+ swap_index=-2;
+ if (IfNormalOp) {
+ GeometryInfo
+ geometry_info;
- ssize_t
- index,
- swap_index;
+ MagickStatusType
+ flags;
+ swap_index=(-1);
if (IfMagickFalse(IsGeometry(arg1)))
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
- index=-1;
- swap_index=-2;
- if (IfNormalOp)
- {
- GeometryInfo
- geometry_info;
-
- MagickStatusType
- flags;
-
- swap_index=(-1);
- flags=ParseGeometry(arg1,&geometry_info);
- index=(ssize_t) geometry_info.rho;
- if ((flags & SigmaValue) != 0)
- swap_index=(ssize_t) geometry_info.sigma;
- }
- p=GetImageFromList(_images,index);
- q=GetImageFromList(_images,swap_index);
- if ((p == (Image *) NULL) || (q == (Image *) NULL))
- CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1);
- if (p == q)
- break; /* same image - no-op - not an error */
- swap=CloneImage(p,0,0,MagickTrue,_exception);
- ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));
- ReplaceImageInList(&q,swap);
- _images=GetFirstImageInList(q);
- break;
- }
+ flags=ParseGeometry(arg1,&geometry_info);
+ index=(ssize_t) geometry_info.rho;
+ if ((flags & SigmaValue) != 0)
+ swap_index=(ssize_t) geometry_info.sigma;
+ }
+ p=GetImageFromList(_images,index);
+ q=GetImageFromList(_images,swap_index);
+ if ((p == (Image *) NULL) || (q == (Image *) NULL))
+ CLIWandExceptArgBreak(OptionError,"NoSuchImage",option,arg1);
+ if (p == q)
+ break; /* same image - no-op - not an error */
+ swap=CloneImage(p,0,0,MagickTrue,_exception);
+ ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));
+ ReplaceImageInList(&q,swap);
+ _images=GetFirstImageInList(q);
+ break;
+ }
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'w':
Image Reading
*/
if ( ( LocaleCompare("read",option+1) == 0 ) ||
- ( LocaleCompare("--",option) == 0 ) ) {
-/*
- int argc = 1
- char **argv = &arg1;
- MagickBooleanType
- status=ExpandFilenames(&argc,&argv);
-
- if (IfMagickFalse(status))
- ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
- GetExceptionMessage(errno));
- ...loop over images to read...
-*/
+ ( LocaleCompare("--",option) == 0 ) ) {
+ int
+ argc;
+ char
+ **argv;
+
+ ssize_t
+ i;
+
+ /* Expand the filename argument (meta-characters or "@filelist" ) */
+ argc = 1;
+ argv = &arg1;
+ MagickBooleanType
+ status=ExpandFilenames(&argc,&argv);
+
+ if (IfMagickFalse(status))
+ CLIWandExceptArgReturn(ResourceLimitError,"MemoryAllocationFailed",
+ option,GetExceptionMessage(errno));
+
+ /* loop over expanded list reading images */
+ for (i=0; i<argc; i++) {
#if !USE_WAND_METHODS
Image *
new_images;
if (IfMagickTrue(cli_wand->wand.image_info->ping))
- new_images=PingImages(cli_wand->wand.image_info,arg1,_exception);
+ new_images=PingImages(cli_wand->wand.image_info,argv[i],_exception);
else
- new_images=ReadImages(cli_wand->wand.image_info,arg1,_exception);
+ new_images=ReadImages(cli_wand->wand.image_info,argv[i],_exception);
AppendImageToList(&cli_wand->wand.images, new_images);
#else
/* read images using MagickWand method - no ping */
MagickReadImage(&cli_wand->wand,arg1);
MagickSetFirstIterator(&cli_wand->wand);
#endif
- return;
}
+ /* FUTURE: how do I free the expanded filename arguments??? */
+
+ return;
+ }
/*
Parenthesis and Brace operations
*/
/*
Informational Operations
*/
- if (LocaleCompare("verbose",option+1) == 0) {
+ if (LocaleCompare("version",option+1) == 0) {
(void) FormatLocaleFile(stdout,"Version: %s\n",
GetMagickVersion((size_t *) NULL));
(void) FormatLocaleFile(stdout,"Copyright: %s\n",