blob: e23d793c6de9e108199971b62373b26e31b2d0f7 [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"
54#include "MagickCore/thread-private.h"
55#include "MagickCore/string-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/*
301** 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.
303*/
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
cristy3884f692011-07-08 18:00:18 +0000388static Image *SparseColorOption(const Image *image,
anthonydf8ebac2011-04-27 09:03:19 +0000389 const SparseColorMethod method,const char *arguments,
390 const MagickBooleanType color_from_image,ExceptionInfo *exception)
391{
anthonydf8ebac2011-04-27 09:03:19 +0000392 char
393 token[MaxTextExtent];
394
395 const char
396 *p;
397
398 double
399 *sparse_arguments;
400
anthonydf8ebac2011-04-27 09:03:19 +0000401 Image
402 *sparse_image;
403
cristy4c08aed2011-07-01 19:47:50 +0000404 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000405 color;
406
407 MagickBooleanType
408 error;
409
cristy5f09d852011-05-29 01:39:29 +0000410 register size_t
411 x;
412
413 size_t
414 number_arguments,
415 number_colors;
416
cristy28474bf2011-09-11 23:32:52 +0000417 /*
418 SparseColorOption() parses the complex -sparse-color argument into an
419 an array of floating point values then calls SparseColorImage().
420 Argument is a complex mix of floating-point pixel coodinates, and color
421 specifications (or direct floating point numbers). The number of floats
422 needed to represent a color varies depending on the current channel
423 setting.
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 */
cristy9950d572011-10-01 18:22:35 +0000537 (void) QueryMagickColorCompliance(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
628 DrawInfo
629 *draw_info;
630
631 GeometryInfo
632 geometry_info;
633
cristy3ed852e2009-09-05 21:47:34 +0000634 Image
635 *region_image;
636
anthonydf8ebac2011-04-27 09:03:19 +0000637 ImageInfo
638 *mogrify_info;
639
cristyebbcfea2011-02-25 02:43:54 +0000640 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000641 status;
642
cristy4c08aed2011-07-01 19:47:50 +0000643 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000644 fill;
cristy3ed852e2009-09-05 21:47:34 +0000645
anthonydf8ebac2011-04-27 09:03:19 +0000646 MagickStatusType
647 flags;
648
cristy28474bf2011-09-11 23:32:52 +0000649 PixelInterpolateMethod
650 interpolate_method;
651
anthonydf8ebac2011-04-27 09:03:19 +0000652 QuantizeInfo
653 *quantize_info;
654
655 RectangleInfo
656 geometry,
657 region_geometry;
anthony56ad4222011-04-25 11:04:27 +0000658
cristybb503372010-05-27 20:51:26 +0000659 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000660 i;
661
662 /*
663 Initialize method variables.
664 */
665 assert(image_info != (const ImageInfo *) NULL);
666 assert(image_info->signature == MagickSignature);
667 assert(image != (Image **) NULL);
668 assert((*image)->signature == MagickSignature);
669 if ((*image)->debug != MagickFalse)
670 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
671 if (argc < 0)
672 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +0000673 mogrify_info=CloneImageInfo(image_info);
anthonydf8ebac2011-04-27 09:03:19 +0000674 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
675 quantize_info=AcquireQuantizeInfo(mogrify_info);
676 SetGeometryInfo(&geometry_info);
cristy4c08aed2011-07-01 19:47:50 +0000677 GetPixelInfo(*image,&fill);
678 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
cristy633f0c62011-09-15 13:27:36 +0000679 compose=(*image)->compose;
cristy28474bf2011-09-11 23:32:52 +0000680 interpolate_method=UndefinedInterpolatePixel;
anthonydf8ebac2011-04-27 09:03:19 +0000681 channel=mogrify_info->channel;
682 format=GetImageOption(mogrify_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000683 SetGeometry(*image,&region_geometry);
684 region_image=NewImageList();
685 /*
686 Transmogrify the image.
687 */
cristybb503372010-05-27 20:51:26 +0000688 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000689 {
anthonydf8ebac2011-04-27 09:03:19 +0000690 Image
691 *mogrify_image;
692
anthonye9c27192011-03-27 08:07:06 +0000693 ssize_t
694 count;
695
anthonydf8ebac2011-04-27 09:03:19 +0000696 option=argv[i];
697 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000698 continue;
anthonydf8ebac2011-04-27 09:03:19 +0000699 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
700 0L);
cristycee97112010-05-28 00:44:52 +0000701 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000702 break;
cristy6b3da3a2010-06-20 02:21:46 +0000703 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000704 mogrify_image=(Image *)NULL;
705 switch (*(option+1))
706 {
707 case 'a':
cristy3ed852e2009-09-05 21:47:34 +0000708 {
anthonydf8ebac2011-04-27 09:03:19 +0000709 if (LocaleCompare("adaptive-blur",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000710 {
anthonydf8ebac2011-04-27 09:03:19 +0000711 /*
712 Adaptive blur image.
713 */
714 (void) SyncImageSettings(mogrify_info,*image);
715 flags=ParseGeometry(argv[i+1],&geometry_info);
716 if ((flags & SigmaValue) == 0)
717 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000718 if ((flags & XiValue) == 0)
719 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000720 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000721 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000722 break;
cristy3ed852e2009-09-05 21:47:34 +0000723 }
anthonydf8ebac2011-04-27 09:03:19 +0000724 if (LocaleCompare("adaptive-resize",option+1) == 0)
725 {
726 /*
727 Adaptive resize image.
728 */
729 (void) SyncImageSettings(mogrify_info,*image);
730 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
731 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
cristy28474bf2011-09-11 23:32:52 +0000732 geometry.height,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000733 break;
734 }
735 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
736 {
737 /*
738 Adaptive sharpen image.
739 */
740 (void) SyncImageSettings(mogrify_info,*image);
741 flags=ParseGeometry(argv[i+1],&geometry_info);
742 if ((flags & SigmaValue) == 0)
743 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000744 if ((flags & XiValue) == 0)
745 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000746 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000747 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000748 break;
749 }
750 if (LocaleCompare("affine",option+1) == 0)
751 {
752 /*
753 Affine matrix.
754 */
755 if (*option == '+')
756 {
757 GetAffineMatrix(&draw_info->affine);
758 break;
759 }
760 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
761 break;
762 }
763 if (LocaleCompare("alpha",option+1) == 0)
764 {
765 AlphaChannelType
766 alpha_type;
cristy3ed852e2009-09-05 21:47:34 +0000767
anthonydf8ebac2011-04-27 09:03:19 +0000768 (void) SyncImageSettings(mogrify_info,*image);
769 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
770 MagickFalse,argv[i+1]);
cristy63240882011-08-05 19:05:27 +0000771 (void) SetImageAlphaChannel(*image,alpha_type,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000772 break;
773 }
774 if (LocaleCompare("annotate",option+1) == 0)
775 {
776 char
777 *text,
778 geometry[MaxTextExtent];
779
780 /*
781 Annotate image.
782 */
783 (void) SyncImageSettings(mogrify_info,*image);
784 SetGeometryInfo(&geometry_info);
785 flags=ParseGeometry(argv[i+1],&geometry_info);
786 if ((flags & SigmaValue) == 0)
787 geometry_info.sigma=geometry_info.rho;
cristy018f07f2011-09-04 21:15:19 +0000788 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
789 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000790 if (text == (char *) NULL)
791 break;
792 (void) CloneString(&draw_info->text,text);
793 text=DestroyString(text);
cristyb51dff52011-05-19 16:55:47 +0000794 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
anthonydf8ebac2011-04-27 09:03:19 +0000795 geometry_info.xi,geometry_info.psi);
796 (void) CloneString(&draw_info->geometry,geometry);
797 draw_info->affine.sx=cos(DegreesToRadians(
798 fmod(geometry_info.rho,360.0)));
799 draw_info->affine.rx=sin(DegreesToRadians(
800 fmod(geometry_info.rho,360.0)));
801 draw_info->affine.ry=(-sin(DegreesToRadians(
802 fmod(geometry_info.sigma,360.0))));
803 draw_info->affine.sy=cos(DegreesToRadians(
804 fmod(geometry_info.sigma,360.0)));
cristy5cbc0162011-08-29 00:36:28 +0000805 (void) AnnotateImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000806 break;
807 }
808 if (LocaleCompare("antialias",option+1) == 0)
809 {
810 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
811 MagickFalse;
812 draw_info->text_antialias=(*option == '-') ? MagickTrue :
813 MagickFalse;
814 break;
815 }
816 if (LocaleCompare("auto-gamma",option+1) == 0)
817 {
818 /*
819 Auto Adjust Gamma of image based on its mean
820 */
821 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000822 (void) AutoGammaImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000823 break;
824 }
825 if (LocaleCompare("auto-level",option+1) == 0)
826 {
827 /*
828 Perfectly Normalize (max/min stretch) the image
829 */
830 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000831 (void) AutoLevelImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000832 break;
833 }
834 if (LocaleCompare("auto-orient",option+1) == 0)
835 {
836 (void) SyncImageSettings(mogrify_info,*image);
837 switch ((*image)->orientation)
838 {
839 case TopRightOrientation:
840 {
841 mogrify_image=FlopImage(*image,exception);
842 break;
843 }
844 case BottomRightOrientation:
845 {
846 mogrify_image=RotateImage(*image,180.0,exception);
847 break;
848 }
849 case BottomLeftOrientation:
850 {
851 mogrify_image=FlipImage(*image,exception);
852 break;
853 }
854 case LeftTopOrientation:
855 {
856 mogrify_image=TransposeImage(*image,exception);
857 break;
858 }
859 case RightTopOrientation:
860 {
861 mogrify_image=RotateImage(*image,90.0,exception);
862 break;
863 }
864 case RightBottomOrientation:
865 {
866 mogrify_image=TransverseImage(*image,exception);
867 break;
868 }
869 case LeftBottomOrientation:
870 {
871 mogrify_image=RotateImage(*image,270.0,exception);
872 break;
873 }
874 default:
875 break;
876 }
877 if (mogrify_image != (Image *) NULL)
878 mogrify_image->orientation=TopLeftOrientation;
879 break;
880 }
881 break;
882 }
883 case 'b':
884 {
885 if (LocaleCompare("black-threshold",option+1) == 0)
886 {
887 /*
888 Black threshold image.
889 */
890 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +0000891 (void) BlackThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +0000892 InheritException(exception,&(*image)->exception);
893 break;
894 }
895 if (LocaleCompare("blue-shift",option+1) == 0)
896 {
897 /*
898 Blue shift image.
899 */
900 (void) SyncImageSettings(mogrify_info,*image);
901 geometry_info.rho=1.5;
902 if (*option == '-')
903 flags=ParseGeometry(argv[i+1],&geometry_info);
904 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
905 break;
906 }
907 if (LocaleCompare("blur",option+1) == 0)
908 {
909 /*
910 Gaussian blur image.
911 */
912 (void) SyncImageSettings(mogrify_info,*image);
913 flags=ParseGeometry(argv[i+1],&geometry_info);
914 if ((flags & SigmaValue) == 0)
915 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000916 if ((flags & XiValue) == 0)
917 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000918 mogrify_image=BlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +0000919 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000920 break;
921 }
922 if (LocaleCompare("border",option+1) == 0)
923 {
924 /*
925 Surround image with a border of solid color.
926 */
927 (void) SyncImageSettings(mogrify_info,*image);
928 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
929 if ((flags & SigmaValue) == 0)
930 geometry.height=geometry.width;
cristy633f0c62011-09-15 13:27:36 +0000931 mogrify_image=BorderImage(*image,&geometry,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000932 break;
933 }
934 if (LocaleCompare("bordercolor",option+1) == 0)
935 {
936 if (*option == '+')
937 {
cristy9950d572011-10-01 18:22:35 +0000938 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy05c0c9a2011-09-05 23:16:13 +0000939 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000940 break;
941 }
cristy9950d572011-10-01 18:22:35 +0000942 (void) QueryColorCompliance(argv[i+1],AllCompliance,
943 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000944 break;
945 }
946 if (LocaleCompare("box",option+1) == 0)
947 {
cristy9950d572011-10-01 18:22:35 +0000948 (void) QueryColorCompliance(argv[i+1],AllCompliance,
949 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000950 break;
951 }
952 if (LocaleCompare("brightness-contrast",option+1) == 0)
953 {
954 double
955 brightness,
956 contrast;
957
958 GeometryInfo
959 geometry_info;
960
961 MagickStatusType
962 flags;
963
964 /*
965 Brightness / contrast image.
966 */
967 (void) SyncImageSettings(mogrify_info,*image);
968 flags=ParseGeometry(argv[i+1],&geometry_info);
969 brightness=geometry_info.rho;
970 contrast=0.0;
971 if ((flags & SigmaValue) != 0)
972 contrast=geometry_info.sigma;
cristy444eda62011-08-10 02:07:46 +0000973 (void) BrightnessContrastImage(*image,brightness,contrast,
974 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000975 InheritException(exception,&(*image)->exception);
976 break;
977 }
978 break;
979 }
980 case 'c':
981 {
982 if (LocaleCompare("cdl",option+1) == 0)
983 {
984 char
985 *color_correction_collection;
986
987 /*
988 Color correct with a color decision list.
989 */
990 (void) SyncImageSettings(mogrify_info,*image);
991 color_correction_collection=FileToString(argv[i+1],~0,exception);
992 if (color_correction_collection == (char *) NULL)
993 break;
cristy1bfa9f02011-08-11 02:35:43 +0000994 (void) ColorDecisionListImage(*image,color_correction_collection,
995 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000996 InheritException(exception,&(*image)->exception);
997 break;
998 }
999 if (LocaleCompare("channel",option+1) == 0)
1000 {
1001 if (*option == '+')
cristyfa806a72011-07-04 02:06:13 +00001002 channel=DefaultChannels;
anthonydf8ebac2011-04-27 09:03:19 +00001003 else
cristyfa806a72011-07-04 02:06:13 +00001004 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00001005 SetPixelChannelMap(*image,channel);
anthonydf8ebac2011-04-27 09:03:19 +00001006 break;
1007 }
1008 if (LocaleCompare("charcoal",option+1) == 0)
1009 {
1010 /*
1011 Charcoal image.
1012 */
1013 (void) SyncImageSettings(mogrify_info,*image);
1014 flags=ParseGeometry(argv[i+1],&geometry_info);
1015 if ((flags & SigmaValue) == 0)
1016 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001017 if ((flags & XiValue) == 0)
1018 geometry_info.xi=1.0;
anthonydf8ebac2011-04-27 09:03:19 +00001019 mogrify_image=CharcoalImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001020 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001021 break;
1022 }
1023 if (LocaleCompare("chop",option+1) == 0)
1024 {
1025 /*
1026 Chop the image.
1027 */
1028 (void) SyncImageSettings(mogrify_info,*image);
1029 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1030 mogrify_image=ChopImage(*image,&geometry,exception);
1031 break;
1032 }
1033 if (LocaleCompare("clamp",option+1) == 0)
1034 {
1035 /*
1036 Clamp image.
1037 */
1038 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00001039 (void) ClampImage(*image);
anthonydf8ebac2011-04-27 09:03:19 +00001040 InheritException(exception,&(*image)->exception);
1041 break;
1042 }
1043 if (LocaleCompare("clip",option+1) == 0)
1044 {
1045 (void) SyncImageSettings(mogrify_info,*image);
1046 if (*option == '+')
1047 {
cristy018f07f2011-09-04 21:15:19 +00001048 (void) SetImageClipMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001049 break;
1050 }
cristy018f07f2011-09-04 21:15:19 +00001051 (void) ClipImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001052 break;
1053 }
1054 if (LocaleCompare("clip-mask",option+1) == 0)
1055 {
1056 CacheView
1057 *mask_view;
1058
1059 Image
1060 *mask_image;
1061
cristy4c08aed2011-07-01 19:47:50 +00001062 register Quantum
anthonydf8ebac2011-04-27 09:03:19 +00001063 *restrict q;
1064
1065 register ssize_t
1066 x;
1067
1068 ssize_t
1069 y;
1070
1071 (void) SyncImageSettings(mogrify_info,*image);
1072 if (*option == '+')
1073 {
1074 /*
1075 Remove a mask.
1076 */
cristy018f07f2011-09-04 21:15:19 +00001077 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001078 break;
1079 }
1080 /*
1081 Set the image mask.
1082 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1083 */
1084 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1085 if (mask_image == (Image *) NULL)
1086 break;
cristy574cc262011-08-05 01:23:58 +00001087 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
anthonydf8ebac2011-04-27 09:03:19 +00001088 return(MagickFalse);
1089 mask_view=AcquireCacheView(mask_image);
1090 for (y=0; y < (ssize_t) mask_image->rows; y++)
1091 {
1092 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1093 exception);
cristyacd2ed22011-08-30 01:44:23 +00001094 if (q == (Quantum *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001095 break;
1096 for (x=0; x < (ssize_t) mask_image->columns; x++)
1097 {
1098 if (mask_image->matte == MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +00001099 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1100 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1101 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1102 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
cristyed231572011-07-14 02:18:59 +00001103 q+=GetPixelChannels(mask_image);
anthonydf8ebac2011-04-27 09:03:19 +00001104 }
1105 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1106 break;
1107 }
1108 mask_view=DestroyCacheView(mask_view);
1109 mask_image->matte=MagickTrue;
cristy018f07f2011-09-04 21:15:19 +00001110 (void) SetImageClipMask(*image,mask_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001111 InheritException(exception,&(*image)->exception);
1112 break;
1113 }
1114 if (LocaleCompare("clip-path",option+1) == 0)
1115 {
1116 (void) SyncImageSettings(mogrify_info,*image);
1117 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
cristy018f07f2011-09-04 21:15:19 +00001118 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001119 break;
1120 }
1121 if (LocaleCompare("colorize",option+1) == 0)
1122 {
1123 /*
1124 Colorize the image.
1125 */
1126 (void) SyncImageSettings(mogrify_info,*image);
1127 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1128 exception);
1129 break;
1130 }
1131 if (LocaleCompare("color-matrix",option+1) == 0)
1132 {
1133 KernelInfo
1134 *kernel;
1135
1136 (void) SyncImageSettings(mogrify_info,*image);
1137 kernel=AcquireKernelInfo(argv[i+1]);
1138 if (kernel == (KernelInfo *) NULL)
1139 break;
1140 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1141 kernel=DestroyKernelInfo(kernel);
1142 break;
1143 }
1144 if (LocaleCompare("colors",option+1) == 0)
1145 {
1146 /*
1147 Reduce the number of colors in the image.
1148 */
1149 (void) SyncImageSettings(mogrify_info,*image);
1150 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1151 if (quantize_info->number_colors == 0)
1152 break;
1153 if (((*image)->storage_class == DirectClass) ||
1154 (*image)->colors > quantize_info->number_colors)
cristy018f07f2011-09-04 21:15:19 +00001155 (void) QuantizeImage(quantize_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001156 else
cristy018f07f2011-09-04 21:15:19 +00001157 (void) CompressImageColormap(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001158 break;
1159 }
1160 if (LocaleCompare("colorspace",option+1) == 0)
1161 {
1162 ColorspaceType
1163 colorspace;
1164
1165 (void) SyncImageSettings(mogrify_info,*image);
1166 if (*option == '+')
1167 {
1168 (void) TransformImageColorspace(*image,RGBColorspace);
1169 InheritException(exception,&(*image)->exception);
1170 break;
1171 }
1172 colorspace=(ColorspaceType) ParseCommandOption(
1173 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1174 (void) TransformImageColorspace(*image,colorspace);
1175 InheritException(exception,&(*image)->exception);
1176 break;
1177 }
cristy633f0c62011-09-15 13:27:36 +00001178 if (LocaleCompare("compose",option+1) == 0)
1179 {
1180 (void) SyncImageSettings(mogrify_info,*image);
1181 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1182 MagickFalse,argv[i+1]);
1183 break;
1184 }
anthonydf8ebac2011-04-27 09:03:19 +00001185 if (LocaleCompare("contrast",option+1) == 0)
1186 {
1187 (void) SyncImageSettings(mogrify_info,*image);
1188 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
cristye23ec9d2011-08-16 18:15:40 +00001189 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001190 break;
1191 }
1192 if (LocaleCompare("contrast-stretch",option+1) == 0)
1193 {
1194 double
1195 black_point,
1196 white_point;
1197
1198 MagickStatusType
1199 flags;
1200
1201 /*
1202 Contrast stretch image.
1203 */
1204 (void) SyncImageSettings(mogrify_info,*image);
1205 flags=ParseGeometry(argv[i+1],&geometry_info);
1206 black_point=geometry_info.rho;
1207 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1208 black_point;
1209 if ((flags & PercentValue) != 0)
1210 {
1211 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1212 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1213 }
1214 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1215 white_point;
cristye23ec9d2011-08-16 18:15:40 +00001216 (void) ContrastStretchImage(*image,black_point,white_point,
1217 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001218 InheritException(exception,&(*image)->exception);
1219 break;
1220 }
1221 if (LocaleCompare("convolve",option+1) == 0)
1222 {
anthonydf8ebac2011-04-27 09:03:19 +00001223 KernelInfo
cristy41cbe682011-07-15 19:12:37 +00001224 *kernel_info;
anthonydf8ebac2011-04-27 09:03:19 +00001225
anthonydf8ebac2011-04-27 09:03:19 +00001226 (void) SyncImageSettings(mogrify_info,*image);
cristy41cbe682011-07-15 19:12:37 +00001227 kernel_info=AcquireKernelInfo(argv[i+1]);
1228 if (kernel_info == (KernelInfo *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001229 break;
cristy0a922382011-07-16 15:30:34 +00001230 kernel_info->bias=(*image)->bias;
cristy5e6be1e2011-07-16 01:23:39 +00001231 mogrify_image=ConvolveImage(*image,kernel_info,exception);
cristy41cbe682011-07-15 19:12:37 +00001232 kernel_info=DestroyKernelInfo(kernel_info);
anthonydf8ebac2011-04-27 09:03:19 +00001233 break;
1234 }
1235 if (LocaleCompare("crop",option+1) == 0)
1236 {
1237 /*
1238 Crop a image to a smaller size
1239 */
1240 (void) SyncImageSettings(mogrify_info,*image);
anthonydf8ebac2011-04-27 09:03:19 +00001241 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00001242 break;
1243 }
1244 if (LocaleCompare("cycle",option+1) == 0)
1245 {
1246 /*
1247 Cycle an image colormap.
1248 */
1249 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00001250 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1251 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001252 break;
1253 }
1254 break;
1255 }
1256 case 'd':
1257 {
1258 if (LocaleCompare("decipher",option+1) == 0)
1259 {
1260 StringInfo
1261 *passkey;
1262
1263 /*
1264 Decipher pixels.
1265 */
1266 (void) SyncImageSettings(mogrify_info,*image);
1267 passkey=FileToStringInfo(argv[i+1],~0,exception);
1268 if (passkey != (StringInfo *) NULL)
1269 {
1270 (void) PasskeyDecipherImage(*image,passkey,exception);
1271 passkey=DestroyStringInfo(passkey);
1272 }
1273 break;
1274 }
1275 if (LocaleCompare("density",option+1) == 0)
1276 {
1277 /*
1278 Set image density.
1279 */
1280 (void) CloneString(&draw_info->density,argv[i+1]);
1281 break;
1282 }
1283 if (LocaleCompare("depth",option+1) == 0)
1284 {
1285 (void) SyncImageSettings(mogrify_info,*image);
1286 if (*option == '+')
1287 {
1288 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1289 break;
1290 }
1291 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1292 break;
1293 }
1294 if (LocaleCompare("deskew",option+1) == 0)
1295 {
1296 double
1297 threshold;
1298
1299 /*
1300 Straighten the image.
1301 */
1302 (void) SyncImageSettings(mogrify_info,*image);
1303 if (*option == '+')
1304 threshold=40.0*QuantumRange/100.0;
1305 else
1306 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1307 mogrify_image=DeskewImage(*image,threshold,exception);
1308 break;
1309 }
1310 if (LocaleCompare("despeckle",option+1) == 0)
1311 {
1312 /*
1313 Reduce the speckles within an image.
1314 */
1315 (void) SyncImageSettings(mogrify_info,*image);
1316 mogrify_image=DespeckleImage(*image,exception);
1317 break;
1318 }
1319 if (LocaleCompare("display",option+1) == 0)
1320 {
1321 (void) CloneString(&draw_info->server_name,argv[i+1]);
1322 break;
1323 }
1324 if (LocaleCompare("distort",option+1) == 0)
1325 {
1326 char
1327 *args,
1328 token[MaxTextExtent];
1329
1330 const char
1331 *p;
1332
1333 DistortImageMethod
1334 method;
1335
1336 double
1337 *arguments;
1338
1339 register ssize_t
1340 x;
1341
1342 size_t
1343 number_arguments;
1344
1345 /*
1346 Distort image.
1347 */
1348 (void) SyncImageSettings(mogrify_info,*image);
1349 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1350 MagickFalse,argv[i+1]);
1351 if ( method == ResizeDistortion )
1352 {
1353 /* Special Case - Argument is actually a resize geometry!
1354 ** Convert that to an appropriate distortion argument array.
1355 */
1356 double
1357 resize_args[2];
1358 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1359 exception);
1360 resize_args[0]=(double)geometry.width;
1361 resize_args[1]=(double)geometry.height;
1362 mogrify_image=DistortImage(*image,method,(size_t)2,
1363 resize_args,MagickTrue,exception);
1364 break;
1365 }
cristy018f07f2011-09-04 21:15:19 +00001366 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1367 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001368 if (args == (char *) NULL)
1369 break;
1370 p=(char *) args;
1371 for (x=0; *p != '\0'; x++)
1372 {
1373 GetMagickToken(p,&p,token);
1374 if (*token == ',')
1375 GetMagickToken(p,&p,token);
1376 }
1377 number_arguments=(size_t) x;
1378 arguments=(double *) AcquireQuantumMemory(number_arguments,
1379 sizeof(*arguments));
1380 if (arguments == (double *) NULL)
1381 ThrowWandFatalException(ResourceLimitFatalError,
1382 "MemoryAllocationFailed",(*image)->filename);
1383 (void) ResetMagickMemory(arguments,0,number_arguments*
1384 sizeof(*arguments));
1385 p=(char *) args;
1386 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1387 {
1388 GetMagickToken(p,&p,token);
1389 if (*token == ',')
1390 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001391 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001392 }
1393 args=DestroyString(args);
1394 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1395 (*option == '+') ? MagickTrue : MagickFalse,exception);
1396 arguments=(double *) RelinquishMagickMemory(arguments);
1397 break;
1398 }
1399 if (LocaleCompare("dither",option+1) == 0)
1400 {
1401 if (*option == '+')
1402 {
1403 quantize_info->dither=MagickFalse;
1404 break;
1405 }
1406 quantize_info->dither=MagickTrue;
1407 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1408 MagickDitherOptions,MagickFalse,argv[i+1]);
1409 if (quantize_info->dither_method == NoDitherMethod)
1410 quantize_info->dither=MagickFalse;
1411 break;
1412 }
1413 if (LocaleCompare("draw",option+1) == 0)
1414 {
1415 /*
1416 Draw image.
1417 */
1418 (void) SyncImageSettings(mogrify_info,*image);
1419 (void) CloneString(&draw_info->primitive,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001420 (void) DrawImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001421 break;
1422 }
1423 break;
1424 }
1425 case 'e':
1426 {
1427 if (LocaleCompare("edge",option+1) == 0)
1428 {
1429 /*
1430 Enhance edges in the image.
1431 */
1432 (void) SyncImageSettings(mogrify_info,*image);
1433 flags=ParseGeometry(argv[i+1],&geometry_info);
1434 if ((flags & SigmaValue) == 0)
1435 geometry_info.sigma=1.0;
cristy8ae632d2011-09-05 17:29:53 +00001436 mogrify_image=EdgeImage(*image,geometry_info.rho,
1437 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001438 break;
1439 }
1440 if (LocaleCompare("emboss",option+1) == 0)
1441 {
1442 /*
1443 Gaussian embossen image.
1444 */
1445 (void) SyncImageSettings(mogrify_info,*image);
1446 flags=ParseGeometry(argv[i+1],&geometry_info);
1447 if ((flags & SigmaValue) == 0)
1448 geometry_info.sigma=1.0;
1449 mogrify_image=EmbossImage(*image,geometry_info.rho,
1450 geometry_info.sigma,exception);
1451 break;
1452 }
1453 if (LocaleCompare("encipher",option+1) == 0)
1454 {
1455 StringInfo
1456 *passkey;
1457
1458 /*
1459 Encipher pixels.
1460 */
1461 (void) SyncImageSettings(mogrify_info,*image);
1462 passkey=FileToStringInfo(argv[i+1],~0,exception);
1463 if (passkey != (StringInfo *) NULL)
1464 {
1465 (void) PasskeyEncipherImage(*image,passkey,exception);
1466 passkey=DestroyStringInfo(passkey);
1467 }
1468 break;
1469 }
1470 if (LocaleCompare("encoding",option+1) == 0)
1471 {
1472 (void) CloneString(&draw_info->encoding,argv[i+1]);
1473 break;
1474 }
1475 if (LocaleCompare("enhance",option+1) == 0)
1476 {
1477 /*
1478 Enhance image.
1479 */
1480 (void) SyncImageSettings(mogrify_info,*image);
1481 mogrify_image=EnhanceImage(*image,exception);
1482 break;
1483 }
1484 if (LocaleCompare("equalize",option+1) == 0)
1485 {
1486 /*
1487 Equalize image.
1488 */
1489 (void) SyncImageSettings(mogrify_info,*image);
cristy6d8c3d72011-08-22 01:20:01 +00001490 (void) EqualizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001491 break;
1492 }
1493 if (LocaleCompare("evaluate",option+1) == 0)
1494 {
1495 double
1496 constant;
1497
1498 MagickEvaluateOperator
1499 op;
1500
1501 (void) SyncImageSettings(mogrify_info,*image);
cristyd42d9952011-07-08 14:21:50 +00001502 op=(MagickEvaluateOperator) ParseCommandOption(
1503 MagickEvaluateOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00001504 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
cristyd42d9952011-07-08 14:21:50 +00001505 (void) EvaluateImage(*image,op,constant,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001506 break;
1507 }
1508 if (LocaleCompare("extent",option+1) == 0)
1509 {
1510 /*
1511 Set the image extent.
1512 */
1513 (void) SyncImageSettings(mogrify_info,*image);
1514 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1515 if (geometry.width == 0)
1516 geometry.width=(*image)->columns;
1517 if (geometry.height == 0)
1518 geometry.height=(*image)->rows;
1519 mogrify_image=ExtentImage(*image,&geometry,exception);
1520 break;
1521 }
1522 break;
1523 }
1524 case 'f':
1525 {
1526 if (LocaleCompare("family",option+1) == 0)
1527 {
1528 if (*option == '+')
1529 {
1530 if (draw_info->family != (char *) NULL)
1531 draw_info->family=DestroyString(draw_info->family);
1532 break;
1533 }
1534 (void) CloneString(&draw_info->family,argv[i+1]);
1535 break;
1536 }
1537 if (LocaleCompare("features",option+1) == 0)
1538 {
1539 if (*option == '+')
1540 {
1541 (void) DeleteImageArtifact(*image,"identify:features");
1542 break;
1543 }
1544 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1545 break;
1546 }
1547 if (LocaleCompare("fill",option+1) == 0)
1548 {
1549 ExceptionInfo
1550 *sans;
1551
cristy4c08aed2011-07-01 19:47:50 +00001552 GetPixelInfo(*image,&fill);
anthonydf8ebac2011-04-27 09:03:19 +00001553 if (*option == '+')
1554 {
cristy9950d572011-10-01 18:22:35 +00001555 (void) QueryMagickColorCompliance("none",AllCompliance,&fill,
1556 exception);
1557 (void) QueryColorCompliance("none",AllCompliance,
1558 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001559 if (draw_info->fill_pattern != (Image *) NULL)
1560 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1561 break;
1562 }
1563 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00001564 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&fill,
1565 sans);
1566 status=QueryColorCompliance(argv[i+1],AllCompliance,
1567 &draw_info->fill,sans);
anthonydf8ebac2011-04-27 09:03:19 +00001568 sans=DestroyExceptionInfo(sans);
1569 if (status == MagickFalse)
1570 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1571 exception);
1572 break;
1573 }
1574 if (LocaleCompare("flip",option+1) == 0)
1575 {
1576 /*
1577 Flip image scanlines.
1578 */
1579 (void) SyncImageSettings(mogrify_info,*image);
1580 mogrify_image=FlipImage(*image,exception);
1581 break;
1582 }
anthonydf8ebac2011-04-27 09:03:19 +00001583 if (LocaleCompare("floodfill",option+1) == 0)
1584 {
cristy4c08aed2011-07-01 19:47:50 +00001585 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001586 target;
1587
1588 /*
1589 Floodfill image.
1590 */
1591 (void) SyncImageSettings(mogrify_info,*image);
1592 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
cristy9950d572011-10-01 18:22:35 +00001593 (void) QueryMagickColorCompliance(argv[i+2],AllCompliance,&target,
1594 exception);
cristyd42d9952011-07-08 14:21:50 +00001595 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
cristy189e84c2011-08-27 18:08:53 +00001596 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001597 break;
1598 }
anthony3d2f4862011-05-01 13:48:16 +00001599 if (LocaleCompare("flop",option+1) == 0)
1600 {
1601 /*
1602 Flop image scanlines.
1603 */
1604 (void) SyncImageSettings(mogrify_info,*image);
1605 mogrify_image=FlopImage(*image,exception);
1606 break;
1607 }
anthonydf8ebac2011-04-27 09:03:19 +00001608 if (LocaleCompare("font",option+1) == 0)
1609 {
1610 if (*option == '+')
1611 {
1612 if (draw_info->font != (char *) NULL)
1613 draw_info->font=DestroyString(draw_info->font);
1614 break;
1615 }
1616 (void) CloneString(&draw_info->font,argv[i+1]);
1617 break;
1618 }
1619 if (LocaleCompare("format",option+1) == 0)
1620 {
1621 format=argv[i+1];
1622 break;
1623 }
1624 if (LocaleCompare("frame",option+1) == 0)
1625 {
1626 FrameInfo
1627 frame_info;
1628
1629 /*
1630 Surround image with an ornamental border.
1631 */
1632 (void) SyncImageSettings(mogrify_info,*image);
1633 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1634 frame_info.width=geometry.width;
1635 frame_info.height=geometry.height;
1636 if ((flags & HeightValue) == 0)
1637 frame_info.height=geometry.width;
1638 frame_info.outer_bevel=geometry.x;
1639 frame_info.inner_bevel=geometry.y;
1640 frame_info.x=(ssize_t) frame_info.width;
1641 frame_info.y=(ssize_t) frame_info.height;
1642 frame_info.width=(*image)->columns+2*frame_info.width;
1643 frame_info.height=(*image)->rows+2*frame_info.height;
cristy633f0c62011-09-15 13:27:36 +00001644 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001645 break;
1646 }
1647 if (LocaleCompare("function",option+1) == 0)
1648 {
1649 char
1650 *arguments,
1651 token[MaxTextExtent];
1652
1653 const char
1654 *p;
1655
1656 double
1657 *parameters;
1658
1659 MagickFunction
1660 function;
1661
1662 register ssize_t
1663 x;
1664
1665 size_t
1666 number_parameters;
1667
1668 /*
1669 Function Modify Image Values
1670 */
1671 (void) SyncImageSettings(mogrify_info,*image);
1672 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1673 MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001674 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1675 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001676 if (arguments == (char *) NULL)
1677 break;
1678 p=(char *) arguments;
1679 for (x=0; *p != '\0'; x++)
1680 {
1681 GetMagickToken(p,&p,token);
1682 if (*token == ',')
1683 GetMagickToken(p,&p,token);
1684 }
1685 number_parameters=(size_t) x;
1686 parameters=(double *) AcquireQuantumMemory(number_parameters,
1687 sizeof(*parameters));
1688 if (parameters == (double *) NULL)
1689 ThrowWandFatalException(ResourceLimitFatalError,
1690 "MemoryAllocationFailed",(*image)->filename);
1691 (void) ResetMagickMemory(parameters,0,number_parameters*
1692 sizeof(*parameters));
1693 p=(char *) arguments;
1694 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1695 {
1696 GetMagickToken(p,&p,token);
1697 if (*token == ',')
1698 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001699 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001700 }
1701 arguments=DestroyString(arguments);
cristyd42d9952011-07-08 14:21:50 +00001702 (void) FunctionImage(*image,function,number_parameters,parameters,
1703 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001704 parameters=(double *) RelinquishMagickMemory(parameters);
1705 break;
1706 }
1707 break;
1708 }
1709 case 'g':
1710 {
1711 if (LocaleCompare("gamma",option+1) == 0)
1712 {
1713 /*
1714 Gamma image.
1715 */
1716 (void) SyncImageSettings(mogrify_info,*image);
1717 if (*option == '+')
cristyc1acd842011-05-19 23:05:47 +00001718 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001719 else
cristyb3e7c6c2011-07-24 01:43:55 +00001720 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1721 (char **) NULL),exception);
anthonydf8ebac2011-04-27 09:03:19 +00001722 break;
1723 }
1724 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1725 (LocaleCompare("gaussian",option+1) == 0))
1726 {
1727 /*
1728 Gaussian blur image.
1729 */
1730 (void) SyncImageSettings(mogrify_info,*image);
1731 flags=ParseGeometry(argv[i+1],&geometry_info);
1732 if ((flags & SigmaValue) == 0)
1733 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001734 if ((flags & XiValue) == 0)
1735 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00001736 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001737 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001738 break;
1739 }
1740 if (LocaleCompare("geometry",option+1) == 0)
1741 {
1742 /*
1743 Record Image offset, Resize last image.
1744 */
1745 (void) SyncImageSettings(mogrify_info,*image);
1746 if (*option == '+')
1747 {
1748 if ((*image)->geometry != (char *) NULL)
1749 (*image)->geometry=DestroyString((*image)->geometry);
1750 break;
1751 }
1752 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1753 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1754 (void) CloneString(&(*image)->geometry,argv[i+1]);
1755 else
1756 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1757 (*image)->filter,(*image)->blur,exception);
1758 break;
1759 }
1760 if (LocaleCompare("gravity",option+1) == 0)
1761 {
1762 if (*option == '+')
1763 {
1764 draw_info->gravity=UndefinedGravity;
1765 break;
1766 }
1767 draw_info->gravity=(GravityType) ParseCommandOption(
1768 MagickGravityOptions,MagickFalse,argv[i+1]);
1769 break;
1770 }
1771 break;
1772 }
1773 case 'h':
1774 {
1775 if (LocaleCompare("highlight-color",option+1) == 0)
1776 {
1777 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1778 break;
1779 }
1780 break;
1781 }
1782 case 'i':
1783 {
1784 if (LocaleCompare("identify",option+1) == 0)
1785 {
1786 char
1787 *text;
1788
1789 (void) SyncImageSettings(mogrify_info,*image);
1790 if (format == (char *) NULL)
1791 {
cristya4037272011-08-28 15:11:39 +00001792 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1793 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001794 break;
1795 }
cristy018f07f2011-09-04 21:15:19 +00001796 text=InterpretImageProperties(mogrify_info,*image,format,
1797 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001798 if (text == (char *) NULL)
1799 break;
1800 (void) fputs(text,stdout);
1801 (void) fputc('\n',stdout);
1802 text=DestroyString(text);
1803 break;
1804 }
1805 if (LocaleCompare("implode",option+1) == 0)
1806 {
1807 /*
1808 Implode image.
1809 */
1810 (void) SyncImageSettings(mogrify_info,*image);
1811 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00001812 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1813 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001814 break;
1815 }
1816 if (LocaleCompare("interline-spacing",option+1) == 0)
1817 {
1818 if (*option == '+')
1819 (void) ParseGeometry("0",&geometry_info);
1820 else
1821 (void) ParseGeometry(argv[i+1],&geometry_info);
1822 draw_info->interline_spacing=geometry_info.rho;
1823 break;
1824 }
cristy28474bf2011-09-11 23:32:52 +00001825 if (LocaleCompare("interpolate",option+1) == 0)
1826 {
1827 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1828 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1829 break;
1830 }
anthonydf8ebac2011-04-27 09:03:19 +00001831 if (LocaleCompare("interword-spacing",option+1) == 0)
1832 {
1833 if (*option == '+')
1834 (void) ParseGeometry("0",&geometry_info);
1835 else
1836 (void) ParseGeometry(argv[i+1],&geometry_info);
1837 draw_info->interword_spacing=geometry_info.rho;
1838 break;
1839 }
1840 break;
1841 }
1842 case 'k':
1843 {
1844 if (LocaleCompare("kerning",option+1) == 0)
1845 {
1846 if (*option == '+')
1847 (void) ParseGeometry("0",&geometry_info);
1848 else
1849 (void) ParseGeometry(argv[i+1],&geometry_info);
1850 draw_info->kerning=geometry_info.rho;
1851 break;
1852 }
1853 break;
1854 }
1855 case 'l':
1856 {
1857 if (LocaleCompare("lat",option+1) == 0)
1858 {
1859 /*
1860 Local adaptive threshold image.
1861 */
1862 (void) SyncImageSettings(mogrify_info,*image);
1863 flags=ParseGeometry(argv[i+1],&geometry_info);
1864 if ((flags & PercentValue) != 0)
1865 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1866 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
cristyde5cc632011-07-18 14:47:00 +00001867 geometry_info.rho,(size_t) geometry_info.sigma,(double)
anthonydf8ebac2011-04-27 09:03:19 +00001868 geometry_info.xi,exception);
1869 break;
1870 }
1871 if (LocaleCompare("level",option+1) == 0)
1872 {
1873 MagickRealType
1874 black_point,
1875 gamma,
1876 white_point;
1877
1878 MagickStatusType
1879 flags;
1880
1881 /*
1882 Parse levels.
1883 */
1884 (void) SyncImageSettings(mogrify_info,*image);
1885 flags=ParseGeometry(argv[i+1],&geometry_info);
1886 black_point=geometry_info.rho;
1887 white_point=(MagickRealType) QuantumRange;
1888 if ((flags & SigmaValue) != 0)
1889 white_point=geometry_info.sigma;
1890 gamma=1.0;
1891 if ((flags & XiValue) != 0)
1892 gamma=geometry_info.xi;
1893 if ((flags & PercentValue) != 0)
1894 {
1895 black_point*=(MagickRealType) (QuantumRange/100.0);
1896 white_point*=(MagickRealType) (QuantumRange/100.0);
1897 }
1898 if ((flags & SigmaValue) == 0)
1899 white_point=(MagickRealType) QuantumRange-black_point;
1900 if ((*option == '+') || ((flags & AspectValue) != 0))
cristy7c0a0a42011-08-23 17:57:25 +00001901 (void) LevelizeImage(*image,black_point,white_point,gamma,
1902 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001903 else
cristy01e9afd2011-08-10 17:38:41 +00001904 (void) LevelImage(*image,black_point,white_point,gamma,
1905 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001906 InheritException(exception,&(*image)->exception);
1907 break;
1908 }
1909 if (LocaleCompare("level-colors",option+1) == 0)
1910 {
1911 char
1912 token[MaxTextExtent];
1913
1914 const char
1915 *p;
1916
cristy4c08aed2011-07-01 19:47:50 +00001917 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001918 black_point,
1919 white_point;
1920
1921 p=(const char *) argv[i+1];
1922 GetMagickToken(p,&p,token); /* get black point color */
1923 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy9950d572011-10-01 18:22:35 +00001924 (void) QueryMagickColorCompliance(token,AllCompliance,
1925 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001926 else
cristy9950d572011-10-01 18:22:35 +00001927 (void) QueryMagickColorCompliance("#000000",AllCompliance,
1928 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001929 if (isalpha((int) token[0]) || (token[0] == '#'))
1930 GetMagickToken(p,&p,token);
1931 if (*token == '\0')
1932 white_point=black_point; /* set everything to that color */
1933 else
1934 {
1935 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1936 GetMagickToken(p,&p,token); /* Get white point color. */
1937 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy9950d572011-10-01 18:22:35 +00001938 (void) QueryMagickColorCompliance(token,AllCompliance,
1939 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001940 else
cristy9950d572011-10-01 18:22:35 +00001941 (void) QueryMagickColorCompliance("#ffffff",AllCompliance,
1942 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001943 }
cristy490408a2011-07-07 14:42:05 +00001944 (void) LevelImageColors(*image,&black_point,&white_point,
cristy7c0a0a42011-08-23 17:57:25 +00001945 *option == '+' ? MagickTrue : MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001946 break;
1947 }
1948 if (LocaleCompare("linear-stretch",option+1) == 0)
1949 {
1950 double
1951 black_point,
1952 white_point;
1953
1954 MagickStatusType
1955 flags;
1956
1957 (void) SyncImageSettings(mogrify_info,*image);
1958 flags=ParseGeometry(argv[i+1],&geometry_info);
1959 black_point=geometry_info.rho;
1960 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1961 if ((flags & SigmaValue) != 0)
1962 white_point=geometry_info.sigma;
1963 if ((flags & PercentValue) != 0)
1964 {
1965 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1966 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1967 }
1968 if ((flags & SigmaValue) == 0)
1969 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1970 black_point;
cristy33bd5152011-08-24 01:42:24 +00001971 (void) LinearStretchImage(*image,black_point,white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001972 InheritException(exception,&(*image)->exception);
1973 break;
1974 }
1975 if (LocaleCompare("linewidth",option+1) == 0)
1976 {
cristyc1acd842011-05-19 23:05:47 +00001977 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1978 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001979 break;
1980 }
1981 if (LocaleCompare("liquid-rescale",option+1) == 0)
1982 {
1983 /*
1984 Liquid rescale image.
1985 */
1986 (void) SyncImageSettings(mogrify_info,*image);
1987 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1988 if ((flags & XValue) == 0)
1989 geometry.x=1;
1990 if ((flags & YValue) == 0)
1991 geometry.y=0;
1992 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1993 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1994 break;
1995 }
1996 if (LocaleCompare("lowlight-color",option+1) == 0)
1997 {
1998 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1999 break;
2000 }
2001 break;
2002 }
2003 case 'm':
2004 {
2005 if (LocaleCompare("map",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00002006 {
cristy3ed852e2009-09-05 21:47:34 +00002007 Image
anthonydf8ebac2011-04-27 09:03:19 +00002008 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002009
anthonydf8ebac2011-04-27 09:03:19 +00002010 /*
2011 Transform image colors to match this set of colors.
2012 */
2013 (void) SyncImageSettings(mogrify_info,*image);
2014 if (*option == '+')
2015 break;
2016 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2017 if (remap_image == (Image *) NULL)
2018 break;
cristy018f07f2011-09-04 21:15:19 +00002019 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002020 remap_image=DestroyImage(remap_image);
2021 break;
2022 }
2023 if (LocaleCompare("mask",option+1) == 0)
2024 {
2025 Image
2026 *mask;
2027
2028 (void) SyncImageSettings(mogrify_info,*image);
2029 if (*option == '+')
2030 {
2031 /*
2032 Remove a mask.
2033 */
cristy018f07f2011-09-04 21:15:19 +00002034 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002035 break;
2036 }
2037 /*
2038 Set the image mask.
2039 */
2040 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2041 if (mask == (Image *) NULL)
2042 break;
cristy018f07f2011-09-04 21:15:19 +00002043 (void) SetImageMask(*image,mask,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002044 mask=DestroyImage(mask);
anthonydf8ebac2011-04-27 09:03:19 +00002045 break;
2046 }
2047 if (LocaleCompare("matte",option+1) == 0)
2048 {
2049 (void) SetImageAlphaChannel(*image,(*option == '-') ?
cristy63240882011-08-05 19:05:27 +00002050 SetAlphaChannel : DeactivateAlphaChannel,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002051 break;
2052 }
2053 if (LocaleCompare("median",option+1) == 0)
2054 {
2055 /*
2056 Median filter image.
2057 */
2058 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002059 flags=ParseGeometry(argv[i+1],&geometry_info);
2060 if ((flags & SigmaValue) == 0)
2061 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002062 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002063 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002064 break;
2065 }
2066 if (LocaleCompare("mode",option+1) == 0)
2067 {
2068 /*
2069 Mode image.
2070 */
2071 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002072 flags=ParseGeometry(argv[i+1],&geometry_info);
2073 if ((flags & SigmaValue) == 0)
2074 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002075 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002076 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002077 break;
2078 }
2079 if (LocaleCompare("modulate",option+1) == 0)
2080 {
2081 (void) SyncImageSettings(mogrify_info,*image);
cristy33bd5152011-08-24 01:42:24 +00002082 (void) ModulateImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002083 break;
2084 }
2085 if (LocaleCompare("monitor",option+1) == 0)
2086 {
2087 if (*option == '+')
2088 {
2089 (void) SetImageProgressMonitor(*image,
2090 (MagickProgressMonitor) NULL,(void *) NULL);
2091 break;
2092 }
2093 (void) SetImageProgressMonitor(*image,MonitorProgress,
2094 (void *) NULL);
2095 break;
2096 }
2097 if (LocaleCompare("monochrome",option+1) == 0)
2098 {
2099 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00002100 (void) SetImageType(*image,BilevelType,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002101 break;
2102 }
2103 if (LocaleCompare("morphology",option+1) == 0)
2104 {
2105 char
2106 token[MaxTextExtent];
2107
2108 const char
2109 *p;
2110
2111 KernelInfo
2112 *kernel;
2113
2114 MorphologyMethod
2115 method;
2116
2117 ssize_t
2118 iterations;
2119
2120 /*
2121 Morphological Image Operation
2122 */
2123 (void) SyncImageSettings(mogrify_info,*image);
2124 p=argv[i+1];
2125 GetMagickToken(p,&p,token);
cristy28474bf2011-09-11 23:32:52 +00002126 method=(MorphologyMethod) ParseCommandOption(
2127 MagickMorphologyOptions,MagickFalse,token);
anthonydf8ebac2011-04-27 09:03:19 +00002128 iterations=1L;
2129 GetMagickToken(p,&p,token);
2130 if ((*p == ':') || (*p == ','))
2131 GetMagickToken(p,&p,token);
2132 if ((*p != '\0'))
2133 iterations=(ssize_t) StringToLong(p);
2134 kernel=AcquireKernelInfo(argv[i+2]);
2135 if (kernel == (KernelInfo *) NULL)
2136 {
2137 (void) ThrowMagickException(exception,GetMagickModule(),
2138 OptionError,"UnabletoParseKernel","morphology");
2139 status=MagickFalse;
2140 break;
2141 }
cristyf4ad9df2011-07-08 16:49:03 +00002142 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2143 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002144 kernel=DestroyKernelInfo(kernel);
2145 break;
2146 }
2147 if (LocaleCompare("motion-blur",option+1) == 0)
2148 {
2149 /*
2150 Motion blur image.
2151 */
2152 (void) SyncImageSettings(mogrify_info,*image);
2153 flags=ParseGeometry(argv[i+1],&geometry_info);
2154 if ((flags & SigmaValue) == 0)
2155 geometry_info.sigma=1.0;
cristyf4ad9df2011-07-08 16:49:03 +00002156 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002157 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2158 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002159 break;
2160 }
2161 break;
2162 }
2163 case 'n':
2164 {
2165 if (LocaleCompare("negate",option+1) == 0)
2166 {
2167 (void) SyncImageSettings(mogrify_info,*image);
cristy50fbc382011-07-07 02:19:17 +00002168 (void) NegateImage(*image,*option == '+' ? MagickTrue :
cristyb3e7c6c2011-07-24 01:43:55 +00002169 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002170 break;
2171 }
2172 if (LocaleCompare("noise",option+1) == 0)
2173 {
2174 (void) SyncImageSettings(mogrify_info,*image);
2175 if (*option == '-')
2176 {
cristyf36cbcb2011-09-07 13:28:22 +00002177 flags=ParseGeometry(argv[i+1],&geometry_info);
2178 if ((flags & SigmaValue) == 0)
2179 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002180 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002181 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002182 }
2183 else
2184 {
2185 NoiseType
2186 noise;
2187
2188 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2189 MagickFalse,argv[i+1]);
cristy490408a2011-07-07 14:42:05 +00002190 mogrify_image=AddNoiseImage(*image,noise,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002191 }
2192 break;
2193 }
2194 if (LocaleCompare("normalize",option+1) == 0)
2195 {
2196 (void) SyncImageSettings(mogrify_info,*image);
cristye23ec9d2011-08-16 18:15:40 +00002197 (void) NormalizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002198 break;
2199 }
2200 break;
2201 }
2202 case 'o':
2203 {
2204 if (LocaleCompare("opaque",option+1) == 0)
2205 {
cristy4c08aed2011-07-01 19:47:50 +00002206 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002207 target;
2208
2209 (void) SyncImageSettings(mogrify_info,*image);
cristy9950d572011-10-01 18:22:35 +00002210 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2211 exception);
cristyd42d9952011-07-08 14:21:50 +00002212 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
cristy189e84c2011-08-27 18:08:53 +00002213 MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002214 break;
2215 }
2216 if (LocaleCompare("ordered-dither",option+1) == 0)
2217 {
2218 (void) SyncImageSettings(mogrify_info,*image);
cristy13020672011-07-08 02:33:26 +00002219 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002220 break;
2221 }
2222 break;
2223 }
2224 case 'p':
2225 {
2226 if (LocaleCompare("paint",option+1) == 0)
2227 {
anthonydf8ebac2011-04-27 09:03:19 +00002228 (void) SyncImageSettings(mogrify_info,*image);
2229 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy14973ba2011-08-27 23:48:07 +00002230 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2231 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002232 break;
2233 }
2234 if (LocaleCompare("pen",option+1) == 0)
2235 {
2236 if (*option == '+')
2237 {
cristy9950d572011-10-01 18:22:35 +00002238 (void) QueryColorCompliance("none",AllCompliance,
2239 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002240 break;
2241 }
cristy9950d572011-10-01 18:22:35 +00002242 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2243 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002244 break;
2245 }
2246 if (LocaleCompare("pointsize",option+1) == 0)
2247 {
2248 if (*option == '+')
2249 (void) ParseGeometry("12",&geometry_info);
2250 else
2251 (void) ParseGeometry(argv[i+1],&geometry_info);
2252 draw_info->pointsize=geometry_info.rho;
2253 break;
2254 }
2255 if (LocaleCompare("polaroid",option+1) == 0)
2256 {
2257 double
2258 angle;
2259
2260 RandomInfo
2261 *random_info;
2262
2263 /*
2264 Simulate a Polaroid picture.
2265 */
2266 (void) SyncImageSettings(mogrify_info,*image);
2267 random_info=AcquireRandomInfo();
2268 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2269 random_info=DestroyRandomInfo(random_info);
2270 if (*option == '-')
2271 {
2272 SetGeometryInfo(&geometry_info);
2273 flags=ParseGeometry(argv[i+1],&geometry_info);
2274 angle=geometry_info.rho;
2275 }
cristy5c4e2582011-09-11 19:21:03 +00002276 mogrify_image=PolaroidImage(*image,draw_info,angle,
cristy28474bf2011-09-11 23:32:52 +00002277 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002278 break;
2279 }
2280 if (LocaleCompare("posterize",option+1) == 0)
2281 {
2282 /*
2283 Posterize image.
2284 */
2285 (void) SyncImageSettings(mogrify_info,*image);
2286 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy018f07f2011-09-04 21:15:19 +00002287 quantize_info->dither,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002288 break;
2289 }
2290 if (LocaleCompare("preview",option+1) == 0)
2291 {
2292 PreviewType
2293 preview_type;
2294
2295 /*
2296 Preview image.
2297 */
2298 (void) SyncImageSettings(mogrify_info,*image);
2299 if (*option == '+')
2300 preview_type=UndefinedPreview;
2301 else
cristy28474bf2011-09-11 23:32:52 +00002302 preview_type=(PreviewType) ParseCommandOption(
2303 MagickPreviewOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002304 mogrify_image=PreviewImage(*image,preview_type,exception);
2305 break;
2306 }
2307 if (LocaleCompare("profile",option+1) == 0)
2308 {
2309 const char
2310 *name;
2311
2312 const StringInfo
2313 *profile;
2314
2315 Image
2316 *profile_image;
2317
2318 ImageInfo
2319 *profile_info;
2320
2321 (void) SyncImageSettings(mogrify_info,*image);
2322 if (*option == '+')
2323 {
2324 /*
2325 Remove a profile from the image.
2326 */
2327 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2328 NULL,0,MagickTrue);
2329 InheritException(exception,&(*image)->exception);
2330 break;
2331 }
2332 /*
2333 Associate a profile with the image.
2334 */
2335 profile_info=CloneImageInfo(mogrify_info);
2336 profile=GetImageProfile(*image,"iptc");
2337 if (profile != (StringInfo *) NULL)
2338 profile_info->profile=(void *) CloneStringInfo(profile);
2339 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2340 profile_info=DestroyImageInfo(profile_info);
2341 if (profile_image == (Image *) NULL)
2342 {
2343 StringInfo
2344 *profile;
2345
2346 profile_info=CloneImageInfo(mogrify_info);
2347 (void) CopyMagickString(profile_info->filename,argv[i+1],
2348 MaxTextExtent);
2349 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2350 if (profile != (StringInfo *) NULL)
2351 {
2352 (void) ProfileImage(*image,profile_info->magick,
2353 GetStringInfoDatum(profile),(size_t)
2354 GetStringInfoLength(profile),MagickFalse);
2355 profile=DestroyStringInfo(profile);
2356 }
2357 profile_info=DestroyImageInfo(profile_info);
2358 break;
2359 }
2360 ResetImageProfileIterator(profile_image);
2361 name=GetNextImageProfile(profile_image);
2362 while (name != (const char *) NULL)
2363 {
2364 profile=GetImageProfile(profile_image,name);
2365 if (profile != (StringInfo *) NULL)
2366 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2367 (size_t) GetStringInfoLength(profile),MagickFalse);
2368 name=GetNextImageProfile(profile_image);
2369 }
2370 profile_image=DestroyImage(profile_image);
2371 break;
2372 }
2373 break;
2374 }
2375 case 'q':
2376 {
2377 if (LocaleCompare("quantize",option+1) == 0)
2378 {
2379 if (*option == '+')
2380 {
2381 quantize_info->colorspace=UndefinedColorspace;
2382 break;
2383 }
2384 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2385 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2386 break;
2387 }
2388 break;
2389 }
2390 case 'r':
2391 {
2392 if (LocaleCompare("radial-blur",option+1) == 0)
2393 {
2394 /*
2395 Radial blur image.
2396 */
2397 (void) SyncImageSettings(mogrify_info,*image);
cristy6435bd92011-09-10 02:10:07 +00002398 flags=ParseGeometry(argv[i+1],&geometry_info);
2399 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2400 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002401 break;
2402 }
2403 if (LocaleCompare("raise",option+1) == 0)
2404 {
2405 /*
2406 Surround image with a raise of solid color.
2407 */
2408 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2409 if ((flags & SigmaValue) == 0)
2410 geometry.height=geometry.width;
2411 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
cristy6170ac32011-08-28 14:15:37 +00002412 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002413 break;
2414 }
2415 if (LocaleCompare("random-threshold",option+1) == 0)
2416 {
2417 /*
2418 Threshold image.
2419 */
2420 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00002421 (void) RandomThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002422 break;
2423 }
2424 if (LocaleCompare("recolor",option+1) == 0)
2425 {
2426 KernelInfo
2427 *kernel;
2428
2429 (void) SyncImageSettings(mogrify_info,*image);
2430 kernel=AcquireKernelInfo(argv[i+1]);
2431 if (kernel == (KernelInfo *) NULL)
2432 break;
2433 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2434 kernel=DestroyKernelInfo(kernel);
2435 break;
2436 }
2437 if (LocaleCompare("region",option+1) == 0)
2438 {
2439 (void) SyncImageSettings(mogrify_info,*image);
2440 if (region_image != (Image *) NULL)
2441 {
2442 /*
2443 Composite region.
2444 */
2445 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00002446 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2447 region_geometry.x,region_geometry.y);
anthonydf8ebac2011-04-27 09:03:19 +00002448 InheritException(exception,&region_image->exception);
2449 *image=DestroyImage(*image);
2450 *image=region_image;
2451 region_image = (Image *) NULL;
2452 }
2453 if (*option == '+')
2454 break;
2455 /*
2456 Apply transformations to a selected region of the image.
2457 */
cristy3ed852e2009-09-05 21:47:34 +00002458 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2459 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002460 mogrify_image=CropImage(*image,&region_geometry,exception);
2461 if (mogrify_image == (Image *) NULL)
2462 break;
2463 region_image=(*image);
2464 *image=mogrify_image;
2465 mogrify_image=(Image *) NULL;
2466 break;
cristy3ed852e2009-09-05 21:47:34 +00002467 }
anthonydf8ebac2011-04-27 09:03:19 +00002468 if (LocaleCompare("render",option+1) == 0)
2469 {
2470 (void) SyncImageSettings(mogrify_info,*image);
2471 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2472 break;
2473 }
2474 if (LocaleCompare("remap",option+1) == 0)
2475 {
2476 Image
2477 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002478
anthonydf8ebac2011-04-27 09:03:19 +00002479 /*
2480 Transform image colors to match this set of colors.
2481 */
2482 (void) SyncImageSettings(mogrify_info,*image);
2483 if (*option == '+')
2484 break;
2485 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2486 if (remap_image == (Image *) NULL)
2487 break;
cristy018f07f2011-09-04 21:15:19 +00002488 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002489 remap_image=DestroyImage(remap_image);
2490 break;
2491 }
2492 if (LocaleCompare("repage",option+1) == 0)
2493 {
2494 if (*option == '+')
2495 {
2496 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2497 break;
2498 }
2499 (void) ResetImagePage(*image,argv[i+1]);
2500 InheritException(exception,&(*image)->exception);
2501 break;
2502 }
2503 if (LocaleCompare("resample",option+1) == 0)
2504 {
2505 /*
2506 Resample image.
2507 */
2508 (void) SyncImageSettings(mogrify_info,*image);
2509 flags=ParseGeometry(argv[i+1],&geometry_info);
2510 if ((flags & SigmaValue) == 0)
2511 geometry_info.sigma=geometry_info.rho;
2512 mogrify_image=ResampleImage(*image,geometry_info.rho,
2513 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2514 break;
2515 }
2516 if (LocaleCompare("resize",option+1) == 0)
2517 {
2518 /*
2519 Resize image.
2520 */
2521 (void) SyncImageSettings(mogrify_info,*image);
2522 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2523 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2524 (*image)->filter,(*image)->blur,exception);
2525 break;
2526 }
2527 if (LocaleCompare("roll",option+1) == 0)
2528 {
2529 /*
2530 Roll image.
2531 */
2532 (void) SyncImageSettings(mogrify_info,*image);
2533 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2534 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2535 break;
2536 }
2537 if (LocaleCompare("rotate",option+1) == 0)
2538 {
2539 char
2540 *geometry;
2541
2542 /*
2543 Check for conditional image rotation.
2544 */
2545 (void) SyncImageSettings(mogrify_info,*image);
2546 if (strchr(argv[i+1],'>') != (char *) NULL)
2547 if ((*image)->columns <= (*image)->rows)
2548 break;
2549 if (strchr(argv[i+1],'<') != (char *) NULL)
2550 if ((*image)->columns >= (*image)->rows)
2551 break;
2552 /*
2553 Rotate image.
2554 */
2555 geometry=ConstantString(argv[i+1]);
2556 (void) SubstituteString(&geometry,">","");
2557 (void) SubstituteString(&geometry,"<","");
2558 (void) ParseGeometry(geometry,&geometry_info);
2559 geometry=DestroyString(geometry);
2560 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2561 break;
2562 }
2563 break;
2564 }
2565 case 's':
2566 {
2567 if (LocaleCompare("sample",option+1) == 0)
2568 {
2569 /*
2570 Sample image with pixel replication.
2571 */
2572 (void) SyncImageSettings(mogrify_info,*image);
2573 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2574 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2575 exception);
2576 break;
2577 }
2578 if (LocaleCompare("scale",option+1) == 0)
2579 {
2580 /*
2581 Resize image.
2582 */
2583 (void) SyncImageSettings(mogrify_info,*image);
2584 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2585 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2586 exception);
2587 break;
2588 }
2589 if (LocaleCompare("selective-blur",option+1) == 0)
2590 {
2591 /*
2592 Selectively blur pixels within a contrast threshold.
2593 */
2594 (void) SyncImageSettings(mogrify_info,*image);
2595 flags=ParseGeometry(argv[i+1],&geometry_info);
2596 if ((flags & PercentValue) != 0)
2597 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristyf4ad9df2011-07-08 16:49:03 +00002598 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
cristy1e7aa312011-09-10 20:01:36 +00002599 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002600 break;
2601 }
2602 if (LocaleCompare("separate",option+1) == 0)
2603 {
2604 /*
2605 Break channels into separate images.
anthonydf8ebac2011-04-27 09:03:19 +00002606 */
2607 (void) SyncImageSettings(mogrify_info,*image);
cristy3139dc22011-07-08 00:11:42 +00002608 mogrify_image=SeparateImages(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002609 break;
2610 }
2611 if (LocaleCompare("sepia-tone",option+1) == 0)
2612 {
2613 double
2614 threshold;
2615
2616 /*
2617 Sepia-tone image.
2618 */
2619 (void) SyncImageSettings(mogrify_info,*image);
2620 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2621 mogrify_image=SepiaToneImage(*image,threshold,exception);
2622 break;
2623 }
2624 if (LocaleCompare("segment",option+1) == 0)
2625 {
2626 /*
2627 Segment image.
2628 */
2629 (void) SyncImageSettings(mogrify_info,*image);
2630 flags=ParseGeometry(argv[i+1],&geometry_info);
2631 if ((flags & SigmaValue) == 0)
2632 geometry_info.sigma=1.0;
2633 (void) SegmentImage(*image,(*image)->colorspace,
cristy018f07f2011-09-04 21:15:19 +00002634 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2635 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002636 break;
2637 }
2638 if (LocaleCompare("set",option+1) == 0)
2639 {
2640 char
2641 *value;
2642
2643 /*
2644 Set image option.
2645 */
2646 if (*option == '+')
2647 {
2648 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2649 (void) DeleteImageRegistry(argv[i+1]+9);
2650 else
2651 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2652 {
2653 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2654 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2655 }
2656 else
2657 (void) DeleteImageProperty(*image,argv[i+1]);
2658 break;
2659 }
cristy018f07f2011-09-04 21:15:19 +00002660 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2661 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002662 if (value == (char *) NULL)
2663 break;
2664 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2665 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2666 exception);
2667 else
2668 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2669 {
2670 (void) SetImageOption(image_info,argv[i+1]+7,value);
2671 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2672 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2673 }
2674 else
2675 (void) SetImageProperty(*image,argv[i+1],value);
2676 value=DestroyString(value);
2677 break;
2678 }
2679 if (LocaleCompare("shade",option+1) == 0)
2680 {
2681 /*
2682 Shade image.
2683 */
2684 (void) SyncImageSettings(mogrify_info,*image);
2685 flags=ParseGeometry(argv[i+1],&geometry_info);
2686 if ((flags & SigmaValue) == 0)
2687 geometry_info.sigma=1.0;
2688 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2689 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2690 break;
2691 }
2692 if (LocaleCompare("shadow",option+1) == 0)
2693 {
2694 /*
2695 Shadow image.
2696 */
2697 (void) SyncImageSettings(mogrify_info,*image);
2698 flags=ParseGeometry(argv[i+1],&geometry_info);
2699 if ((flags & SigmaValue) == 0)
2700 geometry_info.sigma=1.0;
2701 if ((flags & XiValue) == 0)
2702 geometry_info.xi=4.0;
2703 if ((flags & PsiValue) == 0)
2704 geometry_info.psi=4.0;
2705 mogrify_image=ShadowImage(*image,geometry_info.rho,
2706 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2707 ceil(geometry_info.psi-0.5),exception);
2708 break;
2709 }
2710 if (LocaleCompare("sharpen",option+1) == 0)
2711 {
2712 /*
2713 Sharpen image.
2714 */
2715 (void) SyncImageSettings(mogrify_info,*image);
2716 flags=ParseGeometry(argv[i+1],&geometry_info);
2717 if ((flags & SigmaValue) == 0)
2718 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00002719 if ((flags & XiValue) == 0)
2720 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00002721 mogrify_image=SharpenImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00002722 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002723 break;
2724 }
2725 if (LocaleCompare("shave",option+1) == 0)
2726 {
2727 /*
2728 Shave the image edges.
2729 */
2730 (void) SyncImageSettings(mogrify_info,*image);
2731 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2732 mogrify_image=ShaveImage(*image,&geometry,exception);
2733 break;
2734 }
2735 if (LocaleCompare("shear",option+1) == 0)
2736 {
2737 /*
2738 Shear image.
2739 */
2740 (void) SyncImageSettings(mogrify_info,*image);
2741 flags=ParseGeometry(argv[i+1],&geometry_info);
2742 if ((flags & SigmaValue) == 0)
2743 geometry_info.sigma=geometry_info.rho;
2744 mogrify_image=ShearImage(*image,geometry_info.rho,
2745 geometry_info.sigma,exception);
2746 break;
2747 }
2748 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2749 {
2750 /*
2751 Sigmoidal non-linearity contrast control.
2752 */
2753 (void) SyncImageSettings(mogrify_info,*image);
2754 flags=ParseGeometry(argv[i+1],&geometry_info);
2755 if ((flags & SigmaValue) == 0)
2756 geometry_info.sigma=(double) QuantumRange/2.0;
2757 if ((flags & PercentValue) != 0)
2758 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2759 100.0;
cristy9ee60942011-07-06 14:54:38 +00002760 (void) SigmoidalContrastImage(*image,(*option == '-') ?
cristy33bd5152011-08-24 01:42:24 +00002761 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2762 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002763 break;
2764 }
2765 if (LocaleCompare("sketch",option+1) == 0)
2766 {
2767 /*
2768 Sketch image.
2769 */
2770 (void) SyncImageSettings(mogrify_info,*image);
2771 flags=ParseGeometry(argv[i+1],&geometry_info);
2772 if ((flags & SigmaValue) == 0)
2773 geometry_info.sigma=1.0;
2774 mogrify_image=SketchImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002775 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002776 break;
2777 }
2778 if (LocaleCompare("solarize",option+1) == 0)
2779 {
2780 double
2781 threshold;
2782
2783 (void) SyncImageSettings(mogrify_info,*image);
2784 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy5cbc0162011-08-29 00:36:28 +00002785 (void) SolarizeImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002786 break;
2787 }
2788 if (LocaleCompare("sparse-color",option+1) == 0)
2789 {
2790 SparseColorMethod
2791 method;
2792
2793 char
2794 *arguments;
2795
2796 /*
2797 Sparse Color Interpolated Gradient
2798 */
2799 (void) SyncImageSettings(mogrify_info,*image);
2800 method=(SparseColorMethod) ParseCommandOption(
2801 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00002802 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2803 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002804 if (arguments == (char *) NULL)
2805 break;
cristy3884f692011-07-08 18:00:18 +00002806 mogrify_image=SparseColorOption(*image,method,arguments,
anthonydf8ebac2011-04-27 09:03:19 +00002807 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2808 arguments=DestroyString(arguments);
2809 break;
2810 }
2811 if (LocaleCompare("splice",option+1) == 0)
2812 {
2813 /*
2814 Splice a solid color into the image.
2815 */
2816 (void) SyncImageSettings(mogrify_info,*image);
2817 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2818 mogrify_image=SpliceImage(*image,&geometry,exception);
2819 break;
2820 }
2821 if (LocaleCompare("spread",option+1) == 0)
2822 {
2823 /*
2824 Spread an image.
2825 */
2826 (void) SyncImageSettings(mogrify_info,*image);
2827 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy5c4e2582011-09-11 19:21:03 +00002828 mogrify_image=SpreadImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00002829 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002830 break;
2831 }
2832 if (LocaleCompare("statistic",option+1) == 0)
2833 {
2834 StatisticType
2835 type;
2836
2837 (void) SyncImageSettings(mogrify_info,*image);
2838 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2839 MagickFalse,argv[i+1]);
2840 (void) ParseGeometry(argv[i+2],&geometry_info);
cristyf4ad9df2011-07-08 16:49:03 +00002841 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2842 (size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002843 break;
2844 }
2845 if (LocaleCompare("stretch",option+1) == 0)
2846 {
2847 if (*option == '+')
2848 {
2849 draw_info->stretch=UndefinedStretch;
2850 break;
2851 }
2852 draw_info->stretch=(StretchType) ParseCommandOption(
2853 MagickStretchOptions,MagickFalse,argv[i+1]);
2854 break;
2855 }
2856 if (LocaleCompare("strip",option+1) == 0)
2857 {
2858 /*
2859 Strip image of profiles and comments.
2860 */
2861 (void) SyncImageSettings(mogrify_info,*image);
2862 (void) StripImage(*image);
2863 InheritException(exception,&(*image)->exception);
2864 break;
2865 }
2866 if (LocaleCompare("stroke",option+1) == 0)
2867 {
2868 ExceptionInfo
2869 *sans;
2870
2871 if (*option == '+')
2872 {
cristy9950d572011-10-01 18:22:35 +00002873 (void) QueryColorCompliance("none",AllCompliance,
2874 &draw_info->stroke,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002875 if (draw_info->stroke_pattern != (Image *) NULL)
2876 draw_info->stroke_pattern=DestroyImage(
2877 draw_info->stroke_pattern);
2878 break;
2879 }
2880 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00002881 status=QueryColorCompliance(argv[i+1],AllCompliance,
2882 &draw_info->stroke,sans);
anthonydf8ebac2011-04-27 09:03:19 +00002883 sans=DestroyExceptionInfo(sans);
2884 if (status == MagickFalse)
2885 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2886 exception);
2887 break;
2888 }
2889 if (LocaleCompare("strokewidth",option+1) == 0)
2890 {
cristyc1acd842011-05-19 23:05:47 +00002891 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2892 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002893 break;
2894 }
2895 if (LocaleCompare("style",option+1) == 0)
2896 {
2897 if (*option == '+')
2898 {
2899 draw_info->style=UndefinedStyle;
2900 break;
2901 }
2902 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2903 MagickFalse,argv[i+1]);
2904 break;
2905 }
2906 if (LocaleCompare("swirl",option+1) == 0)
2907 {
2908 /*
2909 Swirl image.
2910 */
2911 (void) SyncImageSettings(mogrify_info,*image);
2912 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00002913 mogrify_image=SwirlImage(*image,geometry_info.rho,
2914 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002915 break;
2916 }
2917 break;
2918 }
2919 case 't':
2920 {
2921 if (LocaleCompare("threshold",option+1) == 0)
2922 {
2923 double
2924 threshold;
2925
2926 /*
2927 Threshold image.
2928 */
2929 (void) SyncImageSettings(mogrify_info,*image);
2930 if (*option == '+')
anthony247a86d2011-05-03 13:18:18 +00002931 threshold=(double) QuantumRange/2;
anthonydf8ebac2011-04-27 09:03:19 +00002932 else
2933 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristyf4ad9df2011-07-08 16:49:03 +00002934 (void) BilevelImage(*image,threshold);
anthonydf8ebac2011-04-27 09:03:19 +00002935 InheritException(exception,&(*image)->exception);
2936 break;
2937 }
2938 if (LocaleCompare("thumbnail",option+1) == 0)
2939 {
2940 /*
2941 Thumbnail image.
2942 */
2943 (void) SyncImageSettings(mogrify_info,*image);
2944 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2945 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2946 exception);
2947 break;
2948 }
2949 if (LocaleCompare("tile",option+1) == 0)
2950 {
2951 if (*option == '+')
2952 {
2953 if (draw_info->fill_pattern != (Image *) NULL)
2954 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2955 break;
2956 }
2957 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2958 exception);
2959 break;
2960 }
2961 if (LocaleCompare("tint",option+1) == 0)
2962 {
2963 /*
2964 Tint the image.
2965 */
2966 (void) SyncImageSettings(mogrify_info,*image);
cristy28474bf2011-09-11 23:32:52 +00002967 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002968 break;
2969 }
2970 if (LocaleCompare("transform",option+1) == 0)
2971 {
2972 /*
2973 Affine transform image.
2974 */
2975 (void) SyncImageSettings(mogrify_info,*image);
2976 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2977 exception);
2978 break;
2979 }
2980 if (LocaleCompare("transparent",option+1) == 0)
2981 {
cristy4c08aed2011-07-01 19:47:50 +00002982 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002983 target;
2984
2985 (void) SyncImageSettings(mogrify_info,*image);
cristy9950d572011-10-01 18:22:35 +00002986 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2987 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002988 (void) TransparentPaintImage(*image,&target,(Quantum)
cristy189e84c2011-08-27 18:08:53 +00002989 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
2990 &(*image)->exception);
anthonydf8ebac2011-04-27 09:03:19 +00002991 break;
2992 }
2993 if (LocaleCompare("transpose",option+1) == 0)
2994 {
2995 /*
2996 Transpose image scanlines.
2997 */
2998 (void) SyncImageSettings(mogrify_info,*image);
2999 mogrify_image=TransposeImage(*image,exception);
3000 break;
3001 }
3002 if (LocaleCompare("transverse",option+1) == 0)
3003 {
3004 /*
3005 Transverse image scanlines.
3006 */
3007 (void) SyncImageSettings(mogrify_info,*image);
3008 mogrify_image=TransverseImage(*image,exception);
3009 break;
3010 }
3011 if (LocaleCompare("treedepth",option+1) == 0)
3012 {
3013 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3014 break;
3015 }
3016 if (LocaleCompare("trim",option+1) == 0)
3017 {
3018 /*
3019 Trim image.
3020 */
3021 (void) SyncImageSettings(mogrify_info,*image);
3022 mogrify_image=TrimImage(*image,exception);
3023 break;
3024 }
3025 if (LocaleCompare("type",option+1) == 0)
3026 {
3027 ImageType
3028 type;
3029
3030 (void) SyncImageSettings(mogrify_info,*image);
3031 if (*option == '+')
3032 type=UndefinedType;
3033 else
3034 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3035 argv[i+1]);
3036 (*image)->type=UndefinedType;
cristy018f07f2011-09-04 21:15:19 +00003037 (void) SetImageType(*image,type,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003038 break;
3039 }
3040 break;
3041 }
3042 case 'u':
3043 {
3044 if (LocaleCompare("undercolor",option+1) == 0)
3045 {
cristy9950d572011-10-01 18:22:35 +00003046 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3047 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003048 break;
3049 }
3050 if (LocaleCompare("unique",option+1) == 0)
3051 {
3052 if (*option == '+')
3053 {
3054 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3055 break;
3056 }
3057 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3058 (void) SetImageArtifact(*image,"verbose","true");
3059 break;
3060 }
3061 if (LocaleCompare("unique-colors",option+1) == 0)
3062 {
3063 /*
3064 Unique image colors.
3065 */
3066 (void) SyncImageSettings(mogrify_info,*image);
3067 mogrify_image=UniqueImageColors(*image,exception);
3068 break;
3069 }
3070 if (LocaleCompare("unsharp",option+1) == 0)
3071 {
3072 /*
3073 Unsharp mask image.
3074 */
3075 (void) SyncImageSettings(mogrify_info,*image);
3076 flags=ParseGeometry(argv[i+1],&geometry_info);
3077 if ((flags & SigmaValue) == 0)
3078 geometry_info.sigma=1.0;
3079 if ((flags & XiValue) == 0)
3080 geometry_info.xi=1.0;
3081 if ((flags & PsiValue) == 0)
3082 geometry_info.psi=0.05;
cristyf4ad9df2011-07-08 16:49:03 +00003083 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3084 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003085 break;
3086 }
3087 break;
3088 }
3089 case 'v':
3090 {
3091 if (LocaleCompare("verbose",option+1) == 0)
3092 {
3093 (void) SetImageArtifact(*image,option+1,
3094 *option == '+' ? "false" : "true");
3095 break;
3096 }
3097 if (LocaleCompare("vignette",option+1) == 0)
3098 {
3099 /*
3100 Vignette image.
3101 */
3102 (void) SyncImageSettings(mogrify_info,*image);
3103 flags=ParseGeometry(argv[i+1],&geometry_info);
3104 if ((flags & SigmaValue) == 0)
3105 geometry_info.sigma=1.0;
3106 if ((flags & XiValue) == 0)
3107 geometry_info.xi=0.1*(*image)->columns;
3108 if ((flags & PsiValue) == 0)
3109 geometry_info.psi=0.1*(*image)->rows;
3110 mogrify_image=VignetteImage(*image,geometry_info.rho,
3111 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3112 ceil(geometry_info.psi-0.5),exception);
3113 break;
3114 }
3115 if (LocaleCompare("virtual-pixel",option+1) == 0)
3116 {
3117 if (*option == '+')
3118 {
3119 (void) SetImageVirtualPixelMethod(*image,
3120 UndefinedVirtualPixelMethod);
3121 break;
3122 }
3123 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3124 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3125 argv[i+1]));
3126 break;
3127 }
3128 break;
3129 }
3130 case 'w':
3131 {
3132 if (LocaleCompare("wave",option+1) == 0)
3133 {
3134 /*
3135 Wave image.
3136 */
3137 (void) SyncImageSettings(mogrify_info,*image);
3138 flags=ParseGeometry(argv[i+1],&geometry_info);
3139 if ((flags & SigmaValue) == 0)
3140 geometry_info.sigma=1.0;
3141 mogrify_image=WaveImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00003142 geometry_info.sigma,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003143 break;
3144 }
3145 if (LocaleCompare("weight",option+1) == 0)
3146 {
3147 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3148 if (LocaleCompare(argv[i+1],"all") == 0)
3149 draw_info->weight=0;
3150 if (LocaleCompare(argv[i+1],"bold") == 0)
3151 draw_info->weight=700;
3152 if (LocaleCompare(argv[i+1],"bolder") == 0)
3153 if (draw_info->weight <= 800)
3154 draw_info->weight+=100;
3155 if (LocaleCompare(argv[i+1],"lighter") == 0)
3156 if (draw_info->weight >= 100)
3157 draw_info->weight-=100;
3158 if (LocaleCompare(argv[i+1],"normal") == 0)
3159 draw_info->weight=400;
3160 break;
3161 }
3162 if (LocaleCompare("white-threshold",option+1) == 0)
3163 {
3164 /*
3165 White threshold image.
3166 */
3167 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00003168 (void) WhiteThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00003169 InheritException(exception,&(*image)->exception);
3170 break;
3171 }
3172 break;
3173 }
3174 default:
3175 break;
3176 }
3177 /*
3178 Replace current image with any image that was generated
3179 */
3180 if (mogrify_image != (Image *) NULL)
3181 ReplaceImageInListReturnLast(image,mogrify_image);
cristy3ed852e2009-09-05 21:47:34 +00003182 i+=count;
3183 }
3184 if (region_image != (Image *) NULL)
3185 {
anthonydf8ebac2011-04-27 09:03:19 +00003186 /*
3187 Composite transformed region onto image.
3188 */
cristy6b3da3a2010-06-20 02:21:46 +00003189 (void) SyncImageSettings(mogrify_info,*image);
anthonya129f702011-04-14 01:08:48 +00003190 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00003191 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3192 region_geometry.x,region_geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00003193 InheritException(exception,&region_image->exception);
3194 *image=DestroyImage(*image);
3195 *image=region_image;
anthonye9c27192011-03-27 08:07:06 +00003196 region_image = (Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00003197 }
3198 /*
3199 Free resources.
3200 */
anthonydf8ebac2011-04-27 09:03:19 +00003201 quantize_info=DestroyQuantizeInfo(quantize_info);
3202 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003203 mogrify_info=DestroyImageInfo(mogrify_info);
cristy4c08aed2011-07-01 19:47:50 +00003204 status=(MagickStatusType) ((*image)->exception.severity ==
cristy5f09d852011-05-29 01:39:29 +00003205 UndefinedException ? 1 : 0);
cristy72988482011-03-29 16:34:38 +00003206 return(status == 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00003207}
3208
3209/*
3210%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3211% %
3212% %
3213% %
cristy5063d812010-10-19 16:28:10 +00003214+ 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 +00003215% %
3216% %
3217% %
3218%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3219%
3220% MogrifyImageCommand() transforms an image or a sequence of images. These
3221% transforms include image scaling, image rotation, color reduction, and
3222% others. The transmogrified image overwrites the original image.
3223%
3224% The format of the MogrifyImageCommand method is:
3225%
3226% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3227% const char **argv,char **metadata,ExceptionInfo *exception)
3228%
3229% A description of each parameter follows:
3230%
3231% o image_info: the image info.
3232%
3233% o argc: the number of elements in the argument vector.
3234%
3235% o argv: A text array containing the command line arguments.
3236%
3237% o metadata: any metadata is returned here.
3238%
3239% o exception: return any errors or warnings in this structure.
3240%
3241*/
3242
3243static MagickBooleanType MogrifyUsage(void)
3244{
3245 static const char
3246 *miscellaneous[]=
3247 {
3248 "-debug events display copious debugging information",
3249 "-help print program options",
3250 "-list type print a list of supported option arguments",
3251 "-log format format of debugging information",
3252 "-version print version information",
3253 (char *) NULL
3254 },
3255 *operators[]=
3256 {
3257 "-adaptive-blur geometry",
3258 " adaptively blur pixels; decrease effect near edges",
3259 "-adaptive-resize geometry",
3260 " adaptively resize image using 'mesh' interpolation",
3261 "-adaptive-sharpen geometry",
3262 " adaptively sharpen pixels; increase effect near edges",
3263 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3264 " transparent, extract, background, or shape",
3265 "-annotate geometry text",
3266 " annotate the image with text",
3267 "-auto-gamma automagically adjust gamma level of image",
3268 "-auto-level automagically adjust color levels of image",
3269 "-auto-orient automagically orient (rotate) image",
3270 "-bench iterations measure performance",
3271 "-black-threshold value",
3272 " force all pixels below the threshold into black",
3273 "-blue-shift simulate a scene at nighttime in the moonlight",
3274 "-blur geometry reduce image noise and reduce detail levels",
3275 "-border geometry surround image with a border of color",
3276 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003277 "-brightness-contrast geometry",
3278 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003279 "-cdl filename color correct with a color decision list",
cristy05c0c9a2011-09-05 23:16:13 +00003280 "-charcoal geometry simulate a charcoal drawing",
cristy3ed852e2009-09-05 21:47:34 +00003281 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003282 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003283 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003284 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003285 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003286 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003287 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003288 "-contrast enhance or reduce the image contrast",
3289 "-contrast-stretch geometry",
3290 " improve contrast by `stretching' the intensity range",
3291 "-convolve coefficients",
3292 " apply a convolution kernel to the image",
3293 "-cycle amount cycle the image colormap",
3294 "-decipher filename convert cipher pixels to plain pixels",
3295 "-deskew threshold straighten an image",
3296 "-despeckle reduce the speckles within an image",
3297 "-distort method args",
3298 " distort images according to given method ad args",
3299 "-draw string annotate the image with a graphic primitive",
3300 "-edge radius apply a filter to detect edges in the image",
3301 "-encipher filename convert plain pixels to cipher pixels",
3302 "-emboss radius emboss an image",
3303 "-enhance apply a digital filter to enhance a noisy image",
3304 "-equalize perform histogram equalization to an image",
3305 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003306 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003307 "-extent geometry set the image size",
3308 "-extract geometry extract area from image",
3309 "-fft implements the discrete Fourier transform (DFT)",
3310 "-flip flip image vertically",
3311 "-floodfill geometry color",
3312 " floodfill the image with color",
3313 "-flop flop image horizontally",
3314 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003315 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003316 " apply function over image values",
3317 "-gamma value level of gamma correction",
3318 "-gaussian-blur geometry",
3319 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003320 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003321 "-identify identify the format and characteristics of the image",
3322 "-ift implements the inverse discrete Fourier transform (DFT)",
3323 "-implode amount implode image pixels about the center",
3324 "-lat geometry local adaptive thresholding",
3325 "-layers method optimize, merge, or compare image layers",
3326 "-level value adjust the level of image contrast",
3327 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003328 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003329 "-linear-stretch geometry",
3330 " improve contrast by `stretching with saturation'",
3331 "-liquid-rescale geometry",
3332 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +00003333 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +00003334 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003335 "-modulate value vary the brightness, saturation, and hue",
3336 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003337 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003338 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003339 "-motion-blur geometry",
3340 " simulate motion blur",
3341 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +00003342 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +00003343 "-normalize transform image to span the full range of colors",
3344 "-opaque color change this color to the fill color",
3345 "-ordered-dither NxN",
3346 " add a noise pattern to the image with specific",
3347 " amplitudes",
3348 "-paint radius simulate an oil painting",
3349 "-polaroid angle simulate a Polaroid picture",
3350 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003351 "-profile filename add, delete, or apply an image profile",
3352 "-quantize colorspace reduce colors in this colorspace",
3353 "-radial-blur angle radial blur the image",
3354 "-raise value lighten/darken image edges to create a 3-D effect",
3355 "-random-threshold low,high",
3356 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003357 "-region geometry apply options to a portion of the image",
3358 "-render render vector graphics",
3359 "-repage geometry size and location of an image canvas",
3360 "-resample geometry change the resolution of an image",
3361 "-resize geometry resize the image",
3362 "-roll geometry roll an image vertically or horizontally",
3363 "-rotate degrees apply Paeth rotation to the image",
3364 "-sample geometry scale image with pixel sampling",
3365 "-scale geometry scale the image",
3366 "-segment values segment an image",
3367 "-selective-blur geometry",
3368 " selectively blur pixels within a contrast threshold",
3369 "-sepia-tone threshold",
3370 " simulate a sepia-toned photo",
3371 "-set property value set an image property",
3372 "-shade degrees shade the image using a distant light source",
3373 "-shadow geometry simulate an image shadow",
3374 "-sharpen geometry sharpen the image",
3375 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003376 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003377 "-sigmoidal-contrast geometry",
3378 " increase the contrast without saturating highlights or shadows",
3379 "-sketch geometry simulate a pencil sketch",
3380 "-solarize threshold negate all pixels above the threshold level",
3381 "-sparse-color method args",
3382 " fill in a image based on a few color points",
3383 "-splice geometry splice the background color into the image",
3384 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003385 "-statistic type radius",
3386 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003387 "-strip strip image of all profiles and comments",
3388 "-swirl degrees swirl image pixels about the center",
3389 "-threshold value threshold the image",
3390 "-thumbnail geometry create a thumbnail of the image",
3391 "-tile filename tile image when filling a graphic primitive",
3392 "-tint value tint the image with the fill color",
3393 "-transform affine transform image",
3394 "-transparent color make this color transparent within the image",
3395 "-transpose flip image vertically and rotate 90 degrees",
3396 "-transverse flop image horizontally and rotate 270 degrees",
3397 "-trim trim image edges",
3398 "-type type image type",
3399 "-unique-colors discard all but one of any pixel color",
3400 "-unsharp geometry sharpen the image",
3401 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003402 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003403 "-white-threshold value",
3404 " force all pixels above the threshold into white",
3405 (char *) NULL
3406 },
3407 *sequence_operators[]=
3408 {
cristy4285d782011-02-09 20:12:28 +00003409 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003410 "-clut apply a color lookup table to the image",
3411 "-coalesce merge a sequence of images",
3412 "-combine combine a sequence of images",
3413 "-composite composite image",
3414 "-crop geometry cut out a rectangular region of the image",
3415 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003416 "-evaluate-sequence operator",
3417 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003418 "-flatten flatten a sequence of images",
3419 "-fx expression apply mathematical expression to an image channel(s)",
3420 "-hald-clut apply a Hald color lookup table to the image",
3421 "-morph value morph an image sequence",
3422 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003423 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003424 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003425 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003426 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003427 "-write filename write images to this file",
3428 (char *) NULL
3429 },
3430 *settings[]=
3431 {
3432 "-adjoin join images into a single multi-image file",
3433 "-affine matrix affine transform matrix",
3434 "-alpha option activate, deactivate, reset, or set the alpha channel",
3435 "-antialias remove pixel-aliasing",
3436 "-authenticate password",
3437 " decipher image with this password",
3438 "-attenuate value lessen (or intensify) when adding noise to an image",
3439 "-background color background color",
3440 "-bias value add bias when convolving an image",
3441 "-black-point-compensation",
3442 " use black point compensation",
3443 "-blue-primary point chromaticity blue primary point",
3444 "-bordercolor color border color",
3445 "-caption string assign a caption to an image",
3446 "-channel type apply option to select image channels",
3447 "-colors value preferred number of colors in the image",
3448 "-colorspace type alternate image colorspace",
3449 "-comment string annotate image with comment",
3450 "-compose operator set image composite operator",
3451 "-compress type type of pixel compression when writing the image",
3452 "-define format:option",
3453 " define one or more image format options",
3454 "-delay value display the next image after pausing",
3455 "-density geometry horizontal and vertical density of the image",
3456 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003457 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003458 "-display server get image or font from this X server",
3459 "-dispose method layer disposal method",
3460 "-dither method apply error diffusion to image",
3461 "-encoding type text encoding type",
3462 "-endian type endianness (MSB or LSB) of the image",
3463 "-family name render text with this font family",
3464 "-fill color color to use when filling a graphic primitive",
3465 "-filter type use this filter when resizing an image",
3466 "-font name render text with this font",
3467 "-format \"string\" output formatted image characteristics",
3468 "-fuzz distance colors within this distance are considered equal",
3469 "-gravity type horizontal and vertical text placement",
3470 "-green-primary point chromaticity green primary point",
3471 "-intent type type of rendering intent when managing the image color",
3472 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003473 "-interline-spacing value",
3474 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003475 "-interpolate method pixel color interpolation method",
3476 "-interword-spacing value",
3477 " set the space between two words",
3478 "-kerning value set the space between two letters",
3479 "-label string assign a label to an image",
3480 "-limit type value pixel cache resource limit",
3481 "-loop iterations add Netscape loop extension to your GIF animation",
3482 "-mask filename associate a mask with the image",
3483 "-mattecolor color frame color",
3484 "-monitor monitor progress",
3485 "-orient type image orientation",
3486 "-page geometry size and location of an image canvas (setting)",
3487 "-ping efficiently determine image attributes",
3488 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003489 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003490 "-preview type image preview type",
3491 "-quality value JPEG/MIFF/PNG compression level",
3492 "-quiet suppress all warning messages",
3493 "-red-primary point chromaticity red primary point",
3494 "-regard-warnings pay attention to warning messages",
3495 "-remap filename transform image colors to match this set of colors",
3496 "-respect-parentheses settings remain in effect until parenthesis boundary",
3497 "-sampling-factor geometry",
3498 " horizontal and vertical sampling factor",
3499 "-scene value image scene number",
3500 "-seed value seed a new sequence of pseudo-random numbers",
3501 "-size geometry width and height of image",
3502 "-stretch type render text with this font stretch",
3503 "-stroke color graphic primitive stroke color",
3504 "-strokewidth value graphic primitive stroke width",
3505 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003506 "-synchronize synchronize image to storage device",
3507 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003508 "-texture filename name of texture to tile onto the image background",
3509 "-tile-offset geometry",
3510 " tile offset",
3511 "-treedepth value color tree depth",
3512 "-transparent-color color",
3513 " transparent color",
3514 "-undercolor color annotation bounding box color",
3515 "-units type the units of image resolution",
3516 "-verbose print detailed information about the image",
3517 "-view FlashPix viewing transforms",
3518 "-virtual-pixel method",
3519 " virtual pixel access method",
3520 "-weight type render text with this font weight",
3521 "-white-point point chromaticity white point",
3522 (char *) NULL
3523 },
3524 *stack_operators[]=
3525 {
anthonyb69c4b32011-03-23 04:37:44 +00003526 "-delete indexes delete the image from the image sequence",
3527 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003528 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003529 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003530 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003531 "-swap indexes swap two images in the image sequence",
3532 (char *) NULL
3533 };
3534
3535 const char
3536 **p;
3537
cristybb503372010-05-27 20:51:26 +00003538 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003539 (void) printf("Copyright: %s\n",GetMagickCopyright());
3540 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003541 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3542 GetClientName());
3543 (void) printf("\nImage Settings:\n");
3544 for (p=settings; *p != (char *) NULL; p++)
3545 (void) printf(" %s\n",*p);
3546 (void) printf("\nImage Operators:\n");
3547 for (p=operators; *p != (char *) NULL; p++)
3548 (void) printf(" %s\n",*p);
3549 (void) printf("\nImage Sequence Operators:\n");
3550 for (p=sequence_operators; *p != (char *) NULL; p++)
3551 (void) printf(" %s\n",*p);
3552 (void) printf("\nImage Stack Operators:\n");
3553 for (p=stack_operators; *p != (char *) NULL; p++)
3554 (void) printf(" %s\n",*p);
3555 (void) printf("\nMiscellaneous Options:\n");
3556 for (p=miscellaneous; *p != (char *) NULL; p++)
3557 (void) printf(" %s\n",*p);
3558 (void) printf(
3559 "\nBy default, the image format of `file' is determined by its magic\n");
3560 (void) printf(
3561 "number. To specify a particular image format, precede the filename\n");
3562 (void) printf(
3563 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3564 (void) printf(
3565 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3566 (void) printf("'-' for standard input or output.\n");
3567 return(MagickFalse);
3568}
3569
3570WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3571 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3572{
3573#define DestroyMogrify() \
3574{ \
3575 if (format != (char *) NULL) \
3576 format=DestroyString(format); \
3577 if (path != (char *) NULL) \
3578 path=DestroyString(path); \
3579 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003580 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003581 argv[i]=DestroyString(argv[i]); \
3582 argv=(char **) RelinquishMagickMemory(argv); \
3583}
3584#define ThrowMogrifyException(asperity,tag,option) \
3585{ \
3586 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3587 option); \
3588 DestroyMogrify(); \
3589 return(MagickFalse); \
3590}
3591#define ThrowMogrifyInvalidArgumentException(option,argument) \
3592{ \
3593 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3594 "InvalidArgument","`%s': %s",argument,option); \
3595 DestroyMogrify(); \
3596 return(MagickFalse); \
3597}
3598
3599 char
3600 *format,
3601 *option,
3602 *path;
3603
3604 Image
3605 *image;
3606
3607 ImageStack
3608 image_stack[MaxImageStackDepth+1];
3609
cristy3ed852e2009-09-05 21:47:34 +00003610 MagickBooleanType
3611 global_colormap;
3612
3613 MagickBooleanType
3614 fire,
cristyebbcfea2011-02-25 02:43:54 +00003615 pend,
3616 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00003617
3618 MagickStatusType
3619 status;
3620
cristyebbcfea2011-02-25 02:43:54 +00003621 register ssize_t
3622 i;
3623
3624 ssize_t
3625 j,
3626 k;
3627
cristy3ed852e2009-09-05 21:47:34 +00003628 /*
3629 Set defaults.
3630 */
3631 assert(image_info != (ImageInfo *) NULL);
3632 assert(image_info->signature == MagickSignature);
3633 if (image_info->debug != MagickFalse)
3634 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3635 assert(exception != (ExceptionInfo *) NULL);
3636 if (argc == 2)
3637 {
3638 option=argv[1];
3639 if ((LocaleCompare("version",option+1) == 0) ||
3640 (LocaleCompare("-version",option+1) == 0))
3641 {
cristyb51dff52011-05-19 16:55:47 +00003642 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00003643 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00003644 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3645 GetMagickCopyright());
3646 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3647 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003648 return(MagickFalse);
3649 }
3650 }
3651 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00003652 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00003653 format=(char *) NULL;
3654 path=(char *) NULL;
3655 global_colormap=MagickFalse;
3656 k=0;
3657 j=1;
3658 NewImageStack();
3659 option=(char *) NULL;
3660 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00003661 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003662 status=MagickTrue;
3663 /*
3664 Parse command line.
3665 */
3666 ReadCommandlLine(argc,&argv);
3667 status=ExpandFilenames(&argc,&argv);
3668 if (status == MagickFalse)
3669 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3670 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00003671 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00003672 {
3673 option=argv[i];
3674 if (LocaleCompare(option,"(") == 0)
3675 {
3676 FireImageStack(MagickFalse,MagickTrue,pend);
3677 if (k == MaxImageStackDepth)
3678 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3679 option);
3680 PushImageStack();
3681 continue;
3682 }
3683 if (LocaleCompare(option,")") == 0)
3684 {
3685 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3686 if (k == 0)
3687 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3688 PopImageStack();
3689 continue;
3690 }
cristy042ee782011-04-22 18:48:30 +00003691 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00003692 {
3693 char
3694 backup_filename[MaxTextExtent],
3695 *filename;
3696
3697 Image
3698 *images;
3699
3700 /*
3701 Option is a file name: begin by reading image from specified file.
3702 */
3703 FireImageStack(MagickFalse,MagickFalse,pend);
3704 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00003705 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00003706 filename=argv[++i];
3707 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3708 images=ReadImages(image_info,exception);
3709 status&=(images != (Image *) NULL) &&
3710 (exception->severity < ErrorException);
3711 if (images == (Image *) NULL)
3712 continue;
cristydaa76602010-06-30 13:05:11 +00003713 if (format != (char *) NULL)
3714 (void) CopyMagickString(images->filename,images->magick_filename,
3715 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00003716 if (path != (char *) NULL)
3717 {
3718 GetPathComponent(option,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +00003719 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
cristy3ed852e2009-09-05 21:47:34 +00003720 path,*DirectorySeparator,filename);
3721 }
3722 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00003723 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00003724 AppendImageStack(images);
3725 FinalizeImageSettings(image_info,image,MagickFalse);
3726 if (global_colormap != MagickFalse)
3727 {
3728 QuantizeInfo
3729 *quantize_info;
3730
3731 quantize_info=AcquireQuantizeInfo(image_info);
cristy018f07f2011-09-04 21:15:19 +00003732 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
cristy3ed852e2009-09-05 21:47:34 +00003733 quantize_info=DestroyQuantizeInfo(quantize_info);
3734 }
3735 *backup_filename='\0';
3736 if ((LocaleCompare(image->filename,"-") != 0) &&
3737 (IsPathWritable(image->filename) != MagickFalse))
3738 {
cristybb503372010-05-27 20:51:26 +00003739 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003740 i;
3741
3742 /*
3743 Rename image file as backup.
3744 */
3745 (void) CopyMagickString(backup_filename,image->filename,
3746 MaxTextExtent);
3747 for (i=0; i < 6; i++)
3748 {
3749 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3750 if (IsPathAccessible(backup_filename) == MagickFalse)
3751 break;
3752 }
3753 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
cristy320684d2011-09-23 14:55:47 +00003754 (rename_utf8(image->filename,backup_filename) != 0))
cristy3ed852e2009-09-05 21:47:34 +00003755 *backup_filename='\0';
3756 }
3757 /*
3758 Write transmogrified image to disk.
3759 */
3760 image_info->synchronize=MagickTrue;
3761 status&=WriteImages(image_info,image,image->filename,exception);
3762 if ((status == MagickFalse) && (*backup_filename != '\0'))
cristy18c6c272011-09-23 14:40:37 +00003763 (void) remove_utf8(backup_filename);
cristy3ed852e2009-09-05 21:47:34 +00003764 RemoveAllImageStack();
3765 continue;
3766 }
3767 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3768 switch (*(option+1))
3769 {
3770 case 'a':
3771 {
3772 if (LocaleCompare("adaptive-blur",option+1) == 0)
3773 {
3774 i++;
cristybb503372010-05-27 20:51:26 +00003775 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003776 ThrowMogrifyException(OptionError,"MissingArgument",option);
3777 if (IsGeometry(argv[i]) == MagickFalse)
3778 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3779 break;
3780 }
3781 if (LocaleCompare("adaptive-resize",option+1) == 0)
3782 {
3783 i++;
cristybb503372010-05-27 20:51:26 +00003784 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003785 ThrowMogrifyException(OptionError,"MissingArgument",option);
3786 if (IsGeometry(argv[i]) == MagickFalse)
3787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3788 break;
3789 }
3790 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3791 {
3792 i++;
cristybb503372010-05-27 20:51:26 +00003793 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003794 ThrowMogrifyException(OptionError,"MissingArgument",option);
3795 if (IsGeometry(argv[i]) == MagickFalse)
3796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3797 break;
3798 }
3799 if (LocaleCompare("affine",option+1) == 0)
3800 {
3801 if (*option == '+')
3802 break;
3803 i++;
cristybb503372010-05-27 20:51:26 +00003804 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003805 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +00003806 break;
3807 }
3808 if (LocaleCompare("alpha",option+1) == 0)
3809 {
cristybb503372010-05-27 20:51:26 +00003810 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003811 type;
3812
3813 if (*option == '+')
3814 break;
3815 i++;
cristybb503372010-05-27 20:51:26 +00003816 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003817 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00003818 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00003819 if (type < 0)
3820 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3821 argv[i]);
3822 break;
3823 }
3824 if (LocaleCompare("annotate",option+1) == 0)
3825 {
3826 if (*option == '+')
3827 break;
3828 i++;
cristybb503372010-05-27 20:51:26 +00003829 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003830 ThrowMogrifyException(OptionError,"MissingArgument",option);
3831 if (IsGeometry(argv[i]) == MagickFalse)
3832 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00003833 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003834 ThrowMogrifyException(OptionError,"MissingArgument",option);
3835 i++;
3836 break;
3837 }
3838 if (LocaleCompare("antialias",option+1) == 0)
3839 break;
3840 if (LocaleCompare("append",option+1) == 0)
3841 break;
3842 if (LocaleCompare("attenuate",option+1) == 0)
3843 {
3844 if (*option == '+')
3845 break;
3846 i++;
cristybb503372010-05-27 20:51:26 +00003847 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003848 ThrowMogrifyException(OptionError,"MissingArgument",option);
3849 if (IsGeometry(argv[i]) == MagickFalse)
3850 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3851 break;
3852 }
3853 if (LocaleCompare("authenticate",option+1) == 0)
3854 {
3855 if (*option == '+')
3856 break;
3857 i++;
cristybb503372010-05-27 20:51:26 +00003858 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003859 ThrowMogrifyException(OptionError,"MissingArgument",option);
3860 break;
3861 }
3862 if (LocaleCompare("auto-gamma",option+1) == 0)
3863 break;
3864 if (LocaleCompare("auto-level",option+1) == 0)
3865 break;
3866 if (LocaleCompare("auto-orient",option+1) == 0)
3867 break;
3868 if (LocaleCompare("average",option+1) == 0)
3869 break;
3870 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3871 }
3872 case 'b':
3873 {
3874 if (LocaleCompare("background",option+1) == 0)
3875 {
3876 if (*option == '+')
3877 break;
3878 i++;
cristybb503372010-05-27 20:51:26 +00003879 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003880 ThrowMogrifyException(OptionError,"MissingArgument",option);
3881 break;
3882 }
3883 if (LocaleCompare("bias",option+1) == 0)
3884 {
3885 if (*option == '+')
3886 break;
3887 i++;
cristybb503372010-05-27 20:51:26 +00003888 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003889 ThrowMogrifyException(OptionError,"MissingArgument",option);
3890 if (IsGeometry(argv[i]) == MagickFalse)
3891 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3892 break;
3893 }
3894 if (LocaleCompare("black-point-compensation",option+1) == 0)
3895 break;
3896 if (LocaleCompare("black-threshold",option+1) == 0)
3897 {
3898 if (*option == '+')
3899 break;
3900 i++;
cristybb503372010-05-27 20:51:26 +00003901 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003902 ThrowMogrifyException(OptionError,"MissingArgument",option);
3903 if (IsGeometry(argv[i]) == MagickFalse)
3904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3905 break;
3906 }
3907 if (LocaleCompare("blue-primary",option+1) == 0)
3908 {
3909 if (*option == '+')
3910 break;
3911 i++;
cristybb503372010-05-27 20:51:26 +00003912 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003913 ThrowMogrifyException(OptionError,"MissingArgument",option);
3914 if (IsGeometry(argv[i]) == MagickFalse)
3915 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3916 break;
3917 }
3918 if (LocaleCompare("blue-shift",option+1) == 0)
3919 {
3920 i++;
cristybb503372010-05-27 20:51:26 +00003921 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003922 ThrowMogrifyException(OptionError,"MissingArgument",option);
3923 if (IsGeometry(argv[i]) == MagickFalse)
3924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3925 break;
3926 }
3927 if (LocaleCompare("blur",option+1) == 0)
3928 {
3929 i++;
cristybb503372010-05-27 20:51:26 +00003930 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003931 ThrowMogrifyException(OptionError,"MissingArgument",option);
3932 if (IsGeometry(argv[i]) == MagickFalse)
3933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3934 break;
3935 }
3936 if (LocaleCompare("border",option+1) == 0)
3937 {
3938 if (*option == '+')
3939 break;
3940 i++;
cristybb503372010-05-27 20:51:26 +00003941 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003942 ThrowMogrifyException(OptionError,"MissingArgument",option);
3943 if (IsGeometry(argv[i]) == MagickFalse)
3944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3945 break;
3946 }
3947 if (LocaleCompare("bordercolor",option+1) == 0)
3948 {
3949 if (*option == '+')
3950 break;
3951 i++;
cristybb503372010-05-27 20:51:26 +00003952 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003953 ThrowMogrifyException(OptionError,"MissingArgument",option);
3954 break;
3955 }
3956 if (LocaleCompare("box",option+1) == 0)
3957 {
3958 if (*option == '+')
3959 break;
3960 i++;
cristybb503372010-05-27 20:51:26 +00003961 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003962 ThrowMogrifyException(OptionError,"MissingArgument",option);
3963 break;
3964 }
cristya28d6b82010-01-11 20:03:47 +00003965 if (LocaleCompare("brightness-contrast",option+1) == 0)
3966 {
3967 i++;
cristybb503372010-05-27 20:51:26 +00003968 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00003969 ThrowMogrifyException(OptionError,"MissingArgument",option);
3970 if (IsGeometry(argv[i]) == MagickFalse)
3971 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3972 break;
3973 }
cristy3ed852e2009-09-05 21:47:34 +00003974 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3975 }
3976 case 'c':
3977 {
3978 if (LocaleCompare("cache",option+1) == 0)
3979 {
3980 if (*option == '+')
3981 break;
3982 i++;
cristybb503372010-05-27 20:51:26 +00003983 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003984 ThrowMogrifyException(OptionError,"MissingArgument",option);
3985 if (IsGeometry(argv[i]) == MagickFalse)
3986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3987 break;
3988 }
3989 if (LocaleCompare("caption",option+1) == 0)
3990 {
3991 if (*option == '+')
3992 break;
3993 i++;
cristybb503372010-05-27 20:51:26 +00003994 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003995 ThrowMogrifyException(OptionError,"MissingArgument",option);
3996 break;
3997 }
3998 if (LocaleCompare("channel",option+1) == 0)
3999 {
cristybb503372010-05-27 20:51:26 +00004000 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004001 channel;
4002
4003 if (*option == '+')
4004 break;
4005 i++;
cristybb503372010-05-27 20:51:26 +00004006 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004007 ThrowMogrifyException(OptionError,"MissingArgument",option);
4008 channel=ParseChannelOption(argv[i]);
4009 if (channel < 0)
4010 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4011 argv[i]);
4012 break;
4013 }
4014 if (LocaleCompare("cdl",option+1) == 0)
4015 {
4016 if (*option == '+')
4017 break;
4018 i++;
cristybb503372010-05-27 20:51:26 +00004019 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004020 ThrowMogrifyException(OptionError,"MissingArgument",option);
4021 break;
4022 }
4023 if (LocaleCompare("charcoal",option+1) == 0)
4024 {
4025 if (*option == '+')
4026 break;
4027 i++;
cristybb503372010-05-27 20:51:26 +00004028 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004029 ThrowMogrifyException(OptionError,"MissingArgument",option);
4030 if (IsGeometry(argv[i]) == MagickFalse)
4031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4032 break;
4033 }
4034 if (LocaleCompare("chop",option+1) == 0)
4035 {
4036 if (*option == '+')
4037 break;
4038 i++;
cristybb503372010-05-27 20:51:26 +00004039 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4041 if (IsGeometry(argv[i]) == MagickFalse)
4042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4043 break;
4044 }
cristy1eb45dd2009-09-25 16:38:06 +00004045 if (LocaleCompare("clamp",option+1) == 0)
4046 break;
4047 if (LocaleCompare("clip",option+1) == 0)
4048 break;
cristy3ed852e2009-09-05 21:47:34 +00004049 if (LocaleCompare("clip-mask",option+1) == 0)
4050 {
4051 if (*option == '+')
4052 break;
4053 i++;
cristybb503372010-05-27 20:51:26 +00004054 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004055 ThrowMogrifyException(OptionError,"MissingArgument",option);
4056 break;
4057 }
4058 if (LocaleCompare("clut",option+1) == 0)
4059 break;
4060 if (LocaleCompare("coalesce",option+1) == 0)
4061 break;
4062 if (LocaleCompare("colorize",option+1) == 0)
4063 {
4064 if (*option == '+')
4065 break;
4066 i++;
cristybb503372010-05-27 20:51:26 +00004067 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004068 ThrowMogrifyException(OptionError,"MissingArgument",option);
4069 if (IsGeometry(argv[i]) == MagickFalse)
4070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4071 break;
4072 }
cristye6365592010-04-02 17:31:23 +00004073 if (LocaleCompare("color-matrix",option+1) == 0)
4074 {
cristyb6bd4ad2010-08-08 01:12:27 +00004075 KernelInfo
4076 *kernel_info;
4077
cristye6365592010-04-02 17:31:23 +00004078 if (*option == '+')
4079 break;
4080 i++;
cristybb503372010-05-27 20:51:26 +00004081 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004082 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004083 kernel_info=AcquireKernelInfo(argv[i]);
4084 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004086 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004087 break;
4088 }
cristy3ed852e2009-09-05 21:47:34 +00004089 if (LocaleCompare("colors",option+1) == 0)
4090 {
4091 if (*option == '+')
4092 break;
4093 i++;
cristybb503372010-05-27 20:51:26 +00004094 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004095 ThrowMogrifyException(OptionError,"MissingArgument",option);
4096 if (IsGeometry(argv[i]) == MagickFalse)
4097 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4098 break;
4099 }
4100 if (LocaleCompare("colorspace",option+1) == 0)
4101 {
cristybb503372010-05-27 20:51:26 +00004102 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004103 colorspace;
4104
4105 if (*option == '+')
4106 break;
4107 i++;
cristybb503372010-05-27 20:51:26 +00004108 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004109 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004110 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004111 argv[i]);
4112 if (colorspace < 0)
4113 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4114 argv[i]);
4115 break;
4116 }
4117 if (LocaleCompare("combine",option+1) == 0)
4118 break;
4119 if (LocaleCompare("comment",option+1) == 0)
4120 {
4121 if (*option == '+')
4122 break;
4123 i++;
cristybb503372010-05-27 20:51:26 +00004124 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004125 ThrowMogrifyException(OptionError,"MissingArgument",option);
4126 break;
4127 }
4128 if (LocaleCompare("composite",option+1) == 0)
4129 break;
4130 if (LocaleCompare("compress",option+1) == 0)
4131 {
cristybb503372010-05-27 20:51:26 +00004132 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004133 compress;
4134
4135 if (*option == '+')
4136 break;
4137 i++;
cristybb503372010-05-27 20:51:26 +00004138 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004139 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004140 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004141 argv[i]);
4142 if (compress < 0)
4143 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4144 argv[i]);
4145 break;
4146 }
cristy22879752009-10-25 23:55:40 +00004147 if (LocaleCompare("concurrent",option+1) == 0)
4148 break;
cristy3ed852e2009-09-05 21:47:34 +00004149 if (LocaleCompare("contrast",option+1) == 0)
4150 break;
4151 if (LocaleCompare("contrast-stretch",option+1) == 0)
4152 {
4153 i++;
cristybb503372010-05-27 20:51:26 +00004154 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004155 ThrowMogrifyException(OptionError,"MissingArgument",option);
4156 if (IsGeometry(argv[i]) == MagickFalse)
4157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4158 break;
4159 }
4160 if (LocaleCompare("convolve",option+1) == 0)
4161 {
cristyb6bd4ad2010-08-08 01:12:27 +00004162 KernelInfo
4163 *kernel_info;
4164
cristy3ed852e2009-09-05 21:47:34 +00004165 if (*option == '+')
4166 break;
4167 i++;
cristybb503372010-05-27 20:51:26 +00004168 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004169 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004170 kernel_info=AcquireKernelInfo(argv[i]);
4171 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004172 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004173 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004174 break;
4175 }
4176 if (LocaleCompare("crop",option+1) == 0)
4177 {
4178 if (*option == '+')
4179 break;
4180 i++;
cristybb503372010-05-27 20:51:26 +00004181 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004182 ThrowMogrifyException(OptionError,"MissingArgument",option);
4183 if (IsGeometry(argv[i]) == MagickFalse)
4184 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4185 break;
4186 }
4187 if (LocaleCompare("cycle",option+1) == 0)
4188 {
4189 if (*option == '+')
4190 break;
4191 i++;
cristybb503372010-05-27 20:51:26 +00004192 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004193 ThrowMogrifyException(OptionError,"MissingArgument",option);
4194 if (IsGeometry(argv[i]) == MagickFalse)
4195 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4196 break;
4197 }
4198 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4199 }
4200 case 'd':
4201 {
4202 if (LocaleCompare("decipher",option+1) == 0)
4203 {
4204 if (*option == '+')
4205 break;
4206 i++;
cristybb503372010-05-27 20:51:26 +00004207 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004208 ThrowMogrifyException(OptionError,"MissingArgument",option);
4209 break;
4210 }
4211 if (LocaleCompare("deconstruct",option+1) == 0)
4212 break;
4213 if (LocaleCompare("debug",option+1) == 0)
4214 {
cristybb503372010-05-27 20:51:26 +00004215 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004216 event;
4217
4218 if (*option == '+')
4219 break;
4220 i++;
cristybb503372010-05-27 20:51:26 +00004221 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004222 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004223 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004224 if (event < 0)
4225 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4226 argv[i]);
4227 (void) SetLogEventMask(argv[i]);
4228 break;
4229 }
4230 if (LocaleCompare("define",option+1) == 0)
4231 {
4232 i++;
cristybb503372010-05-27 20:51:26 +00004233 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004234 ThrowMogrifyException(OptionError,"MissingArgument",option);
4235 if (*option == '+')
4236 {
4237 const char
4238 *define;
4239
4240 define=GetImageOption(image_info,argv[i]);
4241 if (define == (const char *) NULL)
4242 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4243 break;
4244 }
4245 break;
4246 }
4247 if (LocaleCompare("delay",option+1) == 0)
4248 {
4249 if (*option == '+')
4250 break;
4251 i++;
cristybb503372010-05-27 20:51:26 +00004252 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004253 ThrowMogrifyException(OptionError,"MissingArgument",option);
4254 if (IsGeometry(argv[i]) == MagickFalse)
4255 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4256 break;
4257 }
cristyecb10ff2011-03-22 13:14:03 +00004258 if (LocaleCompare("delete",option+1) == 0)
4259 {
4260 if (*option == '+')
4261 break;
4262 i++;
4263 if (i == (ssize_t) (argc-1))
4264 ThrowMogrifyException(OptionError,"MissingArgument",option);
4265 if (IsGeometry(argv[i]) == MagickFalse)
4266 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4267 break;
4268 }
cristy3ed852e2009-09-05 21:47:34 +00004269 if (LocaleCompare("density",option+1) == 0)
4270 {
4271 if (*option == '+')
4272 break;
4273 i++;
cristybb503372010-05-27 20:51:26 +00004274 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004275 ThrowMogrifyException(OptionError,"MissingArgument",option);
4276 if (IsGeometry(argv[i]) == MagickFalse)
4277 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4278 break;
4279 }
4280 if (LocaleCompare("depth",option+1) == 0)
4281 {
4282 if (*option == '+')
4283 break;
4284 i++;
cristybb503372010-05-27 20:51:26 +00004285 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004286 ThrowMogrifyException(OptionError,"MissingArgument",option);
4287 if (IsGeometry(argv[i]) == MagickFalse)
4288 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4289 break;
4290 }
4291 if (LocaleCompare("deskew",option+1) == 0)
4292 {
4293 if (*option == '+')
4294 break;
4295 i++;
cristybb503372010-05-27 20:51:26 +00004296 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004297 ThrowMogrifyException(OptionError,"MissingArgument",option);
4298 if (IsGeometry(argv[i]) == MagickFalse)
4299 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4300 break;
4301 }
4302 if (LocaleCompare("despeckle",option+1) == 0)
4303 break;
4304 if (LocaleCompare("dft",option+1) == 0)
4305 break;
cristyc9b12952010-03-28 01:12:28 +00004306 if (LocaleCompare("direction",option+1) == 0)
4307 {
cristybb503372010-05-27 20:51:26 +00004308 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004309 direction;
4310
4311 if (*option == '+')
4312 break;
4313 i++;
cristybb503372010-05-27 20:51:26 +00004314 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004315 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004316 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00004317 argv[i]);
4318 if (direction < 0)
4319 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4320 argv[i]);
4321 break;
4322 }
cristy3ed852e2009-09-05 21:47:34 +00004323 if (LocaleCompare("display",option+1) == 0)
4324 {
4325 if (*option == '+')
4326 break;
4327 i++;
cristybb503372010-05-27 20:51:26 +00004328 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004329 ThrowMogrifyException(OptionError,"MissingArgument",option);
4330 break;
4331 }
4332 if (LocaleCompare("dispose",option+1) == 0)
4333 {
cristybb503372010-05-27 20:51:26 +00004334 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004335 dispose;
4336
4337 if (*option == '+')
4338 break;
4339 i++;
cristybb503372010-05-27 20:51:26 +00004340 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004341 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004342 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004343 if (dispose < 0)
4344 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4345 argv[i]);
4346 break;
4347 }
4348 if (LocaleCompare("distort",option+1) == 0)
4349 {
cristybb503372010-05-27 20:51:26 +00004350 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004351 op;
4352
4353 i++;
cristybb503372010-05-27 20:51:26 +00004354 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004355 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004356 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004357 if (op < 0)
4358 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4359 argv[i]);
4360 i++;
cristybb503372010-05-27 20:51:26 +00004361 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004362 ThrowMogrifyException(OptionError,"MissingArgument",option);
4363 break;
4364 }
4365 if (LocaleCompare("dither",option+1) == 0)
4366 {
cristybb503372010-05-27 20:51:26 +00004367 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004368 method;
4369
4370 if (*option == '+')
4371 break;
4372 i++;
cristybb503372010-05-27 20:51:26 +00004373 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004374 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004375 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004376 if (method < 0)
4377 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4378 argv[i]);
4379 break;
4380 }
4381 if (LocaleCompare("draw",option+1) == 0)
4382 {
4383 if (*option == '+')
4384 break;
4385 i++;
cristybb503372010-05-27 20:51:26 +00004386 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004387 ThrowMogrifyException(OptionError,"MissingArgument",option);
4388 break;
4389 }
cristyecb10ff2011-03-22 13:14:03 +00004390 if (LocaleCompare("duplicate",option+1) == 0)
4391 {
4392 if (*option == '+')
4393 break;
4394 i++;
4395 if (i == (ssize_t) (argc-1))
4396 ThrowMogrifyException(OptionError,"MissingArgument",option);
4397 if (IsGeometry(argv[i]) == MagickFalse)
4398 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4399 break;
4400 }
cristy22879752009-10-25 23:55:40 +00004401 if (LocaleCompare("duration",option+1) == 0)
4402 {
4403 if (*option == '+')
4404 break;
4405 i++;
cristybb503372010-05-27 20:51:26 +00004406 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004407 ThrowMogrifyException(OptionError,"MissingArgument",option);
4408 if (IsGeometry(argv[i]) == MagickFalse)
4409 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4410 break;
4411 }
cristy3ed852e2009-09-05 21:47:34 +00004412 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4413 }
4414 case 'e':
4415 {
4416 if (LocaleCompare("edge",option+1) == 0)
4417 {
4418 if (*option == '+')
4419 break;
4420 i++;
cristybb503372010-05-27 20:51:26 +00004421 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004422 ThrowMogrifyException(OptionError,"MissingArgument",option);
4423 if (IsGeometry(argv[i]) == MagickFalse)
4424 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4425 break;
4426 }
4427 if (LocaleCompare("emboss",option+1) == 0)
4428 {
4429 if (*option == '+')
4430 break;
4431 i++;
cristybb503372010-05-27 20:51:26 +00004432 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004433 ThrowMogrifyException(OptionError,"MissingArgument",option);
4434 if (IsGeometry(argv[i]) == MagickFalse)
4435 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4436 break;
4437 }
4438 if (LocaleCompare("encipher",option+1) == 0)
4439 {
4440 if (*option == '+')
4441 break;
4442 i++;
cristybb503372010-05-27 20:51:26 +00004443 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004444 ThrowMogrifyException(OptionError,"MissingArgument",option);
4445 break;
4446 }
4447 if (LocaleCompare("encoding",option+1) == 0)
4448 {
4449 if (*option == '+')
4450 break;
4451 i++;
cristybb503372010-05-27 20:51:26 +00004452 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004453 ThrowMogrifyException(OptionError,"MissingArgument",option);
4454 break;
4455 }
4456 if (LocaleCompare("endian",option+1) == 0)
4457 {
cristybb503372010-05-27 20:51:26 +00004458 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004459 endian;
4460
4461 if (*option == '+')
4462 break;
4463 i++;
cristybb503372010-05-27 20:51:26 +00004464 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004465 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004466 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004467 if (endian < 0)
4468 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4469 argv[i]);
4470 break;
4471 }
4472 if (LocaleCompare("enhance",option+1) == 0)
4473 break;
4474 if (LocaleCompare("equalize",option+1) == 0)
4475 break;
4476 if (LocaleCompare("evaluate",option+1) == 0)
4477 {
cristybb503372010-05-27 20:51:26 +00004478 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004479 op;
4480
4481 if (*option == '+')
4482 break;
4483 i++;
cristybb503372010-05-27 20:51:26 +00004484 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004485 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004486 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004487 if (op < 0)
4488 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4489 argv[i]);
4490 i++;
cristybb503372010-05-27 20:51:26 +00004491 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004492 ThrowMogrifyException(OptionError,"MissingArgument",option);
4493 if (IsGeometry(argv[i]) == MagickFalse)
4494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4495 break;
4496 }
cristyd18ae7c2010-03-07 17:39:52 +00004497 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4498 {
cristybb503372010-05-27 20:51:26 +00004499 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004500 op;
4501
4502 if (*option == '+')
4503 break;
4504 i++;
cristybb503372010-05-27 20:51:26 +00004505 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004506 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004507 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00004508 if (op < 0)
4509 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4510 argv[i]);
4511 break;
4512 }
cristy3ed852e2009-09-05 21:47:34 +00004513 if (LocaleCompare("extent",option+1) == 0)
4514 {
4515 if (*option == '+')
4516 break;
4517 i++;
cristybb503372010-05-27 20:51:26 +00004518 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004519 ThrowMogrifyException(OptionError,"MissingArgument",option);
4520 if (IsGeometry(argv[i]) == MagickFalse)
4521 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4522 break;
4523 }
4524 if (LocaleCompare("extract",option+1) == 0)
4525 {
4526 if (*option == '+')
4527 break;
4528 i++;
cristybb503372010-05-27 20:51:26 +00004529 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004530 ThrowMogrifyException(OptionError,"MissingArgument",option);
4531 if (IsGeometry(argv[i]) == MagickFalse)
4532 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4533 break;
4534 }
4535 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4536 }
4537 case 'f':
4538 {
4539 if (LocaleCompare("family",option+1) == 0)
4540 {
4541 if (*option == '+')
4542 break;
4543 i++;
cristybb503372010-05-27 20:51:26 +00004544 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004545 ThrowMogrifyException(OptionError,"MissingArgument",option);
4546 break;
4547 }
4548 if (LocaleCompare("fill",option+1) == 0)
4549 {
4550 if (*option == '+')
4551 break;
4552 i++;
cristybb503372010-05-27 20:51:26 +00004553 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004554 ThrowMogrifyException(OptionError,"MissingArgument",option);
4555 break;
4556 }
4557 if (LocaleCompare("filter",option+1) == 0)
4558 {
cristybb503372010-05-27 20:51:26 +00004559 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004560 filter;
4561
4562 if (*option == '+')
4563 break;
4564 i++;
cristybb503372010-05-27 20:51:26 +00004565 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004566 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004567 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004568 if (filter < 0)
4569 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4570 argv[i]);
4571 break;
4572 }
4573 if (LocaleCompare("flatten",option+1) == 0)
4574 break;
4575 if (LocaleCompare("flip",option+1) == 0)
4576 break;
4577 if (LocaleCompare("flop",option+1) == 0)
4578 break;
4579 if (LocaleCompare("floodfill",option+1) == 0)
4580 {
4581 if (*option == '+')
4582 break;
4583 i++;
cristybb503372010-05-27 20:51:26 +00004584 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004585 ThrowMogrifyException(OptionError,"MissingArgument",option);
4586 if (IsGeometry(argv[i]) == MagickFalse)
4587 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4588 i++;
cristybb503372010-05-27 20:51:26 +00004589 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004590 ThrowMogrifyException(OptionError,"MissingArgument",option);
4591 break;
4592 }
4593 if (LocaleCompare("font",option+1) == 0)
4594 {
4595 if (*option == '+')
4596 break;
4597 i++;
cristybb503372010-05-27 20:51:26 +00004598 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 break;
4601 }
4602 if (LocaleCompare("format",option+1) == 0)
4603 {
4604 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4605 (void) CloneString(&format,(char *) NULL);
4606 if (*option == '+')
4607 break;
4608 i++;
cristybb503372010-05-27 20:51:26 +00004609 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004610 ThrowMogrifyException(OptionError,"MissingArgument",option);
4611 (void) CloneString(&format,argv[i]);
4612 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4613 (void) ConcatenateMagickString(image_info->filename,":",
4614 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00004615 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00004616 if (*image_info->magick == '\0')
4617 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4618 format);
4619 break;
4620 }
4621 if (LocaleCompare("frame",option+1) == 0)
4622 {
4623 if (*option == '+')
4624 break;
4625 i++;
cristybb503372010-05-27 20:51:26 +00004626 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004627 ThrowMogrifyException(OptionError,"MissingArgument",option);
4628 if (IsGeometry(argv[i]) == MagickFalse)
4629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4630 break;
4631 }
4632 if (LocaleCompare("function",option+1) == 0)
4633 {
cristybb503372010-05-27 20:51:26 +00004634 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004635 op;
4636
4637 if (*option == '+')
4638 break;
4639 i++;
cristybb503372010-05-27 20:51:26 +00004640 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004641 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004642 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004643 if (op < 0)
4644 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4645 i++;
cristybb503372010-05-27 20:51:26 +00004646 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004647 ThrowMogrifyException(OptionError,"MissingArgument",option);
4648 break;
4649 }
4650 if (LocaleCompare("fuzz",option+1) == 0)
4651 {
4652 if (*option == '+')
4653 break;
4654 i++;
cristybb503372010-05-27 20:51:26 +00004655 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004656 ThrowMogrifyException(OptionError,"MissingArgument",option);
4657 if (IsGeometry(argv[i]) == MagickFalse)
4658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4659 break;
4660 }
4661 if (LocaleCompare("fx",option+1) == 0)
4662 {
4663 if (*option == '+')
4664 break;
4665 i++;
cristybb503372010-05-27 20:51:26 +00004666 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004667 ThrowMogrifyException(OptionError,"MissingArgument",option);
4668 break;
4669 }
4670 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4671 }
4672 case 'g':
4673 {
4674 if (LocaleCompare("gamma",option+1) == 0)
4675 {
4676 i++;
cristybb503372010-05-27 20:51:26 +00004677 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004678 ThrowMogrifyException(OptionError,"MissingArgument",option);
4679 if (IsGeometry(argv[i]) == MagickFalse)
4680 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4681 break;
4682 }
4683 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4684 (LocaleCompare("gaussian",option+1) == 0))
4685 {
4686 i++;
cristybb503372010-05-27 20:51:26 +00004687 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004688 ThrowMogrifyException(OptionError,"MissingArgument",option);
4689 if (IsGeometry(argv[i]) == MagickFalse)
4690 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4691 break;
4692 }
4693 if (LocaleCompare("geometry",option+1) == 0)
4694 {
4695 if (*option == '+')
4696 break;
4697 i++;
cristybb503372010-05-27 20:51:26 +00004698 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004699 ThrowMogrifyException(OptionError,"MissingArgument",option);
4700 if (IsGeometry(argv[i]) == MagickFalse)
4701 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4702 break;
4703 }
4704 if (LocaleCompare("gravity",option+1) == 0)
4705 {
cristybb503372010-05-27 20:51:26 +00004706 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004707 gravity;
4708
4709 if (*option == '+')
4710 break;
4711 i++;
cristybb503372010-05-27 20:51:26 +00004712 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004713 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004714 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004715 if (gravity < 0)
4716 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4717 argv[i]);
4718 break;
4719 }
4720 if (LocaleCompare("green-primary",option+1) == 0)
4721 {
4722 if (*option == '+')
4723 break;
4724 i++;
cristybb503372010-05-27 20:51:26 +00004725 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004726 ThrowMogrifyException(OptionError,"MissingArgument",option);
4727 if (IsGeometry(argv[i]) == MagickFalse)
4728 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4729 break;
4730 }
4731 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4732 }
4733 case 'h':
4734 {
4735 if (LocaleCompare("hald-clut",option+1) == 0)
4736 break;
4737 if ((LocaleCompare("help",option+1) == 0) ||
4738 (LocaleCompare("-help",option+1) == 0))
4739 return(MogrifyUsage());
4740 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4741 }
4742 case 'i':
4743 {
4744 if (LocaleCompare("identify",option+1) == 0)
4745 break;
4746 if (LocaleCompare("idft",option+1) == 0)
4747 break;
4748 if (LocaleCompare("implode",option+1) == 0)
4749 {
4750 if (*option == '+')
4751 break;
4752 i++;
cristybb503372010-05-27 20:51:26 +00004753 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004754 ThrowMogrifyException(OptionError,"MissingArgument",option);
4755 if (IsGeometry(argv[i]) == MagickFalse)
4756 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4757 break;
4758 }
4759 if (LocaleCompare("intent",option+1) == 0)
4760 {
cristybb503372010-05-27 20:51:26 +00004761 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004762 intent;
4763
4764 if (*option == '+')
4765 break;
4766 i++;
cristybb503372010-05-27 20:51:26 +00004767 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004768 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004769 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004770 if (intent < 0)
4771 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4772 argv[i]);
4773 break;
4774 }
4775 if (LocaleCompare("interlace",option+1) == 0)
4776 {
cristybb503372010-05-27 20:51:26 +00004777 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004778 interlace;
4779
4780 if (*option == '+')
4781 break;
4782 i++;
cristybb503372010-05-27 20:51:26 +00004783 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004784 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004785 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004786 argv[i]);
4787 if (interlace < 0)
4788 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4789 argv[i]);
4790 break;
4791 }
cristyb32b90a2009-09-07 21:45:48 +00004792 if (LocaleCompare("interline-spacing",option+1) == 0)
4793 {
4794 if (*option == '+')
4795 break;
4796 i++;
cristybb503372010-05-27 20:51:26 +00004797 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00004798 ThrowMogrifyException(OptionError,"MissingArgument",option);
4799 if (IsGeometry(argv[i]) == MagickFalse)
4800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4801 break;
4802 }
cristy3ed852e2009-09-05 21:47:34 +00004803 if (LocaleCompare("interpolate",option+1) == 0)
4804 {
cristybb503372010-05-27 20:51:26 +00004805 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004806 interpolate;
4807
4808 if (*option == '+')
4809 break;
4810 i++;
cristybb503372010-05-27 20:51:26 +00004811 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004812 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004813 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004814 argv[i]);
4815 if (interpolate < 0)
4816 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4817 argv[i]);
4818 break;
4819 }
4820 if (LocaleCompare("interword-spacing",option+1) == 0)
4821 {
4822 if (*option == '+')
4823 break;
4824 i++;
cristybb503372010-05-27 20:51:26 +00004825 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004826 ThrowMogrifyException(OptionError,"MissingArgument",option);
4827 if (IsGeometry(argv[i]) == MagickFalse)
4828 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4829 break;
4830 }
4831 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4832 }
4833 case 'k':
4834 {
4835 if (LocaleCompare("kerning",option+1) == 0)
4836 {
4837 if (*option == '+')
4838 break;
4839 i++;
cristybb503372010-05-27 20:51:26 +00004840 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004841 ThrowMogrifyException(OptionError,"MissingArgument",option);
4842 if (IsGeometry(argv[i]) == MagickFalse)
4843 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4844 break;
4845 }
4846 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4847 }
4848 case 'l':
4849 {
4850 if (LocaleCompare("label",option+1) == 0)
4851 {
4852 if (*option == '+')
4853 break;
4854 i++;
cristybb503372010-05-27 20:51:26 +00004855 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004856 ThrowMogrifyException(OptionError,"MissingArgument",option);
4857 break;
4858 }
4859 if (LocaleCompare("lat",option+1) == 0)
4860 {
4861 if (*option == '+')
4862 break;
4863 i++;
cristybb503372010-05-27 20:51:26 +00004864 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004865 ThrowMogrifyException(OptionError,"MissingArgument",option);
4866 if (IsGeometry(argv[i]) == MagickFalse)
4867 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4868 }
4869 if (LocaleCompare("layers",option+1) == 0)
4870 {
cristybb503372010-05-27 20:51:26 +00004871 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004872 type;
4873
4874 if (*option == '+')
4875 break;
4876 i++;
cristybb503372010-05-27 20:51:26 +00004877 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004878 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004879 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004880 if (type < 0)
4881 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4882 argv[i]);
4883 break;
4884 }
4885 if (LocaleCompare("level",option+1) == 0)
4886 {
4887 i++;
cristybb503372010-05-27 20:51:26 +00004888 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004889 ThrowMogrifyException(OptionError,"MissingArgument",option);
4890 if (IsGeometry(argv[i]) == MagickFalse)
4891 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4892 break;
4893 }
4894 if (LocaleCompare("level-colors",option+1) == 0)
4895 {
4896 i++;
cristybb503372010-05-27 20:51:26 +00004897 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004898 ThrowMogrifyException(OptionError,"MissingArgument",option);
4899 break;
4900 }
4901 if (LocaleCompare("linewidth",option+1) == 0)
4902 {
4903 if (*option == '+')
4904 break;
4905 i++;
cristybb503372010-05-27 20:51:26 +00004906 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004907 ThrowMogrifyException(OptionError,"MissingArgument",option);
4908 if (IsGeometry(argv[i]) == MagickFalse)
4909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4910 break;
4911 }
4912 if (LocaleCompare("limit",option+1) == 0)
4913 {
4914 char
4915 *p;
4916
4917 double
4918 value;
4919
cristybb503372010-05-27 20:51:26 +00004920 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004921 resource;
4922
4923 if (*option == '+')
4924 break;
4925 i++;
cristybb503372010-05-27 20:51:26 +00004926 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004927 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004928 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004929 argv[i]);
4930 if (resource < 0)
4931 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4932 argv[i]);
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);
cristyc1acd842011-05-19 23:05:47 +00004936 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00004937 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00004938 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4940 break;
4941 }
4942 if (LocaleCompare("liquid-rescale",option+1) == 0)
4943 {
4944 i++;
cristybb503372010-05-27 20:51:26 +00004945 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004946 ThrowMogrifyException(OptionError,"MissingArgument",option);
4947 if (IsGeometry(argv[i]) == MagickFalse)
4948 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4949 break;
4950 }
4951 if (LocaleCompare("list",option+1) == 0)
4952 {
cristybb503372010-05-27 20:51:26 +00004953 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004954 list;
4955
4956 if (*option == '+')
4957 break;
4958 i++;
cristybb503372010-05-27 20:51:26 +00004959 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004960 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004961 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004962 if (list < 0)
4963 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00004964 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00004965 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00004966 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00004967 }
4968 if (LocaleCompare("log",option+1) == 0)
4969 {
4970 if (*option == '+')
4971 break;
4972 i++;
cristybb503372010-05-27 20:51:26 +00004973 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00004974 (strchr(argv[i],'%') == (char *) NULL))
4975 ThrowMogrifyException(OptionError,"MissingArgument",option);
4976 break;
4977 }
4978 if (LocaleCompare("loop",option+1) == 0)
4979 {
4980 if (*option == '+')
4981 break;
4982 i++;
cristybb503372010-05-27 20:51:26 +00004983 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004984 ThrowMogrifyException(OptionError,"MissingArgument",option);
4985 if (IsGeometry(argv[i]) == MagickFalse)
4986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4987 break;
4988 }
4989 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4990 }
4991 case 'm':
4992 {
4993 if (LocaleCompare("map",option+1) == 0)
4994 {
4995 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4996 if (*option == '+')
4997 break;
4998 i++;
cristybb503372010-05-27 20:51:26 +00004999 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005000 ThrowMogrifyException(OptionError,"MissingArgument",option);
5001 break;
5002 }
5003 if (LocaleCompare("mask",option+1) == 0)
5004 {
5005 if (*option == '+')
5006 break;
5007 i++;
cristybb503372010-05-27 20:51:26 +00005008 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005009 ThrowMogrifyException(OptionError,"MissingArgument",option);
5010 break;
5011 }
5012 if (LocaleCompare("matte",option+1) == 0)
5013 break;
5014 if (LocaleCompare("mattecolor",option+1) == 0)
5015 {
5016 if (*option == '+')
5017 break;
5018 i++;
cristybb503372010-05-27 20:51:26 +00005019 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005020 ThrowMogrifyException(OptionError,"MissingArgument",option);
5021 break;
5022 }
cristyf40785b2010-03-06 02:27:27 +00005023 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005024 break;
cristyf40785b2010-03-06 02:27:27 +00005025 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005026 break;
cristy3ed852e2009-09-05 21:47:34 +00005027 if (LocaleCompare("modulate",option+1) == 0)
5028 {
5029 if (*option == '+')
5030 break;
5031 i++;
cristybb503372010-05-27 20:51:26 +00005032 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005033 ThrowMogrifyException(OptionError,"MissingArgument",option);
5034 if (IsGeometry(argv[i]) == MagickFalse)
5035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5036 break;
5037 }
5038 if (LocaleCompare("median",option+1) == 0)
5039 {
5040 if (*option == '+')
5041 break;
5042 i++;
cristybb503372010-05-27 20:51:26 +00005043 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005044 ThrowMogrifyException(OptionError,"MissingArgument",option);
5045 if (IsGeometry(argv[i]) == MagickFalse)
5046 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5047 break;
5048 }
cristy69ec32d2011-02-27 23:57:09 +00005049 if (LocaleCompare("mode",option+1) == 0)
5050 {
5051 if (*option == '+')
5052 break;
5053 i++;
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,"MissingArgument",option);
5056 if (IsGeometry(argv[i]) == MagickFalse)
5057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5058 break;
5059 }
cristy3ed852e2009-09-05 21:47:34 +00005060 if (LocaleCompare("monitor",option+1) == 0)
5061 break;
5062 if (LocaleCompare("monochrome",option+1) == 0)
5063 break;
5064 if (LocaleCompare("morph",option+1) == 0)
5065 {
5066 if (*option == '+')
5067 break;
5068 i++;
cristybb503372010-05-27 20:51:26 +00005069 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005070 ThrowMogrifyException(OptionError,"MissingArgument",option);
5071 if (IsGeometry(argv[i]) == MagickFalse)
5072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5073 break;
5074 }
anthony29188a82010-01-22 10:12:34 +00005075 if (LocaleCompare("morphology",option+1) == 0)
5076 {
anthony29188a82010-01-22 10:12:34 +00005077 char
5078 token[MaxTextExtent];
5079
cristyb6bd4ad2010-08-08 01:12:27 +00005080 KernelInfo
5081 *kernel_info;
5082
5083 ssize_t
5084 op;
5085
anthony29188a82010-01-22 10:12:34 +00005086 i++;
cristybb503372010-05-27 20:51:26 +00005087 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005088 ThrowMogrifyException(OptionError,"MissingArgument",option);
5089 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00005090 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00005091 if (op < 0)
5092 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005093 token);
anthony29188a82010-01-22 10:12:34 +00005094 i++;
cristybb503372010-05-27 20:51:26 +00005095 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005096 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005097 kernel_info=AcquireKernelInfo(argv[i]);
5098 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005100 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005101 break;
5102 }
cristy3ed852e2009-09-05 21:47:34 +00005103 if (LocaleCompare("mosaic",option+1) == 0)
5104 break;
5105 if (LocaleCompare("motion-blur",option+1) == 0)
5106 {
5107 if (*option == '+')
5108 break;
5109 i++;
cristybb503372010-05-27 20:51:26 +00005110 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005111 ThrowMogrifyException(OptionError,"MissingArgument",option);
5112 if (IsGeometry(argv[i]) == MagickFalse)
5113 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5114 break;
5115 }
5116 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5117 }
5118 case 'n':
5119 {
5120 if (LocaleCompare("negate",option+1) == 0)
5121 break;
5122 if (LocaleCompare("noise",option+1) == 0)
5123 {
5124 i++;
cristybb503372010-05-27 20:51:26 +00005125 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005126 ThrowMogrifyException(OptionError,"MissingArgument",option);
5127 if (*option == '+')
5128 {
cristybb503372010-05-27 20:51:26 +00005129 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005130 noise;
5131
cristy042ee782011-04-22 18:48:30 +00005132 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005133 if (noise < 0)
5134 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5135 argv[i]);
5136 break;
5137 }
5138 if (IsGeometry(argv[i]) == MagickFalse)
5139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5140 break;
5141 }
5142 if (LocaleCompare("noop",option+1) == 0)
5143 break;
5144 if (LocaleCompare("normalize",option+1) == 0)
5145 break;
5146 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5147 }
5148 case 'o':
5149 {
5150 if (LocaleCompare("opaque",option+1) == 0)
5151 {
cristy3ed852e2009-09-05 21:47:34 +00005152 i++;
cristybb503372010-05-27 20:51:26 +00005153 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005154 ThrowMogrifyException(OptionError,"MissingArgument",option);
5155 break;
5156 }
5157 if (LocaleCompare("ordered-dither",option+1) == 0)
5158 {
5159 if (*option == '+')
5160 break;
5161 i++;
cristybb503372010-05-27 20:51:26 +00005162 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005163 ThrowMogrifyException(OptionError,"MissingArgument",option);
5164 break;
5165 }
5166 if (LocaleCompare("orient",option+1) == 0)
5167 {
cristybb503372010-05-27 20:51:26 +00005168 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005169 orientation;
5170
5171 orientation=UndefinedOrientation;
5172 if (*option == '+')
5173 break;
5174 i++;
cristybb503372010-05-27 20:51:26 +00005175 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005176 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005177 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005178 argv[i]);
5179 if (orientation < 0)
5180 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5181 argv[i]);
5182 break;
5183 }
5184 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5185 }
5186 case 'p':
5187 {
5188 if (LocaleCompare("page",option+1) == 0)
5189 {
5190 if (*option == '+')
5191 break;
5192 i++;
cristybb503372010-05-27 20:51:26 +00005193 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005194 ThrowMogrifyException(OptionError,"MissingArgument",option);
5195 break;
5196 }
5197 if (LocaleCompare("paint",option+1) == 0)
5198 {
5199 if (*option == '+')
5200 break;
5201 i++;
cristybb503372010-05-27 20:51:26 +00005202 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005203 ThrowMogrifyException(OptionError,"MissingArgument",option);
5204 if (IsGeometry(argv[i]) == MagickFalse)
5205 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5206 break;
5207 }
5208 if (LocaleCompare("path",option+1) == 0)
5209 {
5210 (void) CloneString(&path,(char *) NULL);
5211 if (*option == '+')
5212 break;
5213 i++;
cristybb503372010-05-27 20:51:26 +00005214 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005215 ThrowMogrifyException(OptionError,"MissingArgument",option);
5216 (void) CloneString(&path,argv[i]);
5217 break;
5218 }
5219 if (LocaleCompare("pointsize",option+1) == 0)
5220 {
5221 if (*option == '+')
5222 break;
5223 i++;
cristybb503372010-05-27 20:51:26 +00005224 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005225 ThrowMogrifyException(OptionError,"MissingArgument",option);
5226 if (IsGeometry(argv[i]) == MagickFalse)
5227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5228 break;
5229 }
5230 if (LocaleCompare("polaroid",option+1) == 0)
5231 {
5232 if (*option == '+')
5233 break;
5234 i++;
cristybb503372010-05-27 20:51:26 +00005235 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005236 ThrowMogrifyException(OptionError,"MissingArgument",option);
5237 if (IsGeometry(argv[i]) == MagickFalse)
5238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5239 break;
5240 }
5241 if (LocaleCompare("posterize",option+1) == 0)
5242 {
5243 if (*option == '+')
5244 break;
5245 i++;
cristybb503372010-05-27 20:51:26 +00005246 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005247 ThrowMogrifyException(OptionError,"MissingArgument",option);
5248 if (IsGeometry(argv[i]) == MagickFalse)
5249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5250 break;
5251 }
cristye7f51092010-01-17 00:39:37 +00005252 if (LocaleCompare("precision",option+1) == 0)
5253 {
5254 if (*option == '+')
5255 break;
5256 i++;
cristybb503372010-05-27 20:51:26 +00005257 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005258 ThrowMogrifyException(OptionError,"MissingArgument",option);
5259 if (IsGeometry(argv[i]) == MagickFalse)
5260 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5261 break;
5262 }
cristy3ed852e2009-09-05 21:47:34 +00005263 if (LocaleCompare("print",option+1) == 0)
5264 {
5265 if (*option == '+')
5266 break;
5267 i++;
cristybb503372010-05-27 20:51:26 +00005268 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005269 ThrowMogrifyException(OptionError,"MissingArgument",option);
5270 break;
5271 }
5272 if (LocaleCompare("process",option+1) == 0)
5273 {
5274 if (*option == '+')
5275 break;
5276 i++;
cristybb503372010-05-27 20:51:26 +00005277 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005278 ThrowMogrifyException(OptionError,"MissingArgument",option);
5279 break;
5280 }
5281 if (LocaleCompare("profile",option+1) == 0)
5282 {
5283 i++;
cristybb503372010-05-27 20:51:26 +00005284 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005285 ThrowMogrifyException(OptionError,"MissingArgument",option);
5286 break;
5287 }
5288 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5289 }
5290 case 'q':
5291 {
5292 if (LocaleCompare("quality",option+1) == 0)
5293 {
5294 if (*option == '+')
5295 break;
5296 i++;
cristybb503372010-05-27 20:51:26 +00005297 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005298 ThrowMogrifyException(OptionError,"MissingArgument",option);
5299 if (IsGeometry(argv[i]) == MagickFalse)
5300 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5301 break;
5302 }
5303 if (LocaleCompare("quantize",option+1) == 0)
5304 {
cristybb503372010-05-27 20:51:26 +00005305 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005306 colorspace;
5307
5308 if (*option == '+')
5309 break;
5310 i++;
cristybb503372010-05-27 20:51:26 +00005311 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005312 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005313 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005314 argv[i]);
5315 if (colorspace < 0)
5316 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5317 argv[i]);
5318 break;
5319 }
5320 if (LocaleCompare("quiet",option+1) == 0)
5321 break;
5322 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5323 }
5324 case 'r':
5325 {
5326 if (LocaleCompare("radial-blur",option+1) == 0)
5327 {
5328 i++;
cristybb503372010-05-27 20:51:26 +00005329 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005330 ThrowMogrifyException(OptionError,"MissingArgument",option);
5331 if (IsGeometry(argv[i]) == MagickFalse)
5332 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5333 break;
5334 }
5335 if (LocaleCompare("raise",option+1) == 0)
5336 {
5337 i++;
cristybb503372010-05-27 20:51:26 +00005338 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005339 ThrowMogrifyException(OptionError,"MissingArgument",option);
5340 if (IsGeometry(argv[i]) == MagickFalse)
5341 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5342 break;
5343 }
5344 if (LocaleCompare("random-threshold",option+1) == 0)
5345 {
5346 if (*option == '+')
5347 break;
5348 i++;
cristybb503372010-05-27 20:51:26 +00005349 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005350 ThrowMogrifyException(OptionError,"MissingArgument",option);
5351 if (IsGeometry(argv[i]) == MagickFalse)
5352 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5353 break;
5354 }
cristye6365592010-04-02 17:31:23 +00005355 if (LocaleCompare("recolor",option+1) == 0)
5356 {
5357 if (*option == '+')
5358 break;
5359 i++;
cristybb503372010-05-27 20:51:26 +00005360 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005361 ThrowMogrifyException(OptionError,"MissingArgument",option);
5362 if (IsGeometry(argv[i]) == MagickFalse)
5363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5364 break;
5365 }
cristy3ed852e2009-09-05 21:47:34 +00005366 if (LocaleCompare("red-primary",option+1) == 0)
5367 {
5368 if (*option == '+')
5369 break;
5370 i++;
cristybb503372010-05-27 20:51:26 +00005371 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005372 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (IsGeometry(argv[i]) == MagickFalse)
5374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5375 }
cristy9f2083a2010-04-22 19:48:05 +00005376 if (LocaleCompare("regard-warnings",option+1) == 0)
5377 break;
cristy3ed852e2009-09-05 21:47:34 +00005378 if (LocaleCompare("region",option+1) == 0)
5379 {
5380 if (*option == '+')
5381 break;
5382 i++;
cristybb503372010-05-27 20:51:26 +00005383 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005384 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 if (IsGeometry(argv[i]) == MagickFalse)
5386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5387 break;
5388 }
cristyf0c78232010-03-15 12:53:40 +00005389 if (LocaleCompare("remap",option+1) == 0)
5390 {
5391 if (*option == '+')
5392 break;
5393 i++;
cristybb503372010-05-27 20:51:26 +00005394 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5396 break;
5397 }
cristy3ed852e2009-09-05 21:47:34 +00005398 if (LocaleCompare("render",option+1) == 0)
5399 break;
5400 if (LocaleCompare("repage",option+1) == 0)
5401 {
5402 if (*option == '+')
5403 break;
5404 i++;
cristybb503372010-05-27 20:51:26 +00005405 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005406 ThrowMogrifyException(OptionError,"MissingArgument",option);
5407 if (IsGeometry(argv[i]) == MagickFalse)
5408 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5409 break;
5410 }
5411 if (LocaleCompare("resample",option+1) == 0)
5412 {
5413 if (*option == '+')
5414 break;
5415 i++;
cristybb503372010-05-27 20:51:26 +00005416 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005417 ThrowMogrifyException(OptionError,"MissingArgument",option);
5418 if (IsGeometry(argv[i]) == MagickFalse)
5419 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5420 break;
5421 }
5422 if (LocaleCompare("resize",option+1) == 0)
5423 {
5424 if (*option == '+')
5425 break;
5426 i++;
cristybb503372010-05-27 20:51:26 +00005427 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005428 ThrowMogrifyException(OptionError,"MissingArgument",option);
5429 if (IsGeometry(argv[i]) == MagickFalse)
5430 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5431 break;
5432 }
cristyebbcfea2011-02-25 02:43:54 +00005433 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5434 {
5435 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5436 break;
5437 }
cristy3ed852e2009-09-05 21:47:34 +00005438 if (LocaleCompare("reverse",option+1) == 0)
5439 break;
5440 if (LocaleCompare("roll",option+1) == 0)
5441 {
5442 if (*option == '+')
5443 break;
5444 i++;
cristybb503372010-05-27 20:51:26 +00005445 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005446 ThrowMogrifyException(OptionError,"MissingArgument",option);
5447 if (IsGeometry(argv[i]) == MagickFalse)
5448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5449 break;
5450 }
5451 if (LocaleCompare("rotate",option+1) == 0)
5452 {
5453 i++;
cristybb503372010-05-27 20:51:26 +00005454 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005455 ThrowMogrifyException(OptionError,"MissingArgument",option);
5456 if (IsGeometry(argv[i]) == MagickFalse)
5457 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5458 break;
5459 }
5460 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5461 }
5462 case 's':
5463 {
5464 if (LocaleCompare("sample",option+1) == 0)
5465 {
5466 if (*option == '+')
5467 break;
5468 i++;
cristybb503372010-05-27 20:51:26 +00005469 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005470 ThrowMogrifyException(OptionError,"MissingArgument",option);
5471 if (IsGeometry(argv[i]) == MagickFalse)
5472 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5473 break;
5474 }
5475 if (LocaleCompare("sampling-factor",option+1) == 0)
5476 {
5477 if (*option == '+')
5478 break;
5479 i++;
cristybb503372010-05-27 20:51:26 +00005480 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005481 ThrowMogrifyException(OptionError,"MissingArgument",option);
5482 if (IsGeometry(argv[i]) == MagickFalse)
5483 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5484 break;
5485 }
5486 if (LocaleCompare("scale",option+1) == 0)
5487 {
5488 if (*option == '+')
5489 break;
5490 i++;
cristybb503372010-05-27 20:51:26 +00005491 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005492 ThrowMogrifyException(OptionError,"MissingArgument",option);
5493 if (IsGeometry(argv[i]) == MagickFalse)
5494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5495 break;
5496 }
5497 if (LocaleCompare("scene",option+1) == 0)
5498 {
5499 if (*option == '+')
5500 break;
5501 i++;
cristybb503372010-05-27 20:51:26 +00005502 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005503 ThrowMogrifyException(OptionError,"MissingArgument",option);
5504 if (IsGeometry(argv[i]) == MagickFalse)
5505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5506 break;
5507 }
5508 if (LocaleCompare("seed",option+1) == 0)
5509 {
5510 if (*option == '+')
5511 break;
5512 i++;
cristybb503372010-05-27 20:51:26 +00005513 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005514 ThrowMogrifyException(OptionError,"MissingArgument",option);
5515 if (IsGeometry(argv[i]) == MagickFalse)
5516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5517 break;
5518 }
5519 if (LocaleCompare("segment",option+1) == 0)
5520 {
5521 if (*option == '+')
5522 break;
5523 i++;
cristybb503372010-05-27 20:51:26 +00005524 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005525 ThrowMogrifyException(OptionError,"MissingArgument",option);
5526 if (IsGeometry(argv[i]) == MagickFalse)
5527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5528 break;
5529 }
5530 if (LocaleCompare("selective-blur",option+1) == 0)
5531 {
5532 i++;
cristybb503372010-05-27 20:51:26 +00005533 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005534 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 if (IsGeometry(argv[i]) == MagickFalse)
5536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537 break;
5538 }
5539 if (LocaleCompare("separate",option+1) == 0)
5540 break;
5541 if (LocaleCompare("sepia-tone",option+1) == 0)
5542 {
5543 if (*option == '+')
5544 break;
5545 i++;
cristybb503372010-05-27 20:51:26 +00005546 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005547 ThrowMogrifyException(OptionError,"MissingArgument",option);
5548 if (IsGeometry(argv[i]) == MagickFalse)
5549 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5550 break;
5551 }
5552 if (LocaleCompare("set",option+1) == 0)
5553 {
5554 i++;
cristybb503372010-05-27 20:51:26 +00005555 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5557 if (*option == '+')
5558 break;
5559 i++;
cristybb503372010-05-27 20:51:26 +00005560 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005561 ThrowMogrifyException(OptionError,"MissingArgument",option);
5562 break;
5563 }
5564 if (LocaleCompare("shade",option+1) == 0)
5565 {
5566 i++;
cristybb503372010-05-27 20:51:26 +00005567 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005568 ThrowMogrifyException(OptionError,"MissingArgument",option);
5569 if (IsGeometry(argv[i]) == MagickFalse)
5570 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5571 break;
5572 }
5573 if (LocaleCompare("shadow",option+1) == 0)
5574 {
5575 if (*option == '+')
5576 break;
5577 i++;
cristybb503372010-05-27 20:51:26 +00005578 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005579 ThrowMogrifyException(OptionError,"MissingArgument",option);
5580 if (IsGeometry(argv[i]) == MagickFalse)
5581 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5582 break;
5583 }
5584 if (LocaleCompare("sharpen",option+1) == 0)
5585 {
5586 i++;
cristybb503372010-05-27 20:51:26 +00005587 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005588 ThrowMogrifyException(OptionError,"MissingArgument",option);
5589 if (IsGeometry(argv[i]) == MagickFalse)
5590 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5591 break;
5592 }
5593 if (LocaleCompare("shave",option+1) == 0)
5594 {
5595 if (*option == '+')
5596 break;
5597 i++;
cristybb503372010-05-27 20:51:26 +00005598 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005599 ThrowMogrifyException(OptionError,"MissingArgument",option);
5600 if (IsGeometry(argv[i]) == MagickFalse)
5601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5602 break;
5603 }
5604 if (LocaleCompare("shear",option+1) == 0)
5605 {
5606 i++;
cristybb503372010-05-27 20:51:26 +00005607 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005608 ThrowMogrifyException(OptionError,"MissingArgument",option);
5609 if (IsGeometry(argv[i]) == MagickFalse)
5610 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5611 break;
5612 }
5613 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5614 {
5615 i++;
cristybb503372010-05-27 20:51:26 +00005616 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005617 ThrowMogrifyException(OptionError,"MissingArgument",option);
5618 if (IsGeometry(argv[i]) == MagickFalse)
5619 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5620 break;
5621 }
5622 if (LocaleCompare("size",option+1) == 0)
5623 {
5624 if (*option == '+')
5625 break;
5626 i++;
cristybb503372010-05-27 20:51:26 +00005627 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005628 ThrowMogrifyException(OptionError,"MissingArgument",option);
5629 if (IsGeometry(argv[i]) == MagickFalse)
5630 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631 break;
5632 }
5633 if (LocaleCompare("sketch",option+1) == 0)
5634 {
5635 if (*option == '+')
5636 break;
5637 i++;
cristybb503372010-05-27 20:51:26 +00005638 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005639 ThrowMogrifyException(OptionError,"MissingArgument",option);
5640 if (IsGeometry(argv[i]) == MagickFalse)
5641 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 break;
5643 }
cristy4285d782011-02-09 20:12:28 +00005644 if (LocaleCompare("smush",option+1) == 0)
5645 {
cristy4285d782011-02-09 20:12:28 +00005646 i++;
5647 if (i == (ssize_t) argc)
5648 ThrowMogrifyException(OptionError,"MissingArgument",option);
5649 if (IsGeometry(argv[i]) == MagickFalse)
5650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00005651 i++;
5652 break;
5653 }
cristy3ed852e2009-09-05 21:47:34 +00005654 if (LocaleCompare("solarize",option+1) == 0)
5655 {
5656 if (*option == '+')
5657 break;
5658 i++;
cristybb503372010-05-27 20:51:26 +00005659 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005660 ThrowMogrifyException(OptionError,"MissingArgument",option);
5661 if (IsGeometry(argv[i]) == MagickFalse)
5662 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5663 break;
5664 }
5665 if (LocaleCompare("sparse-color",option+1) == 0)
5666 {
cristybb503372010-05-27 20:51:26 +00005667 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005668 op;
5669
5670 i++;
cristybb503372010-05-27 20:51:26 +00005671 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005672 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005673 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005674 if (op < 0)
5675 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5676 argv[i]);
5677 i++;
cristybb503372010-05-27 20:51:26 +00005678 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005679 ThrowMogrifyException(OptionError,"MissingArgument",option);
5680 break;
5681 }
5682 if (LocaleCompare("spread",option+1) == 0)
5683 {
5684 if (*option == '+')
5685 break;
5686 i++;
cristybb503372010-05-27 20:51:26 +00005687 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005688 ThrowMogrifyException(OptionError,"MissingArgument",option);
5689 if (IsGeometry(argv[i]) == MagickFalse)
5690 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5691 break;
5692 }
cristy0834d642011-03-18 18:26:08 +00005693 if (LocaleCompare("statistic",option+1) == 0)
5694 {
5695 ssize_t
5696 op;
5697
5698 if (*option == '+')
5699 break;
5700 i++;
5701 if (i == (ssize_t) argc)
5702 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005703 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00005704 if (op < 0)
5705 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5706 argv[i]);
5707 i++;
5708 if (i == (ssize_t) (argc-1))
5709 ThrowMogrifyException(OptionError,"MissingArgument",option);
5710 if (IsGeometry(argv[i]) == MagickFalse)
5711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5712 break;
5713 }
cristy3ed852e2009-09-05 21:47:34 +00005714 if (LocaleCompare("stretch",option+1) == 0)
5715 {
cristybb503372010-05-27 20:51:26 +00005716 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005717 stretch;
5718
5719 if (*option == '+')
5720 break;
5721 i++;
cristybb503372010-05-27 20:51:26 +00005722 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005723 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005724 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005725 if (stretch < 0)
5726 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5727 argv[i]);
5728 break;
5729 }
5730 if (LocaleCompare("strip",option+1) == 0)
5731 break;
5732 if (LocaleCompare("stroke",option+1) == 0)
5733 {
5734 if (*option == '+')
5735 break;
5736 i++;
cristybb503372010-05-27 20:51:26 +00005737 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005738 ThrowMogrifyException(OptionError,"MissingArgument",option);
5739 break;
5740 }
5741 if (LocaleCompare("strokewidth",option+1) == 0)
5742 {
5743 if (*option == '+')
5744 break;
5745 i++;
cristybb503372010-05-27 20:51:26 +00005746 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005747 ThrowMogrifyException(OptionError,"MissingArgument",option);
5748 if (IsGeometry(argv[i]) == MagickFalse)
5749 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5750 break;
5751 }
5752 if (LocaleCompare("style",option+1) == 0)
5753 {
cristybb503372010-05-27 20:51:26 +00005754 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005755 style;
5756
5757 if (*option == '+')
5758 break;
5759 i++;
cristybb503372010-05-27 20:51:26 +00005760 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005761 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005762 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005763 if (style < 0)
5764 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5765 argv[i]);
5766 break;
5767 }
cristyecb10ff2011-03-22 13:14:03 +00005768 if (LocaleCompare("swap",option+1) == 0)
5769 {
5770 if (*option == '+')
5771 break;
5772 i++;
5773 if (i == (ssize_t) (argc-1))
5774 ThrowMogrifyException(OptionError,"MissingArgument",option);
5775 if (IsGeometry(argv[i]) == MagickFalse)
5776 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 break;
5778 }
cristy3ed852e2009-09-05 21:47:34 +00005779 if (LocaleCompare("swirl",option+1) == 0)
5780 {
5781 if (*option == '+')
5782 break;
5783 i++;
cristybb503372010-05-27 20:51:26 +00005784 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005785 ThrowMogrifyException(OptionError,"MissingArgument",option);
5786 if (IsGeometry(argv[i]) == MagickFalse)
5787 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5788 break;
5789 }
cristyd9a29192010-10-16 16:49:53 +00005790 if (LocaleCompare("synchronize",option+1) == 0)
5791 break;
cristy3ed852e2009-09-05 21:47:34 +00005792 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5793 }
5794 case 't':
5795 {
5796 if (LocaleCompare("taint",option+1) == 0)
5797 break;
5798 if (LocaleCompare("texture",option+1) == 0)
5799 {
5800 if (*option == '+')
5801 break;
5802 i++;
cristybb503372010-05-27 20:51:26 +00005803 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005804 ThrowMogrifyException(OptionError,"MissingArgument",option);
5805 break;
5806 }
5807 if (LocaleCompare("tile",option+1) == 0)
5808 {
5809 if (*option == '+')
5810 break;
5811 i++;
cristybb503372010-05-27 20:51:26 +00005812 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005813 ThrowMogrifyException(OptionError,"MissingArgument",option);
5814 break;
5815 }
5816 if (LocaleCompare("tile-offset",option+1) == 0)
5817 {
5818 if (*option == '+')
5819 break;
5820 i++;
cristybb503372010-05-27 20:51:26 +00005821 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5825 break;
5826 }
5827 if (LocaleCompare("tint",option+1) == 0)
5828 {
5829 if (*option == '+')
5830 break;
5831 i++;
cristybb503372010-05-27 20:51:26 +00005832 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005833 ThrowMogrifyException(OptionError,"MissingArgument",option);
5834 if (IsGeometry(argv[i]) == MagickFalse)
5835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5836 break;
5837 }
5838 if (LocaleCompare("transform",option+1) == 0)
5839 break;
5840 if (LocaleCompare("transpose",option+1) == 0)
5841 break;
5842 if (LocaleCompare("transverse",option+1) == 0)
5843 break;
5844 if (LocaleCompare("threshold",option+1) == 0)
5845 {
5846 if (*option == '+')
5847 break;
5848 i++;
cristybb503372010-05-27 20:51:26 +00005849 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005850 ThrowMogrifyException(OptionError,"MissingArgument",option);
5851 if (IsGeometry(argv[i]) == MagickFalse)
5852 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5853 break;
5854 }
5855 if (LocaleCompare("thumbnail",option+1) == 0)
5856 {
5857 if (*option == '+')
5858 break;
5859 i++;
cristybb503372010-05-27 20:51:26 +00005860 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005861 ThrowMogrifyException(OptionError,"MissingArgument",option);
5862 if (IsGeometry(argv[i]) == MagickFalse)
5863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5864 break;
5865 }
5866 if (LocaleCompare("transparent",option+1) == 0)
5867 {
5868 i++;
cristybb503372010-05-27 20:51:26 +00005869 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005870 ThrowMogrifyException(OptionError,"MissingArgument",option);
5871 break;
5872 }
5873 if (LocaleCompare("transparent-color",option+1) == 0)
5874 {
5875 if (*option == '+')
5876 break;
5877 i++;
cristybb503372010-05-27 20:51:26 +00005878 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 break;
5881 }
5882 if (LocaleCompare("treedepth",option+1) == 0)
5883 {
5884 if (*option == '+')
5885 break;
5886 i++;
cristybb503372010-05-27 20:51:26 +00005887 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005888 ThrowMogrifyException(OptionError,"MissingArgument",option);
5889 if (IsGeometry(argv[i]) == MagickFalse)
5890 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5891 break;
5892 }
5893 if (LocaleCompare("trim",option+1) == 0)
5894 break;
5895 if (LocaleCompare("type",option+1) == 0)
5896 {
cristybb503372010-05-27 20:51:26 +00005897 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005898 type;
5899
5900 if (*option == '+')
5901 break;
5902 i++;
cristybb503372010-05-27 20:51:26 +00005903 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005904 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005905 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005906 if (type < 0)
5907 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5908 argv[i]);
5909 break;
5910 }
5911 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5912 }
5913 case 'u':
5914 {
5915 if (LocaleCompare("undercolor",option+1) == 0)
5916 {
5917 if (*option == '+')
5918 break;
5919 i++;
cristybb503372010-05-27 20:51:26 +00005920 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005921 ThrowMogrifyException(OptionError,"MissingArgument",option);
5922 break;
5923 }
5924 if (LocaleCompare("unique-colors",option+1) == 0)
5925 break;
5926 if (LocaleCompare("units",option+1) == 0)
5927 {
cristybb503372010-05-27 20:51:26 +00005928 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005929 units;
5930
5931 if (*option == '+')
5932 break;
5933 i++;
cristybb503372010-05-27 20:51:26 +00005934 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005935 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005936 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005937 argv[i]);
5938 if (units < 0)
5939 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5940 argv[i]);
5941 break;
5942 }
5943 if (LocaleCompare("unsharp",option+1) == 0)
5944 {
5945 i++;
cristybb503372010-05-27 20:51:26 +00005946 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005947 ThrowMogrifyException(OptionError,"MissingArgument",option);
5948 if (IsGeometry(argv[i]) == MagickFalse)
5949 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5950 break;
5951 }
5952 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5953 }
5954 case 'v':
5955 {
5956 if (LocaleCompare("verbose",option+1) == 0)
5957 {
5958 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5959 break;
5960 }
5961 if ((LocaleCompare("version",option+1) == 0) ||
5962 (LocaleCompare("-version",option+1) == 0))
5963 {
cristyb51dff52011-05-19 16:55:47 +00005964 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00005965 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00005966 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5967 GetMagickCopyright());
5968 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5969 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00005970 break;
5971 }
5972 if (LocaleCompare("view",option+1) == 0)
5973 {
5974 if (*option == '+')
5975 break;
5976 i++;
cristybb503372010-05-27 20:51:26 +00005977 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005978 ThrowMogrifyException(OptionError,"MissingArgument",option);
5979 break;
5980 }
5981 if (LocaleCompare("vignette",option+1) == 0)
5982 {
5983 if (*option == '+')
5984 break;
5985 i++;
cristybb503372010-05-27 20:51:26 +00005986 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005987 ThrowMogrifyException(OptionError,"MissingArgument",option);
5988 if (IsGeometry(argv[i]) == MagickFalse)
5989 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5990 break;
5991 }
5992 if (LocaleCompare("virtual-pixel",option+1) == 0)
5993 {
cristybb503372010-05-27 20:51:26 +00005994 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005995 method;
5996
5997 if (*option == '+')
5998 break;
5999 i++;
cristybb503372010-05-27 20:51:26 +00006000 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006001 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00006002 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00006003 argv[i]);
6004 if (method < 0)
6005 ThrowMogrifyException(OptionError,
6006 "UnrecognizedVirtualPixelMethod",argv[i]);
6007 break;
6008 }
6009 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6010 }
6011 case 'w':
6012 {
6013 if (LocaleCompare("wave",option+1) == 0)
6014 {
6015 i++;
cristybb503372010-05-27 20:51:26 +00006016 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006017 ThrowMogrifyException(OptionError,"MissingArgument",option);
6018 if (IsGeometry(argv[i]) == MagickFalse)
6019 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6020 break;
6021 }
6022 if (LocaleCompare("weight",option+1) == 0)
6023 {
6024 if (*option == '+')
6025 break;
6026 i++;
cristybb503372010-05-27 20:51:26 +00006027 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006028 ThrowMogrifyException(OptionError,"MissingArgument",option);
6029 break;
6030 }
6031 if (LocaleCompare("white-point",option+1) == 0)
6032 {
6033 if (*option == '+')
6034 break;
6035 i++;
cristybb503372010-05-27 20:51:26 +00006036 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006037 ThrowMogrifyException(OptionError,"MissingArgument",option);
6038 if (IsGeometry(argv[i]) == MagickFalse)
6039 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6040 break;
6041 }
6042 if (LocaleCompare("white-threshold",option+1) == 0)
6043 {
6044 if (*option == '+')
6045 break;
6046 i++;
cristybb503372010-05-27 20:51:26 +00006047 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006048 ThrowMogrifyException(OptionError,"MissingArgument",option);
6049 if (IsGeometry(argv[i]) == MagickFalse)
6050 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6051 break;
6052 }
6053 if (LocaleCompare("write",option+1) == 0)
6054 {
6055 i++;
cristybb503372010-05-27 20:51:26 +00006056 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006057 ThrowMogrifyException(OptionError,"MissingArgument",option);
6058 break;
6059 }
6060 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6061 }
6062 case '?':
6063 break;
6064 default:
6065 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6066 }
cristy042ee782011-04-22 18:48:30 +00006067 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6068 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00006069 if (fire != MagickFalse)
6070 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6071 }
6072 if (k != 0)
6073 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006074 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006075 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6076 DestroyMogrify();
6077 return(status != 0 ? MagickTrue : MagickFalse);
6078}
6079
6080/*
6081%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6082% %
6083% %
6084% %
6085+ M o g r i f y I m a g e I n f o %
6086% %
6087% %
6088% %
6089%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6090%
6091% MogrifyImageInfo() applies image processing settings to the image as
6092% prescribed by command line options.
6093%
6094% The format of the MogrifyImageInfo method is:
6095%
6096% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6097% const char **argv,ExceptionInfo *exception)
6098%
6099% A description of each parameter follows:
6100%
6101% o image_info: the image info..
6102%
6103% o argc: Specifies a pointer to an integer describing the number of
6104% elements in the argument vector.
6105%
6106% o argv: Specifies a pointer to a text array containing the command line
6107% arguments.
6108%
6109% o exception: return any errors or warnings in this structure.
6110%
6111*/
6112WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6113 const int argc,const char **argv,ExceptionInfo *exception)
6114{
6115 const char
6116 *option;
6117
6118 GeometryInfo
6119 geometry_info;
6120
cristybb503372010-05-27 20:51:26 +00006121 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006122 count;
6123
cristybb503372010-05-27 20:51:26 +00006124 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006125 i;
6126
6127 /*
6128 Initialize method variables.
6129 */
6130 assert(image_info != (ImageInfo *) NULL);
6131 assert(image_info->signature == MagickSignature);
6132 if (image_info->debug != MagickFalse)
6133 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6134 image_info->filename);
6135 if (argc < 0)
6136 return(MagickTrue);
6137 /*
6138 Set the image settings.
6139 */
cristybb503372010-05-27 20:51:26 +00006140 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006141 {
6142 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00006143 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00006144 continue;
cristy042ee782011-04-22 18:48:30 +00006145 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00006146 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00006147 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006148 break;
6149 switch (*(option+1))
6150 {
6151 case 'a':
6152 {
6153 if (LocaleCompare("adjoin",option+1) == 0)
6154 {
6155 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6156 break;
6157 }
6158 if (LocaleCompare("antialias",option+1) == 0)
6159 {
6160 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6161 break;
6162 }
6163 if (LocaleCompare("attenuate",option+1) == 0)
6164 {
6165 if (*option == '+')
6166 {
6167 (void) DeleteImageOption(image_info,option+1);
6168 break;
6169 }
6170 (void) SetImageOption(image_info,option+1,argv[i+1]);
6171 break;
6172 }
6173 if (LocaleCompare("authenticate",option+1) == 0)
6174 {
6175 if (*option == '+')
6176 (void) CloneString(&image_info->authenticate,(char *) NULL);
6177 else
6178 (void) CloneString(&image_info->authenticate,argv[i+1]);
6179 break;
6180 }
6181 break;
6182 }
6183 case 'b':
6184 {
6185 if (LocaleCompare("background",option+1) == 0)
6186 {
6187 if (*option == '+')
6188 {
6189 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006190 (void) QueryColorCompliance(MogrifyBackgroundColor,
6191 AllCompliance,&image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006192 break;
6193 }
6194 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006195 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6196 &image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006197 break;
6198 }
6199 if (LocaleCompare("bias",option+1) == 0)
6200 {
6201 if (*option == '+')
6202 {
6203 (void) SetImageOption(image_info,option+1,"0.0");
6204 break;
6205 }
6206 (void) SetImageOption(image_info,option+1,argv[i+1]);
6207 break;
6208 }
6209 if (LocaleCompare("black-point-compensation",option+1) == 0)
6210 {
6211 if (*option == '+')
6212 {
6213 (void) SetImageOption(image_info,option+1,"false");
6214 break;
6215 }
6216 (void) SetImageOption(image_info,option+1,"true");
6217 break;
6218 }
6219 if (LocaleCompare("blue-primary",option+1) == 0)
6220 {
6221 if (*option == '+')
6222 {
6223 (void) SetImageOption(image_info,option+1,"0.0");
6224 break;
6225 }
6226 (void) SetImageOption(image_info,option+1,argv[i+1]);
6227 break;
6228 }
6229 if (LocaleCompare("bordercolor",option+1) == 0)
6230 {
6231 if (*option == '+')
6232 {
6233 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006234 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006235 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006236 break;
6237 }
cristy9950d572011-10-01 18:22:35 +00006238 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6239 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006240 (void) SetImageOption(image_info,option+1,argv[i+1]);
6241 break;
6242 }
6243 if (LocaleCompare("box",option+1) == 0)
6244 {
6245 if (*option == '+')
6246 {
6247 (void) SetImageOption(image_info,"undercolor","none");
6248 break;
6249 }
6250 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6251 break;
6252 }
6253 break;
6254 }
6255 case 'c':
6256 {
6257 if (LocaleCompare("cache",option+1) == 0)
6258 {
6259 MagickSizeType
6260 limit;
6261
6262 limit=MagickResourceInfinity;
6263 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006264 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006265 (void) SetMagickResourceLimit(MemoryResource,limit);
6266 (void) SetMagickResourceLimit(MapResource,2*limit);
6267 break;
6268 }
6269 if (LocaleCompare("caption",option+1) == 0)
6270 {
6271 if (*option == '+')
6272 {
6273 (void) DeleteImageOption(image_info,option+1);
6274 break;
6275 }
6276 (void) SetImageOption(image_info,option+1,argv[i+1]);
6277 break;
6278 }
6279 if (LocaleCompare("channel",option+1) == 0)
6280 {
6281 if (*option == '+')
6282 {
6283 image_info->channel=DefaultChannels;
6284 break;
6285 }
6286 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6287 break;
6288 }
6289 if (LocaleCompare("colors",option+1) == 0)
6290 {
cristye27293e2009-12-18 02:53:20 +00006291 image_info->colors=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006292 break;
6293 }
6294 if (LocaleCompare("colorspace",option+1) == 0)
6295 {
6296 if (*option == '+')
6297 {
6298 image_info->colorspace=UndefinedColorspace;
6299 (void) SetImageOption(image_info,option+1,"undefined");
6300 break;
6301 }
cristy042ee782011-04-22 18:48:30 +00006302 image_info->colorspace=(ColorspaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006303 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6304 (void) SetImageOption(image_info,option+1,argv[i+1]);
6305 break;
6306 }
cristy3ed852e2009-09-05 21:47:34 +00006307 if (LocaleCompare("comment",option+1) == 0)
6308 {
6309 if (*option == '+')
6310 {
6311 (void) DeleteImageOption(image_info,option+1);
6312 break;
6313 }
6314 (void) SetImageOption(image_info,option+1,argv[i+1]);
6315 break;
6316 }
6317 if (LocaleCompare("compose",option+1) == 0)
6318 {
6319 if (*option == '+')
6320 {
6321 (void) SetImageOption(image_info,option+1,"undefined");
6322 break;
6323 }
6324 (void) SetImageOption(image_info,option+1,argv[i+1]);
6325 break;
6326 }
6327 if (LocaleCompare("compress",option+1) == 0)
6328 {
6329 if (*option == '+')
6330 {
6331 image_info->compression=UndefinedCompression;
6332 (void) SetImageOption(image_info,option+1,"undefined");
6333 break;
6334 }
cristy042ee782011-04-22 18:48:30 +00006335 image_info->compression=(CompressionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006336 MagickCompressOptions,MagickFalse,argv[i+1]);
6337 (void) SetImageOption(image_info,option+1,argv[i+1]);
6338 break;
6339 }
6340 break;
6341 }
6342 case 'd':
6343 {
6344 if (LocaleCompare("debug",option+1) == 0)
6345 {
6346 if (*option == '+')
6347 (void) SetLogEventMask("none");
6348 else
6349 (void) SetLogEventMask(argv[i+1]);
6350 image_info->debug=IsEventLogging();
6351 break;
6352 }
6353 if (LocaleCompare("define",option+1) == 0)
6354 {
6355 if (*option == '+')
6356 {
6357 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6358 (void) DeleteImageRegistry(argv[i+1]+9);
6359 else
6360 (void) DeleteImageOption(image_info,argv[i+1]);
6361 break;
6362 }
6363 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6364 {
6365 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6366 exception);
6367 break;
6368 }
6369 (void) DefineImageOption(image_info,argv[i+1]);
6370 break;
6371 }
6372 if (LocaleCompare("delay",option+1) == 0)
6373 {
6374 if (*option == '+')
6375 {
6376 (void) SetImageOption(image_info,option+1,"0");
6377 break;
6378 }
6379 (void) SetImageOption(image_info,option+1,argv[i+1]);
6380 break;
6381 }
6382 if (LocaleCompare("density",option+1) == 0)
6383 {
6384 /*
6385 Set image density.
6386 */
6387 if (*option == '+')
6388 {
6389 if (image_info->density != (char *) NULL)
6390 image_info->density=DestroyString(image_info->density);
6391 (void) SetImageOption(image_info,option+1,"72");
6392 break;
6393 }
6394 (void) CloneString(&image_info->density,argv[i+1]);
6395 (void) SetImageOption(image_info,option+1,argv[i+1]);
6396 break;
6397 }
6398 if (LocaleCompare("depth",option+1) == 0)
6399 {
6400 if (*option == '+')
6401 {
6402 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6403 break;
6404 }
cristye27293e2009-12-18 02:53:20 +00006405 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006406 break;
6407 }
cristyc9b12952010-03-28 01:12:28 +00006408 if (LocaleCompare("direction",option+1) == 0)
6409 {
6410 if (*option == '+')
6411 {
6412 (void) SetImageOption(image_info,option+1,"undefined");
6413 break;
6414 }
6415 (void) SetImageOption(image_info,option+1,argv[i+1]);
6416 break;
6417 }
cristy3ed852e2009-09-05 21:47:34 +00006418 if (LocaleCompare("display",option+1) == 0)
6419 {
6420 if (*option == '+')
6421 {
6422 if (image_info->server_name != (char *) NULL)
6423 image_info->server_name=DestroyString(
6424 image_info->server_name);
6425 break;
6426 }
6427 (void) CloneString(&image_info->server_name,argv[i+1]);
6428 break;
6429 }
6430 if (LocaleCompare("dispose",option+1) == 0)
6431 {
6432 if (*option == '+')
6433 {
6434 (void) SetImageOption(image_info,option+1,"undefined");
6435 break;
6436 }
6437 (void) SetImageOption(image_info,option+1,argv[i+1]);
6438 break;
6439 }
6440 if (LocaleCompare("dither",option+1) == 0)
6441 {
6442 if (*option == '+')
6443 {
6444 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006445 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006446 break;
6447 }
6448 (void) SetImageOption(image_info,option+1,argv[i+1]);
6449 image_info->dither=MagickTrue;
6450 break;
6451 }
6452 break;
6453 }
6454 case 'e':
6455 {
6456 if (LocaleCompare("encoding",option+1) == 0)
6457 {
6458 if (*option == '+')
6459 {
6460 (void) SetImageOption(image_info,option+1,"undefined");
6461 break;
6462 }
6463 (void) SetImageOption(image_info,option+1,argv[i+1]);
6464 break;
6465 }
6466 if (LocaleCompare("endian",option+1) == 0)
6467 {
6468 if (*option == '+')
6469 {
6470 image_info->endian=UndefinedEndian;
6471 (void) SetImageOption(image_info,option+1,"undefined");
6472 break;
6473 }
cristy042ee782011-04-22 18:48:30 +00006474 image_info->endian=(EndianType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006475 MagickEndianOptions,MagickFalse,argv[i+1]);
6476 (void) SetImageOption(image_info,option+1,argv[i+1]);
6477 break;
6478 }
6479 if (LocaleCompare("extract",option+1) == 0)
6480 {
6481 /*
6482 Set image extract geometry.
6483 */
6484 if (*option == '+')
6485 {
6486 if (image_info->extract != (char *) NULL)
6487 image_info->extract=DestroyString(image_info->extract);
6488 break;
6489 }
6490 (void) CloneString(&image_info->extract,argv[i+1]);
6491 break;
6492 }
6493 break;
6494 }
6495 case 'f':
6496 {
6497 if (LocaleCompare("fill",option+1) == 0)
6498 {
6499 if (*option == '+')
6500 {
6501 (void) SetImageOption(image_info,option+1,"none");
6502 break;
6503 }
6504 (void) SetImageOption(image_info,option+1,argv[i+1]);
6505 break;
6506 }
6507 if (LocaleCompare("filter",option+1) == 0)
6508 {
6509 if (*option == '+')
6510 {
6511 (void) SetImageOption(image_info,option+1,"undefined");
6512 break;
6513 }
6514 (void) SetImageOption(image_info,option+1,argv[i+1]);
6515 break;
6516 }
6517 if (LocaleCompare("font",option+1) == 0)
6518 {
6519 if (*option == '+')
6520 {
6521 if (image_info->font != (char *) NULL)
6522 image_info->font=DestroyString(image_info->font);
6523 break;
6524 }
6525 (void) CloneString(&image_info->font,argv[i+1]);
6526 break;
6527 }
6528 if (LocaleCompare("format",option+1) == 0)
6529 {
6530 register const char
6531 *q;
6532
6533 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006534 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006535 image_info->ping=MagickFalse;
6536 (void) SetImageOption(image_info,option+1,argv[i+1]);
6537 break;
6538 }
6539 if (LocaleCompare("fuzz",option+1) == 0)
6540 {
6541 if (*option == '+')
6542 {
6543 image_info->fuzz=0.0;
6544 (void) SetImageOption(image_info,option+1,"0");
6545 break;
6546 }
cristyf2f27272009-12-17 14:48:46 +00006547 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006548 1.0);
6549 (void) SetImageOption(image_info,option+1,argv[i+1]);
6550 break;
6551 }
6552 break;
6553 }
6554 case 'g':
6555 {
6556 if (LocaleCompare("gravity",option+1) == 0)
6557 {
6558 if (*option == '+')
6559 {
6560 (void) SetImageOption(image_info,option+1,"undefined");
6561 break;
6562 }
6563 (void) SetImageOption(image_info,option+1,argv[i+1]);
6564 break;
6565 }
6566 if (LocaleCompare("green-primary",option+1) == 0)
6567 {
6568 if (*option == '+')
6569 {
6570 (void) SetImageOption(image_info,option+1,"0.0");
6571 break;
6572 }
6573 (void) SetImageOption(image_info,option+1,argv[i+1]);
6574 break;
6575 }
6576 break;
6577 }
6578 case 'i':
6579 {
6580 if (LocaleCompare("intent",option+1) == 0)
6581 {
6582 if (*option == '+')
6583 {
6584 (void) SetImageOption(image_info,option+1,"undefined");
6585 break;
6586 }
6587 (void) SetImageOption(image_info,option+1,argv[i+1]);
6588 break;
6589 }
6590 if (LocaleCompare("interlace",option+1) == 0)
6591 {
6592 if (*option == '+')
6593 {
6594 image_info->interlace=UndefinedInterlace;
6595 (void) SetImageOption(image_info,option+1,"undefined");
6596 break;
6597 }
cristy042ee782011-04-22 18:48:30 +00006598 image_info->interlace=(InterlaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006599 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6600 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 break;
6602 }
cristyb32b90a2009-09-07 21:45:48 +00006603 if (LocaleCompare("interline-spacing",option+1) == 0)
6604 {
6605 if (*option == '+')
6606 {
6607 (void) SetImageOption(image_info,option+1,"undefined");
6608 break;
6609 }
6610 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 break;
6612 }
cristy3ed852e2009-09-05 21:47:34 +00006613 if (LocaleCompare("interpolate",option+1) == 0)
6614 {
6615 if (*option == '+')
6616 {
6617 (void) SetImageOption(image_info,option+1,"undefined");
6618 break;
6619 }
6620 (void) SetImageOption(image_info,option+1,argv[i+1]);
6621 break;
6622 }
6623 if (LocaleCompare("interword-spacing",option+1) == 0)
6624 {
6625 if (*option == '+')
6626 {
6627 (void) SetImageOption(image_info,option+1,"undefined");
6628 break;
6629 }
6630 (void) SetImageOption(image_info,option+1,argv[i+1]);
6631 break;
6632 }
6633 break;
6634 }
6635 case 'k':
6636 {
6637 if (LocaleCompare("kerning",option+1) == 0)
6638 {
6639 if (*option == '+')
6640 {
6641 (void) SetImageOption(image_info,option+1,"undefined");
6642 break;
6643 }
6644 (void) SetImageOption(image_info,option+1,argv[i+1]);
6645 break;
6646 }
6647 break;
6648 }
6649 case 'l':
6650 {
6651 if (LocaleCompare("label",option+1) == 0)
6652 {
6653 if (*option == '+')
6654 {
6655 (void) DeleteImageOption(image_info,option+1);
6656 break;
6657 }
6658 (void) SetImageOption(image_info,option+1,argv[i+1]);
6659 break;
6660 }
6661 if (LocaleCompare("limit",option+1) == 0)
6662 {
6663 MagickSizeType
6664 limit;
6665
6666 ResourceType
6667 type;
6668
6669 if (*option == '+')
6670 break;
cristy042ee782011-04-22 18:48:30 +00006671 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
cristy3ed852e2009-09-05 21:47:34 +00006672 MagickFalse,argv[i+1]);
6673 limit=MagickResourceInfinity;
6674 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006675 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006676 (void) SetMagickResourceLimit(type,limit);
6677 break;
6678 }
6679 if (LocaleCompare("list",option+1) == 0)
6680 {
cristybb503372010-05-27 20:51:26 +00006681 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006682 list;
6683
6684 /*
6685 Display configuration list.
6686 */
cristy042ee782011-04-22 18:48:30 +00006687 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006688 switch (list)
6689 {
6690 case MagickCoderOptions:
6691 {
6692 (void) ListCoderInfo((FILE *) NULL,exception);
6693 break;
6694 }
6695 case MagickColorOptions:
6696 {
6697 (void) ListColorInfo((FILE *) NULL,exception);
6698 break;
6699 }
6700 case MagickConfigureOptions:
6701 {
6702 (void) ListConfigureInfo((FILE *) NULL,exception);
6703 break;
6704 }
6705 case MagickDelegateOptions:
6706 {
6707 (void) ListDelegateInfo((FILE *) NULL,exception);
6708 break;
6709 }
6710 case MagickFontOptions:
6711 {
6712 (void) ListTypeInfo((FILE *) NULL,exception);
6713 break;
6714 }
6715 case MagickFormatOptions:
6716 {
6717 (void) ListMagickInfo((FILE *) NULL,exception);
6718 break;
6719 }
6720 case MagickLocaleOptions:
6721 {
6722 (void) ListLocaleInfo((FILE *) NULL,exception);
6723 break;
6724 }
6725 case MagickLogOptions:
6726 {
6727 (void) ListLogInfo((FILE *) NULL,exception);
6728 break;
6729 }
6730 case MagickMagicOptions:
6731 {
6732 (void) ListMagicInfo((FILE *) NULL,exception);
6733 break;
6734 }
6735 case MagickMimeOptions:
6736 {
6737 (void) ListMimeInfo((FILE *) NULL,exception);
6738 break;
6739 }
6740 case MagickModuleOptions:
6741 {
6742 (void) ListModuleInfo((FILE *) NULL,exception);
6743 break;
6744 }
6745 case MagickPolicyOptions:
6746 {
6747 (void) ListPolicyInfo((FILE *) NULL,exception);
6748 break;
6749 }
6750 case MagickResourceOptions:
6751 {
6752 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6753 break;
6754 }
6755 case MagickThresholdOptions:
6756 {
6757 (void) ListThresholdMaps((FILE *) NULL,exception);
6758 break;
6759 }
6760 default:
6761 {
cristy042ee782011-04-22 18:48:30 +00006762 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
cristy3ed852e2009-09-05 21:47:34 +00006763 exception);
6764 break;
6765 }
6766 }
cristyaeb2cbc2010-05-07 13:28:58 +00006767 break;
cristy3ed852e2009-09-05 21:47:34 +00006768 }
6769 if (LocaleCompare("log",option+1) == 0)
6770 {
6771 if (*option == '+')
6772 break;
6773 (void) SetLogFormat(argv[i+1]);
6774 break;
6775 }
6776 if (LocaleCompare("loop",option+1) == 0)
6777 {
6778 if (*option == '+')
6779 {
6780 (void) SetImageOption(image_info,option+1,"0");
6781 break;
6782 }
6783 (void) SetImageOption(image_info,option+1,argv[i+1]);
6784 break;
6785 }
6786 break;
6787 }
6788 case 'm':
6789 {
6790 if (LocaleCompare("matte",option+1) == 0)
6791 {
6792 if (*option == '+')
6793 {
6794 (void) SetImageOption(image_info,option+1,"false");
6795 break;
6796 }
6797 (void) SetImageOption(image_info,option+1,"true");
6798 break;
6799 }
6800 if (LocaleCompare("mattecolor",option+1) == 0)
6801 {
6802 if (*option == '+')
6803 {
6804 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006805 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006806 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006807 break;
6808 }
6809 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006810 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6811 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006812 break;
6813 }
6814 if (LocaleCompare("monitor",option+1) == 0)
6815 {
6816 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6817 (void *) NULL);
6818 break;
6819 }
6820 if (LocaleCompare("monochrome",option+1) == 0)
6821 {
6822 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6823 break;
6824 }
6825 break;
6826 }
6827 case 'o':
6828 {
6829 if (LocaleCompare("orient",option+1) == 0)
6830 {
6831 if (*option == '+')
6832 {
6833 image_info->orientation=UndefinedOrientation;
6834 (void) SetImageOption(image_info,option+1,"undefined");
6835 break;
6836 }
cristy042ee782011-04-22 18:48:30 +00006837 image_info->orientation=(OrientationType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006838 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00006839 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006840 break;
6841 }
6842 }
6843 case 'p':
6844 {
6845 if (LocaleCompare("page",option+1) == 0)
6846 {
6847 char
6848 *canonical_page,
6849 page[MaxTextExtent];
6850
6851 const char
6852 *image_option;
6853
6854 MagickStatusType
6855 flags;
6856
6857 RectangleInfo
6858 geometry;
6859
6860 if (*option == '+')
6861 {
6862 (void) DeleteImageOption(image_info,option+1);
6863 (void) CloneString(&image_info->page,(char *) NULL);
6864 break;
6865 }
6866 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6867 image_option=GetImageOption(image_info,"page");
6868 if (image_option != (const char *) NULL)
6869 flags=ParseAbsoluteGeometry(image_option,&geometry);
6870 canonical_page=GetPageGeometry(argv[i+1]);
6871 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6872 canonical_page=DestroyString(canonical_page);
cristyb51dff52011-05-19 16:55:47 +00006873 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00006874 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00006875 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
cristyb51dff52011-05-19 16:55:47 +00006876 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00006877 (unsigned long) geometry.width,(unsigned long) geometry.height,
6878 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00006879 (void) SetImageOption(image_info,option+1,page);
6880 (void) CloneString(&image_info->page,page);
6881 break;
6882 }
6883 if (LocaleCompare("pen",option+1) == 0)
6884 {
6885 if (*option == '+')
6886 {
6887 (void) SetImageOption(image_info,option+1,"none");
6888 break;
6889 }
6890 (void) SetImageOption(image_info,option+1,argv[i+1]);
6891 break;
6892 }
6893 if (LocaleCompare("ping",option+1) == 0)
6894 {
6895 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6896 break;
6897 }
6898 if (LocaleCompare("pointsize",option+1) == 0)
6899 {
6900 if (*option == '+')
6901 geometry_info.rho=0.0;
6902 else
6903 (void) ParseGeometry(argv[i+1],&geometry_info);
6904 image_info->pointsize=geometry_info.rho;
6905 break;
6906 }
cristye7f51092010-01-17 00:39:37 +00006907 if (LocaleCompare("precision",option+1) == 0)
6908 {
cristybf2766a2010-01-17 03:33:23 +00006909 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00006910 break;
6911 }
cristy3ed852e2009-09-05 21:47:34 +00006912 if (LocaleCompare("preview",option+1) == 0)
6913 {
6914 /*
6915 Preview image.
6916 */
6917 if (*option == '+')
6918 {
6919 image_info->preview_type=UndefinedPreview;
6920 break;
6921 }
cristy042ee782011-04-22 18:48:30 +00006922 image_info->preview_type=(PreviewType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006923 MagickPreviewOptions,MagickFalse,argv[i+1]);
6924 break;
6925 }
6926 break;
6927 }
6928 case 'q':
6929 {
6930 if (LocaleCompare("quality",option+1) == 0)
6931 {
6932 /*
6933 Set image compression quality.
6934 */
6935 if (*option == '+')
6936 {
6937 image_info->quality=UndefinedCompressionQuality;
6938 (void) SetImageOption(image_info,option+1,"0");
6939 break;
6940 }
cristye27293e2009-12-18 02:53:20 +00006941 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006942 (void) SetImageOption(image_info,option+1,argv[i+1]);
6943 break;
6944 }
6945 if (LocaleCompare("quiet",option+1) == 0)
6946 {
6947 static WarningHandler
6948 warning_handler = (WarningHandler) NULL;
6949
6950 if (*option == '+')
6951 {
6952 /*
6953 Restore error or warning messages.
6954 */
6955 warning_handler=SetWarningHandler(warning_handler);
6956 break;
6957 }
6958 /*
6959 Suppress error or warning messages.
6960 */
6961 warning_handler=SetWarningHandler((WarningHandler) NULL);
6962 break;
6963 }
6964 break;
6965 }
6966 case 'r':
6967 {
6968 if (LocaleCompare("red-primary",option+1) == 0)
6969 {
6970 if (*option == '+')
6971 {
6972 (void) SetImageOption(image_info,option+1,"0.0");
6973 break;
6974 }
6975 (void) SetImageOption(image_info,option+1,argv[i+1]);
6976 break;
6977 }
6978 break;
6979 }
6980 case 's':
6981 {
6982 if (LocaleCompare("sampling-factor",option+1) == 0)
6983 {
6984 /*
6985 Set image sampling factor.
6986 */
6987 if (*option == '+')
6988 {
6989 if (image_info->sampling_factor != (char *) NULL)
6990 image_info->sampling_factor=DestroyString(
6991 image_info->sampling_factor);
6992 break;
6993 }
6994 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6995 break;
6996 }
6997 if (LocaleCompare("scene",option+1) == 0)
6998 {
6999 /*
7000 Set image scene.
7001 */
7002 if (*option == '+')
7003 {
7004 image_info->scene=0;
7005 (void) SetImageOption(image_info,option+1,"0");
7006 break;
7007 }
cristye27293e2009-12-18 02:53:20 +00007008 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007009 (void) SetImageOption(image_info,option+1,argv[i+1]);
7010 break;
7011 }
7012 if (LocaleCompare("seed",option+1) == 0)
7013 {
cristybb503372010-05-27 20:51:26 +00007014 size_t
cristy3ed852e2009-09-05 21:47:34 +00007015 seed;
7016
7017 if (*option == '+')
7018 {
cristybb503372010-05-27 20:51:26 +00007019 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007020 SeedPseudoRandomGenerator(seed);
7021 break;
7022 }
cristye27293e2009-12-18 02:53:20 +00007023 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007024 SeedPseudoRandomGenerator(seed);
7025 break;
7026 }
7027 if (LocaleCompare("size",option+1) == 0)
7028 {
7029 if (*option == '+')
7030 {
7031 if (image_info->size != (char *) NULL)
7032 image_info->size=DestroyString(image_info->size);
7033 break;
7034 }
7035 (void) CloneString(&image_info->size,argv[i+1]);
7036 break;
7037 }
7038 if (LocaleCompare("stroke",option+1) == 0)
7039 {
7040 if (*option == '+')
7041 {
7042 (void) SetImageOption(image_info,option+1,"none");
7043 break;
7044 }
7045 (void) SetImageOption(image_info,option+1,argv[i+1]);
7046 break;
7047 }
7048 if (LocaleCompare("strokewidth",option+1) == 0)
7049 {
7050 if (*option == '+')
7051 {
7052 (void) SetImageOption(image_info,option+1,"0");
7053 break;
7054 }
7055 (void) SetImageOption(image_info,option+1,argv[i+1]);
7056 break;
7057 }
cristyd9a29192010-10-16 16:49:53 +00007058 if (LocaleCompare("synchronize",option+1) == 0)
7059 {
7060 if (*option == '+')
7061 {
7062 image_info->synchronize=MagickFalse;
7063 break;
7064 }
7065 image_info->synchronize=MagickTrue;
7066 break;
7067 }
cristy3ed852e2009-09-05 21:47:34 +00007068 break;
7069 }
7070 case 't':
7071 {
7072 if (LocaleCompare("taint",option+1) == 0)
7073 {
7074 if (*option == '+')
7075 {
7076 (void) SetImageOption(image_info,option+1,"false");
7077 break;
7078 }
7079 (void) SetImageOption(image_info,option+1,"true");
7080 break;
7081 }
7082 if (LocaleCompare("texture",option+1) == 0)
7083 {
7084 if (*option == '+')
7085 {
7086 if (image_info->texture != (char *) NULL)
7087 image_info->texture=DestroyString(image_info->texture);
7088 break;
7089 }
7090 (void) CloneString(&image_info->texture,argv[i+1]);
7091 break;
7092 }
7093 if (LocaleCompare("tile-offset",option+1) == 0)
7094 {
7095 if (*option == '+')
7096 {
7097 (void) SetImageOption(image_info,option+1,"0");
7098 break;
7099 }
7100 (void) SetImageOption(image_info,option+1,argv[i+1]);
7101 break;
7102 }
7103 if (LocaleCompare("transparent-color",option+1) == 0)
7104 {
7105 if (*option == '+')
7106 {
cristy9950d572011-10-01 18:22:35 +00007107 (void) QueryColorCompliance("none",AllCompliance,
7108 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007109 (void) SetImageOption(image_info,option+1,"none");
7110 break;
7111 }
cristy9950d572011-10-01 18:22:35 +00007112 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7113 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007114 (void) SetImageOption(image_info,option+1,argv[i+1]);
7115 break;
7116 }
7117 if (LocaleCompare("type",option+1) == 0)
7118 {
7119 if (*option == '+')
7120 {
cristy5f1c1ff2010-12-23 21:38:06 +00007121 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007122 (void) SetImageOption(image_info,option+1,"undefined");
7123 break;
7124 }
cristy042ee782011-04-22 18:48:30 +00007125 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
cristy3ed852e2009-09-05 21:47:34 +00007126 MagickFalse,argv[i+1]);
7127 (void) SetImageOption(image_info,option+1,argv[i+1]);
7128 break;
7129 }
7130 break;
7131 }
7132 case 'u':
7133 {
7134 if (LocaleCompare("undercolor",option+1) == 0)
7135 {
7136 if (*option == '+')
7137 {
7138 (void) DeleteImageOption(image_info,option+1);
7139 break;
7140 }
7141 (void) SetImageOption(image_info,option+1,argv[i+1]);
7142 break;
7143 }
7144 if (LocaleCompare("units",option+1) == 0)
7145 {
7146 if (*option == '+')
7147 {
7148 image_info->units=UndefinedResolution;
7149 (void) SetImageOption(image_info,option+1,"undefined");
7150 break;
7151 }
cristy042ee782011-04-22 18:48:30 +00007152 image_info->units=(ResolutionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007153 MagickResolutionOptions,MagickFalse,argv[i+1]);
7154 (void) SetImageOption(image_info,option+1,argv[i+1]);
7155 break;
7156 }
7157 break;
7158 }
7159 case 'v':
7160 {
7161 if (LocaleCompare("verbose",option+1) == 0)
7162 {
7163 if (*option == '+')
7164 {
7165 image_info->verbose=MagickFalse;
7166 break;
7167 }
7168 image_info->verbose=MagickTrue;
7169 image_info->ping=MagickFalse;
7170 break;
7171 }
7172 if (LocaleCompare("view",option+1) == 0)
7173 {
7174 if (*option == '+')
7175 {
7176 if (image_info->view != (char *) NULL)
7177 image_info->view=DestroyString(image_info->view);
7178 break;
7179 }
7180 (void) CloneString(&image_info->view,argv[i+1]);
7181 break;
7182 }
7183 if (LocaleCompare("virtual-pixel",option+1) == 0)
7184 {
7185 if (*option == '+')
7186 {
7187 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7188 (void) SetImageOption(image_info,option+1,"undefined");
7189 break;
7190 }
7191 image_info->virtual_pixel_method=(VirtualPixelMethod)
cristy042ee782011-04-22 18:48:30 +00007192 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00007193 argv[i+1]);
7194 (void) SetImageOption(image_info,option+1,argv[i+1]);
7195 break;
7196 }
7197 break;
7198 }
7199 case 'w':
7200 {
7201 if (LocaleCompare("white-point",option+1) == 0)
7202 {
7203 if (*option == '+')
7204 {
7205 (void) SetImageOption(image_info,option+1,"0.0");
7206 break;
7207 }
7208 (void) SetImageOption(image_info,option+1,argv[i+1]);
7209 break;
7210 }
7211 break;
7212 }
7213 default:
7214 break;
7215 }
7216 i+=count;
7217 }
7218 return(MagickTrue);
7219}
7220
7221/*
7222%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7223% %
7224% %
7225% %
7226+ M o g r i f y I m a g e L i s t %
7227% %
7228% %
7229% %
7230%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7231%
7232% MogrifyImageList() applies any command line options that might affect the
7233% entire image list (e.g. -append, -coalesce, etc.).
7234%
7235% The format of the MogrifyImage method is:
7236%
7237% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7238% const char **argv,Image **images,ExceptionInfo *exception)
7239%
7240% A description of each parameter follows:
7241%
7242% o image_info: the image info..
7243%
7244% o argc: Specifies a pointer to an integer describing the number of
7245% elements in the argument vector.
7246%
7247% o argv: Specifies a pointer to a text array containing the command line
7248% arguments.
7249%
anthonye9c27192011-03-27 08:07:06 +00007250% o images: pointer to pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00007251%
7252% o exception: return any errors or warnings in this structure.
7253%
7254*/
7255WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7256 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7257{
cristy3ed852e2009-09-05 21:47:34 +00007258 const char
7259 *option;
7260
cristy6b3da3a2010-06-20 02:21:46 +00007261 ImageInfo
7262 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007263
7264 MagickStatusType
7265 status;
7266
cristy28474bf2011-09-11 23:32:52 +00007267 PixelInterpolateMethod
7268 interpolate_method;
7269
cristy3ed852e2009-09-05 21:47:34 +00007270 QuantizeInfo
7271 *quantize_info;
7272
cristybb503372010-05-27 20:51:26 +00007273 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007274 i;
7275
cristy6b3da3a2010-06-20 02:21:46 +00007276 ssize_t
7277 count,
7278 index;
7279
cristy3ed852e2009-09-05 21:47:34 +00007280 /*
7281 Apply options to the image list.
7282 */
7283 assert(image_info != (ImageInfo *) NULL);
7284 assert(image_info->signature == MagickSignature);
7285 assert(images != (Image **) NULL);
anthonye9c27192011-03-27 08:07:06 +00007286 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007287 assert((*images)->signature == MagickSignature);
7288 if ((*images)->debug != MagickFalse)
7289 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7290 (*images)->filename);
7291 if ((argc <= 0) || (*argv == (char *) NULL))
7292 return(MagickTrue);
cristy28474bf2011-09-11 23:32:52 +00007293 interpolate_method=UndefinedInterpolatePixel;
cristy6b3da3a2010-06-20 02:21:46 +00007294 mogrify_info=CloneImageInfo(image_info);
7295 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00007296 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007297 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007298 {
cristy74fe8f12009-10-03 19:09:01 +00007299 if (*images == (Image *) NULL)
7300 break;
cristy3ed852e2009-09-05 21:47:34 +00007301 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00007302 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00007303 continue;
cristy042ee782011-04-22 18:48:30 +00007304 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00007305 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00007306 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007307 break;
cristy6b3da3a2010-06-20 02:21:46 +00007308 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007309 switch (*(option+1))
7310 {
7311 case 'a':
7312 {
7313 if (LocaleCompare("affinity",option+1) == 0)
7314 {
cristy6b3da3a2010-06-20 02:21:46 +00007315 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007316 if (*option == '+')
7317 {
cristy018f07f2011-09-04 21:15:19 +00007318 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7319 exception);
cristy3ed852e2009-09-05 21:47:34 +00007320 break;
7321 }
7322 i++;
7323 break;
7324 }
7325 if (LocaleCompare("append",option+1) == 0)
7326 {
7327 Image
7328 *append_image;
7329
cristy6b3da3a2010-06-20 02:21:46 +00007330 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007331 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7332 MagickFalse,exception);
7333 if (append_image == (Image *) NULL)
7334 {
7335 status=MagickFalse;
7336 break;
7337 }
7338 *images=DestroyImageList(*images);
7339 *images=append_image;
7340 break;
7341 }
7342 if (LocaleCompare("average",option+1) == 0)
7343 {
7344 Image
7345 *average_image;
7346
cristyd18ae7c2010-03-07 17:39:52 +00007347 /*
7348 Average an image sequence (deprecated).
7349 */
cristy6b3da3a2010-06-20 02:21:46 +00007350 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007351 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7352 exception);
cristy3ed852e2009-09-05 21:47:34 +00007353 if (average_image == (Image *) NULL)
7354 {
7355 status=MagickFalse;
7356 break;
7357 }
7358 *images=DestroyImageList(*images);
7359 *images=average_image;
7360 break;
7361 }
7362 break;
7363 }
7364 case 'c':
7365 {
7366 if (LocaleCompare("channel",option+1) == 0)
7367 {
cristyf4ad9df2011-07-08 16:49:03 +00007368 ChannelType
7369 channel;
7370
cristy3ed852e2009-09-05 21:47:34 +00007371 if (*option == '+')
7372 {
7373 channel=DefaultChannels;
7374 break;
7375 }
7376 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00007377 SetPixelChannelMap(*images,channel);
cristy3ed852e2009-09-05 21:47:34 +00007378 break;
7379 }
7380 if (LocaleCompare("clut",option+1) == 0)
7381 {
7382 Image
7383 *clut_image,
7384 *image;
7385
cristy6b3da3a2010-06-20 02:21:46 +00007386 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007387 image=RemoveFirstImageFromList(images);
7388 clut_image=RemoveFirstImageFromList(images);
7389 if (clut_image == (Image *) NULL)
7390 {
7391 status=MagickFalse;
7392 break;
7393 }
cristy28474bf2011-09-11 23:32:52 +00007394 (void) ClutImage(image,clut_image,interpolate_method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007395 clut_image=DestroyImage(clut_image);
cristy3ed852e2009-09-05 21:47:34 +00007396 *images=DestroyImageList(*images);
7397 *images=image;
7398 break;
7399 }
7400 if (LocaleCompare("coalesce",option+1) == 0)
7401 {
7402 Image
7403 *coalesce_image;
7404
cristy6b3da3a2010-06-20 02:21:46 +00007405 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007406 coalesce_image=CoalesceImages(*images,exception);
7407 if (coalesce_image == (Image *) NULL)
7408 {
7409 status=MagickFalse;
7410 break;
7411 }
7412 *images=DestroyImageList(*images);
7413 *images=coalesce_image;
7414 break;
7415 }
7416 if (LocaleCompare("combine",option+1) == 0)
7417 {
7418 Image
7419 *combine_image;
7420
cristy6b3da3a2010-06-20 02:21:46 +00007421 (void) SyncImagesSettings(mogrify_info,*images);
cristy3139dc22011-07-08 00:11:42 +00007422 combine_image=CombineImages(*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007423 if (combine_image == (Image *) NULL)
7424 {
7425 status=MagickFalse;
7426 break;
7427 }
7428 *images=DestroyImageList(*images);
7429 *images=combine_image;
7430 break;
7431 }
7432 if (LocaleCompare("composite",option+1) == 0)
7433 {
7434 Image
7435 *mask_image,
7436 *composite_image,
7437 *image;
7438
7439 RectangleInfo
7440 geometry;
7441
cristy6b3da3a2010-06-20 02:21:46 +00007442 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007443 image=RemoveFirstImageFromList(images);
7444 composite_image=RemoveFirstImageFromList(images);
7445 if (composite_image == (Image *) NULL)
7446 {
7447 status=MagickFalse;
7448 break;
7449 }
7450 (void) TransformImage(&composite_image,(char *) NULL,
7451 composite_image->geometry);
7452 SetGeometry(composite_image,&geometry);
7453 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7454 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7455 &geometry);
7456 mask_image=RemoveFirstImageFromList(images);
7457 if (mask_image != (Image *) NULL)
7458 {
7459 if ((image->compose == DisplaceCompositeOp) ||
7460 (image->compose == DistortCompositeOp))
7461 {
7462 /*
7463 Merge Y displacement into X displacement image.
7464 */
7465 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7466 mask_image,0,0);
7467 mask_image=DestroyImage(mask_image);
7468 }
7469 else
7470 {
7471 /*
7472 Set a blending mask for the composition.
cristy28474bf2011-09-11 23:32:52 +00007473 Posible error, what if image->mask already set.
cristy3ed852e2009-09-05 21:47:34 +00007474 */
7475 image->mask=mask_image;
cristyb3e7c6c2011-07-24 01:43:55 +00007476 (void) NegateImage(image->mask,MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007477 }
7478 }
cristyf4ad9df2011-07-08 16:49:03 +00007479 (void) CompositeImage(image,image->compose,composite_image,
7480 geometry.x,geometry.y);
anthonya129f702011-04-14 01:08:48 +00007481 if (mask_image != (Image *) NULL)
7482 mask_image=image->mask=DestroyImage(image->mask);
cristy3ed852e2009-09-05 21:47:34 +00007483 composite_image=DestroyImage(composite_image);
7484 InheritException(exception,&image->exception);
7485 *images=DestroyImageList(*images);
7486 *images=image;
7487 break;
7488 }
cristy3ed852e2009-09-05 21:47:34 +00007489 break;
7490 }
7491 case 'd':
7492 {
7493 if (LocaleCompare("deconstruct",option+1) == 0)
7494 {
7495 Image
7496 *deconstruct_image;
7497
cristy6b3da3a2010-06-20 02:21:46 +00007498 (void) SyncImagesSettings(mogrify_info,*images);
cristy8a9106f2011-07-05 14:39:26 +00007499 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
cristy4c08aed2011-07-01 19:47:50 +00007500 exception);
cristy3ed852e2009-09-05 21:47:34 +00007501 if (deconstruct_image == (Image *) NULL)
7502 {
7503 status=MagickFalse;
7504 break;
7505 }
7506 *images=DestroyImageList(*images);
7507 *images=deconstruct_image;
7508 break;
7509 }
7510 if (LocaleCompare("delete",option+1) == 0)
7511 {
7512 if (*option == '+')
7513 DeleteImages(images,"-1",exception);
7514 else
7515 DeleteImages(images,argv[i+1],exception);
7516 break;
7517 }
7518 if (LocaleCompare("dither",option+1) == 0)
7519 {
7520 if (*option == '+')
7521 {
7522 quantize_info->dither=MagickFalse;
7523 break;
7524 }
7525 quantize_info->dither=MagickTrue;
cristy042ee782011-04-22 18:48:30 +00007526 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007527 MagickDitherOptions,MagickFalse,argv[i+1]);
7528 break;
7529 }
cristyecb10ff2011-03-22 13:14:03 +00007530 if (LocaleCompare("duplicate",option+1) == 0)
7531 {
cristy72988482011-03-29 16:34:38 +00007532 Image
7533 *duplicate_images;
cristybf95deb2011-03-23 00:25:36 +00007534
anthony2b6bcae2011-03-23 13:05:34 +00007535 if (*option == '+')
cristy72988482011-03-29 16:34:38 +00007536 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7537 else
7538 {
7539 const char
7540 *p;
7541
anthony2b6bcae2011-03-23 13:05:34 +00007542 size_t
7543 number_duplicates;
anthony9bd15492011-03-23 02:11:13 +00007544
anthony2b6bcae2011-03-23 13:05:34 +00007545 number_duplicates=(size_t) StringToLong(argv[i+1]);
cristy72988482011-03-29 16:34:38 +00007546 p=strchr(argv[i+1],',');
7547 if (p == (const char *) NULL)
7548 duplicate_images=DuplicateImages(*images,number_duplicates,
7549 "-1",exception);
anthony2b6bcae2011-03-23 13:05:34 +00007550 else
cristy72988482011-03-29 16:34:38 +00007551 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7552 exception);
anthony2b6bcae2011-03-23 13:05:34 +00007553 }
7554 AppendImageToList(images, duplicate_images);
7555 (void) SyncImagesSettings(mogrify_info,*images);
cristyecb10ff2011-03-22 13:14:03 +00007556 break;
7557 }
cristy3ed852e2009-09-05 21:47:34 +00007558 break;
7559 }
cristyd18ae7c2010-03-07 17:39:52 +00007560 case 'e':
7561 {
7562 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7563 {
7564 Image
7565 *evaluate_image;
7566
7567 MagickEvaluateOperator
7568 op;
7569
cristy6b3da3a2010-06-20 02:21:46 +00007570 (void) SyncImageSettings(mogrify_info,*images);
cristy28474bf2011-09-11 23:32:52 +00007571 op=(MagickEvaluateOperator) ParseCommandOption(
7572 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristyd18ae7c2010-03-07 17:39:52 +00007573 evaluate_image=EvaluateImages(*images,op,exception);
7574 if (evaluate_image == (Image *) NULL)
7575 {
7576 status=MagickFalse;
7577 break;
7578 }
7579 *images=DestroyImageList(*images);
7580 *images=evaluate_image;
7581 break;
7582 }
7583 break;
7584 }
cristy3ed852e2009-09-05 21:47:34 +00007585 case 'f':
7586 {
cristyf0a247f2009-10-04 00:20:03 +00007587 if (LocaleCompare("fft",option+1) == 0)
7588 {
7589 Image
7590 *fourier_image;
7591
7592 /*
7593 Implements the discrete Fourier transform (DFT).
7594 */
cristy6b3da3a2010-06-20 02:21:46 +00007595 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00007596 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7597 MagickTrue : MagickFalse,exception);
7598 if (fourier_image == (Image *) NULL)
7599 break;
7600 *images=DestroyImage(*images);
7601 *images=fourier_image;
7602 break;
7603 }
cristy3ed852e2009-09-05 21:47:34 +00007604 if (LocaleCompare("flatten",option+1) == 0)
7605 {
7606 Image
7607 *flatten_image;
7608
cristy6b3da3a2010-06-20 02:21:46 +00007609 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007610 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7611 if (flatten_image == (Image *) NULL)
7612 break;
7613 *images=DestroyImageList(*images);
7614 *images=flatten_image;
7615 break;
7616 }
7617 if (LocaleCompare("fx",option+1) == 0)
7618 {
7619 Image
7620 *fx_image;
7621
cristy6b3da3a2010-06-20 02:21:46 +00007622 (void) SyncImagesSettings(mogrify_info,*images);
cristy490408a2011-07-07 14:42:05 +00007623 fx_image=FxImage(*images,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00007624 if (fx_image == (Image *) NULL)
7625 {
7626 status=MagickFalse;
7627 break;
7628 }
7629 *images=DestroyImageList(*images);
7630 *images=fx_image;
7631 break;
7632 }
7633 break;
7634 }
7635 case 'h':
7636 {
7637 if (LocaleCompare("hald-clut",option+1) == 0)
7638 {
7639 Image
7640 *hald_image,
7641 *image;
7642
cristy6b3da3a2010-06-20 02:21:46 +00007643 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007644 image=RemoveFirstImageFromList(images);
7645 hald_image=RemoveFirstImageFromList(images);
7646 if (hald_image == (Image *) NULL)
7647 {
7648 status=MagickFalse;
7649 break;
7650 }
cristy7c0a0a42011-08-23 17:57:25 +00007651 (void) HaldClutImage(image,hald_image,exception);
cristy3ed852e2009-09-05 21:47:34 +00007652 hald_image=DestroyImage(hald_image);
cristy0aff6ea2009-11-14 01:40:53 +00007653 if (*images != (Image *) NULL)
7654 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00007655 *images=image;
7656 break;
7657 }
7658 break;
7659 }
7660 case 'i':
7661 {
7662 if (LocaleCompare("ift",option+1) == 0)
7663 {
7664 Image
cristy8587f882009-11-13 20:28:49 +00007665 *fourier_image,
7666 *magnitude_image,
7667 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00007668
7669 /*
7670 Implements the inverse fourier discrete Fourier transform (DFT).
7671 */
cristy6b3da3a2010-06-20 02:21:46 +00007672 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00007673 magnitude_image=RemoveFirstImageFromList(images);
7674 phase_image=RemoveFirstImageFromList(images);
7675 if (phase_image == (Image *) NULL)
7676 {
7677 status=MagickFalse;
7678 break;
7679 }
7680 fourier_image=InverseFourierTransformImage(magnitude_image,
7681 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007682 if (fourier_image == (Image *) NULL)
7683 break;
cristy0aff6ea2009-11-14 01:40:53 +00007684 if (*images != (Image *) NULL)
7685 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00007686 *images=fourier_image;
7687 break;
7688 }
7689 if (LocaleCompare("insert",option+1) == 0)
7690 {
7691 Image
7692 *p,
7693 *q;
7694
7695 index=0;
7696 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00007697 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007698 p=RemoveLastImageFromList(images);
7699 if (p == (Image *) NULL)
7700 {
7701 (void) ThrowMagickException(exception,GetMagickModule(),
7702 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7703 status=MagickFalse;
7704 break;
7705 }
7706 q=p;
7707 if (index == 0)
7708 PrependImageToList(images,q);
7709 else
cristybb503372010-05-27 20:51:26 +00007710 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00007711 AppendImageToList(images,q);
7712 else
7713 {
7714 q=GetImageFromList(*images,index-1);
7715 if (q == (Image *) NULL)
7716 {
7717 (void) ThrowMagickException(exception,GetMagickModule(),
7718 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7719 status=MagickFalse;
7720 break;
7721 }
7722 InsertImageInList(&q,p);
7723 }
7724 *images=GetFirstImageInList(q);
7725 break;
7726 }
cristy28474bf2011-09-11 23:32:52 +00007727 if (LocaleCompare("interpolate",option+1) == 0)
7728 {
7729 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7730 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7731 break;
7732 }
cristy3ed852e2009-09-05 21:47:34 +00007733 break;
7734 }
7735 case 'l':
7736 {
7737 if (LocaleCompare("layers",option+1) == 0)
7738 {
7739 Image
7740 *layers;
7741
7742 ImageLayerMethod
7743 method;
7744
cristy6b3da3a2010-06-20 02:21:46 +00007745 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007746 layers=(Image *) NULL;
cristy042ee782011-04-22 18:48:30 +00007747 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
cristy3ed852e2009-09-05 21:47:34 +00007748 MagickFalse,argv[i+1]);
7749 switch (method)
7750 {
7751 case CoalesceLayer:
7752 {
7753 layers=CoalesceImages(*images,exception);
7754 break;
7755 }
7756 case CompareAnyLayer:
7757 case CompareClearLayer:
7758 case CompareOverlayLayer:
7759 default:
7760 {
cristy8a9106f2011-07-05 14:39:26 +00007761 layers=CompareImagesLayers(*images,method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007762 break;
7763 }
7764 case MergeLayer:
7765 case FlattenLayer:
7766 case MosaicLayer:
7767 case TrimBoundsLayer:
7768 {
7769 layers=MergeImageLayers(*images,method,exception);
7770 break;
7771 }
7772 case DisposeLayer:
7773 {
7774 layers=DisposeImages(*images,exception);
7775 break;
7776 }
7777 case OptimizeImageLayer:
7778 {
7779 layers=OptimizeImageLayers(*images,exception);
7780 break;
7781 }
7782 case OptimizePlusLayer:
7783 {
7784 layers=OptimizePlusImageLayers(*images,exception);
7785 break;
7786 }
7787 case OptimizeTransLayer:
7788 {
7789 OptimizeImageTransparency(*images,exception);
7790 break;
7791 }
7792 case RemoveDupsLayer:
7793 {
7794 RemoveDuplicateLayers(images,exception);
7795 break;
7796 }
7797 case RemoveZeroLayer:
7798 {
7799 RemoveZeroDelayLayers(images,exception);
7800 break;
7801 }
7802 case OptimizeLayer:
7803 {
7804 /*
7805 General Purpose, GIF Animation Optimizer.
7806 */
7807 layers=CoalesceImages(*images,exception);
7808 if (layers == (Image *) NULL)
7809 {
7810 status=MagickFalse;
7811 break;
7812 }
cristy3ed852e2009-09-05 21:47:34 +00007813 *images=DestroyImageList(*images);
7814 *images=layers;
7815 layers=OptimizeImageLayers(*images,exception);
7816 if (layers == (Image *) NULL)
7817 {
7818 status=MagickFalse;
7819 break;
7820 }
cristy3ed852e2009-09-05 21:47:34 +00007821 *images=DestroyImageList(*images);
7822 *images=layers;
7823 layers=(Image *) NULL;
7824 OptimizeImageTransparency(*images,exception);
cristy018f07f2011-09-04 21:15:19 +00007825 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7826 exception);
cristy3ed852e2009-09-05 21:47:34 +00007827 break;
7828 }
7829 case CompositeLayer:
7830 {
7831 CompositeOperator
7832 compose;
7833
7834 Image
7835 *source;
7836
7837 RectangleInfo
7838 geometry;
7839
7840 /*
7841 Split image sequence at the first 'NULL:' image.
7842 */
7843 source=(*images);
7844 while (source != (Image *) NULL)
7845 {
7846 source=GetNextImageInList(source);
7847 if ((source != (Image *) NULL) &&
7848 (LocaleCompare(source->magick,"NULL") == 0))
7849 break;
7850 }
7851 if (source != (Image *) NULL)
7852 {
7853 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7854 (GetNextImageInList(source) == (Image *) NULL))
7855 source=(Image *) NULL;
7856 else
7857 {
7858 /*
7859 Separate the two lists, junk the null: image.
7860 */
7861 source=SplitImageList(source->previous);
7862 DeleteImageFromList(&source);
7863 }
7864 }
7865 if (source == (Image *) NULL)
7866 {
7867 (void) ThrowMagickException(exception,GetMagickModule(),
7868 OptionError,"MissingNullSeparator","layers Composite");
7869 status=MagickFalse;
7870 break;
7871 }
7872 /*
7873 Adjust offset with gravity and virtual canvas.
7874 */
7875 SetGeometry(*images,&geometry);
7876 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7877 geometry.width=source->page.width != 0 ?
7878 source->page.width : source->columns;
7879 geometry.height=source->page.height != 0 ?
7880 source->page.height : source->rows;
7881 GravityAdjustGeometry((*images)->page.width != 0 ?
7882 (*images)->page.width : (*images)->columns,
7883 (*images)->page.height != 0 ? (*images)->page.height :
7884 (*images)->rows,(*images)->gravity,&geometry);
7885 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00007886 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00007887 if (option != (const char *) NULL)
cristy042ee782011-04-22 18:48:30 +00007888 compose=(CompositeOperator) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007889 MagickComposeOptions,MagickFalse,option);
7890 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7891 exception);
7892 source=DestroyImageList(source);
7893 break;
7894 }
7895 }
7896 if (layers == (Image *) NULL)
7897 break;
7898 InheritException(exception,&layers->exception);
7899 *images=DestroyImageList(*images);
7900 *images=layers;
7901 break;
7902 }
7903 break;
7904 }
7905 case 'm':
7906 {
7907 if (LocaleCompare("map",option+1) == 0)
7908 {
cristy6b3da3a2010-06-20 02:21:46 +00007909 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007910 if (*option == '+')
7911 {
cristy018f07f2011-09-04 21:15:19 +00007912 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7913 exception);
cristy3ed852e2009-09-05 21:47:34 +00007914 break;
7915 }
7916 i++;
7917 break;
7918 }
cristyf40785b2010-03-06 02:27:27 +00007919 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007920 {
7921 Image
cristyf40785b2010-03-06 02:27:27 +00007922 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007923
cristyd18ae7c2010-03-07 17:39:52 +00007924 /*
7925 Maximum image sequence (deprecated).
7926 */
cristy6b3da3a2010-06-20 02:21:46 +00007927 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007928 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007929 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007930 {
7931 status=MagickFalse;
7932 break;
7933 }
7934 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007935 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007936 break;
7937 }
cristyf40785b2010-03-06 02:27:27 +00007938 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007939 {
7940 Image
cristyf40785b2010-03-06 02:27:27 +00007941 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007942
cristyd18ae7c2010-03-07 17:39:52 +00007943 /*
7944 Minimum image sequence (deprecated).
7945 */
cristy6b3da3a2010-06-20 02:21:46 +00007946 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007947 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007948 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007949 {
7950 status=MagickFalse;
7951 break;
7952 }
7953 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007954 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007955 break;
7956 }
cristy3ed852e2009-09-05 21:47:34 +00007957 if (LocaleCompare("morph",option+1) == 0)
7958 {
7959 Image
7960 *morph_image;
7961
cristy6b3da3a2010-06-20 02:21:46 +00007962 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00007963 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00007964 exception);
7965 if (morph_image == (Image *) NULL)
7966 {
7967 status=MagickFalse;
7968 break;
7969 }
7970 *images=DestroyImageList(*images);
7971 *images=morph_image;
7972 break;
7973 }
7974 if (LocaleCompare("mosaic",option+1) == 0)
7975 {
7976 Image
7977 *mosaic_image;
7978
cristy6b3da3a2010-06-20 02:21:46 +00007979 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007980 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7981 if (mosaic_image == (Image *) NULL)
7982 {
7983 status=MagickFalse;
7984 break;
7985 }
7986 *images=DestroyImageList(*images);
7987 *images=mosaic_image;
7988 break;
7989 }
7990 break;
7991 }
7992 case 'p':
7993 {
7994 if (LocaleCompare("print",option+1) == 0)
7995 {
7996 char
7997 *string;
7998
cristy6b3da3a2010-06-20 02:21:46 +00007999 (void) SyncImagesSettings(mogrify_info,*images);
cristy018f07f2011-09-04 21:15:19 +00008000 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8001 exception);
cristy3ed852e2009-09-05 21:47:34 +00008002 if (string == (char *) NULL)
8003 break;
cristyb51dff52011-05-19 16:55:47 +00008004 (void) FormatLocaleFile(stdout,"%s",string);
cristy3ed852e2009-09-05 21:47:34 +00008005 string=DestroyString(string);
8006 }
8007 if (LocaleCompare("process",option+1) == 0)
8008 {
8009 char
8010 **arguments;
8011
8012 int
8013 j,
8014 number_arguments;
8015
cristy6b3da3a2010-06-20 02:21:46 +00008016 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008017 arguments=StringToArgv(argv[i+1],&number_arguments);
8018 if (arguments == (char **) NULL)
8019 break;
8020 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8021 {
8022 char
8023 breaker,
8024 quote,
8025 *token;
8026
8027 const char
8028 *arguments;
8029
8030 int
8031 next,
8032 status;
8033
8034 size_t
8035 length;
8036
8037 TokenInfo
8038 *token_info;
8039
8040 /*
8041 Support old style syntax, filter="-option arg".
8042 */
8043 length=strlen(argv[i+1]);
8044 token=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +00008045 if (~length >= (MaxTextExtent-1))
cristy3ed852e2009-09-05 21:47:34 +00008046 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8047 sizeof(*token));
8048 if (token == (char *) NULL)
8049 break;
8050 next=0;
8051 arguments=argv[i+1];
8052 token_info=AcquireTokenInfo();
8053 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8054 "\"",'\0',&breaker,&next,&quote);
8055 token_info=DestroyTokenInfo(token_info);
8056 if (status == 0)
8057 {
8058 const char
8059 *argv;
8060
8061 argv=(&(arguments[next]));
8062 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8063 exception);
8064 }
8065 token=DestroyString(token);
8066 break;
8067 }
cristy91c0da22010-05-02 01:44:07 +00008068 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008069 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8070 number_arguments-2,(const char **) arguments+2,exception);
8071 for (j=0; j < number_arguments; j++)
8072 arguments[j]=DestroyString(arguments[j]);
8073 arguments=(char **) RelinquishMagickMemory(arguments);
8074 break;
8075 }
8076 break;
8077 }
8078 case 'r':
8079 {
8080 if (LocaleCompare("reverse",option+1) == 0)
8081 {
8082 ReverseImageList(images);
8083 InheritException(exception,&(*images)->exception);
8084 break;
8085 }
8086 break;
8087 }
8088 case 's':
8089 {
cristy4285d782011-02-09 20:12:28 +00008090 if (LocaleCompare("smush",option+1) == 0)
8091 {
8092 Image
8093 *smush_image;
8094
8095 ssize_t
8096 offset;
8097
8098 (void) SyncImagesSettings(mogrify_info,*images);
8099 offset=(ssize_t) StringToLong(argv[i+1]);
8100 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8101 MagickFalse,offset,exception);
8102 if (smush_image == (Image *) NULL)
8103 {
8104 status=MagickFalse;
8105 break;
8106 }
8107 *images=DestroyImageList(*images);
8108 *images=smush_image;
8109 break;
8110 }
cristy3ed852e2009-09-05 21:47:34 +00008111 if (LocaleCompare("swap",option+1) == 0)
8112 {
8113 Image
8114 *p,
8115 *q,
8116 *swap;
8117
cristybb503372010-05-27 20:51:26 +00008118 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008119 swap_index;
8120
8121 index=(-1);
8122 swap_index=(-2);
8123 if (*option != '+')
8124 {
8125 GeometryInfo
8126 geometry_info;
8127
8128 MagickStatusType
8129 flags;
8130
8131 swap_index=(-1);
8132 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008133 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008134 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008135 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008136 }
8137 p=GetImageFromList(*images,index);
8138 q=GetImageFromList(*images,swap_index);
8139 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8140 {
8141 (void) ThrowMagickException(exception,GetMagickModule(),
8142 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8143 status=MagickFalse;
8144 break;
8145 }
8146 if (p == q)
8147 break;
8148 swap=CloneImage(p,0,0,MagickTrue,exception);
8149 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8150 ReplaceImageInList(&q,swap);
8151 *images=GetFirstImageInList(q);
8152 break;
8153 }
8154 break;
8155 }
8156 case 'w':
8157 {
8158 if (LocaleCompare("write",option+1) == 0)
8159 {
cristy071dd7b2010-04-09 13:04:54 +00008160 char
cristy06609ee2010-03-17 20:21:27 +00008161 key[MaxTextExtent];
8162
cristy3ed852e2009-09-05 21:47:34 +00008163 Image
8164 *write_images;
8165
8166 ImageInfo
8167 *write_info;
8168
cristy6b3da3a2010-06-20 02:21:46 +00008169 (void) SyncImagesSettings(mogrify_info,*images);
cristyb51dff52011-05-19 16:55:47 +00008170 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
cristy06609ee2010-03-17 20:21:27 +00008171 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008172 write_images=(*images);
8173 if (*option == '+')
8174 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008175 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008176 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8177 write_info=DestroyImageInfo(write_info);
8178 if (*option == '+')
8179 write_images=DestroyImageList(write_images);
8180 break;
8181 }
8182 break;
8183 }
8184 default:
8185 break;
8186 }
8187 i+=count;
8188 }
8189 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008190 mogrify_info=DestroyImageInfo(mogrify_info);
8191 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008192 return(status != 0 ? MagickTrue : MagickFalse);
8193}
8194
8195/*
8196%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8197% %
8198% %
8199% %
8200+ M o g r i f y I m a g e s %
8201% %
8202% %
8203% %
8204%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8205%
8206% MogrifyImages() applies image processing options to a sequence of images as
8207% prescribed by command line options.
8208%
8209% The format of the MogrifyImage method is:
8210%
8211% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8212% const MagickBooleanType post,const int argc,const char **argv,
8213% Image **images,Exceptioninfo *exception)
8214%
8215% A description of each parameter follows:
8216%
8217% o image_info: the image info..
8218%
8219% o post: If true, post process image list operators otherwise pre-process.
8220%
8221% o argc: Specifies a pointer to an integer describing the number of
8222% elements in the argument vector.
8223%
8224% o argv: Specifies a pointer to a text array containing the command line
8225% arguments.
8226%
anthonye9c27192011-03-27 08:07:06 +00008227% o images: pointer to a pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00008228%
8229% o exception: return any errors or warnings in this structure.
8230%
8231*/
8232WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8233 const MagickBooleanType post,const int argc,const char **argv,
8234 Image **images,ExceptionInfo *exception)
8235{
8236#define MogrifyImageTag "Mogrify/Image"
8237
anthonye9c27192011-03-27 08:07:06 +00008238 MagickStatusType
8239 status;
cristy3ed852e2009-09-05 21:47:34 +00008240
cristy0e9f9c12010-02-11 03:00:47 +00008241 MagickBooleanType
8242 proceed;
8243
anthonye9c27192011-03-27 08:07:06 +00008244 size_t
8245 n;
cristy3ed852e2009-09-05 21:47:34 +00008246
cristybb503372010-05-27 20:51:26 +00008247 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008248 i;
8249
cristy3ed852e2009-09-05 21:47:34 +00008250 assert(image_info != (ImageInfo *) NULL);
8251 assert(image_info->signature == MagickSignature);
8252 if (images == (Image **) NULL)
8253 return(MogrifyImage(image_info,argc,argv,images,exception));
anthonye9c27192011-03-27 08:07:06 +00008254 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008255 assert((*images)->signature == MagickSignature);
8256 if ((*images)->debug != MagickFalse)
8257 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8258 (*images)->filename);
8259 if ((argc <= 0) || (*argv == (char *) NULL))
8260 return(MagickTrue);
8261 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8262 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008263 status=0;
anthonye9c27192011-03-27 08:07:06 +00008264
anthonyce2716b2011-04-22 09:51:34 +00008265#if 0
cristy1e604812011-05-19 18:07:50 +00008266 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8267 post?"post":"pre");
anthonyce2716b2011-04-22 09:51:34 +00008268#endif
8269
anthonye9c27192011-03-27 08:07:06 +00008270 /*
8271 Pre-process multi-image sequence operators
8272 */
cristy3ed852e2009-09-05 21:47:34 +00008273 if (post == MagickFalse)
8274 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthonye9c27192011-03-27 08:07:06 +00008275 /*
8276 For each image, process simple single image operators
8277 */
8278 i=0;
8279 n=GetImageListLength(*images);
cristy9f027d12011-09-21 01:17:17 +00008280 for ( ; ; )
cristy3ed852e2009-09-05 21:47:34 +00008281 {
anthonyce2716b2011-04-22 09:51:34 +00008282#if 0
cristy1e604812011-05-19 18:07:50 +00008283 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8284 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008285#endif
anthonye9c27192011-03-27 08:07:06 +00008286 status&=MogrifyImage(image_info,argc,argv,images,exception);
8287 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
cristy0e9f9c12010-02-11 03:00:47 +00008288 if (proceed == MagickFalse)
8289 break;
anthonye9c27192011-03-27 08:07:06 +00008290 if ( (*images)->next == (Image *) NULL )
8291 break;
8292 *images=(*images)->next;
8293 i++;
cristy3ed852e2009-09-05 21:47:34 +00008294 }
anthonye9c27192011-03-27 08:07:06 +00008295 assert( *images != (Image *) NULL );
anthonyce2716b2011-04-22 09:51:34 +00008296#if 0
cristy1e604812011-05-19 18:07:50 +00008297 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8298 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008299#endif
anthonye9c27192011-03-27 08:07:06 +00008300
8301 /*
8302 Post-process, multi-image sequence operators
8303 */
8304 *images=GetFirstImageInList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008305 if (post != MagickFalse)
anthonye9c27192011-03-27 08:07:06 +00008306 status&=MogrifyImageList(image_info,argc,argv,images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008307 return(status != 0 ? MagickTrue : MagickFalse);
8308}