blob: be5d208fe51fdc6dc73279fb7f1e7e7b8b39e752 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7% MM MM O O G R R I F Y Y %
8% M M M O O G GGG RRRR I FFF Y %
9% M M O O G G R R I F Y %
10% M M OOO GGGG R R IIIII F Y %
11% %
12% %
13% MagickWand Module Methods %
14% %
15% Software Design %
16% John Cristy %
17% March 2000 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36% Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37% draw on, flip, join, re-sample, and much more. This tool is similiar to
38% convert except that the original image file is overwritten (unless you
39% change the file suffix with the -format option) with any changes you
cristy6a917d92009-10-06 19:23:54 +000040% request.
cristy3ed852e2009-09-05 21:47:34 +000041%
42*/
43
44/*
45 Include declarations.
46*/
cristy4c08aed2011-07-01 19:47:50 +000047#include "MagickWand/studio.h"
48#include "MagickWand/MagickWand.h"
49#include "MagickWand/mogrify-private.h"
50#undef DegreesToRadians
51#undef RadiansToDegrees
52#include "MagickCore/image-private.h"
53#include "MagickCore/monitor-private.h"
cristy4c08aed2011-07-01 19:47:50 +000054#include "MagickCore/string-private.h"
cristy0740a982011-10-13 15:01:01 +000055#include "MagickCore/thread-private.h"
cristy18c6c272011-09-23 14:40:37 +000056#include "MagickCore/utility-private.h"
cristy3ed852e2009-09-05 21:47:34 +000057
58/*
cristy154fa9d2011-08-05 14:25:15 +000059 Constant declaration.
60*/
cristy3a557c02011-08-06 19:48:02 +000061static const char
cristy638895a2011-08-06 23:19:14 +000062 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
cristy154fa9d2011-08-05 14:25:15 +000065
66/*
cristy3ed852e2009-09-05 21:47:34 +000067 Define declarations.
68*/
69#define UndefinedCompressionQuality 0UL
70
71/*
cristy3ed852e2009-09-05 21:47:34 +000072%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73% %
74% %
75% %
cristy5063d812010-10-19 16:28:10 +000076% M a g i c k C o m m a n d G e n e s i s %
cristy3980b0d2009-10-25 14:37:13 +000077% %
78% %
79% %
80%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81%
82% MagickCommandGenesis() applies image processing options to an image as
83% prescribed by command line options.
84%
85% The format of the MagickCommandGenesis method is:
86%
87% MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
cristy5063d812010-10-19 16:28:10 +000088% MagickCommand command,int argc,char **argv,char **metadata,
89% ExceptionInfo *exception)
cristy3980b0d2009-10-25 14:37:13 +000090%
91% A description of each parameter follows:
92%
93% o image_info: the image info.
94%
cristy5063d812010-10-19 16:28:10 +000095% o command: Choose from ConvertImageCommand, IdentifyImageCommand,
cristy8a9106f2011-07-05 14:39:26 +000096% MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
cristy5063d812010-10-19 16:28:10 +000097% ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98% DisplayImageCommand, or AnimateImageCommand.
cristy3980b0d2009-10-25 14:37:13 +000099%
100% o argc: Specifies a pointer to an integer describing the number of
101% elements in the argument vector.
102%
103% o argv: Specifies a pointer to a text array containing the command line
104% arguments.
105%
cristy5063d812010-10-19 16:28:10 +0000106% o metadata: any metadata is returned here.
cristy3980b0d2009-10-25 14:37:13 +0000107%
108% o exception: return any errors or warnings in this structure.
109%
110*/
111WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
112 MagickCommand command,int argc,char **argv,char **metadata,
113 ExceptionInfo *exception)
114{
115 char
116 *option;
117
118 double
119 duration,
120 elapsed_time,
121 user_time;
122
cristy3980b0d2009-10-25 14:37:13 +0000123 MagickBooleanType
124 concurrent,
125 regard_warnings,
126 status;
127
cristybb503372010-05-27 20:51:26 +0000128 register ssize_t
cristy3980b0d2009-10-25 14:37:13 +0000129 i;
130
131 TimerInfo
132 *timer;
133
cristybb503372010-05-27 20:51:26 +0000134 size_t
cristy3980b0d2009-10-25 14:37:13 +0000135 iterations;
136
cristyd0a94fa2010-03-12 14:18:11 +0000137 (void) setlocale(LC_ALL,"");
138 (void) setlocale(LC_NUMERIC,"C");
cristy3980b0d2009-10-25 14:37:13 +0000139 concurrent=MagickFalse;
140 duration=(-1.0);
141 iterations=1;
cristy33557d72009-11-06 00:54:33 +0000142 status=MagickFalse;
cristy3980b0d2009-10-25 14:37:13 +0000143 regard_warnings=MagickFalse;
cristybb503372010-05-27 20:51:26 +0000144 for (i=1; i < (ssize_t) (argc-1); i++)
cristy3980b0d2009-10-25 14:37:13 +0000145 {
146 option=argv[i];
147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
148 continue;
149 if (LocaleCompare("bench",option+1) == 0)
cristye27293e2009-12-18 02:53:20 +0000150 iterations=StringToUnsignedLong(argv[++i]);
cristy3980b0d2009-10-25 14:37:13 +0000151 if (LocaleCompare("concurrent",option+1) == 0)
152 concurrent=MagickTrue;
153 if (LocaleCompare("debug",option+1) == 0)
154 (void) SetLogEventMask(argv[++i]);
155 if (LocaleCompare("duration",option+1) == 0)
cristyc1acd842011-05-19 23:05:47 +0000156 duration=InterpretLocaleValue(argv[++i],(char **) NULL);
cristy3980b0d2009-10-25 14:37:13 +0000157 if (LocaleCompare("regard-warnings",option+1) == 0)
158 regard_warnings=MagickTrue;
159 }
160 timer=AcquireTimerInfo();
cristyceae09d2009-10-28 17:18:47 +0000161 if (concurrent == MagickFalse)
cristy3980b0d2009-10-25 14:37:13 +0000162 {
cristybb503372010-05-27 20:51:26 +0000163 for (i=0; i < (ssize_t) iterations; i++)
cristy3980b0d2009-10-25 14:37:13 +0000164 {
cristy33557d72009-11-06 00:54:33 +0000165 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000166 continue;
167 if (duration > 0)
168 {
169 if (GetElapsedTime(timer) > duration)
170 continue;
171 (void) ContinueTimer(timer);
172 }
173 status=command(image_info,argc,argv,metadata,exception);
cristy3980b0d2009-10-25 14:37:13 +0000174 if (exception->severity != UndefinedException)
175 {
176 if ((exception->severity > ErrorException) ||
177 (regard_warnings != MagickFalse))
178 status=MagickTrue;
179 CatchException(exception);
180 }
cristy3d1a5512009-10-25 21:23:27 +0000181 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
cristy3980b0d2009-10-25 14:37:13 +0000182 {
183 (void) fputs(*metadata,stdout);
184 (void) fputc('\n',stdout);
185 *metadata=DestroyString(*metadata);
186 }
187 }
188 }
cristyceae09d2009-10-28 17:18:47 +0000189 else
190 {
191 SetOpenMPNested(1);
cristyb5d5f722009-11-04 03:03:49 +0000192#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristyceae09d2009-10-28 17:18:47 +0000193 # pragma omp parallel for shared(status)
194#endif
cristybb503372010-05-27 20:51:26 +0000195 for (i=0; i < (ssize_t) iterations; i++)
cristyceae09d2009-10-28 17:18:47 +0000196 {
cristy33557d72009-11-06 00:54:33 +0000197 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000198 continue;
199 if (duration > 0)
200 {
201 if (GetElapsedTime(timer) > duration)
202 continue;
203 (void) ContinueTimer(timer);
204 }
205 status=command(image_info,argc,argv,metadata,exception);
cristyb5d5f722009-11-04 03:03:49 +0000206#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristy524549f2010-06-20 21:10:20 +0000207 # pragma omp critical (MagickCore_CommandGenesis)
cristyceae09d2009-10-28 17:18:47 +0000208#endif
209 {
210 if (exception->severity != UndefinedException)
211 {
212 if ((exception->severity > ErrorException) ||
213 (regard_warnings != MagickFalse))
214 status=MagickTrue;
215 CatchException(exception);
216 }
217 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
218 {
219 (void) fputs(*metadata,stdout);
220 (void) fputc('\n',stdout);
221 *metadata=DestroyString(*metadata);
222 }
223 }
224 }
225 }
cristy3980b0d2009-10-25 14:37:13 +0000226 if (iterations > 1)
227 {
228 elapsed_time=GetElapsedTime(timer);
229 user_time=GetUserTime(timer);
cristyb51dff52011-05-19 16:55:47 +0000230 (void) FormatLocaleFile(stderr,
cristye8c25f92010-06-03 00:53:06 +0000231 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
232 iterations,1.0*iterations/elapsed_time,user_time,(double)
233 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
234 (1000.0*(elapsed_time-floor(elapsed_time))));
cristy524549f2010-06-20 21:10:20 +0000235 (void) fflush(stderr);
cristy3980b0d2009-10-25 14:37:13 +0000236 }
237 timer=DestroyTimerInfo(timer);
cristy1f9e1ed2009-11-18 04:09:38 +0000238 return(status);
cristy3980b0d2009-10-25 14:37:13 +0000239}
240
241/*
242%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243% %
244% %
245% %
cristy3ed852e2009-09-05 21:47:34 +0000246+ M o g r i f y I m a g e %
247% %
248% %
249% %
250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251%
anthonye9c27192011-03-27 08:07:06 +0000252% MogrifyImage() applies simple single image processing options to a single
anthonydf8ebac2011-04-27 09:03:19 +0000253% image that may be part of a large list, but also handles any 'region'
254% image handling.
anthonye9c27192011-03-27 08:07:06 +0000255%
256% The image in the list may be modified in three different ways...
257%
258% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
259% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
260% * replace by a list of images (only the -separate option!)
261%
262% In each case the result is returned into the list, and a pointer to the
263% modified image (last image added if replaced by a list of images) is
264% returned.
265%
266% ASIDE: The -crop is present but restricted to non-tile single image crops
267%
268% This means if all the images are being processed (such as by
269% MogrifyImages(), next image to be processed will be as per the pointer
270% (*image)->next. Also the image list may grow as a result of some specific
271% operations but as images are never merged or deleted, it will never shrink
272% in length. Typically the list will remain the same length.
273%
274% WARNING: As the image pointed to may be replaced, the first image in the
275% list may also change. GetFirstImageInList() should be used by caller if
276% they wish return the Image pointer to the first image in list.
277%
cristy3ed852e2009-09-05 21:47:34 +0000278%
279% The format of the MogrifyImage method is:
280%
281% MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
282% const char **argv,Image **image)
283%
284% A description of each parameter follows:
285%
286% o image_info: the image info..
287%
288% o argc: Specifies a pointer to an integer describing the number of
289% elements in the argument vector.
290%
291% o argv: Specifies a pointer to a text array containing the command line
292% arguments.
293%
294% o image: the image.
295%
296% o exception: return any errors or warnings in this structure.
297%
298*/
299
cristy4c08aed2011-07-01 19:47:50 +0000300/*
anthony0d0fd352011-10-04 11:09:07 +0000301 GetImageCache() will read an image into a image cache if not already
302 present then return the image that is in the cache under that filename.
cristy4c08aed2011-07-01 19:47:50 +0000303*/
anthonydf8ebac2011-04-27 09:03:19 +0000304static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
305 ExceptionInfo *exception)
306{
307 char
308 key[MaxTextExtent];
309
310 ExceptionInfo
311 *sans_exception;
312
313 Image
314 *image;
315
316 ImageInfo
317 *read_info;
318
cristyb51dff52011-05-19 16:55:47 +0000319 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
anthonydf8ebac2011-04-27 09:03:19 +0000320 sans_exception=AcquireExceptionInfo();
321 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
322 sans_exception=DestroyExceptionInfo(sans_exception);
323 if (image != (Image *) NULL)
324 return(image);
325 read_info=CloneImageInfo(image_info);
326 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
327 image=ReadImage(read_info,exception);
328 read_info=DestroyImageInfo(read_info);
329 if (image != (Image *) NULL)
330 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
331 return(image);
332}
333
cristy3ed852e2009-09-05 21:47:34 +0000334static MagickBooleanType IsPathWritable(const char *path)
335{
336 if (IsPathAccessible(path) == MagickFalse)
337 return(MagickFalse);
cristy18c6c272011-09-23 14:40:37 +0000338 if (access_utf8(path,W_OK) != 0)
cristy3ed852e2009-09-05 21:47:34 +0000339 return(MagickFalse);
340 return(MagickTrue);
341}
342
cristybb503372010-05-27 20:51:26 +0000343static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
cristy3ed852e2009-09-05 21:47:34 +0000344{
345 if (x > y)
346 return(x);
347 return(y);
348}
349
anthonydf8ebac2011-04-27 09:03:19 +0000350static MagickBooleanType MonitorProgress(const char *text,
351 const MagickOffsetType offset,const MagickSizeType extent,
352 void *wand_unused(client_data))
353{
354 char
355 message[MaxTextExtent],
356 tag[MaxTextExtent];
357
358 const char
359 *locale_message;
360
361 register char
362 *p;
363
364 if (extent < 2)
365 return(MagickTrue);
366 (void) CopyMagickMemory(tag,text,MaxTextExtent);
367 p=strrchr(tag,'/');
368 if (p != (char *) NULL)
369 *p='\0';
cristyb51dff52011-05-19 16:55:47 +0000370 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
anthonydf8ebac2011-04-27 09:03:19 +0000371 locale_message=GetLocaleMessage(message);
372 if (locale_message == message)
373 locale_message=tag;
374 if (p == (char *) NULL)
cristy1e604812011-05-19 18:07:50 +0000375 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
376 locale_message,(long) offset,(unsigned long) extent,(long)
377 (100L*offset/(extent-1)));
anthonydf8ebac2011-04-27 09:03:19 +0000378 else
cristyb51dff52011-05-19 16:55:47 +0000379 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
anthonydf8ebac2011-04-27 09:03:19 +0000380 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
381 (100L*offset/(extent-1)));
382 if (offset == (MagickOffsetType) (extent-1))
cristyb51dff52011-05-19 16:55:47 +0000383 (void) FormatLocaleFile(stderr,"\n");
anthonydf8ebac2011-04-27 09:03:19 +0000384 (void) fflush(stderr);
385 return(MagickTrue);
386}
387
anthony0d0fd352011-10-04 11:09:07 +0000388 /*
389 SparseColorOption() parses the complex -sparse-color argument into an
390 an array of floating point values then calls SparseColorImage().
391 Argument is a complex mix of floating-point pixel coodinates, and color
392 specifications (or direct floating point numbers). The number of floats
393 needed to represent a color varies depending on the current channel
394 setting.
395 */
cristy3884f692011-07-08 18:00:18 +0000396static Image *SparseColorOption(const Image *image,
anthonydf8ebac2011-04-27 09:03:19 +0000397 const SparseColorMethod method,const char *arguments,
398 const MagickBooleanType color_from_image,ExceptionInfo *exception)
399{
anthonydf8ebac2011-04-27 09:03:19 +0000400 char
401 token[MaxTextExtent];
402
403 const char
404 *p;
405
406 double
407 *sparse_arguments;
408
anthonydf8ebac2011-04-27 09:03:19 +0000409 Image
410 *sparse_image;
411
cristy4c08aed2011-07-01 19:47:50 +0000412 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000413 color;
414
415 MagickBooleanType
416 error;
417
cristy5f09d852011-05-29 01:39:29 +0000418 register size_t
419 x;
420
421 size_t
422 number_arguments,
423 number_colors;
424
anthonydf8ebac2011-04-27 09:03:19 +0000425 assert(image != (Image *) NULL);
426 assert(image->signature == MagickSignature);
427 if (image->debug != MagickFalse)
428 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
429 assert(exception != (ExceptionInfo *) NULL);
430 assert(exception->signature == MagickSignature);
431 /*
432 Limit channels according to image - and add up number of color channel.
433 */
anthonydf8ebac2011-04-27 09:03:19 +0000434 number_colors=0;
cristyed231572011-07-14 02:18:59 +0000435 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000436 number_colors++;
cristyed231572011-07-14 02:18:59 +0000437 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000438 number_colors++;
cristyed231572011-07-14 02:18:59 +0000439 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000440 number_colors++;
cristyed231572011-07-14 02:18:59 +0000441 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000442 (image->colorspace == CMYKColorspace))
anthonydf8ebac2011-04-27 09:03:19 +0000443 number_colors++;
cristyed231572011-07-14 02:18:59 +0000444 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000445 (image->matte != MagickFalse))
anthonydf8ebac2011-04-27 09:03:19 +0000446 number_colors++;
447
448 /*
449 Read string, to determine number of arguments needed,
450 */
451 p=arguments;
452 x=0;
453 while( *p != '\0' )
454 {
455 GetMagickToken(p,&p,token);
456 if ( token[0] == ',' ) continue;
457 if ( isalpha((int) token[0]) || token[0] == '#' ) {
458 if ( color_from_image ) {
459 (void) ThrowMagickException(exception,GetMagickModule(),
460 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
461 "Color arg given, when colors are coming from image");
462 return( (Image *)NULL);
463 }
464 x += number_colors; /* color argument */
465 }
466 else {
467 x++; /* floating point argument */
468 }
469 }
470 error=MagickTrue;
471 if ( color_from_image ) {
472 /* just the control points are being given */
473 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
474 number_arguments=(x/2)*(2+number_colors);
475 }
476 else {
477 /* control points and color values */
478 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
479 number_arguments=x;
480 }
481 if ( error ) {
482 (void) ThrowMagickException(exception,GetMagickModule(),
483 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
484 "Invalid number of Arguments");
485 return( (Image *)NULL);
486 }
487
488 /* Allocate and fill in the floating point arguments */
489 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
490 sizeof(*sparse_arguments));
491 if (sparse_arguments == (double *) NULL) {
492 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
493 "MemoryAllocationFailed","%s","SparseColorOption");
494 return( (Image *)NULL);
495 }
496 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
497 sizeof(*sparse_arguments));
498 p=arguments;
499 x=0;
500 while( *p != '\0' && x < number_arguments ) {
501 /* X coordinate */
502 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
503 if ( token[0] == '\0' ) break;
504 if ( isalpha((int) token[0]) || token[0] == '#' ) {
505 (void) ThrowMagickException(exception,GetMagickModule(),
506 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
507 "Color found, instead of X-coord");
508 error = MagickTrue;
509 break;
510 }
cristyc1acd842011-05-19 23:05:47 +0000511 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000512 /* Y coordinate */
513 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
514 if ( token[0] == '\0' ) break;
515 if ( isalpha((int) token[0]) || token[0] == '#' ) {
516 (void) ThrowMagickException(exception,GetMagickModule(),
517 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
518 "Color found, instead of Y-coord");
519 error = MagickTrue;
520 break;
521 }
cristyc1acd842011-05-19 23:05:47 +0000522 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000523 /* color values for this control point */
524#if 0
525 if ( (color_from_image ) {
526 /* get color from image */
527 /* HOW??? */
528 }
529 else
530#endif
531 {
532 /* color name or function given in string argument */
533 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
534 if ( token[0] == '\0' ) break;
535 if ( isalpha((int) token[0]) || token[0] == '#' ) {
536 /* Color string given */
cristy269c9412011-10-13 23:41:15 +0000537 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
cristyed231572011-07-14 02:18:59 +0000538 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000539 sparse_arguments[x++] = QuantumScale*color.red;
cristyed231572011-07-14 02:18:59 +0000540 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000541 sparse_arguments[x++] = QuantumScale*color.green;
cristyed231572011-07-14 02:18:59 +0000542 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000543 sparse_arguments[x++] = QuantumScale*color.blue;
cristyed231572011-07-14 02:18:59 +0000544 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000545 (image->colorspace == CMYKColorspace))
cristy4c08aed2011-07-01 19:47:50 +0000546 sparse_arguments[x++] = QuantumScale*color.black;
cristyed231572011-07-14 02:18:59 +0000547 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000548 (image->matte != MagickFalse))
cristy4c08aed2011-07-01 19:47:50 +0000549 sparse_arguments[x++] = QuantumScale*color.alpha;
anthonydf8ebac2011-04-27 09:03:19 +0000550 }
551 else {
552 /* Colors given as a set of floating point values - experimental */
553 /* NB: token contains the first floating point value to use! */
cristyed231572011-07-14 02:18:59 +0000554 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000555 {
anthonydf8ebac2011-04-27 09:03:19 +0000556 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
557 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
558 break;
cristyc1acd842011-05-19 23:05:47 +0000559 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000560 token[0] = ','; /* used this token - get another */
561 }
cristyed231572011-07-14 02:18:59 +0000562 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000563 {
anthonydf8ebac2011-04-27 09:03:19 +0000564 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
565 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
566 break;
cristyc1acd842011-05-19 23:05:47 +0000567 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000568 token[0] = ','; /* used this token - get another */
569 }
cristyed231572011-07-14 02:18:59 +0000570 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000571 {
anthonydf8ebac2011-04-27 09:03:19 +0000572 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
573 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
574 break;
cristyc1acd842011-05-19 23:05:47 +0000575 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000576 token[0] = ','; /* used this token - get another */
577 }
cristyed231572011-07-14 02:18:59 +0000578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000579 (image->colorspace == CMYKColorspace))
580 {
anthonydf8ebac2011-04-27 09:03:19 +0000581 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
582 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
583 break;
cristyc1acd842011-05-19 23:05:47 +0000584 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000585 token[0] = ','; /* used this token - get another */
586 }
cristyed231572011-07-14 02:18:59 +0000587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000588 (image->matte != MagickFalse))
589 {
anthonydf8ebac2011-04-27 09:03:19 +0000590 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
592 break;
cristyc1acd842011-05-19 23:05:47 +0000593 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000594 token[0] = ','; /* used this token - get another */
595 }
596 }
597 }
598 }
599 if ( number_arguments != x && !error ) {
600 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
601 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
602 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
603 return( (Image *)NULL);
604 }
605 if ( error )
606 return( (Image *)NULL);
607
608 /* Call the Interpolation function with the parsed arguments */
cristy3884f692011-07-08 18:00:18 +0000609 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
610 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000611 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
612 return( sparse_image );
613}
614
cristy3ed852e2009-09-05 21:47:34 +0000615WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
616 const char **argv,Image **image,ExceptionInfo *exception)
617{
anthonydf8ebac2011-04-27 09:03:19 +0000618 ChannelType
619 channel;
620
cristy633f0c62011-09-15 13:27:36 +0000621 CompositeOperator
622 compose;
623
anthonydf8ebac2011-04-27 09:03:19 +0000624 const char
625 *format,
626 *option;
627
cristy9ed1f812011-10-08 02:00:08 +0000628 double
629 attenuate;
630
anthonydf8ebac2011-04-27 09:03:19 +0000631 DrawInfo
632 *draw_info;
633
634 GeometryInfo
635 geometry_info;
636
cristy3ed852e2009-09-05 21:47:34 +0000637 Image
638 *region_image;
639
anthonydf8ebac2011-04-27 09:03:19 +0000640 ImageInfo
641 *mogrify_info;
642
cristyebbcfea2011-02-25 02:43:54 +0000643 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000644 status;
645
cristy4c08aed2011-07-01 19:47:50 +0000646 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000647 fill;
cristy3ed852e2009-09-05 21:47:34 +0000648
anthonydf8ebac2011-04-27 09:03:19 +0000649 MagickStatusType
650 flags;
651
cristy28474bf2011-09-11 23:32:52 +0000652 PixelInterpolateMethod
653 interpolate_method;
654
anthonydf8ebac2011-04-27 09:03:19 +0000655 QuantizeInfo
656 *quantize_info;
657
658 RectangleInfo
659 geometry,
660 region_geometry;
anthony56ad4222011-04-25 11:04:27 +0000661
cristybb503372010-05-27 20:51:26 +0000662 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000663 i;
664
665 /*
666 Initialize method variables.
667 */
668 assert(image_info != (const ImageInfo *) NULL);
669 assert(image_info->signature == MagickSignature);
670 assert(image != (Image **) NULL);
671 assert((*image)->signature == MagickSignature);
672 if ((*image)->debug != MagickFalse)
673 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
674 if (argc < 0)
675 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +0000676 mogrify_info=CloneImageInfo(image_info);
anthonydf8ebac2011-04-27 09:03:19 +0000677 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
678 quantize_info=AcquireQuantizeInfo(mogrify_info);
679 SetGeometryInfo(&geometry_info);
cristy4c08aed2011-07-01 19:47:50 +0000680 GetPixelInfo(*image,&fill);
681 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
cristy9ed1f812011-10-08 02:00:08 +0000682 attenuate=1.0;
cristy633f0c62011-09-15 13:27:36 +0000683 compose=(*image)->compose;
cristy28474bf2011-09-11 23:32:52 +0000684 interpolate_method=UndefinedInterpolatePixel;
anthonydf8ebac2011-04-27 09:03:19 +0000685 channel=mogrify_info->channel;
686 format=GetImageOption(mogrify_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000687 SetGeometry(*image,&region_geometry);
688 region_image=NewImageList();
689 /*
690 Transmogrify the image.
691 */
cristybb503372010-05-27 20:51:26 +0000692 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000693 {
anthonydf8ebac2011-04-27 09:03:19 +0000694 Image
695 *mogrify_image;
696
anthonye9c27192011-03-27 08:07:06 +0000697 ssize_t
698 count;
699
anthonydf8ebac2011-04-27 09:03:19 +0000700 option=argv[i];
701 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000702 continue;
anthonydf8ebac2011-04-27 09:03:19 +0000703 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
704 0L);
cristycee97112010-05-28 00:44:52 +0000705 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000706 break;
cristy6b3da3a2010-06-20 02:21:46 +0000707 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000708 mogrify_image=(Image *)NULL;
709 switch (*(option+1))
710 {
711 case 'a':
cristy3ed852e2009-09-05 21:47:34 +0000712 {
anthonydf8ebac2011-04-27 09:03:19 +0000713 if (LocaleCompare("adaptive-blur",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000714 {
anthonydf8ebac2011-04-27 09:03:19 +0000715 /*
716 Adaptive blur image.
717 */
718 (void) SyncImageSettings(mogrify_info,*image);
719 flags=ParseGeometry(argv[i+1],&geometry_info);
720 if ((flags & SigmaValue) == 0)
721 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000722 if ((flags & XiValue) == 0)
723 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000724 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000725 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000726 break;
cristy3ed852e2009-09-05 21:47:34 +0000727 }
anthonydf8ebac2011-04-27 09:03:19 +0000728 if (LocaleCompare("adaptive-resize",option+1) == 0)
729 {
730 /*
731 Adaptive resize image.
732 */
733 (void) SyncImageSettings(mogrify_info,*image);
734 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
735 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
cristy28474bf2011-09-11 23:32:52 +0000736 geometry.height,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000737 break;
738 }
739 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
740 {
741 /*
742 Adaptive sharpen image.
743 */
744 (void) SyncImageSettings(mogrify_info,*image);
745 flags=ParseGeometry(argv[i+1],&geometry_info);
746 if ((flags & SigmaValue) == 0)
747 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000748 if ((flags & XiValue) == 0)
749 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000750 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000751 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000752 break;
753 }
754 if (LocaleCompare("affine",option+1) == 0)
755 {
756 /*
757 Affine matrix.
758 */
759 if (*option == '+')
760 {
761 GetAffineMatrix(&draw_info->affine);
762 break;
763 }
764 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
765 break;
766 }
767 if (LocaleCompare("alpha",option+1) == 0)
768 {
769 AlphaChannelType
770 alpha_type;
cristy3ed852e2009-09-05 21:47:34 +0000771
anthonydf8ebac2011-04-27 09:03:19 +0000772 (void) SyncImageSettings(mogrify_info,*image);
773 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
774 MagickFalse,argv[i+1]);
cristy63240882011-08-05 19:05:27 +0000775 (void) SetImageAlphaChannel(*image,alpha_type,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000776 break;
777 }
778 if (LocaleCompare("annotate",option+1) == 0)
779 {
780 char
781 *text,
782 geometry[MaxTextExtent];
783
784 /*
785 Annotate image.
786 */
787 (void) SyncImageSettings(mogrify_info,*image);
788 SetGeometryInfo(&geometry_info);
789 flags=ParseGeometry(argv[i+1],&geometry_info);
790 if ((flags & SigmaValue) == 0)
791 geometry_info.sigma=geometry_info.rho;
cristy018f07f2011-09-04 21:15:19 +0000792 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
793 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000794 if (text == (char *) NULL)
795 break;
796 (void) CloneString(&draw_info->text,text);
797 text=DestroyString(text);
cristyb51dff52011-05-19 16:55:47 +0000798 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
anthonydf8ebac2011-04-27 09:03:19 +0000799 geometry_info.xi,geometry_info.psi);
800 (void) CloneString(&draw_info->geometry,geometry);
801 draw_info->affine.sx=cos(DegreesToRadians(
802 fmod(geometry_info.rho,360.0)));
803 draw_info->affine.rx=sin(DegreesToRadians(
804 fmod(geometry_info.rho,360.0)));
805 draw_info->affine.ry=(-sin(DegreesToRadians(
806 fmod(geometry_info.sigma,360.0))));
807 draw_info->affine.sy=cos(DegreesToRadians(
808 fmod(geometry_info.sigma,360.0)));
cristy5cbc0162011-08-29 00:36:28 +0000809 (void) AnnotateImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000810 break;
811 }
812 if (LocaleCompare("antialias",option+1) == 0)
813 {
814 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
815 MagickFalse;
816 draw_info->text_antialias=(*option == '-') ? MagickTrue :
817 MagickFalse;
818 break;
819 }
cristy9ed1f812011-10-08 02:00:08 +0000820 if (LocaleCompare("attenuate",option+1) == 0)
821 {
822 if (*option == '+')
823 {
824 attenuate=1.0;
825 break;
826 }
827 attenuate=InterpretLocaleValue(argv[i+1],(char **) NULL);
828 break;
829 }
anthonydf8ebac2011-04-27 09:03:19 +0000830 if (LocaleCompare("auto-gamma",option+1) == 0)
831 {
832 /*
833 Auto Adjust Gamma of image based on its mean
834 */
835 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000836 (void) AutoGammaImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000837 break;
838 }
839 if (LocaleCompare("auto-level",option+1) == 0)
840 {
841 /*
842 Perfectly Normalize (max/min stretch) the image
843 */
844 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000845 (void) AutoLevelImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000846 break;
847 }
848 if (LocaleCompare("auto-orient",option+1) == 0)
849 {
850 (void) SyncImageSettings(mogrify_info,*image);
851 switch ((*image)->orientation)
852 {
853 case TopRightOrientation:
854 {
855 mogrify_image=FlopImage(*image,exception);
856 break;
857 }
858 case BottomRightOrientation:
859 {
860 mogrify_image=RotateImage(*image,180.0,exception);
861 break;
862 }
863 case BottomLeftOrientation:
864 {
865 mogrify_image=FlipImage(*image,exception);
866 break;
867 }
868 case LeftTopOrientation:
869 {
870 mogrify_image=TransposeImage(*image,exception);
871 break;
872 }
873 case RightTopOrientation:
874 {
875 mogrify_image=RotateImage(*image,90.0,exception);
876 break;
877 }
878 case RightBottomOrientation:
879 {
880 mogrify_image=TransverseImage(*image,exception);
881 break;
882 }
883 case LeftBottomOrientation:
884 {
885 mogrify_image=RotateImage(*image,270.0,exception);
886 break;
887 }
888 default:
889 break;
890 }
891 if (mogrify_image != (Image *) NULL)
892 mogrify_image->orientation=TopLeftOrientation;
893 break;
894 }
895 break;
896 }
897 case 'b':
898 {
899 if (LocaleCompare("black-threshold",option+1) == 0)
900 {
901 /*
902 Black threshold image.
903 */
904 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +0000905 (void) BlackThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +0000906 InheritException(exception,&(*image)->exception);
907 break;
908 }
909 if (LocaleCompare("blue-shift",option+1) == 0)
910 {
911 /*
912 Blue shift image.
913 */
914 (void) SyncImageSettings(mogrify_info,*image);
915 geometry_info.rho=1.5;
916 if (*option == '-')
917 flags=ParseGeometry(argv[i+1],&geometry_info);
918 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
919 break;
920 }
921 if (LocaleCompare("blur",option+1) == 0)
922 {
923 /*
924 Gaussian blur image.
925 */
926 (void) SyncImageSettings(mogrify_info,*image);
927 flags=ParseGeometry(argv[i+1],&geometry_info);
928 if ((flags & SigmaValue) == 0)
929 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000930 if ((flags & XiValue) == 0)
931 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000932 mogrify_image=BlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +0000933 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000934 break;
935 }
936 if (LocaleCompare("border",option+1) == 0)
937 {
938 /*
939 Surround image with a border of solid color.
940 */
941 (void) SyncImageSettings(mogrify_info,*image);
942 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
943 if ((flags & SigmaValue) == 0)
944 geometry.height=geometry.width;
cristy633f0c62011-09-15 13:27:36 +0000945 mogrify_image=BorderImage(*image,&geometry,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000946 break;
947 }
948 if (LocaleCompare("bordercolor",option+1) == 0)
949 {
950 if (*option == '+')
951 {
cristy9950d572011-10-01 18:22:35 +0000952 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy05c0c9a2011-09-05 23:16:13 +0000953 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000954 break;
955 }
cristy9950d572011-10-01 18:22:35 +0000956 (void) QueryColorCompliance(argv[i+1],AllCompliance,
957 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000958 break;
959 }
960 if (LocaleCompare("box",option+1) == 0)
961 {
cristy9950d572011-10-01 18:22:35 +0000962 (void) QueryColorCompliance(argv[i+1],AllCompliance,
963 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000964 break;
965 }
966 if (LocaleCompare("brightness-contrast",option+1) == 0)
967 {
968 double
969 brightness,
970 contrast;
971
972 GeometryInfo
973 geometry_info;
974
975 MagickStatusType
976 flags;
977
978 /*
979 Brightness / contrast image.
980 */
981 (void) SyncImageSettings(mogrify_info,*image);
982 flags=ParseGeometry(argv[i+1],&geometry_info);
983 brightness=geometry_info.rho;
984 contrast=0.0;
985 if ((flags & SigmaValue) != 0)
986 contrast=geometry_info.sigma;
cristy444eda62011-08-10 02:07:46 +0000987 (void) BrightnessContrastImage(*image,brightness,contrast,
988 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000989 InheritException(exception,&(*image)->exception);
990 break;
991 }
992 break;
993 }
994 case 'c':
995 {
996 if (LocaleCompare("cdl",option+1) == 0)
997 {
998 char
999 *color_correction_collection;
1000
1001 /*
1002 Color correct with a color decision list.
1003 */
1004 (void) SyncImageSettings(mogrify_info,*image);
1005 color_correction_collection=FileToString(argv[i+1],~0,exception);
1006 if (color_correction_collection == (char *) NULL)
1007 break;
cristy1bfa9f02011-08-11 02:35:43 +00001008 (void) ColorDecisionListImage(*image,color_correction_collection,
1009 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001010 InheritException(exception,&(*image)->exception);
1011 break;
1012 }
1013 if (LocaleCompare("channel",option+1) == 0)
1014 {
1015 if (*option == '+')
cristyfa806a72011-07-04 02:06:13 +00001016 channel=DefaultChannels;
anthonydf8ebac2011-04-27 09:03:19 +00001017 else
cristyfa806a72011-07-04 02:06:13 +00001018 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00001019 SetPixelChannelMap(*image,channel);
anthonydf8ebac2011-04-27 09:03:19 +00001020 break;
1021 }
1022 if (LocaleCompare("charcoal",option+1) == 0)
1023 {
1024 /*
1025 Charcoal image.
1026 */
1027 (void) SyncImageSettings(mogrify_info,*image);
1028 flags=ParseGeometry(argv[i+1],&geometry_info);
1029 if ((flags & SigmaValue) == 0)
1030 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001031 if ((flags & XiValue) == 0)
1032 geometry_info.xi=1.0;
anthonydf8ebac2011-04-27 09:03:19 +00001033 mogrify_image=CharcoalImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001034 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001035 break;
1036 }
1037 if (LocaleCompare("chop",option+1) == 0)
1038 {
1039 /*
1040 Chop the image.
1041 */
1042 (void) SyncImageSettings(mogrify_info,*image);
1043 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1044 mogrify_image=ChopImage(*image,&geometry,exception);
1045 break;
1046 }
1047 if (LocaleCompare("clamp",option+1) == 0)
1048 {
1049 /*
1050 Clamp image.
1051 */
1052 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00001053 (void) ClampImage(*image);
anthonydf8ebac2011-04-27 09:03:19 +00001054 InheritException(exception,&(*image)->exception);
1055 break;
1056 }
1057 if (LocaleCompare("clip",option+1) == 0)
1058 {
1059 (void) SyncImageSettings(mogrify_info,*image);
1060 if (*option == '+')
1061 {
cristy018f07f2011-09-04 21:15:19 +00001062 (void) SetImageClipMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001063 break;
1064 }
cristy018f07f2011-09-04 21:15:19 +00001065 (void) ClipImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001066 break;
1067 }
1068 if (LocaleCompare("clip-mask",option+1) == 0)
1069 {
1070 CacheView
1071 *mask_view;
1072
1073 Image
1074 *mask_image;
1075
cristy4c08aed2011-07-01 19:47:50 +00001076 register Quantum
anthonydf8ebac2011-04-27 09:03:19 +00001077 *restrict q;
1078
1079 register ssize_t
1080 x;
1081
1082 ssize_t
1083 y;
1084
1085 (void) SyncImageSettings(mogrify_info,*image);
1086 if (*option == '+')
1087 {
1088 /*
1089 Remove a mask.
1090 */
cristy018f07f2011-09-04 21:15:19 +00001091 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001092 break;
1093 }
1094 /*
1095 Set the image mask.
1096 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1097 */
1098 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1099 if (mask_image == (Image *) NULL)
1100 break;
cristy574cc262011-08-05 01:23:58 +00001101 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
anthonydf8ebac2011-04-27 09:03:19 +00001102 return(MagickFalse);
1103 mask_view=AcquireCacheView(mask_image);
1104 for (y=0; y < (ssize_t) mask_image->rows; y++)
1105 {
1106 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1107 exception);
cristyacd2ed22011-08-30 01:44:23 +00001108 if (q == (Quantum *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001109 break;
1110 for (x=0; x < (ssize_t) mask_image->columns; x++)
1111 {
1112 if (mask_image->matte == MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +00001113 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1114 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1115 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1116 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
cristyed231572011-07-14 02:18:59 +00001117 q+=GetPixelChannels(mask_image);
anthonydf8ebac2011-04-27 09:03:19 +00001118 }
1119 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1120 break;
1121 }
1122 mask_view=DestroyCacheView(mask_view);
1123 mask_image->matte=MagickTrue;
cristy018f07f2011-09-04 21:15:19 +00001124 (void) SetImageClipMask(*image,mask_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001125 InheritException(exception,&(*image)->exception);
1126 break;
1127 }
1128 if (LocaleCompare("clip-path",option+1) == 0)
1129 {
1130 (void) SyncImageSettings(mogrify_info,*image);
1131 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
cristy018f07f2011-09-04 21:15:19 +00001132 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001133 break;
1134 }
1135 if (LocaleCompare("colorize",option+1) == 0)
1136 {
1137 /*
1138 Colorize the image.
1139 */
1140 (void) SyncImageSettings(mogrify_info,*image);
cristyc7e6ff62011-10-03 13:46:11 +00001141 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001142 break;
1143 }
1144 if (LocaleCompare("color-matrix",option+1) == 0)
1145 {
1146 KernelInfo
1147 *kernel;
1148
1149 (void) SyncImageSettings(mogrify_info,*image);
1150 kernel=AcquireKernelInfo(argv[i+1]);
1151 if (kernel == (KernelInfo *) NULL)
1152 break;
1153 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1154 kernel=DestroyKernelInfo(kernel);
1155 break;
1156 }
1157 if (LocaleCompare("colors",option+1) == 0)
1158 {
1159 /*
1160 Reduce the number of colors in the image.
1161 */
1162 (void) SyncImageSettings(mogrify_info,*image);
1163 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1164 if (quantize_info->number_colors == 0)
1165 break;
1166 if (((*image)->storage_class == DirectClass) ||
1167 (*image)->colors > quantize_info->number_colors)
cristy018f07f2011-09-04 21:15:19 +00001168 (void) QuantizeImage(quantize_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001169 else
cristy018f07f2011-09-04 21:15:19 +00001170 (void) CompressImageColormap(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001171 break;
1172 }
1173 if (LocaleCompare("colorspace",option+1) == 0)
1174 {
1175 ColorspaceType
1176 colorspace;
1177
1178 (void) SyncImageSettings(mogrify_info,*image);
1179 if (*option == '+')
1180 {
1181 (void) TransformImageColorspace(*image,RGBColorspace);
1182 InheritException(exception,&(*image)->exception);
1183 break;
1184 }
1185 colorspace=(ColorspaceType) ParseCommandOption(
1186 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1187 (void) TransformImageColorspace(*image,colorspace);
1188 InheritException(exception,&(*image)->exception);
1189 break;
1190 }
cristy633f0c62011-09-15 13:27:36 +00001191 if (LocaleCompare("compose",option+1) == 0)
1192 {
1193 (void) SyncImageSettings(mogrify_info,*image);
1194 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1195 MagickFalse,argv[i+1]);
1196 break;
1197 }
anthonydf8ebac2011-04-27 09:03:19 +00001198 if (LocaleCompare("contrast",option+1) == 0)
1199 {
1200 (void) SyncImageSettings(mogrify_info,*image);
1201 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
cristye23ec9d2011-08-16 18:15:40 +00001202 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001203 break;
1204 }
1205 if (LocaleCompare("contrast-stretch",option+1) == 0)
1206 {
1207 double
1208 black_point,
1209 white_point;
1210
1211 MagickStatusType
1212 flags;
1213
1214 /*
1215 Contrast stretch image.
1216 */
1217 (void) SyncImageSettings(mogrify_info,*image);
1218 flags=ParseGeometry(argv[i+1],&geometry_info);
1219 black_point=geometry_info.rho;
1220 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1221 black_point;
1222 if ((flags & PercentValue) != 0)
1223 {
1224 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1225 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1226 }
1227 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1228 white_point;
cristye23ec9d2011-08-16 18:15:40 +00001229 (void) ContrastStretchImage(*image,black_point,white_point,
1230 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001231 InheritException(exception,&(*image)->exception);
1232 break;
1233 }
1234 if (LocaleCompare("convolve",option+1) == 0)
1235 {
anthonydf8ebac2011-04-27 09:03:19 +00001236 KernelInfo
cristy41cbe682011-07-15 19:12:37 +00001237 *kernel_info;
anthonydf8ebac2011-04-27 09:03:19 +00001238
anthonydf8ebac2011-04-27 09:03:19 +00001239 (void) SyncImageSettings(mogrify_info,*image);
cristy41cbe682011-07-15 19:12:37 +00001240 kernel_info=AcquireKernelInfo(argv[i+1]);
1241 if (kernel_info == (KernelInfo *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001242 break;
cristy0a922382011-07-16 15:30:34 +00001243 kernel_info->bias=(*image)->bias;
cristy5e6be1e2011-07-16 01:23:39 +00001244 mogrify_image=ConvolveImage(*image,kernel_info,exception);
cristy41cbe682011-07-15 19:12:37 +00001245 kernel_info=DestroyKernelInfo(kernel_info);
anthonydf8ebac2011-04-27 09:03:19 +00001246 break;
1247 }
1248 if (LocaleCompare("crop",option+1) == 0)
1249 {
1250 /*
1251 Crop a image to a smaller size
1252 */
1253 (void) SyncImageSettings(mogrify_info,*image);
anthonydf8ebac2011-04-27 09:03:19 +00001254 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00001255 break;
1256 }
1257 if (LocaleCompare("cycle",option+1) == 0)
1258 {
1259 /*
1260 Cycle an image colormap.
1261 */
1262 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00001263 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1264 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001265 break;
1266 }
1267 break;
1268 }
1269 case 'd':
1270 {
1271 if (LocaleCompare("decipher",option+1) == 0)
1272 {
1273 StringInfo
1274 *passkey;
1275
1276 /*
1277 Decipher pixels.
1278 */
1279 (void) SyncImageSettings(mogrify_info,*image);
1280 passkey=FileToStringInfo(argv[i+1],~0,exception);
1281 if (passkey != (StringInfo *) NULL)
1282 {
1283 (void) PasskeyDecipherImage(*image,passkey,exception);
1284 passkey=DestroyStringInfo(passkey);
1285 }
1286 break;
1287 }
1288 if (LocaleCompare("density",option+1) == 0)
1289 {
1290 /*
1291 Set image density.
1292 */
1293 (void) CloneString(&draw_info->density,argv[i+1]);
1294 break;
1295 }
1296 if (LocaleCompare("depth",option+1) == 0)
1297 {
1298 (void) SyncImageSettings(mogrify_info,*image);
1299 if (*option == '+')
1300 {
1301 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1302 break;
1303 }
1304 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1305 break;
1306 }
1307 if (LocaleCompare("deskew",option+1) == 0)
1308 {
1309 double
1310 threshold;
1311
1312 /*
1313 Straighten the image.
1314 */
1315 (void) SyncImageSettings(mogrify_info,*image);
1316 if (*option == '+')
1317 threshold=40.0*QuantumRange/100.0;
1318 else
1319 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1320 mogrify_image=DeskewImage(*image,threshold,exception);
1321 break;
1322 }
1323 if (LocaleCompare("despeckle",option+1) == 0)
1324 {
1325 /*
1326 Reduce the speckles within an image.
1327 */
1328 (void) SyncImageSettings(mogrify_info,*image);
1329 mogrify_image=DespeckleImage(*image,exception);
1330 break;
1331 }
1332 if (LocaleCompare("display",option+1) == 0)
1333 {
1334 (void) CloneString(&draw_info->server_name,argv[i+1]);
1335 break;
1336 }
1337 if (LocaleCompare("distort",option+1) == 0)
1338 {
1339 char
1340 *args,
1341 token[MaxTextExtent];
1342
1343 const char
1344 *p;
1345
1346 DistortImageMethod
1347 method;
1348
1349 double
1350 *arguments;
1351
1352 register ssize_t
1353 x;
1354
1355 size_t
1356 number_arguments;
1357
1358 /*
1359 Distort image.
1360 */
1361 (void) SyncImageSettings(mogrify_info,*image);
1362 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1363 MagickFalse,argv[i+1]);
1364 if ( method == ResizeDistortion )
1365 {
1366 /* Special Case - Argument is actually a resize geometry!
1367 ** Convert that to an appropriate distortion argument array.
1368 */
1369 double
1370 resize_args[2];
1371 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1372 exception);
1373 resize_args[0]=(double)geometry.width;
1374 resize_args[1]=(double)geometry.height;
1375 mogrify_image=DistortImage(*image,method,(size_t)2,
1376 resize_args,MagickTrue,exception);
1377 break;
1378 }
cristy018f07f2011-09-04 21:15:19 +00001379 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1380 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001381 if (args == (char *) NULL)
1382 break;
1383 p=(char *) args;
1384 for (x=0; *p != '\0'; x++)
1385 {
1386 GetMagickToken(p,&p,token);
1387 if (*token == ',')
1388 GetMagickToken(p,&p,token);
1389 }
1390 number_arguments=(size_t) x;
1391 arguments=(double *) AcquireQuantumMemory(number_arguments,
1392 sizeof(*arguments));
1393 if (arguments == (double *) NULL)
1394 ThrowWandFatalException(ResourceLimitFatalError,
1395 "MemoryAllocationFailed",(*image)->filename);
1396 (void) ResetMagickMemory(arguments,0,number_arguments*
1397 sizeof(*arguments));
1398 p=(char *) args;
1399 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1400 {
1401 GetMagickToken(p,&p,token);
1402 if (*token == ',')
1403 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001404 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001405 }
1406 args=DestroyString(args);
1407 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1408 (*option == '+') ? MagickTrue : MagickFalse,exception);
1409 arguments=(double *) RelinquishMagickMemory(arguments);
1410 break;
1411 }
1412 if (LocaleCompare("dither",option+1) == 0)
1413 {
1414 if (*option == '+')
1415 {
1416 quantize_info->dither=MagickFalse;
1417 break;
1418 }
1419 quantize_info->dither=MagickTrue;
1420 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1421 MagickDitherOptions,MagickFalse,argv[i+1]);
1422 if (quantize_info->dither_method == NoDitherMethod)
1423 quantize_info->dither=MagickFalse;
1424 break;
1425 }
1426 if (LocaleCompare("draw",option+1) == 0)
1427 {
1428 /*
1429 Draw image.
1430 */
1431 (void) SyncImageSettings(mogrify_info,*image);
1432 (void) CloneString(&draw_info->primitive,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001433 (void) DrawImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001434 break;
1435 }
1436 break;
1437 }
1438 case 'e':
1439 {
1440 if (LocaleCompare("edge",option+1) == 0)
1441 {
1442 /*
1443 Enhance edges in the 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;
cristy8ae632d2011-09-05 17:29:53 +00001449 mogrify_image=EdgeImage(*image,geometry_info.rho,
1450 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001451 break;
1452 }
1453 if (LocaleCompare("emboss",option+1) == 0)
1454 {
1455 /*
1456 Gaussian embossen image.
1457 */
1458 (void) SyncImageSettings(mogrify_info,*image);
1459 flags=ParseGeometry(argv[i+1],&geometry_info);
1460 if ((flags & SigmaValue) == 0)
1461 geometry_info.sigma=1.0;
1462 mogrify_image=EmbossImage(*image,geometry_info.rho,
1463 geometry_info.sigma,exception);
1464 break;
1465 }
1466 if (LocaleCompare("encipher",option+1) == 0)
1467 {
1468 StringInfo
1469 *passkey;
1470
1471 /*
1472 Encipher pixels.
1473 */
1474 (void) SyncImageSettings(mogrify_info,*image);
1475 passkey=FileToStringInfo(argv[i+1],~0,exception);
1476 if (passkey != (StringInfo *) NULL)
1477 {
1478 (void) PasskeyEncipherImage(*image,passkey,exception);
1479 passkey=DestroyStringInfo(passkey);
1480 }
1481 break;
1482 }
1483 if (LocaleCompare("encoding",option+1) == 0)
1484 {
1485 (void) CloneString(&draw_info->encoding,argv[i+1]);
1486 break;
1487 }
1488 if (LocaleCompare("enhance",option+1) == 0)
1489 {
1490 /*
1491 Enhance image.
1492 */
1493 (void) SyncImageSettings(mogrify_info,*image);
1494 mogrify_image=EnhanceImage(*image,exception);
1495 break;
1496 }
1497 if (LocaleCompare("equalize",option+1) == 0)
1498 {
1499 /*
1500 Equalize image.
1501 */
1502 (void) SyncImageSettings(mogrify_info,*image);
cristy6d8c3d72011-08-22 01:20:01 +00001503 (void) EqualizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001504 break;
1505 }
1506 if (LocaleCompare("evaluate",option+1) == 0)
1507 {
1508 double
1509 constant;
1510
1511 MagickEvaluateOperator
1512 op;
1513
1514 (void) SyncImageSettings(mogrify_info,*image);
cristyd42d9952011-07-08 14:21:50 +00001515 op=(MagickEvaluateOperator) ParseCommandOption(
1516 MagickEvaluateOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00001517 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
cristyd42d9952011-07-08 14:21:50 +00001518 (void) EvaluateImage(*image,op,constant,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001519 break;
1520 }
1521 if (LocaleCompare("extent",option+1) == 0)
1522 {
1523 /*
1524 Set the image extent.
1525 */
1526 (void) SyncImageSettings(mogrify_info,*image);
1527 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1528 if (geometry.width == 0)
1529 geometry.width=(*image)->columns;
1530 if (geometry.height == 0)
1531 geometry.height=(*image)->rows;
1532 mogrify_image=ExtentImage(*image,&geometry,exception);
1533 break;
1534 }
1535 break;
1536 }
1537 case 'f':
1538 {
1539 if (LocaleCompare("family",option+1) == 0)
1540 {
1541 if (*option == '+')
1542 {
1543 if (draw_info->family != (char *) NULL)
1544 draw_info->family=DestroyString(draw_info->family);
1545 break;
1546 }
1547 (void) CloneString(&draw_info->family,argv[i+1]);
1548 break;
1549 }
1550 if (LocaleCompare("features",option+1) == 0)
1551 {
1552 if (*option == '+')
1553 {
1554 (void) DeleteImageArtifact(*image,"identify:features");
1555 break;
1556 }
1557 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1558 break;
1559 }
1560 if (LocaleCompare("fill",option+1) == 0)
1561 {
1562 ExceptionInfo
1563 *sans;
1564
cristy4c08aed2011-07-01 19:47:50 +00001565 GetPixelInfo(*image,&fill);
anthonydf8ebac2011-04-27 09:03:19 +00001566 if (*option == '+')
1567 {
cristy269c9412011-10-13 23:41:15 +00001568 (void) QueryColorCompliance("none",AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001569 exception);
1570 (void) QueryColorCompliance("none",AllCompliance,
1571 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001572 if (draw_info->fill_pattern != (Image *) NULL)
1573 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1574 break;
1575 }
1576 sans=AcquireExceptionInfo();
cristy269c9412011-10-13 23:41:15 +00001577 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001578 sans);
1579 status=QueryColorCompliance(argv[i+1],AllCompliance,
1580 &draw_info->fill,sans);
anthonydf8ebac2011-04-27 09:03:19 +00001581 sans=DestroyExceptionInfo(sans);
1582 if (status == MagickFalse)
1583 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1584 exception);
1585 break;
1586 }
1587 if (LocaleCompare("flip",option+1) == 0)
1588 {
1589 /*
1590 Flip image scanlines.
1591 */
1592 (void) SyncImageSettings(mogrify_info,*image);
1593 mogrify_image=FlipImage(*image,exception);
1594 break;
1595 }
anthonydf8ebac2011-04-27 09:03:19 +00001596 if (LocaleCompare("floodfill",option+1) == 0)
1597 {
cristy4c08aed2011-07-01 19:47:50 +00001598 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001599 target;
1600
1601 /*
1602 Floodfill image.
1603 */
1604 (void) SyncImageSettings(mogrify_info,*image);
1605 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
cristy269c9412011-10-13 23:41:15 +00001606 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00001607 exception);
cristyd42d9952011-07-08 14:21:50 +00001608 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
cristy189e84c2011-08-27 18:08:53 +00001609 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001610 break;
1611 }
anthony3d2f4862011-05-01 13:48:16 +00001612 if (LocaleCompare("flop",option+1) == 0)
1613 {
1614 /*
1615 Flop image scanlines.
1616 */
1617 (void) SyncImageSettings(mogrify_info,*image);
1618 mogrify_image=FlopImage(*image,exception);
1619 break;
1620 }
anthonydf8ebac2011-04-27 09:03:19 +00001621 if (LocaleCompare("font",option+1) == 0)
1622 {
1623 if (*option == '+')
1624 {
1625 if (draw_info->font != (char *) NULL)
1626 draw_info->font=DestroyString(draw_info->font);
1627 break;
1628 }
1629 (void) CloneString(&draw_info->font,argv[i+1]);
1630 break;
1631 }
1632 if (LocaleCompare("format",option+1) == 0)
1633 {
1634 format=argv[i+1];
1635 break;
1636 }
1637 if (LocaleCompare("frame",option+1) == 0)
1638 {
1639 FrameInfo
1640 frame_info;
1641
1642 /*
1643 Surround image with an ornamental border.
1644 */
1645 (void) SyncImageSettings(mogrify_info,*image);
1646 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1647 frame_info.width=geometry.width;
1648 frame_info.height=geometry.height;
1649 if ((flags & HeightValue) == 0)
1650 frame_info.height=geometry.width;
1651 frame_info.outer_bevel=geometry.x;
1652 frame_info.inner_bevel=geometry.y;
1653 frame_info.x=(ssize_t) frame_info.width;
1654 frame_info.y=(ssize_t) frame_info.height;
1655 frame_info.width=(*image)->columns+2*frame_info.width;
1656 frame_info.height=(*image)->rows+2*frame_info.height;
cristy633f0c62011-09-15 13:27:36 +00001657 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001658 break;
1659 }
1660 if (LocaleCompare("function",option+1) == 0)
1661 {
1662 char
1663 *arguments,
1664 token[MaxTextExtent];
1665
1666 const char
1667 *p;
1668
1669 double
1670 *parameters;
1671
1672 MagickFunction
1673 function;
1674
1675 register ssize_t
1676 x;
1677
1678 size_t
1679 number_parameters;
1680
1681 /*
1682 Function Modify Image Values
1683 */
1684 (void) SyncImageSettings(mogrify_info,*image);
1685 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1686 MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001687 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1688 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001689 if (arguments == (char *) NULL)
1690 break;
1691 p=(char *) arguments;
1692 for (x=0; *p != '\0'; x++)
1693 {
1694 GetMagickToken(p,&p,token);
1695 if (*token == ',')
1696 GetMagickToken(p,&p,token);
1697 }
1698 number_parameters=(size_t) x;
1699 parameters=(double *) AcquireQuantumMemory(number_parameters,
1700 sizeof(*parameters));
1701 if (parameters == (double *) NULL)
1702 ThrowWandFatalException(ResourceLimitFatalError,
1703 "MemoryAllocationFailed",(*image)->filename);
1704 (void) ResetMagickMemory(parameters,0,number_parameters*
1705 sizeof(*parameters));
1706 p=(char *) arguments;
1707 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1708 {
1709 GetMagickToken(p,&p,token);
1710 if (*token == ',')
1711 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001712 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001713 }
1714 arguments=DestroyString(arguments);
cristyd42d9952011-07-08 14:21:50 +00001715 (void) FunctionImage(*image,function,number_parameters,parameters,
1716 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001717 parameters=(double *) RelinquishMagickMemory(parameters);
1718 break;
1719 }
1720 break;
1721 }
1722 case 'g':
1723 {
1724 if (LocaleCompare("gamma",option+1) == 0)
1725 {
1726 /*
1727 Gamma image.
1728 */
1729 (void) SyncImageSettings(mogrify_info,*image);
1730 if (*option == '+')
cristyc1acd842011-05-19 23:05:47 +00001731 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001732 else
cristyb3e7c6c2011-07-24 01:43:55 +00001733 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1734 (char **) NULL),exception);
anthonydf8ebac2011-04-27 09:03:19 +00001735 break;
1736 }
1737 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1738 (LocaleCompare("gaussian",option+1) == 0))
1739 {
1740 /*
1741 Gaussian blur image.
1742 */
1743 (void) SyncImageSettings(mogrify_info,*image);
1744 flags=ParseGeometry(argv[i+1],&geometry_info);
1745 if ((flags & SigmaValue) == 0)
1746 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001747 if ((flags & XiValue) == 0)
1748 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00001749 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001750 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001751 break;
1752 }
1753 if (LocaleCompare("geometry",option+1) == 0)
1754 {
1755 /*
1756 Record Image offset, Resize last image.
1757 */
1758 (void) SyncImageSettings(mogrify_info,*image);
1759 if (*option == '+')
1760 {
1761 if ((*image)->geometry != (char *) NULL)
1762 (*image)->geometry=DestroyString((*image)->geometry);
1763 break;
1764 }
1765 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1766 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1767 (void) CloneString(&(*image)->geometry,argv[i+1]);
1768 else
1769 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1770 (*image)->filter,(*image)->blur,exception);
1771 break;
1772 }
1773 if (LocaleCompare("gravity",option+1) == 0)
1774 {
1775 if (*option == '+')
1776 {
1777 draw_info->gravity=UndefinedGravity;
1778 break;
1779 }
1780 draw_info->gravity=(GravityType) ParseCommandOption(
1781 MagickGravityOptions,MagickFalse,argv[i+1]);
1782 break;
1783 }
1784 break;
1785 }
1786 case 'h':
1787 {
1788 if (LocaleCompare("highlight-color",option+1) == 0)
1789 {
1790 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1791 break;
1792 }
1793 break;
1794 }
1795 case 'i':
1796 {
1797 if (LocaleCompare("identify",option+1) == 0)
1798 {
1799 char
1800 *text;
1801
1802 (void) SyncImageSettings(mogrify_info,*image);
1803 if (format == (char *) NULL)
1804 {
cristya4037272011-08-28 15:11:39 +00001805 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1806 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001807 break;
1808 }
cristy018f07f2011-09-04 21:15:19 +00001809 text=InterpretImageProperties(mogrify_info,*image,format,
1810 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001811 if (text == (char *) NULL)
1812 break;
1813 (void) fputs(text,stdout);
1814 (void) fputc('\n',stdout);
1815 text=DestroyString(text);
1816 break;
1817 }
1818 if (LocaleCompare("implode",option+1) == 0)
1819 {
1820 /*
1821 Implode image.
1822 */
1823 (void) SyncImageSettings(mogrify_info,*image);
1824 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00001825 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1826 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001827 break;
1828 }
1829 if (LocaleCompare("interline-spacing",option+1) == 0)
1830 {
1831 if (*option == '+')
1832 (void) ParseGeometry("0",&geometry_info);
1833 else
1834 (void) ParseGeometry(argv[i+1],&geometry_info);
1835 draw_info->interline_spacing=geometry_info.rho;
1836 break;
1837 }
cristy28474bf2011-09-11 23:32:52 +00001838 if (LocaleCompare("interpolate",option+1) == 0)
1839 {
1840 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1841 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1842 break;
1843 }
anthonydf8ebac2011-04-27 09:03:19 +00001844 if (LocaleCompare("interword-spacing",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->interword_spacing=geometry_info.rho;
1851 break;
1852 }
1853 break;
1854 }
1855 case 'k':
1856 {
1857 if (LocaleCompare("kerning",option+1) == 0)
1858 {
1859 if (*option == '+')
1860 (void) ParseGeometry("0",&geometry_info);
1861 else
1862 (void) ParseGeometry(argv[i+1],&geometry_info);
1863 draw_info->kerning=geometry_info.rho;
1864 break;
1865 }
1866 break;
1867 }
1868 case 'l':
1869 {
1870 if (LocaleCompare("lat",option+1) == 0)
1871 {
1872 /*
1873 Local adaptive threshold image.
1874 */
1875 (void) SyncImageSettings(mogrify_info,*image);
1876 flags=ParseGeometry(argv[i+1],&geometry_info);
1877 if ((flags & PercentValue) != 0)
1878 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1879 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
cristyde5cc632011-07-18 14:47:00 +00001880 geometry_info.rho,(size_t) geometry_info.sigma,(double)
anthonydf8ebac2011-04-27 09:03:19 +00001881 geometry_info.xi,exception);
1882 break;
1883 }
1884 if (LocaleCompare("level",option+1) == 0)
1885 {
1886 MagickRealType
1887 black_point,
1888 gamma,
1889 white_point;
1890
1891 MagickStatusType
1892 flags;
1893
1894 /*
1895 Parse levels.
1896 */
1897 (void) SyncImageSettings(mogrify_info,*image);
1898 flags=ParseGeometry(argv[i+1],&geometry_info);
1899 black_point=geometry_info.rho;
1900 white_point=(MagickRealType) QuantumRange;
1901 if ((flags & SigmaValue) != 0)
1902 white_point=geometry_info.sigma;
1903 gamma=1.0;
1904 if ((flags & XiValue) != 0)
1905 gamma=geometry_info.xi;
1906 if ((flags & PercentValue) != 0)
1907 {
1908 black_point*=(MagickRealType) (QuantumRange/100.0);
1909 white_point*=(MagickRealType) (QuantumRange/100.0);
1910 }
1911 if ((flags & SigmaValue) == 0)
1912 white_point=(MagickRealType) QuantumRange-black_point;
1913 if ((*option == '+') || ((flags & AspectValue) != 0))
cristy7c0a0a42011-08-23 17:57:25 +00001914 (void) LevelizeImage(*image,black_point,white_point,gamma,
1915 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001916 else
cristy01e9afd2011-08-10 17:38:41 +00001917 (void) LevelImage(*image,black_point,white_point,gamma,
1918 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001919 InheritException(exception,&(*image)->exception);
1920 break;
1921 }
1922 if (LocaleCompare("level-colors",option+1) == 0)
1923 {
1924 char
1925 token[MaxTextExtent];
1926
1927 const char
1928 *p;
1929
cristy4c08aed2011-07-01 19:47:50 +00001930 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001931 black_point,
1932 white_point;
1933
1934 p=(const char *) argv[i+1];
1935 GetMagickToken(p,&p,token); /* get black point color */
1936 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001937 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001938 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001939 else
cristy269c9412011-10-13 23:41:15 +00001940 (void) QueryColorCompliance("#000000",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001941 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001942 if (isalpha((int) token[0]) || (token[0] == '#'))
1943 GetMagickToken(p,&p,token);
1944 if (*token == '\0')
1945 white_point=black_point; /* set everything to that color */
1946 else
1947 {
1948 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1949 GetMagickToken(p,&p,token); /* Get white point color. */
1950 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001951 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001952 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001953 else
cristy269c9412011-10-13 23:41:15 +00001954 (void) QueryColorCompliance("#ffffff",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001955 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001956 }
cristy490408a2011-07-07 14:42:05 +00001957 (void) LevelImageColors(*image,&black_point,&white_point,
cristy7c0a0a42011-08-23 17:57:25 +00001958 *option == '+' ? MagickTrue : MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001959 break;
1960 }
1961 if (LocaleCompare("linear-stretch",option+1) == 0)
1962 {
1963 double
1964 black_point,
1965 white_point;
1966
1967 MagickStatusType
1968 flags;
1969
1970 (void) SyncImageSettings(mogrify_info,*image);
1971 flags=ParseGeometry(argv[i+1],&geometry_info);
1972 black_point=geometry_info.rho;
1973 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1974 if ((flags & SigmaValue) != 0)
1975 white_point=geometry_info.sigma;
1976 if ((flags & PercentValue) != 0)
1977 {
1978 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1979 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1980 }
1981 if ((flags & SigmaValue) == 0)
1982 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1983 black_point;
cristy33bd5152011-08-24 01:42:24 +00001984 (void) LinearStretchImage(*image,black_point,white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001985 InheritException(exception,&(*image)->exception);
1986 break;
1987 }
1988 if (LocaleCompare("linewidth",option+1) == 0)
1989 {
cristyc1acd842011-05-19 23:05:47 +00001990 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1991 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001992 break;
1993 }
1994 if (LocaleCompare("liquid-rescale",option+1) == 0)
1995 {
1996 /*
1997 Liquid rescale image.
1998 */
1999 (void) SyncImageSettings(mogrify_info,*image);
2000 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2001 if ((flags & XValue) == 0)
2002 geometry.x=1;
2003 if ((flags & YValue) == 0)
2004 geometry.y=0;
2005 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2006 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2007 break;
2008 }
2009 if (LocaleCompare("lowlight-color",option+1) == 0)
2010 {
2011 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2012 break;
2013 }
2014 break;
2015 }
2016 case 'm':
2017 {
2018 if (LocaleCompare("map",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00002019 {
cristy3ed852e2009-09-05 21:47:34 +00002020 Image
anthonydf8ebac2011-04-27 09:03:19 +00002021 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002022
anthonydf8ebac2011-04-27 09:03:19 +00002023 /*
2024 Transform image colors to match this set of colors.
2025 */
2026 (void) SyncImageSettings(mogrify_info,*image);
2027 if (*option == '+')
2028 break;
2029 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2030 if (remap_image == (Image *) NULL)
2031 break;
cristy018f07f2011-09-04 21:15:19 +00002032 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002033 remap_image=DestroyImage(remap_image);
2034 break;
2035 }
2036 if (LocaleCompare("mask",option+1) == 0)
2037 {
2038 Image
2039 *mask;
2040
2041 (void) SyncImageSettings(mogrify_info,*image);
2042 if (*option == '+')
2043 {
2044 /*
2045 Remove a mask.
2046 */
cristy018f07f2011-09-04 21:15:19 +00002047 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002048 break;
2049 }
2050 /*
2051 Set the image mask.
2052 */
2053 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2054 if (mask == (Image *) NULL)
2055 break;
cristy018f07f2011-09-04 21:15:19 +00002056 (void) SetImageMask(*image,mask,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002057 mask=DestroyImage(mask);
anthonydf8ebac2011-04-27 09:03:19 +00002058 break;
2059 }
2060 if (LocaleCompare("matte",option+1) == 0)
2061 {
2062 (void) SetImageAlphaChannel(*image,(*option == '-') ?
cristy63240882011-08-05 19:05:27 +00002063 SetAlphaChannel : DeactivateAlphaChannel,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002064 break;
2065 }
2066 if (LocaleCompare("median",option+1) == 0)
2067 {
2068 /*
2069 Median filter 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,MedianStatistic,(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("mode",option+1) == 0)
2080 {
2081 /*
2082 Mode image.
2083 */
2084 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002085 flags=ParseGeometry(argv[i+1],&geometry_info);
2086 if ((flags & SigmaValue) == 0)
2087 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002088 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002089 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002090 break;
2091 }
2092 if (LocaleCompare("modulate",option+1) == 0)
2093 {
2094 (void) SyncImageSettings(mogrify_info,*image);
cristy33bd5152011-08-24 01:42:24 +00002095 (void) ModulateImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002096 break;
2097 }
2098 if (LocaleCompare("monitor",option+1) == 0)
2099 {
2100 if (*option == '+')
2101 {
2102 (void) SetImageProgressMonitor(*image,
2103 (MagickProgressMonitor) NULL,(void *) NULL);
2104 break;
2105 }
2106 (void) SetImageProgressMonitor(*image,MonitorProgress,
2107 (void *) NULL);
2108 break;
2109 }
2110 if (LocaleCompare("monochrome",option+1) == 0)
2111 {
2112 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00002113 (void) SetImageType(*image,BilevelType,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002114 break;
2115 }
2116 if (LocaleCompare("morphology",option+1) == 0)
2117 {
2118 char
2119 token[MaxTextExtent];
2120
2121 const char
2122 *p;
2123
2124 KernelInfo
2125 *kernel;
2126
2127 MorphologyMethod
2128 method;
2129
2130 ssize_t
2131 iterations;
2132
2133 /*
2134 Morphological Image Operation
2135 */
2136 (void) SyncImageSettings(mogrify_info,*image);
2137 p=argv[i+1];
2138 GetMagickToken(p,&p,token);
cristy28474bf2011-09-11 23:32:52 +00002139 method=(MorphologyMethod) ParseCommandOption(
2140 MagickMorphologyOptions,MagickFalse,token);
anthonydf8ebac2011-04-27 09:03:19 +00002141 iterations=1L;
2142 GetMagickToken(p,&p,token);
2143 if ((*p == ':') || (*p == ','))
2144 GetMagickToken(p,&p,token);
2145 if ((*p != '\0'))
2146 iterations=(ssize_t) StringToLong(p);
2147 kernel=AcquireKernelInfo(argv[i+2]);
2148 if (kernel == (KernelInfo *) NULL)
2149 {
2150 (void) ThrowMagickException(exception,GetMagickModule(),
2151 OptionError,"UnabletoParseKernel","morphology");
2152 status=MagickFalse;
2153 break;
2154 }
cristyf4ad9df2011-07-08 16:49:03 +00002155 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2156 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002157 kernel=DestroyKernelInfo(kernel);
2158 break;
2159 }
2160 if (LocaleCompare("motion-blur",option+1) == 0)
2161 {
2162 /*
2163 Motion blur image.
2164 */
2165 (void) SyncImageSettings(mogrify_info,*image);
2166 flags=ParseGeometry(argv[i+1],&geometry_info);
2167 if ((flags & SigmaValue) == 0)
2168 geometry_info.sigma=1.0;
cristyf4ad9df2011-07-08 16:49:03 +00002169 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002170 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2171 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002172 break;
2173 }
2174 break;
2175 }
2176 case 'n':
2177 {
2178 if (LocaleCompare("negate",option+1) == 0)
2179 {
2180 (void) SyncImageSettings(mogrify_info,*image);
cristy50fbc382011-07-07 02:19:17 +00002181 (void) NegateImage(*image,*option == '+' ? MagickTrue :
cristyb3e7c6c2011-07-24 01:43:55 +00002182 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002183 break;
2184 }
2185 if (LocaleCompare("noise",option+1) == 0)
2186 {
2187 (void) SyncImageSettings(mogrify_info,*image);
2188 if (*option == '-')
2189 {
cristyf36cbcb2011-09-07 13:28:22 +00002190 flags=ParseGeometry(argv[i+1],&geometry_info);
2191 if ((flags & SigmaValue) == 0)
2192 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002193 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002194 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002195 }
2196 else
2197 {
2198 NoiseType
2199 noise;
2200
2201 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2202 MagickFalse,argv[i+1]);
cristy9ed1f812011-10-08 02:00:08 +00002203 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002204 }
2205 break;
2206 }
2207 if (LocaleCompare("normalize",option+1) == 0)
2208 {
2209 (void) SyncImageSettings(mogrify_info,*image);
cristye23ec9d2011-08-16 18:15:40 +00002210 (void) NormalizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002211 break;
2212 }
2213 break;
2214 }
2215 case 'o':
2216 {
2217 if (LocaleCompare("opaque",option+1) == 0)
2218 {
cristy4c08aed2011-07-01 19:47:50 +00002219 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002220 target;
2221
2222 (void) SyncImageSettings(mogrify_info,*image);
cristy269c9412011-10-13 23:41:15 +00002223 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00002224 exception);
cristyd42d9952011-07-08 14:21:50 +00002225 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
cristy189e84c2011-08-27 18:08:53 +00002226 MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002227 break;
2228 }
2229 if (LocaleCompare("ordered-dither",option+1) == 0)
2230 {
2231 (void) SyncImageSettings(mogrify_info,*image);
cristy13020672011-07-08 02:33:26 +00002232 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002233 break;
2234 }
2235 break;
2236 }
2237 case 'p':
2238 {
2239 if (LocaleCompare("paint",option+1) == 0)
2240 {
anthonydf8ebac2011-04-27 09:03:19 +00002241 (void) SyncImageSettings(mogrify_info,*image);
2242 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy14973ba2011-08-27 23:48:07 +00002243 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2244 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002245 break;
2246 }
2247 if (LocaleCompare("pen",option+1) == 0)
2248 {
2249 if (*option == '+')
2250 {
cristy9950d572011-10-01 18:22:35 +00002251 (void) QueryColorCompliance("none",AllCompliance,
2252 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002253 break;
2254 }
cristy9950d572011-10-01 18:22:35 +00002255 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2256 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002257 break;
2258 }
2259 if (LocaleCompare("pointsize",option+1) == 0)
2260 {
2261 if (*option == '+')
2262 (void) ParseGeometry("12",&geometry_info);
2263 else
2264 (void) ParseGeometry(argv[i+1],&geometry_info);
2265 draw_info->pointsize=geometry_info.rho;
2266 break;
2267 }
2268 if (LocaleCompare("polaroid",option+1) == 0)
2269 {
2270 double
2271 angle;
2272
2273 RandomInfo
2274 *random_info;
2275
2276 /*
2277 Simulate a Polaroid picture.
2278 */
2279 (void) SyncImageSettings(mogrify_info,*image);
2280 random_info=AcquireRandomInfo();
2281 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2282 random_info=DestroyRandomInfo(random_info);
2283 if (*option == '-')
2284 {
2285 SetGeometryInfo(&geometry_info);
2286 flags=ParseGeometry(argv[i+1],&geometry_info);
2287 angle=geometry_info.rho;
2288 }
cristy5c4e2582011-09-11 19:21:03 +00002289 mogrify_image=PolaroidImage(*image,draw_info,angle,
cristy28474bf2011-09-11 23:32:52 +00002290 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002291 break;
2292 }
2293 if (LocaleCompare("posterize",option+1) == 0)
2294 {
2295 /*
2296 Posterize image.
2297 */
2298 (void) SyncImageSettings(mogrify_info,*image);
2299 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy018f07f2011-09-04 21:15:19 +00002300 quantize_info->dither,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002301 break;
2302 }
2303 if (LocaleCompare("preview",option+1) == 0)
2304 {
2305 PreviewType
2306 preview_type;
2307
2308 /*
2309 Preview image.
2310 */
2311 (void) SyncImageSettings(mogrify_info,*image);
2312 if (*option == '+')
2313 preview_type=UndefinedPreview;
2314 else
cristy28474bf2011-09-11 23:32:52 +00002315 preview_type=(PreviewType) ParseCommandOption(
2316 MagickPreviewOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002317 mogrify_image=PreviewImage(*image,preview_type,exception);
2318 break;
2319 }
2320 if (LocaleCompare("profile",option+1) == 0)
2321 {
2322 const char
2323 *name;
2324
2325 const StringInfo
2326 *profile;
2327
2328 Image
2329 *profile_image;
2330
2331 ImageInfo
2332 *profile_info;
2333
2334 (void) SyncImageSettings(mogrify_info,*image);
2335 if (*option == '+')
2336 {
2337 /*
2338 Remove a profile from the image.
2339 */
2340 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2341 NULL,0,MagickTrue);
2342 InheritException(exception,&(*image)->exception);
2343 break;
2344 }
2345 /*
2346 Associate a profile with the image.
2347 */
2348 profile_info=CloneImageInfo(mogrify_info);
2349 profile=GetImageProfile(*image,"iptc");
2350 if (profile != (StringInfo *) NULL)
2351 profile_info->profile=(void *) CloneStringInfo(profile);
2352 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2353 profile_info=DestroyImageInfo(profile_info);
2354 if (profile_image == (Image *) NULL)
2355 {
2356 StringInfo
2357 *profile;
2358
2359 profile_info=CloneImageInfo(mogrify_info);
2360 (void) CopyMagickString(profile_info->filename,argv[i+1],
2361 MaxTextExtent);
2362 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2363 if (profile != (StringInfo *) NULL)
2364 {
2365 (void) ProfileImage(*image,profile_info->magick,
2366 GetStringInfoDatum(profile),(size_t)
2367 GetStringInfoLength(profile),MagickFalse);
2368 profile=DestroyStringInfo(profile);
2369 }
2370 profile_info=DestroyImageInfo(profile_info);
2371 break;
2372 }
2373 ResetImageProfileIterator(profile_image);
2374 name=GetNextImageProfile(profile_image);
2375 while (name != (const char *) NULL)
2376 {
2377 profile=GetImageProfile(profile_image,name);
2378 if (profile != (StringInfo *) NULL)
2379 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2380 (size_t) GetStringInfoLength(profile),MagickFalse);
2381 name=GetNextImageProfile(profile_image);
2382 }
2383 profile_image=DestroyImage(profile_image);
2384 break;
2385 }
2386 break;
2387 }
2388 case 'q':
2389 {
2390 if (LocaleCompare("quantize",option+1) == 0)
2391 {
2392 if (*option == '+')
2393 {
2394 quantize_info->colorspace=UndefinedColorspace;
2395 break;
2396 }
2397 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2398 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2399 break;
2400 }
2401 break;
2402 }
2403 case 'r':
2404 {
2405 if (LocaleCompare("radial-blur",option+1) == 0)
2406 {
2407 /*
2408 Radial blur image.
2409 */
2410 (void) SyncImageSettings(mogrify_info,*image);
cristy6435bd92011-09-10 02:10:07 +00002411 flags=ParseGeometry(argv[i+1],&geometry_info);
2412 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2413 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002414 break;
2415 }
2416 if (LocaleCompare("raise",option+1) == 0)
2417 {
2418 /*
2419 Surround image with a raise of solid color.
2420 */
2421 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2422 if ((flags & SigmaValue) == 0)
2423 geometry.height=geometry.width;
2424 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
cristy6170ac32011-08-28 14:15:37 +00002425 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002426 break;
2427 }
2428 if (LocaleCompare("random-threshold",option+1) == 0)
2429 {
2430 /*
2431 Threshold image.
2432 */
2433 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00002434 (void) RandomThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002435 break;
2436 }
2437 if (LocaleCompare("recolor",option+1) == 0)
2438 {
2439 KernelInfo
2440 *kernel;
2441
2442 (void) SyncImageSettings(mogrify_info,*image);
2443 kernel=AcquireKernelInfo(argv[i+1]);
2444 if (kernel == (KernelInfo *) NULL)
2445 break;
2446 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2447 kernel=DestroyKernelInfo(kernel);
2448 break;
2449 }
2450 if (LocaleCompare("region",option+1) == 0)
2451 {
2452 (void) SyncImageSettings(mogrify_info,*image);
2453 if (region_image != (Image *) NULL)
2454 {
2455 /*
2456 Composite region.
2457 */
2458 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00002459 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2460 region_geometry.x,region_geometry.y);
anthonydf8ebac2011-04-27 09:03:19 +00002461 InheritException(exception,&region_image->exception);
2462 *image=DestroyImage(*image);
2463 *image=region_image;
2464 region_image = (Image *) NULL;
2465 }
2466 if (*option == '+')
2467 break;
2468 /*
2469 Apply transformations to a selected region of the image.
2470 */
cristy3ed852e2009-09-05 21:47:34 +00002471 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2472 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002473 mogrify_image=CropImage(*image,&region_geometry,exception);
2474 if (mogrify_image == (Image *) NULL)
2475 break;
2476 region_image=(*image);
2477 *image=mogrify_image;
2478 mogrify_image=(Image *) NULL;
2479 break;
cristy3ed852e2009-09-05 21:47:34 +00002480 }
anthonydf8ebac2011-04-27 09:03:19 +00002481 if (LocaleCompare("render",option+1) == 0)
2482 {
2483 (void) SyncImageSettings(mogrify_info,*image);
2484 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2485 break;
2486 }
2487 if (LocaleCompare("remap",option+1) == 0)
2488 {
2489 Image
2490 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002491
anthonydf8ebac2011-04-27 09:03:19 +00002492 /*
2493 Transform image colors to match this set of colors.
2494 */
2495 (void) SyncImageSettings(mogrify_info,*image);
2496 if (*option == '+')
2497 break;
2498 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2499 if (remap_image == (Image *) NULL)
2500 break;
cristy018f07f2011-09-04 21:15:19 +00002501 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002502 remap_image=DestroyImage(remap_image);
2503 break;
2504 }
2505 if (LocaleCompare("repage",option+1) == 0)
2506 {
2507 if (*option == '+')
2508 {
2509 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2510 break;
2511 }
2512 (void) ResetImagePage(*image,argv[i+1]);
2513 InheritException(exception,&(*image)->exception);
2514 break;
2515 }
2516 if (LocaleCompare("resample",option+1) == 0)
2517 {
2518 /*
2519 Resample image.
2520 */
2521 (void) SyncImageSettings(mogrify_info,*image);
2522 flags=ParseGeometry(argv[i+1],&geometry_info);
2523 if ((flags & SigmaValue) == 0)
2524 geometry_info.sigma=geometry_info.rho;
2525 mogrify_image=ResampleImage(*image,geometry_info.rho,
2526 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2527 break;
2528 }
2529 if (LocaleCompare("resize",option+1) == 0)
2530 {
2531 /*
2532 Resize image.
2533 */
2534 (void) SyncImageSettings(mogrify_info,*image);
2535 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2536 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2537 (*image)->filter,(*image)->blur,exception);
2538 break;
2539 }
2540 if (LocaleCompare("roll",option+1) == 0)
2541 {
2542 /*
2543 Roll image.
2544 */
2545 (void) SyncImageSettings(mogrify_info,*image);
2546 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2547 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2548 break;
2549 }
2550 if (LocaleCompare("rotate",option+1) == 0)
2551 {
2552 char
2553 *geometry;
2554
2555 /*
2556 Check for conditional image rotation.
2557 */
2558 (void) SyncImageSettings(mogrify_info,*image);
2559 if (strchr(argv[i+1],'>') != (char *) NULL)
2560 if ((*image)->columns <= (*image)->rows)
2561 break;
2562 if (strchr(argv[i+1],'<') != (char *) NULL)
2563 if ((*image)->columns >= (*image)->rows)
2564 break;
2565 /*
2566 Rotate image.
2567 */
2568 geometry=ConstantString(argv[i+1]);
2569 (void) SubstituteString(&geometry,">","");
2570 (void) SubstituteString(&geometry,"<","");
2571 (void) ParseGeometry(geometry,&geometry_info);
2572 geometry=DestroyString(geometry);
2573 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2574 break;
2575 }
2576 break;
2577 }
2578 case 's':
2579 {
2580 if (LocaleCompare("sample",option+1) == 0)
2581 {
2582 /*
2583 Sample image with pixel replication.
2584 */
2585 (void) SyncImageSettings(mogrify_info,*image);
2586 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2587 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2588 exception);
2589 break;
2590 }
2591 if (LocaleCompare("scale",option+1) == 0)
2592 {
2593 /*
2594 Resize image.
2595 */
2596 (void) SyncImageSettings(mogrify_info,*image);
2597 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2598 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2599 exception);
2600 break;
2601 }
2602 if (LocaleCompare("selective-blur",option+1) == 0)
2603 {
2604 /*
2605 Selectively blur pixels within a contrast threshold.
2606 */
2607 (void) SyncImageSettings(mogrify_info,*image);
2608 flags=ParseGeometry(argv[i+1],&geometry_info);
2609 if ((flags & PercentValue) != 0)
2610 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristyf4ad9df2011-07-08 16:49:03 +00002611 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
cristy1e7aa312011-09-10 20:01:36 +00002612 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002613 break;
2614 }
2615 if (LocaleCompare("separate",option+1) == 0)
2616 {
2617 /*
2618 Break channels into separate images.
anthonydf8ebac2011-04-27 09:03:19 +00002619 */
2620 (void) SyncImageSettings(mogrify_info,*image);
cristy3139dc22011-07-08 00:11:42 +00002621 mogrify_image=SeparateImages(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002622 break;
2623 }
2624 if (LocaleCompare("sepia-tone",option+1) == 0)
2625 {
2626 double
2627 threshold;
2628
2629 /*
2630 Sepia-tone image.
2631 */
2632 (void) SyncImageSettings(mogrify_info,*image);
2633 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2634 mogrify_image=SepiaToneImage(*image,threshold,exception);
2635 break;
2636 }
2637 if (LocaleCompare("segment",option+1) == 0)
2638 {
2639 /*
2640 Segment image.
2641 */
2642 (void) SyncImageSettings(mogrify_info,*image);
2643 flags=ParseGeometry(argv[i+1],&geometry_info);
2644 if ((flags & SigmaValue) == 0)
2645 geometry_info.sigma=1.0;
2646 (void) SegmentImage(*image,(*image)->colorspace,
cristy018f07f2011-09-04 21:15:19 +00002647 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2648 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002649 break;
2650 }
2651 if (LocaleCompare("set",option+1) == 0)
2652 {
2653 char
2654 *value;
2655
2656 /*
2657 Set image option.
2658 */
2659 if (*option == '+')
2660 {
2661 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2662 (void) DeleteImageRegistry(argv[i+1]+9);
2663 else
2664 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2665 {
2666 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2667 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2668 }
2669 else
2670 (void) DeleteImageProperty(*image,argv[i+1]);
2671 break;
2672 }
cristy018f07f2011-09-04 21:15:19 +00002673 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2674 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002675 if (value == (char *) NULL)
2676 break;
2677 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2678 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2679 exception);
2680 else
2681 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2682 {
2683 (void) SetImageOption(image_info,argv[i+1]+7,value);
2684 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2685 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2686 }
2687 else
2688 (void) SetImageProperty(*image,argv[i+1],value);
2689 value=DestroyString(value);
2690 break;
2691 }
2692 if (LocaleCompare("shade",option+1) == 0)
2693 {
2694 /*
2695 Shade 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 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2702 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2703 break;
2704 }
2705 if (LocaleCompare("shadow",option+1) == 0)
2706 {
2707 /*
2708 Shadow image.
2709 */
2710 (void) SyncImageSettings(mogrify_info,*image);
2711 flags=ParseGeometry(argv[i+1],&geometry_info);
2712 if ((flags & SigmaValue) == 0)
2713 geometry_info.sigma=1.0;
2714 if ((flags & XiValue) == 0)
2715 geometry_info.xi=4.0;
2716 if ((flags & PsiValue) == 0)
2717 geometry_info.psi=4.0;
2718 mogrify_image=ShadowImage(*image,geometry_info.rho,
2719 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2720 ceil(geometry_info.psi-0.5),exception);
2721 break;
2722 }
2723 if (LocaleCompare("sharpen",option+1) == 0)
2724 {
2725 /*
2726 Sharpen image.
2727 */
2728 (void) SyncImageSettings(mogrify_info,*image);
2729 flags=ParseGeometry(argv[i+1],&geometry_info);
2730 if ((flags & SigmaValue) == 0)
2731 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00002732 if ((flags & XiValue) == 0)
2733 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00002734 mogrify_image=SharpenImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00002735 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002736 break;
2737 }
2738 if (LocaleCompare("shave",option+1) == 0)
2739 {
2740 /*
2741 Shave the image edges.
2742 */
2743 (void) SyncImageSettings(mogrify_info,*image);
2744 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2745 mogrify_image=ShaveImage(*image,&geometry,exception);
2746 break;
2747 }
2748 if (LocaleCompare("shear",option+1) == 0)
2749 {
2750 /*
2751 Shear image.
2752 */
2753 (void) SyncImageSettings(mogrify_info,*image);
2754 flags=ParseGeometry(argv[i+1],&geometry_info);
2755 if ((flags & SigmaValue) == 0)
2756 geometry_info.sigma=geometry_info.rho;
2757 mogrify_image=ShearImage(*image,geometry_info.rho,
2758 geometry_info.sigma,exception);
2759 break;
2760 }
2761 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2762 {
2763 /*
2764 Sigmoidal non-linearity contrast control.
2765 */
2766 (void) SyncImageSettings(mogrify_info,*image);
2767 flags=ParseGeometry(argv[i+1],&geometry_info);
2768 if ((flags & SigmaValue) == 0)
2769 geometry_info.sigma=(double) QuantumRange/2.0;
2770 if ((flags & PercentValue) != 0)
2771 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2772 100.0;
cristy9ee60942011-07-06 14:54:38 +00002773 (void) SigmoidalContrastImage(*image,(*option == '-') ?
cristy33bd5152011-08-24 01:42:24 +00002774 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2775 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002776 break;
2777 }
2778 if (LocaleCompare("sketch",option+1) == 0)
2779 {
2780 /*
2781 Sketch image.
2782 */
2783 (void) SyncImageSettings(mogrify_info,*image);
2784 flags=ParseGeometry(argv[i+1],&geometry_info);
2785 if ((flags & SigmaValue) == 0)
2786 geometry_info.sigma=1.0;
2787 mogrify_image=SketchImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002788 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002789 break;
2790 }
2791 if (LocaleCompare("solarize",option+1) == 0)
2792 {
2793 double
2794 threshold;
2795
2796 (void) SyncImageSettings(mogrify_info,*image);
2797 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy5cbc0162011-08-29 00:36:28 +00002798 (void) SolarizeImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002799 break;
2800 }
2801 if (LocaleCompare("sparse-color",option+1) == 0)
2802 {
2803 SparseColorMethod
2804 method;
2805
2806 char
2807 *arguments;
2808
2809 /*
2810 Sparse Color Interpolated Gradient
2811 */
2812 (void) SyncImageSettings(mogrify_info,*image);
2813 method=(SparseColorMethod) ParseCommandOption(
2814 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00002815 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2816 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002817 if (arguments == (char *) NULL)
2818 break;
cristy3884f692011-07-08 18:00:18 +00002819 mogrify_image=SparseColorOption(*image,method,arguments,
anthonydf8ebac2011-04-27 09:03:19 +00002820 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2821 arguments=DestroyString(arguments);
2822 break;
2823 }
2824 if (LocaleCompare("splice",option+1) == 0)
2825 {
2826 /*
2827 Splice a solid color into the image.
2828 */
2829 (void) SyncImageSettings(mogrify_info,*image);
2830 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2831 mogrify_image=SpliceImage(*image,&geometry,exception);
2832 break;
2833 }
2834 if (LocaleCompare("spread",option+1) == 0)
2835 {
2836 /*
2837 Spread an image.
2838 */
2839 (void) SyncImageSettings(mogrify_info,*image);
2840 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy5c4e2582011-09-11 19:21:03 +00002841 mogrify_image=SpreadImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00002842 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002843 break;
2844 }
2845 if (LocaleCompare("statistic",option+1) == 0)
2846 {
2847 StatisticType
2848 type;
2849
2850 (void) SyncImageSettings(mogrify_info,*image);
2851 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2852 MagickFalse,argv[i+1]);
2853 (void) ParseGeometry(argv[i+2],&geometry_info);
cristyf4ad9df2011-07-08 16:49:03 +00002854 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2855 (size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002856 break;
2857 }
2858 if (LocaleCompare("stretch",option+1) == 0)
2859 {
2860 if (*option == '+')
2861 {
2862 draw_info->stretch=UndefinedStretch;
2863 break;
2864 }
2865 draw_info->stretch=(StretchType) ParseCommandOption(
2866 MagickStretchOptions,MagickFalse,argv[i+1]);
2867 break;
2868 }
2869 if (LocaleCompare("strip",option+1) == 0)
2870 {
2871 /*
2872 Strip image of profiles and comments.
2873 */
2874 (void) SyncImageSettings(mogrify_info,*image);
2875 (void) StripImage(*image);
2876 InheritException(exception,&(*image)->exception);
2877 break;
2878 }
2879 if (LocaleCompare("stroke",option+1) == 0)
2880 {
2881 ExceptionInfo
2882 *sans;
2883
2884 if (*option == '+')
2885 {
cristy9950d572011-10-01 18:22:35 +00002886 (void) QueryColorCompliance("none",AllCompliance,
2887 &draw_info->stroke,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002888 if (draw_info->stroke_pattern != (Image *) NULL)
2889 draw_info->stroke_pattern=DestroyImage(
2890 draw_info->stroke_pattern);
2891 break;
2892 }
2893 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00002894 status=QueryColorCompliance(argv[i+1],AllCompliance,
2895 &draw_info->stroke,sans);
anthonydf8ebac2011-04-27 09:03:19 +00002896 sans=DestroyExceptionInfo(sans);
2897 if (status == MagickFalse)
2898 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2899 exception);
2900 break;
2901 }
2902 if (LocaleCompare("strokewidth",option+1) == 0)
2903 {
cristyc1acd842011-05-19 23:05:47 +00002904 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2905 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002906 break;
2907 }
2908 if (LocaleCompare("style",option+1) == 0)
2909 {
2910 if (*option == '+')
2911 {
2912 draw_info->style=UndefinedStyle;
2913 break;
2914 }
2915 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2916 MagickFalse,argv[i+1]);
2917 break;
2918 }
2919 if (LocaleCompare("swirl",option+1) == 0)
2920 {
2921 /*
2922 Swirl image.
2923 */
2924 (void) SyncImageSettings(mogrify_info,*image);
2925 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00002926 mogrify_image=SwirlImage(*image,geometry_info.rho,
2927 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002928 break;
2929 }
2930 break;
2931 }
2932 case 't':
2933 {
2934 if (LocaleCompare("threshold",option+1) == 0)
2935 {
2936 double
2937 threshold;
2938
2939 /*
2940 Threshold image.
2941 */
2942 (void) SyncImageSettings(mogrify_info,*image);
2943 if (*option == '+')
anthony247a86d2011-05-03 13:18:18 +00002944 threshold=(double) QuantumRange/2;
anthonydf8ebac2011-04-27 09:03:19 +00002945 else
2946 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristyf4ad9df2011-07-08 16:49:03 +00002947 (void) BilevelImage(*image,threshold);
anthonydf8ebac2011-04-27 09:03:19 +00002948 InheritException(exception,&(*image)->exception);
2949 break;
2950 }
2951 if (LocaleCompare("thumbnail",option+1) == 0)
2952 {
2953 /*
2954 Thumbnail image.
2955 */
2956 (void) SyncImageSettings(mogrify_info,*image);
2957 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2958 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2959 exception);
2960 break;
2961 }
2962 if (LocaleCompare("tile",option+1) == 0)
2963 {
2964 if (*option == '+')
2965 {
2966 if (draw_info->fill_pattern != (Image *) NULL)
2967 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2968 break;
2969 }
2970 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2971 exception);
2972 break;
2973 }
2974 if (LocaleCompare("tint",option+1) == 0)
2975 {
2976 /*
2977 Tint the image.
2978 */
2979 (void) SyncImageSettings(mogrify_info,*image);
cristy28474bf2011-09-11 23:32:52 +00002980 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002981 break;
2982 }
2983 if (LocaleCompare("transform",option+1) == 0)
2984 {
2985 /*
2986 Affine transform image.
2987 */
2988 (void) SyncImageSettings(mogrify_info,*image);
2989 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2990 exception);
2991 break;
2992 }
2993 if (LocaleCompare("transparent",option+1) == 0)
2994 {
cristy4c08aed2011-07-01 19:47:50 +00002995 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002996 target;
2997
2998 (void) SyncImageSettings(mogrify_info,*image);
cristy269c9412011-10-13 23:41:15 +00002999 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00003000 exception);
anthonydf8ebac2011-04-27 09:03:19 +00003001 (void) TransparentPaintImage(*image,&target,(Quantum)
cristy189e84c2011-08-27 18:08:53 +00003002 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3003 &(*image)->exception);
anthonydf8ebac2011-04-27 09:03:19 +00003004 break;
3005 }
3006 if (LocaleCompare("transpose",option+1) == 0)
3007 {
3008 /*
3009 Transpose image scanlines.
3010 */
3011 (void) SyncImageSettings(mogrify_info,*image);
3012 mogrify_image=TransposeImage(*image,exception);
3013 break;
3014 }
3015 if (LocaleCompare("transverse",option+1) == 0)
3016 {
3017 /*
3018 Transverse image scanlines.
3019 */
3020 (void) SyncImageSettings(mogrify_info,*image);
3021 mogrify_image=TransverseImage(*image,exception);
3022 break;
3023 }
3024 if (LocaleCompare("treedepth",option+1) == 0)
3025 {
3026 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3027 break;
3028 }
3029 if (LocaleCompare("trim",option+1) == 0)
3030 {
3031 /*
3032 Trim image.
3033 */
3034 (void) SyncImageSettings(mogrify_info,*image);
3035 mogrify_image=TrimImage(*image,exception);
3036 break;
3037 }
3038 if (LocaleCompare("type",option+1) == 0)
3039 {
3040 ImageType
3041 type;
3042
3043 (void) SyncImageSettings(mogrify_info,*image);
3044 if (*option == '+')
3045 type=UndefinedType;
3046 else
3047 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3048 argv[i+1]);
3049 (*image)->type=UndefinedType;
cristy018f07f2011-09-04 21:15:19 +00003050 (void) SetImageType(*image,type,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003051 break;
3052 }
3053 break;
3054 }
3055 case 'u':
3056 {
3057 if (LocaleCompare("undercolor",option+1) == 0)
3058 {
cristy9950d572011-10-01 18:22:35 +00003059 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3060 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003061 break;
3062 }
3063 if (LocaleCompare("unique",option+1) == 0)
3064 {
3065 if (*option == '+')
3066 {
3067 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3068 break;
3069 }
3070 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3071 (void) SetImageArtifact(*image,"verbose","true");
3072 break;
3073 }
3074 if (LocaleCompare("unique-colors",option+1) == 0)
3075 {
3076 /*
3077 Unique image colors.
3078 */
3079 (void) SyncImageSettings(mogrify_info,*image);
3080 mogrify_image=UniqueImageColors(*image,exception);
3081 break;
3082 }
3083 if (LocaleCompare("unsharp",option+1) == 0)
3084 {
3085 /*
3086 Unsharp mask image.
3087 */
3088 (void) SyncImageSettings(mogrify_info,*image);
3089 flags=ParseGeometry(argv[i+1],&geometry_info);
3090 if ((flags & SigmaValue) == 0)
3091 geometry_info.sigma=1.0;
3092 if ((flags & XiValue) == 0)
3093 geometry_info.xi=1.0;
3094 if ((flags & PsiValue) == 0)
3095 geometry_info.psi=0.05;
cristyf4ad9df2011-07-08 16:49:03 +00003096 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3097 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003098 break;
3099 }
3100 break;
3101 }
3102 case 'v':
3103 {
3104 if (LocaleCompare("verbose",option+1) == 0)
3105 {
3106 (void) SetImageArtifact(*image,option+1,
3107 *option == '+' ? "false" : "true");
3108 break;
3109 }
3110 if (LocaleCompare("vignette",option+1) == 0)
3111 {
3112 /*
3113 Vignette image.
3114 */
3115 (void) SyncImageSettings(mogrify_info,*image);
3116 flags=ParseGeometry(argv[i+1],&geometry_info);
3117 if ((flags & SigmaValue) == 0)
3118 geometry_info.sigma=1.0;
3119 if ((flags & XiValue) == 0)
3120 geometry_info.xi=0.1*(*image)->columns;
3121 if ((flags & PsiValue) == 0)
3122 geometry_info.psi=0.1*(*image)->rows;
3123 mogrify_image=VignetteImage(*image,geometry_info.rho,
3124 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3125 ceil(geometry_info.psi-0.5),exception);
3126 break;
3127 }
3128 if (LocaleCompare("virtual-pixel",option+1) == 0)
3129 {
3130 if (*option == '+')
3131 {
3132 (void) SetImageVirtualPixelMethod(*image,
3133 UndefinedVirtualPixelMethod);
3134 break;
3135 }
3136 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3137 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3138 argv[i+1]));
3139 break;
3140 }
3141 break;
3142 }
3143 case 'w':
3144 {
3145 if (LocaleCompare("wave",option+1) == 0)
3146 {
3147 /*
3148 Wave image.
3149 */
3150 (void) SyncImageSettings(mogrify_info,*image);
3151 flags=ParseGeometry(argv[i+1],&geometry_info);
3152 if ((flags & SigmaValue) == 0)
3153 geometry_info.sigma=1.0;
3154 mogrify_image=WaveImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00003155 geometry_info.sigma,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003156 break;
3157 }
3158 if (LocaleCompare("weight",option+1) == 0)
3159 {
3160 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3161 if (LocaleCompare(argv[i+1],"all") == 0)
3162 draw_info->weight=0;
3163 if (LocaleCompare(argv[i+1],"bold") == 0)
3164 draw_info->weight=700;
3165 if (LocaleCompare(argv[i+1],"bolder") == 0)
3166 if (draw_info->weight <= 800)
3167 draw_info->weight+=100;
3168 if (LocaleCompare(argv[i+1],"lighter") == 0)
3169 if (draw_info->weight >= 100)
3170 draw_info->weight-=100;
3171 if (LocaleCompare(argv[i+1],"normal") == 0)
3172 draw_info->weight=400;
3173 break;
3174 }
3175 if (LocaleCompare("white-threshold",option+1) == 0)
3176 {
3177 /*
3178 White threshold image.
3179 */
3180 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00003181 (void) WhiteThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00003182 InheritException(exception,&(*image)->exception);
3183 break;
3184 }
3185 break;
3186 }
3187 default:
3188 break;
3189 }
3190 /*
3191 Replace current image with any image that was generated
3192 */
3193 if (mogrify_image != (Image *) NULL)
3194 ReplaceImageInListReturnLast(image,mogrify_image);
cristy3ed852e2009-09-05 21:47:34 +00003195 i+=count;
3196 }
3197 if (region_image != (Image *) NULL)
3198 {
anthonydf8ebac2011-04-27 09:03:19 +00003199 /*
3200 Composite transformed region onto image.
3201 */
cristy6b3da3a2010-06-20 02:21:46 +00003202 (void) SyncImageSettings(mogrify_info,*image);
anthonya129f702011-04-14 01:08:48 +00003203 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00003204 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3205 region_geometry.x,region_geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00003206 InheritException(exception,&region_image->exception);
3207 *image=DestroyImage(*image);
3208 *image=region_image;
anthonye9c27192011-03-27 08:07:06 +00003209 region_image = (Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00003210 }
3211 /*
3212 Free resources.
3213 */
anthonydf8ebac2011-04-27 09:03:19 +00003214 quantize_info=DestroyQuantizeInfo(quantize_info);
3215 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003216 mogrify_info=DestroyImageInfo(mogrify_info);
cristy4c08aed2011-07-01 19:47:50 +00003217 status=(MagickStatusType) ((*image)->exception.severity ==
cristy5f09d852011-05-29 01:39:29 +00003218 UndefinedException ? 1 : 0);
cristy72988482011-03-29 16:34:38 +00003219 return(status == 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00003220}
3221
3222/*
3223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3224% %
3225% %
3226% %
cristy5063d812010-10-19 16:28:10 +00003227+ 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 +00003228% %
3229% %
3230% %
3231%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3232%
3233% MogrifyImageCommand() transforms an image or a sequence of images. These
3234% transforms include image scaling, image rotation, color reduction, and
3235% others. The transmogrified image overwrites the original image.
3236%
3237% The format of the MogrifyImageCommand method is:
3238%
3239% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3240% const char **argv,char **metadata,ExceptionInfo *exception)
3241%
3242% A description of each parameter follows:
3243%
3244% o image_info: the image info.
3245%
3246% o argc: the number of elements in the argument vector.
3247%
3248% o argv: A text array containing the command line arguments.
3249%
3250% o metadata: any metadata is returned here.
3251%
3252% o exception: return any errors or warnings in this structure.
3253%
3254*/
3255
3256static MagickBooleanType MogrifyUsage(void)
3257{
3258 static const char
3259 *miscellaneous[]=
3260 {
3261 "-debug events display copious debugging information",
3262 "-help print program options",
3263 "-list type print a list of supported option arguments",
3264 "-log format format of debugging information",
3265 "-version print version information",
3266 (char *) NULL
3267 },
3268 *operators[]=
3269 {
3270 "-adaptive-blur geometry",
3271 " adaptively blur pixels; decrease effect near edges",
3272 "-adaptive-resize geometry",
3273 " adaptively resize image using 'mesh' interpolation",
3274 "-adaptive-sharpen geometry",
3275 " adaptively sharpen pixels; increase effect near edges",
3276 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3277 " transparent, extract, background, or shape",
3278 "-annotate geometry text",
3279 " annotate the image with text",
3280 "-auto-gamma automagically adjust gamma level of image",
3281 "-auto-level automagically adjust color levels of image",
3282 "-auto-orient automagically orient (rotate) image",
3283 "-bench iterations measure performance",
3284 "-black-threshold value",
3285 " force all pixels below the threshold into black",
3286 "-blue-shift simulate a scene at nighttime in the moonlight",
3287 "-blur geometry reduce image noise and reduce detail levels",
3288 "-border geometry surround image with a border of color",
3289 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003290 "-brightness-contrast geometry",
3291 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003292 "-cdl filename color correct with a color decision list",
cristy05c0c9a2011-09-05 23:16:13 +00003293 "-charcoal geometry simulate a charcoal drawing",
cristy3ed852e2009-09-05 21:47:34 +00003294 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003295 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003296 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003297 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003298 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003299 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003300 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003301 "-contrast enhance or reduce the image contrast",
3302 "-contrast-stretch geometry",
3303 " improve contrast by `stretching' the intensity range",
3304 "-convolve coefficients",
3305 " apply a convolution kernel to the image",
3306 "-cycle amount cycle the image colormap",
3307 "-decipher filename convert cipher pixels to plain pixels",
3308 "-deskew threshold straighten an image",
3309 "-despeckle reduce the speckles within an image",
3310 "-distort method args",
3311 " distort images according to given method ad args",
3312 "-draw string annotate the image with a graphic primitive",
3313 "-edge radius apply a filter to detect edges in the image",
3314 "-encipher filename convert plain pixels to cipher pixels",
3315 "-emboss radius emboss an image",
3316 "-enhance apply a digital filter to enhance a noisy image",
3317 "-equalize perform histogram equalization to an image",
3318 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003319 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003320 "-extent geometry set the image size",
3321 "-extract geometry extract area from image",
3322 "-fft implements the discrete Fourier transform (DFT)",
3323 "-flip flip image vertically",
3324 "-floodfill geometry color",
3325 " floodfill the image with color",
3326 "-flop flop image horizontally",
3327 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003328 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003329 " apply function over image values",
3330 "-gamma value level of gamma correction",
3331 "-gaussian-blur geometry",
3332 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003333 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003334 "-identify identify the format and characteristics of the image",
3335 "-ift implements the inverse discrete Fourier transform (DFT)",
3336 "-implode amount implode image pixels about the center",
3337 "-lat geometry local adaptive thresholding",
3338 "-layers method optimize, merge, or compare image layers",
3339 "-level value adjust the level of image contrast",
3340 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003341 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003342 "-linear-stretch geometry",
3343 " improve contrast by `stretching with saturation'",
3344 "-liquid-rescale geometry",
3345 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +00003346 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +00003347 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003348 "-modulate value vary the brightness, saturation, and hue",
3349 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003350 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003351 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003352 "-motion-blur geometry",
3353 " simulate motion blur",
3354 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +00003355 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +00003356 "-normalize transform image to span the full range of colors",
3357 "-opaque color change this color to the fill color",
3358 "-ordered-dither NxN",
3359 " add a noise pattern to the image with specific",
3360 " amplitudes",
3361 "-paint radius simulate an oil painting",
3362 "-polaroid angle simulate a Polaroid picture",
3363 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003364 "-profile filename add, delete, or apply an image profile",
3365 "-quantize colorspace reduce colors in this colorspace",
3366 "-radial-blur angle radial blur the image",
3367 "-raise value lighten/darken image edges to create a 3-D effect",
3368 "-random-threshold low,high",
3369 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003370 "-region geometry apply options to a portion of the image",
3371 "-render render vector graphics",
3372 "-repage geometry size and location of an image canvas",
3373 "-resample geometry change the resolution of an image",
3374 "-resize geometry resize the image",
3375 "-roll geometry roll an image vertically or horizontally",
3376 "-rotate degrees apply Paeth rotation to the image",
3377 "-sample geometry scale image with pixel sampling",
3378 "-scale geometry scale the image",
3379 "-segment values segment an image",
3380 "-selective-blur geometry",
3381 " selectively blur pixels within a contrast threshold",
3382 "-sepia-tone threshold",
3383 " simulate a sepia-toned photo",
3384 "-set property value set an image property",
3385 "-shade degrees shade the image using a distant light source",
3386 "-shadow geometry simulate an image shadow",
3387 "-sharpen geometry sharpen the image",
3388 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003389 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003390 "-sigmoidal-contrast geometry",
3391 " increase the contrast without saturating highlights or shadows",
3392 "-sketch geometry simulate a pencil sketch",
3393 "-solarize threshold negate all pixels above the threshold level",
3394 "-sparse-color method args",
3395 " fill in a image based on a few color points",
3396 "-splice geometry splice the background color into the image",
3397 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003398 "-statistic type radius",
3399 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003400 "-strip strip image of all profiles and comments",
3401 "-swirl degrees swirl image pixels about the center",
3402 "-threshold value threshold the image",
3403 "-thumbnail geometry create a thumbnail of the image",
3404 "-tile filename tile image when filling a graphic primitive",
3405 "-tint value tint the image with the fill color",
3406 "-transform affine transform image",
3407 "-transparent color make this color transparent within the image",
3408 "-transpose flip image vertically and rotate 90 degrees",
3409 "-transverse flop image horizontally and rotate 270 degrees",
3410 "-trim trim image edges",
3411 "-type type image type",
3412 "-unique-colors discard all but one of any pixel color",
3413 "-unsharp geometry sharpen the image",
3414 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003415 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003416 "-white-threshold value",
3417 " force all pixels above the threshold into white",
3418 (char *) NULL
3419 },
3420 *sequence_operators[]=
3421 {
cristy4285d782011-02-09 20:12:28 +00003422 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003423 "-clut apply a color lookup table to the image",
3424 "-coalesce merge a sequence of images",
3425 "-combine combine a sequence of images",
3426 "-composite composite image",
3427 "-crop geometry cut out a rectangular region of the image",
3428 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003429 "-evaluate-sequence operator",
3430 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003431 "-flatten flatten a sequence of images",
3432 "-fx expression apply mathematical expression to an image channel(s)",
3433 "-hald-clut apply a Hald color lookup table to the image",
3434 "-morph value morph an image sequence",
3435 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003436 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003437 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003438 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003439 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003440 "-write filename write images to this file",
3441 (char *) NULL
3442 },
3443 *settings[]=
3444 {
3445 "-adjoin join images into a single multi-image file",
3446 "-affine matrix affine transform matrix",
3447 "-alpha option activate, deactivate, reset, or set the alpha channel",
3448 "-antialias remove pixel-aliasing",
3449 "-authenticate password",
3450 " decipher image with this password",
3451 "-attenuate value lessen (or intensify) when adding noise to an image",
3452 "-background color background color",
3453 "-bias value add bias when convolving an image",
3454 "-black-point-compensation",
3455 " use black point compensation",
3456 "-blue-primary point chromaticity blue primary point",
3457 "-bordercolor color border color",
3458 "-caption string assign a caption to an image",
3459 "-channel type apply option to select image channels",
3460 "-colors value preferred number of colors in the image",
3461 "-colorspace type alternate image colorspace",
3462 "-comment string annotate image with comment",
3463 "-compose operator set image composite operator",
3464 "-compress type type of pixel compression when writing the image",
3465 "-define format:option",
3466 " define one or more image format options",
3467 "-delay value display the next image after pausing",
3468 "-density geometry horizontal and vertical density of the image",
3469 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003470 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003471 "-display server get image or font from this X server",
3472 "-dispose method layer disposal method",
3473 "-dither method apply error diffusion to image",
3474 "-encoding type text encoding type",
3475 "-endian type endianness (MSB or LSB) of the image",
3476 "-family name render text with this font family",
3477 "-fill color color to use when filling a graphic primitive",
3478 "-filter type use this filter when resizing an image",
3479 "-font name render text with this font",
3480 "-format \"string\" output formatted image characteristics",
3481 "-fuzz distance colors within this distance are considered equal",
3482 "-gravity type horizontal and vertical text placement",
3483 "-green-primary point chromaticity green primary point",
3484 "-intent type type of rendering intent when managing the image color",
3485 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003486 "-interline-spacing value",
3487 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003488 "-interpolate method pixel color interpolation method",
3489 "-interword-spacing value",
3490 " set the space between two words",
3491 "-kerning value set the space between two letters",
3492 "-label string assign a label to an image",
3493 "-limit type value pixel cache resource limit",
3494 "-loop iterations add Netscape loop extension to your GIF animation",
3495 "-mask filename associate a mask with the image",
3496 "-mattecolor color frame color",
3497 "-monitor monitor progress",
3498 "-orient type image orientation",
3499 "-page geometry size and location of an image canvas (setting)",
3500 "-ping efficiently determine image attributes",
3501 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003502 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003503 "-preview type image preview type",
3504 "-quality value JPEG/MIFF/PNG compression level",
3505 "-quiet suppress all warning messages",
3506 "-red-primary point chromaticity red primary point",
3507 "-regard-warnings pay attention to warning messages",
3508 "-remap filename transform image colors to match this set of colors",
3509 "-respect-parentheses settings remain in effect until parenthesis boundary",
3510 "-sampling-factor geometry",
3511 " horizontal and vertical sampling factor",
3512 "-scene value image scene number",
3513 "-seed value seed a new sequence of pseudo-random numbers",
3514 "-size geometry width and height of image",
3515 "-stretch type render text with this font stretch",
3516 "-stroke color graphic primitive stroke color",
3517 "-strokewidth value graphic primitive stroke width",
3518 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003519 "-synchronize synchronize image to storage device",
3520 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003521 "-texture filename name of texture to tile onto the image background",
3522 "-tile-offset geometry",
3523 " tile offset",
3524 "-treedepth value color tree depth",
3525 "-transparent-color color",
3526 " transparent color",
3527 "-undercolor color annotation bounding box color",
3528 "-units type the units of image resolution",
3529 "-verbose print detailed information about the image",
3530 "-view FlashPix viewing transforms",
3531 "-virtual-pixel method",
3532 " virtual pixel access method",
3533 "-weight type render text with this font weight",
3534 "-white-point point chromaticity white point",
3535 (char *) NULL
3536 },
3537 *stack_operators[]=
3538 {
anthonyb69c4b32011-03-23 04:37:44 +00003539 "-delete indexes delete the image from the image sequence",
3540 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003541 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003542 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003543 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003544 "-swap indexes swap two images in the image sequence",
3545 (char *) NULL
3546 };
3547
3548 const char
3549 **p;
3550
cristybb503372010-05-27 20:51:26 +00003551 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003552 (void) printf("Copyright: %s\n",GetMagickCopyright());
3553 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003554 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3555 GetClientName());
3556 (void) printf("\nImage Settings:\n");
3557 for (p=settings; *p != (char *) NULL; p++)
3558 (void) printf(" %s\n",*p);
3559 (void) printf("\nImage Operators:\n");
3560 for (p=operators; *p != (char *) NULL; p++)
3561 (void) printf(" %s\n",*p);
3562 (void) printf("\nImage Sequence Operators:\n");
3563 for (p=sequence_operators; *p != (char *) NULL; p++)
3564 (void) printf(" %s\n",*p);
3565 (void) printf("\nImage Stack Operators:\n");
3566 for (p=stack_operators; *p != (char *) NULL; p++)
3567 (void) printf(" %s\n",*p);
3568 (void) printf("\nMiscellaneous Options:\n");
3569 for (p=miscellaneous; *p != (char *) NULL; p++)
3570 (void) printf(" %s\n",*p);
3571 (void) printf(
3572 "\nBy default, the image format of `file' is determined by its magic\n");
3573 (void) printf(
3574 "number. To specify a particular image format, precede the filename\n");
3575 (void) printf(
3576 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3577 (void) printf(
3578 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3579 (void) printf("'-' for standard input or output.\n");
3580 return(MagickFalse);
3581}
3582
3583WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3584 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3585{
3586#define DestroyMogrify() \
3587{ \
3588 if (format != (char *) NULL) \
3589 format=DestroyString(format); \
3590 if (path != (char *) NULL) \
3591 path=DestroyString(path); \
3592 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003593 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003594 argv[i]=DestroyString(argv[i]); \
3595 argv=(char **) RelinquishMagickMemory(argv); \
3596}
3597#define ThrowMogrifyException(asperity,tag,option) \
3598{ \
3599 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3600 option); \
3601 DestroyMogrify(); \
3602 return(MagickFalse); \
3603}
3604#define ThrowMogrifyInvalidArgumentException(option,argument) \
3605{ \
3606 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3607 "InvalidArgument","`%s': %s",argument,option); \
3608 DestroyMogrify(); \
3609 return(MagickFalse); \
3610}
3611
3612 char
3613 *format,
3614 *option,
3615 *path;
3616
3617 Image
3618 *image;
3619
3620 ImageStack
3621 image_stack[MaxImageStackDepth+1];
3622
cristy3ed852e2009-09-05 21:47:34 +00003623 MagickBooleanType
3624 global_colormap;
3625
3626 MagickBooleanType
3627 fire,
cristyebbcfea2011-02-25 02:43:54 +00003628 pend,
3629 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00003630
3631 MagickStatusType
3632 status;
3633
cristyebbcfea2011-02-25 02:43:54 +00003634 register ssize_t
3635 i;
3636
3637 ssize_t
3638 j,
3639 k;
3640
cristy3ed852e2009-09-05 21:47:34 +00003641 /*
3642 Set defaults.
3643 */
3644 assert(image_info != (ImageInfo *) NULL);
3645 assert(image_info->signature == MagickSignature);
3646 if (image_info->debug != MagickFalse)
3647 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3648 assert(exception != (ExceptionInfo *) NULL);
3649 if (argc == 2)
3650 {
3651 option=argv[1];
3652 if ((LocaleCompare("version",option+1) == 0) ||
3653 (LocaleCompare("-version",option+1) == 0))
3654 {
cristyb51dff52011-05-19 16:55:47 +00003655 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00003656 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00003657 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3658 GetMagickCopyright());
3659 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3660 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003661 return(MagickFalse);
3662 }
3663 }
3664 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00003665 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00003666 format=(char *) NULL;
3667 path=(char *) NULL;
3668 global_colormap=MagickFalse;
3669 k=0;
3670 j=1;
3671 NewImageStack();
3672 option=(char *) NULL;
3673 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00003674 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003675 status=MagickTrue;
3676 /*
3677 Parse command line.
3678 */
3679 ReadCommandlLine(argc,&argv);
3680 status=ExpandFilenames(&argc,&argv);
3681 if (status == MagickFalse)
3682 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3683 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00003684 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00003685 {
3686 option=argv[i];
3687 if (LocaleCompare(option,"(") == 0)
3688 {
3689 FireImageStack(MagickFalse,MagickTrue,pend);
3690 if (k == MaxImageStackDepth)
3691 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3692 option);
3693 PushImageStack();
3694 continue;
3695 }
3696 if (LocaleCompare(option,")") == 0)
3697 {
3698 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3699 if (k == 0)
3700 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3701 PopImageStack();
3702 continue;
3703 }
cristy042ee782011-04-22 18:48:30 +00003704 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00003705 {
3706 char
3707 backup_filename[MaxTextExtent],
3708 *filename;
3709
3710 Image
3711 *images;
3712
3713 /*
3714 Option is a file name: begin by reading image from specified file.
3715 */
3716 FireImageStack(MagickFalse,MagickFalse,pend);
3717 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00003718 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00003719 filename=argv[++i];
3720 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3721 images=ReadImages(image_info,exception);
3722 status&=(images != (Image *) NULL) &&
3723 (exception->severity < ErrorException);
3724 if (images == (Image *) NULL)
3725 continue;
cristydaa76602010-06-30 13:05:11 +00003726 if (format != (char *) NULL)
3727 (void) CopyMagickString(images->filename,images->magick_filename,
3728 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00003729 if (path != (char *) NULL)
3730 {
3731 GetPathComponent(option,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +00003732 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
cristy3ed852e2009-09-05 21:47:34 +00003733 path,*DirectorySeparator,filename);
3734 }
3735 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00003736 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00003737 AppendImageStack(images);
3738 FinalizeImageSettings(image_info,image,MagickFalse);
3739 if (global_colormap != MagickFalse)
3740 {
3741 QuantizeInfo
3742 *quantize_info;
3743
3744 quantize_info=AcquireQuantizeInfo(image_info);
cristy018f07f2011-09-04 21:15:19 +00003745 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
cristy3ed852e2009-09-05 21:47:34 +00003746 quantize_info=DestroyQuantizeInfo(quantize_info);
3747 }
3748 *backup_filename='\0';
3749 if ((LocaleCompare(image->filename,"-") != 0) &&
3750 (IsPathWritable(image->filename) != MagickFalse))
3751 {
cristybb503372010-05-27 20:51:26 +00003752 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003753 i;
3754
3755 /*
3756 Rename image file as backup.
3757 */
3758 (void) CopyMagickString(backup_filename,image->filename,
3759 MaxTextExtent);
3760 for (i=0; i < 6; i++)
3761 {
3762 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3763 if (IsPathAccessible(backup_filename) == MagickFalse)
3764 break;
3765 }
3766 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
cristy320684d2011-09-23 14:55:47 +00003767 (rename_utf8(image->filename,backup_filename) != 0))
cristy3ed852e2009-09-05 21:47:34 +00003768 *backup_filename='\0';
3769 }
3770 /*
3771 Write transmogrified image to disk.
3772 */
3773 image_info->synchronize=MagickTrue;
3774 status&=WriteImages(image_info,image,image->filename,exception);
3775 if ((status == MagickFalse) && (*backup_filename != '\0'))
cristy18c6c272011-09-23 14:40:37 +00003776 (void) remove_utf8(backup_filename);
cristy3ed852e2009-09-05 21:47:34 +00003777 RemoveAllImageStack();
3778 continue;
3779 }
3780 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3781 switch (*(option+1))
3782 {
3783 case 'a':
3784 {
3785 if (LocaleCompare("adaptive-blur",option+1) == 0)
3786 {
3787 i++;
cristybb503372010-05-27 20:51:26 +00003788 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003789 ThrowMogrifyException(OptionError,"MissingArgument",option);
3790 if (IsGeometry(argv[i]) == MagickFalse)
3791 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3792 break;
3793 }
3794 if (LocaleCompare("adaptive-resize",option+1) == 0)
3795 {
3796 i++;
cristybb503372010-05-27 20:51:26 +00003797 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003798 ThrowMogrifyException(OptionError,"MissingArgument",option);
3799 if (IsGeometry(argv[i]) == MagickFalse)
3800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3801 break;
3802 }
3803 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3804 {
3805 i++;
cristybb503372010-05-27 20:51:26 +00003806 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003807 ThrowMogrifyException(OptionError,"MissingArgument",option);
3808 if (IsGeometry(argv[i]) == MagickFalse)
3809 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3810 break;
3811 }
3812 if (LocaleCompare("affine",option+1) == 0)
3813 {
3814 if (*option == '+')
3815 break;
3816 i++;
cristybb503372010-05-27 20:51:26 +00003817 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003818 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +00003819 break;
3820 }
3821 if (LocaleCompare("alpha",option+1) == 0)
3822 {
cristybb503372010-05-27 20:51:26 +00003823 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003824 type;
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);
cristy042ee782011-04-22 18:48:30 +00003831 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00003832 if (type < 0)
3833 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3834 argv[i]);
3835 break;
3836 }
3837 if (LocaleCompare("annotate",option+1) == 0)
3838 {
3839 if (*option == '+')
3840 break;
3841 i++;
cristybb503372010-05-27 20:51:26 +00003842 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003843 ThrowMogrifyException(OptionError,"MissingArgument",option);
3844 if (IsGeometry(argv[i]) == MagickFalse)
3845 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00003846 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003847 ThrowMogrifyException(OptionError,"MissingArgument",option);
3848 i++;
3849 break;
3850 }
3851 if (LocaleCompare("antialias",option+1) == 0)
3852 break;
3853 if (LocaleCompare("append",option+1) == 0)
3854 break;
3855 if (LocaleCompare("attenuate",option+1) == 0)
3856 {
3857 if (*option == '+')
3858 break;
3859 i++;
cristybb503372010-05-27 20:51:26 +00003860 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003861 ThrowMogrifyException(OptionError,"MissingArgument",option);
3862 if (IsGeometry(argv[i]) == MagickFalse)
3863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3864 break;
3865 }
3866 if (LocaleCompare("authenticate",option+1) == 0)
3867 {
3868 if (*option == '+')
3869 break;
3870 i++;
cristybb503372010-05-27 20:51:26 +00003871 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003872 ThrowMogrifyException(OptionError,"MissingArgument",option);
3873 break;
3874 }
3875 if (LocaleCompare("auto-gamma",option+1) == 0)
3876 break;
3877 if (LocaleCompare("auto-level",option+1) == 0)
3878 break;
3879 if (LocaleCompare("auto-orient",option+1) == 0)
3880 break;
3881 if (LocaleCompare("average",option+1) == 0)
3882 break;
3883 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3884 }
3885 case 'b':
3886 {
3887 if (LocaleCompare("background",option+1) == 0)
3888 {
3889 if (*option == '+')
3890 break;
3891 i++;
cristybb503372010-05-27 20:51:26 +00003892 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003893 ThrowMogrifyException(OptionError,"MissingArgument",option);
3894 break;
3895 }
3896 if (LocaleCompare("bias",option+1) == 0)
3897 {
3898 if (*option == '+')
3899 break;
3900 i++;
cristybb503372010-05-27 20:51:26 +00003901 if (i == (ssize_t) (argc-1))
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("black-point-compensation",option+1) == 0)
3908 break;
3909 if (LocaleCompare("black-threshold",option+1) == 0)
3910 {
3911 if (*option == '+')
3912 break;
3913 i++;
cristybb503372010-05-27 20:51:26 +00003914 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003915 ThrowMogrifyException(OptionError,"MissingArgument",option);
3916 if (IsGeometry(argv[i]) == MagickFalse)
3917 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3918 break;
3919 }
3920 if (LocaleCompare("blue-primary",option+1) == 0)
3921 {
3922 if (*option == '+')
3923 break;
3924 i++;
cristybb503372010-05-27 20:51:26 +00003925 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003926 ThrowMogrifyException(OptionError,"MissingArgument",option);
3927 if (IsGeometry(argv[i]) == MagickFalse)
3928 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3929 break;
3930 }
3931 if (LocaleCompare("blue-shift",option+1) == 0)
3932 {
3933 i++;
cristybb503372010-05-27 20:51:26 +00003934 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003935 ThrowMogrifyException(OptionError,"MissingArgument",option);
3936 if (IsGeometry(argv[i]) == MagickFalse)
3937 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3938 break;
3939 }
3940 if (LocaleCompare("blur",option+1) == 0)
3941 {
3942 i++;
cristybb503372010-05-27 20:51:26 +00003943 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003944 ThrowMogrifyException(OptionError,"MissingArgument",option);
3945 if (IsGeometry(argv[i]) == MagickFalse)
3946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3947 break;
3948 }
3949 if (LocaleCompare("border",option+1) == 0)
3950 {
3951 if (*option == '+')
3952 break;
3953 i++;
cristybb503372010-05-27 20:51:26 +00003954 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003955 ThrowMogrifyException(OptionError,"MissingArgument",option);
3956 if (IsGeometry(argv[i]) == MagickFalse)
3957 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3958 break;
3959 }
3960 if (LocaleCompare("bordercolor",option+1) == 0)
3961 {
3962 if (*option == '+')
3963 break;
3964 i++;
cristybb503372010-05-27 20:51:26 +00003965 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003966 ThrowMogrifyException(OptionError,"MissingArgument",option);
3967 break;
3968 }
3969 if (LocaleCompare("box",option+1) == 0)
3970 {
3971 if (*option == '+')
3972 break;
3973 i++;
cristybb503372010-05-27 20:51:26 +00003974 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003975 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 break;
3977 }
cristya28d6b82010-01-11 20:03:47 +00003978 if (LocaleCompare("brightness-contrast",option+1) == 0)
3979 {
3980 i++;
cristybb503372010-05-27 20:51:26 +00003981 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00003982 ThrowMogrifyException(OptionError,"MissingArgument",option);
3983 if (IsGeometry(argv[i]) == MagickFalse)
3984 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3985 break;
3986 }
cristy3ed852e2009-09-05 21:47:34 +00003987 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3988 }
3989 case 'c':
3990 {
3991 if (LocaleCompare("cache",option+1) == 0)
3992 {
3993 if (*option == '+')
3994 break;
3995 i++;
cristybb503372010-05-27 20:51:26 +00003996 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003997 ThrowMogrifyException(OptionError,"MissingArgument",option);
3998 if (IsGeometry(argv[i]) == MagickFalse)
3999 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4000 break;
4001 }
4002 if (LocaleCompare("caption",option+1) == 0)
4003 {
4004 if (*option == '+')
4005 break;
4006 i++;
cristybb503372010-05-27 20:51:26 +00004007 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004008 ThrowMogrifyException(OptionError,"MissingArgument",option);
4009 break;
4010 }
4011 if (LocaleCompare("channel",option+1) == 0)
4012 {
cristybb503372010-05-27 20:51:26 +00004013 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004014 channel;
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 channel=ParseChannelOption(argv[i]);
4022 if (channel < 0)
4023 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4024 argv[i]);
4025 break;
4026 }
4027 if (LocaleCompare("cdl",option+1) == 0)
4028 {
4029 if (*option == '+')
4030 break;
4031 i++;
cristybb503372010-05-27 20:51:26 +00004032 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004033 ThrowMogrifyException(OptionError,"MissingArgument",option);
4034 break;
4035 }
4036 if (LocaleCompare("charcoal",option+1) == 0)
4037 {
4038 if (*option == '+')
4039 break;
4040 i++;
cristybb503372010-05-27 20:51:26 +00004041 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004042 ThrowMogrifyException(OptionError,"MissingArgument",option);
4043 if (IsGeometry(argv[i]) == MagickFalse)
4044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4045 break;
4046 }
4047 if (LocaleCompare("chop",option+1) == 0)
4048 {
4049 if (*option == '+')
4050 break;
4051 i++;
cristybb503372010-05-27 20:51:26 +00004052 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004053 ThrowMogrifyException(OptionError,"MissingArgument",option);
4054 if (IsGeometry(argv[i]) == MagickFalse)
4055 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4056 break;
4057 }
cristy1eb45dd2009-09-25 16:38:06 +00004058 if (LocaleCompare("clamp",option+1) == 0)
4059 break;
4060 if (LocaleCompare("clip",option+1) == 0)
4061 break;
cristy3ed852e2009-09-05 21:47:34 +00004062 if (LocaleCompare("clip-mask",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 break;
4070 }
4071 if (LocaleCompare("clut",option+1) == 0)
4072 break;
4073 if (LocaleCompare("coalesce",option+1) == 0)
4074 break;
4075 if (LocaleCompare("colorize",option+1) == 0)
4076 {
4077 if (*option == '+')
4078 break;
4079 i++;
cristybb503372010-05-27 20:51:26 +00004080 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004081 ThrowMogrifyException(OptionError,"MissingArgument",option);
4082 if (IsGeometry(argv[i]) == MagickFalse)
4083 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4084 break;
4085 }
cristye6365592010-04-02 17:31:23 +00004086 if (LocaleCompare("color-matrix",option+1) == 0)
4087 {
cristyb6bd4ad2010-08-08 01:12:27 +00004088 KernelInfo
4089 *kernel_info;
4090
cristye6365592010-04-02 17:31:23 +00004091 if (*option == '+')
4092 break;
4093 i++;
cristybb503372010-05-27 20:51:26 +00004094 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004095 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004096 kernel_info=AcquireKernelInfo(argv[i]);
4097 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004098 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004099 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004100 break;
4101 }
cristy3ed852e2009-09-05 21:47:34 +00004102 if (LocaleCompare("colors",option+1) == 0)
4103 {
4104 if (*option == '+')
4105 break;
4106 i++;
cristybb503372010-05-27 20:51:26 +00004107 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004108 ThrowMogrifyException(OptionError,"MissingArgument",option);
4109 if (IsGeometry(argv[i]) == MagickFalse)
4110 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4111 break;
4112 }
4113 if (LocaleCompare("colorspace",option+1) == 0)
4114 {
cristybb503372010-05-27 20:51:26 +00004115 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004116 colorspace;
4117
4118 if (*option == '+')
4119 break;
4120 i++;
cristybb503372010-05-27 20:51:26 +00004121 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004122 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004123 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004124 argv[i]);
4125 if (colorspace < 0)
4126 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4127 argv[i]);
4128 break;
4129 }
4130 if (LocaleCompare("combine",option+1) == 0)
4131 break;
4132 if (LocaleCompare("comment",option+1) == 0)
4133 {
4134 if (*option == '+')
4135 break;
4136 i++;
cristybb503372010-05-27 20:51:26 +00004137 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004138 ThrowMogrifyException(OptionError,"MissingArgument",option);
4139 break;
4140 }
4141 if (LocaleCompare("composite",option+1) == 0)
4142 break;
4143 if (LocaleCompare("compress",option+1) == 0)
4144 {
cristybb503372010-05-27 20:51:26 +00004145 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004146 compress;
4147
4148 if (*option == '+')
4149 break;
4150 i++;
cristybb503372010-05-27 20:51:26 +00004151 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004152 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004153 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004154 argv[i]);
4155 if (compress < 0)
4156 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4157 argv[i]);
4158 break;
4159 }
cristy22879752009-10-25 23:55:40 +00004160 if (LocaleCompare("concurrent",option+1) == 0)
4161 break;
cristy3ed852e2009-09-05 21:47:34 +00004162 if (LocaleCompare("contrast",option+1) == 0)
4163 break;
4164 if (LocaleCompare("contrast-stretch",option+1) == 0)
4165 {
4166 i++;
cristybb503372010-05-27 20:51:26 +00004167 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004168 ThrowMogrifyException(OptionError,"MissingArgument",option);
4169 if (IsGeometry(argv[i]) == MagickFalse)
4170 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4171 break;
4172 }
4173 if (LocaleCompare("convolve",option+1) == 0)
4174 {
cristyb6bd4ad2010-08-08 01:12:27 +00004175 KernelInfo
4176 *kernel_info;
4177
cristy3ed852e2009-09-05 21:47:34 +00004178 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);
cristyb6bd4ad2010-08-08 01:12:27 +00004183 kernel_info=AcquireKernelInfo(argv[i]);
4184 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004186 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004187 break;
4188 }
4189 if (LocaleCompare("crop",option+1) == 0)
4190 {
4191 if (*option == '+')
4192 break;
4193 i++;
cristybb503372010-05-27 20:51:26 +00004194 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004195 ThrowMogrifyException(OptionError,"MissingArgument",option);
4196 if (IsGeometry(argv[i]) == MagickFalse)
4197 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4198 break;
4199 }
4200 if (LocaleCompare("cycle",option+1) == 0)
4201 {
4202 if (*option == '+')
4203 break;
4204 i++;
cristybb503372010-05-27 20:51:26 +00004205 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004206 ThrowMogrifyException(OptionError,"MissingArgument",option);
4207 if (IsGeometry(argv[i]) == MagickFalse)
4208 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4209 break;
4210 }
4211 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4212 }
4213 case 'd':
4214 {
4215 if (LocaleCompare("decipher",option+1) == 0)
4216 {
4217 if (*option == '+')
4218 break;
4219 i++;
cristybb503372010-05-27 20:51:26 +00004220 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004221 ThrowMogrifyException(OptionError,"MissingArgument",option);
4222 break;
4223 }
4224 if (LocaleCompare("deconstruct",option+1) == 0)
4225 break;
4226 if (LocaleCompare("debug",option+1) == 0)
4227 {
cristybb503372010-05-27 20:51:26 +00004228 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004229 event;
4230
4231 if (*option == '+')
4232 break;
4233 i++;
cristybb503372010-05-27 20:51:26 +00004234 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004235 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004236 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004237 if (event < 0)
4238 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4239 argv[i]);
4240 (void) SetLogEventMask(argv[i]);
4241 break;
4242 }
4243 if (LocaleCompare("define",option+1) == 0)
4244 {
4245 i++;
cristybb503372010-05-27 20:51:26 +00004246 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004247 ThrowMogrifyException(OptionError,"MissingArgument",option);
4248 if (*option == '+')
4249 {
4250 const char
4251 *define;
4252
4253 define=GetImageOption(image_info,argv[i]);
4254 if (define == (const char *) NULL)
4255 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4256 break;
4257 }
4258 break;
4259 }
4260 if (LocaleCompare("delay",option+1) == 0)
4261 {
4262 if (*option == '+')
4263 break;
4264 i++;
cristybb503372010-05-27 20:51:26 +00004265 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004266 ThrowMogrifyException(OptionError,"MissingArgument",option);
4267 if (IsGeometry(argv[i]) == MagickFalse)
4268 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4269 break;
4270 }
cristyecb10ff2011-03-22 13:14:03 +00004271 if (LocaleCompare("delete",option+1) == 0)
4272 {
4273 if (*option == '+')
4274 break;
4275 i++;
4276 if (i == (ssize_t) (argc-1))
4277 ThrowMogrifyException(OptionError,"MissingArgument",option);
4278 if (IsGeometry(argv[i]) == MagickFalse)
4279 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4280 break;
4281 }
cristy3ed852e2009-09-05 21:47:34 +00004282 if (LocaleCompare("density",option+1) == 0)
4283 {
4284 if (*option == '+')
4285 break;
4286 i++;
cristybb503372010-05-27 20:51:26 +00004287 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004288 ThrowMogrifyException(OptionError,"MissingArgument",option);
4289 if (IsGeometry(argv[i]) == MagickFalse)
4290 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4291 break;
4292 }
4293 if (LocaleCompare("depth",option+1) == 0)
4294 {
4295 if (*option == '+')
4296 break;
4297 i++;
cristybb503372010-05-27 20:51:26 +00004298 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004299 ThrowMogrifyException(OptionError,"MissingArgument",option);
4300 if (IsGeometry(argv[i]) == MagickFalse)
4301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4302 break;
4303 }
4304 if (LocaleCompare("deskew",option+1) == 0)
4305 {
4306 if (*option == '+')
4307 break;
4308 i++;
cristybb503372010-05-27 20:51:26 +00004309 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004310 ThrowMogrifyException(OptionError,"MissingArgument",option);
4311 if (IsGeometry(argv[i]) == MagickFalse)
4312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4313 break;
4314 }
4315 if (LocaleCompare("despeckle",option+1) == 0)
4316 break;
4317 if (LocaleCompare("dft",option+1) == 0)
4318 break;
cristyc9b12952010-03-28 01:12:28 +00004319 if (LocaleCompare("direction",option+1) == 0)
4320 {
cristybb503372010-05-27 20:51:26 +00004321 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004322 direction;
4323
4324 if (*option == '+')
4325 break;
4326 i++;
cristybb503372010-05-27 20:51:26 +00004327 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004328 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004329 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00004330 argv[i]);
4331 if (direction < 0)
4332 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4333 argv[i]);
4334 break;
4335 }
cristy3ed852e2009-09-05 21:47:34 +00004336 if (LocaleCompare("display",option+1) == 0)
4337 {
4338 if (*option == '+')
4339 break;
4340 i++;
cristybb503372010-05-27 20:51:26 +00004341 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004342 ThrowMogrifyException(OptionError,"MissingArgument",option);
4343 break;
4344 }
4345 if (LocaleCompare("dispose",option+1) == 0)
4346 {
cristybb503372010-05-27 20:51:26 +00004347 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004348 dispose;
4349
4350 if (*option == '+')
4351 break;
4352 i++;
cristybb503372010-05-27 20:51:26 +00004353 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004354 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004355 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004356 if (dispose < 0)
4357 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4358 argv[i]);
4359 break;
4360 }
4361 if (LocaleCompare("distort",option+1) == 0)
4362 {
cristybb503372010-05-27 20:51:26 +00004363 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004364 op;
4365
4366 i++;
cristybb503372010-05-27 20:51:26 +00004367 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004368 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004369 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004370 if (op < 0)
4371 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4372 argv[i]);
4373 i++;
cristybb503372010-05-27 20:51:26 +00004374 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4376 break;
4377 }
4378 if (LocaleCompare("dither",option+1) == 0)
4379 {
cristybb503372010-05-27 20:51:26 +00004380 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004381 method;
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);
cristy042ee782011-04-22 18:48:30 +00004388 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004389 if (method < 0)
4390 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4391 argv[i]);
4392 break;
4393 }
4394 if (LocaleCompare("draw",option+1) == 0)
4395 {
4396 if (*option == '+')
4397 break;
4398 i++;
cristybb503372010-05-27 20:51:26 +00004399 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004400 ThrowMogrifyException(OptionError,"MissingArgument",option);
4401 break;
4402 }
cristyecb10ff2011-03-22 13:14:03 +00004403 if (LocaleCompare("duplicate",option+1) == 0)
4404 {
4405 if (*option == '+')
4406 break;
4407 i++;
4408 if (i == (ssize_t) (argc-1))
4409 ThrowMogrifyException(OptionError,"MissingArgument",option);
4410 if (IsGeometry(argv[i]) == MagickFalse)
4411 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4412 break;
4413 }
cristy22879752009-10-25 23:55:40 +00004414 if (LocaleCompare("duration",option+1) == 0)
4415 {
4416 if (*option == '+')
4417 break;
4418 i++;
cristybb503372010-05-27 20:51:26 +00004419 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004420 ThrowMogrifyException(OptionError,"MissingArgument",option);
4421 if (IsGeometry(argv[i]) == MagickFalse)
4422 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4423 break;
4424 }
cristy3ed852e2009-09-05 21:47:34 +00004425 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4426 }
4427 case 'e':
4428 {
4429 if (LocaleCompare("edge",option+1) == 0)
4430 {
4431 if (*option == '+')
4432 break;
4433 i++;
cristybb503372010-05-27 20:51:26 +00004434 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004435 ThrowMogrifyException(OptionError,"MissingArgument",option);
4436 if (IsGeometry(argv[i]) == MagickFalse)
4437 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4438 break;
4439 }
4440 if (LocaleCompare("emboss",option+1) == 0)
4441 {
4442 if (*option == '+')
4443 break;
4444 i++;
cristybb503372010-05-27 20:51:26 +00004445 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004446 ThrowMogrifyException(OptionError,"MissingArgument",option);
4447 if (IsGeometry(argv[i]) == MagickFalse)
4448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4449 break;
4450 }
4451 if (LocaleCompare("encipher",option+1) == 0)
4452 {
4453 if (*option == '+')
4454 break;
4455 i++;
cristybb503372010-05-27 20:51:26 +00004456 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004457 ThrowMogrifyException(OptionError,"MissingArgument",option);
4458 break;
4459 }
4460 if (LocaleCompare("encoding",option+1) == 0)
4461 {
4462 if (*option == '+')
4463 break;
4464 i++;
cristybb503372010-05-27 20:51:26 +00004465 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004466 ThrowMogrifyException(OptionError,"MissingArgument",option);
4467 break;
4468 }
4469 if (LocaleCompare("endian",option+1) == 0)
4470 {
cristybb503372010-05-27 20:51:26 +00004471 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004472 endian;
4473
4474 if (*option == '+')
4475 break;
4476 i++;
cristybb503372010-05-27 20:51:26 +00004477 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004478 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004479 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004480 if (endian < 0)
4481 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4482 argv[i]);
4483 break;
4484 }
4485 if (LocaleCompare("enhance",option+1) == 0)
4486 break;
4487 if (LocaleCompare("equalize",option+1) == 0)
4488 break;
4489 if (LocaleCompare("evaluate",option+1) == 0)
4490 {
cristybb503372010-05-27 20:51:26 +00004491 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004492 op;
4493
4494 if (*option == '+')
4495 break;
4496 i++;
cristybb503372010-05-27 20:51:26 +00004497 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004498 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004499 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004500 if (op < 0)
4501 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4502 argv[i]);
4503 i++;
cristybb503372010-05-27 20:51:26 +00004504 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004505 ThrowMogrifyException(OptionError,"MissingArgument",option);
4506 if (IsGeometry(argv[i]) == MagickFalse)
4507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4508 break;
4509 }
cristyd18ae7c2010-03-07 17:39:52 +00004510 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4511 {
cristybb503372010-05-27 20:51:26 +00004512 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004513 op;
4514
4515 if (*option == '+')
4516 break;
4517 i++;
cristybb503372010-05-27 20:51:26 +00004518 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004519 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004520 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00004521 if (op < 0)
4522 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4523 argv[i]);
4524 break;
4525 }
cristy3ed852e2009-09-05 21:47:34 +00004526 if (LocaleCompare("extent",option+1) == 0)
4527 {
4528 if (*option == '+')
4529 break;
4530 i++;
cristybb503372010-05-27 20:51:26 +00004531 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004532 ThrowMogrifyException(OptionError,"MissingArgument",option);
4533 if (IsGeometry(argv[i]) == MagickFalse)
4534 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4535 break;
4536 }
4537 if (LocaleCompare("extract",option+1) == 0)
4538 {
4539 if (*option == '+')
4540 break;
4541 i++;
cristybb503372010-05-27 20:51:26 +00004542 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004543 ThrowMogrifyException(OptionError,"MissingArgument",option);
4544 if (IsGeometry(argv[i]) == MagickFalse)
4545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4546 break;
4547 }
4548 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4549 }
4550 case 'f':
4551 {
4552 if (LocaleCompare("family",option+1) == 0)
4553 {
4554 if (*option == '+')
4555 break;
4556 i++;
cristybb503372010-05-27 20:51:26 +00004557 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004558 ThrowMogrifyException(OptionError,"MissingArgument",option);
4559 break;
4560 }
4561 if (LocaleCompare("fill",option+1) == 0)
4562 {
4563 if (*option == '+')
4564 break;
4565 i++;
cristybb503372010-05-27 20:51:26 +00004566 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004567 ThrowMogrifyException(OptionError,"MissingArgument",option);
4568 break;
4569 }
4570 if (LocaleCompare("filter",option+1) == 0)
4571 {
cristybb503372010-05-27 20:51:26 +00004572 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004573 filter;
4574
4575 if (*option == '+')
4576 break;
4577 i++;
cristybb503372010-05-27 20:51:26 +00004578 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004579 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004580 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004581 if (filter < 0)
4582 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4583 argv[i]);
4584 break;
4585 }
4586 if (LocaleCompare("flatten",option+1) == 0)
4587 break;
4588 if (LocaleCompare("flip",option+1) == 0)
4589 break;
4590 if (LocaleCompare("flop",option+1) == 0)
4591 break;
4592 if (LocaleCompare("floodfill",option+1) == 0)
4593 {
4594 if (*option == '+')
4595 break;
4596 i++;
cristybb503372010-05-27 20:51:26 +00004597 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004598 ThrowMogrifyException(OptionError,"MissingArgument",option);
4599 if (IsGeometry(argv[i]) == MagickFalse)
4600 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4601 i++;
cristybb503372010-05-27 20:51:26 +00004602 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004603 ThrowMogrifyException(OptionError,"MissingArgument",option);
4604 break;
4605 }
4606 if (LocaleCompare("font",option+1) == 0)
4607 {
4608 if (*option == '+')
4609 break;
4610 i++;
cristybb503372010-05-27 20:51:26 +00004611 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004612 ThrowMogrifyException(OptionError,"MissingArgument",option);
4613 break;
4614 }
4615 if (LocaleCompare("format",option+1) == 0)
4616 {
4617 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4618 (void) CloneString(&format,(char *) NULL);
4619 if (*option == '+')
4620 break;
4621 i++;
cristybb503372010-05-27 20:51:26 +00004622 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004623 ThrowMogrifyException(OptionError,"MissingArgument",option);
4624 (void) CloneString(&format,argv[i]);
4625 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4626 (void) ConcatenateMagickString(image_info->filename,":",
4627 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00004628 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00004629 if (*image_info->magick == '\0')
4630 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4631 format);
4632 break;
4633 }
4634 if (LocaleCompare("frame",option+1) == 0)
4635 {
4636 if (*option == '+')
4637 break;
4638 i++;
cristybb503372010-05-27 20:51:26 +00004639 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004640 ThrowMogrifyException(OptionError,"MissingArgument",option);
4641 if (IsGeometry(argv[i]) == MagickFalse)
4642 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4643 break;
4644 }
4645 if (LocaleCompare("function",option+1) == 0)
4646 {
cristybb503372010-05-27 20:51:26 +00004647 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004648 op;
4649
4650 if (*option == '+')
4651 break;
4652 i++;
cristybb503372010-05-27 20:51:26 +00004653 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004654 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004655 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004656 if (op < 0)
4657 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4658 i++;
cristybb503372010-05-27 20:51:26 +00004659 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004660 ThrowMogrifyException(OptionError,"MissingArgument",option);
4661 break;
4662 }
4663 if (LocaleCompare("fuzz",option+1) == 0)
4664 {
4665 if (*option == '+')
4666 break;
4667 i++;
cristybb503372010-05-27 20:51:26 +00004668 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004669 ThrowMogrifyException(OptionError,"MissingArgument",option);
4670 if (IsGeometry(argv[i]) == MagickFalse)
4671 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4672 break;
4673 }
4674 if (LocaleCompare("fx",option+1) == 0)
4675 {
4676 if (*option == '+')
4677 break;
4678 i++;
cristybb503372010-05-27 20:51:26 +00004679 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004680 ThrowMogrifyException(OptionError,"MissingArgument",option);
4681 break;
4682 }
4683 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4684 }
4685 case 'g':
4686 {
4687 if (LocaleCompare("gamma",option+1) == 0)
4688 {
4689 i++;
cristybb503372010-05-27 20:51:26 +00004690 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004691 ThrowMogrifyException(OptionError,"MissingArgument",option);
4692 if (IsGeometry(argv[i]) == MagickFalse)
4693 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4694 break;
4695 }
4696 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4697 (LocaleCompare("gaussian",option+1) == 0))
4698 {
4699 i++;
cristybb503372010-05-27 20:51:26 +00004700 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004701 ThrowMogrifyException(OptionError,"MissingArgument",option);
4702 if (IsGeometry(argv[i]) == MagickFalse)
4703 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4704 break;
4705 }
4706 if (LocaleCompare("geometry",option+1) == 0)
4707 {
4708 if (*option == '+')
4709 break;
4710 i++;
cristybb503372010-05-27 20:51:26 +00004711 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004712 ThrowMogrifyException(OptionError,"MissingArgument",option);
4713 if (IsGeometry(argv[i]) == MagickFalse)
4714 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4715 break;
4716 }
4717 if (LocaleCompare("gravity",option+1) == 0)
4718 {
cristybb503372010-05-27 20:51:26 +00004719 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004720 gravity;
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);
cristy042ee782011-04-22 18:48:30 +00004727 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004728 if (gravity < 0)
4729 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4730 argv[i]);
4731 break;
4732 }
4733 if (LocaleCompare("green-primary",option+1) == 0)
4734 {
4735 if (*option == '+')
4736 break;
4737 i++;
cristybb503372010-05-27 20:51:26 +00004738 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004739 ThrowMogrifyException(OptionError,"MissingArgument",option);
4740 if (IsGeometry(argv[i]) == MagickFalse)
4741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4742 break;
4743 }
4744 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4745 }
4746 case 'h':
4747 {
4748 if (LocaleCompare("hald-clut",option+1) == 0)
4749 break;
4750 if ((LocaleCompare("help",option+1) == 0) ||
4751 (LocaleCompare("-help",option+1) == 0))
4752 return(MogrifyUsage());
4753 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4754 }
4755 case 'i':
4756 {
4757 if (LocaleCompare("identify",option+1) == 0)
4758 break;
4759 if (LocaleCompare("idft",option+1) == 0)
4760 break;
4761 if (LocaleCompare("implode",option+1) == 0)
4762 {
4763 if (*option == '+')
4764 break;
4765 i++;
cristybb503372010-05-27 20:51:26 +00004766 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004767 ThrowMogrifyException(OptionError,"MissingArgument",option);
4768 if (IsGeometry(argv[i]) == MagickFalse)
4769 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4770 break;
4771 }
4772 if (LocaleCompare("intent",option+1) == 0)
4773 {
cristybb503372010-05-27 20:51:26 +00004774 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004775 intent;
4776
4777 if (*option == '+')
4778 break;
4779 i++;
cristybb503372010-05-27 20:51:26 +00004780 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004781 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004782 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004783 if (intent < 0)
4784 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4785 argv[i]);
4786 break;
4787 }
4788 if (LocaleCompare("interlace",option+1) == 0)
4789 {
cristybb503372010-05-27 20:51:26 +00004790 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004791 interlace;
4792
4793 if (*option == '+')
4794 break;
4795 i++;
cristybb503372010-05-27 20:51:26 +00004796 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004797 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004798 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004799 argv[i]);
4800 if (interlace < 0)
4801 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4802 argv[i]);
4803 break;
4804 }
cristyb32b90a2009-09-07 21:45:48 +00004805 if (LocaleCompare("interline-spacing",option+1) == 0)
4806 {
4807 if (*option == '+')
4808 break;
4809 i++;
cristybb503372010-05-27 20:51:26 +00004810 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00004811 ThrowMogrifyException(OptionError,"MissingArgument",option);
4812 if (IsGeometry(argv[i]) == MagickFalse)
4813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4814 break;
4815 }
cristy3ed852e2009-09-05 21:47:34 +00004816 if (LocaleCompare("interpolate",option+1) == 0)
4817 {
cristybb503372010-05-27 20:51:26 +00004818 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004819 interpolate;
4820
4821 if (*option == '+')
4822 break;
4823 i++;
cristybb503372010-05-27 20:51:26 +00004824 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004825 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004826 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004827 argv[i]);
4828 if (interpolate < 0)
4829 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4830 argv[i]);
4831 break;
4832 }
4833 if (LocaleCompare("interword-spacing",option+1) == 0)
4834 {
4835 if (*option == '+')
4836 break;
4837 i++;
cristybb503372010-05-27 20:51:26 +00004838 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004839 ThrowMogrifyException(OptionError,"MissingArgument",option);
4840 if (IsGeometry(argv[i]) == MagickFalse)
4841 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4842 break;
4843 }
4844 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4845 }
4846 case 'k':
4847 {
4848 if (LocaleCompare("kerning",option+1) == 0)
4849 {
4850 if (*option == '+')
4851 break;
4852 i++;
cristybb503372010-05-27 20:51:26 +00004853 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004854 ThrowMogrifyException(OptionError,"MissingArgument",option);
4855 if (IsGeometry(argv[i]) == MagickFalse)
4856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4857 break;
4858 }
4859 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4860 }
4861 case 'l':
4862 {
4863 if (LocaleCompare("label",option+1) == 0)
4864 {
4865 if (*option == '+')
4866 break;
4867 i++;
cristybb503372010-05-27 20:51:26 +00004868 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004869 ThrowMogrifyException(OptionError,"MissingArgument",option);
4870 break;
4871 }
4872 if (LocaleCompare("lat",option+1) == 0)
4873 {
4874 if (*option == '+')
4875 break;
4876 i++;
cristybb503372010-05-27 20:51:26 +00004877 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004878 ThrowMogrifyException(OptionError,"MissingArgument",option);
4879 if (IsGeometry(argv[i]) == MagickFalse)
4880 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4881 }
4882 if (LocaleCompare("layers",option+1) == 0)
4883 {
cristybb503372010-05-27 20:51:26 +00004884 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004885 type;
4886
4887 if (*option == '+')
4888 break;
4889 i++;
cristybb503372010-05-27 20:51:26 +00004890 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004891 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004892 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004893 if (type < 0)
4894 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4895 argv[i]);
4896 break;
4897 }
4898 if (LocaleCompare("level",option+1) == 0)
4899 {
4900 i++;
cristybb503372010-05-27 20:51:26 +00004901 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004902 ThrowMogrifyException(OptionError,"MissingArgument",option);
4903 if (IsGeometry(argv[i]) == MagickFalse)
4904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4905 break;
4906 }
4907 if (LocaleCompare("level-colors",option+1) == 0)
4908 {
4909 i++;
cristybb503372010-05-27 20:51:26 +00004910 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004911 ThrowMogrifyException(OptionError,"MissingArgument",option);
4912 break;
4913 }
4914 if (LocaleCompare("linewidth",option+1) == 0)
4915 {
4916 if (*option == '+')
4917 break;
4918 i++;
cristybb503372010-05-27 20:51:26 +00004919 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004920 ThrowMogrifyException(OptionError,"MissingArgument",option);
4921 if (IsGeometry(argv[i]) == MagickFalse)
4922 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4923 break;
4924 }
4925 if (LocaleCompare("limit",option+1) == 0)
4926 {
4927 char
4928 *p;
4929
4930 double
4931 value;
4932
cristybb503372010-05-27 20:51:26 +00004933 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004934 resource;
4935
4936 if (*option == '+')
4937 break;
4938 i++;
cristybb503372010-05-27 20:51:26 +00004939 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004940 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004941 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004942 argv[i]);
4943 if (resource < 0)
4944 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4945 argv[i]);
4946 i++;
cristybb503372010-05-27 20:51:26 +00004947 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004948 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyc1acd842011-05-19 23:05:47 +00004949 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00004950 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00004951 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4952 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4953 break;
4954 }
4955 if (LocaleCompare("liquid-rescale",option+1) == 0)
4956 {
4957 i++;
cristybb503372010-05-27 20:51:26 +00004958 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004959 ThrowMogrifyException(OptionError,"MissingArgument",option);
4960 if (IsGeometry(argv[i]) == MagickFalse)
4961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4962 break;
4963 }
4964 if (LocaleCompare("list",option+1) == 0)
4965 {
cristybb503372010-05-27 20:51:26 +00004966 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004967 list;
4968
4969 if (*option == '+')
4970 break;
4971 i++;
cristybb503372010-05-27 20:51:26 +00004972 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004973 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004974 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004975 if (list < 0)
4976 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00004977 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00004978 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00004979 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00004980 }
4981 if (LocaleCompare("log",option+1) == 0)
4982 {
4983 if (*option == '+')
4984 break;
4985 i++;
cristybb503372010-05-27 20:51:26 +00004986 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00004987 (strchr(argv[i],'%') == (char *) NULL))
4988 ThrowMogrifyException(OptionError,"MissingArgument",option);
4989 break;
4990 }
4991 if (LocaleCompare("loop",option+1) == 0)
4992 {
4993 if (*option == '+')
4994 break;
4995 i++;
cristybb503372010-05-27 20:51:26 +00004996 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004997 ThrowMogrifyException(OptionError,"MissingArgument",option);
4998 if (IsGeometry(argv[i]) == MagickFalse)
4999 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5000 break;
5001 }
5002 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5003 }
5004 case 'm':
5005 {
5006 if (LocaleCompare("map",option+1) == 0)
5007 {
5008 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5009 if (*option == '+')
5010 break;
5011 i++;
cristybb503372010-05-27 20:51:26 +00005012 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005013 ThrowMogrifyException(OptionError,"MissingArgument",option);
5014 break;
5015 }
5016 if (LocaleCompare("mask",option+1) == 0)
5017 {
5018 if (*option == '+')
5019 break;
5020 i++;
cristybb503372010-05-27 20:51:26 +00005021 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005022 ThrowMogrifyException(OptionError,"MissingArgument",option);
5023 break;
5024 }
5025 if (LocaleCompare("matte",option+1) == 0)
5026 break;
5027 if (LocaleCompare("mattecolor",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 break;
5035 }
cristyf40785b2010-03-06 02:27:27 +00005036 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005037 break;
cristyf40785b2010-03-06 02:27:27 +00005038 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005039 break;
cristy3ed852e2009-09-05 21:47:34 +00005040 if (LocaleCompare("modulate",option+1) == 0)
5041 {
5042 if (*option == '+')
5043 break;
5044 i++;
cristybb503372010-05-27 20:51:26 +00005045 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005046 ThrowMogrifyException(OptionError,"MissingArgument",option);
5047 if (IsGeometry(argv[i]) == MagickFalse)
5048 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5049 break;
5050 }
5051 if (LocaleCompare("median",option+1) == 0)
5052 {
5053 if (*option == '+')
5054 break;
5055 i++;
cristybb503372010-05-27 20:51:26 +00005056 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005057 ThrowMogrifyException(OptionError,"MissingArgument",option);
5058 if (IsGeometry(argv[i]) == MagickFalse)
5059 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5060 break;
5061 }
cristy69ec32d2011-02-27 23:57:09 +00005062 if (LocaleCompare("mode",option+1) == 0)
5063 {
5064 if (*option == '+')
5065 break;
5066 i++;
5067 if (i == (ssize_t) argc)
5068 ThrowMogrifyException(OptionError,"MissingArgument",option);
5069 if (IsGeometry(argv[i]) == MagickFalse)
5070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5071 break;
5072 }
cristy3ed852e2009-09-05 21:47:34 +00005073 if (LocaleCompare("monitor",option+1) == 0)
5074 break;
5075 if (LocaleCompare("monochrome",option+1) == 0)
5076 break;
5077 if (LocaleCompare("morph",option+1) == 0)
5078 {
5079 if (*option == '+')
5080 break;
5081 i++;
cristybb503372010-05-27 20:51:26 +00005082 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005083 ThrowMogrifyException(OptionError,"MissingArgument",option);
5084 if (IsGeometry(argv[i]) == MagickFalse)
5085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5086 break;
5087 }
anthony29188a82010-01-22 10:12:34 +00005088 if (LocaleCompare("morphology",option+1) == 0)
5089 {
anthony29188a82010-01-22 10:12:34 +00005090 char
5091 token[MaxTextExtent];
5092
cristyb6bd4ad2010-08-08 01:12:27 +00005093 KernelInfo
5094 *kernel_info;
5095
5096 ssize_t
5097 op;
5098
anthony29188a82010-01-22 10:12:34 +00005099 i++;
cristybb503372010-05-27 20:51:26 +00005100 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005101 ThrowMogrifyException(OptionError,"MissingArgument",option);
5102 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00005103 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00005104 if (op < 0)
5105 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005106 token);
anthony29188a82010-01-22 10:12:34 +00005107 i++;
cristybb503372010-05-27 20:51:26 +00005108 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005109 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005110 kernel_info=AcquireKernelInfo(argv[i]);
5111 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005113 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005114 break;
5115 }
cristy3ed852e2009-09-05 21:47:34 +00005116 if (LocaleCompare("mosaic",option+1) == 0)
5117 break;
5118 if (LocaleCompare("motion-blur",option+1) == 0)
5119 {
5120 if (*option == '+')
5121 break;
5122 i++;
cristybb503372010-05-27 20:51:26 +00005123 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005124 ThrowMogrifyException(OptionError,"MissingArgument",option);
5125 if (IsGeometry(argv[i]) == MagickFalse)
5126 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5127 break;
5128 }
5129 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5130 }
5131 case 'n':
5132 {
5133 if (LocaleCompare("negate",option+1) == 0)
5134 break;
5135 if (LocaleCompare("noise",option+1) == 0)
5136 {
5137 i++;
cristybb503372010-05-27 20:51:26 +00005138 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005139 ThrowMogrifyException(OptionError,"MissingArgument",option);
5140 if (*option == '+')
5141 {
cristybb503372010-05-27 20:51:26 +00005142 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005143 noise;
5144
cristy042ee782011-04-22 18:48:30 +00005145 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005146 if (noise < 0)
5147 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5148 argv[i]);
5149 break;
5150 }
5151 if (IsGeometry(argv[i]) == MagickFalse)
5152 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5153 break;
5154 }
5155 if (LocaleCompare("noop",option+1) == 0)
5156 break;
5157 if (LocaleCompare("normalize",option+1) == 0)
5158 break;
5159 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5160 }
5161 case 'o':
5162 {
5163 if (LocaleCompare("opaque",option+1) == 0)
5164 {
cristy3ed852e2009-09-05 21:47:34 +00005165 i++;
cristybb503372010-05-27 20:51:26 +00005166 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005167 ThrowMogrifyException(OptionError,"MissingArgument",option);
5168 break;
5169 }
5170 if (LocaleCompare("ordered-dither",option+1) == 0)
5171 {
5172 if (*option == '+')
5173 break;
5174 i++;
cristybb503372010-05-27 20:51:26 +00005175 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005176 ThrowMogrifyException(OptionError,"MissingArgument",option);
5177 break;
5178 }
5179 if (LocaleCompare("orient",option+1) == 0)
5180 {
cristybb503372010-05-27 20:51:26 +00005181 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005182 orientation;
5183
5184 orientation=UndefinedOrientation;
5185 if (*option == '+')
5186 break;
5187 i++;
cristybb503372010-05-27 20:51:26 +00005188 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005189 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005190 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005191 argv[i]);
5192 if (orientation < 0)
5193 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5194 argv[i]);
5195 break;
5196 }
5197 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5198 }
5199 case 'p':
5200 {
5201 if (LocaleCompare("page",option+1) == 0)
5202 {
5203 if (*option == '+')
5204 break;
5205 i++;
cristybb503372010-05-27 20:51:26 +00005206 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005207 ThrowMogrifyException(OptionError,"MissingArgument",option);
5208 break;
5209 }
5210 if (LocaleCompare("paint",option+1) == 0)
5211 {
5212 if (*option == '+')
5213 break;
5214 i++;
cristybb503372010-05-27 20:51:26 +00005215 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005216 ThrowMogrifyException(OptionError,"MissingArgument",option);
5217 if (IsGeometry(argv[i]) == MagickFalse)
5218 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5219 break;
5220 }
5221 if (LocaleCompare("path",option+1) == 0)
5222 {
5223 (void) CloneString(&path,(char *) NULL);
5224 if (*option == '+')
5225 break;
5226 i++;
cristybb503372010-05-27 20:51:26 +00005227 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005228 ThrowMogrifyException(OptionError,"MissingArgument",option);
5229 (void) CloneString(&path,argv[i]);
5230 break;
5231 }
5232 if (LocaleCompare("pointsize",option+1) == 0)
5233 {
5234 if (*option == '+')
5235 break;
5236 i++;
cristybb503372010-05-27 20:51:26 +00005237 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005238 ThrowMogrifyException(OptionError,"MissingArgument",option);
5239 if (IsGeometry(argv[i]) == MagickFalse)
5240 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5241 break;
5242 }
5243 if (LocaleCompare("polaroid",option+1) == 0)
5244 {
5245 if (*option == '+')
5246 break;
5247 i++;
cristybb503372010-05-27 20:51:26 +00005248 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005249 ThrowMogrifyException(OptionError,"MissingArgument",option);
5250 if (IsGeometry(argv[i]) == MagickFalse)
5251 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5252 break;
5253 }
5254 if (LocaleCompare("posterize",option+1) == 0)
5255 {
5256 if (*option == '+')
5257 break;
5258 i++;
cristybb503372010-05-27 20:51:26 +00005259 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005260 ThrowMogrifyException(OptionError,"MissingArgument",option);
5261 if (IsGeometry(argv[i]) == MagickFalse)
5262 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5263 break;
5264 }
cristye7f51092010-01-17 00:39:37 +00005265 if (LocaleCompare("precision",option+1) == 0)
5266 {
5267 if (*option == '+')
5268 break;
5269 i++;
cristybb503372010-05-27 20:51:26 +00005270 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005271 ThrowMogrifyException(OptionError,"MissingArgument",option);
5272 if (IsGeometry(argv[i]) == MagickFalse)
5273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5274 break;
5275 }
cristy3ed852e2009-09-05 21:47:34 +00005276 if (LocaleCompare("print",option+1) == 0)
5277 {
5278 if (*option == '+')
5279 break;
5280 i++;
cristybb503372010-05-27 20:51:26 +00005281 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005282 ThrowMogrifyException(OptionError,"MissingArgument",option);
5283 break;
5284 }
5285 if (LocaleCompare("process",option+1) == 0)
5286 {
5287 if (*option == '+')
5288 break;
5289 i++;
cristybb503372010-05-27 20:51:26 +00005290 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005291 ThrowMogrifyException(OptionError,"MissingArgument",option);
5292 break;
5293 }
5294 if (LocaleCompare("profile",option+1) == 0)
5295 {
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 break;
5300 }
5301 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5302 }
5303 case 'q':
5304 {
5305 if (LocaleCompare("quality",option+1) == 0)
5306 {
5307 if (*option == '+')
5308 break;
5309 i++;
cristybb503372010-05-27 20:51:26 +00005310 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005311 ThrowMogrifyException(OptionError,"MissingArgument",option);
5312 if (IsGeometry(argv[i]) == MagickFalse)
5313 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5314 break;
5315 }
5316 if (LocaleCompare("quantize",option+1) == 0)
5317 {
cristybb503372010-05-27 20:51:26 +00005318 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005319 colorspace;
5320
5321 if (*option == '+')
5322 break;
5323 i++;
cristybb503372010-05-27 20:51:26 +00005324 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005325 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005326 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005327 argv[i]);
5328 if (colorspace < 0)
5329 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5330 argv[i]);
5331 break;
5332 }
5333 if (LocaleCompare("quiet",option+1) == 0)
5334 break;
5335 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5336 }
5337 case 'r':
5338 {
5339 if (LocaleCompare("radial-blur",option+1) == 0)
5340 {
5341 i++;
cristybb503372010-05-27 20:51:26 +00005342 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005343 ThrowMogrifyException(OptionError,"MissingArgument",option);
5344 if (IsGeometry(argv[i]) == MagickFalse)
5345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5346 break;
5347 }
5348 if (LocaleCompare("raise",option+1) == 0)
5349 {
5350 i++;
cristybb503372010-05-27 20:51:26 +00005351 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005352 ThrowMogrifyException(OptionError,"MissingArgument",option);
5353 if (IsGeometry(argv[i]) == MagickFalse)
5354 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5355 break;
5356 }
5357 if (LocaleCompare("random-threshold",option+1) == 0)
5358 {
5359 if (*option == '+')
5360 break;
5361 i++;
cristybb503372010-05-27 20:51:26 +00005362 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005363 ThrowMogrifyException(OptionError,"MissingArgument",option);
5364 if (IsGeometry(argv[i]) == MagickFalse)
5365 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5366 break;
5367 }
cristye6365592010-04-02 17:31:23 +00005368 if (LocaleCompare("recolor",option+1) == 0)
5369 {
5370 if (*option == '+')
5371 break;
5372 i++;
cristybb503372010-05-27 20:51:26 +00005373 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005374 ThrowMogrifyException(OptionError,"MissingArgument",option);
5375 if (IsGeometry(argv[i]) == MagickFalse)
5376 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5377 break;
5378 }
cristy3ed852e2009-09-05 21:47:34 +00005379 if (LocaleCompare("red-primary",option+1) == 0)
5380 {
5381 if (*option == '+')
5382 break;
5383 i++;
cristybb503372010-05-27 20:51:26 +00005384 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005385 ThrowMogrifyException(OptionError,"MissingArgument",option);
5386 if (IsGeometry(argv[i]) == MagickFalse)
5387 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5388 }
cristy9f2083a2010-04-22 19:48:05 +00005389 if (LocaleCompare("regard-warnings",option+1) == 0)
5390 break;
cristy3ed852e2009-09-05 21:47:34 +00005391 if (LocaleCompare("region",option+1) == 0)
5392 {
5393 if (*option == '+')
5394 break;
5395 i++;
cristybb503372010-05-27 20:51:26 +00005396 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005397 ThrowMogrifyException(OptionError,"MissingArgument",option);
5398 if (IsGeometry(argv[i]) == MagickFalse)
5399 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5400 break;
5401 }
cristyf0c78232010-03-15 12:53:40 +00005402 if (LocaleCompare("remap",option+1) == 0)
5403 {
5404 if (*option == '+')
5405 break;
5406 i++;
cristybb503372010-05-27 20:51:26 +00005407 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005408 ThrowMogrifyException(OptionError,"MissingArgument",option);
5409 break;
5410 }
cristy3ed852e2009-09-05 21:47:34 +00005411 if (LocaleCompare("render",option+1) == 0)
5412 break;
5413 if (LocaleCompare("repage",option+1) == 0)
5414 {
5415 if (*option == '+')
5416 break;
5417 i++;
cristybb503372010-05-27 20:51:26 +00005418 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005419 ThrowMogrifyException(OptionError,"MissingArgument",option);
5420 if (IsGeometry(argv[i]) == MagickFalse)
5421 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5422 break;
5423 }
5424 if (LocaleCompare("resample",option+1) == 0)
5425 {
5426 if (*option == '+')
5427 break;
5428 i++;
cristybb503372010-05-27 20:51:26 +00005429 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005430 ThrowMogrifyException(OptionError,"MissingArgument",option);
5431 if (IsGeometry(argv[i]) == MagickFalse)
5432 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5433 break;
5434 }
5435 if (LocaleCompare("resize",option+1) == 0)
5436 {
5437 if (*option == '+')
5438 break;
5439 i++;
cristybb503372010-05-27 20:51:26 +00005440 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005441 ThrowMogrifyException(OptionError,"MissingArgument",option);
5442 if (IsGeometry(argv[i]) == MagickFalse)
5443 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5444 break;
5445 }
cristyebbcfea2011-02-25 02:43:54 +00005446 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5447 {
5448 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5449 break;
5450 }
cristy3ed852e2009-09-05 21:47:34 +00005451 if (LocaleCompare("reverse",option+1) == 0)
5452 break;
5453 if (LocaleCompare("roll",option+1) == 0)
5454 {
5455 if (*option == '+')
5456 break;
5457 i++;
cristybb503372010-05-27 20:51:26 +00005458 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005459 ThrowMogrifyException(OptionError,"MissingArgument",option);
5460 if (IsGeometry(argv[i]) == MagickFalse)
5461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5462 break;
5463 }
5464 if (LocaleCompare("rotate",option+1) == 0)
5465 {
5466 i++;
cristybb503372010-05-27 20:51:26 +00005467 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005468 ThrowMogrifyException(OptionError,"MissingArgument",option);
5469 if (IsGeometry(argv[i]) == MagickFalse)
5470 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5471 break;
5472 }
5473 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5474 }
5475 case 's':
5476 {
5477 if (LocaleCompare("sample",option+1) == 0)
5478 {
5479 if (*option == '+')
5480 break;
5481 i++;
cristybb503372010-05-27 20:51:26 +00005482 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005483 ThrowMogrifyException(OptionError,"MissingArgument",option);
5484 if (IsGeometry(argv[i]) == MagickFalse)
5485 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5486 break;
5487 }
5488 if (LocaleCompare("sampling-factor",option+1) == 0)
5489 {
5490 if (*option == '+')
5491 break;
5492 i++;
cristybb503372010-05-27 20:51:26 +00005493 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005494 ThrowMogrifyException(OptionError,"MissingArgument",option);
5495 if (IsGeometry(argv[i]) == MagickFalse)
5496 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5497 break;
5498 }
5499 if (LocaleCompare("scale",option+1) == 0)
5500 {
5501 if (*option == '+')
5502 break;
5503 i++;
cristybb503372010-05-27 20:51:26 +00005504 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005505 ThrowMogrifyException(OptionError,"MissingArgument",option);
5506 if (IsGeometry(argv[i]) == MagickFalse)
5507 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5508 break;
5509 }
5510 if (LocaleCompare("scene",option+1) == 0)
5511 {
5512 if (*option == '+')
5513 break;
5514 i++;
cristybb503372010-05-27 20:51:26 +00005515 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005516 ThrowMogrifyException(OptionError,"MissingArgument",option);
5517 if (IsGeometry(argv[i]) == MagickFalse)
5518 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5519 break;
5520 }
5521 if (LocaleCompare("seed",option+1) == 0)
5522 {
5523 if (*option == '+')
5524 break;
5525 i++;
cristybb503372010-05-27 20:51:26 +00005526 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005527 ThrowMogrifyException(OptionError,"MissingArgument",option);
5528 if (IsGeometry(argv[i]) == MagickFalse)
5529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5530 break;
5531 }
5532 if (LocaleCompare("segment",option+1) == 0)
5533 {
5534 if (*option == '+')
5535 break;
5536 i++;
cristybb503372010-05-27 20:51:26 +00005537 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005538 ThrowMogrifyException(OptionError,"MissingArgument",option);
5539 if (IsGeometry(argv[i]) == MagickFalse)
5540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5541 break;
5542 }
5543 if (LocaleCompare("selective-blur",option+1) == 0)
5544 {
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("separate",option+1) == 0)
5553 break;
5554 if (LocaleCompare("sepia-tone",option+1) == 0)
5555 {
5556 if (*option == '+')
5557 break;
5558 i++;
cristybb503372010-05-27 20:51:26 +00005559 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005560 ThrowMogrifyException(OptionError,"MissingArgument",option);
5561 if (IsGeometry(argv[i]) == MagickFalse)
5562 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5563 break;
5564 }
5565 if (LocaleCompare("set",option+1) == 0)
5566 {
5567 i++;
cristybb503372010-05-27 20:51:26 +00005568 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005569 ThrowMogrifyException(OptionError,"MissingArgument",option);
5570 if (*option == '+')
5571 break;
5572 i++;
cristybb503372010-05-27 20:51:26 +00005573 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005574 ThrowMogrifyException(OptionError,"MissingArgument",option);
5575 break;
5576 }
5577 if (LocaleCompare("shade",option+1) == 0)
5578 {
5579 i++;
cristybb503372010-05-27 20:51:26 +00005580 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005581 ThrowMogrifyException(OptionError,"MissingArgument",option);
5582 if (IsGeometry(argv[i]) == MagickFalse)
5583 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5584 break;
5585 }
5586 if (LocaleCompare("shadow",option+1) == 0)
5587 {
5588 if (*option == '+')
5589 break;
5590 i++;
cristybb503372010-05-27 20:51:26 +00005591 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005592 ThrowMogrifyException(OptionError,"MissingArgument",option);
5593 if (IsGeometry(argv[i]) == MagickFalse)
5594 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5595 break;
5596 }
5597 if (LocaleCompare("sharpen",option+1) == 0)
5598 {
5599 i++;
cristybb503372010-05-27 20:51:26 +00005600 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005601 ThrowMogrifyException(OptionError,"MissingArgument",option);
5602 if (IsGeometry(argv[i]) == MagickFalse)
5603 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5604 break;
5605 }
5606 if (LocaleCompare("shave",option+1) == 0)
5607 {
5608 if (*option == '+')
5609 break;
5610 i++;
cristybb503372010-05-27 20:51:26 +00005611 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005612 ThrowMogrifyException(OptionError,"MissingArgument",option);
5613 if (IsGeometry(argv[i]) == MagickFalse)
5614 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5615 break;
5616 }
5617 if (LocaleCompare("shear",option+1) == 0)
5618 {
5619 i++;
cristybb503372010-05-27 20:51:26 +00005620 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005621 ThrowMogrifyException(OptionError,"MissingArgument",option);
5622 if (IsGeometry(argv[i]) == MagickFalse)
5623 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5624 break;
5625 }
5626 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5627 {
5628 i++;
cristybb503372010-05-27 20:51:26 +00005629 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005630 ThrowMogrifyException(OptionError,"MissingArgument",option);
5631 if (IsGeometry(argv[i]) == MagickFalse)
5632 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5633 break;
5634 }
5635 if (LocaleCompare("size",option+1) == 0)
5636 {
5637 if (*option == '+')
5638 break;
5639 i++;
cristybb503372010-05-27 20:51:26 +00005640 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005641 ThrowMogrifyException(OptionError,"MissingArgument",option);
5642 if (IsGeometry(argv[i]) == MagickFalse)
5643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5644 break;
5645 }
5646 if (LocaleCompare("sketch",option+1) == 0)
5647 {
5648 if (*option == '+')
5649 break;
5650 i++;
cristybb503372010-05-27 20:51:26 +00005651 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005652 ThrowMogrifyException(OptionError,"MissingArgument",option);
5653 if (IsGeometry(argv[i]) == MagickFalse)
5654 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5655 break;
5656 }
cristy4285d782011-02-09 20:12:28 +00005657 if (LocaleCompare("smush",option+1) == 0)
5658 {
cristy4285d782011-02-09 20:12:28 +00005659 i++;
5660 if (i == (ssize_t) argc)
5661 ThrowMogrifyException(OptionError,"MissingArgument",option);
5662 if (IsGeometry(argv[i]) == MagickFalse)
5663 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00005664 i++;
5665 break;
5666 }
cristy3ed852e2009-09-05 21:47:34 +00005667 if (LocaleCompare("solarize",option+1) == 0)
5668 {
5669 if (*option == '+')
5670 break;
5671 i++;
cristybb503372010-05-27 20:51:26 +00005672 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005673 ThrowMogrifyException(OptionError,"MissingArgument",option);
5674 if (IsGeometry(argv[i]) == MagickFalse)
5675 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5676 break;
5677 }
5678 if (LocaleCompare("sparse-color",option+1) == 0)
5679 {
cristybb503372010-05-27 20:51:26 +00005680 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005681 op;
5682
5683 i++;
cristybb503372010-05-27 20:51:26 +00005684 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005685 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005686 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005687 if (op < 0)
5688 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5689 argv[i]);
5690 i++;
cristybb503372010-05-27 20:51:26 +00005691 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005692 ThrowMogrifyException(OptionError,"MissingArgument",option);
5693 break;
5694 }
5695 if (LocaleCompare("spread",option+1) == 0)
5696 {
5697 if (*option == '+')
5698 break;
5699 i++;
cristybb503372010-05-27 20:51:26 +00005700 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005701 ThrowMogrifyException(OptionError,"MissingArgument",option);
5702 if (IsGeometry(argv[i]) == MagickFalse)
5703 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5704 break;
5705 }
cristy0834d642011-03-18 18:26:08 +00005706 if (LocaleCompare("statistic",option+1) == 0)
5707 {
5708 ssize_t
5709 op;
5710
5711 if (*option == '+')
5712 break;
5713 i++;
5714 if (i == (ssize_t) argc)
5715 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005716 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00005717 if (op < 0)
5718 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5719 argv[i]);
5720 i++;
5721 if (i == (ssize_t) (argc-1))
5722 ThrowMogrifyException(OptionError,"MissingArgument",option);
5723 if (IsGeometry(argv[i]) == MagickFalse)
5724 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5725 break;
5726 }
cristy3ed852e2009-09-05 21:47:34 +00005727 if (LocaleCompare("stretch",option+1) == 0)
5728 {
cristybb503372010-05-27 20:51:26 +00005729 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005730 stretch;
5731
5732 if (*option == '+')
5733 break;
5734 i++;
cristybb503372010-05-27 20:51:26 +00005735 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005736 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005737 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005738 if (stretch < 0)
5739 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5740 argv[i]);
5741 break;
5742 }
5743 if (LocaleCompare("strip",option+1) == 0)
5744 break;
5745 if (LocaleCompare("stroke",option+1) == 0)
5746 {
5747 if (*option == '+')
5748 break;
5749 i++;
cristybb503372010-05-27 20:51:26 +00005750 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005751 ThrowMogrifyException(OptionError,"MissingArgument",option);
5752 break;
5753 }
5754 if (LocaleCompare("strokewidth",option+1) == 0)
5755 {
5756 if (*option == '+')
5757 break;
5758 i++;
cristybb503372010-05-27 20:51:26 +00005759 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005760 ThrowMogrifyException(OptionError,"MissingArgument",option);
5761 if (IsGeometry(argv[i]) == MagickFalse)
5762 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5763 break;
5764 }
5765 if (LocaleCompare("style",option+1) == 0)
5766 {
cristybb503372010-05-27 20:51:26 +00005767 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005768 style;
5769
5770 if (*option == '+')
5771 break;
5772 i++;
cristybb503372010-05-27 20:51:26 +00005773 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005774 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005775 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005776 if (style < 0)
5777 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5778 argv[i]);
5779 break;
5780 }
cristyecb10ff2011-03-22 13:14:03 +00005781 if (LocaleCompare("swap",option+1) == 0)
5782 {
5783 if (*option == '+')
5784 break;
5785 i++;
5786 if (i == (ssize_t) (argc-1))
5787 ThrowMogrifyException(OptionError,"MissingArgument",option);
5788 if (IsGeometry(argv[i]) == MagickFalse)
5789 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5790 break;
5791 }
cristy3ed852e2009-09-05 21:47:34 +00005792 if (LocaleCompare("swirl",option+1) == 0)
5793 {
5794 if (*option == '+')
5795 break;
5796 i++;
cristybb503372010-05-27 20:51:26 +00005797 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005798 ThrowMogrifyException(OptionError,"MissingArgument",option);
5799 if (IsGeometry(argv[i]) == MagickFalse)
5800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5801 break;
5802 }
cristyd9a29192010-10-16 16:49:53 +00005803 if (LocaleCompare("synchronize",option+1) == 0)
5804 break;
cristy3ed852e2009-09-05 21:47:34 +00005805 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5806 }
5807 case 't':
5808 {
5809 if (LocaleCompare("taint",option+1) == 0)
5810 break;
5811 if (LocaleCompare("texture",option+1) == 0)
5812 {
5813 if (*option == '+')
5814 break;
5815 i++;
cristybb503372010-05-27 20:51:26 +00005816 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005817 ThrowMogrifyException(OptionError,"MissingArgument",option);
5818 break;
5819 }
5820 if (LocaleCompare("tile",option+1) == 0)
5821 {
5822 if (*option == '+')
5823 break;
5824 i++;
cristybb503372010-05-27 20:51:26 +00005825 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005826 ThrowMogrifyException(OptionError,"MissingArgument",option);
5827 break;
5828 }
5829 if (LocaleCompare("tile-offset",option+1) == 0)
5830 {
5831 if (*option == '+')
5832 break;
5833 i++;
cristybb503372010-05-27 20:51:26 +00005834 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005835 ThrowMogrifyException(OptionError,"MissingArgument",option);
5836 if (IsGeometry(argv[i]) == MagickFalse)
5837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5838 break;
5839 }
5840 if (LocaleCompare("tint",option+1) == 0)
5841 {
5842 if (*option == '+')
5843 break;
5844 i++;
cristybb503372010-05-27 20:51:26 +00005845 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005846 ThrowMogrifyException(OptionError,"MissingArgument",option);
5847 if (IsGeometry(argv[i]) == MagickFalse)
5848 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5849 break;
5850 }
5851 if (LocaleCompare("transform",option+1) == 0)
5852 break;
5853 if (LocaleCompare("transpose",option+1) == 0)
5854 break;
5855 if (LocaleCompare("transverse",option+1) == 0)
5856 break;
5857 if (LocaleCompare("threshold",option+1) == 0)
5858 {
5859 if (*option == '+')
5860 break;
5861 i++;
cristybb503372010-05-27 20:51:26 +00005862 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005863 ThrowMogrifyException(OptionError,"MissingArgument",option);
5864 if (IsGeometry(argv[i]) == MagickFalse)
5865 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5866 break;
5867 }
5868 if (LocaleCompare("thumbnail",option+1) == 0)
5869 {
5870 if (*option == '+')
5871 break;
5872 i++;
cristybb503372010-05-27 20:51:26 +00005873 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005874 ThrowMogrifyException(OptionError,"MissingArgument",option);
5875 if (IsGeometry(argv[i]) == MagickFalse)
5876 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5877 break;
5878 }
5879 if (LocaleCompare("transparent",option+1) == 0)
5880 {
5881 i++;
cristybb503372010-05-27 20:51:26 +00005882 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005883 ThrowMogrifyException(OptionError,"MissingArgument",option);
5884 break;
5885 }
5886 if (LocaleCompare("transparent-color",option+1) == 0)
5887 {
5888 if (*option == '+')
5889 break;
5890 i++;
cristybb503372010-05-27 20:51:26 +00005891 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005892 ThrowMogrifyException(OptionError,"MissingArgument",option);
5893 break;
5894 }
5895 if (LocaleCompare("treedepth",option+1) == 0)
5896 {
5897 if (*option == '+')
5898 break;
5899 i++;
cristybb503372010-05-27 20:51:26 +00005900 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005901 ThrowMogrifyException(OptionError,"MissingArgument",option);
5902 if (IsGeometry(argv[i]) == MagickFalse)
5903 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5904 break;
5905 }
5906 if (LocaleCompare("trim",option+1) == 0)
5907 break;
5908 if (LocaleCompare("type",option+1) == 0)
5909 {
cristybb503372010-05-27 20:51:26 +00005910 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005911 type;
5912
5913 if (*option == '+')
5914 break;
5915 i++;
cristybb503372010-05-27 20:51:26 +00005916 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005917 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005918 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005919 if (type < 0)
5920 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5921 argv[i]);
5922 break;
5923 }
5924 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5925 }
5926 case 'u':
5927 {
5928 if (LocaleCompare("undercolor",option+1) == 0)
5929 {
5930 if (*option == '+')
5931 break;
5932 i++;
cristybb503372010-05-27 20:51:26 +00005933 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005934 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 break;
5936 }
5937 if (LocaleCompare("unique-colors",option+1) == 0)
5938 break;
5939 if (LocaleCompare("units",option+1) == 0)
5940 {
cristybb503372010-05-27 20:51:26 +00005941 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005942 units;
5943
5944 if (*option == '+')
5945 break;
5946 i++;
cristybb503372010-05-27 20:51:26 +00005947 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005948 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005949 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005950 argv[i]);
5951 if (units < 0)
5952 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5953 argv[i]);
5954 break;
5955 }
5956 if (LocaleCompare("unsharp",option+1) == 0)
5957 {
5958 i++;
cristybb503372010-05-27 20:51:26 +00005959 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005960 ThrowMogrifyException(OptionError,"MissingArgument",option);
5961 if (IsGeometry(argv[i]) == MagickFalse)
5962 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5963 break;
5964 }
5965 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5966 }
5967 case 'v':
5968 {
5969 if (LocaleCompare("verbose",option+1) == 0)
5970 {
5971 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5972 break;
5973 }
5974 if ((LocaleCompare("version",option+1) == 0) ||
5975 (LocaleCompare("-version",option+1) == 0))
5976 {
cristyb51dff52011-05-19 16:55:47 +00005977 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00005978 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00005979 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5980 GetMagickCopyright());
5981 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5982 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00005983 break;
5984 }
5985 if (LocaleCompare("view",option+1) == 0)
5986 {
5987 if (*option == '+')
5988 break;
5989 i++;
cristybb503372010-05-27 20:51:26 +00005990 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005991 ThrowMogrifyException(OptionError,"MissingArgument",option);
5992 break;
5993 }
5994 if (LocaleCompare("vignette",option+1) == 0)
5995 {
5996 if (*option == '+')
5997 break;
5998 i++;
cristybb503372010-05-27 20:51:26 +00005999 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006000 ThrowMogrifyException(OptionError,"MissingArgument",option);
6001 if (IsGeometry(argv[i]) == MagickFalse)
6002 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6003 break;
6004 }
6005 if (LocaleCompare("virtual-pixel",option+1) == 0)
6006 {
cristybb503372010-05-27 20:51:26 +00006007 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006008 method;
6009
6010 if (*option == '+')
6011 break;
6012 i++;
cristybb503372010-05-27 20:51:26 +00006013 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006014 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00006015 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00006016 argv[i]);
6017 if (method < 0)
6018 ThrowMogrifyException(OptionError,
6019 "UnrecognizedVirtualPixelMethod",argv[i]);
6020 break;
6021 }
6022 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6023 }
6024 case 'w':
6025 {
6026 if (LocaleCompare("wave",option+1) == 0)
6027 {
6028 i++;
cristybb503372010-05-27 20:51:26 +00006029 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006030 ThrowMogrifyException(OptionError,"MissingArgument",option);
6031 if (IsGeometry(argv[i]) == MagickFalse)
6032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6033 break;
6034 }
6035 if (LocaleCompare("weight",option+1) == 0)
6036 {
6037 if (*option == '+')
6038 break;
6039 i++;
cristybb503372010-05-27 20:51:26 +00006040 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006041 ThrowMogrifyException(OptionError,"MissingArgument",option);
6042 break;
6043 }
6044 if (LocaleCompare("white-point",option+1) == 0)
6045 {
6046 if (*option == '+')
6047 break;
6048 i++;
cristybb503372010-05-27 20:51:26 +00006049 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006050 ThrowMogrifyException(OptionError,"MissingArgument",option);
6051 if (IsGeometry(argv[i]) == MagickFalse)
6052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6053 break;
6054 }
6055 if (LocaleCompare("white-threshold",option+1) == 0)
6056 {
6057 if (*option == '+')
6058 break;
6059 i++;
cristybb503372010-05-27 20:51:26 +00006060 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006061 ThrowMogrifyException(OptionError,"MissingArgument",option);
6062 if (IsGeometry(argv[i]) == MagickFalse)
6063 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6064 break;
6065 }
6066 if (LocaleCompare("write",option+1) == 0)
6067 {
6068 i++;
cristybb503372010-05-27 20:51:26 +00006069 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006070 ThrowMogrifyException(OptionError,"MissingArgument",option);
6071 break;
6072 }
6073 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6074 }
6075 case '?':
6076 break;
6077 default:
6078 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6079 }
cristy042ee782011-04-22 18:48:30 +00006080 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6081 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00006082 if (fire != MagickFalse)
6083 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6084 }
6085 if (k != 0)
6086 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006087 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006088 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6089 DestroyMogrify();
6090 return(status != 0 ? MagickTrue : MagickFalse);
6091}
6092
6093/*
6094%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6095% %
6096% %
6097% %
6098+ M o g r i f y I m a g e I n f o %
6099% %
6100% %
6101% %
6102%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6103%
6104% MogrifyImageInfo() applies image processing settings to the image as
6105% prescribed by command line options.
6106%
6107% The format of the MogrifyImageInfo method is:
6108%
6109% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6110% const char **argv,ExceptionInfo *exception)
6111%
6112% A description of each parameter follows:
6113%
6114% o image_info: the image info..
6115%
6116% o argc: Specifies a pointer to an integer describing the number of
6117% elements in the argument vector.
6118%
6119% o argv: Specifies a pointer to a text array containing the command line
6120% arguments.
6121%
6122% o exception: return any errors or warnings in this structure.
6123%
6124*/
6125WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6126 const int argc,const char **argv,ExceptionInfo *exception)
6127{
6128 const char
6129 *option;
6130
6131 GeometryInfo
6132 geometry_info;
6133
cristybb503372010-05-27 20:51:26 +00006134 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006135 count;
6136
cristybb503372010-05-27 20:51:26 +00006137 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006138 i;
6139
6140 /*
6141 Initialize method variables.
6142 */
6143 assert(image_info != (ImageInfo *) NULL);
6144 assert(image_info->signature == MagickSignature);
6145 if (image_info->debug != MagickFalse)
6146 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6147 image_info->filename);
6148 if (argc < 0)
6149 return(MagickTrue);
6150 /*
6151 Set the image settings.
6152 */
cristybb503372010-05-27 20:51:26 +00006153 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006154 {
6155 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00006156 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00006157 continue;
cristy042ee782011-04-22 18:48:30 +00006158 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00006159 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00006160 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006161 break;
6162 switch (*(option+1))
6163 {
6164 case 'a':
6165 {
6166 if (LocaleCompare("adjoin",option+1) == 0)
6167 {
6168 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6169 break;
6170 }
6171 if (LocaleCompare("antialias",option+1) == 0)
6172 {
6173 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6174 break;
6175 }
cristy3ed852e2009-09-05 21:47:34 +00006176 if (LocaleCompare("authenticate",option+1) == 0)
6177 {
6178 if (*option == '+')
anthony1afdc7a2011-10-05 11:54:28 +00006179 (void) DeleteImageOption(image_info,option+1);
cristy3ed852e2009-09-05 21:47:34 +00006180 else
anthony1afdc7a2011-10-05 11:54:28 +00006181 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006182 break;
6183 }
6184 break;
6185 }
6186 case 'b':
6187 {
6188 if (LocaleCompare("background",option+1) == 0)
6189 {
6190 if (*option == '+')
6191 {
6192 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006193 (void) QueryColorCompliance(MogrifyBackgroundColor,
6194 AllCompliance,&image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006195 break;
6196 }
6197 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006198 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6199 &image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006200 break;
6201 }
6202 if (LocaleCompare("bias",option+1) == 0)
6203 {
6204 if (*option == '+')
6205 {
6206 (void) SetImageOption(image_info,option+1,"0.0");
6207 break;
6208 }
6209 (void) SetImageOption(image_info,option+1,argv[i+1]);
6210 break;
6211 }
6212 if (LocaleCompare("black-point-compensation",option+1) == 0)
6213 {
6214 if (*option == '+')
6215 {
6216 (void) SetImageOption(image_info,option+1,"false");
6217 break;
6218 }
6219 (void) SetImageOption(image_info,option+1,"true");
6220 break;
6221 }
6222 if (LocaleCompare("blue-primary",option+1) == 0)
6223 {
6224 if (*option == '+')
6225 {
6226 (void) SetImageOption(image_info,option+1,"0.0");
6227 break;
6228 }
6229 (void) SetImageOption(image_info,option+1,argv[i+1]);
6230 break;
6231 }
6232 if (LocaleCompare("bordercolor",option+1) == 0)
6233 {
6234 if (*option == '+')
6235 {
6236 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006237 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006238 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006239 break;
6240 }
cristy9950d572011-10-01 18:22:35 +00006241 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6242 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006243 (void) SetImageOption(image_info,option+1,argv[i+1]);
6244 break;
6245 }
6246 if (LocaleCompare("box",option+1) == 0)
6247 {
6248 if (*option == '+')
6249 {
6250 (void) SetImageOption(image_info,"undercolor","none");
6251 break;
6252 }
6253 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6254 break;
6255 }
6256 break;
6257 }
6258 case 'c':
6259 {
6260 if (LocaleCompare("cache",option+1) == 0)
6261 {
6262 MagickSizeType
6263 limit;
6264
6265 limit=MagickResourceInfinity;
6266 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006267 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006268 (void) SetMagickResourceLimit(MemoryResource,limit);
6269 (void) SetMagickResourceLimit(MapResource,2*limit);
6270 break;
6271 }
6272 if (LocaleCompare("caption",option+1) == 0)
6273 {
6274 if (*option == '+')
6275 {
6276 (void) DeleteImageOption(image_info,option+1);
6277 break;
6278 }
6279 (void) SetImageOption(image_info,option+1,argv[i+1]);
6280 break;
6281 }
6282 if (LocaleCompare("channel",option+1) == 0)
6283 {
6284 if (*option == '+')
6285 {
6286 image_info->channel=DefaultChannels;
6287 break;
6288 }
6289 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6290 break;
6291 }
cristy3ed852e2009-09-05 21:47:34 +00006292 if (LocaleCompare("colorspace",option+1) == 0)
6293 {
6294 if (*option == '+')
6295 {
6296 image_info->colorspace=UndefinedColorspace;
6297 (void) SetImageOption(image_info,option+1,"undefined");
6298 break;
6299 }
cristy042ee782011-04-22 18:48:30 +00006300 image_info->colorspace=(ColorspaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006301 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6302 (void) SetImageOption(image_info,option+1,argv[i+1]);
6303 break;
6304 }
cristy3ed852e2009-09-05 21:47:34 +00006305 if (LocaleCompare("comment",option+1) == 0)
6306 {
6307 if (*option == '+')
6308 {
6309 (void) DeleteImageOption(image_info,option+1);
6310 break;
6311 }
6312 (void) SetImageOption(image_info,option+1,argv[i+1]);
6313 break;
6314 }
6315 if (LocaleCompare("compose",option+1) == 0)
6316 {
6317 if (*option == '+')
6318 {
6319 (void) SetImageOption(image_info,option+1,"undefined");
6320 break;
6321 }
6322 (void) SetImageOption(image_info,option+1,argv[i+1]);
6323 break;
6324 }
6325 if (LocaleCompare("compress",option+1) == 0)
6326 {
6327 if (*option == '+')
6328 {
6329 image_info->compression=UndefinedCompression;
6330 (void) SetImageOption(image_info,option+1,"undefined");
6331 break;
6332 }
cristy042ee782011-04-22 18:48:30 +00006333 image_info->compression=(CompressionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006334 MagickCompressOptions,MagickFalse,argv[i+1]);
6335 (void) SetImageOption(image_info,option+1,argv[i+1]);
6336 break;
6337 }
6338 break;
6339 }
6340 case 'd':
6341 {
6342 if (LocaleCompare("debug",option+1) == 0)
6343 {
6344 if (*option == '+')
6345 (void) SetLogEventMask("none");
6346 else
6347 (void) SetLogEventMask(argv[i+1]);
6348 image_info->debug=IsEventLogging();
6349 break;
6350 }
6351 if (LocaleCompare("define",option+1) == 0)
6352 {
6353 if (*option == '+')
6354 {
6355 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6356 (void) DeleteImageRegistry(argv[i+1]+9);
6357 else
6358 (void) DeleteImageOption(image_info,argv[i+1]);
6359 break;
6360 }
6361 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6362 {
6363 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6364 exception);
6365 break;
6366 }
6367 (void) DefineImageOption(image_info,argv[i+1]);
6368 break;
6369 }
6370 if (LocaleCompare("delay",option+1) == 0)
6371 {
6372 if (*option == '+')
6373 {
6374 (void) SetImageOption(image_info,option+1,"0");
6375 break;
6376 }
6377 (void) SetImageOption(image_info,option+1,argv[i+1]);
6378 break;
6379 }
6380 if (LocaleCompare("density",option+1) == 0)
6381 {
6382 /*
6383 Set image density.
6384 */
6385 if (*option == '+')
6386 {
6387 if (image_info->density != (char *) NULL)
6388 image_info->density=DestroyString(image_info->density);
6389 (void) SetImageOption(image_info,option+1,"72");
6390 break;
6391 }
6392 (void) CloneString(&image_info->density,argv[i+1]);
6393 (void) SetImageOption(image_info,option+1,argv[i+1]);
6394 break;
6395 }
6396 if (LocaleCompare("depth",option+1) == 0)
6397 {
6398 if (*option == '+')
6399 {
6400 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6401 break;
6402 }
cristye27293e2009-12-18 02:53:20 +00006403 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006404 break;
6405 }
cristyc9b12952010-03-28 01:12:28 +00006406 if (LocaleCompare("direction",option+1) == 0)
6407 {
6408 if (*option == '+')
6409 {
6410 (void) SetImageOption(image_info,option+1,"undefined");
6411 break;
6412 }
6413 (void) SetImageOption(image_info,option+1,argv[i+1]);
6414 break;
6415 }
cristy3ed852e2009-09-05 21:47:34 +00006416 if (LocaleCompare("display",option+1) == 0)
6417 {
6418 if (*option == '+')
6419 {
6420 if (image_info->server_name != (char *) NULL)
6421 image_info->server_name=DestroyString(
6422 image_info->server_name);
6423 break;
6424 }
6425 (void) CloneString(&image_info->server_name,argv[i+1]);
6426 break;
6427 }
6428 if (LocaleCompare("dispose",option+1) == 0)
6429 {
6430 if (*option == '+')
6431 {
6432 (void) SetImageOption(image_info,option+1,"undefined");
6433 break;
6434 }
6435 (void) SetImageOption(image_info,option+1,argv[i+1]);
6436 break;
6437 }
6438 if (LocaleCompare("dither",option+1) == 0)
6439 {
6440 if (*option == '+')
6441 {
6442 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006443 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006444 break;
6445 }
6446 (void) SetImageOption(image_info,option+1,argv[i+1]);
6447 image_info->dither=MagickTrue;
6448 break;
6449 }
6450 break;
6451 }
6452 case 'e':
6453 {
6454 if (LocaleCompare("encoding",option+1) == 0)
6455 {
6456 if (*option == '+')
6457 {
6458 (void) SetImageOption(image_info,option+1,"undefined");
6459 break;
6460 }
6461 (void) SetImageOption(image_info,option+1,argv[i+1]);
6462 break;
6463 }
6464 if (LocaleCompare("endian",option+1) == 0)
6465 {
6466 if (*option == '+')
6467 {
6468 image_info->endian=UndefinedEndian;
6469 (void) SetImageOption(image_info,option+1,"undefined");
6470 break;
6471 }
cristy042ee782011-04-22 18:48:30 +00006472 image_info->endian=(EndianType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006473 MagickEndianOptions,MagickFalse,argv[i+1]);
6474 (void) SetImageOption(image_info,option+1,argv[i+1]);
6475 break;
6476 }
6477 if (LocaleCompare("extract",option+1) == 0)
6478 {
6479 /*
6480 Set image extract geometry.
6481 */
6482 if (*option == '+')
6483 {
6484 if (image_info->extract != (char *) NULL)
6485 image_info->extract=DestroyString(image_info->extract);
6486 break;
6487 }
6488 (void) CloneString(&image_info->extract,argv[i+1]);
6489 break;
6490 }
6491 break;
6492 }
6493 case 'f':
6494 {
6495 if (LocaleCompare("fill",option+1) == 0)
6496 {
6497 if (*option == '+')
6498 {
6499 (void) SetImageOption(image_info,option+1,"none");
6500 break;
6501 }
6502 (void) SetImageOption(image_info,option+1,argv[i+1]);
6503 break;
6504 }
6505 if (LocaleCompare("filter",option+1) == 0)
6506 {
6507 if (*option == '+')
6508 {
6509 (void) SetImageOption(image_info,option+1,"undefined");
6510 break;
6511 }
6512 (void) SetImageOption(image_info,option+1,argv[i+1]);
6513 break;
6514 }
6515 if (LocaleCompare("font",option+1) == 0)
6516 {
6517 if (*option == '+')
6518 {
6519 if (image_info->font != (char *) NULL)
6520 image_info->font=DestroyString(image_info->font);
6521 break;
6522 }
6523 (void) CloneString(&image_info->font,argv[i+1]);
6524 break;
6525 }
6526 if (LocaleCompare("format",option+1) == 0)
6527 {
6528 register const char
6529 *q;
6530
6531 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006532 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006533 image_info->ping=MagickFalse;
6534 (void) SetImageOption(image_info,option+1,argv[i+1]);
6535 break;
6536 }
6537 if (LocaleCompare("fuzz",option+1) == 0)
6538 {
6539 if (*option == '+')
6540 {
6541 image_info->fuzz=0.0;
6542 (void) SetImageOption(image_info,option+1,"0");
6543 break;
6544 }
cristyf2f27272009-12-17 14:48:46 +00006545 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006546 1.0);
6547 (void) SetImageOption(image_info,option+1,argv[i+1]);
6548 break;
6549 }
6550 break;
6551 }
6552 case 'g':
6553 {
6554 if (LocaleCompare("gravity",option+1) == 0)
6555 {
6556 if (*option == '+')
6557 {
6558 (void) SetImageOption(image_info,option+1,"undefined");
6559 break;
6560 }
6561 (void) SetImageOption(image_info,option+1,argv[i+1]);
6562 break;
6563 }
6564 if (LocaleCompare("green-primary",option+1) == 0)
6565 {
6566 if (*option == '+')
6567 {
6568 (void) SetImageOption(image_info,option+1,"0.0");
6569 break;
6570 }
6571 (void) SetImageOption(image_info,option+1,argv[i+1]);
6572 break;
6573 }
6574 break;
6575 }
6576 case 'i':
6577 {
6578 if (LocaleCompare("intent",option+1) == 0)
6579 {
6580 if (*option == '+')
6581 {
6582 (void) SetImageOption(image_info,option+1,"undefined");
6583 break;
6584 }
6585 (void) SetImageOption(image_info,option+1,argv[i+1]);
6586 break;
6587 }
6588 if (LocaleCompare("interlace",option+1) == 0)
6589 {
6590 if (*option == '+')
6591 {
6592 image_info->interlace=UndefinedInterlace;
6593 (void) SetImageOption(image_info,option+1,"undefined");
6594 break;
6595 }
cristy042ee782011-04-22 18:48:30 +00006596 image_info->interlace=(InterlaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006597 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6599 break;
6600 }
cristyb32b90a2009-09-07 21:45:48 +00006601 if (LocaleCompare("interline-spacing",option+1) == 0)
6602 {
6603 if (*option == '+')
6604 {
6605 (void) SetImageOption(image_info,option+1,"undefined");
6606 break;
6607 }
6608 (void) SetImageOption(image_info,option+1,argv[i+1]);
6609 break;
6610 }
cristy3ed852e2009-09-05 21:47:34 +00006611 if (LocaleCompare("interpolate",option+1) == 0)
6612 {
6613 if (*option == '+')
6614 {
6615 (void) SetImageOption(image_info,option+1,"undefined");
6616 break;
6617 }
6618 (void) SetImageOption(image_info,option+1,argv[i+1]);
6619 break;
6620 }
6621 if (LocaleCompare("interword-spacing",option+1) == 0)
6622 {
6623 if (*option == '+')
6624 {
6625 (void) SetImageOption(image_info,option+1,"undefined");
6626 break;
6627 }
6628 (void) SetImageOption(image_info,option+1,argv[i+1]);
6629 break;
6630 }
6631 break;
6632 }
6633 case 'k':
6634 {
6635 if (LocaleCompare("kerning",option+1) == 0)
6636 {
6637 if (*option == '+')
6638 {
6639 (void) SetImageOption(image_info,option+1,"undefined");
6640 break;
6641 }
6642 (void) SetImageOption(image_info,option+1,argv[i+1]);
6643 break;
6644 }
6645 break;
6646 }
6647 case 'l':
6648 {
6649 if (LocaleCompare("label",option+1) == 0)
6650 {
6651 if (*option == '+')
6652 {
6653 (void) DeleteImageOption(image_info,option+1);
6654 break;
6655 }
6656 (void) SetImageOption(image_info,option+1,argv[i+1]);
6657 break;
6658 }
6659 if (LocaleCompare("limit",option+1) == 0)
6660 {
6661 MagickSizeType
6662 limit;
6663
6664 ResourceType
6665 type;
6666
6667 if (*option == '+')
6668 break;
cristy042ee782011-04-22 18:48:30 +00006669 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
cristy3ed852e2009-09-05 21:47:34 +00006670 MagickFalse,argv[i+1]);
6671 limit=MagickResourceInfinity;
6672 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006673 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006674 (void) SetMagickResourceLimit(type,limit);
6675 break;
6676 }
6677 if (LocaleCompare("list",option+1) == 0)
6678 {
cristybb503372010-05-27 20:51:26 +00006679 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006680 list;
6681
6682 /*
6683 Display configuration list.
6684 */
cristy042ee782011-04-22 18:48:30 +00006685 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006686 switch (list)
6687 {
6688 case MagickCoderOptions:
6689 {
6690 (void) ListCoderInfo((FILE *) NULL,exception);
6691 break;
6692 }
6693 case MagickColorOptions:
6694 {
6695 (void) ListColorInfo((FILE *) NULL,exception);
6696 break;
6697 }
6698 case MagickConfigureOptions:
6699 {
6700 (void) ListConfigureInfo((FILE *) NULL,exception);
6701 break;
6702 }
6703 case MagickDelegateOptions:
6704 {
6705 (void) ListDelegateInfo((FILE *) NULL,exception);
6706 break;
6707 }
6708 case MagickFontOptions:
6709 {
6710 (void) ListTypeInfo((FILE *) NULL,exception);
6711 break;
6712 }
6713 case MagickFormatOptions:
6714 {
6715 (void) ListMagickInfo((FILE *) NULL,exception);
6716 break;
6717 }
6718 case MagickLocaleOptions:
6719 {
6720 (void) ListLocaleInfo((FILE *) NULL,exception);
6721 break;
6722 }
6723 case MagickLogOptions:
6724 {
6725 (void) ListLogInfo((FILE *) NULL,exception);
6726 break;
6727 }
6728 case MagickMagicOptions:
6729 {
6730 (void) ListMagicInfo((FILE *) NULL,exception);
6731 break;
6732 }
6733 case MagickMimeOptions:
6734 {
6735 (void) ListMimeInfo((FILE *) NULL,exception);
6736 break;
6737 }
6738 case MagickModuleOptions:
6739 {
6740 (void) ListModuleInfo((FILE *) NULL,exception);
6741 break;
6742 }
6743 case MagickPolicyOptions:
6744 {
6745 (void) ListPolicyInfo((FILE *) NULL,exception);
6746 break;
6747 }
6748 case MagickResourceOptions:
6749 {
6750 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6751 break;
6752 }
6753 case MagickThresholdOptions:
6754 {
6755 (void) ListThresholdMaps((FILE *) NULL,exception);
6756 break;
6757 }
6758 default:
6759 {
cristy042ee782011-04-22 18:48:30 +00006760 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
cristy3ed852e2009-09-05 21:47:34 +00006761 exception);
6762 break;
6763 }
6764 }
cristyaeb2cbc2010-05-07 13:28:58 +00006765 break;
cristy3ed852e2009-09-05 21:47:34 +00006766 }
6767 if (LocaleCompare("log",option+1) == 0)
6768 {
6769 if (*option == '+')
6770 break;
6771 (void) SetLogFormat(argv[i+1]);
6772 break;
6773 }
6774 if (LocaleCompare("loop",option+1) == 0)
6775 {
6776 if (*option == '+')
6777 {
6778 (void) SetImageOption(image_info,option+1,"0");
6779 break;
6780 }
6781 (void) SetImageOption(image_info,option+1,argv[i+1]);
6782 break;
6783 }
6784 break;
6785 }
6786 case 'm':
6787 {
6788 if (LocaleCompare("matte",option+1) == 0)
6789 {
6790 if (*option == '+')
6791 {
6792 (void) SetImageOption(image_info,option+1,"false");
6793 break;
6794 }
6795 (void) SetImageOption(image_info,option+1,"true");
6796 break;
6797 }
6798 if (LocaleCompare("mattecolor",option+1) == 0)
6799 {
6800 if (*option == '+')
6801 {
6802 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006803 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006804 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006805 break;
6806 }
6807 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006808 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6809 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006810 break;
6811 }
6812 if (LocaleCompare("monitor",option+1) == 0)
6813 {
6814 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6815 (void *) NULL);
6816 break;
6817 }
6818 if (LocaleCompare("monochrome",option+1) == 0)
6819 {
6820 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6821 break;
6822 }
6823 break;
6824 }
6825 case 'o':
6826 {
6827 if (LocaleCompare("orient",option+1) == 0)
6828 {
6829 if (*option == '+')
6830 {
6831 image_info->orientation=UndefinedOrientation;
6832 (void) SetImageOption(image_info,option+1,"undefined");
6833 break;
6834 }
cristy042ee782011-04-22 18:48:30 +00006835 image_info->orientation=(OrientationType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006836 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00006837 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006838 break;
6839 }
6840 }
6841 case 'p':
6842 {
6843 if (LocaleCompare("page",option+1) == 0)
6844 {
6845 char
6846 *canonical_page,
6847 page[MaxTextExtent];
6848
6849 const char
6850 *image_option;
6851
6852 MagickStatusType
6853 flags;
6854
6855 RectangleInfo
6856 geometry;
6857
6858 if (*option == '+')
6859 {
6860 (void) DeleteImageOption(image_info,option+1);
6861 (void) CloneString(&image_info->page,(char *) NULL);
6862 break;
6863 }
6864 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6865 image_option=GetImageOption(image_info,"page");
6866 if (image_option != (const char *) NULL)
6867 flags=ParseAbsoluteGeometry(image_option,&geometry);
6868 canonical_page=GetPageGeometry(argv[i+1]);
6869 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6870 canonical_page=DestroyString(canonical_page);
cristyb51dff52011-05-19 16:55:47 +00006871 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00006872 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00006873 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
cristyb51dff52011-05-19 16:55:47 +00006874 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00006875 (unsigned long) geometry.width,(unsigned long) geometry.height,
6876 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00006877 (void) SetImageOption(image_info,option+1,page);
6878 (void) CloneString(&image_info->page,page);
6879 break;
6880 }
6881 if (LocaleCompare("pen",option+1) == 0)
6882 {
6883 if (*option == '+')
6884 {
6885 (void) SetImageOption(image_info,option+1,"none");
6886 break;
6887 }
6888 (void) SetImageOption(image_info,option+1,argv[i+1]);
6889 break;
6890 }
6891 if (LocaleCompare("ping",option+1) == 0)
6892 {
6893 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6894 break;
6895 }
6896 if (LocaleCompare("pointsize",option+1) == 0)
6897 {
6898 if (*option == '+')
6899 geometry_info.rho=0.0;
6900 else
6901 (void) ParseGeometry(argv[i+1],&geometry_info);
6902 image_info->pointsize=geometry_info.rho;
6903 break;
6904 }
cristye7f51092010-01-17 00:39:37 +00006905 if (LocaleCompare("precision",option+1) == 0)
6906 {
cristybf2766a2010-01-17 03:33:23 +00006907 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00006908 break;
6909 }
cristy3ed852e2009-09-05 21:47:34 +00006910 if (LocaleCompare("preview",option+1) == 0)
6911 {
6912 /*
6913 Preview image.
6914 */
6915 if (*option == '+')
6916 {
6917 image_info->preview_type=UndefinedPreview;
6918 break;
6919 }
cristy042ee782011-04-22 18:48:30 +00006920 image_info->preview_type=(PreviewType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006921 MagickPreviewOptions,MagickFalse,argv[i+1]);
6922 break;
6923 }
6924 break;
6925 }
6926 case 'q':
6927 {
6928 if (LocaleCompare("quality",option+1) == 0)
6929 {
6930 /*
6931 Set image compression quality.
6932 */
6933 if (*option == '+')
6934 {
6935 image_info->quality=UndefinedCompressionQuality;
6936 (void) SetImageOption(image_info,option+1,"0");
6937 break;
6938 }
cristye27293e2009-12-18 02:53:20 +00006939 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006940 (void) SetImageOption(image_info,option+1,argv[i+1]);
6941 break;
6942 }
6943 if (LocaleCompare("quiet",option+1) == 0)
6944 {
6945 static WarningHandler
6946 warning_handler = (WarningHandler) NULL;
6947
6948 if (*option == '+')
6949 {
6950 /*
6951 Restore error or warning messages.
6952 */
6953 warning_handler=SetWarningHandler(warning_handler);
6954 break;
6955 }
6956 /*
6957 Suppress error or warning messages.
6958 */
6959 warning_handler=SetWarningHandler((WarningHandler) NULL);
6960 break;
6961 }
6962 break;
6963 }
6964 case 'r':
6965 {
6966 if (LocaleCompare("red-primary",option+1) == 0)
6967 {
6968 if (*option == '+')
6969 {
6970 (void) SetImageOption(image_info,option+1,"0.0");
6971 break;
6972 }
6973 (void) SetImageOption(image_info,option+1,argv[i+1]);
6974 break;
6975 }
6976 break;
6977 }
6978 case 's':
6979 {
6980 if (LocaleCompare("sampling-factor",option+1) == 0)
6981 {
6982 /*
6983 Set image sampling factor.
6984 */
6985 if (*option == '+')
6986 {
6987 if (image_info->sampling_factor != (char *) NULL)
6988 image_info->sampling_factor=DestroyString(
6989 image_info->sampling_factor);
6990 break;
6991 }
6992 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6993 break;
6994 }
6995 if (LocaleCompare("scene",option+1) == 0)
6996 {
6997 /*
6998 Set image scene.
6999 */
7000 if (*option == '+')
7001 {
7002 image_info->scene=0;
7003 (void) SetImageOption(image_info,option+1,"0");
7004 break;
7005 }
cristye27293e2009-12-18 02:53:20 +00007006 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007007 (void) SetImageOption(image_info,option+1,argv[i+1]);
7008 break;
7009 }
7010 if (LocaleCompare("seed",option+1) == 0)
7011 {
cristybb503372010-05-27 20:51:26 +00007012 size_t
cristy3ed852e2009-09-05 21:47:34 +00007013 seed;
7014
7015 if (*option == '+')
7016 {
cristybb503372010-05-27 20:51:26 +00007017 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007018 SeedPseudoRandomGenerator(seed);
7019 break;
7020 }
cristye27293e2009-12-18 02:53:20 +00007021 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007022 SeedPseudoRandomGenerator(seed);
7023 break;
7024 }
7025 if (LocaleCompare("size",option+1) == 0)
7026 {
7027 if (*option == '+')
7028 {
7029 if (image_info->size != (char *) NULL)
7030 image_info->size=DestroyString(image_info->size);
7031 break;
7032 }
7033 (void) CloneString(&image_info->size,argv[i+1]);
7034 break;
7035 }
7036 if (LocaleCompare("stroke",option+1) == 0)
7037 {
7038 if (*option == '+')
7039 {
7040 (void) SetImageOption(image_info,option+1,"none");
7041 break;
7042 }
7043 (void) SetImageOption(image_info,option+1,argv[i+1]);
7044 break;
7045 }
7046 if (LocaleCompare("strokewidth",option+1) == 0)
7047 {
7048 if (*option == '+')
7049 {
7050 (void) SetImageOption(image_info,option+1,"0");
7051 break;
7052 }
7053 (void) SetImageOption(image_info,option+1,argv[i+1]);
7054 break;
7055 }
cristyd9a29192010-10-16 16:49:53 +00007056 if (LocaleCompare("synchronize",option+1) == 0)
7057 {
7058 if (*option == '+')
7059 {
7060 image_info->synchronize=MagickFalse;
7061 break;
7062 }
7063 image_info->synchronize=MagickTrue;
7064 break;
7065 }
cristy3ed852e2009-09-05 21:47:34 +00007066 break;
7067 }
7068 case 't':
7069 {
7070 if (LocaleCompare("taint",option+1) == 0)
7071 {
7072 if (*option == '+')
7073 {
7074 (void) SetImageOption(image_info,option+1,"false");
7075 break;
7076 }
7077 (void) SetImageOption(image_info,option+1,"true");
7078 break;
7079 }
7080 if (LocaleCompare("texture",option+1) == 0)
7081 {
7082 if (*option == '+')
7083 {
7084 if (image_info->texture != (char *) NULL)
7085 image_info->texture=DestroyString(image_info->texture);
7086 break;
7087 }
7088 (void) CloneString(&image_info->texture,argv[i+1]);
7089 break;
7090 }
7091 if (LocaleCompare("tile-offset",option+1) == 0)
7092 {
7093 if (*option == '+')
7094 {
7095 (void) SetImageOption(image_info,option+1,"0");
7096 break;
7097 }
7098 (void) SetImageOption(image_info,option+1,argv[i+1]);
7099 break;
7100 }
7101 if (LocaleCompare("transparent-color",option+1) == 0)
7102 {
7103 if (*option == '+')
7104 {
cristy9950d572011-10-01 18:22:35 +00007105 (void) QueryColorCompliance("none",AllCompliance,
7106 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007107 (void) SetImageOption(image_info,option+1,"none");
7108 break;
7109 }
cristy9950d572011-10-01 18:22:35 +00007110 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7111 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007112 (void) SetImageOption(image_info,option+1,argv[i+1]);
7113 break;
7114 }
7115 if (LocaleCompare("type",option+1) == 0)
7116 {
7117 if (*option == '+')
7118 {
cristy5f1c1ff2010-12-23 21:38:06 +00007119 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007120 (void) SetImageOption(image_info,option+1,"undefined");
7121 break;
7122 }
cristy042ee782011-04-22 18:48:30 +00007123 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
cristy3ed852e2009-09-05 21:47:34 +00007124 MagickFalse,argv[i+1]);
7125 (void) SetImageOption(image_info,option+1,argv[i+1]);
7126 break;
7127 }
7128 break;
7129 }
7130 case 'u':
7131 {
7132 if (LocaleCompare("undercolor",option+1) == 0)
7133 {
7134 if (*option == '+')
7135 {
7136 (void) DeleteImageOption(image_info,option+1);
7137 break;
7138 }
7139 (void) SetImageOption(image_info,option+1,argv[i+1]);
7140 break;
7141 }
7142 if (LocaleCompare("units",option+1) == 0)
7143 {
7144 if (*option == '+')
7145 {
7146 image_info->units=UndefinedResolution;
7147 (void) SetImageOption(image_info,option+1,"undefined");
7148 break;
7149 }
cristy042ee782011-04-22 18:48:30 +00007150 image_info->units=(ResolutionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007151 MagickResolutionOptions,MagickFalse,argv[i+1]);
7152 (void) SetImageOption(image_info,option+1,argv[i+1]);
7153 break;
7154 }
7155 break;
7156 }
7157 case 'v':
7158 {
7159 if (LocaleCompare("verbose",option+1) == 0)
7160 {
7161 if (*option == '+')
7162 {
7163 image_info->verbose=MagickFalse;
7164 break;
7165 }
7166 image_info->verbose=MagickTrue;
7167 image_info->ping=MagickFalse;
7168 break;
7169 }
7170 if (LocaleCompare("view",option+1) == 0)
7171 {
7172 if (*option == '+')
7173 {
7174 if (image_info->view != (char *) NULL)
7175 image_info->view=DestroyString(image_info->view);
7176 break;
7177 }
7178 (void) CloneString(&image_info->view,argv[i+1]);
7179 break;
7180 }
7181 if (LocaleCompare("virtual-pixel",option+1) == 0)
7182 {
7183 if (*option == '+')
7184 {
7185 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7186 (void) SetImageOption(image_info,option+1,"undefined");
7187 break;
7188 }
7189 image_info->virtual_pixel_method=(VirtualPixelMethod)
cristy042ee782011-04-22 18:48:30 +00007190 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00007191 argv[i+1]);
7192 (void) SetImageOption(image_info,option+1,argv[i+1]);
7193 break;
7194 }
7195 break;
7196 }
7197 case 'w':
7198 {
7199 if (LocaleCompare("white-point",option+1) == 0)
7200 {
7201 if (*option == '+')
7202 {
7203 (void) SetImageOption(image_info,option+1,"0.0");
7204 break;
7205 }
7206 (void) SetImageOption(image_info,option+1,argv[i+1]);
7207 break;
7208 }
7209 break;
7210 }
7211 default:
7212 break;
7213 }
7214 i+=count;
7215 }
7216 return(MagickTrue);
7217}
7218
7219/*
7220%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7221% %
7222% %
7223% %
7224+ M o g r i f y I m a g e L i s t %
7225% %
7226% %
7227% %
7228%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7229%
7230% MogrifyImageList() applies any command line options that might affect the
7231% entire image list (e.g. -append, -coalesce, etc.).
7232%
7233% The format of the MogrifyImage method is:
7234%
7235% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7236% const char **argv,Image **images,ExceptionInfo *exception)
7237%
7238% A description of each parameter follows:
7239%
7240% o image_info: the image info..
7241%
7242% o argc: Specifies a pointer to an integer describing the number of
7243% elements in the argument vector.
7244%
7245% o argv: Specifies a pointer to a text array containing the command line
7246% arguments.
7247%
anthonye9c27192011-03-27 08:07:06 +00007248% o images: pointer to pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00007249%
7250% o exception: return any errors or warnings in this structure.
7251%
7252*/
7253WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7254 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7255{
cristy3ed852e2009-09-05 21:47:34 +00007256 const char
7257 *option;
7258
cristy6b3da3a2010-06-20 02:21:46 +00007259 ImageInfo
7260 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007261
7262 MagickStatusType
7263 status;
7264
cristy28474bf2011-09-11 23:32:52 +00007265 PixelInterpolateMethod
7266 interpolate_method;
7267
cristy3ed852e2009-09-05 21:47:34 +00007268 QuantizeInfo
7269 *quantize_info;
7270
cristybb503372010-05-27 20:51:26 +00007271 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007272 i;
7273
cristy6b3da3a2010-06-20 02:21:46 +00007274 ssize_t
7275 count,
7276 index;
7277
cristy3ed852e2009-09-05 21:47:34 +00007278 /*
7279 Apply options to the image list.
7280 */
7281 assert(image_info != (ImageInfo *) NULL);
7282 assert(image_info->signature == MagickSignature);
7283 assert(images != (Image **) NULL);
anthonye9c27192011-03-27 08:07:06 +00007284 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007285 assert((*images)->signature == MagickSignature);
7286 if ((*images)->debug != MagickFalse)
7287 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7288 (*images)->filename);
7289 if ((argc <= 0) || (*argv == (char *) NULL))
7290 return(MagickTrue);
cristy28474bf2011-09-11 23:32:52 +00007291 interpolate_method=UndefinedInterpolatePixel;
cristy6b3da3a2010-06-20 02:21:46 +00007292 mogrify_info=CloneImageInfo(image_info);
7293 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00007294 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007295 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007296 {
cristy74fe8f12009-10-03 19:09:01 +00007297 if (*images == (Image *) NULL)
7298 break;
cristy3ed852e2009-09-05 21:47:34 +00007299 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00007300 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00007301 continue;
cristy042ee782011-04-22 18:48:30 +00007302 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00007303 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00007304 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007305 break;
cristy6b3da3a2010-06-20 02:21:46 +00007306 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007307 switch (*(option+1))
7308 {
7309 case 'a':
7310 {
7311 if (LocaleCompare("affinity",option+1) == 0)
7312 {
cristy6b3da3a2010-06-20 02:21:46 +00007313 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007314 if (*option == '+')
7315 {
cristy018f07f2011-09-04 21:15:19 +00007316 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7317 exception);
cristy3ed852e2009-09-05 21:47:34 +00007318 break;
7319 }
7320 i++;
7321 break;
7322 }
7323 if (LocaleCompare("append",option+1) == 0)
7324 {
7325 Image
7326 *append_image;
7327
cristy6b3da3a2010-06-20 02:21:46 +00007328 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007329 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7330 MagickFalse,exception);
7331 if (append_image == (Image *) NULL)
7332 {
7333 status=MagickFalse;
7334 break;
7335 }
7336 *images=DestroyImageList(*images);
7337 *images=append_image;
7338 break;
7339 }
7340 if (LocaleCompare("average",option+1) == 0)
7341 {
7342 Image
7343 *average_image;
7344
cristyd18ae7c2010-03-07 17:39:52 +00007345 /*
7346 Average an image sequence (deprecated).
7347 */
cristy6b3da3a2010-06-20 02:21:46 +00007348 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007349 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7350 exception);
cristy3ed852e2009-09-05 21:47:34 +00007351 if (average_image == (Image *) NULL)
7352 {
7353 status=MagickFalse;
7354 break;
7355 }
7356 *images=DestroyImageList(*images);
7357 *images=average_image;
7358 break;
7359 }
7360 break;
7361 }
7362 case 'c':
7363 {
7364 if (LocaleCompare("channel",option+1) == 0)
7365 {
cristyf4ad9df2011-07-08 16:49:03 +00007366 ChannelType
7367 channel;
7368
cristy3ed852e2009-09-05 21:47:34 +00007369 if (*option == '+')
7370 {
7371 channel=DefaultChannels;
7372 break;
7373 }
7374 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00007375 SetPixelChannelMap(*images,channel);
cristy3ed852e2009-09-05 21:47:34 +00007376 break;
7377 }
7378 if (LocaleCompare("clut",option+1) == 0)
7379 {
7380 Image
7381 *clut_image,
7382 *image;
7383
cristy6b3da3a2010-06-20 02:21:46 +00007384 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007385 image=RemoveFirstImageFromList(images);
7386 clut_image=RemoveFirstImageFromList(images);
7387 if (clut_image == (Image *) NULL)
7388 {
7389 status=MagickFalse;
7390 break;
7391 }
cristy28474bf2011-09-11 23:32:52 +00007392 (void) ClutImage(image,clut_image,interpolate_method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007393 clut_image=DestroyImage(clut_image);
cristy3ed852e2009-09-05 21:47:34 +00007394 *images=DestroyImageList(*images);
7395 *images=image;
7396 break;
7397 }
7398 if (LocaleCompare("coalesce",option+1) == 0)
7399 {
7400 Image
7401 *coalesce_image;
7402
cristy6b3da3a2010-06-20 02:21:46 +00007403 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007404 coalesce_image=CoalesceImages(*images,exception);
7405 if (coalesce_image == (Image *) NULL)
7406 {
7407 status=MagickFalse;
7408 break;
7409 }
7410 *images=DestroyImageList(*images);
7411 *images=coalesce_image;
7412 break;
7413 }
7414 if (LocaleCompare("combine",option+1) == 0)
7415 {
7416 Image
7417 *combine_image;
7418
cristy6b3da3a2010-06-20 02:21:46 +00007419 (void) SyncImagesSettings(mogrify_info,*images);
cristy3139dc22011-07-08 00:11:42 +00007420 combine_image=CombineImages(*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007421 if (combine_image == (Image *) NULL)
7422 {
7423 status=MagickFalse;
7424 break;
7425 }
7426 *images=DestroyImageList(*images);
7427 *images=combine_image;
7428 break;
7429 }
7430 if (LocaleCompare("composite",option+1) == 0)
7431 {
7432 Image
7433 *mask_image,
7434 *composite_image,
7435 *image;
7436
7437 RectangleInfo
7438 geometry;
7439
cristy6b3da3a2010-06-20 02:21:46 +00007440 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007441 image=RemoveFirstImageFromList(images);
7442 composite_image=RemoveFirstImageFromList(images);
7443 if (composite_image == (Image *) NULL)
7444 {
7445 status=MagickFalse;
7446 break;
7447 }
7448 (void) TransformImage(&composite_image,(char *) NULL,
7449 composite_image->geometry);
7450 SetGeometry(composite_image,&geometry);
7451 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7452 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7453 &geometry);
7454 mask_image=RemoveFirstImageFromList(images);
7455 if (mask_image != (Image *) NULL)
7456 {
7457 if ((image->compose == DisplaceCompositeOp) ||
7458 (image->compose == DistortCompositeOp))
7459 {
7460 /*
7461 Merge Y displacement into X displacement image.
7462 */
7463 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7464 mask_image,0,0);
7465 mask_image=DestroyImage(mask_image);
7466 }
7467 else
7468 {
7469 /*
7470 Set a blending mask for the composition.
cristy28474bf2011-09-11 23:32:52 +00007471 Posible error, what if image->mask already set.
cristy3ed852e2009-09-05 21:47:34 +00007472 */
7473 image->mask=mask_image;
cristyb3e7c6c2011-07-24 01:43:55 +00007474 (void) NegateImage(image->mask,MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007475 }
7476 }
cristyf4ad9df2011-07-08 16:49:03 +00007477 (void) CompositeImage(image,image->compose,composite_image,
7478 geometry.x,geometry.y);
anthonya129f702011-04-14 01:08:48 +00007479 if (mask_image != (Image *) NULL)
7480 mask_image=image->mask=DestroyImage(image->mask);
cristy3ed852e2009-09-05 21:47:34 +00007481 composite_image=DestroyImage(composite_image);
7482 InheritException(exception,&image->exception);
7483 *images=DestroyImageList(*images);
7484 *images=image;
7485 break;
7486 }
cristy3ed852e2009-09-05 21:47:34 +00007487 break;
7488 }
7489 case 'd':
7490 {
7491 if (LocaleCompare("deconstruct",option+1) == 0)
7492 {
7493 Image
7494 *deconstruct_image;
7495
cristy6b3da3a2010-06-20 02:21:46 +00007496 (void) SyncImagesSettings(mogrify_info,*images);
cristy8a9106f2011-07-05 14:39:26 +00007497 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
cristy4c08aed2011-07-01 19:47:50 +00007498 exception);
cristy3ed852e2009-09-05 21:47:34 +00007499 if (deconstruct_image == (Image *) NULL)
7500 {
7501 status=MagickFalse;
7502 break;
7503 }
7504 *images=DestroyImageList(*images);
7505 *images=deconstruct_image;
7506 break;
7507 }
7508 if (LocaleCompare("delete",option+1) == 0)
7509 {
7510 if (*option == '+')
7511 DeleteImages(images,"-1",exception);
7512 else
7513 DeleteImages(images,argv[i+1],exception);
7514 break;
7515 }
7516 if (LocaleCompare("dither",option+1) == 0)
7517 {
7518 if (*option == '+')
7519 {
7520 quantize_info->dither=MagickFalse;
7521 break;
7522 }
7523 quantize_info->dither=MagickTrue;
cristy042ee782011-04-22 18:48:30 +00007524 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007525 MagickDitherOptions,MagickFalse,argv[i+1]);
7526 break;
7527 }
cristyecb10ff2011-03-22 13:14:03 +00007528 if (LocaleCompare("duplicate",option+1) == 0)
7529 {
cristy72988482011-03-29 16:34:38 +00007530 Image
7531 *duplicate_images;
cristybf95deb2011-03-23 00:25:36 +00007532
anthony2b6bcae2011-03-23 13:05:34 +00007533 if (*option == '+')
cristy72988482011-03-29 16:34:38 +00007534 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7535 else
7536 {
7537 const char
7538 *p;
7539
anthony2b6bcae2011-03-23 13:05:34 +00007540 size_t
7541 number_duplicates;
anthony9bd15492011-03-23 02:11:13 +00007542
anthony2b6bcae2011-03-23 13:05:34 +00007543 number_duplicates=(size_t) StringToLong(argv[i+1]);
cristy72988482011-03-29 16:34:38 +00007544 p=strchr(argv[i+1],',');
7545 if (p == (const char *) NULL)
7546 duplicate_images=DuplicateImages(*images,number_duplicates,
7547 "-1",exception);
anthony2b6bcae2011-03-23 13:05:34 +00007548 else
cristy72988482011-03-29 16:34:38 +00007549 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7550 exception);
anthony2b6bcae2011-03-23 13:05:34 +00007551 }
7552 AppendImageToList(images, duplicate_images);
7553 (void) SyncImagesSettings(mogrify_info,*images);
cristyecb10ff2011-03-22 13:14:03 +00007554 break;
7555 }
cristy3ed852e2009-09-05 21:47:34 +00007556 break;
7557 }
cristyd18ae7c2010-03-07 17:39:52 +00007558 case 'e':
7559 {
7560 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7561 {
7562 Image
7563 *evaluate_image;
7564
7565 MagickEvaluateOperator
7566 op;
7567
cristy6b3da3a2010-06-20 02:21:46 +00007568 (void) SyncImageSettings(mogrify_info,*images);
cristy28474bf2011-09-11 23:32:52 +00007569 op=(MagickEvaluateOperator) ParseCommandOption(
7570 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristyd18ae7c2010-03-07 17:39:52 +00007571 evaluate_image=EvaluateImages(*images,op,exception);
7572 if (evaluate_image == (Image *) NULL)
7573 {
7574 status=MagickFalse;
7575 break;
7576 }
7577 *images=DestroyImageList(*images);
7578 *images=evaluate_image;
7579 break;
7580 }
7581 break;
7582 }
cristy3ed852e2009-09-05 21:47:34 +00007583 case 'f':
7584 {
cristyf0a247f2009-10-04 00:20:03 +00007585 if (LocaleCompare("fft",option+1) == 0)
7586 {
7587 Image
7588 *fourier_image;
7589
7590 /*
7591 Implements the discrete Fourier transform (DFT).
7592 */
cristy6b3da3a2010-06-20 02:21:46 +00007593 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00007594 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7595 MagickTrue : MagickFalse,exception);
7596 if (fourier_image == (Image *) NULL)
7597 break;
7598 *images=DestroyImage(*images);
7599 *images=fourier_image;
7600 break;
7601 }
cristy3ed852e2009-09-05 21:47:34 +00007602 if (LocaleCompare("flatten",option+1) == 0)
7603 {
7604 Image
7605 *flatten_image;
7606
cristy6b3da3a2010-06-20 02:21:46 +00007607 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007608 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7609 if (flatten_image == (Image *) NULL)
7610 break;
7611 *images=DestroyImageList(*images);
7612 *images=flatten_image;
7613 break;
7614 }
7615 if (LocaleCompare("fx",option+1) == 0)
7616 {
7617 Image
7618 *fx_image;
7619
cristy6b3da3a2010-06-20 02:21:46 +00007620 (void) SyncImagesSettings(mogrify_info,*images);
cristy490408a2011-07-07 14:42:05 +00007621 fx_image=FxImage(*images,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00007622 if (fx_image == (Image *) NULL)
7623 {
7624 status=MagickFalse;
7625 break;
7626 }
7627 *images=DestroyImageList(*images);
7628 *images=fx_image;
7629 break;
7630 }
7631 break;
7632 }
7633 case 'h':
7634 {
7635 if (LocaleCompare("hald-clut",option+1) == 0)
7636 {
7637 Image
7638 *hald_image,
7639 *image;
7640
cristy6b3da3a2010-06-20 02:21:46 +00007641 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007642 image=RemoveFirstImageFromList(images);
7643 hald_image=RemoveFirstImageFromList(images);
7644 if (hald_image == (Image *) NULL)
7645 {
7646 status=MagickFalse;
7647 break;
7648 }
cristy7c0a0a42011-08-23 17:57:25 +00007649 (void) HaldClutImage(image,hald_image,exception);
cristy3ed852e2009-09-05 21:47:34 +00007650 hald_image=DestroyImage(hald_image);
cristy0aff6ea2009-11-14 01:40:53 +00007651 if (*images != (Image *) NULL)
7652 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00007653 *images=image;
7654 break;
7655 }
7656 break;
7657 }
7658 case 'i':
7659 {
7660 if (LocaleCompare("ift",option+1) == 0)
7661 {
7662 Image
cristy8587f882009-11-13 20:28:49 +00007663 *fourier_image,
7664 *magnitude_image,
7665 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00007666
7667 /*
7668 Implements the inverse fourier discrete Fourier transform (DFT).
7669 */
cristy6b3da3a2010-06-20 02:21:46 +00007670 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00007671 magnitude_image=RemoveFirstImageFromList(images);
7672 phase_image=RemoveFirstImageFromList(images);
7673 if (phase_image == (Image *) NULL)
7674 {
7675 status=MagickFalse;
7676 break;
7677 }
7678 fourier_image=InverseFourierTransformImage(magnitude_image,
7679 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007680 if (fourier_image == (Image *) NULL)
7681 break;
cristy0aff6ea2009-11-14 01:40:53 +00007682 if (*images != (Image *) NULL)
7683 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00007684 *images=fourier_image;
7685 break;
7686 }
7687 if (LocaleCompare("insert",option+1) == 0)
7688 {
7689 Image
7690 *p,
7691 *q;
7692
7693 index=0;
7694 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00007695 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007696 p=RemoveLastImageFromList(images);
7697 if (p == (Image *) NULL)
7698 {
7699 (void) ThrowMagickException(exception,GetMagickModule(),
7700 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7701 status=MagickFalse;
7702 break;
7703 }
7704 q=p;
7705 if (index == 0)
7706 PrependImageToList(images,q);
7707 else
cristybb503372010-05-27 20:51:26 +00007708 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00007709 AppendImageToList(images,q);
7710 else
7711 {
7712 q=GetImageFromList(*images,index-1);
7713 if (q == (Image *) NULL)
7714 {
7715 (void) ThrowMagickException(exception,GetMagickModule(),
7716 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7717 status=MagickFalse;
7718 break;
7719 }
7720 InsertImageInList(&q,p);
7721 }
7722 *images=GetFirstImageInList(q);
7723 break;
7724 }
cristy28474bf2011-09-11 23:32:52 +00007725 if (LocaleCompare("interpolate",option+1) == 0)
7726 {
7727 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7728 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7729 break;
7730 }
cristy3ed852e2009-09-05 21:47:34 +00007731 break;
7732 }
7733 case 'l':
7734 {
7735 if (LocaleCompare("layers",option+1) == 0)
7736 {
7737 Image
7738 *layers;
7739
7740 ImageLayerMethod
7741 method;
7742
cristy6b3da3a2010-06-20 02:21:46 +00007743 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007744 layers=(Image *) NULL;
cristy042ee782011-04-22 18:48:30 +00007745 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
cristy3ed852e2009-09-05 21:47:34 +00007746 MagickFalse,argv[i+1]);
7747 switch (method)
7748 {
7749 case CoalesceLayer:
7750 {
7751 layers=CoalesceImages(*images,exception);
7752 break;
7753 }
7754 case CompareAnyLayer:
7755 case CompareClearLayer:
7756 case CompareOverlayLayer:
7757 default:
7758 {
cristy8a9106f2011-07-05 14:39:26 +00007759 layers=CompareImagesLayers(*images,method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007760 break;
7761 }
7762 case MergeLayer:
7763 case FlattenLayer:
7764 case MosaicLayer:
7765 case TrimBoundsLayer:
7766 {
7767 layers=MergeImageLayers(*images,method,exception);
7768 break;
7769 }
7770 case DisposeLayer:
7771 {
7772 layers=DisposeImages(*images,exception);
7773 break;
7774 }
7775 case OptimizeImageLayer:
7776 {
7777 layers=OptimizeImageLayers(*images,exception);
7778 break;
7779 }
7780 case OptimizePlusLayer:
7781 {
7782 layers=OptimizePlusImageLayers(*images,exception);
7783 break;
7784 }
7785 case OptimizeTransLayer:
7786 {
7787 OptimizeImageTransparency(*images,exception);
7788 break;
7789 }
7790 case RemoveDupsLayer:
7791 {
7792 RemoveDuplicateLayers(images,exception);
7793 break;
7794 }
7795 case RemoveZeroLayer:
7796 {
7797 RemoveZeroDelayLayers(images,exception);
7798 break;
7799 }
7800 case OptimizeLayer:
7801 {
7802 /*
7803 General Purpose, GIF Animation Optimizer.
7804 */
7805 layers=CoalesceImages(*images,exception);
7806 if (layers == (Image *) NULL)
7807 {
7808 status=MagickFalse;
7809 break;
7810 }
cristy3ed852e2009-09-05 21:47:34 +00007811 *images=DestroyImageList(*images);
7812 *images=layers;
7813 layers=OptimizeImageLayers(*images,exception);
7814 if (layers == (Image *) NULL)
7815 {
7816 status=MagickFalse;
7817 break;
7818 }
cristy3ed852e2009-09-05 21:47:34 +00007819 *images=DestroyImageList(*images);
7820 *images=layers;
7821 layers=(Image *) NULL;
7822 OptimizeImageTransparency(*images,exception);
cristy018f07f2011-09-04 21:15:19 +00007823 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7824 exception);
cristy3ed852e2009-09-05 21:47:34 +00007825 break;
7826 }
7827 case CompositeLayer:
7828 {
7829 CompositeOperator
7830 compose;
7831
7832 Image
7833 *source;
7834
7835 RectangleInfo
7836 geometry;
7837
7838 /*
7839 Split image sequence at the first 'NULL:' image.
7840 */
7841 source=(*images);
7842 while (source != (Image *) NULL)
7843 {
7844 source=GetNextImageInList(source);
7845 if ((source != (Image *) NULL) &&
7846 (LocaleCompare(source->magick,"NULL") == 0))
7847 break;
7848 }
7849 if (source != (Image *) NULL)
7850 {
7851 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7852 (GetNextImageInList(source) == (Image *) NULL))
7853 source=(Image *) NULL;
7854 else
7855 {
7856 /*
7857 Separate the two lists, junk the null: image.
7858 */
7859 source=SplitImageList(source->previous);
7860 DeleteImageFromList(&source);
7861 }
7862 }
7863 if (source == (Image *) NULL)
7864 {
7865 (void) ThrowMagickException(exception,GetMagickModule(),
7866 OptionError,"MissingNullSeparator","layers Composite");
7867 status=MagickFalse;
7868 break;
7869 }
7870 /*
7871 Adjust offset with gravity and virtual canvas.
7872 */
7873 SetGeometry(*images,&geometry);
7874 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7875 geometry.width=source->page.width != 0 ?
7876 source->page.width : source->columns;
7877 geometry.height=source->page.height != 0 ?
7878 source->page.height : source->rows;
7879 GravityAdjustGeometry((*images)->page.width != 0 ?
7880 (*images)->page.width : (*images)->columns,
7881 (*images)->page.height != 0 ? (*images)->page.height :
7882 (*images)->rows,(*images)->gravity,&geometry);
7883 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00007884 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00007885 if (option != (const char *) NULL)
cristy042ee782011-04-22 18:48:30 +00007886 compose=(CompositeOperator) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007887 MagickComposeOptions,MagickFalse,option);
7888 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7889 exception);
7890 source=DestroyImageList(source);
7891 break;
7892 }
7893 }
7894 if (layers == (Image *) NULL)
7895 break;
7896 InheritException(exception,&layers->exception);
7897 *images=DestroyImageList(*images);
7898 *images=layers;
7899 break;
7900 }
7901 break;
7902 }
7903 case 'm':
7904 {
7905 if (LocaleCompare("map",option+1) == 0)
7906 {
cristy6b3da3a2010-06-20 02:21:46 +00007907 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007908 if (*option == '+')
7909 {
cristy018f07f2011-09-04 21:15:19 +00007910 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7911 exception);
cristy3ed852e2009-09-05 21:47:34 +00007912 break;
7913 }
7914 i++;
7915 break;
7916 }
cristyf40785b2010-03-06 02:27:27 +00007917 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007918 {
7919 Image
cristyf40785b2010-03-06 02:27:27 +00007920 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007921
cristyd18ae7c2010-03-07 17:39:52 +00007922 /*
7923 Maximum image sequence (deprecated).
7924 */
cristy6b3da3a2010-06-20 02:21:46 +00007925 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007926 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007927 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007928 {
7929 status=MagickFalse;
7930 break;
7931 }
7932 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007933 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007934 break;
7935 }
cristyf40785b2010-03-06 02:27:27 +00007936 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007937 {
7938 Image
cristyf40785b2010-03-06 02:27:27 +00007939 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007940
cristyd18ae7c2010-03-07 17:39:52 +00007941 /*
7942 Minimum image sequence (deprecated).
7943 */
cristy6b3da3a2010-06-20 02:21:46 +00007944 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007945 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007946 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007947 {
7948 status=MagickFalse;
7949 break;
7950 }
7951 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007952 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007953 break;
7954 }
cristy3ed852e2009-09-05 21:47:34 +00007955 if (LocaleCompare("morph",option+1) == 0)
7956 {
7957 Image
7958 *morph_image;
7959
cristy6b3da3a2010-06-20 02:21:46 +00007960 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00007961 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00007962 exception);
7963 if (morph_image == (Image *) NULL)
7964 {
7965 status=MagickFalse;
7966 break;
7967 }
7968 *images=DestroyImageList(*images);
7969 *images=morph_image;
7970 break;
7971 }
7972 if (LocaleCompare("mosaic",option+1) == 0)
7973 {
7974 Image
7975 *mosaic_image;
7976
cristy6b3da3a2010-06-20 02:21:46 +00007977 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007978 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7979 if (mosaic_image == (Image *) NULL)
7980 {
7981 status=MagickFalse;
7982 break;
7983 }
7984 *images=DestroyImageList(*images);
7985 *images=mosaic_image;
7986 break;
7987 }
7988 break;
7989 }
7990 case 'p':
7991 {
7992 if (LocaleCompare("print",option+1) == 0)
7993 {
7994 char
7995 *string;
7996
cristy6b3da3a2010-06-20 02:21:46 +00007997 (void) SyncImagesSettings(mogrify_info,*images);
cristy018f07f2011-09-04 21:15:19 +00007998 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7999 exception);
cristy3ed852e2009-09-05 21:47:34 +00008000 if (string == (char *) NULL)
8001 break;
cristyb51dff52011-05-19 16:55:47 +00008002 (void) FormatLocaleFile(stdout,"%s",string);
cristy3ed852e2009-09-05 21:47:34 +00008003 string=DestroyString(string);
8004 }
8005 if (LocaleCompare("process",option+1) == 0)
8006 {
8007 char
8008 **arguments;
8009
8010 int
8011 j,
8012 number_arguments;
8013
cristy6b3da3a2010-06-20 02:21:46 +00008014 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008015 arguments=StringToArgv(argv[i+1],&number_arguments);
8016 if (arguments == (char **) NULL)
8017 break;
8018 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8019 {
8020 char
8021 breaker,
8022 quote,
8023 *token;
8024
8025 const char
8026 *arguments;
8027
8028 int
8029 next,
8030 status;
8031
8032 size_t
8033 length;
8034
8035 TokenInfo
8036 *token_info;
8037
8038 /*
8039 Support old style syntax, filter="-option arg".
8040 */
8041 length=strlen(argv[i+1]);
8042 token=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +00008043 if (~length >= (MaxTextExtent-1))
cristy3ed852e2009-09-05 21:47:34 +00008044 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8045 sizeof(*token));
8046 if (token == (char *) NULL)
8047 break;
8048 next=0;
8049 arguments=argv[i+1];
8050 token_info=AcquireTokenInfo();
8051 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8052 "\"",'\0',&breaker,&next,&quote);
8053 token_info=DestroyTokenInfo(token_info);
8054 if (status == 0)
8055 {
8056 const char
8057 *argv;
8058
8059 argv=(&(arguments[next]));
8060 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8061 exception);
8062 }
8063 token=DestroyString(token);
8064 break;
8065 }
cristy91c0da22010-05-02 01:44:07 +00008066 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008067 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8068 number_arguments-2,(const char **) arguments+2,exception);
8069 for (j=0; j < number_arguments; j++)
8070 arguments[j]=DestroyString(arguments[j]);
8071 arguments=(char **) RelinquishMagickMemory(arguments);
8072 break;
8073 }
8074 break;
8075 }
8076 case 'r':
8077 {
8078 if (LocaleCompare("reverse",option+1) == 0)
8079 {
8080 ReverseImageList(images);
8081 InheritException(exception,&(*images)->exception);
8082 break;
8083 }
8084 break;
8085 }
8086 case 's':
8087 {
cristy4285d782011-02-09 20:12:28 +00008088 if (LocaleCompare("smush",option+1) == 0)
8089 {
8090 Image
8091 *smush_image;
8092
8093 ssize_t
8094 offset;
8095
8096 (void) SyncImagesSettings(mogrify_info,*images);
8097 offset=(ssize_t) StringToLong(argv[i+1]);
8098 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8099 MagickFalse,offset,exception);
8100 if (smush_image == (Image *) NULL)
8101 {
8102 status=MagickFalse;
8103 break;
8104 }
8105 *images=DestroyImageList(*images);
8106 *images=smush_image;
8107 break;
8108 }
cristy3ed852e2009-09-05 21:47:34 +00008109 if (LocaleCompare("swap",option+1) == 0)
8110 {
8111 Image
8112 *p,
8113 *q,
8114 *swap;
8115
cristybb503372010-05-27 20:51:26 +00008116 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008117 swap_index;
8118
8119 index=(-1);
8120 swap_index=(-2);
8121 if (*option != '+')
8122 {
8123 GeometryInfo
8124 geometry_info;
8125
8126 MagickStatusType
8127 flags;
8128
8129 swap_index=(-1);
8130 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008131 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008132 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008133 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008134 }
8135 p=GetImageFromList(*images,index);
8136 q=GetImageFromList(*images,swap_index);
8137 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8138 {
8139 (void) ThrowMagickException(exception,GetMagickModule(),
8140 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8141 status=MagickFalse;
8142 break;
8143 }
8144 if (p == q)
8145 break;
8146 swap=CloneImage(p,0,0,MagickTrue,exception);
8147 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8148 ReplaceImageInList(&q,swap);
8149 *images=GetFirstImageInList(q);
8150 break;
8151 }
8152 break;
8153 }
8154 case 'w':
8155 {
8156 if (LocaleCompare("write",option+1) == 0)
8157 {
cristy071dd7b2010-04-09 13:04:54 +00008158 char
cristy06609ee2010-03-17 20:21:27 +00008159 key[MaxTextExtent];
8160
cristy3ed852e2009-09-05 21:47:34 +00008161 Image
8162 *write_images;
8163
8164 ImageInfo
8165 *write_info;
8166
cristy6b3da3a2010-06-20 02:21:46 +00008167 (void) SyncImagesSettings(mogrify_info,*images);
cristyb51dff52011-05-19 16:55:47 +00008168 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
cristy06609ee2010-03-17 20:21:27 +00008169 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008170 write_images=(*images);
8171 if (*option == '+')
8172 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008173 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008174 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8175 write_info=DestroyImageInfo(write_info);
8176 if (*option == '+')
8177 write_images=DestroyImageList(write_images);
8178 break;
8179 }
8180 break;
8181 }
8182 default:
8183 break;
8184 }
8185 i+=count;
8186 }
8187 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008188 mogrify_info=DestroyImageInfo(mogrify_info);
8189 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008190 return(status != 0 ? MagickTrue : MagickFalse);
8191}
8192
8193/*
8194%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8195% %
8196% %
8197% %
8198+ M o g r i f y I m a g e s %
8199% %
8200% %
8201% %
8202%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8203%
8204% MogrifyImages() applies image processing options to a sequence of images as
8205% prescribed by command line options.
8206%
8207% The format of the MogrifyImage method is:
8208%
8209% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8210% const MagickBooleanType post,const int argc,const char **argv,
8211% Image **images,Exceptioninfo *exception)
8212%
8213% A description of each parameter follows:
8214%
8215% o image_info: the image info..
8216%
8217% o post: If true, post process image list operators otherwise pre-process.
8218%
8219% o argc: Specifies a pointer to an integer describing the number of
8220% elements in the argument vector.
8221%
8222% o argv: Specifies a pointer to a text array containing the command line
8223% arguments.
8224%
anthonye9c27192011-03-27 08:07:06 +00008225% o images: pointer to a pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00008226%
8227% o exception: return any errors or warnings in this structure.
8228%
8229*/
8230WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8231 const MagickBooleanType post,const int argc,const char **argv,
8232 Image **images,ExceptionInfo *exception)
8233{
8234#define MogrifyImageTag "Mogrify/Image"
8235
anthonye9c27192011-03-27 08:07:06 +00008236 MagickStatusType
8237 status;
cristy3ed852e2009-09-05 21:47:34 +00008238
cristy0e9f9c12010-02-11 03:00:47 +00008239 MagickBooleanType
8240 proceed;
8241
anthonye9c27192011-03-27 08:07:06 +00008242 size_t
8243 n;
cristy3ed852e2009-09-05 21:47:34 +00008244
cristybb503372010-05-27 20:51:26 +00008245 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008246 i;
8247
cristy3ed852e2009-09-05 21:47:34 +00008248 assert(image_info != (ImageInfo *) NULL);
8249 assert(image_info->signature == MagickSignature);
8250 if (images == (Image **) NULL)
8251 return(MogrifyImage(image_info,argc,argv,images,exception));
anthonye9c27192011-03-27 08:07:06 +00008252 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008253 assert((*images)->signature == MagickSignature);
8254 if ((*images)->debug != MagickFalse)
8255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8256 (*images)->filename);
8257 if ((argc <= 0) || (*argv == (char *) NULL))
8258 return(MagickTrue);
8259 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8260 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008261 status=0;
anthonye9c27192011-03-27 08:07:06 +00008262
anthonyce2716b2011-04-22 09:51:34 +00008263#if 0
cristy1e604812011-05-19 18:07:50 +00008264 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8265 post?"post":"pre");
anthonyce2716b2011-04-22 09:51:34 +00008266#endif
8267
anthonye9c27192011-03-27 08:07:06 +00008268 /*
8269 Pre-process multi-image sequence operators
8270 */
cristy3ed852e2009-09-05 21:47:34 +00008271 if (post == MagickFalse)
8272 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthonye9c27192011-03-27 08:07:06 +00008273 /*
8274 For each image, process simple single image operators
8275 */
8276 i=0;
8277 n=GetImageListLength(*images);
cristy9f027d12011-09-21 01:17:17 +00008278 for ( ; ; )
cristy3ed852e2009-09-05 21:47:34 +00008279 {
anthonyce2716b2011-04-22 09:51:34 +00008280#if 0
cristy1e604812011-05-19 18:07:50 +00008281 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8282 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008283#endif
anthonye9c27192011-03-27 08:07:06 +00008284 status&=MogrifyImage(image_info,argc,argv,images,exception);
8285 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
cristy0e9f9c12010-02-11 03:00:47 +00008286 if (proceed == MagickFalse)
8287 break;
anthonye9c27192011-03-27 08:07:06 +00008288 if ( (*images)->next == (Image *) NULL )
8289 break;
8290 *images=(*images)->next;
8291 i++;
cristy3ed852e2009-09-05 21:47:34 +00008292 }
anthonye9c27192011-03-27 08:07:06 +00008293 assert( *images != (Image *) NULL );
anthonyce2716b2011-04-22 09:51:34 +00008294#if 0
cristy1e604812011-05-19 18:07:50 +00008295 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8296 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008297#endif
anthonye9c27192011-03-27 08:07:06 +00008298
8299 /*
8300 Post-process, multi-image sequence operators
8301 */
8302 *images=GetFirstImageInList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008303 if (post != MagickFalse)
anthonye9c27192011-03-27 08:07:06 +00008304 status&=MogrifyImageList(image_info,argc,argv,images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008305 return(status != 0 ? MagickTrue : MagickFalse);
8306}