The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Posts: 1
Joined: 2012-03-13T10:05:28-07:00
Authentication code: 8675308


Post by janardhan »

What's the difference between using MagicCommandGenesis() and passing command line arguments
and using 'Magick Wand Image Methods' to perform the same operation.

Is there any difference in performance? or both handled in same way
User avatar
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickCommandGenesis()

Post by anthony »

The MagickCommandGenesis() is Shell API, using options. It is actually goes through a wrapper function that handles some very very specialised options such as -bench, and directly uses both MagickCore, and MagickWand.

Here is an example....

Code: Select all

#include <stdio.h>
#include "magick/studio.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/image.h"
#include "wand/MagickWand.h"
#include "wand/convert.h"

int main(int argc, char **argv)

    MagickBooleanType status;

    ImageInfo *image_info = AcquireImageInfo();
    ExceptionInfo *exception = AcquireExceptionInfo();

    int arg_count;
    char *args[] = { "convert", "-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)
      fprintf(stderr, "Major Error Detected\n");

In Shell API the above implements the command
convert -size 100x100 xc:red \
\( rose: -rotate -90 \) \
+append show:

MagickWand is a API designed to be used from multiple languages.
I does not directly make use of MagickCore, and hides as much of the details as it can.

An example of MagickWand, for the exact same command is given in...

In IMv7 their will also be at least two other ways to use CLI options directly from C...
This is an example, though the final API is not finalised and will likely change (perhaps even simplify)
Note that a MagickCLI Wand is a sort of 'super Magick Wand' that provide controls for things like the Parenthesis and Settings Stacks, sparsing file streams continaing options, and better error reporting.
It is designed so that you can actually use it as a pointer to a normal MagickWand, so you can 'mix'
MagickWand and CLI option styles of processing. However this is all 'in-flux' at this time.

Code: Select all

#include <stdio.h>
#include "MagickCore/studio.h"
#include "MagickWand/MagickWand.h"
#include "MagickWand/operation.h"

int main(int argc, char **argv)


  cli_wand = AcquireMagickCLI((ImageInfo *)NULL,(ExceptionInfo *)NULL);

  CLISettingOptionInfo    (cli_wand, "-size", "100x100");
  CLISpecialOperator      (cli_wand, "-read", "xc:red");
  CLISpecialOperator      (cli_wand, "(", NULL);
  CLISpecialOperator      (cli_wand, "-read", "rose:");
  CLISimpleOperatorImages (cli_wand, "-rotate", "-90", NULL);
  CLISpecialOperator      (cli_wand, ")", NULL);
  CLIListOperatorImages   (cli_wand, "+append", NULL, NULL);
  CLIListOperatorImages   (cli_wand, "-write", "show:", NULL);

  /* Note use of 'True' to report all exceptions - including fatals */
  if ( CLICatchException(cli_wand,MagickTrue) != MagickFalse )
    fprintf(stderr, "Major Error Detected\n");

  cli_wand = DestroyMagickCLI(cli_wand);

Anthony Thyssen -- Webmaster for ImageMagick Example Pages
Post Reply