cli_process.c 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
   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

12
   Compile and run directly from Source Directory...
13 14 15 16 17

     IM_PROG=api_examples/cli_process
     gcc -I`pwd` -LMagickWand/.libs -LMagickCore/.libs \
       -lMagickWand -lMagickCore  $IM_PROG.c -o $IM_PROG

18
     sh ./magick.sh    $IM_PROG
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

*/
#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 };

cristy's avatar
cristy committed
35
  for(arg_count = 0; args[arg_count] != (char *) NULL; arg_count++);
36 37 38


  MagickCoreGenesis(argv[0],MagickFalse);
cristy's avatar
cristy committed
39
  cli_wand = AcquireMagickCLI((ImageInfo *) NULL,(ExceptionInfo *) NULL);
40 41 42 43 44 45 46 47 48 49 50

  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();
}