]> granicus.if.org Git - imagemagick/blob - api_examples/cli_operators.c
Added checks for exceptions.
[imagemagick] / api_examples / cli_operators.c
1 /*
2    Make direct calls to process the various CLI option handling groups
3    as defined in "MagickWand/operators.c" which uses a special
4    MagickCLI type of 'wand'.
5
6    This is essentually the calls 'ProcessCommandOptions()' make
7    though without as many error and sanity checks.
8
9    Compile with ImageMagick-devlop installed...
10
11      gcc -lMagickWand -lMagickCore cli_operators.c -o cli_operators
12
13    Compile and run directly in Source Directory...
14
15      IM_PROG=api_examples/cli_operators
16      gcc -I`pwd` -LMagickWand/.libs -LMagickCore/.libs \
17        -lMagickWand -lMagickCore  $IM_PROG.c -o $IM_PROG
18
19      sh magick.sh    $IM_PROG
20
21
22 */
23 #include <stdio.h>
24 #include "MagickCore/studio.h"
25 #include "MagickWand/MagickWand.h"
26 #include "MagickWand/operation.h"
27
28 int main(int argc, char **argv)
29 {
30   MagickCLI
31     *cli_wand;
32
33   MagickCoreGenesis(argv[0],MagickFalse);
34
35   cli_wand = AcquireMagickCLI((ImageInfo *)NULL,(ExceptionInfo *)NULL);
36
37   CLISettingOptionInfo    (cli_wand, "-size", "100x100");
38   CLISpecialOperator      (cli_wand, "-read", "xc:red");
39   CLISpecialOperator      (cli_wand, "(", NULL);
40   CLISpecialOperator      (cli_wand, "-read", "rose:");
41   CLISimpleOperatorImages (cli_wand, "-rotate", "-90", NULL);
42   CLISpecialOperator      (cli_wand, ")", NULL);
43   CLIListOperatorImages   (cli_wand, "+append", NULL, NULL);
44   CLIListOperatorImages   (cli_wand, "-write", "show:", NULL);
45
46   /* Note use of 'True' to report all exceptions - including fatals */
47   if ( CLICatchException(cli_wand,MagickTrue) != MagickFalse )
48     fprintf(stderr, "Major Error Detected\n");
49
50   cli_wand = DestroyMagickCLI(cli_wand);
51
52   MagickCoreTerminus();
53 }