liyujie
2025-08-28 b3810562527858a3b3d98ffa6e9c9c5b0f4a9a8e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
   Direct call to MagickImageCommand(),
   which is basically what the "magick" command does via
   a wrapper function MagickCommandGenesis()
 
   Compile with ImageMagick-devlop installed...
 
     gcc -lMagickWand -lMagickCore magick_command.c -o magick_command
 
   Compile and run directly from Source Directory...
 
     IM_PROG=api_examples/magick_command
     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 "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/image.h"
#include "MagickWand/MagickWand.h"
#include "MagickWand/magick-cli.h"
 
int main(int argc, char **argv)
{
  MagickCoreGenesis(argv[0],MagickFalse);
 
  {
    
    ImageInfo *image_info = AcquireImageInfo();
    ExceptionInfo *exception = AcquireExceptionInfo();
 
    int arg_count;
    char *args[] = { "magick", "-size", "100x100", "xc:red",
                     "(", "rose:", "-rotate", "-90", ")",
                     "+append", "show:", NULL };
 
    for(arg_count = 0; args[arg_count] != (char *) NULL; arg_count++);
 
    (void) MagickImageCommand(image_info, arg_count, args, NULL, exception);
 
    if (exception->severity != UndefinedException)
    {
      CatchException(exception);
      fprintf(stderr, "Major Error Detected\n");
    }
 
    image_info=DestroyImageInfo(image_info);
    exception=DestroyExceptionInfo(exception);
  }
  MagickCoreTerminus();
}