root / ImageMagick / trunk / utilities / conjure.c
| Revision 10625, 5.4 kB (checked in by cristy, 4 months ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % CCCC OOO N N JJJJJ U U RRRR EEEEE % |
| 7 | % C O O NN N J U U R R E % |
| 8 | % C O O N N N J U U RRRR EEE % |
| 9 | % C O O N NN J J U U R R E % |
| 10 | % CCCC OOO N N JJJ UUU R R EEEEE % |
| 11 | % % |
| 12 | % % |
| 13 | % Interpret Magick Scripting Language. % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % December 2001 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization % |
| 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Conjure interprets and executes scripts in the Magick Scripting Language |
| 37 | % (MSL). The Magick scripting language (MSL) will primarily benefit those |
| 38 | % that want to accomplish custom image processing tasks but do not wish |
| 39 | % to program, or those that do not have access to a Perl interpreter or a |
| 40 | % compiler. The interpreter is called conjure and here is an example script: |
| 41 | % |
| 42 | % <?xml version="1.0" encoding="UTF-8"?> |
| 43 | % <image size="400x400" > |
| 44 | % <read filename="image.gif" /> |
| 45 | % <get width="base-width" height="base-height" /> |
| 46 | % <resize geometry="%[dimensions]" /> |
| 47 | % <get width="width" height="height" /> |
| 48 | % <print output="Image sized from %[base-width]x%[base-height] |
| 49 | % to %[width]x%[height].\n" /> |
| 50 | % <write filename="image.png" /> |
| 51 | % </image> |
| 52 | % |
| 53 | % |
| 54 | */ |
| 55 | |
| 56 | /* |
| 57 | Include declarations. |
| 58 | */ |
| 59 | |
| 60 | /* |
| 61 | Include declarations. |
| 62 | */ |
| 63 | #include <stdio.h> |
| 64 | #include <stdlib.h> |
| 65 | #include <string.h> |
| 66 | #include <time.h> |
| 67 | #include "wand/MagickWand.h" |
| 68 | #if defined(__WINDOWS__) |
| 69 | #include <windows.h> |
| 70 | #endif |
| 71 | |
| 72 | /* |
| 73 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 74 | % % |
| 75 | % % |
| 76 | % % |
| 77 | % M a i n % |
| 78 | % % |
| 79 | % % |
| 80 | % % |
| 81 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 82 | % |
| 83 | % |
| 84 | */ |
| 85 | int main(int argc,char **argv) |
| 86 | { |
| 87 | char |
| 88 | *option; |
| 89 | |
| 90 | ExceptionInfo |
| 91 | *exception; |
| 92 | |
| 93 | ImageInfo |
| 94 | *image_info; |
| 95 | |
| 96 | MagickBooleanType |
| 97 | regard_warnings, |
| 98 | status; |
| 99 | |
| 100 | register long |
| 101 | i; |
| 102 | |
| 103 | MagickCoreGenesis(*argv,MagickTrue); |
| 104 | exception=AcquireExceptionInfo(); |
| 105 | regard_warnings=MagickFalse; |
| 106 | for (i=1; i < (long) argc; i++) |
| 107 | { |
| 108 | option=argv[i]; |
| 109 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 110 | continue; |
| 111 | if (LocaleCompare("debug",option+1) == 0) |
| 112 | (void) SetLogEventMask(argv[++i]); |
| 113 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 114 | regard_warnings=MagickTrue; |
| 115 | } |
| 116 | image_info=AcquireImageInfo(); |
| 117 | status=ConjureImageCommand(image_info,argc,argv,(char **) NULL,exception); |
| 118 | if (exception->severity != UndefinedException) |
| 119 | { |
| 120 | if ((exception->severity > ErrorException) || |
| 121 | (regard_warnings != MagickFalse)) |
| 122 | status=MagickTrue; |
| 123 | CatchException(exception); |
| 124 | } |
| 125 | image_info=DestroyImageInfo(image_info); |
| 126 | exception=DestroyExceptionInfo(exception); |
| 127 | MagickCoreTerminus(); |
| 128 | return(status == MagickFalse ? 0 : 1); |
| 129 | } |
Note: See TracBrowser
for help on using the browser.
