As for the OK message. you can often ignore it, BUT you still much check for exceptions after every operation!
The new IMv7 CLI ("magick" command) does that, and aborts earlier when a higher level exception happens (level to abort at will be settable) It relies on exceptions far more than 'OKay' responses.
This is also reflected in 'example C usage' of the new CLI interface.
See MagickWand/tests/ of the source.
Also api_examples (though I am not certain if I added that to the SVN)...
this tries to implement a small CLI command in many different (and progressivally lower level) ways.
Here is one such example...
Code: Select all
/*
Direct call to ProcessCommandOptions() to process an array of
options minus the command argument. This is the function that
actually splits up the argument array into separate operation
group calls.
Compile with ImageMagick-devlop installed...
gcc -lMagickWand -lMagickCore cli_process.c -o cli_process
Compile and run directly in Source Directory...
IM_PROG=examples/cli_process
gcc -I`pwd` -LMagickWand/.libs -LMagickCore/.libs \
-lMagickWand -lMagickCore $IM_PROG.c -o $IM_PROG
sh magick.sh $IM_PROG
*/
#include <stdio.h>
#include "MagickCore/studio.h"
#include "MagickWand/MagickWand.h"
int main(int argc, char **argv)
{
MagickCLI
*cli_wand;
int arg_count;
char *args[] = { "-size", "100x100", "xc:red",
"(", "rose:", "-rotate", "-90", ")",
"+append", "show:", NULL };
for(arg_count = 0; args[arg_count] != (char *)NULL; arg_count++);
MagickCoreGenesis(argv[0],MagickFalse);
cli_wand = AcquireMagickCLI((ImageInfo *)NULL,(ExceptionInfo *)NULL);
ProcessCommandOptions(cli_wand, arg_count, args, 0, MagickCommandOptionFlags);
/* Note use of 'True' to report all exceptions - including non-fatals */
if ( CLICatchException(cli_wand,MagickTrue) != MagickFalse )
fprintf(stderr, "Major Error Detected\n");
cli_wand = DestroyMagickCLI(cli_wand);
MagickCoreTerminus();
}
The CLI-Wand is new to IMv7 and represents an expanded 'wand' that is part of CLI process.
Basically this is a normal 'magick-wand' (which is a list of images and current global settings) plus extra info needed for CLI argument handling (draw/quantization info structures, processing flags, parenthesis image stack, where argument came from for error reporting etc.). Basically a collecting of what were ordinaly processing variables in IMv6 CLI process.
The MagickWand part of MagickCLI is the first element, so its point can technically be directly used for MagickWand API's, though currently doesn't make a lot of use of that feature.