blob: ae2ddd7019e9bf9304d9016c3611ff00102724fe [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7% MM MM O O G R R I F Y Y %
8% M M M O O G GGG RRRR I FFF Y %
9% M M O O G G R R I F Y %
10% M M OOO GGGG R R IIIII F Y %
11% %
12% %
13% MagickWand Module Methods %
14% %
15% Software Design %
16% John Cristy %
17% March 2000 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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% Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37% draw on, flip, join, re-sample, and much more. This tool is similiar to
38% convert except that the original image file is overwritten (unless you
39% change the file suffix with the -format option) with any changes you
cristy6a917d92009-10-06 19:23:54 +000040% request.
cristy3ed852e2009-09-05 21:47:34 +000041%
42*/
43
44/*
45 Include declarations.
46*/
cristy4c08aed2011-07-01 19:47:50 +000047#include "MagickWand/studio.h"
48#include "MagickWand/MagickWand.h"
49#include "MagickWand/mogrify-private.h"
50#undef DegreesToRadians
51#undef RadiansToDegrees
52#include "MagickCore/image-private.h"
53#include "MagickCore/monitor-private.h"
cristy4c08aed2011-07-01 19:47:50 +000054#include "MagickCore/string-private.h"
cristy0740a982011-10-13 15:01:01 +000055#include "MagickCore/thread-private.h"
cristy18c6c272011-09-23 14:40:37 +000056#include "MagickCore/utility-private.h"
cristy3ed852e2009-09-05 21:47:34 +000057
58/*
cristy154fa9d2011-08-05 14:25:15 +000059 Constant declaration.
60*/
cristy3a557c02011-08-06 19:48:02 +000061static const char
cristy638895a2011-08-06 23:19:14 +000062 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
cristy154fa9d2011-08-05 14:25:15 +000065
66/*
cristy3ed852e2009-09-05 21:47:34 +000067 Define declarations.
68*/
69#define UndefinedCompressionQuality 0UL
70
71/*
cristy3ed852e2009-09-05 21:47:34 +000072%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73% %
74% %
75% %
cristy5063d812010-10-19 16:28:10 +000076% M a g i c k C o m m a n d G e n e s i s %
cristy3980b0d2009-10-25 14:37:13 +000077% %
78% %
79% %
80%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81%
82% MagickCommandGenesis() applies image processing options to an image as
83% prescribed by command line options.
84%
85% The format of the MagickCommandGenesis method is:
86%
87% MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
cristy5063d812010-10-19 16:28:10 +000088% MagickCommand command,int argc,char **argv,char **metadata,
89% ExceptionInfo *exception)
cristy3980b0d2009-10-25 14:37:13 +000090%
91% A description of each parameter follows:
92%
93% o image_info: the image info.
94%
cristy5063d812010-10-19 16:28:10 +000095% o command: Choose from ConvertImageCommand, IdentifyImageCommand,
cristy8a9106f2011-07-05 14:39:26 +000096% MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
cristy5063d812010-10-19 16:28:10 +000097% ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98% DisplayImageCommand, or AnimateImageCommand.
cristy3980b0d2009-10-25 14:37:13 +000099%
100% o argc: Specifies a pointer to an integer describing the number of
101% elements in the argument vector.
102%
103% o argv: Specifies a pointer to a text array containing the command line
104% arguments.
105%
cristy5063d812010-10-19 16:28:10 +0000106% o metadata: any metadata is returned here.
cristy3980b0d2009-10-25 14:37:13 +0000107%
108% o exception: return any errors or warnings in this structure.
109%
110*/
111WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
112 MagickCommand command,int argc,char **argv,char **metadata,
113 ExceptionInfo *exception)
114{
115 char
116 *option;
117
118 double
119 duration,
120 elapsed_time,
121 user_time;
122
cristy3980b0d2009-10-25 14:37:13 +0000123 MagickBooleanType
124 concurrent,
125 regard_warnings,
126 status;
127
cristybb503372010-05-27 20:51:26 +0000128 register ssize_t
cristy3980b0d2009-10-25 14:37:13 +0000129 i;
130
131 TimerInfo
132 *timer;
133
cristybb503372010-05-27 20:51:26 +0000134 size_t
cristy3980b0d2009-10-25 14:37:13 +0000135 iterations;
136
cristyd0a94fa2010-03-12 14:18:11 +0000137 (void) setlocale(LC_ALL,"");
138 (void) setlocale(LC_NUMERIC,"C");
cristy3980b0d2009-10-25 14:37:13 +0000139 concurrent=MagickFalse;
140 duration=(-1.0);
141 iterations=1;
cristy33557d72009-11-06 00:54:33 +0000142 status=MagickFalse;
cristy3980b0d2009-10-25 14:37:13 +0000143 regard_warnings=MagickFalse;
cristybb503372010-05-27 20:51:26 +0000144 for (i=1; i < (ssize_t) (argc-1); i++)
cristy3980b0d2009-10-25 14:37:13 +0000145 {
146 option=argv[i];
147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
148 continue;
149 if (LocaleCompare("bench",option+1) == 0)
cristye27293e2009-12-18 02:53:20 +0000150 iterations=StringToUnsignedLong(argv[++i]);
cristy3980b0d2009-10-25 14:37:13 +0000151 if (LocaleCompare("concurrent",option+1) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("debug",option+1) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("duration",option+1) == 0)
cristyc1acd842011-05-19 23:05:47 +0000156 duration=InterpretLocaleValue(argv[++i],(char **) NULL);
cristy3980b0d2009-10-25 14:37:13 +0000157 if (LocaleCompare("regard-warnings",option+1) == 0)
158 regard_warnings=MagickTrue;
159 }
160 timer=AcquireTimerInfo();
cristyceae09d2009-10-28 17:18:47 +0000161 if (concurrent == MagickFalse)
cristy3980b0d2009-10-25 14:37:13 +0000162 {
cristybb503372010-05-27 20:51:26 +0000163 for (i=0; i < (ssize_t) iterations; i++)
cristy3980b0d2009-10-25 14:37:13 +0000164 {
cristy33557d72009-11-06 00:54:33 +0000165 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000166 continue;
167 if (duration > 0)
168 {
169 if (GetElapsedTime(timer) > duration)
170 continue;
171 (void) ContinueTimer(timer);
172 }
173 status=command(image_info,argc,argv,metadata,exception);
cristy3980b0d2009-10-25 14:37:13 +0000174 if (exception->severity != UndefinedException)
175 {
176 if ((exception->severity > ErrorException) ||
177 (regard_warnings != MagickFalse))
178 status=MagickTrue;
179 CatchException(exception);
180 }
cristy3d1a5512009-10-25 21:23:27 +0000181 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
cristy3980b0d2009-10-25 14:37:13 +0000182 {
183 (void) fputs(*metadata,stdout);
184 (void) fputc('\n',stdout);
185 *metadata=DestroyString(*metadata);
186 }
187 }
188 }
cristyceae09d2009-10-28 17:18:47 +0000189 else
190 {
191 SetOpenMPNested(1);
cristyb5d5f722009-11-04 03:03:49 +0000192#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristyceae09d2009-10-28 17:18:47 +0000193 # pragma omp parallel for shared(status)
194#endif
cristybb503372010-05-27 20:51:26 +0000195 for (i=0; i < (ssize_t) iterations; i++)
cristyceae09d2009-10-28 17:18:47 +0000196 {
cristy33557d72009-11-06 00:54:33 +0000197 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000198 continue;
199 if (duration > 0)
200 {
201 if (GetElapsedTime(timer) > duration)
202 continue;
203 (void) ContinueTimer(timer);
204 }
205 status=command(image_info,argc,argv,metadata,exception);
cristyb5d5f722009-11-04 03:03:49 +0000206#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristy524549f2010-06-20 21:10:20 +0000207 # pragma omp critical (MagickCore_CommandGenesis)
cristyceae09d2009-10-28 17:18:47 +0000208#endif
209 {
210 if (exception->severity != UndefinedException)
211 {
212 if ((exception->severity > ErrorException) ||
213 (regard_warnings != MagickFalse))
214 status=MagickTrue;
215 CatchException(exception);
216 }
217 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
218 {
219 (void) fputs(*metadata,stdout);
220 (void) fputc('\n',stdout);
221 *metadata=DestroyString(*metadata);
222 }
223 }
224 }
225 }
cristy3980b0d2009-10-25 14:37:13 +0000226 if (iterations > 1)
227 {
228 elapsed_time=GetElapsedTime(timer);
229 user_time=GetUserTime(timer);
cristyb51dff52011-05-19 16:55:47 +0000230 (void) FormatLocaleFile(stderr,
cristye8c25f92010-06-03 00:53:06 +0000231 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
232 iterations,1.0*iterations/elapsed_time,user_time,(double)
233 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
234 (1000.0*(elapsed_time-floor(elapsed_time))));
cristy524549f2010-06-20 21:10:20 +0000235 (void) fflush(stderr);
cristy3980b0d2009-10-25 14:37:13 +0000236 }
237 timer=DestroyTimerInfo(timer);
cristy1f9e1ed2009-11-18 04:09:38 +0000238 return(status);
cristy3980b0d2009-10-25 14:37:13 +0000239}
240
241/*
242%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243% %
244% %
245% %
cristy3ed852e2009-09-05 21:47:34 +0000246+ M o g r i f y I m a g e %
247% %
248% %
249% %
250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251%
anthonye9c27192011-03-27 08:07:06 +0000252% MogrifyImage() applies simple single image processing options to a single
anthonydf8ebac2011-04-27 09:03:19 +0000253% image that may be part of a large list, but also handles any 'region'
254% image handling.
anthonye9c27192011-03-27 08:07:06 +0000255%
256% The image in the list may be modified in three different ways...
257%
258% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
259% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
260% * replace by a list of images (only the -separate option!)
261%
262% In each case the result is returned into the list, and a pointer to the
263% modified image (last image added if replaced by a list of images) is
264% returned.
265%
266% ASIDE: The -crop is present but restricted to non-tile single image crops
267%
268% This means if all the images are being processed (such as by
269% MogrifyImages(), next image to be processed will be as per the pointer
270% (*image)->next. Also the image list may grow as a result of some specific
271% operations but as images are never merged or deleted, it will never shrink
272% in length. Typically the list will remain the same length.
273%
274% WARNING: As the image pointed to may be replaced, the first image in the
275% list may also change. GetFirstImageInList() should be used by caller if
276% they wish return the Image pointer to the first image in list.
277%
cristy3ed852e2009-09-05 21:47:34 +0000278%
279% The format of the MogrifyImage method is:
280%
281% MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
282% const char **argv,Image **image)
283%
284% A description of each parameter follows:
285%
286% o image_info: the image info..
287%
288% o argc: Specifies a pointer to an integer describing the number of
289% elements in the argument vector.
290%
291% o argv: Specifies a pointer to a text array containing the command line
292% arguments.
293%
294% o image: the image.
295%
296% o exception: return any errors or warnings in this structure.
297%
298*/
299
cristy4c08aed2011-07-01 19:47:50 +0000300/*
anthony0d0fd352011-10-04 11:09:07 +0000301 GetImageCache() will read an image into a image cache if not already
302 present then return the image that is in the cache under that filename.
cristy4c08aed2011-07-01 19:47:50 +0000303*/
anthonydf8ebac2011-04-27 09:03:19 +0000304static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
305 ExceptionInfo *exception)
306{
307 char
308 key[MaxTextExtent];
309
310 ExceptionInfo
311 *sans_exception;
312
313 Image
314 *image;
315
316 ImageInfo
317 *read_info;
318
cristyb51dff52011-05-19 16:55:47 +0000319 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
anthonydf8ebac2011-04-27 09:03:19 +0000320 sans_exception=AcquireExceptionInfo();
321 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
322 sans_exception=DestroyExceptionInfo(sans_exception);
323 if (image != (Image *) NULL)
324 return(image);
325 read_info=CloneImageInfo(image_info);
326 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
327 image=ReadImage(read_info,exception);
328 read_info=DestroyImageInfo(read_info);
329 if (image != (Image *) NULL)
330 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
331 return(image);
332}
333
cristy3ed852e2009-09-05 21:47:34 +0000334static MagickBooleanType IsPathWritable(const char *path)
335{
336 if (IsPathAccessible(path) == MagickFalse)
337 return(MagickFalse);
cristy18c6c272011-09-23 14:40:37 +0000338 if (access_utf8(path,W_OK) != 0)
cristy3ed852e2009-09-05 21:47:34 +0000339 return(MagickFalse);
340 return(MagickTrue);
341}
342
cristybb503372010-05-27 20:51:26 +0000343static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
cristy3ed852e2009-09-05 21:47:34 +0000344{
345 if (x > y)
346 return(x);
347 return(y);
348}
349
anthonydf8ebac2011-04-27 09:03:19 +0000350static MagickBooleanType MonitorProgress(const char *text,
351 const MagickOffsetType offset,const MagickSizeType extent,
352 void *wand_unused(client_data))
353{
354 char
355 message[MaxTextExtent],
356 tag[MaxTextExtent];
357
358 const char
359 *locale_message;
360
361 register char
362 *p;
363
364 if (extent < 2)
365 return(MagickTrue);
366 (void) CopyMagickMemory(tag,text,MaxTextExtent);
367 p=strrchr(tag,'/');
368 if (p != (char *) NULL)
369 *p='\0';
cristyb51dff52011-05-19 16:55:47 +0000370 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
anthonydf8ebac2011-04-27 09:03:19 +0000371 locale_message=GetLocaleMessage(message);
372 if (locale_message == message)
373 locale_message=tag;
374 if (p == (char *) NULL)
cristy1e604812011-05-19 18:07:50 +0000375 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
376 locale_message,(long) offset,(unsigned long) extent,(long)
377 (100L*offset/(extent-1)));
anthonydf8ebac2011-04-27 09:03:19 +0000378 else
cristyb51dff52011-05-19 16:55:47 +0000379 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
anthonydf8ebac2011-04-27 09:03:19 +0000380 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
381 (100L*offset/(extent-1)));
382 if (offset == (MagickOffsetType) (extent-1))
cristyb51dff52011-05-19 16:55:47 +0000383 (void) FormatLocaleFile(stderr,"\n");
anthonydf8ebac2011-04-27 09:03:19 +0000384 (void) fflush(stderr);
385 return(MagickTrue);
386}
387
anthony0d0fd352011-10-04 11:09:07 +0000388 /*
389 SparseColorOption() parses the complex -sparse-color argument into an
390 an array of floating point values then calls SparseColorImage().
391 Argument is a complex mix of floating-point pixel coodinates, and color
392 specifications (or direct floating point numbers). The number of floats
393 needed to represent a color varies depending on the current channel
394 setting.
395 */
cristy3884f692011-07-08 18:00:18 +0000396static Image *SparseColorOption(const Image *image,
anthonydf8ebac2011-04-27 09:03:19 +0000397 const SparseColorMethod method,const char *arguments,
398 const MagickBooleanType color_from_image,ExceptionInfo *exception)
399{
anthonydf8ebac2011-04-27 09:03:19 +0000400 char
401 token[MaxTextExtent];
402
403 const char
404 *p;
405
406 double
407 *sparse_arguments;
408
anthonydf8ebac2011-04-27 09:03:19 +0000409 Image
410 *sparse_image;
411
cristy4c08aed2011-07-01 19:47:50 +0000412 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000413 color;
414
415 MagickBooleanType
416 error;
417
cristy5f09d852011-05-29 01:39:29 +0000418 register size_t
419 x;
420
421 size_t
422 number_arguments,
423 number_colors;
424
anthonydf8ebac2011-04-27 09:03:19 +0000425 assert(image != (Image *) NULL);
426 assert(image->signature == MagickSignature);
427 if (image->debug != MagickFalse)
428 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
429 assert(exception != (ExceptionInfo *) NULL);
430 assert(exception->signature == MagickSignature);
431 /*
432 Limit channels according to image - and add up number of color channel.
433 */
anthonydf8ebac2011-04-27 09:03:19 +0000434 number_colors=0;
cristyed231572011-07-14 02:18:59 +0000435 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000436 number_colors++;
cristyed231572011-07-14 02:18:59 +0000437 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000438 number_colors++;
cristyed231572011-07-14 02:18:59 +0000439 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000440 number_colors++;
cristyed231572011-07-14 02:18:59 +0000441 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000442 (image->colorspace == CMYKColorspace))
anthonydf8ebac2011-04-27 09:03:19 +0000443 number_colors++;
cristyed231572011-07-14 02:18:59 +0000444 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000445 (image->matte != MagickFalse))
anthonydf8ebac2011-04-27 09:03:19 +0000446 number_colors++;
447
448 /*
449 Read string, to determine number of arguments needed,
450 */
451 p=arguments;
452 x=0;
453 while( *p != '\0' )
454 {
455 GetMagickToken(p,&p,token);
456 if ( token[0] == ',' ) continue;
457 if ( isalpha((int) token[0]) || token[0] == '#' ) {
458 if ( color_from_image ) {
459 (void) ThrowMagickException(exception,GetMagickModule(),
460 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
461 "Color arg given, when colors are coming from image");
462 return( (Image *)NULL);
463 }
464 x += number_colors; /* color argument */
465 }
466 else {
467 x++; /* floating point argument */
468 }
469 }
470 error=MagickTrue;
471 if ( color_from_image ) {
472 /* just the control points are being given */
473 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
474 number_arguments=(x/2)*(2+number_colors);
475 }
476 else {
477 /* control points and color values */
478 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
479 number_arguments=x;
480 }
481 if ( error ) {
482 (void) ThrowMagickException(exception,GetMagickModule(),
483 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
484 "Invalid number of Arguments");
485 return( (Image *)NULL);
486 }
487
488 /* Allocate and fill in the floating point arguments */
489 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
490 sizeof(*sparse_arguments));
491 if (sparse_arguments == (double *) NULL) {
492 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
493 "MemoryAllocationFailed","%s","SparseColorOption");
494 return( (Image *)NULL);
495 }
496 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
497 sizeof(*sparse_arguments));
498 p=arguments;
499 x=0;
500 while( *p != '\0' && x < number_arguments ) {
501 /* X coordinate */
502 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
503 if ( token[0] == '\0' ) break;
504 if ( isalpha((int) token[0]) || token[0] == '#' ) {
505 (void) ThrowMagickException(exception,GetMagickModule(),
506 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
507 "Color found, instead of X-coord");
508 error = MagickTrue;
509 break;
510 }
cristyc1acd842011-05-19 23:05:47 +0000511 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000512 /* Y coordinate */
513 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
514 if ( token[0] == '\0' ) break;
515 if ( isalpha((int) token[0]) || token[0] == '#' ) {
516 (void) ThrowMagickException(exception,GetMagickModule(),
517 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
518 "Color found, instead of Y-coord");
519 error = MagickTrue;
520 break;
521 }
cristyc1acd842011-05-19 23:05:47 +0000522 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000523 /* color values for this control point */
524#if 0
525 if ( (color_from_image ) {
526 /* get color from image */
527 /* HOW??? */
528 }
529 else
530#endif
531 {
532 /* color name or function given in string argument */
533 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
534 if ( token[0] == '\0' ) break;
535 if ( isalpha((int) token[0]) || token[0] == '#' ) {
536 /* Color string given */
cristy269c9412011-10-13 23:41:15 +0000537 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
cristyed231572011-07-14 02:18:59 +0000538 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000539 sparse_arguments[x++] = QuantumScale*color.red;
cristyed231572011-07-14 02:18:59 +0000540 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000541 sparse_arguments[x++] = QuantumScale*color.green;
cristyed231572011-07-14 02:18:59 +0000542 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000543 sparse_arguments[x++] = QuantumScale*color.blue;
cristyed231572011-07-14 02:18:59 +0000544 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000545 (image->colorspace == CMYKColorspace))
cristy4c08aed2011-07-01 19:47:50 +0000546 sparse_arguments[x++] = QuantumScale*color.black;
cristyed231572011-07-14 02:18:59 +0000547 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000548 (image->matte != MagickFalse))
cristy4c08aed2011-07-01 19:47:50 +0000549 sparse_arguments[x++] = QuantumScale*color.alpha;
anthonydf8ebac2011-04-27 09:03:19 +0000550 }
551 else {
552 /* Colors given as a set of floating point values - experimental */
553 /* NB: token contains the first floating point value to use! */
cristyed231572011-07-14 02:18:59 +0000554 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000555 {
anthonydf8ebac2011-04-27 09:03:19 +0000556 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
557 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
558 break;
cristyc1acd842011-05-19 23:05:47 +0000559 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000560 token[0] = ','; /* used this token - get another */
561 }
cristyed231572011-07-14 02:18:59 +0000562 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000563 {
anthonydf8ebac2011-04-27 09:03:19 +0000564 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
565 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
566 break;
cristyc1acd842011-05-19 23:05:47 +0000567 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000568 token[0] = ','; /* used this token - get another */
569 }
cristyed231572011-07-14 02:18:59 +0000570 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000571 {
anthonydf8ebac2011-04-27 09:03:19 +0000572 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
573 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
574 break;
cristyc1acd842011-05-19 23:05:47 +0000575 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000576 token[0] = ','; /* used this token - get another */
577 }
cristyed231572011-07-14 02:18:59 +0000578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000579 (image->colorspace == CMYKColorspace))
580 {
anthonydf8ebac2011-04-27 09:03:19 +0000581 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
582 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
583 break;
cristyc1acd842011-05-19 23:05:47 +0000584 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000585 token[0] = ','; /* used this token - get another */
586 }
cristyed231572011-07-14 02:18:59 +0000587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000588 (image->matte != MagickFalse))
589 {
anthonydf8ebac2011-04-27 09:03:19 +0000590 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
592 break;
cristyc1acd842011-05-19 23:05:47 +0000593 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000594 token[0] = ','; /* used this token - get another */
595 }
596 }
597 }
598 }
599 if ( number_arguments != x && !error ) {
600 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
601 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
602 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
603 return( (Image *)NULL);
604 }
605 if ( error )
606 return( (Image *)NULL);
607
608 /* Call the Interpolation function with the parsed arguments */
cristy3884f692011-07-08 18:00:18 +0000609 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
610 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000611 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
612 return( sparse_image );
613}
614
cristy3ed852e2009-09-05 21:47:34 +0000615WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
616 const char **argv,Image **image,ExceptionInfo *exception)
617{
anthonydf8ebac2011-04-27 09:03:19 +0000618 ChannelType
619 channel;
620
cristy633f0c62011-09-15 13:27:36 +0000621 CompositeOperator
622 compose;
623
anthonydf8ebac2011-04-27 09:03:19 +0000624 const char
625 *format,
626 *option;
627
cristy9ed1f812011-10-08 02:00:08 +0000628 double
629 attenuate;
630
anthonydf8ebac2011-04-27 09:03:19 +0000631 DrawInfo
632 *draw_info;
633
634 GeometryInfo
635 geometry_info;
636
cristy3ed852e2009-09-05 21:47:34 +0000637 Image
638 *region_image;
639
anthonydf8ebac2011-04-27 09:03:19 +0000640 ImageInfo
641 *mogrify_info;
642
cristyebbcfea2011-02-25 02:43:54 +0000643 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000644 status;
645
cristy4c08aed2011-07-01 19:47:50 +0000646 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000647 fill;
cristy3ed852e2009-09-05 21:47:34 +0000648
anthonydf8ebac2011-04-27 09:03:19 +0000649 MagickStatusType
650 flags;
651
cristy28474bf2011-09-11 23:32:52 +0000652 PixelInterpolateMethod
653 interpolate_method;
654
anthonydf8ebac2011-04-27 09:03:19 +0000655 QuantizeInfo
656 *quantize_info;
657
658 RectangleInfo
659 geometry,
660 region_geometry;
anthony56ad4222011-04-25 11:04:27 +0000661
cristybb503372010-05-27 20:51:26 +0000662 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000663 i;
664
665 /*
666 Initialize method variables.
667 */
668 assert(image_info != (const ImageInfo *) NULL);
669 assert(image_info->signature == MagickSignature);
670 assert(image != (Image **) NULL);
671 assert((*image)->signature == MagickSignature);
672 if ((*image)->debug != MagickFalse)
673 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
674 if (argc < 0)
675 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +0000676 mogrify_info=CloneImageInfo(image_info);
anthonydf8ebac2011-04-27 09:03:19 +0000677 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
678 quantize_info=AcquireQuantizeInfo(mogrify_info);
679 SetGeometryInfo(&geometry_info);
cristy4c08aed2011-07-01 19:47:50 +0000680 GetPixelInfo(*image,&fill);
681 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
cristy9ed1f812011-10-08 02:00:08 +0000682 attenuate=1.0;
cristy633f0c62011-09-15 13:27:36 +0000683 compose=(*image)->compose;
cristy28474bf2011-09-11 23:32:52 +0000684 interpolate_method=UndefinedInterpolatePixel;
anthonydf8ebac2011-04-27 09:03:19 +0000685 channel=mogrify_info->channel;
686 format=GetImageOption(mogrify_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000687 SetGeometry(*image,&region_geometry);
688 region_image=NewImageList();
689 /*
690 Transmogrify the image.
691 */
cristybb503372010-05-27 20:51:26 +0000692 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000693 {
anthonydf8ebac2011-04-27 09:03:19 +0000694 Image
695 *mogrify_image;
696
anthonye9c27192011-03-27 08:07:06 +0000697 ssize_t
698 count;
699
anthonydf8ebac2011-04-27 09:03:19 +0000700 option=argv[i];
701 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000702 continue;
anthonydf8ebac2011-04-27 09:03:19 +0000703 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
704 0L);
cristycee97112010-05-28 00:44:52 +0000705 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000706 break;
cristy6b3da3a2010-06-20 02:21:46 +0000707 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000708 mogrify_image=(Image *)NULL;
709 switch (*(option+1))
710 {
711 case 'a':
cristy3ed852e2009-09-05 21:47:34 +0000712 {
anthonydf8ebac2011-04-27 09:03:19 +0000713 if (LocaleCompare("adaptive-blur",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000714 {
anthonydf8ebac2011-04-27 09:03:19 +0000715 /*
716 Adaptive blur image.
717 */
718 (void) SyncImageSettings(mogrify_info,*image);
719 flags=ParseGeometry(argv[i+1],&geometry_info);
720 if ((flags & SigmaValue) == 0)
721 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000722 if ((flags & XiValue) == 0)
723 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000724 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000725 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000726 break;
cristy3ed852e2009-09-05 21:47:34 +0000727 }
anthonydf8ebac2011-04-27 09:03:19 +0000728 if (LocaleCompare("adaptive-resize",option+1) == 0)
729 {
730 /*
731 Adaptive resize image.
732 */
733 (void) SyncImageSettings(mogrify_info,*image);
734 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
735 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
cristy28474bf2011-09-11 23:32:52 +0000736 geometry.height,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000737 break;
738 }
739 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
740 {
741 /*
742 Adaptive sharpen image.
743 */
744 (void) SyncImageSettings(mogrify_info,*image);
745 flags=ParseGeometry(argv[i+1],&geometry_info);
746 if ((flags & SigmaValue) == 0)
747 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000748 if ((flags & XiValue) == 0)
749 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000750 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000751 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000752 break;
753 }
754 if (LocaleCompare("affine",option+1) == 0)
755 {
756 /*
757 Affine matrix.
758 */
759 if (*option == '+')
760 {
761 GetAffineMatrix(&draw_info->affine);
762 break;
763 }
764 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
765 break;
766 }
767 if (LocaleCompare("alpha",option+1) == 0)
768 {
769 AlphaChannelType
770 alpha_type;
cristy3ed852e2009-09-05 21:47:34 +0000771
anthonydf8ebac2011-04-27 09:03:19 +0000772 (void) SyncImageSettings(mogrify_info,*image);
773 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
774 MagickFalse,argv[i+1]);
cristy63240882011-08-05 19:05:27 +0000775 (void) SetImageAlphaChannel(*image,alpha_type,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000776 break;
777 }
778 if (LocaleCompare("annotate",option+1) == 0)
779 {
780 char
781 *text,
782 geometry[MaxTextExtent];
783
784 /*
785 Annotate image.
786 */
787 (void) SyncImageSettings(mogrify_info,*image);
788 SetGeometryInfo(&geometry_info);
789 flags=ParseGeometry(argv[i+1],&geometry_info);
790 if ((flags & SigmaValue) == 0)
791 geometry_info.sigma=geometry_info.rho;
cristy018f07f2011-09-04 21:15:19 +0000792 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
793 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000794 if (text == (char *) NULL)
795 break;
796 (void) CloneString(&draw_info->text,text);
797 text=DestroyString(text);
cristyb51dff52011-05-19 16:55:47 +0000798 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
anthonydf8ebac2011-04-27 09:03:19 +0000799 geometry_info.xi,geometry_info.psi);
800 (void) CloneString(&draw_info->geometry,geometry);
801 draw_info->affine.sx=cos(DegreesToRadians(
802 fmod(geometry_info.rho,360.0)));
803 draw_info->affine.rx=sin(DegreesToRadians(
804 fmod(geometry_info.rho,360.0)));
805 draw_info->affine.ry=(-sin(DegreesToRadians(
806 fmod(geometry_info.sigma,360.0))));
807 draw_info->affine.sy=cos(DegreesToRadians(
808 fmod(geometry_info.sigma,360.0)));
cristy5cbc0162011-08-29 00:36:28 +0000809 (void) AnnotateImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000810 break;
811 }
812 if (LocaleCompare("antialias",option+1) == 0)
813 {
814 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
815 MagickFalse;
816 draw_info->text_antialias=(*option == '-') ? MagickTrue :
817 MagickFalse;
818 break;
819 }
cristy9ed1f812011-10-08 02:00:08 +0000820 if (LocaleCompare("attenuate",option+1) == 0)
821 {
822 if (*option == '+')
823 {
824 attenuate=1.0;
825 break;
826 }
827 attenuate=InterpretLocaleValue(argv[i+1],(char **) NULL);
828 break;
829 }
anthonydf8ebac2011-04-27 09:03:19 +0000830 if (LocaleCompare("auto-gamma",option+1) == 0)
831 {
832 /*
833 Auto Adjust Gamma of image based on its mean
834 */
835 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000836 (void) AutoGammaImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000837 break;
838 }
839 if (LocaleCompare("auto-level",option+1) == 0)
840 {
841 /*
842 Perfectly Normalize (max/min stretch) the image
843 */
844 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000845 (void) AutoLevelImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000846 break;
847 }
848 if (LocaleCompare("auto-orient",option+1) == 0)
849 {
850 (void) SyncImageSettings(mogrify_info,*image);
851 switch ((*image)->orientation)
852 {
853 case TopRightOrientation:
854 {
855 mogrify_image=FlopImage(*image,exception);
856 break;
857 }
858 case BottomRightOrientation:
859 {
860 mogrify_image=RotateImage(*image,180.0,exception);
861 break;
862 }
863 case BottomLeftOrientation:
864 {
865 mogrify_image=FlipImage(*image,exception);
866 break;
867 }
868 case LeftTopOrientation:
869 {
870 mogrify_image=TransposeImage(*image,exception);
871 break;
872 }
873 case RightTopOrientation:
874 {
875 mogrify_image=RotateImage(*image,90.0,exception);
876 break;
877 }
878 case RightBottomOrientation:
879 {
880 mogrify_image=TransverseImage(*image,exception);
881 break;
882 }
883 case LeftBottomOrientation:
884 {
885 mogrify_image=RotateImage(*image,270.0,exception);
886 break;
887 }
888 default:
889 break;
890 }
891 if (mogrify_image != (Image *) NULL)
892 mogrify_image->orientation=TopLeftOrientation;
893 break;
894 }
895 break;
896 }
897 case 'b':
898 {
899 if (LocaleCompare("black-threshold",option+1) == 0)
900 {
901 /*
902 Black threshold image.
903 */
904 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +0000905 (void) BlackThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +0000906 InheritException(exception,&(*image)->exception);
907 break;
908 }
909 if (LocaleCompare("blue-shift",option+1) == 0)
910 {
911 /*
912 Blue shift image.
913 */
914 (void) SyncImageSettings(mogrify_info,*image);
915 geometry_info.rho=1.5;
916 if (*option == '-')
917 flags=ParseGeometry(argv[i+1],&geometry_info);
918 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
919 break;
920 }
921 if (LocaleCompare("blur",option+1) == 0)
922 {
923 /*
924 Gaussian blur image.
925 */
926 (void) SyncImageSettings(mogrify_info,*image);
927 flags=ParseGeometry(argv[i+1],&geometry_info);
928 if ((flags & SigmaValue) == 0)
929 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000930 if ((flags & XiValue) == 0)
931 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000932 mogrify_image=BlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +0000933 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000934 break;
935 }
936 if (LocaleCompare("border",option+1) == 0)
937 {
938 /*
939 Surround image with a border of solid color.
940 */
941 (void) SyncImageSettings(mogrify_info,*image);
942 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
943 if ((flags & SigmaValue) == 0)
944 geometry.height=geometry.width;
cristy633f0c62011-09-15 13:27:36 +0000945 mogrify_image=BorderImage(*image,&geometry,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000946 break;
947 }
948 if (LocaleCompare("bordercolor",option+1) == 0)
949 {
950 if (*option == '+')
951 {
cristy9950d572011-10-01 18:22:35 +0000952 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy05c0c9a2011-09-05 23:16:13 +0000953 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000954 break;
955 }
cristy9950d572011-10-01 18:22:35 +0000956 (void) QueryColorCompliance(argv[i+1],AllCompliance,
957 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000958 break;
959 }
960 if (LocaleCompare("box",option+1) == 0)
961 {
cristy9950d572011-10-01 18:22:35 +0000962 (void) QueryColorCompliance(argv[i+1],AllCompliance,
963 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000964 break;
965 }
966 if (LocaleCompare("brightness-contrast",option+1) == 0)
967 {
968 double
969 brightness,
970 contrast;
971
972 GeometryInfo
973 geometry_info;
974
975 MagickStatusType
976 flags;
977
978 /*
979 Brightness / contrast image.
980 */
981 (void) SyncImageSettings(mogrify_info,*image);
982 flags=ParseGeometry(argv[i+1],&geometry_info);
983 brightness=geometry_info.rho;
984 contrast=0.0;
985 if ((flags & SigmaValue) != 0)
986 contrast=geometry_info.sigma;
cristy444eda62011-08-10 02:07:46 +0000987 (void) BrightnessContrastImage(*image,brightness,contrast,
988 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000989 InheritException(exception,&(*image)->exception);
990 break;
991 }
992 break;
993 }
994 case 'c':
995 {
996 if (LocaleCompare("cdl",option+1) == 0)
997 {
998 char
999 *color_correction_collection;
1000
1001 /*
1002 Color correct with a color decision list.
1003 */
1004 (void) SyncImageSettings(mogrify_info,*image);
1005 color_correction_collection=FileToString(argv[i+1],~0,exception);
1006 if (color_correction_collection == (char *) NULL)
1007 break;
cristy1bfa9f02011-08-11 02:35:43 +00001008 (void) ColorDecisionListImage(*image,color_correction_collection,
1009 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001010 InheritException(exception,&(*image)->exception);
1011 break;
1012 }
1013 if (LocaleCompare("channel",option+1) == 0)
1014 {
1015 if (*option == '+')
cristyfa806a72011-07-04 02:06:13 +00001016 channel=DefaultChannels;
anthonydf8ebac2011-04-27 09:03:19 +00001017 else
cristyfa806a72011-07-04 02:06:13 +00001018 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00001019 SetPixelChannelMap(*image,channel);
anthonydf8ebac2011-04-27 09:03:19 +00001020 break;
1021 }
1022 if (LocaleCompare("charcoal",option+1) == 0)
1023 {
1024 /*
1025 Charcoal image.
1026 */
1027 (void) SyncImageSettings(mogrify_info,*image);
1028 flags=ParseGeometry(argv[i+1],&geometry_info);
1029 if ((flags & SigmaValue) == 0)
1030 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001031 if ((flags & XiValue) == 0)
1032 geometry_info.xi=1.0;
anthonydf8ebac2011-04-27 09:03:19 +00001033 mogrify_image=CharcoalImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001034 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001035 break;
1036 }
1037 if (LocaleCompare("chop",option+1) == 0)
1038 {
1039 /*
1040 Chop the image.
1041 */
1042 (void) SyncImageSettings(mogrify_info,*image);
1043 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1044 mogrify_image=ChopImage(*image,&geometry,exception);
1045 break;
1046 }
1047 if (LocaleCompare("clamp",option+1) == 0)
1048 {
1049 /*
1050 Clamp image.
1051 */
1052 (void) SyncImageSettings(mogrify_info,*image);
cristy092d71c2011-10-14 18:01:29 +00001053 (void) ClampImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001054 break;
1055 }
1056 if (LocaleCompare("clip",option+1) == 0)
1057 {
1058 (void) SyncImageSettings(mogrify_info,*image);
1059 if (*option == '+')
1060 {
cristy018f07f2011-09-04 21:15:19 +00001061 (void) SetImageClipMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001062 break;
1063 }
cristy018f07f2011-09-04 21:15:19 +00001064 (void) ClipImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001065 break;
1066 }
1067 if (LocaleCompare("clip-mask",option+1) == 0)
1068 {
1069 CacheView
1070 *mask_view;
1071
1072 Image
1073 *mask_image;
1074
cristy4c08aed2011-07-01 19:47:50 +00001075 register Quantum
anthonydf8ebac2011-04-27 09:03:19 +00001076 *restrict q;
1077
1078 register ssize_t
1079 x;
1080
1081 ssize_t
1082 y;
1083
1084 (void) SyncImageSettings(mogrify_info,*image);
1085 if (*option == '+')
1086 {
1087 /*
1088 Remove a mask.
1089 */
cristy018f07f2011-09-04 21:15:19 +00001090 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001091 break;
1092 }
1093 /*
1094 Set the image mask.
1095 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1096 */
1097 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1098 if (mask_image == (Image *) NULL)
1099 break;
cristy574cc262011-08-05 01:23:58 +00001100 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
anthonydf8ebac2011-04-27 09:03:19 +00001101 return(MagickFalse);
1102 mask_view=AcquireCacheView(mask_image);
1103 for (y=0; y < (ssize_t) mask_image->rows; y++)
1104 {
1105 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1106 exception);
cristyacd2ed22011-08-30 01:44:23 +00001107 if (q == (Quantum *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001108 break;
1109 for (x=0; x < (ssize_t) mask_image->columns; x++)
1110 {
1111 if (mask_image->matte == MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +00001112 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1113 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1114 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1115 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
cristyed231572011-07-14 02:18:59 +00001116 q+=GetPixelChannels(mask_image);
anthonydf8ebac2011-04-27 09:03:19 +00001117 }
1118 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1119 break;
1120 }
1121 mask_view=DestroyCacheView(mask_view);
1122 mask_image->matte=MagickTrue;
cristy018f07f2011-09-04 21:15:19 +00001123 (void) SetImageClipMask(*image,mask_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001124 InheritException(exception,&(*image)->exception);
1125 break;
1126 }
1127 if (LocaleCompare("clip-path",option+1) == 0)
1128 {
1129 (void) SyncImageSettings(mogrify_info,*image);
1130 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
cristy018f07f2011-09-04 21:15:19 +00001131 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001132 break;
1133 }
1134 if (LocaleCompare("colorize",option+1) == 0)
1135 {
1136 /*
1137 Colorize the image.
1138 */
1139 (void) SyncImageSettings(mogrify_info,*image);
cristyc7e6ff62011-10-03 13:46:11 +00001140 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001141 break;
1142 }
1143 if (LocaleCompare("color-matrix",option+1) == 0)
1144 {
1145 KernelInfo
1146 *kernel;
1147
1148 (void) SyncImageSettings(mogrify_info,*image);
1149 kernel=AcquireKernelInfo(argv[i+1]);
1150 if (kernel == (KernelInfo *) NULL)
1151 break;
1152 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1153 kernel=DestroyKernelInfo(kernel);
1154 break;
1155 }
1156 if (LocaleCompare("colors",option+1) == 0)
1157 {
1158 /*
1159 Reduce the number of colors in the image.
1160 */
1161 (void) SyncImageSettings(mogrify_info,*image);
1162 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1163 if (quantize_info->number_colors == 0)
1164 break;
1165 if (((*image)->storage_class == DirectClass) ||
1166 (*image)->colors > quantize_info->number_colors)
cristy018f07f2011-09-04 21:15:19 +00001167 (void) QuantizeImage(quantize_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001168 else
cristy018f07f2011-09-04 21:15:19 +00001169 (void) CompressImageColormap(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001170 break;
1171 }
1172 if (LocaleCompare("colorspace",option+1) == 0)
1173 {
1174 ColorspaceType
1175 colorspace;
1176
1177 (void) SyncImageSettings(mogrify_info,*image);
1178 if (*option == '+')
1179 {
cristye941a752011-10-15 01:52:48 +00001180 (void) TransformImageColorspace(*image,RGBColorspace,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001181 InheritException(exception,&(*image)->exception);
1182 break;
1183 }
1184 colorspace=(ColorspaceType) ParseCommandOption(
1185 MagickColorspaceOptions,MagickFalse,argv[i+1]);
cristye941a752011-10-15 01:52:48 +00001186 (void) TransformImageColorspace(*image,colorspace,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001187 InheritException(exception,&(*image)->exception);
1188 break;
1189 }
cristy633f0c62011-09-15 13:27:36 +00001190 if (LocaleCompare("compose",option+1) == 0)
1191 {
1192 (void) SyncImageSettings(mogrify_info,*image);
1193 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1194 MagickFalse,argv[i+1]);
1195 break;
1196 }
anthonydf8ebac2011-04-27 09:03:19 +00001197 if (LocaleCompare("contrast",option+1) == 0)
1198 {
1199 (void) SyncImageSettings(mogrify_info,*image);
1200 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
cristye23ec9d2011-08-16 18:15:40 +00001201 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001202 break;
1203 }
1204 if (LocaleCompare("contrast-stretch",option+1) == 0)
1205 {
1206 double
1207 black_point,
1208 white_point;
1209
1210 MagickStatusType
1211 flags;
1212
1213 /*
1214 Contrast stretch image.
1215 */
1216 (void) SyncImageSettings(mogrify_info,*image);
1217 flags=ParseGeometry(argv[i+1],&geometry_info);
1218 black_point=geometry_info.rho;
1219 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1220 black_point;
1221 if ((flags & PercentValue) != 0)
1222 {
1223 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1224 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1225 }
1226 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1227 white_point;
cristye23ec9d2011-08-16 18:15:40 +00001228 (void) ContrastStretchImage(*image,black_point,white_point,
1229 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001230 InheritException(exception,&(*image)->exception);
1231 break;
1232 }
1233 if (LocaleCompare("convolve",option+1) == 0)
1234 {
anthonydf8ebac2011-04-27 09:03:19 +00001235 KernelInfo
cristy41cbe682011-07-15 19:12:37 +00001236 *kernel_info;
anthonydf8ebac2011-04-27 09:03:19 +00001237
anthonydf8ebac2011-04-27 09:03:19 +00001238 (void) SyncImageSettings(mogrify_info,*image);
cristy41cbe682011-07-15 19:12:37 +00001239 kernel_info=AcquireKernelInfo(argv[i+1]);
1240 if (kernel_info == (KernelInfo *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001241 break;
cristy0a922382011-07-16 15:30:34 +00001242 kernel_info->bias=(*image)->bias;
cristy5e6be1e2011-07-16 01:23:39 +00001243 mogrify_image=ConvolveImage(*image,kernel_info,exception);
cristy41cbe682011-07-15 19:12:37 +00001244 kernel_info=DestroyKernelInfo(kernel_info);
anthonydf8ebac2011-04-27 09:03:19 +00001245 break;
1246 }
1247 if (LocaleCompare("crop",option+1) == 0)
1248 {
1249 /*
1250 Crop a image to a smaller size
1251 */
1252 (void) SyncImageSettings(mogrify_info,*image);
anthonydf8ebac2011-04-27 09:03:19 +00001253 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00001254 break;
1255 }
1256 if (LocaleCompare("cycle",option+1) == 0)
1257 {
1258 /*
1259 Cycle an image colormap.
1260 */
1261 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00001262 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1263 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001264 break;
1265 }
1266 break;
1267 }
1268 case 'd':
1269 {
1270 if (LocaleCompare("decipher",option+1) == 0)
1271 {
1272 StringInfo
1273 *passkey;
1274
1275 /*
1276 Decipher pixels.
1277 */
1278 (void) SyncImageSettings(mogrify_info,*image);
1279 passkey=FileToStringInfo(argv[i+1],~0,exception);
1280 if (passkey != (StringInfo *) NULL)
1281 {
1282 (void) PasskeyDecipherImage(*image,passkey,exception);
1283 passkey=DestroyStringInfo(passkey);
1284 }
1285 break;
1286 }
1287 if (LocaleCompare("density",option+1) == 0)
1288 {
1289 /*
1290 Set image density.
1291 */
1292 (void) CloneString(&draw_info->density,argv[i+1]);
1293 break;
1294 }
1295 if (LocaleCompare("depth",option+1) == 0)
1296 {
1297 (void) SyncImageSettings(mogrify_info,*image);
1298 if (*option == '+')
1299 {
1300 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1301 break;
1302 }
1303 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1304 break;
1305 }
1306 if (LocaleCompare("deskew",option+1) == 0)
1307 {
1308 double
1309 threshold;
1310
1311 /*
1312 Straighten the image.
1313 */
1314 (void) SyncImageSettings(mogrify_info,*image);
1315 if (*option == '+')
1316 threshold=40.0*QuantumRange/100.0;
1317 else
1318 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1319 mogrify_image=DeskewImage(*image,threshold,exception);
1320 break;
1321 }
1322 if (LocaleCompare("despeckle",option+1) == 0)
1323 {
1324 /*
1325 Reduce the speckles within an image.
1326 */
1327 (void) SyncImageSettings(mogrify_info,*image);
1328 mogrify_image=DespeckleImage(*image,exception);
1329 break;
1330 }
1331 if (LocaleCompare("display",option+1) == 0)
1332 {
1333 (void) CloneString(&draw_info->server_name,argv[i+1]);
1334 break;
1335 }
1336 if (LocaleCompare("distort",option+1) == 0)
1337 {
1338 char
1339 *args,
1340 token[MaxTextExtent];
1341
1342 const char
1343 *p;
1344
1345 DistortImageMethod
1346 method;
1347
1348 double
1349 *arguments;
1350
1351 register ssize_t
1352 x;
1353
1354 size_t
1355 number_arguments;
1356
1357 /*
1358 Distort image.
1359 */
1360 (void) SyncImageSettings(mogrify_info,*image);
1361 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1362 MagickFalse,argv[i+1]);
1363 if ( method == ResizeDistortion )
1364 {
1365 /* Special Case - Argument is actually a resize geometry!
1366 ** Convert that to an appropriate distortion argument array.
1367 */
1368 double
1369 resize_args[2];
1370 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1371 exception);
1372 resize_args[0]=(double)geometry.width;
1373 resize_args[1]=(double)geometry.height;
1374 mogrify_image=DistortImage(*image,method,(size_t)2,
1375 resize_args,MagickTrue,exception);
1376 break;
1377 }
cristy018f07f2011-09-04 21:15:19 +00001378 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1379 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001380 if (args == (char *) NULL)
1381 break;
1382 p=(char *) args;
1383 for (x=0; *p != '\0'; x++)
1384 {
1385 GetMagickToken(p,&p,token);
1386 if (*token == ',')
1387 GetMagickToken(p,&p,token);
1388 }
1389 number_arguments=(size_t) x;
1390 arguments=(double *) AcquireQuantumMemory(number_arguments,
1391 sizeof(*arguments));
1392 if (arguments == (double *) NULL)
1393 ThrowWandFatalException(ResourceLimitFatalError,
1394 "MemoryAllocationFailed",(*image)->filename);
1395 (void) ResetMagickMemory(arguments,0,number_arguments*
1396 sizeof(*arguments));
1397 p=(char *) args;
1398 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1399 {
1400 GetMagickToken(p,&p,token);
1401 if (*token == ',')
1402 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001403 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001404 }
1405 args=DestroyString(args);
1406 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1407 (*option == '+') ? MagickTrue : MagickFalse,exception);
1408 arguments=(double *) RelinquishMagickMemory(arguments);
1409 break;
1410 }
1411 if (LocaleCompare("dither",option+1) == 0)
1412 {
1413 if (*option == '+')
1414 {
1415 quantize_info->dither=MagickFalse;
1416 break;
1417 }
1418 quantize_info->dither=MagickTrue;
1419 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1420 MagickDitherOptions,MagickFalse,argv[i+1]);
1421 if (quantize_info->dither_method == NoDitherMethod)
1422 quantize_info->dither=MagickFalse;
1423 break;
1424 }
1425 if (LocaleCompare("draw",option+1) == 0)
1426 {
1427 /*
1428 Draw image.
1429 */
1430 (void) SyncImageSettings(mogrify_info,*image);
1431 (void) CloneString(&draw_info->primitive,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001432 (void) DrawImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001433 break;
1434 }
1435 break;
1436 }
1437 case 'e':
1438 {
1439 if (LocaleCompare("edge",option+1) == 0)
1440 {
1441 /*
1442 Enhance edges in the image.
1443 */
1444 (void) SyncImageSettings(mogrify_info,*image);
1445 flags=ParseGeometry(argv[i+1],&geometry_info);
1446 if ((flags & SigmaValue) == 0)
1447 geometry_info.sigma=1.0;
cristy8ae632d2011-09-05 17:29:53 +00001448 mogrify_image=EdgeImage(*image,geometry_info.rho,
1449 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001450 break;
1451 }
1452 if (LocaleCompare("emboss",option+1) == 0)
1453 {
1454 /*
1455 Gaussian embossen image.
1456 */
1457 (void) SyncImageSettings(mogrify_info,*image);
1458 flags=ParseGeometry(argv[i+1],&geometry_info);
1459 if ((flags & SigmaValue) == 0)
1460 geometry_info.sigma=1.0;
1461 mogrify_image=EmbossImage(*image,geometry_info.rho,
1462 geometry_info.sigma,exception);
1463 break;
1464 }
1465 if (LocaleCompare("encipher",option+1) == 0)
1466 {
1467 StringInfo
1468 *passkey;
1469
1470 /*
1471 Encipher pixels.
1472 */
1473 (void) SyncImageSettings(mogrify_info,*image);
1474 passkey=FileToStringInfo(argv[i+1],~0,exception);
1475 if (passkey != (StringInfo *) NULL)
1476 {
1477 (void) PasskeyEncipherImage(*image,passkey,exception);
1478 passkey=DestroyStringInfo(passkey);
1479 }
1480 break;
1481 }
1482 if (LocaleCompare("encoding",option+1) == 0)
1483 {
1484 (void) CloneString(&draw_info->encoding,argv[i+1]);
1485 break;
1486 }
1487 if (LocaleCompare("enhance",option+1) == 0)
1488 {
1489 /*
1490 Enhance image.
1491 */
1492 (void) SyncImageSettings(mogrify_info,*image);
1493 mogrify_image=EnhanceImage(*image,exception);
1494 break;
1495 }
1496 if (LocaleCompare("equalize",option+1) == 0)
1497 {
1498 /*
1499 Equalize image.
1500 */
1501 (void) SyncImageSettings(mogrify_info,*image);
cristy6d8c3d72011-08-22 01:20:01 +00001502 (void) EqualizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001503 break;
1504 }
1505 if (LocaleCompare("evaluate",option+1) == 0)
1506 {
1507 double
1508 constant;
1509
1510 MagickEvaluateOperator
1511 op;
1512
1513 (void) SyncImageSettings(mogrify_info,*image);
cristyd42d9952011-07-08 14:21:50 +00001514 op=(MagickEvaluateOperator) ParseCommandOption(
1515 MagickEvaluateOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00001516 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
cristyd42d9952011-07-08 14:21:50 +00001517 (void) EvaluateImage(*image,op,constant,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001518 break;
1519 }
1520 if (LocaleCompare("extent",option+1) == 0)
1521 {
1522 /*
1523 Set the image extent.
1524 */
1525 (void) SyncImageSettings(mogrify_info,*image);
1526 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1527 if (geometry.width == 0)
1528 geometry.width=(*image)->columns;
1529 if (geometry.height == 0)
1530 geometry.height=(*image)->rows;
1531 mogrify_image=ExtentImage(*image,&geometry,exception);
1532 break;
1533 }
1534 break;
1535 }
1536 case 'f':
1537 {
1538 if (LocaleCompare("family",option+1) == 0)
1539 {
1540 if (*option == '+')
1541 {
1542 if (draw_info->family != (char *) NULL)
1543 draw_info->family=DestroyString(draw_info->family);
1544 break;
1545 }
1546 (void) CloneString(&draw_info->family,argv[i+1]);
1547 break;
1548 }
1549 if (LocaleCompare("features",option+1) == 0)
1550 {
1551 if (*option == '+')
1552 {
1553 (void) DeleteImageArtifact(*image,"identify:features");
1554 break;
1555 }
1556 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1557 break;
1558 }
1559 if (LocaleCompare("fill",option+1) == 0)
1560 {
1561 ExceptionInfo
1562 *sans;
1563
cristy4c08aed2011-07-01 19:47:50 +00001564 GetPixelInfo(*image,&fill);
anthonydf8ebac2011-04-27 09:03:19 +00001565 if (*option == '+')
1566 {
cristy269c9412011-10-13 23:41:15 +00001567 (void) QueryColorCompliance("none",AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001568 exception);
1569 (void) QueryColorCompliance("none",AllCompliance,
1570 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001571 if (draw_info->fill_pattern != (Image *) NULL)
1572 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1573 break;
1574 }
1575 sans=AcquireExceptionInfo();
cristy269c9412011-10-13 23:41:15 +00001576 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001577 sans);
1578 status=QueryColorCompliance(argv[i+1],AllCompliance,
1579 &draw_info->fill,sans);
anthonydf8ebac2011-04-27 09:03:19 +00001580 sans=DestroyExceptionInfo(sans);
1581 if (status == MagickFalse)
1582 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1583 exception);
1584 break;
1585 }
1586 if (LocaleCompare("flip",option+1) == 0)
1587 {
1588 /*
1589 Flip image scanlines.
1590 */
1591 (void) SyncImageSettings(mogrify_info,*image);
1592 mogrify_image=FlipImage(*image,exception);
1593 break;
1594 }
anthonydf8ebac2011-04-27 09:03:19 +00001595 if (LocaleCompare("floodfill",option+1) == 0)
1596 {
cristy4c08aed2011-07-01 19:47:50 +00001597 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001598 target;
1599
1600 /*
1601 Floodfill image.
1602 */
1603 (void) SyncImageSettings(mogrify_info,*image);
1604 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
cristy269c9412011-10-13 23:41:15 +00001605 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00001606 exception);
cristyd42d9952011-07-08 14:21:50 +00001607 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
cristy189e84c2011-08-27 18:08:53 +00001608 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001609 break;
1610 }
anthony3d2f4862011-05-01 13:48:16 +00001611 if (LocaleCompare("flop",option+1) == 0)
1612 {
1613 /*
1614 Flop image scanlines.
1615 */
1616 (void) SyncImageSettings(mogrify_info,*image);
1617 mogrify_image=FlopImage(*image,exception);
1618 break;
1619 }
anthonydf8ebac2011-04-27 09:03:19 +00001620 if (LocaleCompare("font",option+1) == 0)
1621 {
1622 if (*option == '+')
1623 {
1624 if (draw_info->font != (char *) NULL)
1625 draw_info->font=DestroyString(draw_info->font);
1626 break;
1627 }
1628 (void) CloneString(&draw_info->font,argv[i+1]);
1629 break;
1630 }
1631 if (LocaleCompare("format",option+1) == 0)
1632 {
1633 format=argv[i+1];
1634 break;
1635 }
1636 if (LocaleCompare("frame",option+1) == 0)
1637 {
1638 FrameInfo
1639 frame_info;
1640
1641 /*
1642 Surround image with an ornamental border.
1643 */
1644 (void) SyncImageSettings(mogrify_info,*image);
1645 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1646 frame_info.width=geometry.width;
1647 frame_info.height=geometry.height;
1648 if ((flags & HeightValue) == 0)
1649 frame_info.height=geometry.width;
1650 frame_info.outer_bevel=geometry.x;
1651 frame_info.inner_bevel=geometry.y;
1652 frame_info.x=(ssize_t) frame_info.width;
1653 frame_info.y=(ssize_t) frame_info.height;
1654 frame_info.width=(*image)->columns+2*frame_info.width;
1655 frame_info.height=(*image)->rows+2*frame_info.height;
cristy633f0c62011-09-15 13:27:36 +00001656 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001657 break;
1658 }
1659 if (LocaleCompare("function",option+1) == 0)
1660 {
1661 char
1662 *arguments,
1663 token[MaxTextExtent];
1664
1665 const char
1666 *p;
1667
1668 double
1669 *parameters;
1670
1671 MagickFunction
1672 function;
1673
1674 register ssize_t
1675 x;
1676
1677 size_t
1678 number_parameters;
1679
1680 /*
1681 Function Modify Image Values
1682 */
1683 (void) SyncImageSettings(mogrify_info,*image);
1684 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1685 MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001686 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1687 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001688 if (arguments == (char *) NULL)
1689 break;
1690 p=(char *) arguments;
1691 for (x=0; *p != '\0'; x++)
1692 {
1693 GetMagickToken(p,&p,token);
1694 if (*token == ',')
1695 GetMagickToken(p,&p,token);
1696 }
1697 number_parameters=(size_t) x;
1698 parameters=(double *) AcquireQuantumMemory(number_parameters,
1699 sizeof(*parameters));
1700 if (parameters == (double *) NULL)
1701 ThrowWandFatalException(ResourceLimitFatalError,
1702 "MemoryAllocationFailed",(*image)->filename);
1703 (void) ResetMagickMemory(parameters,0,number_parameters*
1704 sizeof(*parameters));
1705 p=(char *) arguments;
1706 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1707 {
1708 GetMagickToken(p,&p,token);
1709 if (*token == ',')
1710 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001711 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001712 }
1713 arguments=DestroyString(arguments);
cristyd42d9952011-07-08 14:21:50 +00001714 (void) FunctionImage(*image,function,number_parameters,parameters,
1715 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001716 parameters=(double *) RelinquishMagickMemory(parameters);
1717 break;
1718 }
1719 break;
1720 }
1721 case 'g':
1722 {
1723 if (LocaleCompare("gamma",option+1) == 0)
1724 {
1725 /*
1726 Gamma image.
1727 */
1728 (void) SyncImageSettings(mogrify_info,*image);
1729 if (*option == '+')
cristyc1acd842011-05-19 23:05:47 +00001730 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001731 else
cristyb3e7c6c2011-07-24 01:43:55 +00001732 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1733 (char **) NULL),exception);
anthonydf8ebac2011-04-27 09:03:19 +00001734 break;
1735 }
1736 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1737 (LocaleCompare("gaussian",option+1) == 0))
1738 {
1739 /*
1740 Gaussian blur image.
1741 */
1742 (void) SyncImageSettings(mogrify_info,*image);
1743 flags=ParseGeometry(argv[i+1],&geometry_info);
1744 if ((flags & SigmaValue) == 0)
1745 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001746 if ((flags & XiValue) == 0)
1747 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00001748 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001749 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001750 break;
1751 }
1752 if (LocaleCompare("geometry",option+1) == 0)
1753 {
1754 /*
1755 Record Image offset, Resize last image.
1756 */
1757 (void) SyncImageSettings(mogrify_info,*image);
1758 if (*option == '+')
1759 {
1760 if ((*image)->geometry != (char *) NULL)
1761 (*image)->geometry=DestroyString((*image)->geometry);
1762 break;
1763 }
1764 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1765 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1766 (void) CloneString(&(*image)->geometry,argv[i+1]);
1767 else
1768 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1769 (*image)->filter,(*image)->blur,exception);
1770 break;
1771 }
1772 if (LocaleCompare("gravity",option+1) == 0)
1773 {
1774 if (*option == '+')
1775 {
1776 draw_info->gravity=UndefinedGravity;
1777 break;
1778 }
1779 draw_info->gravity=(GravityType) ParseCommandOption(
1780 MagickGravityOptions,MagickFalse,argv[i+1]);
1781 break;
1782 }
1783 break;
1784 }
1785 case 'h':
1786 {
1787 if (LocaleCompare("highlight-color",option+1) == 0)
1788 {
1789 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1790 break;
1791 }
1792 break;
1793 }
1794 case 'i':
1795 {
1796 if (LocaleCompare("identify",option+1) == 0)
1797 {
1798 char
1799 *text;
1800
1801 (void) SyncImageSettings(mogrify_info,*image);
1802 if (format == (char *) NULL)
1803 {
cristya4037272011-08-28 15:11:39 +00001804 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1805 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001806 break;
1807 }
cristy018f07f2011-09-04 21:15:19 +00001808 text=InterpretImageProperties(mogrify_info,*image,format,
1809 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001810 if (text == (char *) NULL)
1811 break;
1812 (void) fputs(text,stdout);
1813 (void) fputc('\n',stdout);
1814 text=DestroyString(text);
1815 break;
1816 }
1817 if (LocaleCompare("implode",option+1) == 0)
1818 {
1819 /*
1820 Implode image.
1821 */
1822 (void) SyncImageSettings(mogrify_info,*image);
1823 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00001824 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1825 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001826 break;
1827 }
1828 if (LocaleCompare("interline-spacing",option+1) == 0)
1829 {
1830 if (*option == '+')
1831 (void) ParseGeometry("0",&geometry_info);
1832 else
1833 (void) ParseGeometry(argv[i+1],&geometry_info);
1834 draw_info->interline_spacing=geometry_info.rho;
1835 break;
1836 }
cristy28474bf2011-09-11 23:32:52 +00001837 if (LocaleCompare("interpolate",option+1) == 0)
1838 {
1839 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1840 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1841 break;
1842 }
anthonydf8ebac2011-04-27 09:03:19 +00001843 if (LocaleCompare("interword-spacing",option+1) == 0)
1844 {
1845 if (*option == '+')
1846 (void) ParseGeometry("0",&geometry_info);
1847 else
1848 (void) ParseGeometry(argv[i+1],&geometry_info);
1849 draw_info->interword_spacing=geometry_info.rho;
1850 break;
1851 }
1852 break;
1853 }
1854 case 'k':
1855 {
1856 if (LocaleCompare("kerning",option+1) == 0)
1857 {
1858 if (*option == '+')
1859 (void) ParseGeometry("0",&geometry_info);
1860 else
1861 (void) ParseGeometry(argv[i+1],&geometry_info);
1862 draw_info->kerning=geometry_info.rho;
1863 break;
1864 }
1865 break;
1866 }
1867 case 'l':
1868 {
1869 if (LocaleCompare("lat",option+1) == 0)
1870 {
1871 /*
1872 Local adaptive threshold image.
1873 */
1874 (void) SyncImageSettings(mogrify_info,*image);
1875 flags=ParseGeometry(argv[i+1],&geometry_info);
1876 if ((flags & PercentValue) != 0)
1877 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1878 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
cristyde5cc632011-07-18 14:47:00 +00001879 geometry_info.rho,(size_t) geometry_info.sigma,(double)
anthonydf8ebac2011-04-27 09:03:19 +00001880 geometry_info.xi,exception);
1881 break;
1882 }
1883 if (LocaleCompare("level",option+1) == 0)
1884 {
1885 MagickRealType
1886 black_point,
1887 gamma,
1888 white_point;
1889
1890 MagickStatusType
1891 flags;
1892
1893 /*
1894 Parse levels.
1895 */
1896 (void) SyncImageSettings(mogrify_info,*image);
1897 flags=ParseGeometry(argv[i+1],&geometry_info);
1898 black_point=geometry_info.rho;
1899 white_point=(MagickRealType) QuantumRange;
1900 if ((flags & SigmaValue) != 0)
1901 white_point=geometry_info.sigma;
1902 gamma=1.0;
1903 if ((flags & XiValue) != 0)
1904 gamma=geometry_info.xi;
1905 if ((flags & PercentValue) != 0)
1906 {
1907 black_point*=(MagickRealType) (QuantumRange/100.0);
1908 white_point*=(MagickRealType) (QuantumRange/100.0);
1909 }
1910 if ((flags & SigmaValue) == 0)
1911 white_point=(MagickRealType) QuantumRange-black_point;
1912 if ((*option == '+') || ((flags & AspectValue) != 0))
cristy7c0a0a42011-08-23 17:57:25 +00001913 (void) LevelizeImage(*image,black_point,white_point,gamma,
1914 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001915 else
cristy01e9afd2011-08-10 17:38:41 +00001916 (void) LevelImage(*image,black_point,white_point,gamma,
1917 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001918 InheritException(exception,&(*image)->exception);
1919 break;
1920 }
1921 if (LocaleCompare("level-colors",option+1) == 0)
1922 {
1923 char
1924 token[MaxTextExtent];
1925
1926 const char
1927 *p;
1928
cristy4c08aed2011-07-01 19:47:50 +00001929 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001930 black_point,
1931 white_point;
1932
1933 p=(const char *) argv[i+1];
1934 GetMagickToken(p,&p,token); /* get black point color */
1935 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001936 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001937 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001938 else
cristy269c9412011-10-13 23:41:15 +00001939 (void) QueryColorCompliance("#000000",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001940 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001941 if (isalpha((int) token[0]) || (token[0] == '#'))
1942 GetMagickToken(p,&p,token);
1943 if (*token == '\0')
1944 white_point=black_point; /* set everything to that color */
1945 else
1946 {
1947 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1948 GetMagickToken(p,&p,token); /* Get white point color. */
1949 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001950 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001951 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001952 else
cristy269c9412011-10-13 23:41:15 +00001953 (void) QueryColorCompliance("#ffffff",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001954 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001955 }
cristy490408a2011-07-07 14:42:05 +00001956 (void) LevelImageColors(*image,&black_point,&white_point,
cristy7c0a0a42011-08-23 17:57:25 +00001957 *option == '+' ? MagickTrue : MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001958 break;
1959 }
1960 if (LocaleCompare("linear-stretch",option+1) == 0)
1961 {
1962 double
1963 black_point,
1964 white_point;
1965
1966 MagickStatusType
1967 flags;
1968
1969 (void) SyncImageSettings(mogrify_info,*image);
1970 flags=ParseGeometry(argv[i+1],&geometry_info);
1971 black_point=geometry_info.rho;
1972 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1973 if ((flags & SigmaValue) != 0)
1974 white_point=geometry_info.sigma;
1975 if ((flags & PercentValue) != 0)
1976 {
1977 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1978 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1979 }
1980 if ((flags & SigmaValue) == 0)
1981 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1982 black_point;
cristy33bd5152011-08-24 01:42:24 +00001983 (void) LinearStretchImage(*image,black_point,white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001984 InheritException(exception,&(*image)->exception);
1985 break;
1986 }
1987 if (LocaleCompare("linewidth",option+1) == 0)
1988 {
cristyc1acd842011-05-19 23:05:47 +00001989 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1990 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001991 break;
1992 }
1993 if (LocaleCompare("liquid-rescale",option+1) == 0)
1994 {
1995 /*
1996 Liquid rescale image.
1997 */
1998 (void) SyncImageSettings(mogrify_info,*image);
1999 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2000 if ((flags & XValue) == 0)
2001 geometry.x=1;
2002 if ((flags & YValue) == 0)
2003 geometry.y=0;
2004 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2005 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2006 break;
2007 }
2008 if (LocaleCompare("lowlight-color",option+1) == 0)
2009 {
2010 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2011 break;
2012 }
2013 break;
2014 }
2015 case 'm':
2016 {
2017 if (LocaleCompare("map",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00002018 {
cristy3ed852e2009-09-05 21:47:34 +00002019 Image
anthonydf8ebac2011-04-27 09:03:19 +00002020 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002021
anthonydf8ebac2011-04-27 09:03:19 +00002022 /*
2023 Transform image colors to match this set of colors.
2024 */
2025 (void) SyncImageSettings(mogrify_info,*image);
2026 if (*option == '+')
2027 break;
2028 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2029 if (remap_image == (Image *) NULL)
2030 break;
cristy018f07f2011-09-04 21:15:19 +00002031 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002032 remap_image=DestroyImage(remap_image);
2033 break;
2034 }
2035 if (LocaleCompare("mask",option+1) == 0)
2036 {
2037 Image
2038 *mask;
2039
2040 (void) SyncImageSettings(mogrify_info,*image);
2041 if (*option == '+')
2042 {
2043 /*
2044 Remove a mask.
2045 */
cristy018f07f2011-09-04 21:15:19 +00002046 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002047 break;
2048 }
2049 /*
2050 Set the image mask.
2051 */
2052 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2053 if (mask == (Image *) NULL)
2054 break;
cristy018f07f2011-09-04 21:15:19 +00002055 (void) SetImageMask(*image,mask,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002056 mask=DestroyImage(mask);
anthonydf8ebac2011-04-27 09:03:19 +00002057 break;
2058 }
2059 if (LocaleCompare("matte",option+1) == 0)
2060 {
2061 (void) SetImageAlphaChannel(*image,(*option == '-') ?
cristy63240882011-08-05 19:05:27 +00002062 SetAlphaChannel : DeactivateAlphaChannel,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002063 break;
2064 }
2065 if (LocaleCompare("median",option+1) == 0)
2066 {
2067 /*
2068 Median filter image.
2069 */
2070 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002071 flags=ParseGeometry(argv[i+1],&geometry_info);
2072 if ((flags & SigmaValue) == 0)
2073 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002074 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002075 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002076 break;
2077 }
2078 if (LocaleCompare("mode",option+1) == 0)
2079 {
2080 /*
2081 Mode image.
2082 */
2083 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002084 flags=ParseGeometry(argv[i+1],&geometry_info);
2085 if ((flags & SigmaValue) == 0)
2086 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002087 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002088 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002089 break;
2090 }
2091 if (LocaleCompare("modulate",option+1) == 0)
2092 {
2093 (void) SyncImageSettings(mogrify_info,*image);
cristy33bd5152011-08-24 01:42:24 +00002094 (void) ModulateImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002095 break;
2096 }
2097 if (LocaleCompare("monitor",option+1) == 0)
2098 {
2099 if (*option == '+')
2100 {
2101 (void) SetImageProgressMonitor(*image,
2102 (MagickProgressMonitor) NULL,(void *) NULL);
2103 break;
2104 }
2105 (void) SetImageProgressMonitor(*image,MonitorProgress,
2106 (void *) NULL);
2107 break;
2108 }
2109 if (LocaleCompare("monochrome",option+1) == 0)
2110 {
2111 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00002112 (void) SetImageType(*image,BilevelType,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002113 break;
2114 }
2115 if (LocaleCompare("morphology",option+1) == 0)
2116 {
2117 char
2118 token[MaxTextExtent];
2119
2120 const char
2121 *p;
2122
2123 KernelInfo
2124 *kernel;
2125
2126 MorphologyMethod
2127 method;
2128
2129 ssize_t
2130 iterations;
2131
2132 /*
2133 Morphological Image Operation
2134 */
2135 (void) SyncImageSettings(mogrify_info,*image);
2136 p=argv[i+1];
2137 GetMagickToken(p,&p,token);
cristy28474bf2011-09-11 23:32:52 +00002138 method=(MorphologyMethod) ParseCommandOption(
2139 MagickMorphologyOptions,MagickFalse,token);
anthonydf8ebac2011-04-27 09:03:19 +00002140 iterations=1L;
2141 GetMagickToken(p,&p,token);
2142 if ((*p == ':') || (*p == ','))
2143 GetMagickToken(p,&p,token);
2144 if ((*p != '\0'))
2145 iterations=(ssize_t) StringToLong(p);
2146 kernel=AcquireKernelInfo(argv[i+2]);
2147 if (kernel == (KernelInfo *) NULL)
2148 {
2149 (void) ThrowMagickException(exception,GetMagickModule(),
2150 OptionError,"UnabletoParseKernel","morphology");
2151 status=MagickFalse;
2152 break;
2153 }
cristyf4ad9df2011-07-08 16:49:03 +00002154 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2155 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002156 kernel=DestroyKernelInfo(kernel);
2157 break;
2158 }
2159 if (LocaleCompare("motion-blur",option+1) == 0)
2160 {
2161 /*
2162 Motion blur image.
2163 */
2164 (void) SyncImageSettings(mogrify_info,*image);
2165 flags=ParseGeometry(argv[i+1],&geometry_info);
2166 if ((flags & SigmaValue) == 0)
2167 geometry_info.sigma=1.0;
cristyf4ad9df2011-07-08 16:49:03 +00002168 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002169 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2170 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002171 break;
2172 }
2173 break;
2174 }
2175 case 'n':
2176 {
2177 if (LocaleCompare("negate",option+1) == 0)
2178 {
2179 (void) SyncImageSettings(mogrify_info,*image);
cristy50fbc382011-07-07 02:19:17 +00002180 (void) NegateImage(*image,*option == '+' ? MagickTrue :
cristyb3e7c6c2011-07-24 01:43:55 +00002181 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002182 break;
2183 }
2184 if (LocaleCompare("noise",option+1) == 0)
2185 {
2186 (void) SyncImageSettings(mogrify_info,*image);
2187 if (*option == '-')
2188 {
cristyf36cbcb2011-09-07 13:28:22 +00002189 flags=ParseGeometry(argv[i+1],&geometry_info);
2190 if ((flags & SigmaValue) == 0)
2191 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002192 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002193 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002194 }
2195 else
2196 {
2197 NoiseType
2198 noise;
2199
2200 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2201 MagickFalse,argv[i+1]);
cristy9ed1f812011-10-08 02:00:08 +00002202 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002203 }
2204 break;
2205 }
2206 if (LocaleCompare("normalize",option+1) == 0)
2207 {
2208 (void) SyncImageSettings(mogrify_info,*image);
cristye23ec9d2011-08-16 18:15:40 +00002209 (void) NormalizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002210 break;
2211 }
2212 break;
2213 }
2214 case 'o':
2215 {
2216 if (LocaleCompare("opaque",option+1) == 0)
2217 {
cristy4c08aed2011-07-01 19:47:50 +00002218 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002219 target;
2220
2221 (void) SyncImageSettings(mogrify_info,*image);
cristy269c9412011-10-13 23:41:15 +00002222 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00002223 exception);
cristyd42d9952011-07-08 14:21:50 +00002224 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
cristy189e84c2011-08-27 18:08:53 +00002225 MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002226 break;
2227 }
2228 if (LocaleCompare("ordered-dither",option+1) == 0)
2229 {
2230 (void) SyncImageSettings(mogrify_info,*image);
cristy13020672011-07-08 02:33:26 +00002231 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002232 break;
2233 }
2234 break;
2235 }
2236 case 'p':
2237 {
2238 if (LocaleCompare("paint",option+1) == 0)
2239 {
anthonydf8ebac2011-04-27 09:03:19 +00002240 (void) SyncImageSettings(mogrify_info,*image);
2241 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy14973ba2011-08-27 23:48:07 +00002242 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2243 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002244 break;
2245 }
2246 if (LocaleCompare("pen",option+1) == 0)
2247 {
2248 if (*option == '+')
2249 {
cristy9950d572011-10-01 18:22:35 +00002250 (void) QueryColorCompliance("none",AllCompliance,
2251 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002252 break;
2253 }
cristy9950d572011-10-01 18:22:35 +00002254 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2255 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002256 break;
2257 }
2258 if (LocaleCompare("pointsize",option+1) == 0)
2259 {
2260 if (*option == '+')
2261 (void) ParseGeometry("12",&geometry_info);
2262 else
2263 (void) ParseGeometry(argv[i+1],&geometry_info);
2264 draw_info->pointsize=geometry_info.rho;
2265 break;
2266 }
2267 if (LocaleCompare("polaroid",option+1) == 0)
2268 {
2269 double
2270 angle;
2271
2272 RandomInfo
2273 *random_info;
2274
2275 /*
2276 Simulate a Polaroid picture.
2277 */
2278 (void) SyncImageSettings(mogrify_info,*image);
2279 random_info=AcquireRandomInfo();
2280 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2281 random_info=DestroyRandomInfo(random_info);
2282 if (*option == '-')
2283 {
2284 SetGeometryInfo(&geometry_info);
2285 flags=ParseGeometry(argv[i+1],&geometry_info);
2286 angle=geometry_info.rho;
2287 }
cristy5c4e2582011-09-11 19:21:03 +00002288 mogrify_image=PolaroidImage(*image,draw_info,angle,
cristy28474bf2011-09-11 23:32:52 +00002289 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002290 break;
2291 }
2292 if (LocaleCompare("posterize",option+1) == 0)
2293 {
2294 /*
2295 Posterize image.
2296 */
2297 (void) SyncImageSettings(mogrify_info,*image);
2298 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy018f07f2011-09-04 21:15:19 +00002299 quantize_info->dither,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002300 break;
2301 }
2302 if (LocaleCompare("preview",option+1) == 0)
2303 {
2304 PreviewType
2305 preview_type;
2306
2307 /*
2308 Preview image.
2309 */
2310 (void) SyncImageSettings(mogrify_info,*image);
2311 if (*option == '+')
2312 preview_type=UndefinedPreview;
2313 else
cristy28474bf2011-09-11 23:32:52 +00002314 preview_type=(PreviewType) ParseCommandOption(
2315 MagickPreviewOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002316 mogrify_image=PreviewImage(*image,preview_type,exception);
2317 break;
2318 }
2319 if (LocaleCompare("profile",option+1) == 0)
2320 {
2321 const char
2322 *name;
2323
2324 const StringInfo
2325 *profile;
2326
2327 Image
2328 *profile_image;
2329
2330 ImageInfo
2331 *profile_info;
2332
2333 (void) SyncImageSettings(mogrify_info,*image);
2334 if (*option == '+')
2335 {
2336 /*
2337 Remove a profile from the image.
2338 */
2339 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
cristy092d71c2011-10-14 18:01:29 +00002340 NULL,0,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002341 break;
2342 }
2343 /*
2344 Associate a profile with the image.
2345 */
2346 profile_info=CloneImageInfo(mogrify_info);
2347 profile=GetImageProfile(*image,"iptc");
2348 if (profile != (StringInfo *) NULL)
2349 profile_info->profile=(void *) CloneStringInfo(profile);
2350 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2351 profile_info=DestroyImageInfo(profile_info);
2352 if (profile_image == (Image *) NULL)
2353 {
2354 StringInfo
2355 *profile;
2356
2357 profile_info=CloneImageInfo(mogrify_info);
2358 (void) CopyMagickString(profile_info->filename,argv[i+1],
2359 MaxTextExtent);
2360 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2361 if (profile != (StringInfo *) NULL)
2362 {
2363 (void) ProfileImage(*image,profile_info->magick,
2364 GetStringInfoDatum(profile),(size_t)
2365 GetStringInfoLength(profile),MagickFalse);
2366 profile=DestroyStringInfo(profile);
2367 }
2368 profile_info=DestroyImageInfo(profile_info);
2369 break;
2370 }
2371 ResetImageProfileIterator(profile_image);
2372 name=GetNextImageProfile(profile_image);
2373 while (name != (const char *) NULL)
2374 {
2375 profile=GetImageProfile(profile_image,name);
2376 if (profile != (StringInfo *) NULL)
2377 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2378 (size_t) GetStringInfoLength(profile),MagickFalse);
2379 name=GetNextImageProfile(profile_image);
2380 }
2381 profile_image=DestroyImage(profile_image);
2382 break;
2383 }
2384 break;
2385 }
2386 case 'q':
2387 {
2388 if (LocaleCompare("quantize",option+1) == 0)
2389 {
2390 if (*option == '+')
2391 {
2392 quantize_info->colorspace=UndefinedColorspace;
2393 break;
2394 }
2395 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2396 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2397 break;
2398 }
2399 break;
2400 }
2401 case 'r':
2402 {
2403 if (LocaleCompare("radial-blur",option+1) == 0)
2404 {
2405 /*
2406 Radial blur image.
2407 */
2408 (void) SyncImageSettings(mogrify_info,*image);
cristy6435bd92011-09-10 02:10:07 +00002409 flags=ParseGeometry(argv[i+1],&geometry_info);
2410 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2411 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002412 break;
2413 }
2414 if (LocaleCompare("raise",option+1) == 0)
2415 {
2416 /*
2417 Surround image with a raise of solid color.
2418 */
2419 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2420 if ((flags & SigmaValue) == 0)
2421 geometry.height=geometry.width;
2422 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
cristy6170ac32011-08-28 14:15:37 +00002423 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002424 break;
2425 }
2426 if (LocaleCompare("random-threshold",option+1) == 0)
2427 {
2428 /*
2429 Threshold image.
2430 */
2431 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00002432 (void) RandomThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002433 break;
2434 }
2435 if (LocaleCompare("recolor",option+1) == 0)
2436 {
2437 KernelInfo
2438 *kernel;
2439
2440 (void) SyncImageSettings(mogrify_info,*image);
2441 kernel=AcquireKernelInfo(argv[i+1]);
2442 if (kernel == (KernelInfo *) NULL)
2443 break;
2444 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2445 kernel=DestroyKernelInfo(kernel);
2446 break;
2447 }
2448 if (LocaleCompare("region",option+1) == 0)
2449 {
2450 (void) SyncImageSettings(mogrify_info,*image);
2451 if (region_image != (Image *) NULL)
2452 {
2453 /*
2454 Composite region.
2455 */
2456 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00002457 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
cristye941a752011-10-15 01:52:48 +00002458 region_geometry.x,region_geometry.y,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002459 *image=DestroyImage(*image);
2460 *image=region_image;
2461 region_image = (Image *) NULL;
2462 }
2463 if (*option == '+')
2464 break;
2465 /*
2466 Apply transformations to a selected region of the image.
2467 */
cristy3ed852e2009-09-05 21:47:34 +00002468 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2469 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002470 mogrify_image=CropImage(*image,&region_geometry,exception);
2471 if (mogrify_image == (Image *) NULL)
2472 break;
2473 region_image=(*image);
2474 *image=mogrify_image;
2475 mogrify_image=(Image *) NULL;
2476 break;
cristy3ed852e2009-09-05 21:47:34 +00002477 }
anthonydf8ebac2011-04-27 09:03:19 +00002478 if (LocaleCompare("render",option+1) == 0)
2479 {
2480 (void) SyncImageSettings(mogrify_info,*image);
2481 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2482 break;
2483 }
2484 if (LocaleCompare("remap",option+1) == 0)
2485 {
2486 Image
2487 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002488
anthonydf8ebac2011-04-27 09:03:19 +00002489 /*
2490 Transform image colors to match this set of colors.
2491 */
2492 (void) SyncImageSettings(mogrify_info,*image);
2493 if (*option == '+')
2494 break;
2495 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2496 if (remap_image == (Image *) NULL)
2497 break;
cristy018f07f2011-09-04 21:15:19 +00002498 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002499 remap_image=DestroyImage(remap_image);
2500 break;
2501 }
2502 if (LocaleCompare("repage",option+1) == 0)
2503 {
2504 if (*option == '+')
2505 {
2506 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2507 break;
2508 }
2509 (void) ResetImagePage(*image,argv[i+1]);
2510 InheritException(exception,&(*image)->exception);
2511 break;
2512 }
2513 if (LocaleCompare("resample",option+1) == 0)
2514 {
2515 /*
2516 Resample image.
2517 */
2518 (void) SyncImageSettings(mogrify_info,*image);
2519 flags=ParseGeometry(argv[i+1],&geometry_info);
2520 if ((flags & SigmaValue) == 0)
2521 geometry_info.sigma=geometry_info.rho;
2522 mogrify_image=ResampleImage(*image,geometry_info.rho,
2523 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2524 break;
2525 }
2526 if (LocaleCompare("resize",option+1) == 0)
2527 {
2528 /*
2529 Resize image.
2530 */
2531 (void) SyncImageSettings(mogrify_info,*image);
2532 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2533 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2534 (*image)->filter,(*image)->blur,exception);
2535 break;
2536 }
2537 if (LocaleCompare("roll",option+1) == 0)
2538 {
2539 /*
2540 Roll image.
2541 */
2542 (void) SyncImageSettings(mogrify_info,*image);
2543 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2544 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2545 break;
2546 }
2547 if (LocaleCompare("rotate",option+1) == 0)
2548 {
2549 char
2550 *geometry;
2551
2552 /*
2553 Check for conditional image rotation.
2554 */
2555 (void) SyncImageSettings(mogrify_info,*image);
2556 if (strchr(argv[i+1],'>') != (char *) NULL)
2557 if ((*image)->columns <= (*image)->rows)
2558 break;
2559 if (strchr(argv[i+1],'<') != (char *) NULL)
2560 if ((*image)->columns >= (*image)->rows)
2561 break;
2562 /*
2563 Rotate image.
2564 */
2565 geometry=ConstantString(argv[i+1]);
2566 (void) SubstituteString(&geometry,">","");
2567 (void) SubstituteString(&geometry,"<","");
2568 (void) ParseGeometry(geometry,&geometry_info);
2569 geometry=DestroyString(geometry);
2570 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2571 break;
2572 }
2573 break;
2574 }
2575 case 's':
2576 {
2577 if (LocaleCompare("sample",option+1) == 0)
2578 {
2579 /*
2580 Sample image with pixel replication.
2581 */
2582 (void) SyncImageSettings(mogrify_info,*image);
2583 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2584 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2585 exception);
2586 break;
2587 }
2588 if (LocaleCompare("scale",option+1) == 0)
2589 {
2590 /*
2591 Resize image.
2592 */
2593 (void) SyncImageSettings(mogrify_info,*image);
2594 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2595 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2596 exception);
2597 break;
2598 }
2599 if (LocaleCompare("selective-blur",option+1) == 0)
2600 {
2601 /*
2602 Selectively blur pixels within a contrast threshold.
2603 */
2604 (void) SyncImageSettings(mogrify_info,*image);
2605 flags=ParseGeometry(argv[i+1],&geometry_info);
2606 if ((flags & PercentValue) != 0)
2607 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristyf4ad9df2011-07-08 16:49:03 +00002608 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
cristy1e7aa312011-09-10 20:01:36 +00002609 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002610 break;
2611 }
2612 if (LocaleCompare("separate",option+1) == 0)
2613 {
2614 /*
2615 Break channels into separate images.
anthonydf8ebac2011-04-27 09:03:19 +00002616 */
2617 (void) SyncImageSettings(mogrify_info,*image);
cristy3139dc22011-07-08 00:11:42 +00002618 mogrify_image=SeparateImages(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002619 break;
2620 }
2621 if (LocaleCompare("sepia-tone",option+1) == 0)
2622 {
2623 double
2624 threshold;
2625
2626 /*
2627 Sepia-tone image.
2628 */
2629 (void) SyncImageSettings(mogrify_info,*image);
2630 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2631 mogrify_image=SepiaToneImage(*image,threshold,exception);
2632 break;
2633 }
2634 if (LocaleCompare("segment",option+1) == 0)
2635 {
2636 /*
2637 Segment image.
2638 */
2639 (void) SyncImageSettings(mogrify_info,*image);
2640 flags=ParseGeometry(argv[i+1],&geometry_info);
2641 if ((flags & SigmaValue) == 0)
2642 geometry_info.sigma=1.0;
2643 (void) SegmentImage(*image,(*image)->colorspace,
cristy018f07f2011-09-04 21:15:19 +00002644 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2645 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002646 break;
2647 }
2648 if (LocaleCompare("set",option+1) == 0)
2649 {
2650 char
2651 *value;
2652
2653 /*
2654 Set image option.
2655 */
2656 if (*option == '+')
2657 {
2658 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2659 (void) DeleteImageRegistry(argv[i+1]+9);
2660 else
2661 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2662 {
2663 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2664 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2665 }
2666 else
2667 (void) DeleteImageProperty(*image,argv[i+1]);
2668 break;
2669 }
cristy018f07f2011-09-04 21:15:19 +00002670 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2671 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002672 if (value == (char *) NULL)
2673 break;
2674 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2675 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2676 exception);
2677 else
2678 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2679 {
2680 (void) SetImageOption(image_info,argv[i+1]+7,value);
2681 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2682 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2683 }
2684 else
cristyd15e6592011-10-15 00:13:06 +00002685 (void) SetImageProperty(*image,argv[i+1],value,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002686 value=DestroyString(value);
2687 break;
2688 }
2689 if (LocaleCompare("shade",option+1) == 0)
2690 {
2691 /*
2692 Shade image.
2693 */
2694 (void) SyncImageSettings(mogrify_info,*image);
2695 flags=ParseGeometry(argv[i+1],&geometry_info);
2696 if ((flags & SigmaValue) == 0)
2697 geometry_info.sigma=1.0;
2698 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2699 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2700 break;
2701 }
2702 if (LocaleCompare("shadow",option+1) == 0)
2703 {
2704 /*
2705 Shadow image.
2706 */
2707 (void) SyncImageSettings(mogrify_info,*image);
2708 flags=ParseGeometry(argv[i+1],&geometry_info);
2709 if ((flags & SigmaValue) == 0)
2710 geometry_info.sigma=1.0;
2711 if ((flags & XiValue) == 0)
2712 geometry_info.xi=4.0;
2713 if ((flags & PsiValue) == 0)
2714 geometry_info.psi=4.0;
2715 mogrify_image=ShadowImage(*image,geometry_info.rho,
2716 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2717 ceil(geometry_info.psi-0.5),exception);
2718 break;
2719 }
2720 if (LocaleCompare("sharpen",option+1) == 0)
2721 {
2722 /*
2723 Sharpen image.
2724 */
2725 (void) SyncImageSettings(mogrify_info,*image);
2726 flags=ParseGeometry(argv[i+1],&geometry_info);
2727 if ((flags & SigmaValue) == 0)
2728 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00002729 if ((flags & XiValue) == 0)
2730 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00002731 mogrify_image=SharpenImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00002732 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002733 break;
2734 }
2735 if (LocaleCompare("shave",option+1) == 0)
2736 {
2737 /*
2738 Shave the image edges.
2739 */
2740 (void) SyncImageSettings(mogrify_info,*image);
2741 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2742 mogrify_image=ShaveImage(*image,&geometry,exception);
2743 break;
2744 }
2745 if (LocaleCompare("shear",option+1) == 0)
2746 {
2747 /*
2748 Shear image.
2749 */
2750 (void) SyncImageSettings(mogrify_info,*image);
2751 flags=ParseGeometry(argv[i+1],&geometry_info);
2752 if ((flags & SigmaValue) == 0)
2753 geometry_info.sigma=geometry_info.rho;
2754 mogrify_image=ShearImage(*image,geometry_info.rho,
2755 geometry_info.sigma,exception);
2756 break;
2757 }
2758 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2759 {
2760 /*
2761 Sigmoidal non-linearity contrast control.
2762 */
2763 (void) SyncImageSettings(mogrify_info,*image);
2764 flags=ParseGeometry(argv[i+1],&geometry_info);
2765 if ((flags & SigmaValue) == 0)
2766 geometry_info.sigma=(double) QuantumRange/2.0;
2767 if ((flags & PercentValue) != 0)
2768 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2769 100.0;
cristy9ee60942011-07-06 14:54:38 +00002770 (void) SigmoidalContrastImage(*image,(*option == '-') ?
cristy33bd5152011-08-24 01:42:24 +00002771 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2772 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002773 break;
2774 }
2775 if (LocaleCompare("sketch",option+1) == 0)
2776 {
2777 /*
2778 Sketch image.
2779 */
2780 (void) SyncImageSettings(mogrify_info,*image);
2781 flags=ParseGeometry(argv[i+1],&geometry_info);
2782 if ((flags & SigmaValue) == 0)
2783 geometry_info.sigma=1.0;
2784 mogrify_image=SketchImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002785 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002786 break;
2787 }
2788 if (LocaleCompare("solarize",option+1) == 0)
2789 {
2790 double
2791 threshold;
2792
2793 (void) SyncImageSettings(mogrify_info,*image);
2794 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy5cbc0162011-08-29 00:36:28 +00002795 (void) SolarizeImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002796 break;
2797 }
2798 if (LocaleCompare("sparse-color",option+1) == 0)
2799 {
2800 SparseColorMethod
2801 method;
2802
2803 char
2804 *arguments;
2805
2806 /*
2807 Sparse Color Interpolated Gradient
2808 */
2809 (void) SyncImageSettings(mogrify_info,*image);
2810 method=(SparseColorMethod) ParseCommandOption(
2811 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00002812 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2813 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002814 if (arguments == (char *) NULL)
2815 break;
cristy3884f692011-07-08 18:00:18 +00002816 mogrify_image=SparseColorOption(*image,method,arguments,
anthonydf8ebac2011-04-27 09:03:19 +00002817 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2818 arguments=DestroyString(arguments);
2819 break;
2820 }
2821 if (LocaleCompare("splice",option+1) == 0)
2822 {
2823 /*
2824 Splice a solid color into the image.
2825 */
2826 (void) SyncImageSettings(mogrify_info,*image);
2827 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2828 mogrify_image=SpliceImage(*image,&geometry,exception);
2829 break;
2830 }
2831 if (LocaleCompare("spread",option+1) == 0)
2832 {
2833 /*
2834 Spread an image.
2835 */
2836 (void) SyncImageSettings(mogrify_info,*image);
2837 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy5c4e2582011-09-11 19:21:03 +00002838 mogrify_image=SpreadImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00002839 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002840 break;
2841 }
2842 if (LocaleCompare("statistic",option+1) == 0)
2843 {
2844 StatisticType
2845 type;
2846
2847 (void) SyncImageSettings(mogrify_info,*image);
2848 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2849 MagickFalse,argv[i+1]);
2850 (void) ParseGeometry(argv[i+2],&geometry_info);
cristyf4ad9df2011-07-08 16:49:03 +00002851 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2852 (size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002853 break;
2854 }
2855 if (LocaleCompare("stretch",option+1) == 0)
2856 {
2857 if (*option == '+')
2858 {
2859 draw_info->stretch=UndefinedStretch;
2860 break;
2861 }
2862 draw_info->stretch=(StretchType) ParseCommandOption(
2863 MagickStretchOptions,MagickFalse,argv[i+1]);
2864 break;
2865 }
2866 if (LocaleCompare("strip",option+1) == 0)
2867 {
2868 /*
2869 Strip image of profiles and comments.
2870 */
2871 (void) SyncImageSettings(mogrify_info,*image);
cristye941a752011-10-15 01:52:48 +00002872 (void) StripImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002873 break;
2874 }
2875 if (LocaleCompare("stroke",option+1) == 0)
2876 {
2877 ExceptionInfo
2878 *sans;
2879
2880 if (*option == '+')
2881 {
cristy9950d572011-10-01 18:22:35 +00002882 (void) QueryColorCompliance("none",AllCompliance,
2883 &draw_info->stroke,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002884 if (draw_info->stroke_pattern != (Image *) NULL)
2885 draw_info->stroke_pattern=DestroyImage(
2886 draw_info->stroke_pattern);
2887 break;
2888 }
2889 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00002890 status=QueryColorCompliance(argv[i+1],AllCompliance,
2891 &draw_info->stroke,sans);
anthonydf8ebac2011-04-27 09:03:19 +00002892 sans=DestroyExceptionInfo(sans);
2893 if (status == MagickFalse)
2894 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2895 exception);
2896 break;
2897 }
2898 if (LocaleCompare("strokewidth",option+1) == 0)
2899 {
cristyc1acd842011-05-19 23:05:47 +00002900 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2901 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002902 break;
2903 }
2904 if (LocaleCompare("style",option+1) == 0)
2905 {
2906 if (*option == '+')
2907 {
2908 draw_info->style=UndefinedStyle;
2909 break;
2910 }
2911 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2912 MagickFalse,argv[i+1]);
2913 break;
2914 }
2915 if (LocaleCompare("swirl",option+1) == 0)
2916 {
2917 /*
2918 Swirl image.
2919 */
2920 (void) SyncImageSettings(mogrify_info,*image);
2921 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00002922 mogrify_image=SwirlImage(*image,geometry_info.rho,
2923 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002924 break;
2925 }
2926 break;
2927 }
2928 case 't':
2929 {
2930 if (LocaleCompare("threshold",option+1) == 0)
2931 {
2932 double
2933 threshold;
2934
2935 /*
2936 Threshold image.
2937 */
2938 (void) SyncImageSettings(mogrify_info,*image);
2939 if (*option == '+')
anthony247a86d2011-05-03 13:18:18 +00002940 threshold=(double) QuantumRange/2;
anthonydf8ebac2011-04-27 09:03:19 +00002941 else
2942 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristye941a752011-10-15 01:52:48 +00002943 (void) BilevelImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002944 InheritException(exception,&(*image)->exception);
2945 break;
2946 }
2947 if (LocaleCompare("thumbnail",option+1) == 0)
2948 {
2949 /*
2950 Thumbnail image.
2951 */
2952 (void) SyncImageSettings(mogrify_info,*image);
2953 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2954 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2955 exception);
2956 break;
2957 }
2958 if (LocaleCompare("tile",option+1) == 0)
2959 {
2960 if (*option == '+')
2961 {
2962 if (draw_info->fill_pattern != (Image *) NULL)
2963 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2964 break;
2965 }
2966 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2967 exception);
2968 break;
2969 }
2970 if (LocaleCompare("tint",option+1) == 0)
2971 {
2972 /*
2973 Tint the image.
2974 */
2975 (void) SyncImageSettings(mogrify_info,*image);
cristy28474bf2011-09-11 23:32:52 +00002976 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002977 break;
2978 }
2979 if (LocaleCompare("transform",option+1) == 0)
2980 {
2981 /*
2982 Affine transform image.
2983 */
2984 (void) SyncImageSettings(mogrify_info,*image);
2985 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2986 exception);
2987 break;
2988 }
2989 if (LocaleCompare("transparent",option+1) == 0)
2990 {
cristy4c08aed2011-07-01 19:47:50 +00002991 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002992 target;
2993
2994 (void) SyncImageSettings(mogrify_info,*image);
cristy269c9412011-10-13 23:41:15 +00002995 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00002996 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002997 (void) TransparentPaintImage(*image,&target,(Quantum)
cristy189e84c2011-08-27 18:08:53 +00002998 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2999 &(*image)->exception);
anthonydf8ebac2011-04-27 09:03:19 +00003000 break;
3001 }
3002 if (LocaleCompare("transpose",option+1) == 0)
3003 {
3004 /*
3005 Transpose image scanlines.
3006 */
3007 (void) SyncImageSettings(mogrify_info,*image);
3008 mogrify_image=TransposeImage(*image,exception);
3009 break;
3010 }
3011 if (LocaleCompare("transverse",option+1) == 0)
3012 {
3013 /*
3014 Transverse image scanlines.
3015 */
3016 (void) SyncImageSettings(mogrify_info,*image);
3017 mogrify_image=TransverseImage(*image,exception);
3018 break;
3019 }
3020 if (LocaleCompare("treedepth",option+1) == 0)
3021 {
3022 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3023 break;
3024 }
3025 if (LocaleCompare("trim",option+1) == 0)
3026 {
3027 /*
3028 Trim image.
3029 */
3030 (void) SyncImageSettings(mogrify_info,*image);
3031 mogrify_image=TrimImage(*image,exception);
3032 break;
3033 }
3034 if (LocaleCompare("type",option+1) == 0)
3035 {
3036 ImageType
3037 type;
3038
3039 (void) SyncImageSettings(mogrify_info,*image);
3040 if (*option == '+')
3041 type=UndefinedType;
3042 else
3043 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3044 argv[i+1]);
3045 (*image)->type=UndefinedType;
cristy018f07f2011-09-04 21:15:19 +00003046 (void) SetImageType(*image,type,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003047 break;
3048 }
3049 break;
3050 }
3051 case 'u':
3052 {
3053 if (LocaleCompare("undercolor",option+1) == 0)
3054 {
cristy9950d572011-10-01 18:22:35 +00003055 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3056 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003057 break;
3058 }
3059 if (LocaleCompare("unique",option+1) == 0)
3060 {
3061 if (*option == '+')
3062 {
3063 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3064 break;
3065 }
3066 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3067 (void) SetImageArtifact(*image,"verbose","true");
3068 break;
3069 }
3070 if (LocaleCompare("unique-colors",option+1) == 0)
3071 {
3072 /*
3073 Unique image colors.
3074 */
3075 (void) SyncImageSettings(mogrify_info,*image);
3076 mogrify_image=UniqueImageColors(*image,exception);
3077 break;
3078 }
3079 if (LocaleCompare("unsharp",option+1) == 0)
3080 {
3081 /*
3082 Unsharp mask image.
3083 */
3084 (void) SyncImageSettings(mogrify_info,*image);
3085 flags=ParseGeometry(argv[i+1],&geometry_info);
3086 if ((flags & SigmaValue) == 0)
3087 geometry_info.sigma=1.0;
3088 if ((flags & XiValue) == 0)
3089 geometry_info.xi=1.0;
3090 if ((flags & PsiValue) == 0)
3091 geometry_info.psi=0.05;
cristyf4ad9df2011-07-08 16:49:03 +00003092 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3093 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003094 break;
3095 }
3096 break;
3097 }
3098 case 'v':
3099 {
3100 if (LocaleCompare("verbose",option+1) == 0)
3101 {
3102 (void) SetImageArtifact(*image,option+1,
3103 *option == '+' ? "false" : "true");
3104 break;
3105 }
3106 if (LocaleCompare("vignette",option+1) == 0)
3107 {
3108 /*
3109 Vignette image.
3110 */
3111 (void) SyncImageSettings(mogrify_info,*image);
3112 flags=ParseGeometry(argv[i+1],&geometry_info);
3113 if ((flags & SigmaValue) == 0)
3114 geometry_info.sigma=1.0;
3115 if ((flags & XiValue) == 0)
3116 geometry_info.xi=0.1*(*image)->columns;
3117 if ((flags & PsiValue) == 0)
3118 geometry_info.psi=0.1*(*image)->rows;
3119 mogrify_image=VignetteImage(*image,geometry_info.rho,
3120 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3121 ceil(geometry_info.psi-0.5),exception);
3122 break;
3123 }
3124 if (LocaleCompare("virtual-pixel",option+1) == 0)
3125 {
3126 if (*option == '+')
3127 {
3128 (void) SetImageVirtualPixelMethod(*image,
3129 UndefinedVirtualPixelMethod);
3130 break;
3131 }
3132 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3133 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3134 argv[i+1]));
3135 break;
3136 }
3137 break;
3138 }
3139 case 'w':
3140 {
3141 if (LocaleCompare("wave",option+1) == 0)
3142 {
3143 /*
3144 Wave image.
3145 */
3146 (void) SyncImageSettings(mogrify_info,*image);
3147 flags=ParseGeometry(argv[i+1],&geometry_info);
3148 if ((flags & SigmaValue) == 0)
3149 geometry_info.sigma=1.0;
3150 mogrify_image=WaveImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00003151 geometry_info.sigma,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003152 break;
3153 }
3154 if (LocaleCompare("weight",option+1) == 0)
3155 {
3156 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3157 if (LocaleCompare(argv[i+1],"all") == 0)
3158 draw_info->weight=0;
3159 if (LocaleCompare(argv[i+1],"bold") == 0)
3160 draw_info->weight=700;
3161 if (LocaleCompare(argv[i+1],"bolder") == 0)
3162 if (draw_info->weight <= 800)
3163 draw_info->weight+=100;
3164 if (LocaleCompare(argv[i+1],"lighter") == 0)
3165 if (draw_info->weight >= 100)
3166 draw_info->weight-=100;
3167 if (LocaleCompare(argv[i+1],"normal") == 0)
3168 draw_info->weight=400;
3169 break;
3170 }
3171 if (LocaleCompare("white-threshold",option+1) == 0)
3172 {
3173 /*
3174 White threshold image.
3175 */
3176 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00003177 (void) WhiteThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00003178 InheritException(exception,&(*image)->exception);
3179 break;
3180 }
3181 break;
3182 }
3183 default:
3184 break;
3185 }
3186 /*
3187 Replace current image with any image that was generated
3188 */
3189 if (mogrify_image != (Image *) NULL)
3190 ReplaceImageInListReturnLast(image,mogrify_image);
cristy3ed852e2009-09-05 21:47:34 +00003191 i+=count;
3192 }
3193 if (region_image != (Image *) NULL)
3194 {
anthonydf8ebac2011-04-27 09:03:19 +00003195 /*
3196 Composite transformed region onto image.
3197 */
cristy6b3da3a2010-06-20 02:21:46 +00003198 (void) SyncImageSettings(mogrify_info,*image);
anthonya129f702011-04-14 01:08:48 +00003199 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00003200 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
cristye941a752011-10-15 01:52:48 +00003201 region_geometry.x,region_geometry.y,exception);
cristy3ed852e2009-09-05 21:47:34 +00003202 *image=DestroyImage(*image);
3203 *image=region_image;
anthonye9c27192011-03-27 08:07:06 +00003204 region_image = (Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00003205 }
3206 /*
3207 Free resources.
3208 */
anthonydf8ebac2011-04-27 09:03:19 +00003209 quantize_info=DestroyQuantizeInfo(quantize_info);
3210 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003211 mogrify_info=DestroyImageInfo(mogrify_info);
cristy4c08aed2011-07-01 19:47:50 +00003212 status=(MagickStatusType) ((*image)->exception.severity ==
cristy5f09d852011-05-29 01:39:29 +00003213 UndefinedException ? 1 : 0);
cristy72988482011-03-29 16:34:38 +00003214 return(status == 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00003215}
3216
3217/*
3218%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3219% %
3220% %
3221% %
cristy5063d812010-10-19 16:28:10 +00003222+ M o g r i f y I m a g e C o m m a n d %
cristy3ed852e2009-09-05 21:47:34 +00003223% %
3224% %
3225% %
3226%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3227%
3228% MogrifyImageCommand() transforms an image or a sequence of images. These
3229% transforms include image scaling, image rotation, color reduction, and
3230% others. The transmogrified image overwrites the original image.
3231%
3232% The format of the MogrifyImageCommand method is:
3233%
3234% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3235% const char **argv,char **metadata,ExceptionInfo *exception)
3236%
3237% A description of each parameter follows:
3238%
3239% o image_info: the image info.
3240%
3241% o argc: the number of elements in the argument vector.
3242%
3243% o argv: A text array containing the command line arguments.
3244%
3245% o metadata: any metadata is returned here.
3246%
3247% o exception: return any errors or warnings in this structure.
3248%
3249*/
3250
3251static MagickBooleanType MogrifyUsage(void)
3252{
3253 static const char
3254 *miscellaneous[]=
3255 {
3256 "-debug events display copious debugging information",
3257 "-help print program options",
3258 "-list type print a list of supported option arguments",
3259 "-log format format of debugging information",
3260 "-version print version information",
3261 (char *) NULL
3262 },
3263 *operators[]=
3264 {
3265 "-adaptive-blur geometry",
3266 " adaptively blur pixels; decrease effect near edges",
3267 "-adaptive-resize geometry",
3268 " adaptively resize image using 'mesh' interpolation",
3269 "-adaptive-sharpen geometry",
3270 " adaptively sharpen pixels; increase effect near edges",
3271 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3272 " transparent, extract, background, or shape",
3273 "-annotate geometry text",
3274 " annotate the image with text",
3275 "-auto-gamma automagically adjust gamma level of image",
3276 "-auto-level automagically adjust color levels of image",
3277 "-auto-orient automagically orient (rotate) image",
3278 "-bench iterations measure performance",
3279 "-black-threshold value",
3280 " force all pixels below the threshold into black",
3281 "-blue-shift simulate a scene at nighttime in the moonlight",
3282 "-blur geometry reduce image noise and reduce detail levels",
3283 "-border geometry surround image with a border of color",
3284 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003285 "-brightness-contrast geometry",
3286 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003287 "-cdl filename color correct with a color decision list",
cristy05c0c9a2011-09-05 23:16:13 +00003288 "-charcoal geometry simulate a charcoal drawing",
cristy3ed852e2009-09-05 21:47:34 +00003289 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003290 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003291 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003292 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003293 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003294 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003295 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003296 "-contrast enhance or reduce the image contrast",
3297 "-contrast-stretch geometry",
3298 " improve contrast by `stretching' the intensity range",
3299 "-convolve coefficients",
3300 " apply a convolution kernel to the image",
3301 "-cycle amount cycle the image colormap",
3302 "-decipher filename convert cipher pixels to plain pixels",
3303 "-deskew threshold straighten an image",
3304 "-despeckle reduce the speckles within an image",
3305 "-distort method args",
3306 " distort images according to given method ad args",
3307 "-draw string annotate the image with a graphic primitive",
3308 "-edge radius apply a filter to detect edges in the image",
3309 "-encipher filename convert plain pixels to cipher pixels",
3310 "-emboss radius emboss an image",
3311 "-enhance apply a digital filter to enhance a noisy image",
3312 "-equalize perform histogram equalization to an image",
3313 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003314 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003315 "-extent geometry set the image size",
3316 "-extract geometry extract area from image",
3317 "-fft implements the discrete Fourier transform (DFT)",
3318 "-flip flip image vertically",
3319 "-floodfill geometry color",
3320 " floodfill the image with color",
3321 "-flop flop image horizontally",
3322 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003323 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003324 " apply function over image values",
3325 "-gamma value level of gamma correction",
3326 "-gaussian-blur geometry",
3327 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003328 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003329 "-identify identify the format and characteristics of the image",
3330 "-ift implements the inverse discrete Fourier transform (DFT)",
3331 "-implode amount implode image pixels about the center",
3332 "-lat geometry local adaptive thresholding",
3333 "-layers method optimize, merge, or compare image layers",
3334 "-level value adjust the level of image contrast",
3335 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003336 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003337 "-linear-stretch geometry",
3338 " improve contrast by `stretching with saturation'",
3339 "-liquid-rescale geometry",
3340 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +00003341 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +00003342 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003343 "-modulate value vary the brightness, saturation, and hue",
3344 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003345 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003346 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003347 "-motion-blur geometry",
3348 " simulate motion blur",
3349 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +00003350 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +00003351 "-normalize transform image to span the full range of colors",
3352 "-opaque color change this color to the fill color",
3353 "-ordered-dither NxN",
3354 " add a noise pattern to the image with specific",
3355 " amplitudes",
3356 "-paint radius simulate an oil painting",
3357 "-polaroid angle simulate a Polaroid picture",
3358 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003359 "-profile filename add, delete, or apply an image profile",
3360 "-quantize colorspace reduce colors in this colorspace",
3361 "-radial-blur angle radial blur the image",
3362 "-raise value lighten/darken image edges to create a 3-D effect",
3363 "-random-threshold low,high",
3364 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003365 "-region geometry apply options to a portion of the image",
3366 "-render render vector graphics",
3367 "-repage geometry size and location of an image canvas",
3368 "-resample geometry change the resolution of an image",
3369 "-resize geometry resize the image",
3370 "-roll geometry roll an image vertically or horizontally",
3371 "-rotate degrees apply Paeth rotation to the image",
3372 "-sample geometry scale image with pixel sampling",
3373 "-scale geometry scale the image",
3374 "-segment values segment an image",
3375 "-selective-blur geometry",
3376 " selectively blur pixels within a contrast threshold",
3377 "-sepia-tone threshold",
3378 " simulate a sepia-toned photo",
3379 "-set property value set an image property",
3380 "-shade degrees shade the image using a distant light source",
3381 "-shadow geometry simulate an image shadow",
3382 "-sharpen geometry sharpen the image",
3383 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003384 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003385 "-sigmoidal-contrast geometry",
3386 " increase the contrast without saturating highlights or shadows",
3387 "-sketch geometry simulate a pencil sketch",
3388 "-solarize threshold negate all pixels above the threshold level",
3389 "-sparse-color method args",
3390 " fill in a image based on a few color points",
3391 "-splice geometry splice the background color into the image",
3392 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003393 "-statistic type radius",
3394 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003395 "-strip strip image of all profiles and comments",
3396 "-swirl degrees swirl image pixels about the center",
3397 "-threshold value threshold the image",
3398 "-thumbnail geometry create a thumbnail of the image",
3399 "-tile filename tile image when filling a graphic primitive",
3400 "-tint value tint the image with the fill color",
3401 "-transform affine transform image",
3402 "-transparent color make this color transparent within the image",
3403 "-transpose flip image vertically and rotate 90 degrees",
3404 "-transverse flop image horizontally and rotate 270 degrees",
3405 "-trim trim image edges",
3406 "-type type image type",
3407 "-unique-colors discard all but one of any pixel color",
3408 "-unsharp geometry sharpen the image",
3409 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003410 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003411 "-white-threshold value",
3412 " force all pixels above the threshold into white",
3413 (char *) NULL
3414 },
3415 *sequence_operators[]=
3416 {
cristy4285d782011-02-09 20:12:28 +00003417 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003418 "-clut apply a color lookup table to the image",
3419 "-coalesce merge a sequence of images",
3420 "-combine combine a sequence of images",
3421 "-composite composite image",
3422 "-crop geometry cut out a rectangular region of the image",
3423 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003424 "-evaluate-sequence operator",
3425 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003426 "-flatten flatten a sequence of images",
3427 "-fx expression apply mathematical expression to an image channel(s)",
3428 "-hald-clut apply a Hald color lookup table to the image",
3429 "-morph value morph an image sequence",
3430 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003431 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003432 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003433 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003434 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003435 "-write filename write images to this file",
3436 (char *) NULL
3437 },
3438 *settings[]=
3439 {
3440 "-adjoin join images into a single multi-image file",
3441 "-affine matrix affine transform matrix",
3442 "-alpha option activate, deactivate, reset, or set the alpha channel",
3443 "-antialias remove pixel-aliasing",
3444 "-authenticate password",
3445 " decipher image with this password",
3446 "-attenuate value lessen (or intensify) when adding noise to an image",
3447 "-background color background color",
3448 "-bias value add bias when convolving an image",
3449 "-black-point-compensation",
3450 " use black point compensation",
3451 "-blue-primary point chromaticity blue primary point",
3452 "-bordercolor color border color",
3453 "-caption string assign a caption to an image",
3454 "-channel type apply option to select image channels",
3455 "-colors value preferred number of colors in the image",
3456 "-colorspace type alternate image colorspace",
3457 "-comment string annotate image with comment",
3458 "-compose operator set image composite operator",
3459 "-compress type type of pixel compression when writing the image",
3460 "-define format:option",
3461 " define one or more image format options",
3462 "-delay value display the next image after pausing",
3463 "-density geometry horizontal and vertical density of the image",
3464 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003465 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003466 "-display server get image or font from this X server",
3467 "-dispose method layer disposal method",
3468 "-dither method apply error diffusion to image",
3469 "-encoding type text encoding type",
3470 "-endian type endianness (MSB or LSB) of the image",
3471 "-family name render text with this font family",
3472 "-fill color color to use when filling a graphic primitive",
3473 "-filter type use this filter when resizing an image",
3474 "-font name render text with this font",
3475 "-format \"string\" output formatted image characteristics",
3476 "-fuzz distance colors within this distance are considered equal",
3477 "-gravity type horizontal and vertical text placement",
3478 "-green-primary point chromaticity green primary point",
3479 "-intent type type of rendering intent when managing the image color",
3480 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003481 "-interline-spacing value",
3482 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003483 "-interpolate method pixel color interpolation method",
3484 "-interword-spacing value",
3485 " set the space between two words",
3486 "-kerning value set the space between two letters",
3487 "-label string assign a label to an image",
3488 "-limit type value pixel cache resource limit",
3489 "-loop iterations add Netscape loop extension to your GIF animation",
3490 "-mask filename associate a mask with the image",
3491 "-mattecolor color frame color",
3492 "-monitor monitor progress",
3493 "-orient type image orientation",
3494 "-page geometry size and location of an image canvas (setting)",
3495 "-ping efficiently determine image attributes",
3496 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003497 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003498 "-preview type image preview type",
3499 "-quality value JPEG/MIFF/PNG compression level",
3500 "-quiet suppress all warning messages",
3501 "-red-primary point chromaticity red primary point",
3502 "-regard-warnings pay attention to warning messages",
3503 "-remap filename transform image colors to match this set of colors",
3504 "-respect-parentheses settings remain in effect until parenthesis boundary",
3505 "-sampling-factor geometry",
3506 " horizontal and vertical sampling factor",
3507 "-scene value image scene number",
3508 "-seed value seed a new sequence of pseudo-random numbers",
3509 "-size geometry width and height of image",
3510 "-stretch type render text with this font stretch",
3511 "-stroke color graphic primitive stroke color",
3512 "-strokewidth value graphic primitive stroke width",
3513 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003514 "-synchronize synchronize image to storage device",
3515 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003516 "-texture filename name of texture to tile onto the image background",
3517 "-tile-offset geometry",
3518 " tile offset",
3519 "-treedepth value color tree depth",
3520 "-transparent-color color",
3521 " transparent color",
3522 "-undercolor color annotation bounding box color",
3523 "-units type the units of image resolution",
3524 "-verbose print detailed information about the image",
3525 "-view FlashPix viewing transforms",
3526 "-virtual-pixel method",
3527 " virtual pixel access method",
3528 "-weight type render text with this font weight",
3529 "-white-point point chromaticity white point",
3530 (char *) NULL
3531 },
3532 *stack_operators[]=
3533 {
anthonyb69c4b32011-03-23 04:37:44 +00003534 "-delete indexes delete the image from the image sequence",
3535 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003536 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003537 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003538 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003539 "-swap indexes swap two images in the image sequence",
3540 (char *) NULL
3541 };
3542
3543 const char
3544 **p;
3545
cristybb503372010-05-27 20:51:26 +00003546 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003547 (void) printf("Copyright: %s\n",GetMagickCopyright());
3548 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003549 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3550 GetClientName());
3551 (void) printf("\nImage Settings:\n");
3552 for (p=settings; *p != (char *) NULL; p++)
3553 (void) printf(" %s\n",*p);
3554 (void) printf("\nImage Operators:\n");
3555 for (p=operators; *p != (char *) NULL; p++)
3556 (void) printf(" %s\n",*p);
3557 (void) printf("\nImage Sequence Operators:\n");
3558 for (p=sequence_operators; *p != (char *) NULL; p++)
3559 (void) printf(" %s\n",*p);
3560 (void) printf("\nImage Stack Operators:\n");
3561 for (p=stack_operators; *p != (char *) NULL; p++)
3562 (void) printf(" %s\n",*p);
3563 (void) printf("\nMiscellaneous Options:\n");
3564 for (p=miscellaneous; *p != (char *) NULL; p++)
3565 (void) printf(" %s\n",*p);
3566 (void) printf(
3567 "\nBy default, the image format of `file' is determined by its magic\n");
3568 (void) printf(
3569 "number. To specify a particular image format, precede the filename\n");
3570 (void) printf(
3571 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3572 (void) printf(
3573 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3574 (void) printf("'-' for standard input or output.\n");
3575 return(MagickFalse);
3576}
3577
3578WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3579 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3580{
3581#define DestroyMogrify() \
3582{ \
3583 if (format != (char *) NULL) \
3584 format=DestroyString(format); \
3585 if (path != (char *) NULL) \
3586 path=DestroyString(path); \
3587 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003588 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003589 argv[i]=DestroyString(argv[i]); \
3590 argv=(char **) RelinquishMagickMemory(argv); \
3591}
3592#define ThrowMogrifyException(asperity,tag,option) \
3593{ \
3594 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3595 option); \
3596 DestroyMogrify(); \
3597 return(MagickFalse); \
3598}
3599#define ThrowMogrifyInvalidArgumentException(option,argument) \
3600{ \
3601 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3602 "InvalidArgument","`%s': %s",argument,option); \
3603 DestroyMogrify(); \
3604 return(MagickFalse); \
3605}
3606
3607 char
3608 *format,
3609 *option,
3610 *path;
3611
3612 Image
3613 *image;
3614
3615 ImageStack
3616 image_stack[MaxImageStackDepth+1];
3617
cristy3ed852e2009-09-05 21:47:34 +00003618 MagickBooleanType
3619 global_colormap;
3620
3621 MagickBooleanType
3622 fire,
cristyebbcfea2011-02-25 02:43:54 +00003623 pend,
3624 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00003625
3626 MagickStatusType
3627 status;
3628
cristyebbcfea2011-02-25 02:43:54 +00003629 register ssize_t
3630 i;
3631
3632 ssize_t
3633 j,
3634 k;
3635
cristy3ed852e2009-09-05 21:47:34 +00003636 /*
3637 Set defaults.
3638 */
3639 assert(image_info != (ImageInfo *) NULL);
3640 assert(image_info->signature == MagickSignature);
3641 if (image_info->debug != MagickFalse)
3642 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3643 assert(exception != (ExceptionInfo *) NULL);
3644 if (argc == 2)
3645 {
3646 option=argv[1];
3647 if ((LocaleCompare("version",option+1) == 0) ||
3648 (LocaleCompare("-version",option+1) == 0))
3649 {
cristyb51dff52011-05-19 16:55:47 +00003650 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00003651 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00003652 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3653 GetMagickCopyright());
3654 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3655 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003656 return(MagickFalse);
3657 }
3658 }
3659 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00003660 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00003661 format=(char *) NULL;
3662 path=(char *) NULL;
3663 global_colormap=MagickFalse;
3664 k=0;
3665 j=1;
3666 NewImageStack();
3667 option=(char *) NULL;
3668 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00003669 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003670 status=MagickTrue;
3671 /*
3672 Parse command line.
3673 */
3674 ReadCommandlLine(argc,&argv);
3675 status=ExpandFilenames(&argc,&argv);
3676 if (status == MagickFalse)
3677 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3678 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00003679 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00003680 {
3681 option=argv[i];
3682 if (LocaleCompare(option,"(") == 0)
3683 {
3684 FireImageStack(MagickFalse,MagickTrue,pend);
3685 if (k == MaxImageStackDepth)
3686 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3687 option);
3688 PushImageStack();
3689 continue;
3690 }
3691 if (LocaleCompare(option,")") == 0)
3692 {
3693 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3694 if (k == 0)
3695 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3696 PopImageStack();
3697 continue;
3698 }
cristy042ee782011-04-22 18:48:30 +00003699 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00003700 {
3701 char
3702 backup_filename[MaxTextExtent],
3703 *filename;
3704
3705 Image
3706 *images;
3707
3708 /*
3709 Option is a file name: begin by reading image from specified file.
3710 */
3711 FireImageStack(MagickFalse,MagickFalse,pend);
3712 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00003713 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00003714 filename=argv[++i];
3715 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3716 images=ReadImages(image_info,exception);
3717 status&=(images != (Image *) NULL) &&
3718 (exception->severity < ErrorException);
3719 if (images == (Image *) NULL)
3720 continue;
cristydaa76602010-06-30 13:05:11 +00003721 if (format != (char *) NULL)
3722 (void) CopyMagickString(images->filename,images->magick_filename,
3723 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00003724 if (path != (char *) NULL)
3725 {
3726 GetPathComponent(option,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +00003727 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
cristy3ed852e2009-09-05 21:47:34 +00003728 path,*DirectorySeparator,filename);
3729 }
3730 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00003731 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00003732 AppendImageStack(images);
3733 FinalizeImageSettings(image_info,image,MagickFalse);
3734 if (global_colormap != MagickFalse)
3735 {
3736 QuantizeInfo
3737 *quantize_info;
3738
3739 quantize_info=AcquireQuantizeInfo(image_info);
cristy018f07f2011-09-04 21:15:19 +00003740 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
cristy3ed852e2009-09-05 21:47:34 +00003741 quantize_info=DestroyQuantizeInfo(quantize_info);
3742 }
3743 *backup_filename='\0';
3744 if ((LocaleCompare(image->filename,"-") != 0) &&
3745 (IsPathWritable(image->filename) != MagickFalse))
3746 {
cristybb503372010-05-27 20:51:26 +00003747 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003748 i;
3749
3750 /*
3751 Rename image file as backup.
3752 */
3753 (void) CopyMagickString(backup_filename,image->filename,
3754 MaxTextExtent);
3755 for (i=0; i < 6; i++)
3756 {
3757 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3758 if (IsPathAccessible(backup_filename) == MagickFalse)
3759 break;
3760 }
3761 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
cristy320684d2011-09-23 14:55:47 +00003762 (rename_utf8(image->filename,backup_filename) != 0))
cristy3ed852e2009-09-05 21:47:34 +00003763 *backup_filename='\0';
3764 }
3765 /*
3766 Write transmogrified image to disk.
3767 */
3768 image_info->synchronize=MagickTrue;
3769 status&=WriteImages(image_info,image,image->filename,exception);
3770 if ((status == MagickFalse) && (*backup_filename != '\0'))
cristy18c6c272011-09-23 14:40:37 +00003771 (void) remove_utf8(backup_filename);
cristy3ed852e2009-09-05 21:47:34 +00003772 RemoveAllImageStack();
3773 continue;
3774 }
3775 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3776 switch (*(option+1))
3777 {
3778 case 'a':
3779 {
3780 if (LocaleCompare("adaptive-blur",option+1) == 0)
3781 {
3782 i++;
cristybb503372010-05-27 20:51:26 +00003783 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003784 ThrowMogrifyException(OptionError,"MissingArgument",option);
3785 if (IsGeometry(argv[i]) == MagickFalse)
3786 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3787 break;
3788 }
3789 if (LocaleCompare("adaptive-resize",option+1) == 0)
3790 {
3791 i++;
cristybb503372010-05-27 20:51:26 +00003792 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003793 ThrowMogrifyException(OptionError,"MissingArgument",option);
3794 if (IsGeometry(argv[i]) == MagickFalse)
3795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3796 break;
3797 }
3798 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3799 {
3800 i++;
cristybb503372010-05-27 20:51:26 +00003801 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003802 ThrowMogrifyException(OptionError,"MissingArgument",option);
3803 if (IsGeometry(argv[i]) == MagickFalse)
3804 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3805 break;
3806 }
3807 if (LocaleCompare("affine",option+1) == 0)
3808 {
3809 if (*option == '+')
3810 break;
3811 i++;
cristybb503372010-05-27 20:51:26 +00003812 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003813 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +00003814 break;
3815 }
3816 if (LocaleCompare("alpha",option+1) == 0)
3817 {
cristybb503372010-05-27 20:51:26 +00003818 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003819 type;
3820
3821 if (*option == '+')
3822 break;
3823 i++;
cristybb503372010-05-27 20:51:26 +00003824 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003825 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00003826 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00003827 if (type < 0)
3828 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3829 argv[i]);
3830 break;
3831 }
3832 if (LocaleCompare("annotate",option+1) == 0)
3833 {
3834 if (*option == '+')
3835 break;
3836 i++;
cristybb503372010-05-27 20:51:26 +00003837 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003838 ThrowMogrifyException(OptionError,"MissingArgument",option);
3839 if (IsGeometry(argv[i]) == MagickFalse)
3840 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00003841 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003842 ThrowMogrifyException(OptionError,"MissingArgument",option);
3843 i++;
3844 break;
3845 }
3846 if (LocaleCompare("antialias",option+1) == 0)
3847 break;
3848 if (LocaleCompare("append",option+1) == 0)
3849 break;
3850 if (LocaleCompare("attenuate",option+1) == 0)
3851 {
3852 if (*option == '+')
3853 break;
3854 i++;
cristybb503372010-05-27 20:51:26 +00003855 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003856 ThrowMogrifyException(OptionError,"MissingArgument",option);
3857 if (IsGeometry(argv[i]) == MagickFalse)
3858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3859 break;
3860 }
3861 if (LocaleCompare("authenticate",option+1) == 0)
3862 {
3863 if (*option == '+')
3864 break;
3865 i++;
cristybb503372010-05-27 20:51:26 +00003866 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003867 ThrowMogrifyException(OptionError,"MissingArgument",option);
3868 break;
3869 }
3870 if (LocaleCompare("auto-gamma",option+1) == 0)
3871 break;
3872 if (LocaleCompare("auto-level",option+1) == 0)
3873 break;
3874 if (LocaleCompare("auto-orient",option+1) == 0)
3875 break;
3876 if (LocaleCompare("average",option+1) == 0)
3877 break;
3878 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3879 }
3880 case 'b':
3881 {
3882 if (LocaleCompare("background",option+1) == 0)
3883 {
3884 if (*option == '+')
3885 break;
3886 i++;
cristybb503372010-05-27 20:51:26 +00003887 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003888 ThrowMogrifyException(OptionError,"MissingArgument",option);
3889 break;
3890 }
3891 if (LocaleCompare("bias",option+1) == 0)
3892 {
3893 if (*option == '+')
3894 break;
3895 i++;
cristybb503372010-05-27 20:51:26 +00003896 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003897 ThrowMogrifyException(OptionError,"MissingArgument",option);
3898 if (IsGeometry(argv[i]) == MagickFalse)
3899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3900 break;
3901 }
3902 if (LocaleCompare("black-point-compensation",option+1) == 0)
3903 break;
3904 if (LocaleCompare("black-threshold",option+1) == 0)
3905 {
3906 if (*option == '+')
3907 break;
3908 i++;
cristybb503372010-05-27 20:51:26 +00003909 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003910 ThrowMogrifyException(OptionError,"MissingArgument",option);
3911 if (IsGeometry(argv[i]) == MagickFalse)
3912 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3913 break;
3914 }
3915 if (LocaleCompare("blue-primary",option+1) == 0)
3916 {
3917 if (*option == '+')
3918 break;
3919 i++;
cristybb503372010-05-27 20:51:26 +00003920 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003921 ThrowMogrifyException(OptionError,"MissingArgument",option);
3922 if (IsGeometry(argv[i]) == MagickFalse)
3923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3924 break;
3925 }
3926 if (LocaleCompare("blue-shift",option+1) == 0)
3927 {
3928 i++;
cristybb503372010-05-27 20:51:26 +00003929 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003930 ThrowMogrifyException(OptionError,"MissingArgument",option);
3931 if (IsGeometry(argv[i]) == MagickFalse)
3932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3933 break;
3934 }
3935 if (LocaleCompare("blur",option+1) == 0)
3936 {
3937 i++;
cristybb503372010-05-27 20:51:26 +00003938 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003939 ThrowMogrifyException(OptionError,"MissingArgument",option);
3940 if (IsGeometry(argv[i]) == MagickFalse)
3941 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3942 break;
3943 }
3944 if (LocaleCompare("border",option+1) == 0)
3945 {
3946 if (*option == '+')
3947 break;
3948 i++;
cristybb503372010-05-27 20:51:26 +00003949 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003950 ThrowMogrifyException(OptionError,"MissingArgument",option);
3951 if (IsGeometry(argv[i]) == MagickFalse)
3952 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3953 break;
3954 }
3955 if (LocaleCompare("bordercolor",option+1) == 0)
3956 {
3957 if (*option == '+')
3958 break;
3959 i++;
cristybb503372010-05-27 20:51:26 +00003960 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003961 ThrowMogrifyException(OptionError,"MissingArgument",option);
3962 break;
3963 }
3964 if (LocaleCompare("box",option+1) == 0)
3965 {
3966 if (*option == '+')
3967 break;
3968 i++;
cristybb503372010-05-27 20:51:26 +00003969 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003970 ThrowMogrifyException(OptionError,"MissingArgument",option);
3971 break;
3972 }
cristya28d6b82010-01-11 20:03:47 +00003973 if (LocaleCompare("brightness-contrast",option+1) == 0)
3974 {
3975 i++;
cristybb503372010-05-27 20:51:26 +00003976 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00003977 ThrowMogrifyException(OptionError,"MissingArgument",option);
3978 if (IsGeometry(argv[i]) == MagickFalse)
3979 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3980 break;
3981 }
cristy3ed852e2009-09-05 21:47:34 +00003982 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3983 }
3984 case 'c':
3985 {
3986 if (LocaleCompare("cache",option+1) == 0)
3987 {
3988 if (*option == '+')
3989 break;
3990 i++;
cristybb503372010-05-27 20:51:26 +00003991 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003992 ThrowMogrifyException(OptionError,"MissingArgument",option);
3993 if (IsGeometry(argv[i]) == MagickFalse)
3994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3995 break;
3996 }
3997 if (LocaleCompare("caption",option+1) == 0)
3998 {
3999 if (*option == '+')
4000 break;
4001 i++;
cristybb503372010-05-27 20:51:26 +00004002 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004003 ThrowMogrifyException(OptionError,"MissingArgument",option);
4004 break;
4005 }
4006 if (LocaleCompare("channel",option+1) == 0)
4007 {
cristybb503372010-05-27 20:51:26 +00004008 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004009 channel;
4010
4011 if (*option == '+')
4012 break;
4013 i++;
cristybb503372010-05-27 20:51:26 +00004014 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004015 ThrowMogrifyException(OptionError,"MissingArgument",option);
4016 channel=ParseChannelOption(argv[i]);
4017 if (channel < 0)
4018 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4019 argv[i]);
4020 break;
4021 }
4022 if (LocaleCompare("cdl",option+1) == 0)
4023 {
4024 if (*option == '+')
4025 break;
4026 i++;
cristybb503372010-05-27 20:51:26 +00004027 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004028 ThrowMogrifyException(OptionError,"MissingArgument",option);
4029 break;
4030 }
4031 if (LocaleCompare("charcoal",option+1) == 0)
4032 {
4033 if (*option == '+')
4034 break;
4035 i++;
cristybb503372010-05-27 20:51:26 +00004036 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004037 ThrowMogrifyException(OptionError,"MissingArgument",option);
4038 if (IsGeometry(argv[i]) == MagickFalse)
4039 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4040 break;
4041 }
4042 if (LocaleCompare("chop",option+1) == 0)
4043 {
4044 if (*option == '+')
4045 break;
4046 i++;
cristybb503372010-05-27 20:51:26 +00004047 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004048 ThrowMogrifyException(OptionError,"MissingArgument",option);
4049 if (IsGeometry(argv[i]) == MagickFalse)
4050 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4051 break;
4052 }
cristy1eb45dd2009-09-25 16:38:06 +00004053 if (LocaleCompare("clamp",option+1) == 0)
4054 break;
4055 if (LocaleCompare("clip",option+1) == 0)
4056 break;
cristy3ed852e2009-09-05 21:47:34 +00004057 if (LocaleCompare("clip-mask",option+1) == 0)
4058 {
4059 if (*option == '+')
4060 break;
4061 i++;
cristybb503372010-05-27 20:51:26 +00004062 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004063 ThrowMogrifyException(OptionError,"MissingArgument",option);
4064 break;
4065 }
4066 if (LocaleCompare("clut",option+1) == 0)
4067 break;
4068 if (LocaleCompare("coalesce",option+1) == 0)
4069 break;
4070 if (LocaleCompare("colorize",option+1) == 0)
4071 {
4072 if (*option == '+')
4073 break;
4074 i++;
cristybb503372010-05-27 20:51:26 +00004075 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004076 ThrowMogrifyException(OptionError,"MissingArgument",option);
4077 if (IsGeometry(argv[i]) == MagickFalse)
4078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4079 break;
4080 }
cristye6365592010-04-02 17:31:23 +00004081 if (LocaleCompare("color-matrix",option+1) == 0)
4082 {
cristyb6bd4ad2010-08-08 01:12:27 +00004083 KernelInfo
4084 *kernel_info;
4085
cristye6365592010-04-02 17:31:23 +00004086 if (*option == '+')
4087 break;
4088 i++;
cristybb503372010-05-27 20:51:26 +00004089 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004090 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004091 kernel_info=AcquireKernelInfo(argv[i]);
4092 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004093 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004094 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004095 break;
4096 }
cristy3ed852e2009-09-05 21:47:34 +00004097 if (LocaleCompare("colors",option+1) == 0)
4098 {
4099 if (*option == '+')
4100 break;
4101 i++;
cristybb503372010-05-27 20:51:26 +00004102 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004103 ThrowMogrifyException(OptionError,"MissingArgument",option);
4104 if (IsGeometry(argv[i]) == MagickFalse)
4105 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4106 break;
4107 }
4108 if (LocaleCompare("colorspace",option+1) == 0)
4109 {
cristybb503372010-05-27 20:51:26 +00004110 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004111 colorspace;
4112
4113 if (*option == '+')
4114 break;
4115 i++;
cristybb503372010-05-27 20:51:26 +00004116 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004117 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004118 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004119 argv[i]);
4120 if (colorspace < 0)
4121 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4122 argv[i]);
4123 break;
4124 }
4125 if (LocaleCompare("combine",option+1) == 0)
4126 break;
4127 if (LocaleCompare("comment",option+1) == 0)
4128 {
4129 if (*option == '+')
4130 break;
4131 i++;
cristybb503372010-05-27 20:51:26 +00004132 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004133 ThrowMogrifyException(OptionError,"MissingArgument",option);
4134 break;
4135 }
4136 if (LocaleCompare("composite",option+1) == 0)
4137 break;
4138 if (LocaleCompare("compress",option+1) == 0)
4139 {
cristybb503372010-05-27 20:51:26 +00004140 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004141 compress;
4142
4143 if (*option == '+')
4144 break;
4145 i++;
cristybb503372010-05-27 20:51:26 +00004146 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004147 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004148 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004149 argv[i]);
4150 if (compress < 0)
4151 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4152 argv[i]);
4153 break;
4154 }
cristy22879752009-10-25 23:55:40 +00004155 if (LocaleCompare("concurrent",option+1) == 0)
4156 break;
cristy3ed852e2009-09-05 21:47:34 +00004157 if (LocaleCompare("contrast",option+1) == 0)
4158 break;
4159 if (LocaleCompare("contrast-stretch",option+1) == 0)
4160 {
4161 i++;
cristybb503372010-05-27 20:51:26 +00004162 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004163 ThrowMogrifyException(OptionError,"MissingArgument",option);
4164 if (IsGeometry(argv[i]) == MagickFalse)
4165 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4166 break;
4167 }
4168 if (LocaleCompare("convolve",option+1) == 0)
4169 {
cristyb6bd4ad2010-08-08 01:12:27 +00004170 KernelInfo
4171 *kernel_info;
4172
cristy3ed852e2009-09-05 21:47:34 +00004173 if (*option == '+')
4174 break;
4175 i++;
cristybb503372010-05-27 20:51:26 +00004176 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004177 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004178 kernel_info=AcquireKernelInfo(argv[i]);
4179 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004180 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004181 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004182 break;
4183 }
4184 if (LocaleCompare("crop",option+1) == 0)
4185 {
4186 if (*option == '+')
4187 break;
4188 i++;
cristybb503372010-05-27 20:51:26 +00004189 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004190 ThrowMogrifyException(OptionError,"MissingArgument",option);
4191 if (IsGeometry(argv[i]) == MagickFalse)
4192 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4193 break;
4194 }
4195 if (LocaleCompare("cycle",option+1) == 0)
4196 {
4197 if (*option == '+')
4198 break;
4199 i++;
cristybb503372010-05-27 20:51:26 +00004200 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004201 ThrowMogrifyException(OptionError,"MissingArgument",option);
4202 if (IsGeometry(argv[i]) == MagickFalse)
4203 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4204 break;
4205 }
4206 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4207 }
4208 case 'd':
4209 {
4210 if (LocaleCompare("decipher",option+1) == 0)
4211 {
4212 if (*option == '+')
4213 break;
4214 i++;
cristybb503372010-05-27 20:51:26 +00004215 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004216 ThrowMogrifyException(OptionError,"MissingArgument",option);
4217 break;
4218 }
4219 if (LocaleCompare("deconstruct",option+1) == 0)
4220 break;
4221 if (LocaleCompare("debug",option+1) == 0)
4222 {
cristybb503372010-05-27 20:51:26 +00004223 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004224 event;
4225
4226 if (*option == '+')
4227 break;
4228 i++;
cristybb503372010-05-27 20:51:26 +00004229 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004230 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004231 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004232 if (event < 0)
4233 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4234 argv[i]);
4235 (void) SetLogEventMask(argv[i]);
4236 break;
4237 }
4238 if (LocaleCompare("define",option+1) == 0)
4239 {
4240 i++;
cristybb503372010-05-27 20:51:26 +00004241 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004242 ThrowMogrifyException(OptionError,"MissingArgument",option);
4243 if (*option == '+')
4244 {
4245 const char
4246 *define;
4247
4248 define=GetImageOption(image_info,argv[i]);
4249 if (define == (const char *) NULL)
4250 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4251 break;
4252 }
4253 break;
4254 }
4255 if (LocaleCompare("delay",option+1) == 0)
4256 {
4257 if (*option == '+')
4258 break;
4259 i++;
cristybb503372010-05-27 20:51:26 +00004260 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004261 ThrowMogrifyException(OptionError,"MissingArgument",option);
4262 if (IsGeometry(argv[i]) == MagickFalse)
4263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4264 break;
4265 }
cristyecb10ff2011-03-22 13:14:03 +00004266 if (LocaleCompare("delete",option+1) == 0)
4267 {
4268 if (*option == '+')
4269 break;
4270 i++;
4271 if (i == (ssize_t) (argc-1))
4272 ThrowMogrifyException(OptionError,"MissingArgument",option);
4273 if (IsGeometry(argv[i]) == MagickFalse)
4274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4275 break;
4276 }
cristy3ed852e2009-09-05 21:47:34 +00004277 if (LocaleCompare("density",option+1) == 0)
4278 {
4279 if (*option == '+')
4280 break;
4281 i++;
cristybb503372010-05-27 20:51:26 +00004282 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004283 ThrowMogrifyException(OptionError,"MissingArgument",option);
4284 if (IsGeometry(argv[i]) == MagickFalse)
4285 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4286 break;
4287 }
4288 if (LocaleCompare("depth",option+1) == 0)
4289 {
4290 if (*option == '+')
4291 break;
4292 i++;
cristybb503372010-05-27 20:51:26 +00004293 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004294 ThrowMogrifyException(OptionError,"MissingArgument",option);
4295 if (IsGeometry(argv[i]) == MagickFalse)
4296 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4297 break;
4298 }
4299 if (LocaleCompare("deskew",option+1) == 0)
4300 {
4301 if (*option == '+')
4302 break;
4303 i++;
cristybb503372010-05-27 20:51:26 +00004304 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004305 ThrowMogrifyException(OptionError,"MissingArgument",option);
4306 if (IsGeometry(argv[i]) == MagickFalse)
4307 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4308 break;
4309 }
4310 if (LocaleCompare("despeckle",option+1) == 0)
4311 break;
4312 if (LocaleCompare("dft",option+1) == 0)
4313 break;
cristyc9b12952010-03-28 01:12:28 +00004314 if (LocaleCompare("direction",option+1) == 0)
4315 {
cristybb503372010-05-27 20:51:26 +00004316 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004317 direction;
4318
4319 if (*option == '+')
4320 break;
4321 i++;
cristybb503372010-05-27 20:51:26 +00004322 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004323 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004324 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00004325 argv[i]);
4326 if (direction < 0)
4327 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4328 argv[i]);
4329 break;
4330 }
cristy3ed852e2009-09-05 21:47:34 +00004331 if (LocaleCompare("display",option+1) == 0)
4332 {
4333 if (*option == '+')
4334 break;
4335 i++;
cristybb503372010-05-27 20:51:26 +00004336 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004337 ThrowMogrifyException(OptionError,"MissingArgument",option);
4338 break;
4339 }
4340 if (LocaleCompare("dispose",option+1) == 0)
4341 {
cristybb503372010-05-27 20:51:26 +00004342 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004343 dispose;
4344
4345 if (*option == '+')
4346 break;
4347 i++;
cristybb503372010-05-27 20:51:26 +00004348 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004349 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004350 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004351 if (dispose < 0)
4352 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4353 argv[i]);
4354 break;
4355 }
4356 if (LocaleCompare("distort",option+1) == 0)
4357 {
cristybb503372010-05-27 20:51:26 +00004358 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004359 op;
4360
4361 i++;
cristybb503372010-05-27 20:51:26 +00004362 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004363 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004364 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004365 if (op < 0)
4366 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4367 argv[i]);
4368 i++;
cristybb503372010-05-27 20:51:26 +00004369 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004370 ThrowMogrifyException(OptionError,"MissingArgument",option);
4371 break;
4372 }
4373 if (LocaleCompare("dither",option+1) == 0)
4374 {
cristybb503372010-05-27 20:51:26 +00004375 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004376 method;
4377
4378 if (*option == '+')
4379 break;
4380 i++;
cristybb503372010-05-27 20:51:26 +00004381 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004382 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004383 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004384 if (method < 0)
4385 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4386 argv[i]);
4387 break;
4388 }
4389 if (LocaleCompare("draw",option+1) == 0)
4390 {
4391 if (*option == '+')
4392 break;
4393 i++;
cristybb503372010-05-27 20:51:26 +00004394 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004395 ThrowMogrifyException(OptionError,"MissingArgument",option);
4396 break;
4397 }
cristyecb10ff2011-03-22 13:14:03 +00004398 if (LocaleCompare("duplicate",option+1) == 0)
4399 {
4400 if (*option == '+')
4401 break;
4402 i++;
4403 if (i == (ssize_t) (argc-1))
4404 ThrowMogrifyException(OptionError,"MissingArgument",option);
4405 if (IsGeometry(argv[i]) == MagickFalse)
4406 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4407 break;
4408 }
cristy22879752009-10-25 23:55:40 +00004409 if (LocaleCompare("duration",option+1) == 0)
4410 {
4411 if (*option == '+')
4412 break;
4413 i++;
cristybb503372010-05-27 20:51:26 +00004414 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004415 ThrowMogrifyException(OptionError,"MissingArgument",option);
4416 if (IsGeometry(argv[i]) == MagickFalse)
4417 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4418 break;
4419 }
cristy3ed852e2009-09-05 21:47:34 +00004420 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4421 }
4422 case 'e':
4423 {
4424 if (LocaleCompare("edge",option+1) == 0)
4425 {
4426 if (*option == '+')
4427 break;
4428 i++;
cristybb503372010-05-27 20:51:26 +00004429 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004430 ThrowMogrifyException(OptionError,"MissingArgument",option);
4431 if (IsGeometry(argv[i]) == MagickFalse)
4432 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4433 break;
4434 }
4435 if (LocaleCompare("emboss",option+1) == 0)
4436 {
4437 if (*option == '+')
4438 break;
4439 i++;
cristybb503372010-05-27 20:51:26 +00004440 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004441 ThrowMogrifyException(OptionError,"MissingArgument",option);
4442 if (IsGeometry(argv[i]) == MagickFalse)
4443 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4444 break;
4445 }
4446 if (LocaleCompare("encipher",option+1) == 0)
4447 {
4448 if (*option == '+')
4449 break;
4450 i++;
cristybb503372010-05-27 20:51:26 +00004451 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004452 ThrowMogrifyException(OptionError,"MissingArgument",option);
4453 break;
4454 }
4455 if (LocaleCompare("encoding",option+1) == 0)
4456 {
4457 if (*option == '+')
4458 break;
4459 i++;
cristybb503372010-05-27 20:51:26 +00004460 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004461 ThrowMogrifyException(OptionError,"MissingArgument",option);
4462 break;
4463 }
4464 if (LocaleCompare("endian",option+1) == 0)
4465 {
cristybb503372010-05-27 20:51:26 +00004466 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004467 endian;
4468
4469 if (*option == '+')
4470 break;
4471 i++;
cristybb503372010-05-27 20:51:26 +00004472 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004473 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004474 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004475 if (endian < 0)
4476 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4477 argv[i]);
4478 break;
4479 }
4480 if (LocaleCompare("enhance",option+1) == 0)
4481 break;
4482 if (LocaleCompare("equalize",option+1) == 0)
4483 break;
4484 if (LocaleCompare("evaluate",option+1) == 0)
4485 {
cristybb503372010-05-27 20:51:26 +00004486 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004487 op;
4488
4489 if (*option == '+')
4490 break;
4491 i++;
cristybb503372010-05-27 20:51:26 +00004492 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004493 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004494 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004495 if (op < 0)
4496 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4497 argv[i]);
4498 i++;
cristybb503372010-05-27 20:51:26 +00004499 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004500 ThrowMogrifyException(OptionError,"MissingArgument",option);
4501 if (IsGeometry(argv[i]) == MagickFalse)
4502 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4503 break;
4504 }
cristyd18ae7c2010-03-07 17:39:52 +00004505 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4506 {
cristybb503372010-05-27 20:51:26 +00004507 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004508 op;
4509
4510 if (*option == '+')
4511 break;
4512 i++;
cristybb503372010-05-27 20:51:26 +00004513 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004514 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004515 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00004516 if (op < 0)
4517 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4518 argv[i]);
4519 break;
4520 }
cristy3ed852e2009-09-05 21:47:34 +00004521 if (LocaleCompare("extent",option+1) == 0)
4522 {
4523 if (*option == '+')
4524 break;
4525 i++;
cristybb503372010-05-27 20:51:26 +00004526 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004527 ThrowMogrifyException(OptionError,"MissingArgument",option);
4528 if (IsGeometry(argv[i]) == MagickFalse)
4529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4530 break;
4531 }
4532 if (LocaleCompare("extract",option+1) == 0)
4533 {
4534 if (*option == '+')
4535 break;
4536 i++;
cristybb503372010-05-27 20:51:26 +00004537 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004538 ThrowMogrifyException(OptionError,"MissingArgument",option);
4539 if (IsGeometry(argv[i]) == MagickFalse)
4540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4541 break;
4542 }
4543 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4544 }
4545 case 'f':
4546 {
4547 if (LocaleCompare("family",option+1) == 0)
4548 {
4549 if (*option == '+')
4550 break;
4551 i++;
cristybb503372010-05-27 20:51:26 +00004552 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004553 ThrowMogrifyException(OptionError,"MissingArgument",option);
4554 break;
4555 }
4556 if (LocaleCompare("fill",option+1) == 0)
4557 {
4558 if (*option == '+')
4559 break;
4560 i++;
cristybb503372010-05-27 20:51:26 +00004561 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004562 ThrowMogrifyException(OptionError,"MissingArgument",option);
4563 break;
4564 }
4565 if (LocaleCompare("filter",option+1) == 0)
4566 {
cristybb503372010-05-27 20:51:26 +00004567 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004568 filter;
4569
4570 if (*option == '+')
4571 break;
4572 i++;
cristybb503372010-05-27 20:51:26 +00004573 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004574 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004575 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004576 if (filter < 0)
4577 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4578 argv[i]);
4579 break;
4580 }
4581 if (LocaleCompare("flatten",option+1) == 0)
4582 break;
4583 if (LocaleCompare("flip",option+1) == 0)
4584 break;
4585 if (LocaleCompare("flop",option+1) == 0)
4586 break;
4587 if (LocaleCompare("floodfill",option+1) == 0)
4588 {
4589 if (*option == '+')
4590 break;
4591 i++;
cristybb503372010-05-27 20:51:26 +00004592 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004593 ThrowMogrifyException(OptionError,"MissingArgument",option);
4594 if (IsGeometry(argv[i]) == MagickFalse)
4595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4596 i++;
cristybb503372010-05-27 20:51:26 +00004597 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004598 ThrowMogrifyException(OptionError,"MissingArgument",option);
4599 break;
4600 }
4601 if (LocaleCompare("font",option+1) == 0)
4602 {
4603 if (*option == '+')
4604 break;
4605 i++;
cristybb503372010-05-27 20:51:26 +00004606 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004607 ThrowMogrifyException(OptionError,"MissingArgument",option);
4608 break;
4609 }
4610 if (LocaleCompare("format",option+1) == 0)
4611 {
4612 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4613 (void) CloneString(&format,(char *) NULL);
4614 if (*option == '+')
4615 break;
4616 i++;
cristybb503372010-05-27 20:51:26 +00004617 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004618 ThrowMogrifyException(OptionError,"MissingArgument",option);
4619 (void) CloneString(&format,argv[i]);
4620 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4621 (void) ConcatenateMagickString(image_info->filename,":",
4622 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00004623 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00004624 if (*image_info->magick == '\0')
4625 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4626 format);
4627 break;
4628 }
4629 if (LocaleCompare("frame",option+1) == 0)
4630 {
4631 if (*option == '+')
4632 break;
4633 i++;
cristybb503372010-05-27 20:51:26 +00004634 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004635 ThrowMogrifyException(OptionError,"MissingArgument",option);
4636 if (IsGeometry(argv[i]) == MagickFalse)
4637 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4638 break;
4639 }
4640 if (LocaleCompare("function",option+1) == 0)
4641 {
cristybb503372010-05-27 20:51:26 +00004642 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004643 op;
4644
4645 if (*option == '+')
4646 break;
4647 i++;
cristybb503372010-05-27 20:51:26 +00004648 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004649 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004650 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004651 if (op < 0)
4652 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4653 i++;
cristybb503372010-05-27 20:51:26 +00004654 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004655 ThrowMogrifyException(OptionError,"MissingArgument",option);
4656 break;
4657 }
4658 if (LocaleCompare("fuzz",option+1) == 0)
4659 {
4660 if (*option == '+')
4661 break;
4662 i++;
cristybb503372010-05-27 20:51:26 +00004663 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004664 ThrowMogrifyException(OptionError,"MissingArgument",option);
4665 if (IsGeometry(argv[i]) == MagickFalse)
4666 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4667 break;
4668 }
4669 if (LocaleCompare("fx",option+1) == 0)
4670 {
4671 if (*option == '+')
4672 break;
4673 i++;
cristybb503372010-05-27 20:51:26 +00004674 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004675 ThrowMogrifyException(OptionError,"MissingArgument",option);
4676 break;
4677 }
4678 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4679 }
4680 case 'g':
4681 {
4682 if (LocaleCompare("gamma",option+1) == 0)
4683 {
4684 i++;
cristybb503372010-05-27 20:51:26 +00004685 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004686 ThrowMogrifyException(OptionError,"MissingArgument",option);
4687 if (IsGeometry(argv[i]) == MagickFalse)
4688 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4689 break;
4690 }
4691 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4692 (LocaleCompare("gaussian",option+1) == 0))
4693 {
4694 i++;
cristybb503372010-05-27 20:51:26 +00004695 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004696 ThrowMogrifyException(OptionError,"MissingArgument",option);
4697 if (IsGeometry(argv[i]) == MagickFalse)
4698 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4699 break;
4700 }
4701 if (LocaleCompare("geometry",option+1) == 0)
4702 {
4703 if (*option == '+')
4704 break;
4705 i++;
cristybb503372010-05-27 20:51:26 +00004706 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004707 ThrowMogrifyException(OptionError,"MissingArgument",option);
4708 if (IsGeometry(argv[i]) == MagickFalse)
4709 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4710 break;
4711 }
4712 if (LocaleCompare("gravity",option+1) == 0)
4713 {
cristybb503372010-05-27 20:51:26 +00004714 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004715 gravity;
4716
4717 if (*option == '+')
4718 break;
4719 i++;
cristybb503372010-05-27 20:51:26 +00004720 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004721 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004722 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004723 if (gravity < 0)
4724 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4725 argv[i]);
4726 break;
4727 }
4728 if (LocaleCompare("green-primary",option+1) == 0)
4729 {
4730 if (*option == '+')
4731 break;
4732 i++;
cristybb503372010-05-27 20:51:26 +00004733 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004734 ThrowMogrifyException(OptionError,"MissingArgument",option);
4735 if (IsGeometry(argv[i]) == MagickFalse)
4736 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4737 break;
4738 }
4739 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4740 }
4741 case 'h':
4742 {
4743 if (LocaleCompare("hald-clut",option+1) == 0)
4744 break;
4745 if ((LocaleCompare("help",option+1) == 0) ||
4746 (LocaleCompare("-help",option+1) == 0))
4747 return(MogrifyUsage());
4748 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4749 }
4750 case 'i':
4751 {
4752 if (LocaleCompare("identify",option+1) == 0)
4753 break;
4754 if (LocaleCompare("idft",option+1) == 0)
4755 break;
4756 if (LocaleCompare("implode",option+1) == 0)
4757 {
4758 if (*option == '+')
4759 break;
4760 i++;
cristybb503372010-05-27 20:51:26 +00004761 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004762 ThrowMogrifyException(OptionError,"MissingArgument",option);
4763 if (IsGeometry(argv[i]) == MagickFalse)
4764 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4765 break;
4766 }
4767 if (LocaleCompare("intent",option+1) == 0)
4768 {
cristybb503372010-05-27 20:51:26 +00004769 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004770 intent;
4771
4772 if (*option == '+')
4773 break;
4774 i++;
cristybb503372010-05-27 20:51:26 +00004775 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004776 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004777 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004778 if (intent < 0)
4779 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4780 argv[i]);
4781 break;
4782 }
4783 if (LocaleCompare("interlace",option+1) == 0)
4784 {
cristybb503372010-05-27 20:51:26 +00004785 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004786 interlace;
4787
4788 if (*option == '+')
4789 break;
4790 i++;
cristybb503372010-05-27 20:51:26 +00004791 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004792 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004793 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004794 argv[i]);
4795 if (interlace < 0)
4796 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4797 argv[i]);
4798 break;
4799 }
cristyb32b90a2009-09-07 21:45:48 +00004800 if (LocaleCompare("interline-spacing",option+1) == 0)
4801 {
4802 if (*option == '+')
4803 break;
4804 i++;
cristybb503372010-05-27 20:51:26 +00004805 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00004806 ThrowMogrifyException(OptionError,"MissingArgument",option);
4807 if (IsGeometry(argv[i]) == MagickFalse)
4808 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4809 break;
4810 }
cristy3ed852e2009-09-05 21:47:34 +00004811 if (LocaleCompare("interpolate",option+1) == 0)
4812 {
cristybb503372010-05-27 20:51:26 +00004813 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004814 interpolate;
4815
4816 if (*option == '+')
4817 break;
4818 i++;
cristybb503372010-05-27 20:51:26 +00004819 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004820 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004821 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004822 argv[i]);
4823 if (interpolate < 0)
4824 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4825 argv[i]);
4826 break;
4827 }
4828 if (LocaleCompare("interword-spacing",option+1) == 0)
4829 {
4830 if (*option == '+')
4831 break;
4832 i++;
cristybb503372010-05-27 20:51:26 +00004833 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004834 ThrowMogrifyException(OptionError,"MissingArgument",option);
4835 if (IsGeometry(argv[i]) == MagickFalse)
4836 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4837 break;
4838 }
4839 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4840 }
4841 case 'k':
4842 {
4843 if (LocaleCompare("kerning",option+1) == 0)
4844 {
4845 if (*option == '+')
4846 break;
4847 i++;
cristybb503372010-05-27 20:51:26 +00004848 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004849 ThrowMogrifyException(OptionError,"MissingArgument",option);
4850 if (IsGeometry(argv[i]) == MagickFalse)
4851 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4852 break;
4853 }
4854 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4855 }
4856 case 'l':
4857 {
4858 if (LocaleCompare("label",option+1) == 0)
4859 {
4860 if (*option == '+')
4861 break;
4862 i++;
cristybb503372010-05-27 20:51:26 +00004863 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004864 ThrowMogrifyException(OptionError,"MissingArgument",option);
4865 break;
4866 }
4867 if (LocaleCompare("lat",option+1) == 0)
4868 {
4869 if (*option == '+')
4870 break;
4871 i++;
cristybb503372010-05-27 20:51:26 +00004872 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004873 ThrowMogrifyException(OptionError,"MissingArgument",option);
4874 if (IsGeometry(argv[i]) == MagickFalse)
4875 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4876 }
4877 if (LocaleCompare("layers",option+1) == 0)
4878 {
cristybb503372010-05-27 20:51:26 +00004879 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004880 type;
4881
4882 if (*option == '+')
4883 break;
4884 i++;
cristybb503372010-05-27 20:51:26 +00004885 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004886 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004887 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004888 if (type < 0)
4889 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4890 argv[i]);
4891 break;
4892 }
4893 if (LocaleCompare("level",option+1) == 0)
4894 {
4895 i++;
cristybb503372010-05-27 20:51:26 +00004896 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004897 ThrowMogrifyException(OptionError,"MissingArgument",option);
4898 if (IsGeometry(argv[i]) == MagickFalse)
4899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4900 break;
4901 }
4902 if (LocaleCompare("level-colors",option+1) == 0)
4903 {
4904 i++;
cristybb503372010-05-27 20:51:26 +00004905 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004906 ThrowMogrifyException(OptionError,"MissingArgument",option);
4907 break;
4908 }
4909 if (LocaleCompare("linewidth",option+1) == 0)
4910 {
4911 if (*option == '+')
4912 break;
4913 i++;
cristybb503372010-05-27 20:51:26 +00004914 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004915 ThrowMogrifyException(OptionError,"MissingArgument",option);
4916 if (IsGeometry(argv[i]) == MagickFalse)
4917 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4918 break;
4919 }
4920 if (LocaleCompare("limit",option+1) == 0)
4921 {
4922 char
4923 *p;
4924
4925 double
4926 value;
4927
cristybb503372010-05-27 20:51:26 +00004928 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004929 resource;
4930
4931 if (*option == '+')
4932 break;
4933 i++;
cristybb503372010-05-27 20:51:26 +00004934 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004935 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004936 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004937 argv[i]);
4938 if (resource < 0)
4939 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4940 argv[i]);
4941 i++;
cristybb503372010-05-27 20:51:26 +00004942 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004943 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyc1acd842011-05-19 23:05:47 +00004944 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00004945 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00004946 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4948 break;
4949 }
4950 if (LocaleCompare("liquid-rescale",option+1) == 0)
4951 {
4952 i++;
cristybb503372010-05-27 20:51:26 +00004953 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004954 ThrowMogrifyException(OptionError,"MissingArgument",option);
4955 if (IsGeometry(argv[i]) == MagickFalse)
4956 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4957 break;
4958 }
4959 if (LocaleCompare("list",option+1) == 0)
4960 {
cristybb503372010-05-27 20:51:26 +00004961 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004962 list;
4963
4964 if (*option == '+')
4965 break;
4966 i++;
cristybb503372010-05-27 20:51:26 +00004967 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004968 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004969 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004970 if (list < 0)
4971 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00004972 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00004973 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00004974 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00004975 }
4976 if (LocaleCompare("log",option+1) == 0)
4977 {
4978 if (*option == '+')
4979 break;
4980 i++;
cristybb503372010-05-27 20:51:26 +00004981 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00004982 (strchr(argv[i],'%') == (char *) NULL))
4983 ThrowMogrifyException(OptionError,"MissingArgument",option);
4984 break;
4985 }
4986 if (LocaleCompare("loop",option+1) == 0)
4987 {
4988 if (*option == '+')
4989 break;
4990 i++;
cristybb503372010-05-27 20:51:26 +00004991 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004992 ThrowMogrifyException(OptionError,"MissingArgument",option);
4993 if (IsGeometry(argv[i]) == MagickFalse)
4994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4995 break;
4996 }
4997 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4998 }
4999 case 'm':
5000 {
5001 if (LocaleCompare("map",option+1) == 0)
5002 {
5003 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5004 if (*option == '+')
5005 break;
5006 i++;
cristybb503372010-05-27 20:51:26 +00005007 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005008 ThrowMogrifyException(OptionError,"MissingArgument",option);
5009 break;
5010 }
5011 if (LocaleCompare("mask",option+1) == 0)
5012 {
5013 if (*option == '+')
5014 break;
5015 i++;
cristybb503372010-05-27 20:51:26 +00005016 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005017 ThrowMogrifyException(OptionError,"MissingArgument",option);
5018 break;
5019 }
5020 if (LocaleCompare("matte",option+1) == 0)
5021 break;
5022 if (LocaleCompare("mattecolor",option+1) == 0)
5023 {
5024 if (*option == '+')
5025 break;
5026 i++;
cristybb503372010-05-27 20:51:26 +00005027 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005028 ThrowMogrifyException(OptionError,"MissingArgument",option);
5029 break;
5030 }
cristyf40785b2010-03-06 02:27:27 +00005031 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005032 break;
cristyf40785b2010-03-06 02:27:27 +00005033 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005034 break;
cristy3ed852e2009-09-05 21:47:34 +00005035 if (LocaleCompare("modulate",option+1) == 0)
5036 {
5037 if (*option == '+')
5038 break;
5039 i++;
cristybb503372010-05-27 20:51:26 +00005040 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005041 ThrowMogrifyException(OptionError,"MissingArgument",option);
5042 if (IsGeometry(argv[i]) == MagickFalse)
5043 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5044 break;
5045 }
5046 if (LocaleCompare("median",option+1) == 0)
5047 {
5048 if (*option == '+')
5049 break;
5050 i++;
cristybb503372010-05-27 20:51:26 +00005051 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005052 ThrowMogrifyException(OptionError,"MissingArgument",option);
5053 if (IsGeometry(argv[i]) == MagickFalse)
5054 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5055 break;
5056 }
cristy69ec32d2011-02-27 23:57:09 +00005057 if (LocaleCompare("mode",option+1) == 0)
5058 {
5059 if (*option == '+')
5060 break;
5061 i++;
5062 if (i == (ssize_t) argc)
5063 ThrowMogrifyException(OptionError,"MissingArgument",option);
5064 if (IsGeometry(argv[i]) == MagickFalse)
5065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5066 break;
5067 }
cristy3ed852e2009-09-05 21:47:34 +00005068 if (LocaleCompare("monitor",option+1) == 0)
5069 break;
5070 if (LocaleCompare("monochrome",option+1) == 0)
5071 break;
5072 if (LocaleCompare("morph",option+1) == 0)
5073 {
5074 if (*option == '+')
5075 break;
5076 i++;
cristybb503372010-05-27 20:51:26 +00005077 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005078 ThrowMogrifyException(OptionError,"MissingArgument",option);
5079 if (IsGeometry(argv[i]) == MagickFalse)
5080 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5081 break;
5082 }
anthony29188a82010-01-22 10:12:34 +00005083 if (LocaleCompare("morphology",option+1) == 0)
5084 {
anthony29188a82010-01-22 10:12:34 +00005085 char
5086 token[MaxTextExtent];
5087
cristyb6bd4ad2010-08-08 01:12:27 +00005088 KernelInfo
5089 *kernel_info;
5090
5091 ssize_t
5092 op;
5093
anthony29188a82010-01-22 10:12:34 +00005094 i++;
cristybb503372010-05-27 20:51:26 +00005095 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005096 ThrowMogrifyException(OptionError,"MissingArgument",option);
5097 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00005098 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00005099 if (op < 0)
5100 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005101 token);
anthony29188a82010-01-22 10:12:34 +00005102 i++;
cristybb503372010-05-27 20:51:26 +00005103 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005104 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005105 kernel_info=AcquireKernelInfo(argv[i]);
5106 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005107 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005108 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005109 break;
5110 }
cristy3ed852e2009-09-05 21:47:34 +00005111 if (LocaleCompare("mosaic",option+1) == 0)
5112 break;
5113 if (LocaleCompare("motion-blur",option+1) == 0)
5114 {
5115 if (*option == '+')
5116 break;
5117 i++;
cristybb503372010-05-27 20:51:26 +00005118 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005119 ThrowMogrifyException(OptionError,"MissingArgument",option);
5120 if (IsGeometry(argv[i]) == MagickFalse)
5121 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5122 break;
5123 }
5124 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5125 }
5126 case 'n':
5127 {
5128 if (LocaleCompare("negate",option+1) == 0)
5129 break;
5130 if (LocaleCompare("noise",option+1) == 0)
5131 {
5132 i++;
cristybb503372010-05-27 20:51:26 +00005133 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005134 ThrowMogrifyException(OptionError,"MissingArgument",option);
5135 if (*option == '+')
5136 {
cristybb503372010-05-27 20:51:26 +00005137 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005138 noise;
5139
cristy042ee782011-04-22 18:48:30 +00005140 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005141 if (noise < 0)
5142 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5143 argv[i]);
5144 break;
5145 }
5146 if (IsGeometry(argv[i]) == MagickFalse)
5147 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5148 break;
5149 }
5150 if (LocaleCompare("noop",option+1) == 0)
5151 break;
5152 if (LocaleCompare("normalize",option+1) == 0)
5153 break;
5154 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5155 }
5156 case 'o':
5157 {
5158 if (LocaleCompare("opaque",option+1) == 0)
5159 {
cristy3ed852e2009-09-05 21:47:34 +00005160 i++;
cristybb503372010-05-27 20:51:26 +00005161 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005162 ThrowMogrifyException(OptionError,"MissingArgument",option);
5163 break;
5164 }
5165 if (LocaleCompare("ordered-dither",option+1) == 0)
5166 {
5167 if (*option == '+')
5168 break;
5169 i++;
cristybb503372010-05-27 20:51:26 +00005170 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005171 ThrowMogrifyException(OptionError,"MissingArgument",option);
5172 break;
5173 }
5174 if (LocaleCompare("orient",option+1) == 0)
5175 {
cristybb503372010-05-27 20:51:26 +00005176 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005177 orientation;
5178
5179 orientation=UndefinedOrientation;
5180 if (*option == '+')
5181 break;
5182 i++;
cristybb503372010-05-27 20:51:26 +00005183 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005184 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005185 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005186 argv[i]);
5187 if (orientation < 0)
5188 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5189 argv[i]);
5190 break;
5191 }
5192 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5193 }
5194 case 'p':
5195 {
5196 if (LocaleCompare("page",option+1) == 0)
5197 {
5198 if (*option == '+')
5199 break;
5200 i++;
cristybb503372010-05-27 20:51:26 +00005201 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005202 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 break;
5204 }
5205 if (LocaleCompare("paint",option+1) == 0)
5206 {
5207 if (*option == '+')
5208 break;
5209 i++;
cristybb503372010-05-27 20:51:26 +00005210 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005211 ThrowMogrifyException(OptionError,"MissingArgument",option);
5212 if (IsGeometry(argv[i]) == MagickFalse)
5213 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5214 break;
5215 }
5216 if (LocaleCompare("path",option+1) == 0)
5217 {
5218 (void) CloneString(&path,(char *) NULL);
5219 if (*option == '+')
5220 break;
5221 i++;
cristybb503372010-05-27 20:51:26 +00005222 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005223 ThrowMogrifyException(OptionError,"MissingArgument",option);
5224 (void) CloneString(&path,argv[i]);
5225 break;
5226 }
5227 if (LocaleCompare("pointsize",option+1) == 0)
5228 {
5229 if (*option == '+')
5230 break;
5231 i++;
cristybb503372010-05-27 20:51:26 +00005232 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005233 ThrowMogrifyException(OptionError,"MissingArgument",option);
5234 if (IsGeometry(argv[i]) == MagickFalse)
5235 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5236 break;
5237 }
5238 if (LocaleCompare("polaroid",option+1) == 0)
5239 {
5240 if (*option == '+')
5241 break;
5242 i++;
cristybb503372010-05-27 20:51:26 +00005243 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005244 ThrowMogrifyException(OptionError,"MissingArgument",option);
5245 if (IsGeometry(argv[i]) == MagickFalse)
5246 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5247 break;
5248 }
5249 if (LocaleCompare("posterize",option+1) == 0)
5250 {
5251 if (*option == '+')
5252 break;
5253 i++;
cristybb503372010-05-27 20:51:26 +00005254 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005255 ThrowMogrifyException(OptionError,"MissingArgument",option);
5256 if (IsGeometry(argv[i]) == MagickFalse)
5257 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5258 break;
5259 }
cristye7f51092010-01-17 00:39:37 +00005260 if (LocaleCompare("precision",option+1) == 0)
5261 {
5262 if (*option == '+')
5263 break;
5264 i++;
cristybb503372010-05-27 20:51:26 +00005265 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005266 ThrowMogrifyException(OptionError,"MissingArgument",option);
5267 if (IsGeometry(argv[i]) == MagickFalse)
5268 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5269 break;
5270 }
cristy3ed852e2009-09-05 21:47:34 +00005271 if (LocaleCompare("print",option+1) == 0)
5272 {
5273 if (*option == '+')
5274 break;
5275 i++;
cristybb503372010-05-27 20:51:26 +00005276 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005277 ThrowMogrifyException(OptionError,"MissingArgument",option);
5278 break;
5279 }
5280 if (LocaleCompare("process",option+1) == 0)
5281 {
5282 if (*option == '+')
5283 break;
5284 i++;
cristybb503372010-05-27 20:51:26 +00005285 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005286 ThrowMogrifyException(OptionError,"MissingArgument",option);
5287 break;
5288 }
5289 if (LocaleCompare("profile",option+1) == 0)
5290 {
5291 i++;
cristybb503372010-05-27 20:51:26 +00005292 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005293 ThrowMogrifyException(OptionError,"MissingArgument",option);
5294 break;
5295 }
5296 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5297 }
5298 case 'q':
5299 {
5300 if (LocaleCompare("quality",option+1) == 0)
5301 {
5302 if (*option == '+')
5303 break;
5304 i++;
cristybb503372010-05-27 20:51:26 +00005305 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005306 ThrowMogrifyException(OptionError,"MissingArgument",option);
5307 if (IsGeometry(argv[i]) == MagickFalse)
5308 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5309 break;
5310 }
5311 if (LocaleCompare("quantize",option+1) == 0)
5312 {
cristybb503372010-05-27 20:51:26 +00005313 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005314 colorspace;
5315
5316 if (*option == '+')
5317 break;
5318 i++;
cristybb503372010-05-27 20:51:26 +00005319 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005320 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005321 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005322 argv[i]);
5323 if (colorspace < 0)
5324 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5325 argv[i]);
5326 break;
5327 }
5328 if (LocaleCompare("quiet",option+1) == 0)
5329 break;
5330 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5331 }
5332 case 'r':
5333 {
5334 if (LocaleCompare("radial-blur",option+1) == 0)
5335 {
5336 i++;
cristybb503372010-05-27 20:51:26 +00005337 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005338 ThrowMogrifyException(OptionError,"MissingArgument",option);
5339 if (IsGeometry(argv[i]) == MagickFalse)
5340 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5341 break;
5342 }
5343 if (LocaleCompare("raise",option+1) == 0)
5344 {
5345 i++;
cristybb503372010-05-27 20:51:26 +00005346 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005347 ThrowMogrifyException(OptionError,"MissingArgument",option);
5348 if (IsGeometry(argv[i]) == MagickFalse)
5349 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5350 break;
5351 }
5352 if (LocaleCompare("random-threshold",option+1) == 0)
5353 {
5354 if (*option == '+')
5355 break;
5356 i++;
cristybb503372010-05-27 20:51:26 +00005357 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005358 ThrowMogrifyException(OptionError,"MissingArgument",option);
5359 if (IsGeometry(argv[i]) == MagickFalse)
5360 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5361 break;
5362 }
cristye6365592010-04-02 17:31:23 +00005363 if (LocaleCompare("recolor",option+1) == 0)
5364 {
5365 if (*option == '+')
5366 break;
5367 i++;
cristybb503372010-05-27 20:51:26 +00005368 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005369 ThrowMogrifyException(OptionError,"MissingArgument",option);
5370 if (IsGeometry(argv[i]) == MagickFalse)
5371 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5372 break;
5373 }
cristy3ed852e2009-09-05 21:47:34 +00005374 if (LocaleCompare("red-primary",option+1) == 0)
5375 {
5376 if (*option == '+')
5377 break;
5378 i++;
cristybb503372010-05-27 20:51:26 +00005379 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005380 ThrowMogrifyException(OptionError,"MissingArgument",option);
5381 if (IsGeometry(argv[i]) == MagickFalse)
5382 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5383 }
cristy9f2083a2010-04-22 19:48:05 +00005384 if (LocaleCompare("regard-warnings",option+1) == 0)
5385 break;
cristy3ed852e2009-09-05 21:47:34 +00005386 if (LocaleCompare("region",option+1) == 0)
5387 {
5388 if (*option == '+')
5389 break;
5390 i++;
cristybb503372010-05-27 20:51:26 +00005391 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 if (IsGeometry(argv[i]) == MagickFalse)
5394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5395 break;
5396 }
cristyf0c78232010-03-15 12:53:40 +00005397 if (LocaleCompare("remap",option+1) == 0)
5398 {
5399 if (*option == '+')
5400 break;
5401 i++;
cristybb503372010-05-27 20:51:26 +00005402 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005403 ThrowMogrifyException(OptionError,"MissingArgument",option);
5404 break;
5405 }
cristy3ed852e2009-09-05 21:47:34 +00005406 if (LocaleCompare("render",option+1) == 0)
5407 break;
5408 if (LocaleCompare("repage",option+1) == 0)
5409 {
5410 if (*option == '+')
5411 break;
5412 i++;
cristybb503372010-05-27 20:51:26 +00005413 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005414 ThrowMogrifyException(OptionError,"MissingArgument",option);
5415 if (IsGeometry(argv[i]) == MagickFalse)
5416 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5417 break;
5418 }
5419 if (LocaleCompare("resample",option+1) == 0)
5420 {
5421 if (*option == '+')
5422 break;
5423 i++;
cristybb503372010-05-27 20:51:26 +00005424 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005425 ThrowMogrifyException(OptionError,"MissingArgument",option);
5426 if (IsGeometry(argv[i]) == MagickFalse)
5427 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5428 break;
5429 }
5430 if (LocaleCompare("resize",option+1) == 0)
5431 {
5432 if (*option == '+')
5433 break;
5434 i++;
cristybb503372010-05-27 20:51:26 +00005435 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005436 ThrowMogrifyException(OptionError,"MissingArgument",option);
5437 if (IsGeometry(argv[i]) == MagickFalse)
5438 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5439 break;
5440 }
cristyebbcfea2011-02-25 02:43:54 +00005441 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5442 {
5443 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5444 break;
5445 }
cristy3ed852e2009-09-05 21:47:34 +00005446 if (LocaleCompare("reverse",option+1) == 0)
5447 break;
5448 if (LocaleCompare("roll",option+1) == 0)
5449 {
5450 if (*option == '+')
5451 break;
5452 i++;
cristybb503372010-05-27 20:51:26 +00005453 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005454 ThrowMogrifyException(OptionError,"MissingArgument",option);
5455 if (IsGeometry(argv[i]) == MagickFalse)
5456 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5457 break;
5458 }
5459 if (LocaleCompare("rotate",option+1) == 0)
5460 {
5461 i++;
cristybb503372010-05-27 20:51:26 +00005462 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005463 ThrowMogrifyException(OptionError,"MissingArgument",option);
5464 if (IsGeometry(argv[i]) == MagickFalse)
5465 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5466 break;
5467 }
5468 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5469 }
5470 case 's':
5471 {
5472 if (LocaleCompare("sample",option+1) == 0)
5473 {
5474 if (*option == '+')
5475 break;
5476 i++;
cristybb503372010-05-27 20:51:26 +00005477 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005478 ThrowMogrifyException(OptionError,"MissingArgument",option);
5479 if (IsGeometry(argv[i]) == MagickFalse)
5480 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5481 break;
5482 }
5483 if (LocaleCompare("sampling-factor",option+1) == 0)
5484 {
5485 if (*option == '+')
5486 break;
5487 i++;
cristybb503372010-05-27 20:51:26 +00005488 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005489 ThrowMogrifyException(OptionError,"MissingArgument",option);
5490 if (IsGeometry(argv[i]) == MagickFalse)
5491 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5492 break;
5493 }
5494 if (LocaleCompare("scale",option+1) == 0)
5495 {
5496 if (*option == '+')
5497 break;
5498 i++;
cristybb503372010-05-27 20:51:26 +00005499 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005500 ThrowMogrifyException(OptionError,"MissingArgument",option);
5501 if (IsGeometry(argv[i]) == MagickFalse)
5502 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5503 break;
5504 }
5505 if (LocaleCompare("scene",option+1) == 0)
5506 {
5507 if (*option == '+')
5508 break;
5509 i++;
cristybb503372010-05-27 20:51:26 +00005510 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005511 ThrowMogrifyException(OptionError,"MissingArgument",option);
5512 if (IsGeometry(argv[i]) == MagickFalse)
5513 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5514 break;
5515 }
5516 if (LocaleCompare("seed",option+1) == 0)
5517 {
5518 if (*option == '+')
5519 break;
5520 i++;
cristybb503372010-05-27 20:51:26 +00005521 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005522 ThrowMogrifyException(OptionError,"MissingArgument",option);
5523 if (IsGeometry(argv[i]) == MagickFalse)
5524 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5525 break;
5526 }
5527 if (LocaleCompare("segment",option+1) == 0)
5528 {
5529 if (*option == '+')
5530 break;
5531 i++;
cristybb503372010-05-27 20:51:26 +00005532 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005533 ThrowMogrifyException(OptionError,"MissingArgument",option);
5534 if (IsGeometry(argv[i]) == MagickFalse)
5535 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5536 break;
5537 }
5538 if (LocaleCompare("selective-blur",option+1) == 0)
5539 {
5540 i++;
cristybb503372010-05-27 20:51:26 +00005541 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005542 ThrowMogrifyException(OptionError,"MissingArgument",option);
5543 if (IsGeometry(argv[i]) == MagickFalse)
5544 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5545 break;
5546 }
5547 if (LocaleCompare("separate",option+1) == 0)
5548 break;
5549 if (LocaleCompare("sepia-tone",option+1) == 0)
5550 {
5551 if (*option == '+')
5552 break;
5553 i++;
cristybb503372010-05-27 20:51:26 +00005554 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005555 ThrowMogrifyException(OptionError,"MissingArgument",option);
5556 if (IsGeometry(argv[i]) == MagickFalse)
5557 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5558 break;
5559 }
5560 if (LocaleCompare("set",option+1) == 0)
5561 {
5562 i++;
cristybb503372010-05-27 20:51:26 +00005563 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005564 ThrowMogrifyException(OptionError,"MissingArgument",option);
5565 if (*option == '+')
5566 break;
5567 i++;
cristybb503372010-05-27 20:51:26 +00005568 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005569 ThrowMogrifyException(OptionError,"MissingArgument",option);
5570 break;
5571 }
5572 if (LocaleCompare("shade",option+1) == 0)
5573 {
5574 i++;
cristybb503372010-05-27 20:51:26 +00005575 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005576 ThrowMogrifyException(OptionError,"MissingArgument",option);
5577 if (IsGeometry(argv[i]) == MagickFalse)
5578 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5579 break;
5580 }
5581 if (LocaleCompare("shadow",option+1) == 0)
5582 {
5583 if (*option == '+')
5584 break;
5585 i++;
cristybb503372010-05-27 20:51:26 +00005586 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005587 ThrowMogrifyException(OptionError,"MissingArgument",option);
5588 if (IsGeometry(argv[i]) == MagickFalse)
5589 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5590 break;
5591 }
5592 if (LocaleCompare("sharpen",option+1) == 0)
5593 {
5594 i++;
cristybb503372010-05-27 20:51:26 +00005595 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005596 ThrowMogrifyException(OptionError,"MissingArgument",option);
5597 if (IsGeometry(argv[i]) == MagickFalse)
5598 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5599 break;
5600 }
5601 if (LocaleCompare("shave",option+1) == 0)
5602 {
5603 if (*option == '+')
5604 break;
5605 i++;
cristybb503372010-05-27 20:51:26 +00005606 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005607 ThrowMogrifyException(OptionError,"MissingArgument",option);
5608 if (IsGeometry(argv[i]) == MagickFalse)
5609 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5610 break;
5611 }
5612 if (LocaleCompare("shear",option+1) == 0)
5613 {
5614 i++;
cristybb503372010-05-27 20:51:26 +00005615 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005616 ThrowMogrifyException(OptionError,"MissingArgument",option);
5617 if (IsGeometry(argv[i]) == MagickFalse)
5618 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5619 break;
5620 }
5621 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5622 {
5623 i++;
cristybb503372010-05-27 20:51:26 +00005624 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005625 ThrowMogrifyException(OptionError,"MissingArgument",option);
5626 if (IsGeometry(argv[i]) == MagickFalse)
5627 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5628 break;
5629 }
5630 if (LocaleCompare("size",option+1) == 0)
5631 {
5632 if (*option == '+')
5633 break;
5634 i++;
cristybb503372010-05-27 20:51:26 +00005635 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005636 ThrowMogrifyException(OptionError,"MissingArgument",option);
5637 if (IsGeometry(argv[i]) == MagickFalse)
5638 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5639 break;
5640 }
5641 if (LocaleCompare("sketch",option+1) == 0)
5642 {
5643 if (*option == '+')
5644 break;
5645 i++;
cristybb503372010-05-27 20:51:26 +00005646 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005647 ThrowMogrifyException(OptionError,"MissingArgument",option);
5648 if (IsGeometry(argv[i]) == MagickFalse)
5649 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 break;
5651 }
cristy4285d782011-02-09 20:12:28 +00005652 if (LocaleCompare("smush",option+1) == 0)
5653 {
cristy4285d782011-02-09 20:12:28 +00005654 i++;
5655 if (i == (ssize_t) argc)
5656 ThrowMogrifyException(OptionError,"MissingArgument",option);
5657 if (IsGeometry(argv[i]) == MagickFalse)
5658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00005659 i++;
5660 break;
5661 }
cristy3ed852e2009-09-05 21:47:34 +00005662 if (LocaleCompare("solarize",option+1) == 0)
5663 {
5664 if (*option == '+')
5665 break;
5666 i++;
cristybb503372010-05-27 20:51:26 +00005667 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005668 ThrowMogrifyException(OptionError,"MissingArgument",option);
5669 if (IsGeometry(argv[i]) == MagickFalse)
5670 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5671 break;
5672 }
5673 if (LocaleCompare("sparse-color",option+1) == 0)
5674 {
cristybb503372010-05-27 20:51:26 +00005675 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005676 op;
5677
5678 i++;
cristybb503372010-05-27 20:51:26 +00005679 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005680 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005681 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005682 if (op < 0)
5683 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5684 argv[i]);
5685 i++;
cristybb503372010-05-27 20:51:26 +00005686 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005687 ThrowMogrifyException(OptionError,"MissingArgument",option);
5688 break;
5689 }
5690 if (LocaleCompare("spread",option+1) == 0)
5691 {
5692 if (*option == '+')
5693 break;
5694 i++;
cristybb503372010-05-27 20:51:26 +00005695 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005696 ThrowMogrifyException(OptionError,"MissingArgument",option);
5697 if (IsGeometry(argv[i]) == MagickFalse)
5698 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5699 break;
5700 }
cristy0834d642011-03-18 18:26:08 +00005701 if (LocaleCompare("statistic",option+1) == 0)
5702 {
5703 ssize_t
5704 op;
5705
5706 if (*option == '+')
5707 break;
5708 i++;
5709 if (i == (ssize_t) argc)
5710 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005711 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00005712 if (op < 0)
5713 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5714 argv[i]);
5715 i++;
5716 if (i == (ssize_t) (argc-1))
5717 ThrowMogrifyException(OptionError,"MissingArgument",option);
5718 if (IsGeometry(argv[i]) == MagickFalse)
5719 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5720 break;
5721 }
cristy3ed852e2009-09-05 21:47:34 +00005722 if (LocaleCompare("stretch",option+1) == 0)
5723 {
cristybb503372010-05-27 20:51:26 +00005724 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005725 stretch;
5726
5727 if (*option == '+')
5728 break;
5729 i++;
cristybb503372010-05-27 20:51:26 +00005730 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005731 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005732 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005733 if (stretch < 0)
5734 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5735 argv[i]);
5736 break;
5737 }
5738 if (LocaleCompare("strip",option+1) == 0)
5739 break;
5740 if (LocaleCompare("stroke",option+1) == 0)
5741 {
5742 if (*option == '+')
5743 break;
5744 i++;
cristybb503372010-05-27 20:51:26 +00005745 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005746 ThrowMogrifyException(OptionError,"MissingArgument",option);
5747 break;
5748 }
5749 if (LocaleCompare("strokewidth",option+1) == 0)
5750 {
5751 if (*option == '+')
5752 break;
5753 i++;
cristybb503372010-05-27 20:51:26 +00005754 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005755 ThrowMogrifyException(OptionError,"MissingArgument",option);
5756 if (IsGeometry(argv[i]) == MagickFalse)
5757 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5758 break;
5759 }
5760 if (LocaleCompare("style",option+1) == 0)
5761 {
cristybb503372010-05-27 20:51:26 +00005762 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005763 style;
5764
5765 if (*option == '+')
5766 break;
5767 i++;
cristybb503372010-05-27 20:51:26 +00005768 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005769 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005770 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005771 if (style < 0)
5772 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5773 argv[i]);
5774 break;
5775 }
cristyecb10ff2011-03-22 13:14:03 +00005776 if (LocaleCompare("swap",option+1) == 0)
5777 {
5778 if (*option == '+')
5779 break;
5780 i++;
5781 if (i == (ssize_t) (argc-1))
5782 ThrowMogrifyException(OptionError,"MissingArgument",option);
5783 if (IsGeometry(argv[i]) == MagickFalse)
5784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5785 break;
5786 }
cristy3ed852e2009-09-05 21:47:34 +00005787 if (LocaleCompare("swirl",option+1) == 0)
5788 {
5789 if (*option == '+')
5790 break;
5791 i++;
cristybb503372010-05-27 20:51:26 +00005792 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005793 ThrowMogrifyException(OptionError,"MissingArgument",option);
5794 if (IsGeometry(argv[i]) == MagickFalse)
5795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5796 break;
5797 }
cristyd9a29192010-10-16 16:49:53 +00005798 if (LocaleCompare("synchronize",option+1) == 0)
5799 break;
cristy3ed852e2009-09-05 21:47:34 +00005800 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5801 }
5802 case 't':
5803 {
5804 if (LocaleCompare("taint",option+1) == 0)
5805 break;
5806 if (LocaleCompare("texture",option+1) == 0)
5807 {
5808 if (*option == '+')
5809 break;
5810 i++;
cristybb503372010-05-27 20:51:26 +00005811 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005812 ThrowMogrifyException(OptionError,"MissingArgument",option);
5813 break;
5814 }
5815 if (LocaleCompare("tile",option+1) == 0)
5816 {
5817 if (*option == '+')
5818 break;
5819 i++;
cristybb503372010-05-27 20:51:26 +00005820 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005821 ThrowMogrifyException(OptionError,"MissingArgument",option);
5822 break;
5823 }
5824 if (LocaleCompare("tile-offset",option+1) == 0)
5825 {
5826 if (*option == '+')
5827 break;
5828 i++;
cristybb503372010-05-27 20:51:26 +00005829 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005830 ThrowMogrifyException(OptionError,"MissingArgument",option);
5831 if (IsGeometry(argv[i]) == MagickFalse)
5832 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5833 break;
5834 }
5835 if (LocaleCompare("tint",option+1) == 0)
5836 {
5837 if (*option == '+')
5838 break;
5839 i++;
cristybb503372010-05-27 20:51:26 +00005840 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005841 ThrowMogrifyException(OptionError,"MissingArgument",option);
5842 if (IsGeometry(argv[i]) == MagickFalse)
5843 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5844 break;
5845 }
5846 if (LocaleCompare("transform",option+1) == 0)
5847 break;
5848 if (LocaleCompare("transpose",option+1) == 0)
5849 break;
5850 if (LocaleCompare("transverse",option+1) == 0)
5851 break;
5852 if (LocaleCompare("threshold",option+1) == 0)
5853 {
5854 if (*option == '+')
5855 break;
5856 i++;
cristybb503372010-05-27 20:51:26 +00005857 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005858 ThrowMogrifyException(OptionError,"MissingArgument",option);
5859 if (IsGeometry(argv[i]) == MagickFalse)
5860 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861 break;
5862 }
5863 if (LocaleCompare("thumbnail",option+1) == 0)
5864 {
5865 if (*option == '+')
5866 break;
5867 i++;
cristybb503372010-05-27 20:51:26 +00005868 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005869 ThrowMogrifyException(OptionError,"MissingArgument",option);
5870 if (IsGeometry(argv[i]) == MagickFalse)
5871 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5872 break;
5873 }
5874 if (LocaleCompare("transparent",option+1) == 0)
5875 {
5876 i++;
cristybb503372010-05-27 20:51:26 +00005877 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005878 ThrowMogrifyException(OptionError,"MissingArgument",option);
5879 break;
5880 }
5881 if (LocaleCompare("transparent-color",option+1) == 0)
5882 {
5883 if (*option == '+')
5884 break;
5885 i++;
cristybb503372010-05-27 20:51:26 +00005886 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005887 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 break;
5889 }
5890 if (LocaleCompare("treedepth",option+1) == 0)
5891 {
5892 if (*option == '+')
5893 break;
5894 i++;
cristybb503372010-05-27 20:51:26 +00005895 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005896 ThrowMogrifyException(OptionError,"MissingArgument",option);
5897 if (IsGeometry(argv[i]) == MagickFalse)
5898 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5899 break;
5900 }
5901 if (LocaleCompare("trim",option+1) == 0)
5902 break;
5903 if (LocaleCompare("type",option+1) == 0)
5904 {
cristybb503372010-05-27 20:51:26 +00005905 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005906 type;
5907
5908 if (*option == '+')
5909 break;
5910 i++;
cristybb503372010-05-27 20:51:26 +00005911 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005912 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005913 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005914 if (type < 0)
5915 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5916 argv[i]);
5917 break;
5918 }
5919 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5920 }
5921 case 'u':
5922 {
5923 if (LocaleCompare("undercolor",option+1) == 0)
5924 {
5925 if (*option == '+')
5926 break;
5927 i++;
cristybb503372010-05-27 20:51:26 +00005928 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005929 ThrowMogrifyException(OptionError,"MissingArgument",option);
5930 break;
5931 }
5932 if (LocaleCompare("unique-colors",option+1) == 0)
5933 break;
5934 if (LocaleCompare("units",option+1) == 0)
5935 {
cristybb503372010-05-27 20:51:26 +00005936 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005937 units;
5938
5939 if (*option == '+')
5940 break;
5941 i++;
cristybb503372010-05-27 20:51:26 +00005942 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005943 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005944 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005945 argv[i]);
5946 if (units < 0)
5947 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5948 argv[i]);
5949 break;
5950 }
5951 if (LocaleCompare("unsharp",option+1) == 0)
5952 {
5953 i++;
cristybb503372010-05-27 20:51:26 +00005954 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005955 ThrowMogrifyException(OptionError,"MissingArgument",option);
5956 if (IsGeometry(argv[i]) == MagickFalse)
5957 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5958 break;
5959 }
5960 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5961 }
5962 case 'v':
5963 {
5964 if (LocaleCompare("verbose",option+1) == 0)
5965 {
5966 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5967 break;
5968 }
5969 if ((LocaleCompare("version",option+1) == 0) ||
5970 (LocaleCompare("-version",option+1) == 0))
5971 {
cristyb51dff52011-05-19 16:55:47 +00005972 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00005973 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00005974 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5975 GetMagickCopyright());
5976 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5977 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00005978 break;
5979 }
5980 if (LocaleCompare("view",option+1) == 0)
5981 {
5982 if (*option == '+')
5983 break;
5984 i++;
cristybb503372010-05-27 20:51:26 +00005985 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005986 ThrowMogrifyException(OptionError,"MissingArgument",option);
5987 break;
5988 }
5989 if (LocaleCompare("vignette",option+1) == 0)
5990 {
5991 if (*option == '+')
5992 break;
5993 i++;
cristybb503372010-05-27 20:51:26 +00005994 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005995 ThrowMogrifyException(OptionError,"MissingArgument",option);
5996 if (IsGeometry(argv[i]) == MagickFalse)
5997 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5998 break;
5999 }
6000 if (LocaleCompare("virtual-pixel",option+1) == 0)
6001 {
cristybb503372010-05-27 20:51:26 +00006002 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006003 method;
6004
6005 if (*option == '+')
6006 break;
6007 i++;
cristybb503372010-05-27 20:51:26 +00006008 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006009 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00006010 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00006011 argv[i]);
6012 if (method < 0)
6013 ThrowMogrifyException(OptionError,
6014 "UnrecognizedVirtualPixelMethod",argv[i]);
6015 break;
6016 }
6017 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6018 }
6019 case 'w':
6020 {
6021 if (LocaleCompare("wave",option+1) == 0)
6022 {
6023 i++;
cristybb503372010-05-27 20:51:26 +00006024 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006025 ThrowMogrifyException(OptionError,"MissingArgument",option);
6026 if (IsGeometry(argv[i]) == MagickFalse)
6027 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6028 break;
6029 }
6030 if (LocaleCompare("weight",option+1) == 0)
6031 {
6032 if (*option == '+')
6033 break;
6034 i++;
cristybb503372010-05-27 20:51:26 +00006035 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006036 ThrowMogrifyException(OptionError,"MissingArgument",option);
6037 break;
6038 }
6039 if (LocaleCompare("white-point",option+1) == 0)
6040 {
6041 if (*option == '+')
6042 break;
6043 i++;
cristybb503372010-05-27 20:51:26 +00006044 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006045 ThrowMogrifyException(OptionError,"MissingArgument",option);
6046 if (IsGeometry(argv[i]) == MagickFalse)
6047 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6048 break;
6049 }
6050 if (LocaleCompare("white-threshold",option+1) == 0)
6051 {
6052 if (*option == '+')
6053 break;
6054 i++;
cristybb503372010-05-27 20:51:26 +00006055 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006056 ThrowMogrifyException(OptionError,"MissingArgument",option);
6057 if (IsGeometry(argv[i]) == MagickFalse)
6058 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6059 break;
6060 }
6061 if (LocaleCompare("write",option+1) == 0)
6062 {
6063 i++;
cristybb503372010-05-27 20:51:26 +00006064 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006065 ThrowMogrifyException(OptionError,"MissingArgument",option);
6066 break;
6067 }
6068 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6069 }
6070 case '?':
6071 break;
6072 default:
6073 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6074 }
cristy042ee782011-04-22 18:48:30 +00006075 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6076 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00006077 if (fire != MagickFalse)
6078 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6079 }
6080 if (k != 0)
6081 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006082 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006083 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6084 DestroyMogrify();
6085 return(status != 0 ? MagickTrue : MagickFalse);
6086}
6087
6088/*
6089%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6090% %
6091% %
6092% %
6093+ M o g r i f y I m a g e I n f o %
6094% %
6095% %
6096% %
6097%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6098%
6099% MogrifyImageInfo() applies image processing settings to the image as
6100% prescribed by command line options.
6101%
6102% The format of the MogrifyImageInfo method is:
6103%
6104% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6105% const char **argv,ExceptionInfo *exception)
6106%
6107% A description of each parameter follows:
6108%
6109% o image_info: the image info..
6110%
6111% o argc: Specifies a pointer to an integer describing the number of
6112% elements in the argument vector.
6113%
6114% o argv: Specifies a pointer to a text array containing the command line
6115% arguments.
6116%
6117% o exception: return any errors or warnings in this structure.
6118%
6119*/
6120WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6121 const int argc,const char **argv,ExceptionInfo *exception)
6122{
6123 const char
6124 *option;
6125
6126 GeometryInfo
6127 geometry_info;
6128
cristybb503372010-05-27 20:51:26 +00006129 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006130 count;
6131
cristybb503372010-05-27 20:51:26 +00006132 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006133 i;
6134
6135 /*
6136 Initialize method variables.
6137 */
6138 assert(image_info != (ImageInfo *) NULL);
6139 assert(image_info->signature == MagickSignature);
6140 if (image_info->debug != MagickFalse)
6141 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6142 image_info->filename);
6143 if (argc < 0)
6144 return(MagickTrue);
6145 /*
6146 Set the image settings.
6147 */
cristybb503372010-05-27 20:51:26 +00006148 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006149 {
6150 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00006151 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00006152 continue;
cristy042ee782011-04-22 18:48:30 +00006153 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00006154 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00006155 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006156 break;
6157 switch (*(option+1))
6158 {
6159 case 'a':
6160 {
6161 if (LocaleCompare("adjoin",option+1) == 0)
6162 {
6163 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6164 break;
6165 }
6166 if (LocaleCompare("antialias",option+1) == 0)
6167 {
6168 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6169 break;
6170 }
cristy3ed852e2009-09-05 21:47:34 +00006171 if (LocaleCompare("authenticate",option+1) == 0)
6172 {
6173 if (*option == '+')
anthony1afdc7a2011-10-05 11:54:28 +00006174 (void) DeleteImageOption(image_info,option+1);
cristy3ed852e2009-09-05 21:47:34 +00006175 else
anthony1afdc7a2011-10-05 11:54:28 +00006176 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006177 break;
6178 }
6179 break;
6180 }
6181 case 'b':
6182 {
6183 if (LocaleCompare("background",option+1) == 0)
6184 {
6185 if (*option == '+')
6186 {
6187 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006188 (void) QueryColorCompliance(MogrifyBackgroundColor,
6189 AllCompliance,&image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006190 break;
6191 }
6192 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006193 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6194 &image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006195 break;
6196 }
6197 if (LocaleCompare("bias",option+1) == 0)
6198 {
6199 if (*option == '+')
6200 {
6201 (void) SetImageOption(image_info,option+1,"0.0");
6202 break;
6203 }
6204 (void) SetImageOption(image_info,option+1,argv[i+1]);
6205 break;
6206 }
6207 if (LocaleCompare("black-point-compensation",option+1) == 0)
6208 {
6209 if (*option == '+')
6210 {
6211 (void) SetImageOption(image_info,option+1,"false");
6212 break;
6213 }
6214 (void) SetImageOption(image_info,option+1,"true");
6215 break;
6216 }
6217 if (LocaleCompare("blue-primary",option+1) == 0)
6218 {
6219 if (*option == '+')
6220 {
6221 (void) SetImageOption(image_info,option+1,"0.0");
6222 break;
6223 }
6224 (void) SetImageOption(image_info,option+1,argv[i+1]);
6225 break;
6226 }
6227 if (LocaleCompare("bordercolor",option+1) == 0)
6228 {
6229 if (*option == '+')
6230 {
6231 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006232 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006233 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006234 break;
6235 }
cristy9950d572011-10-01 18:22:35 +00006236 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6237 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006238 (void) SetImageOption(image_info,option+1,argv[i+1]);
6239 break;
6240 }
6241 if (LocaleCompare("box",option+1) == 0)
6242 {
6243 if (*option == '+')
6244 {
6245 (void) SetImageOption(image_info,"undercolor","none");
6246 break;
6247 }
6248 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6249 break;
6250 }
6251 break;
6252 }
6253 case 'c':
6254 {
6255 if (LocaleCompare("cache",option+1) == 0)
6256 {
6257 MagickSizeType
6258 limit;
6259
6260 limit=MagickResourceInfinity;
6261 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006262 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006263 (void) SetMagickResourceLimit(MemoryResource,limit);
6264 (void) SetMagickResourceLimit(MapResource,2*limit);
6265 break;
6266 }
6267 if (LocaleCompare("caption",option+1) == 0)
6268 {
6269 if (*option == '+')
6270 {
6271 (void) DeleteImageOption(image_info,option+1);
6272 break;
6273 }
6274 (void) SetImageOption(image_info,option+1,argv[i+1]);
6275 break;
6276 }
6277 if (LocaleCompare("channel",option+1) == 0)
6278 {
6279 if (*option == '+')
6280 {
6281 image_info->channel=DefaultChannels;
6282 break;
6283 }
6284 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6285 break;
6286 }
cristy3ed852e2009-09-05 21:47:34 +00006287 if (LocaleCompare("colorspace",option+1) == 0)
6288 {
6289 if (*option == '+')
6290 {
6291 image_info->colorspace=UndefinedColorspace;
6292 (void) SetImageOption(image_info,option+1,"undefined");
6293 break;
6294 }
cristy042ee782011-04-22 18:48:30 +00006295 image_info->colorspace=(ColorspaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006296 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6297 (void) SetImageOption(image_info,option+1,argv[i+1]);
6298 break;
6299 }
cristy3ed852e2009-09-05 21:47:34 +00006300 if (LocaleCompare("comment",option+1) == 0)
6301 {
6302 if (*option == '+')
6303 {
6304 (void) DeleteImageOption(image_info,option+1);
6305 break;
6306 }
6307 (void) SetImageOption(image_info,option+1,argv[i+1]);
6308 break;
6309 }
6310 if (LocaleCompare("compose",option+1) == 0)
6311 {
6312 if (*option == '+')
6313 {
6314 (void) SetImageOption(image_info,option+1,"undefined");
6315 break;
6316 }
6317 (void) SetImageOption(image_info,option+1,argv[i+1]);
6318 break;
6319 }
6320 if (LocaleCompare("compress",option+1) == 0)
6321 {
6322 if (*option == '+')
6323 {
6324 image_info->compression=UndefinedCompression;
6325 (void) SetImageOption(image_info,option+1,"undefined");
6326 break;
6327 }
cristy042ee782011-04-22 18:48:30 +00006328 image_info->compression=(CompressionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006329 MagickCompressOptions,MagickFalse,argv[i+1]);
6330 (void) SetImageOption(image_info,option+1,argv[i+1]);
6331 break;
6332 }
6333 break;
6334 }
6335 case 'd':
6336 {
6337 if (LocaleCompare("debug",option+1) == 0)
6338 {
6339 if (*option == '+')
6340 (void) SetLogEventMask("none");
6341 else
6342 (void) SetLogEventMask(argv[i+1]);
6343 image_info->debug=IsEventLogging();
6344 break;
6345 }
6346 if (LocaleCompare("define",option+1) == 0)
6347 {
6348 if (*option == '+')
6349 {
6350 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6351 (void) DeleteImageRegistry(argv[i+1]+9);
6352 else
6353 (void) DeleteImageOption(image_info,argv[i+1]);
6354 break;
6355 }
6356 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6357 {
6358 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6359 exception);
6360 break;
6361 }
6362 (void) DefineImageOption(image_info,argv[i+1]);
6363 break;
6364 }
6365 if (LocaleCompare("delay",option+1) == 0)
6366 {
6367 if (*option == '+')
6368 {
6369 (void) SetImageOption(image_info,option+1,"0");
6370 break;
6371 }
6372 (void) SetImageOption(image_info,option+1,argv[i+1]);
6373 break;
6374 }
6375 if (LocaleCompare("density",option+1) == 0)
6376 {
6377 /*
6378 Set image density.
6379 */
6380 if (*option == '+')
6381 {
6382 if (image_info->density != (char *) NULL)
6383 image_info->density=DestroyString(image_info->density);
6384 (void) SetImageOption(image_info,option+1,"72");
6385 break;
6386 }
6387 (void) CloneString(&image_info->density,argv[i+1]);
6388 (void) SetImageOption(image_info,option+1,argv[i+1]);
6389 break;
6390 }
6391 if (LocaleCompare("depth",option+1) == 0)
6392 {
6393 if (*option == '+')
6394 {
6395 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6396 break;
6397 }
cristye27293e2009-12-18 02:53:20 +00006398 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006399 break;
6400 }
cristyc9b12952010-03-28 01:12:28 +00006401 if (LocaleCompare("direction",option+1) == 0)
6402 {
6403 if (*option == '+')
6404 {
6405 (void) SetImageOption(image_info,option+1,"undefined");
6406 break;
6407 }
6408 (void) SetImageOption(image_info,option+1,argv[i+1]);
6409 break;
6410 }
cristy3ed852e2009-09-05 21:47:34 +00006411 if (LocaleCompare("display",option+1) == 0)
6412 {
6413 if (*option == '+')
6414 {
6415 if (image_info->server_name != (char *) NULL)
6416 image_info->server_name=DestroyString(
6417 image_info->server_name);
6418 break;
6419 }
6420 (void) CloneString(&image_info->server_name,argv[i+1]);
6421 break;
6422 }
6423 if (LocaleCompare("dispose",option+1) == 0)
6424 {
6425 if (*option == '+')
6426 {
6427 (void) SetImageOption(image_info,option+1,"undefined");
6428 break;
6429 }
6430 (void) SetImageOption(image_info,option+1,argv[i+1]);
6431 break;
6432 }
6433 if (LocaleCompare("dither",option+1) == 0)
6434 {
6435 if (*option == '+')
6436 {
6437 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006438 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006439 break;
6440 }
6441 (void) SetImageOption(image_info,option+1,argv[i+1]);
6442 image_info->dither=MagickTrue;
6443 break;
6444 }
6445 break;
6446 }
6447 case 'e':
6448 {
6449 if (LocaleCompare("encoding",option+1) == 0)
6450 {
6451 if (*option == '+')
6452 {
6453 (void) SetImageOption(image_info,option+1,"undefined");
6454 break;
6455 }
6456 (void) SetImageOption(image_info,option+1,argv[i+1]);
6457 break;
6458 }
6459 if (LocaleCompare("endian",option+1) == 0)
6460 {
6461 if (*option == '+')
6462 {
6463 image_info->endian=UndefinedEndian;
6464 (void) SetImageOption(image_info,option+1,"undefined");
6465 break;
6466 }
cristy042ee782011-04-22 18:48:30 +00006467 image_info->endian=(EndianType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006468 MagickEndianOptions,MagickFalse,argv[i+1]);
6469 (void) SetImageOption(image_info,option+1,argv[i+1]);
6470 break;
6471 }
6472 if (LocaleCompare("extract",option+1) == 0)
6473 {
6474 /*
6475 Set image extract geometry.
6476 */
6477 if (*option == '+')
6478 {
6479 if (image_info->extract != (char *) NULL)
6480 image_info->extract=DestroyString(image_info->extract);
6481 break;
6482 }
6483 (void) CloneString(&image_info->extract,argv[i+1]);
6484 break;
6485 }
6486 break;
6487 }
6488 case 'f':
6489 {
6490 if (LocaleCompare("fill",option+1) == 0)
6491 {
6492 if (*option == '+')
6493 {
6494 (void) SetImageOption(image_info,option+1,"none");
6495 break;
6496 }
6497 (void) SetImageOption(image_info,option+1,argv[i+1]);
6498 break;
6499 }
6500 if (LocaleCompare("filter",option+1) == 0)
6501 {
6502 if (*option == '+')
6503 {
6504 (void) SetImageOption(image_info,option+1,"undefined");
6505 break;
6506 }
6507 (void) SetImageOption(image_info,option+1,argv[i+1]);
6508 break;
6509 }
6510 if (LocaleCompare("font",option+1) == 0)
6511 {
6512 if (*option == '+')
6513 {
6514 if (image_info->font != (char *) NULL)
6515 image_info->font=DestroyString(image_info->font);
6516 break;
6517 }
6518 (void) CloneString(&image_info->font,argv[i+1]);
6519 break;
6520 }
6521 if (LocaleCompare("format",option+1) == 0)
6522 {
6523 register const char
6524 *q;
6525
6526 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006527 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006528 image_info->ping=MagickFalse;
6529 (void) SetImageOption(image_info,option+1,argv[i+1]);
6530 break;
6531 }
6532 if (LocaleCompare("fuzz",option+1) == 0)
6533 {
6534 if (*option == '+')
6535 {
6536 image_info->fuzz=0.0;
6537 (void) SetImageOption(image_info,option+1,"0");
6538 break;
6539 }
cristyf2f27272009-12-17 14:48:46 +00006540 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006541 1.0);
6542 (void) SetImageOption(image_info,option+1,argv[i+1]);
6543 break;
6544 }
6545 break;
6546 }
6547 case 'g':
6548 {
6549 if (LocaleCompare("gravity",option+1) == 0)
6550 {
6551 if (*option == '+')
6552 {
6553 (void) SetImageOption(image_info,option+1,"undefined");
6554 break;
6555 }
6556 (void) SetImageOption(image_info,option+1,argv[i+1]);
6557 break;
6558 }
6559 if (LocaleCompare("green-primary",option+1) == 0)
6560 {
6561 if (*option == '+')
6562 {
6563 (void) SetImageOption(image_info,option+1,"0.0");
6564 break;
6565 }
6566 (void) SetImageOption(image_info,option+1,argv[i+1]);
6567 break;
6568 }
6569 break;
6570 }
6571 case 'i':
6572 {
6573 if (LocaleCompare("intent",option+1) == 0)
6574 {
6575 if (*option == '+')
6576 {
6577 (void) SetImageOption(image_info,option+1,"undefined");
6578 break;
6579 }
6580 (void) SetImageOption(image_info,option+1,argv[i+1]);
6581 break;
6582 }
6583 if (LocaleCompare("interlace",option+1) == 0)
6584 {
6585 if (*option == '+')
6586 {
6587 image_info->interlace=UndefinedInterlace;
6588 (void) SetImageOption(image_info,option+1,"undefined");
6589 break;
6590 }
cristy042ee782011-04-22 18:48:30 +00006591 image_info->interlace=(InterlaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006592 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6593 (void) SetImageOption(image_info,option+1,argv[i+1]);
6594 break;
6595 }
cristyb32b90a2009-09-07 21:45:48 +00006596 if (LocaleCompare("interline-spacing",option+1) == 0)
6597 {
6598 if (*option == '+')
6599 {
6600 (void) SetImageOption(image_info,option+1,"undefined");
6601 break;
6602 }
6603 (void) SetImageOption(image_info,option+1,argv[i+1]);
6604 break;
6605 }
cristy3ed852e2009-09-05 21:47:34 +00006606 if (LocaleCompare("interpolate",option+1) == 0)
6607 {
6608 if (*option == '+')
6609 {
6610 (void) SetImageOption(image_info,option+1,"undefined");
6611 break;
6612 }
6613 (void) SetImageOption(image_info,option+1,argv[i+1]);
6614 break;
6615 }
6616 if (LocaleCompare("interword-spacing",option+1) == 0)
6617 {
6618 if (*option == '+')
6619 {
6620 (void) SetImageOption(image_info,option+1,"undefined");
6621 break;
6622 }
6623 (void) SetImageOption(image_info,option+1,argv[i+1]);
6624 break;
6625 }
6626 break;
6627 }
6628 case 'k':
6629 {
6630 if (LocaleCompare("kerning",option+1) == 0)
6631 {
6632 if (*option == '+')
6633 {
6634 (void) SetImageOption(image_info,option+1,"undefined");
6635 break;
6636 }
6637 (void) SetImageOption(image_info,option+1,argv[i+1]);
6638 break;
6639 }
6640 break;
6641 }
6642 case 'l':
6643 {
6644 if (LocaleCompare("label",option+1) == 0)
6645 {
6646 if (*option == '+')
6647 {
6648 (void) DeleteImageOption(image_info,option+1);
6649 break;
6650 }
6651 (void) SetImageOption(image_info,option+1,argv[i+1]);
6652 break;
6653 }
6654 if (LocaleCompare("limit",option+1) == 0)
6655 {
6656 MagickSizeType
6657 limit;
6658
6659 ResourceType
6660 type;
6661
6662 if (*option == '+')
6663 break;
cristy042ee782011-04-22 18:48:30 +00006664 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
cristy3ed852e2009-09-05 21:47:34 +00006665 MagickFalse,argv[i+1]);
6666 limit=MagickResourceInfinity;
6667 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006668 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006669 (void) SetMagickResourceLimit(type,limit);
6670 break;
6671 }
6672 if (LocaleCompare("list",option+1) == 0)
6673 {
cristybb503372010-05-27 20:51:26 +00006674 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006675 list;
6676
6677 /*
6678 Display configuration list.
6679 */
cristy042ee782011-04-22 18:48:30 +00006680 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006681 switch (list)
6682 {
6683 case MagickCoderOptions:
6684 {
6685 (void) ListCoderInfo((FILE *) NULL,exception);
6686 break;
6687 }
6688 case MagickColorOptions:
6689 {
6690 (void) ListColorInfo((FILE *) NULL,exception);
6691 break;
6692 }
6693 case MagickConfigureOptions:
6694 {
6695 (void) ListConfigureInfo((FILE *) NULL,exception);
6696 break;
6697 }
6698 case MagickDelegateOptions:
6699 {
6700 (void) ListDelegateInfo((FILE *) NULL,exception);
6701 break;
6702 }
6703 case MagickFontOptions:
6704 {
6705 (void) ListTypeInfo((FILE *) NULL,exception);
6706 break;
6707 }
6708 case MagickFormatOptions:
6709 {
6710 (void) ListMagickInfo((FILE *) NULL,exception);
6711 break;
6712 }
6713 case MagickLocaleOptions:
6714 {
6715 (void) ListLocaleInfo((FILE *) NULL,exception);
6716 break;
6717 }
6718 case MagickLogOptions:
6719 {
6720 (void) ListLogInfo((FILE *) NULL,exception);
6721 break;
6722 }
6723 case MagickMagicOptions:
6724 {
6725 (void) ListMagicInfo((FILE *) NULL,exception);
6726 break;
6727 }
6728 case MagickMimeOptions:
6729 {
6730 (void) ListMimeInfo((FILE *) NULL,exception);
6731 break;
6732 }
6733 case MagickModuleOptions:
6734 {
6735 (void) ListModuleInfo((FILE *) NULL,exception);
6736 break;
6737 }
6738 case MagickPolicyOptions:
6739 {
6740 (void) ListPolicyInfo((FILE *) NULL,exception);
6741 break;
6742 }
6743 case MagickResourceOptions:
6744 {
6745 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6746 break;
6747 }
6748 case MagickThresholdOptions:
6749 {
6750 (void) ListThresholdMaps((FILE *) NULL,exception);
6751 break;
6752 }
6753 default:
6754 {
cristy042ee782011-04-22 18:48:30 +00006755 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
cristy3ed852e2009-09-05 21:47:34 +00006756 exception);
6757 break;
6758 }
6759 }
cristyaeb2cbc2010-05-07 13:28:58 +00006760 break;
cristy3ed852e2009-09-05 21:47:34 +00006761 }
6762 if (LocaleCompare("log",option+1) == 0)
6763 {
6764 if (*option == '+')
6765 break;
6766 (void) SetLogFormat(argv[i+1]);
6767 break;
6768 }
6769 if (LocaleCompare("loop",option+1) == 0)
6770 {
6771 if (*option == '+')
6772 {
6773 (void) SetImageOption(image_info,option+1,"0");
6774 break;
6775 }
6776 (void) SetImageOption(image_info,option+1,argv[i+1]);
6777 break;
6778 }
6779 break;
6780 }
6781 case 'm':
6782 {
6783 if (LocaleCompare("matte",option+1) == 0)
6784 {
6785 if (*option == '+')
6786 {
6787 (void) SetImageOption(image_info,option+1,"false");
6788 break;
6789 }
6790 (void) SetImageOption(image_info,option+1,"true");
6791 break;
6792 }
6793 if (LocaleCompare("mattecolor",option+1) == 0)
6794 {
6795 if (*option == '+')
6796 {
6797 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006798 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006799 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006800 break;
6801 }
6802 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006803 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6804 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006805 break;
6806 }
6807 if (LocaleCompare("monitor",option+1) == 0)
6808 {
6809 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6810 (void *) NULL);
6811 break;
6812 }
6813 if (LocaleCompare("monochrome",option+1) == 0)
6814 {
6815 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6816 break;
6817 }
6818 break;
6819 }
6820 case 'o':
6821 {
6822 if (LocaleCompare("orient",option+1) == 0)
6823 {
6824 if (*option == '+')
6825 {
6826 image_info->orientation=UndefinedOrientation;
6827 (void) SetImageOption(image_info,option+1,"undefined");
6828 break;
6829 }
cristy042ee782011-04-22 18:48:30 +00006830 image_info->orientation=(OrientationType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006831 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00006832 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006833 break;
6834 }
6835 }
6836 case 'p':
6837 {
6838 if (LocaleCompare("page",option+1) == 0)
6839 {
6840 char
6841 *canonical_page,
6842 page[MaxTextExtent];
6843
6844 const char
6845 *image_option;
6846
6847 MagickStatusType
6848 flags;
6849
6850 RectangleInfo
6851 geometry;
6852
6853 if (*option == '+')
6854 {
6855 (void) DeleteImageOption(image_info,option+1);
6856 (void) CloneString(&image_info->page,(char *) NULL);
6857 break;
6858 }
6859 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6860 image_option=GetImageOption(image_info,"page");
6861 if (image_option != (const char *) NULL)
6862 flags=ParseAbsoluteGeometry(image_option,&geometry);
6863 canonical_page=GetPageGeometry(argv[i+1]);
6864 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6865 canonical_page=DestroyString(canonical_page);
cristyb51dff52011-05-19 16:55:47 +00006866 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00006867 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00006868 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
cristyb51dff52011-05-19 16:55:47 +00006869 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00006870 (unsigned long) geometry.width,(unsigned long) geometry.height,
6871 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00006872 (void) SetImageOption(image_info,option+1,page);
6873 (void) CloneString(&image_info->page,page);
6874 break;
6875 }
6876 if (LocaleCompare("pen",option+1) == 0)
6877 {
6878 if (*option == '+')
6879 {
6880 (void) SetImageOption(image_info,option+1,"none");
6881 break;
6882 }
6883 (void) SetImageOption(image_info,option+1,argv[i+1]);
6884 break;
6885 }
6886 if (LocaleCompare("ping",option+1) == 0)
6887 {
6888 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6889 break;
6890 }
6891 if (LocaleCompare("pointsize",option+1) == 0)
6892 {
6893 if (*option == '+')
6894 geometry_info.rho=0.0;
6895 else
6896 (void) ParseGeometry(argv[i+1],&geometry_info);
6897 image_info->pointsize=geometry_info.rho;
6898 break;
6899 }
cristye7f51092010-01-17 00:39:37 +00006900 if (LocaleCompare("precision",option+1) == 0)
6901 {
cristybf2766a2010-01-17 03:33:23 +00006902 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00006903 break;
6904 }
cristy3ed852e2009-09-05 21:47:34 +00006905 if (LocaleCompare("preview",option+1) == 0)
6906 {
6907 /*
6908 Preview image.
6909 */
6910 if (*option == '+')
6911 {
6912 image_info->preview_type=UndefinedPreview;
6913 break;
6914 }
cristy042ee782011-04-22 18:48:30 +00006915 image_info->preview_type=(PreviewType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006916 MagickPreviewOptions,MagickFalse,argv[i+1]);
6917 break;
6918 }
6919 break;
6920 }
6921 case 'q':
6922 {
6923 if (LocaleCompare("quality",option+1) == 0)
6924 {
6925 /*
6926 Set image compression quality.
6927 */
6928 if (*option == '+')
6929 {
6930 image_info->quality=UndefinedCompressionQuality;
6931 (void) SetImageOption(image_info,option+1,"0");
6932 break;
6933 }
cristye27293e2009-12-18 02:53:20 +00006934 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006935 (void) SetImageOption(image_info,option+1,argv[i+1]);
6936 break;
6937 }
6938 if (LocaleCompare("quiet",option+1) == 0)
6939 {
6940 static WarningHandler
6941 warning_handler = (WarningHandler) NULL;
6942
6943 if (*option == '+')
6944 {
6945 /*
6946 Restore error or warning messages.
6947 */
6948 warning_handler=SetWarningHandler(warning_handler);
6949 break;
6950 }
6951 /*
6952 Suppress error or warning messages.
6953 */
6954 warning_handler=SetWarningHandler((WarningHandler) NULL);
6955 break;
6956 }
6957 break;
6958 }
6959 case 'r':
6960 {
6961 if (LocaleCompare("red-primary",option+1) == 0)
6962 {
6963 if (*option == '+')
6964 {
6965 (void) SetImageOption(image_info,option+1,"0.0");
6966 break;
6967 }
6968 (void) SetImageOption(image_info,option+1,argv[i+1]);
6969 break;
6970 }
6971 break;
6972 }
6973 case 's':
6974 {
6975 if (LocaleCompare("sampling-factor",option+1) == 0)
6976 {
6977 /*
6978 Set image sampling factor.
6979 */
6980 if (*option == '+')
6981 {
6982 if (image_info->sampling_factor != (char *) NULL)
6983 image_info->sampling_factor=DestroyString(
6984 image_info->sampling_factor);
6985 break;
6986 }
6987 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6988 break;
6989 }
6990 if (LocaleCompare("scene",option+1) == 0)
6991 {
6992 /*
6993 Set image scene.
6994 */
6995 if (*option == '+')
6996 {
6997 image_info->scene=0;
6998 (void) SetImageOption(image_info,option+1,"0");
6999 break;
7000 }
cristye27293e2009-12-18 02:53:20 +00007001 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007002 (void) SetImageOption(image_info,option+1,argv[i+1]);
7003 break;
7004 }
7005 if (LocaleCompare("seed",option+1) == 0)
7006 {
cristybb503372010-05-27 20:51:26 +00007007 size_t
cristy3ed852e2009-09-05 21:47:34 +00007008 seed;
7009
7010 if (*option == '+')
7011 {
cristybb503372010-05-27 20:51:26 +00007012 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007013 SeedPseudoRandomGenerator(seed);
7014 break;
7015 }
cristye27293e2009-12-18 02:53:20 +00007016 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007017 SeedPseudoRandomGenerator(seed);
7018 break;
7019 }
7020 if (LocaleCompare("size",option+1) == 0)
7021 {
7022 if (*option == '+')
7023 {
7024 if (image_info->size != (char *) NULL)
7025 image_info->size=DestroyString(image_info->size);
7026 break;
7027 }
7028 (void) CloneString(&image_info->size,argv[i+1]);
7029 break;
7030 }
7031 if (LocaleCompare("stroke",option+1) == 0)
7032 {
7033 if (*option == '+')
7034 {
7035 (void) SetImageOption(image_info,option+1,"none");
7036 break;
7037 }
7038 (void) SetImageOption(image_info,option+1,argv[i+1]);
7039 break;
7040 }
7041 if (LocaleCompare("strokewidth",option+1) == 0)
7042 {
7043 if (*option == '+')
7044 {
7045 (void) SetImageOption(image_info,option+1,"0");
7046 break;
7047 }
7048 (void) SetImageOption(image_info,option+1,argv[i+1]);
7049 break;
7050 }
cristyd9a29192010-10-16 16:49:53 +00007051 if (LocaleCompare("synchronize",option+1) == 0)
7052 {
7053 if (*option == '+')
7054 {
7055 image_info->synchronize=MagickFalse;
7056 break;
7057 }
7058 image_info->synchronize=MagickTrue;
7059 break;
7060 }
cristy3ed852e2009-09-05 21:47:34 +00007061 break;
7062 }
7063 case 't':
7064 {
7065 if (LocaleCompare("taint",option+1) == 0)
7066 {
7067 if (*option == '+')
7068 {
7069 (void) SetImageOption(image_info,option+1,"false");
7070 break;
7071 }
7072 (void) SetImageOption(image_info,option+1,"true");
7073 break;
7074 }
7075 if (LocaleCompare("texture",option+1) == 0)
7076 {
7077 if (*option == '+')
7078 {
7079 if (image_info->texture != (char *) NULL)
7080 image_info->texture=DestroyString(image_info->texture);
7081 break;
7082 }
7083 (void) CloneString(&image_info->texture,argv[i+1]);
7084 break;
7085 }
7086 if (LocaleCompare("tile-offset",option+1) == 0)
7087 {
7088 if (*option == '+')
7089 {
7090 (void) SetImageOption(image_info,option+1,"0");
7091 break;
7092 }
7093 (void) SetImageOption(image_info,option+1,argv[i+1]);
7094 break;
7095 }
7096 if (LocaleCompare("transparent-color",option+1) == 0)
7097 {
7098 if (*option == '+')
7099 {
cristy9950d572011-10-01 18:22:35 +00007100 (void) QueryColorCompliance("none",AllCompliance,
7101 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007102 (void) SetImageOption(image_info,option+1,"none");
7103 break;
7104 }
cristy9950d572011-10-01 18:22:35 +00007105 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7106 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007107 (void) SetImageOption(image_info,option+1,argv[i+1]);
7108 break;
7109 }
7110 if (LocaleCompare("type",option+1) == 0)
7111 {
7112 if (*option == '+')
7113 {
cristy5f1c1ff2010-12-23 21:38:06 +00007114 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007115 (void) SetImageOption(image_info,option+1,"undefined");
7116 break;
7117 }
cristy042ee782011-04-22 18:48:30 +00007118 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
cristy3ed852e2009-09-05 21:47:34 +00007119 MagickFalse,argv[i+1]);
7120 (void) SetImageOption(image_info,option+1,argv[i+1]);
7121 break;
7122 }
7123 break;
7124 }
7125 case 'u':
7126 {
7127 if (LocaleCompare("undercolor",option+1) == 0)
7128 {
7129 if (*option == '+')
7130 {
7131 (void) DeleteImageOption(image_info,option+1);
7132 break;
7133 }
7134 (void) SetImageOption(image_info,option+1,argv[i+1]);
7135 break;
7136 }
7137 if (LocaleCompare("units",option+1) == 0)
7138 {
7139 if (*option == '+')
7140 {
7141 image_info->units=UndefinedResolution;
7142 (void) SetImageOption(image_info,option+1,"undefined");
7143 break;
7144 }
cristy042ee782011-04-22 18:48:30 +00007145 image_info->units=(ResolutionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007146 MagickResolutionOptions,MagickFalse,argv[i+1]);
7147 (void) SetImageOption(image_info,option+1,argv[i+1]);
7148 break;
7149 }
7150 break;
7151 }
7152 case 'v':
7153 {
7154 if (LocaleCompare("verbose",option+1) == 0)
7155 {
7156 if (*option == '+')
7157 {
7158 image_info->verbose=MagickFalse;
7159 break;
7160 }
7161 image_info->verbose=MagickTrue;
7162 image_info->ping=MagickFalse;
7163 break;
7164 }
7165 if (LocaleCompare("view",option+1) == 0)
7166 {
7167 if (*option == '+')
7168 {
7169 if (image_info->view != (char *) NULL)
7170 image_info->view=DestroyString(image_info->view);
7171 break;
7172 }
7173 (void) CloneString(&image_info->view,argv[i+1]);
7174 break;
7175 }
7176 if (LocaleCompare("virtual-pixel",option+1) == 0)
7177 {
7178 if (*option == '+')
7179 {
7180 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7181 (void) SetImageOption(image_info,option+1,"undefined");
7182 break;
7183 }
7184 image_info->virtual_pixel_method=(VirtualPixelMethod)
cristy042ee782011-04-22 18:48:30 +00007185 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00007186 argv[i+1]);
7187 (void) SetImageOption(image_info,option+1,argv[i+1]);
7188 break;
7189 }
7190 break;
7191 }
7192 case 'w':
7193 {
7194 if (LocaleCompare("white-point",option+1) == 0)
7195 {
7196 if (*option == '+')
7197 {
7198 (void) SetImageOption(image_info,option+1,"0.0");
7199 break;
7200 }
7201 (void) SetImageOption(image_info,option+1,argv[i+1]);
7202 break;
7203 }
7204 break;
7205 }
7206 default:
7207 break;
7208 }
7209 i+=count;
7210 }
7211 return(MagickTrue);
7212}
7213
7214/*
7215%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7216% %
7217% %
7218% %
7219+ M o g r i f y I m a g e L i s t %
7220% %
7221% %
7222% %
7223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7224%
7225% MogrifyImageList() applies any command line options that might affect the
7226% entire image list (e.g. -append, -coalesce, etc.).
7227%
7228% The format of the MogrifyImage method is:
7229%
7230% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7231% const char **argv,Image **images,ExceptionInfo *exception)
7232%
7233% A description of each parameter follows:
7234%
7235% o image_info: the image info..
7236%
7237% o argc: Specifies a pointer to an integer describing the number of
7238% elements in the argument vector.
7239%
7240% o argv: Specifies a pointer to a text array containing the command line
7241% arguments.
7242%
anthonye9c27192011-03-27 08:07:06 +00007243% o images: pointer to pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00007244%
7245% o exception: return any errors or warnings in this structure.
7246%
7247*/
7248WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7249 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7250{
cristy3ed852e2009-09-05 21:47:34 +00007251 const char
7252 *option;
7253
cristy6b3da3a2010-06-20 02:21:46 +00007254 ImageInfo
7255 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007256
7257 MagickStatusType
7258 status;
7259
cristy28474bf2011-09-11 23:32:52 +00007260 PixelInterpolateMethod
7261 interpolate_method;
7262
cristy3ed852e2009-09-05 21:47:34 +00007263 QuantizeInfo
7264 *quantize_info;
7265
cristybb503372010-05-27 20:51:26 +00007266 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007267 i;
7268
cristy6b3da3a2010-06-20 02:21:46 +00007269 ssize_t
7270 count,
7271 index;
7272
cristy3ed852e2009-09-05 21:47:34 +00007273 /*
7274 Apply options to the image list.
7275 */
7276 assert(image_info != (ImageInfo *) NULL);
7277 assert(image_info->signature == MagickSignature);
7278 assert(images != (Image **) NULL);
anthonye9c27192011-03-27 08:07:06 +00007279 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007280 assert((*images)->signature == MagickSignature);
7281 if ((*images)->debug != MagickFalse)
7282 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7283 (*images)->filename);
7284 if ((argc <= 0) || (*argv == (char *) NULL))
7285 return(MagickTrue);
cristy28474bf2011-09-11 23:32:52 +00007286 interpolate_method=UndefinedInterpolatePixel;
cristy6b3da3a2010-06-20 02:21:46 +00007287 mogrify_info=CloneImageInfo(image_info);
7288 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00007289 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007290 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007291 {
cristy74fe8f12009-10-03 19:09:01 +00007292 if (*images == (Image *) NULL)
7293 break;
cristy3ed852e2009-09-05 21:47:34 +00007294 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00007295 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00007296 continue;
cristy042ee782011-04-22 18:48:30 +00007297 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00007298 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00007299 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007300 break;
cristy6b3da3a2010-06-20 02:21:46 +00007301 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007302 switch (*(option+1))
7303 {
7304 case 'a':
7305 {
7306 if (LocaleCompare("affinity",option+1) == 0)
7307 {
cristy6b3da3a2010-06-20 02:21:46 +00007308 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007309 if (*option == '+')
7310 {
cristy018f07f2011-09-04 21:15:19 +00007311 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7312 exception);
cristy3ed852e2009-09-05 21:47:34 +00007313 break;
7314 }
7315 i++;
7316 break;
7317 }
7318 if (LocaleCompare("append",option+1) == 0)
7319 {
7320 Image
7321 *append_image;
7322
cristy6b3da3a2010-06-20 02:21:46 +00007323 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007324 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7325 MagickFalse,exception);
7326 if (append_image == (Image *) NULL)
7327 {
7328 status=MagickFalse;
7329 break;
7330 }
7331 *images=DestroyImageList(*images);
7332 *images=append_image;
7333 break;
7334 }
7335 if (LocaleCompare("average",option+1) == 0)
7336 {
7337 Image
7338 *average_image;
7339
cristyd18ae7c2010-03-07 17:39:52 +00007340 /*
7341 Average an image sequence (deprecated).
7342 */
cristy6b3da3a2010-06-20 02:21:46 +00007343 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007344 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7345 exception);
cristy3ed852e2009-09-05 21:47:34 +00007346 if (average_image == (Image *) NULL)
7347 {
7348 status=MagickFalse;
7349 break;
7350 }
7351 *images=DestroyImageList(*images);
7352 *images=average_image;
7353 break;
7354 }
7355 break;
7356 }
7357 case 'c':
7358 {
7359 if (LocaleCompare("channel",option+1) == 0)
7360 {
cristyf4ad9df2011-07-08 16:49:03 +00007361 ChannelType
7362 channel;
7363
cristy3ed852e2009-09-05 21:47:34 +00007364 if (*option == '+')
7365 {
7366 channel=DefaultChannels;
7367 break;
7368 }
7369 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00007370 SetPixelChannelMap(*images,channel);
cristy3ed852e2009-09-05 21:47:34 +00007371 break;
7372 }
7373 if (LocaleCompare("clut",option+1) == 0)
7374 {
7375 Image
7376 *clut_image,
7377 *image;
7378
cristy6b3da3a2010-06-20 02:21:46 +00007379 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007380 image=RemoveFirstImageFromList(images);
7381 clut_image=RemoveFirstImageFromList(images);
7382 if (clut_image == (Image *) NULL)
7383 {
7384 status=MagickFalse;
7385 break;
7386 }
cristy28474bf2011-09-11 23:32:52 +00007387 (void) ClutImage(image,clut_image,interpolate_method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007388 clut_image=DestroyImage(clut_image);
cristy3ed852e2009-09-05 21:47:34 +00007389 *images=DestroyImageList(*images);
7390 *images=image;
7391 break;
7392 }
7393 if (LocaleCompare("coalesce",option+1) == 0)
7394 {
7395 Image
7396 *coalesce_image;
7397
cristy6b3da3a2010-06-20 02:21:46 +00007398 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007399 coalesce_image=CoalesceImages(*images,exception);
7400 if (coalesce_image == (Image *) NULL)
7401 {
7402 status=MagickFalse;
7403 break;
7404 }
7405 *images=DestroyImageList(*images);
7406 *images=coalesce_image;
7407 break;
7408 }
7409 if (LocaleCompare("combine",option+1) == 0)
7410 {
7411 Image
7412 *combine_image;
7413
cristy6b3da3a2010-06-20 02:21:46 +00007414 (void) SyncImagesSettings(mogrify_info,*images);
cristy3139dc22011-07-08 00:11:42 +00007415 combine_image=CombineImages(*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007416 if (combine_image == (Image *) NULL)
7417 {
7418 status=MagickFalse;
7419 break;
7420 }
7421 *images=DestroyImageList(*images);
7422 *images=combine_image;
7423 break;
7424 }
7425 if (LocaleCompare("composite",option+1) == 0)
7426 {
7427 Image
7428 *mask_image,
7429 *composite_image,
7430 *image;
7431
7432 RectangleInfo
7433 geometry;
7434
cristy6b3da3a2010-06-20 02:21:46 +00007435 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007436 image=RemoveFirstImageFromList(images);
7437 composite_image=RemoveFirstImageFromList(images);
7438 if (composite_image == (Image *) NULL)
7439 {
7440 status=MagickFalse;
7441 break;
7442 }
7443 (void) TransformImage(&composite_image,(char *) NULL,
cristye941a752011-10-15 01:52:48 +00007444 composite_image->geometry,exception);
cristy3ed852e2009-09-05 21:47:34 +00007445 SetGeometry(composite_image,&geometry);
7446 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7447 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7448 &geometry);
7449 mask_image=RemoveFirstImageFromList(images);
7450 if (mask_image != (Image *) NULL)
7451 {
7452 if ((image->compose == DisplaceCompositeOp) ||
7453 (image->compose == DistortCompositeOp))
7454 {
7455 /*
7456 Merge Y displacement into X displacement image.
7457 */
7458 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
cristye941a752011-10-15 01:52:48 +00007459 mask_image,0,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00007460 mask_image=DestroyImage(mask_image);
7461 }
7462 else
7463 {
7464 /*
7465 Set a blending mask for the composition.
cristy28474bf2011-09-11 23:32:52 +00007466 Posible error, what if image->mask already set.
cristy3ed852e2009-09-05 21:47:34 +00007467 */
7468 image->mask=mask_image;
cristyb3e7c6c2011-07-24 01:43:55 +00007469 (void) NegateImage(image->mask,MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007470 }
7471 }
cristyf4ad9df2011-07-08 16:49:03 +00007472 (void) CompositeImage(image,image->compose,composite_image,
cristye941a752011-10-15 01:52:48 +00007473 geometry.x,geometry.y,exception);
anthonya129f702011-04-14 01:08:48 +00007474 if (mask_image != (Image *) NULL)
7475 mask_image=image->mask=DestroyImage(image->mask);
cristy3ed852e2009-09-05 21:47:34 +00007476 composite_image=DestroyImage(composite_image);
7477 InheritException(exception,&image->exception);
7478 *images=DestroyImageList(*images);
7479 *images=image;
7480 break;
7481 }
cristy3ed852e2009-09-05 21:47:34 +00007482 break;
7483 }
7484 case 'd':
7485 {
7486 if (LocaleCompare("deconstruct",option+1) == 0)
7487 {
7488 Image
7489 *deconstruct_image;
7490
cristy6b3da3a2010-06-20 02:21:46 +00007491 (void) SyncImagesSettings(mogrify_info,*images);
cristy8a9106f2011-07-05 14:39:26 +00007492 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
cristy4c08aed2011-07-01 19:47:50 +00007493 exception);
cristy3ed852e2009-09-05 21:47:34 +00007494 if (deconstruct_image == (Image *) NULL)
7495 {
7496 status=MagickFalse;
7497 break;
7498 }
7499 *images=DestroyImageList(*images);
7500 *images=deconstruct_image;
7501 break;
7502 }
7503 if (LocaleCompare("delete",option+1) == 0)
7504 {
7505 if (*option == '+')
7506 DeleteImages(images,"-1",exception);
7507 else
7508 DeleteImages(images,argv[i+1],exception);
7509 break;
7510 }
7511 if (LocaleCompare("dither",option+1) == 0)
7512 {
7513 if (*option == '+')
7514 {
7515 quantize_info->dither=MagickFalse;
7516 break;
7517 }
7518 quantize_info->dither=MagickTrue;
cristy042ee782011-04-22 18:48:30 +00007519 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007520 MagickDitherOptions,MagickFalse,argv[i+1]);
7521 break;
7522 }
cristyecb10ff2011-03-22 13:14:03 +00007523 if (LocaleCompare("duplicate",option+1) == 0)
7524 {
cristy72988482011-03-29 16:34:38 +00007525 Image
7526 *duplicate_images;
cristybf95deb2011-03-23 00:25:36 +00007527
anthony2b6bcae2011-03-23 13:05:34 +00007528 if (*option == '+')
cristy72988482011-03-29 16:34:38 +00007529 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7530 else
7531 {
7532 const char
7533 *p;
7534
anthony2b6bcae2011-03-23 13:05:34 +00007535 size_t
7536 number_duplicates;
anthony9bd15492011-03-23 02:11:13 +00007537
anthony2b6bcae2011-03-23 13:05:34 +00007538 number_duplicates=(size_t) StringToLong(argv[i+1]);
cristy72988482011-03-29 16:34:38 +00007539 p=strchr(argv[i+1],',');
7540 if (p == (const char *) NULL)
7541 duplicate_images=DuplicateImages(*images,number_duplicates,
7542 "-1",exception);
anthony2b6bcae2011-03-23 13:05:34 +00007543 else
cristy72988482011-03-29 16:34:38 +00007544 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7545 exception);
anthony2b6bcae2011-03-23 13:05:34 +00007546 }
7547 AppendImageToList(images, duplicate_images);
7548 (void) SyncImagesSettings(mogrify_info,*images);
cristyecb10ff2011-03-22 13:14:03 +00007549 break;
7550 }
cristy3ed852e2009-09-05 21:47:34 +00007551 break;
7552 }
cristyd18ae7c2010-03-07 17:39:52 +00007553 case 'e':
7554 {
7555 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7556 {
7557 Image
7558 *evaluate_image;
7559
7560 MagickEvaluateOperator
7561 op;
7562
cristy6b3da3a2010-06-20 02:21:46 +00007563 (void) SyncImageSettings(mogrify_info,*images);
cristy28474bf2011-09-11 23:32:52 +00007564 op=(MagickEvaluateOperator) ParseCommandOption(
7565 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristyd18ae7c2010-03-07 17:39:52 +00007566 evaluate_image=EvaluateImages(*images,op,exception);
7567 if (evaluate_image == (Image *) NULL)
7568 {
7569 status=MagickFalse;
7570 break;
7571 }
7572 *images=DestroyImageList(*images);
7573 *images=evaluate_image;
7574 break;
7575 }
7576 break;
7577 }
cristy3ed852e2009-09-05 21:47:34 +00007578 case 'f':
7579 {
cristyf0a247f2009-10-04 00:20:03 +00007580 if (LocaleCompare("fft",option+1) == 0)
7581 {
7582 Image
7583 *fourier_image;
7584
7585 /*
7586 Implements the discrete Fourier transform (DFT).
7587 */
cristy6b3da3a2010-06-20 02:21:46 +00007588 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00007589 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7590 MagickTrue : MagickFalse,exception);
7591 if (fourier_image == (Image *) NULL)
7592 break;
7593 *images=DestroyImage(*images);
7594 *images=fourier_image;
7595 break;
7596 }
cristy3ed852e2009-09-05 21:47:34 +00007597 if (LocaleCompare("flatten",option+1) == 0)
7598 {
7599 Image
7600 *flatten_image;
7601
cristy6b3da3a2010-06-20 02:21:46 +00007602 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007603 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7604 if (flatten_image == (Image *) NULL)
7605 break;
7606 *images=DestroyImageList(*images);
7607 *images=flatten_image;
7608 break;
7609 }
7610 if (LocaleCompare("fx",option+1) == 0)
7611 {
7612 Image
7613 *fx_image;
7614
cristy6b3da3a2010-06-20 02:21:46 +00007615 (void) SyncImagesSettings(mogrify_info,*images);
cristy490408a2011-07-07 14:42:05 +00007616 fx_image=FxImage(*images,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00007617 if (fx_image == (Image *) NULL)
7618 {
7619 status=MagickFalse;
7620 break;
7621 }
7622 *images=DestroyImageList(*images);
7623 *images=fx_image;
7624 break;
7625 }
7626 break;
7627 }
7628 case 'h':
7629 {
7630 if (LocaleCompare("hald-clut",option+1) == 0)
7631 {
7632 Image
7633 *hald_image,
7634 *image;
7635
cristy6b3da3a2010-06-20 02:21:46 +00007636 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007637 image=RemoveFirstImageFromList(images);
7638 hald_image=RemoveFirstImageFromList(images);
7639 if (hald_image == (Image *) NULL)
7640 {
7641 status=MagickFalse;
7642 break;
7643 }
cristy7c0a0a42011-08-23 17:57:25 +00007644 (void) HaldClutImage(image,hald_image,exception);
cristy3ed852e2009-09-05 21:47:34 +00007645 hald_image=DestroyImage(hald_image);
cristy0aff6ea2009-11-14 01:40:53 +00007646 if (*images != (Image *) NULL)
7647 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00007648 *images=image;
7649 break;
7650 }
7651 break;
7652 }
7653 case 'i':
7654 {
7655 if (LocaleCompare("ift",option+1) == 0)
7656 {
7657 Image
cristy8587f882009-11-13 20:28:49 +00007658 *fourier_image,
7659 *magnitude_image,
7660 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00007661
7662 /*
7663 Implements the inverse fourier discrete Fourier transform (DFT).
7664 */
cristy6b3da3a2010-06-20 02:21:46 +00007665 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00007666 magnitude_image=RemoveFirstImageFromList(images);
7667 phase_image=RemoveFirstImageFromList(images);
7668 if (phase_image == (Image *) NULL)
7669 {
7670 status=MagickFalse;
7671 break;
7672 }
7673 fourier_image=InverseFourierTransformImage(magnitude_image,
7674 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007675 if (fourier_image == (Image *) NULL)
7676 break;
cristy0aff6ea2009-11-14 01:40:53 +00007677 if (*images != (Image *) NULL)
7678 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00007679 *images=fourier_image;
7680 break;
7681 }
7682 if (LocaleCompare("insert",option+1) == 0)
7683 {
7684 Image
7685 *p,
7686 *q;
7687
7688 index=0;
7689 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00007690 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007691 p=RemoveLastImageFromList(images);
7692 if (p == (Image *) NULL)
7693 {
7694 (void) ThrowMagickException(exception,GetMagickModule(),
7695 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7696 status=MagickFalse;
7697 break;
7698 }
7699 q=p;
7700 if (index == 0)
7701 PrependImageToList(images,q);
7702 else
cristybb503372010-05-27 20:51:26 +00007703 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00007704 AppendImageToList(images,q);
7705 else
7706 {
7707 q=GetImageFromList(*images,index-1);
7708 if (q == (Image *) NULL)
7709 {
7710 (void) ThrowMagickException(exception,GetMagickModule(),
7711 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7712 status=MagickFalse;
7713 break;
7714 }
7715 InsertImageInList(&q,p);
7716 }
7717 *images=GetFirstImageInList(q);
7718 break;
7719 }
cristy28474bf2011-09-11 23:32:52 +00007720 if (LocaleCompare("interpolate",option+1) == 0)
7721 {
7722 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7723 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7724 break;
7725 }
cristy3ed852e2009-09-05 21:47:34 +00007726 break;
7727 }
7728 case 'l':
7729 {
7730 if (LocaleCompare("layers",option+1) == 0)
7731 {
7732 Image
7733 *layers;
7734
7735 ImageLayerMethod
7736 method;
7737
cristy6b3da3a2010-06-20 02:21:46 +00007738 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007739 layers=(Image *) NULL;
cristy042ee782011-04-22 18:48:30 +00007740 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
cristy3ed852e2009-09-05 21:47:34 +00007741 MagickFalse,argv[i+1]);
7742 switch (method)
7743 {
7744 case CoalesceLayer:
7745 {
7746 layers=CoalesceImages(*images,exception);
7747 break;
7748 }
7749 case CompareAnyLayer:
7750 case CompareClearLayer:
7751 case CompareOverlayLayer:
7752 default:
7753 {
cristy8a9106f2011-07-05 14:39:26 +00007754 layers=CompareImagesLayers(*images,method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007755 break;
7756 }
7757 case MergeLayer:
7758 case FlattenLayer:
7759 case MosaicLayer:
7760 case TrimBoundsLayer:
7761 {
7762 layers=MergeImageLayers(*images,method,exception);
7763 break;
7764 }
7765 case DisposeLayer:
7766 {
7767 layers=DisposeImages(*images,exception);
7768 break;
7769 }
7770 case OptimizeImageLayer:
7771 {
7772 layers=OptimizeImageLayers(*images,exception);
7773 break;
7774 }
7775 case OptimizePlusLayer:
7776 {
7777 layers=OptimizePlusImageLayers(*images,exception);
7778 break;
7779 }
7780 case OptimizeTransLayer:
7781 {
7782 OptimizeImageTransparency(*images,exception);
7783 break;
7784 }
7785 case RemoveDupsLayer:
7786 {
7787 RemoveDuplicateLayers(images,exception);
7788 break;
7789 }
7790 case RemoveZeroLayer:
7791 {
7792 RemoveZeroDelayLayers(images,exception);
7793 break;
7794 }
7795 case OptimizeLayer:
7796 {
7797 /*
7798 General Purpose, GIF Animation Optimizer.
7799 */
7800 layers=CoalesceImages(*images,exception);
7801 if (layers == (Image *) NULL)
7802 {
7803 status=MagickFalse;
7804 break;
7805 }
cristy3ed852e2009-09-05 21:47:34 +00007806 *images=DestroyImageList(*images);
7807 *images=layers;
7808 layers=OptimizeImageLayers(*images,exception);
7809 if (layers == (Image *) NULL)
7810 {
7811 status=MagickFalse;
7812 break;
7813 }
cristy3ed852e2009-09-05 21:47:34 +00007814 *images=DestroyImageList(*images);
7815 *images=layers;
7816 layers=(Image *) NULL;
7817 OptimizeImageTransparency(*images,exception);
cristy018f07f2011-09-04 21:15:19 +00007818 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7819 exception);
cristy3ed852e2009-09-05 21:47:34 +00007820 break;
7821 }
7822 case CompositeLayer:
7823 {
7824 CompositeOperator
7825 compose;
7826
7827 Image
7828 *source;
7829
7830 RectangleInfo
7831 geometry;
7832
7833 /*
7834 Split image sequence at the first 'NULL:' image.
7835 */
7836 source=(*images);
7837 while (source != (Image *) NULL)
7838 {
7839 source=GetNextImageInList(source);
7840 if ((source != (Image *) NULL) &&
7841 (LocaleCompare(source->magick,"NULL") == 0))
7842 break;
7843 }
7844 if (source != (Image *) NULL)
7845 {
7846 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7847 (GetNextImageInList(source) == (Image *) NULL))
7848 source=(Image *) NULL;
7849 else
7850 {
7851 /*
7852 Separate the two lists, junk the null: image.
7853 */
7854 source=SplitImageList(source->previous);
7855 DeleteImageFromList(&source);
7856 }
7857 }
7858 if (source == (Image *) NULL)
7859 {
7860 (void) ThrowMagickException(exception,GetMagickModule(),
7861 OptionError,"MissingNullSeparator","layers Composite");
7862 status=MagickFalse;
7863 break;
7864 }
7865 /*
7866 Adjust offset with gravity and virtual canvas.
7867 */
7868 SetGeometry(*images,&geometry);
7869 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7870 geometry.width=source->page.width != 0 ?
7871 source->page.width : source->columns;
7872 geometry.height=source->page.height != 0 ?
7873 source->page.height : source->rows;
7874 GravityAdjustGeometry((*images)->page.width != 0 ?
7875 (*images)->page.width : (*images)->columns,
7876 (*images)->page.height != 0 ? (*images)->page.height :
7877 (*images)->rows,(*images)->gravity,&geometry);
7878 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00007879 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00007880 if (option != (const char *) NULL)
cristy042ee782011-04-22 18:48:30 +00007881 compose=(CompositeOperator) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007882 MagickComposeOptions,MagickFalse,option);
7883 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7884 exception);
7885 source=DestroyImageList(source);
7886 break;
7887 }
7888 }
7889 if (layers == (Image *) NULL)
7890 break;
7891 InheritException(exception,&layers->exception);
7892 *images=DestroyImageList(*images);
7893 *images=layers;
7894 break;
7895 }
7896 break;
7897 }
7898 case 'm':
7899 {
7900 if (LocaleCompare("map",option+1) == 0)
7901 {
cristy6b3da3a2010-06-20 02:21:46 +00007902 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007903 if (*option == '+')
7904 {
cristy018f07f2011-09-04 21:15:19 +00007905 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7906 exception);
cristy3ed852e2009-09-05 21:47:34 +00007907 break;
7908 }
7909 i++;
7910 break;
7911 }
cristyf40785b2010-03-06 02:27:27 +00007912 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007913 {
7914 Image
cristyf40785b2010-03-06 02:27:27 +00007915 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007916
cristyd18ae7c2010-03-07 17:39:52 +00007917 /*
7918 Maximum image sequence (deprecated).
7919 */
cristy6b3da3a2010-06-20 02:21:46 +00007920 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007921 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007922 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007923 {
7924 status=MagickFalse;
7925 break;
7926 }
7927 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007928 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007929 break;
7930 }
cristyf40785b2010-03-06 02:27:27 +00007931 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007932 {
7933 Image
cristyf40785b2010-03-06 02:27:27 +00007934 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007935
cristyd18ae7c2010-03-07 17:39:52 +00007936 /*
7937 Minimum image sequence (deprecated).
7938 */
cristy6b3da3a2010-06-20 02:21:46 +00007939 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007940 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007941 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007942 {
7943 status=MagickFalse;
7944 break;
7945 }
7946 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007947 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007948 break;
7949 }
cristy3ed852e2009-09-05 21:47:34 +00007950 if (LocaleCompare("morph",option+1) == 0)
7951 {
7952 Image
7953 *morph_image;
7954
cristy6b3da3a2010-06-20 02:21:46 +00007955 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00007956 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00007957 exception);
7958 if (morph_image == (Image *) NULL)
7959 {
7960 status=MagickFalse;
7961 break;
7962 }
7963 *images=DestroyImageList(*images);
7964 *images=morph_image;
7965 break;
7966 }
7967 if (LocaleCompare("mosaic",option+1) == 0)
7968 {
7969 Image
7970 *mosaic_image;
7971
cristy6b3da3a2010-06-20 02:21:46 +00007972 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007973 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7974 if (mosaic_image == (Image *) NULL)
7975 {
7976 status=MagickFalse;
7977 break;
7978 }
7979 *images=DestroyImageList(*images);
7980 *images=mosaic_image;
7981 break;
7982 }
7983 break;
7984 }
7985 case 'p':
7986 {
7987 if (LocaleCompare("print",option+1) == 0)
7988 {
7989 char
7990 *string;
7991
cristy6b3da3a2010-06-20 02:21:46 +00007992 (void) SyncImagesSettings(mogrify_info,*images);
cristy018f07f2011-09-04 21:15:19 +00007993 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7994 exception);
cristy3ed852e2009-09-05 21:47:34 +00007995 if (string == (char *) NULL)
7996 break;
cristyb51dff52011-05-19 16:55:47 +00007997 (void) FormatLocaleFile(stdout,"%s",string);
cristy3ed852e2009-09-05 21:47:34 +00007998 string=DestroyString(string);
7999 }
8000 if (LocaleCompare("process",option+1) == 0)
8001 {
8002 char
8003 **arguments;
8004
8005 int
8006 j,
8007 number_arguments;
8008
cristy6b3da3a2010-06-20 02:21:46 +00008009 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008010 arguments=StringToArgv(argv[i+1],&number_arguments);
8011 if (arguments == (char **) NULL)
8012 break;
8013 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8014 {
8015 char
8016 breaker,
8017 quote,
8018 *token;
8019
8020 const char
8021 *arguments;
8022
8023 int
8024 next,
8025 status;
8026
8027 size_t
8028 length;
8029
8030 TokenInfo
8031 *token_info;
8032
8033 /*
8034 Support old style syntax, filter="-option arg".
8035 */
8036 length=strlen(argv[i+1]);
8037 token=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +00008038 if (~length >= (MaxTextExtent-1))
cristy3ed852e2009-09-05 21:47:34 +00008039 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8040 sizeof(*token));
8041 if (token == (char *) NULL)
8042 break;
8043 next=0;
8044 arguments=argv[i+1];
8045 token_info=AcquireTokenInfo();
8046 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8047 "\"",'\0',&breaker,&next,&quote);
8048 token_info=DestroyTokenInfo(token_info);
8049 if (status == 0)
8050 {
8051 const char
8052 *argv;
8053
8054 argv=(&(arguments[next]));
8055 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8056 exception);
8057 }
8058 token=DestroyString(token);
8059 break;
8060 }
cristy91c0da22010-05-02 01:44:07 +00008061 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008062 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8063 number_arguments-2,(const char **) arguments+2,exception);
8064 for (j=0; j < number_arguments; j++)
8065 arguments[j]=DestroyString(arguments[j]);
8066 arguments=(char **) RelinquishMagickMemory(arguments);
8067 break;
8068 }
8069 break;
8070 }
8071 case 'r':
8072 {
8073 if (LocaleCompare("reverse",option+1) == 0)
8074 {
8075 ReverseImageList(images);
8076 InheritException(exception,&(*images)->exception);
8077 break;
8078 }
8079 break;
8080 }
8081 case 's':
8082 {
cristy4285d782011-02-09 20:12:28 +00008083 if (LocaleCompare("smush",option+1) == 0)
8084 {
8085 Image
8086 *smush_image;
8087
8088 ssize_t
8089 offset;
8090
8091 (void) SyncImagesSettings(mogrify_info,*images);
8092 offset=(ssize_t) StringToLong(argv[i+1]);
8093 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8094 MagickFalse,offset,exception);
8095 if (smush_image == (Image *) NULL)
8096 {
8097 status=MagickFalse;
8098 break;
8099 }
8100 *images=DestroyImageList(*images);
8101 *images=smush_image;
8102 break;
8103 }
cristy3ed852e2009-09-05 21:47:34 +00008104 if (LocaleCompare("swap",option+1) == 0)
8105 {
8106 Image
8107 *p,
8108 *q,
8109 *swap;
8110
cristybb503372010-05-27 20:51:26 +00008111 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008112 swap_index;
8113
8114 index=(-1);
8115 swap_index=(-2);
8116 if (*option != '+')
8117 {
8118 GeometryInfo
8119 geometry_info;
8120
8121 MagickStatusType
8122 flags;
8123
8124 swap_index=(-1);
8125 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008126 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008127 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008128 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008129 }
8130 p=GetImageFromList(*images,index);
8131 q=GetImageFromList(*images,swap_index);
8132 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8133 {
8134 (void) ThrowMagickException(exception,GetMagickModule(),
8135 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8136 status=MagickFalse;
8137 break;
8138 }
8139 if (p == q)
8140 break;
8141 swap=CloneImage(p,0,0,MagickTrue,exception);
8142 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8143 ReplaceImageInList(&q,swap);
8144 *images=GetFirstImageInList(q);
8145 break;
8146 }
8147 break;
8148 }
8149 case 'w':
8150 {
8151 if (LocaleCompare("write",option+1) == 0)
8152 {
cristy071dd7b2010-04-09 13:04:54 +00008153 char
cristy06609ee2010-03-17 20:21:27 +00008154 key[MaxTextExtent];
8155
cristy3ed852e2009-09-05 21:47:34 +00008156 Image
8157 *write_images;
8158
8159 ImageInfo
8160 *write_info;
8161
cristy6b3da3a2010-06-20 02:21:46 +00008162 (void) SyncImagesSettings(mogrify_info,*images);
cristyb51dff52011-05-19 16:55:47 +00008163 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
cristy06609ee2010-03-17 20:21:27 +00008164 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008165 write_images=(*images);
8166 if (*option == '+')
8167 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008168 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008169 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8170 write_info=DestroyImageInfo(write_info);
8171 if (*option == '+')
8172 write_images=DestroyImageList(write_images);
8173 break;
8174 }
8175 break;
8176 }
8177 default:
8178 break;
8179 }
8180 i+=count;
8181 }
8182 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008183 mogrify_info=DestroyImageInfo(mogrify_info);
8184 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008185 return(status != 0 ? MagickTrue : MagickFalse);
8186}
8187
8188/*
8189%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8190% %
8191% %
8192% %
8193+ M o g r i f y I m a g e s %
8194% %
8195% %
8196% %
8197%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8198%
8199% MogrifyImages() applies image processing options to a sequence of images as
8200% prescribed by command line options.
8201%
8202% The format of the MogrifyImage method is:
8203%
8204% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8205% const MagickBooleanType post,const int argc,const char **argv,
8206% Image **images,Exceptioninfo *exception)
8207%
8208% A description of each parameter follows:
8209%
8210% o image_info: the image info..
8211%
8212% o post: If true, post process image list operators otherwise pre-process.
8213%
8214% o argc: Specifies a pointer to an integer describing the number of
8215% elements in the argument vector.
8216%
8217% o argv: Specifies a pointer to a text array containing the command line
8218% arguments.
8219%
anthonye9c27192011-03-27 08:07:06 +00008220% o images: pointer to a pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00008221%
8222% o exception: return any errors or warnings in this structure.
8223%
8224*/
8225WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8226 const MagickBooleanType post,const int argc,const char **argv,
8227 Image **images,ExceptionInfo *exception)
8228{
8229#define MogrifyImageTag "Mogrify/Image"
8230
anthonye9c27192011-03-27 08:07:06 +00008231 MagickStatusType
8232 status;
cristy3ed852e2009-09-05 21:47:34 +00008233
cristy0e9f9c12010-02-11 03:00:47 +00008234 MagickBooleanType
8235 proceed;
8236
anthonye9c27192011-03-27 08:07:06 +00008237 size_t
8238 n;
cristy3ed852e2009-09-05 21:47:34 +00008239
cristybb503372010-05-27 20:51:26 +00008240 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008241 i;
8242
cristy3ed852e2009-09-05 21:47:34 +00008243 assert(image_info != (ImageInfo *) NULL);
8244 assert(image_info->signature == MagickSignature);
8245 if (images == (Image **) NULL)
8246 return(MogrifyImage(image_info,argc,argv,images,exception));
anthonye9c27192011-03-27 08:07:06 +00008247 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008248 assert((*images)->signature == MagickSignature);
8249 if ((*images)->debug != MagickFalse)
8250 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8251 (*images)->filename);
8252 if ((argc <= 0) || (*argv == (char *) NULL))
8253 return(MagickTrue);
8254 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8255 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008256 status=0;
anthonye9c27192011-03-27 08:07:06 +00008257
anthonyce2716b2011-04-22 09:51:34 +00008258#if 0
cristy1e604812011-05-19 18:07:50 +00008259 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8260 post?"post":"pre");
anthonyce2716b2011-04-22 09:51:34 +00008261#endif
8262
anthonye9c27192011-03-27 08:07:06 +00008263 /*
8264 Pre-process multi-image sequence operators
8265 */
cristy3ed852e2009-09-05 21:47:34 +00008266 if (post == MagickFalse)
8267 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthonye9c27192011-03-27 08:07:06 +00008268 /*
8269 For each image, process simple single image operators
8270 */
8271 i=0;
8272 n=GetImageListLength(*images);
cristy9f027d12011-09-21 01:17:17 +00008273 for ( ; ; )
cristy3ed852e2009-09-05 21:47:34 +00008274 {
anthonyce2716b2011-04-22 09:51:34 +00008275#if 0
cristy1e604812011-05-19 18:07:50 +00008276 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8277 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008278#endif
anthonye9c27192011-03-27 08:07:06 +00008279 status&=MogrifyImage(image_info,argc,argv,images,exception);
8280 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
cristy0e9f9c12010-02-11 03:00:47 +00008281 if (proceed == MagickFalse)
8282 break;
anthonye9c27192011-03-27 08:07:06 +00008283 if ( (*images)->next == (Image *) NULL )
8284 break;
8285 *images=(*images)->next;
8286 i++;
cristy3ed852e2009-09-05 21:47:34 +00008287 }
anthonye9c27192011-03-27 08:07:06 +00008288 assert( *images != (Image *) NULL );
anthonyce2716b2011-04-22 09:51:34 +00008289#if 0
cristy1e604812011-05-19 18:07:50 +00008290 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8291 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008292#endif
anthonye9c27192011-03-27 08:07:06 +00008293
8294 /*
8295 Post-process, multi-image sequence operators
8296 */
8297 *images=GetFirstImageInList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008298 if (post != MagickFalse)
anthonye9c27192011-03-27 08:07:06 +00008299 status&=MogrifyImageList(image_info,argc,argv,images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008300 return(status != 0 ? MagickTrue : MagickFalse);
8301}