48#include "MagickWand/studio.h"
49#include "MagickWand/MagickWand.h"
50#include "MagickWand/mogrify-private.h"
90static MagickBooleanType ConjureUsage(
void)
94 " -debug events display copious debugging information\n"
95 " -help print program options\n"
96 " -list type print a list of supported option arguments\n"
97 " -log format format of debugging information\n"
98 " -version print version information",
100 " -monitor monitor progress\n"
101 " -quiet suppress all warning messages\n"
102 " -regard-warnings pay attention to warning messages\n"
103 " -seed value seed a new sequence of pseudo-random numbers\n"
104 " -verbose print detailed information about the image";
106 ListMagickVersion(stdout);
107 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
109 (void) printf(
"\nImage Settings:\n");
110 (void) puts(settings);
111 (void) printf(
"\nMiscellaneous Options:\n");
112 (void) puts(miscellaneous);
113 (void) printf(
"\nIn addition, define any key value pairs required by "
114 "your script. For\nexample,\n\n");
115 (void) printf(
" conjure -size 100x100 -color blue -foo bar script.msl\n");
119WandExport MagickBooleanType ConjureImageCommand(ImageInfo *image_info,
120 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
122#define DestroyConjure() \
124 image=DestroyImageList(image); \
125 for (i=0; i < (ssize_t) argc; i++) \
126 argv[i]=DestroyString(argv[i]); \
127 argv=(char **) RelinquishMagickMemory(argv); \
129#define ThrowConjureException(asperity,tag,option) \
131 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
134 return(MagickFalse); \
136#define ThrowConjureInvalidArgumentException(option,argument) \
138 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
139 "InvalidArgument","'%s': %s",option,argument); \
141 return(MagickFalse); \
145 filename[MagickPathExtent],
160 wand_unreferenced(metadata);
165 assert(image_info != (ImageInfo *) NULL);
166 assert(image_info->signature == MagickCoreSignature);
167 assert(exception != (ExceptionInfo *) NULL);
168 if (IsEventLogging() != MagickFalse)
169 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
172 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
173 "MissingArgument",
"%s",
"");
174 (void) ConjureUsage();
177 image=NewImageList();
179 option=(
char *) NULL;
183 ReadCommandlLine(argc,&argv);
184 status=ExpandFilenames(&argc,&argv);
185 if (status == MagickFalse)
186 ThrowConjureException(ResourceLimitError,
"MemoryAllocationFailed",
187 GetExceptionMessage(errno));
188 for (i=1; i < (ssize_t) argc; i++)
191 if (IsCommandOption(option) != MagickFalse)
193 if (LocaleCompare(
"concurrent",option+1) == 0)
195 if (LocaleCompare(
"debug",option+1) == 0)
203 if (i == (ssize_t) argc)
204 ThrowConjureException(OptionError,
"MissingArgument",option);
205 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
207 ThrowConjureException(OptionError,
"UnrecognizedEventType",
209 (void) SetLogEventMask(argv[i]);
212 if (LocaleCompare(
"duration",option+1) == 0)
217 if (i == (ssize_t) argc)
218 ThrowConjureException(OptionError,
"MissingArgument",option);
219 if (IsGeometry(argv[i]) == MagickFalse)
220 ThrowConjureInvalidArgumentException(option,argv[i]);
223 if ((LocaleCompare(
"help",option+1) == 0) ||
224 (LocaleCompare(
"-help",option+1) == 0))
229 return(ConjureUsage());
233 if (LocaleCompare(
"log",option+1) == 0)
238 if (i == (ssize_t) argc)
239 ThrowConjureException(OptionError,
"MissingLogFormat",option);
240 (void) SetLogFormat(argv[i]);
244 if (LocaleCompare(
"monitor",option+1) == 0)
246 if (LocaleCompare(
"quiet",option+1) == 0)
248 if (LocaleCompare(
"regard-warnings",option+1) == 0)
250 if (LocaleCompare(
"seed",option+1) == 0)
255 if (i == (ssize_t) argc)
256 ThrowConjureException(OptionError,
"MissingArgument",option);
257 if (IsGeometry(argv[i]) == MagickFalse)
258 ThrowConjureInvalidArgumentException(option,argv[i]);
261 if (LocaleCompare(
"verbose",option+1) == 0)
263 image_info->verbose=(*option ==
'-') ? MagickTrue : MagickFalse;
266 if ((LocaleCompare(
"version",option+1) == 0) ||
267 (LocaleCompare(
"-version",option+1) == 0))
269 ListMagickVersion(stdout);
275 (void) DeleteImageOption(image_info,option+1);
278 ThrowConjureException(OptionError,
"MissingArgument",option);
279 status=SetImageOption(image_info,option+1,argv[i]);
280 if (status == MagickFalse)
281 ThrowConjureException(ImageError,
"UnableToPersistKey",option);
287 (void) DeleteImageOption(image_info,
"filename");
288 status=SetImageOption(image_info,
"filename",argv[i]);
289 if (status == MagickFalse)
290 ThrowConjureException(ImageError,
"UnableToPersistKey",argv[i]);
291 (void) FormatLocaleString(filename,MagickPathExtent,
"%s",argv[i]);
292 image=ReadImages(image_info,filename,exception);
293 CatchException(exception);
294 if (image != (Image *) NULL)
295 image=DestroyImageList(image);
296 status=image != (Image *) NULL ? MagickTrue : MagickFalse;
299 if (i != (ssize_t) argc)
300 ThrowConjureException(OptionError,
"MissingAnImageFilename",argv[i]);
301 if (number_images == 0)
302 ThrowConjureException(OptionError,
"MissingAnImageFilename",argv[argc-1]);
303 if (image != (Image *) NULL)
304 image=DestroyImageList(image);
305 for (i=0; i < (ssize_t) argc; i++)
306 argv[i]=DestroyString(argv[i]);
307 argv=(
char **) RelinquishMagickMemory(argv);
308 return(status != 0 ? MagickTrue : MagickFalse);