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
MagickCommandGenesis()
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: MagickCommandGenesis()
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....
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...
viewtopic.php?f=6&t=20428
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.
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)
{
MagickCoreGenesis(argv[0],MagickFalse);
{
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)
{
CatchException(exception);
fprintf(stderr, "Major Error Detected\n");
}
image_info=DestroyImageInfo(image_info);
exception=DestroyExceptionInfo(exception);
}
MagickCoreTerminus();
}
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...
viewtopic.php?f=6&t=20428
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)
{
MagickCLI
*cli_wand;
MagickCoreGenesis(argv[0],MagickFalse);
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);
MagickCoreTerminus();
}
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/