blob: ef122d9e8ab3a216dd3b80da4973822a76b93a97 [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 break;
907 }
908 if (LocaleCompare("blue-shift",option+1) == 0)
909 {
910 /*
911 Blue shift image.
912 */
913 (void) SyncImageSettings(mogrify_info,*image);
914 geometry_info.rho=1.5;
915 if (*option == '-')
916 flags=ParseGeometry(argv[i+1],&geometry_info);
917 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
918 break;
919 }
920 if (LocaleCompare("blur",option+1) == 0)
921 {
922 /*
923 Gaussian blur image.
924 */
925 (void) SyncImageSettings(mogrify_info,*image);
926 flags=ParseGeometry(argv[i+1],&geometry_info);
927 if ((flags & SigmaValue) == 0)
928 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000929 if ((flags & XiValue) == 0)
930 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000931 mogrify_image=BlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +0000932 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000933 break;
934 }
935 if (LocaleCompare("border",option+1) == 0)
936 {
937 /*
938 Surround image with a border of solid color.
939 */
940 (void) SyncImageSettings(mogrify_info,*image);
941 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
942 if ((flags & SigmaValue) == 0)
943 geometry.height=geometry.width;
cristy633f0c62011-09-15 13:27:36 +0000944 mogrify_image=BorderImage(*image,&geometry,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000945 break;
946 }
947 if (LocaleCompare("bordercolor",option+1) == 0)
948 {
949 if (*option == '+')
950 {
cristy9950d572011-10-01 18:22:35 +0000951 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy05c0c9a2011-09-05 23:16:13 +0000952 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000953 break;
954 }
cristy9950d572011-10-01 18:22:35 +0000955 (void) QueryColorCompliance(argv[i+1],AllCompliance,
956 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000957 break;
958 }
959 if (LocaleCompare("box",option+1) == 0)
960 {
cristy9950d572011-10-01 18:22:35 +0000961 (void) QueryColorCompliance(argv[i+1],AllCompliance,
962 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000963 break;
964 }
965 if (LocaleCompare("brightness-contrast",option+1) == 0)
966 {
967 double
968 brightness,
969 contrast;
970
971 GeometryInfo
972 geometry_info;
973
974 MagickStatusType
975 flags;
976
977 /*
978 Brightness / contrast image.
979 */
980 (void) SyncImageSettings(mogrify_info,*image);
981 flags=ParseGeometry(argv[i+1],&geometry_info);
982 brightness=geometry_info.rho;
983 contrast=0.0;
984 if ((flags & SigmaValue) != 0)
985 contrast=geometry_info.sigma;
cristy444eda62011-08-10 02:07:46 +0000986 (void) BrightnessContrastImage(*image,brightness,contrast,
987 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000988 break;
989 }
990 break;
991 }
992 case 'c':
993 {
994 if (LocaleCompare("cdl",option+1) == 0)
995 {
996 char
997 *color_correction_collection;
998
999 /*
1000 Color correct with a color decision list.
1001 */
1002 (void) SyncImageSettings(mogrify_info,*image);
1003 color_correction_collection=FileToString(argv[i+1],~0,exception);
1004 if (color_correction_collection == (char *) NULL)
1005 break;
cristy1bfa9f02011-08-11 02:35:43 +00001006 (void) ColorDecisionListImage(*image,color_correction_collection,
1007 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001008 break;
1009 }
1010 if (LocaleCompare("channel",option+1) == 0)
1011 {
1012 if (*option == '+')
cristyfa806a72011-07-04 02:06:13 +00001013 channel=DefaultChannels;
anthonydf8ebac2011-04-27 09:03:19 +00001014 else
cristyfa806a72011-07-04 02:06:13 +00001015 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00001016 SetPixelChannelMap(*image,channel);
anthonydf8ebac2011-04-27 09:03:19 +00001017 break;
1018 }
1019 if (LocaleCompare("charcoal",option+1) == 0)
1020 {
1021 /*
1022 Charcoal image.
1023 */
1024 (void) SyncImageSettings(mogrify_info,*image);
1025 flags=ParseGeometry(argv[i+1],&geometry_info);
1026 if ((flags & SigmaValue) == 0)
1027 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001028 if ((flags & XiValue) == 0)
1029 geometry_info.xi=1.0;
anthonydf8ebac2011-04-27 09:03:19 +00001030 mogrify_image=CharcoalImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001031 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001032 break;
1033 }
1034 if (LocaleCompare("chop",option+1) == 0)
1035 {
1036 /*
1037 Chop the image.
1038 */
1039 (void) SyncImageSettings(mogrify_info,*image);
1040 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1041 mogrify_image=ChopImage(*image,&geometry,exception);
1042 break;
1043 }
1044 if (LocaleCompare("clamp",option+1) == 0)
1045 {
1046 /*
1047 Clamp image.
1048 */
1049 (void) SyncImageSettings(mogrify_info,*image);
cristy092d71c2011-10-14 18:01:29 +00001050 (void) ClampImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001051 break;
1052 }
1053 if (LocaleCompare("clip",option+1) == 0)
1054 {
1055 (void) SyncImageSettings(mogrify_info,*image);
1056 if (*option == '+')
1057 {
cristy018f07f2011-09-04 21:15:19 +00001058 (void) SetImageClipMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001059 break;
1060 }
cristy018f07f2011-09-04 21:15:19 +00001061 (void) ClipImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001062 break;
1063 }
1064 if (LocaleCompare("clip-mask",option+1) == 0)
1065 {
1066 CacheView
1067 *mask_view;
1068
1069 Image
1070 *mask_image;
1071
cristy4c08aed2011-07-01 19:47:50 +00001072 register Quantum
anthonydf8ebac2011-04-27 09:03:19 +00001073 *restrict q;
1074
1075 register ssize_t
1076 x;
1077
1078 ssize_t
1079 y;
1080
1081 (void) SyncImageSettings(mogrify_info,*image);
1082 if (*option == '+')
1083 {
1084 /*
1085 Remove a mask.
1086 */
cristy018f07f2011-09-04 21:15:19 +00001087 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001088 break;
1089 }
1090 /*
1091 Set the image mask.
1092 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1093 */
1094 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1095 if (mask_image == (Image *) NULL)
1096 break;
cristy574cc262011-08-05 01:23:58 +00001097 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
anthonydf8ebac2011-04-27 09:03:19 +00001098 return(MagickFalse);
1099 mask_view=AcquireCacheView(mask_image);
1100 for (y=0; y < (ssize_t) mask_image->rows; y++)
1101 {
1102 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1103 exception);
cristyacd2ed22011-08-30 01:44:23 +00001104 if (q == (Quantum *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001105 break;
1106 for (x=0; x < (ssize_t) mask_image->columns; x++)
1107 {
1108 if (mask_image->matte == MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +00001109 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1110 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1111 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1112 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
cristyed231572011-07-14 02:18:59 +00001113 q+=GetPixelChannels(mask_image);
anthonydf8ebac2011-04-27 09:03:19 +00001114 }
1115 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1116 break;
1117 }
1118 mask_view=DestroyCacheView(mask_view);
1119 mask_image->matte=MagickTrue;
cristy018f07f2011-09-04 21:15:19 +00001120 (void) SetImageClipMask(*image,mask_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001121 break;
1122 }
1123 if (LocaleCompare("clip-path",option+1) == 0)
1124 {
1125 (void) SyncImageSettings(mogrify_info,*image);
1126 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
cristy018f07f2011-09-04 21:15:19 +00001127 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001128 break;
1129 }
1130 if (LocaleCompare("colorize",option+1) == 0)
1131 {
1132 /*
1133 Colorize the image.
1134 */
1135 (void) SyncImageSettings(mogrify_info,*image);
cristyc7e6ff62011-10-03 13:46:11 +00001136 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001137 break;
1138 }
1139 if (LocaleCompare("color-matrix",option+1) == 0)
1140 {
1141 KernelInfo
1142 *kernel;
1143
1144 (void) SyncImageSettings(mogrify_info,*image);
1145 kernel=AcquireKernelInfo(argv[i+1]);
1146 if (kernel == (KernelInfo *) NULL)
1147 break;
1148 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1149 kernel=DestroyKernelInfo(kernel);
1150 break;
1151 }
1152 if (LocaleCompare("colors",option+1) == 0)
1153 {
1154 /*
1155 Reduce the number of colors in the image.
1156 */
1157 (void) SyncImageSettings(mogrify_info,*image);
1158 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1159 if (quantize_info->number_colors == 0)
1160 break;
1161 if (((*image)->storage_class == DirectClass) ||
1162 (*image)->colors > quantize_info->number_colors)
cristy018f07f2011-09-04 21:15:19 +00001163 (void) QuantizeImage(quantize_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001164 else
cristy018f07f2011-09-04 21:15:19 +00001165 (void) CompressImageColormap(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001166 break;
1167 }
1168 if (LocaleCompare("colorspace",option+1) == 0)
1169 {
1170 ColorspaceType
1171 colorspace;
1172
1173 (void) SyncImageSettings(mogrify_info,*image);
1174 if (*option == '+')
1175 {
cristye941a752011-10-15 01:52:48 +00001176 (void) TransformImageColorspace(*image,RGBColorspace,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001177 break;
1178 }
1179 colorspace=(ColorspaceType) ParseCommandOption(
1180 MagickColorspaceOptions,MagickFalse,argv[i+1]);
cristye941a752011-10-15 01:52:48 +00001181 (void) TransformImageColorspace(*image,colorspace,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001182 break;
1183 }
cristy633f0c62011-09-15 13:27:36 +00001184 if (LocaleCompare("compose",option+1) == 0)
1185 {
1186 (void) SyncImageSettings(mogrify_info,*image);
1187 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1188 MagickFalse,argv[i+1]);
1189 break;
1190 }
anthonydf8ebac2011-04-27 09:03:19 +00001191 if (LocaleCompare("contrast",option+1) == 0)
1192 {
1193 (void) SyncImageSettings(mogrify_info,*image);
1194 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
cristye23ec9d2011-08-16 18:15:40 +00001195 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001196 break;
1197 }
1198 if (LocaleCompare("contrast-stretch",option+1) == 0)
1199 {
1200 double
1201 black_point,
1202 white_point;
1203
1204 MagickStatusType
1205 flags;
1206
1207 /*
1208 Contrast stretch image.
1209 */
1210 (void) SyncImageSettings(mogrify_info,*image);
1211 flags=ParseGeometry(argv[i+1],&geometry_info);
1212 black_point=geometry_info.rho;
1213 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1214 black_point;
1215 if ((flags & PercentValue) != 0)
1216 {
1217 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1218 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1219 }
1220 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1221 white_point;
cristye23ec9d2011-08-16 18:15:40 +00001222 (void) ContrastStretchImage(*image,black_point,white_point,
1223 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001224 break;
1225 }
1226 if (LocaleCompare("convolve",option+1) == 0)
1227 {
anthonydf8ebac2011-04-27 09:03:19 +00001228 KernelInfo
cristy41cbe682011-07-15 19:12:37 +00001229 *kernel_info;
anthonydf8ebac2011-04-27 09:03:19 +00001230
anthonydf8ebac2011-04-27 09:03:19 +00001231 (void) SyncImageSettings(mogrify_info,*image);
cristy41cbe682011-07-15 19:12:37 +00001232 kernel_info=AcquireKernelInfo(argv[i+1]);
1233 if (kernel_info == (KernelInfo *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001234 break;
cristy0a922382011-07-16 15:30:34 +00001235 kernel_info->bias=(*image)->bias;
cristy5e6be1e2011-07-16 01:23:39 +00001236 mogrify_image=ConvolveImage(*image,kernel_info,exception);
cristy41cbe682011-07-15 19:12:37 +00001237 kernel_info=DestroyKernelInfo(kernel_info);
anthonydf8ebac2011-04-27 09:03:19 +00001238 break;
1239 }
1240 if (LocaleCompare("crop",option+1) == 0)
1241 {
1242 /*
1243 Crop a image to a smaller size
1244 */
1245 (void) SyncImageSettings(mogrify_info,*image);
anthonydf8ebac2011-04-27 09:03:19 +00001246 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00001247 break;
1248 }
1249 if (LocaleCompare("cycle",option+1) == 0)
1250 {
1251 /*
1252 Cycle an image colormap.
1253 */
1254 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00001255 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1256 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001257 break;
1258 }
1259 break;
1260 }
1261 case 'd':
1262 {
1263 if (LocaleCompare("decipher",option+1) == 0)
1264 {
1265 StringInfo
1266 *passkey;
1267
1268 /*
1269 Decipher pixels.
1270 */
1271 (void) SyncImageSettings(mogrify_info,*image);
1272 passkey=FileToStringInfo(argv[i+1],~0,exception);
1273 if (passkey != (StringInfo *) NULL)
1274 {
1275 (void) PasskeyDecipherImage(*image,passkey,exception);
1276 passkey=DestroyStringInfo(passkey);
1277 }
1278 break;
1279 }
1280 if (LocaleCompare("density",option+1) == 0)
1281 {
1282 /*
1283 Set image density.
1284 */
1285 (void) CloneString(&draw_info->density,argv[i+1]);
1286 break;
1287 }
1288 if (LocaleCompare("depth",option+1) == 0)
1289 {
1290 (void) SyncImageSettings(mogrify_info,*image);
1291 if (*option == '+')
1292 {
1293 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1294 break;
1295 }
1296 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1297 break;
1298 }
1299 if (LocaleCompare("deskew",option+1) == 0)
1300 {
1301 double
1302 threshold;
1303
1304 /*
1305 Straighten the image.
1306 */
1307 (void) SyncImageSettings(mogrify_info,*image);
1308 if (*option == '+')
1309 threshold=40.0*QuantumRange/100.0;
1310 else
1311 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1312 mogrify_image=DeskewImage(*image,threshold,exception);
1313 break;
1314 }
1315 if (LocaleCompare("despeckle",option+1) == 0)
1316 {
1317 /*
1318 Reduce the speckles within an image.
1319 */
1320 (void) SyncImageSettings(mogrify_info,*image);
1321 mogrify_image=DespeckleImage(*image,exception);
1322 break;
1323 }
1324 if (LocaleCompare("display",option+1) == 0)
1325 {
1326 (void) CloneString(&draw_info->server_name,argv[i+1]);
1327 break;
1328 }
1329 if (LocaleCompare("distort",option+1) == 0)
1330 {
1331 char
1332 *args,
1333 token[MaxTextExtent];
1334
1335 const char
1336 *p;
1337
1338 DistortImageMethod
1339 method;
1340
1341 double
1342 *arguments;
1343
1344 register ssize_t
1345 x;
1346
1347 size_t
1348 number_arguments;
1349
1350 /*
1351 Distort image.
1352 */
1353 (void) SyncImageSettings(mogrify_info,*image);
1354 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1355 MagickFalse,argv[i+1]);
1356 if ( method == ResizeDistortion )
1357 {
1358 /* Special Case - Argument is actually a resize geometry!
1359 ** Convert that to an appropriate distortion argument array.
1360 */
1361 double
1362 resize_args[2];
1363 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1364 exception);
1365 resize_args[0]=(double)geometry.width;
1366 resize_args[1]=(double)geometry.height;
1367 mogrify_image=DistortImage(*image,method,(size_t)2,
1368 resize_args,MagickTrue,exception);
1369 break;
1370 }
cristy018f07f2011-09-04 21:15:19 +00001371 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1372 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001373 if (args == (char *) NULL)
1374 break;
1375 p=(char *) args;
1376 for (x=0; *p != '\0'; x++)
1377 {
1378 GetMagickToken(p,&p,token);
1379 if (*token == ',')
1380 GetMagickToken(p,&p,token);
1381 }
1382 number_arguments=(size_t) x;
1383 arguments=(double *) AcquireQuantumMemory(number_arguments,
1384 sizeof(*arguments));
1385 if (arguments == (double *) NULL)
1386 ThrowWandFatalException(ResourceLimitFatalError,
1387 "MemoryAllocationFailed",(*image)->filename);
1388 (void) ResetMagickMemory(arguments,0,number_arguments*
1389 sizeof(*arguments));
1390 p=(char *) args;
1391 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1392 {
1393 GetMagickToken(p,&p,token);
1394 if (*token == ',')
1395 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001396 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001397 }
1398 args=DestroyString(args);
1399 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1400 (*option == '+') ? MagickTrue : MagickFalse,exception);
1401 arguments=(double *) RelinquishMagickMemory(arguments);
1402 break;
1403 }
1404 if (LocaleCompare("dither",option+1) == 0)
1405 {
1406 if (*option == '+')
1407 {
1408 quantize_info->dither=MagickFalse;
1409 break;
1410 }
1411 quantize_info->dither=MagickTrue;
1412 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1413 MagickDitherOptions,MagickFalse,argv[i+1]);
1414 if (quantize_info->dither_method == NoDitherMethod)
1415 quantize_info->dither=MagickFalse;
1416 break;
1417 }
1418 if (LocaleCompare("draw",option+1) == 0)
1419 {
1420 /*
1421 Draw image.
1422 */
1423 (void) SyncImageSettings(mogrify_info,*image);
1424 (void) CloneString(&draw_info->primitive,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001425 (void) DrawImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001426 break;
1427 }
1428 break;
1429 }
1430 case 'e':
1431 {
1432 if (LocaleCompare("edge",option+1) == 0)
1433 {
1434 /*
1435 Enhance edges in the image.
1436 */
1437 (void) SyncImageSettings(mogrify_info,*image);
1438 flags=ParseGeometry(argv[i+1],&geometry_info);
1439 if ((flags & SigmaValue) == 0)
1440 geometry_info.sigma=1.0;
cristy8ae632d2011-09-05 17:29:53 +00001441 mogrify_image=EdgeImage(*image,geometry_info.rho,
1442 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001443 break;
1444 }
1445 if (LocaleCompare("emboss",option+1) == 0)
1446 {
1447 /*
1448 Gaussian embossen image.
1449 */
1450 (void) SyncImageSettings(mogrify_info,*image);
1451 flags=ParseGeometry(argv[i+1],&geometry_info);
1452 if ((flags & SigmaValue) == 0)
1453 geometry_info.sigma=1.0;
1454 mogrify_image=EmbossImage(*image,geometry_info.rho,
1455 geometry_info.sigma,exception);
1456 break;
1457 }
1458 if (LocaleCompare("encipher",option+1) == 0)
1459 {
1460 StringInfo
1461 *passkey;
1462
1463 /*
1464 Encipher pixels.
1465 */
1466 (void) SyncImageSettings(mogrify_info,*image);
1467 passkey=FileToStringInfo(argv[i+1],~0,exception);
1468 if (passkey != (StringInfo *) NULL)
1469 {
1470 (void) PasskeyEncipherImage(*image,passkey,exception);
1471 passkey=DestroyStringInfo(passkey);
1472 }
1473 break;
1474 }
1475 if (LocaleCompare("encoding",option+1) == 0)
1476 {
1477 (void) CloneString(&draw_info->encoding,argv[i+1]);
1478 break;
1479 }
1480 if (LocaleCompare("enhance",option+1) == 0)
1481 {
1482 /*
1483 Enhance image.
1484 */
1485 (void) SyncImageSettings(mogrify_info,*image);
1486 mogrify_image=EnhanceImage(*image,exception);
1487 break;
1488 }
1489 if (LocaleCompare("equalize",option+1) == 0)
1490 {
1491 /*
1492 Equalize image.
1493 */
1494 (void) SyncImageSettings(mogrify_info,*image);
cristy6d8c3d72011-08-22 01:20:01 +00001495 (void) EqualizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001496 break;
1497 }
1498 if (LocaleCompare("evaluate",option+1) == 0)
1499 {
1500 double
1501 constant;
1502
1503 MagickEvaluateOperator
1504 op;
1505
1506 (void) SyncImageSettings(mogrify_info,*image);
cristyd42d9952011-07-08 14:21:50 +00001507 op=(MagickEvaluateOperator) ParseCommandOption(
1508 MagickEvaluateOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00001509 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
cristyd42d9952011-07-08 14:21:50 +00001510 (void) EvaluateImage(*image,op,constant,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001511 break;
1512 }
1513 if (LocaleCompare("extent",option+1) == 0)
1514 {
1515 /*
1516 Set the image extent.
1517 */
1518 (void) SyncImageSettings(mogrify_info,*image);
1519 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1520 if (geometry.width == 0)
1521 geometry.width=(*image)->columns;
1522 if (geometry.height == 0)
1523 geometry.height=(*image)->rows;
1524 mogrify_image=ExtentImage(*image,&geometry,exception);
1525 break;
1526 }
1527 break;
1528 }
1529 case 'f':
1530 {
1531 if (LocaleCompare("family",option+1) == 0)
1532 {
1533 if (*option == '+')
1534 {
1535 if (draw_info->family != (char *) NULL)
1536 draw_info->family=DestroyString(draw_info->family);
1537 break;
1538 }
1539 (void) CloneString(&draw_info->family,argv[i+1]);
1540 break;
1541 }
1542 if (LocaleCompare("features",option+1) == 0)
1543 {
1544 if (*option == '+')
1545 {
1546 (void) DeleteImageArtifact(*image,"identify:features");
1547 break;
1548 }
1549 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1550 break;
1551 }
1552 if (LocaleCompare("fill",option+1) == 0)
1553 {
1554 ExceptionInfo
1555 *sans;
1556
cristy4c08aed2011-07-01 19:47:50 +00001557 GetPixelInfo(*image,&fill);
anthonydf8ebac2011-04-27 09:03:19 +00001558 if (*option == '+')
1559 {
cristy269c9412011-10-13 23:41:15 +00001560 (void) QueryColorCompliance("none",AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001561 exception);
1562 (void) QueryColorCompliance("none",AllCompliance,
1563 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001564 if (draw_info->fill_pattern != (Image *) NULL)
1565 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1566 break;
1567 }
1568 sans=AcquireExceptionInfo();
cristy269c9412011-10-13 23:41:15 +00001569 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001570 sans);
1571 status=QueryColorCompliance(argv[i+1],AllCompliance,
1572 &draw_info->fill,sans);
anthonydf8ebac2011-04-27 09:03:19 +00001573 sans=DestroyExceptionInfo(sans);
1574 if (status == MagickFalse)
1575 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1576 exception);
1577 break;
1578 }
1579 if (LocaleCompare("flip",option+1) == 0)
1580 {
1581 /*
1582 Flip image scanlines.
1583 */
1584 (void) SyncImageSettings(mogrify_info,*image);
1585 mogrify_image=FlipImage(*image,exception);
1586 break;
1587 }
anthonydf8ebac2011-04-27 09:03:19 +00001588 if (LocaleCompare("floodfill",option+1) == 0)
1589 {
cristy4c08aed2011-07-01 19:47:50 +00001590 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001591 target;
1592
1593 /*
1594 Floodfill image.
1595 */
1596 (void) SyncImageSettings(mogrify_info,*image);
1597 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
cristy269c9412011-10-13 23:41:15 +00001598 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00001599 exception);
cristyd42d9952011-07-08 14:21:50 +00001600 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
cristy189e84c2011-08-27 18:08:53 +00001601 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001602 break;
1603 }
anthony3d2f4862011-05-01 13:48:16 +00001604 if (LocaleCompare("flop",option+1) == 0)
1605 {
1606 /*
1607 Flop image scanlines.
1608 */
1609 (void) SyncImageSettings(mogrify_info,*image);
1610 mogrify_image=FlopImage(*image,exception);
1611 break;
1612 }
anthonydf8ebac2011-04-27 09:03:19 +00001613 if (LocaleCompare("font",option+1) == 0)
1614 {
1615 if (*option == '+')
1616 {
1617 if (draw_info->font != (char *) NULL)
1618 draw_info->font=DestroyString(draw_info->font);
1619 break;
1620 }
1621 (void) CloneString(&draw_info->font,argv[i+1]);
1622 break;
1623 }
1624 if (LocaleCompare("format",option+1) == 0)
1625 {
1626 format=argv[i+1];
1627 break;
1628 }
1629 if (LocaleCompare("frame",option+1) == 0)
1630 {
1631 FrameInfo
1632 frame_info;
1633
1634 /*
1635 Surround image with an ornamental border.
1636 */
1637 (void) SyncImageSettings(mogrify_info,*image);
1638 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1639 frame_info.width=geometry.width;
1640 frame_info.height=geometry.height;
1641 if ((flags & HeightValue) == 0)
1642 frame_info.height=geometry.width;
1643 frame_info.outer_bevel=geometry.x;
1644 frame_info.inner_bevel=geometry.y;
1645 frame_info.x=(ssize_t) frame_info.width;
1646 frame_info.y=(ssize_t) frame_info.height;
1647 frame_info.width=(*image)->columns+2*frame_info.width;
1648 frame_info.height=(*image)->rows+2*frame_info.height;
cristy633f0c62011-09-15 13:27:36 +00001649 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001650 break;
1651 }
1652 if (LocaleCompare("function",option+1) == 0)
1653 {
1654 char
1655 *arguments,
1656 token[MaxTextExtent];
1657
1658 const char
1659 *p;
1660
1661 double
1662 *parameters;
1663
1664 MagickFunction
1665 function;
1666
1667 register ssize_t
1668 x;
1669
1670 size_t
1671 number_parameters;
1672
1673 /*
1674 Function Modify Image Values
1675 */
1676 (void) SyncImageSettings(mogrify_info,*image);
1677 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1678 MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001679 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1680 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001681 if (arguments == (char *) NULL)
1682 break;
1683 p=(char *) arguments;
1684 for (x=0; *p != '\0'; x++)
1685 {
1686 GetMagickToken(p,&p,token);
1687 if (*token == ',')
1688 GetMagickToken(p,&p,token);
1689 }
1690 number_parameters=(size_t) x;
1691 parameters=(double *) AcquireQuantumMemory(number_parameters,
1692 sizeof(*parameters));
1693 if (parameters == (double *) NULL)
1694 ThrowWandFatalException(ResourceLimitFatalError,
1695 "MemoryAllocationFailed",(*image)->filename);
1696 (void) ResetMagickMemory(parameters,0,number_parameters*
1697 sizeof(*parameters));
1698 p=(char *) arguments;
1699 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1700 {
1701 GetMagickToken(p,&p,token);
1702 if (*token == ',')
1703 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001704 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001705 }
1706 arguments=DestroyString(arguments);
cristyd42d9952011-07-08 14:21:50 +00001707 (void) FunctionImage(*image,function,number_parameters,parameters,
1708 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001709 parameters=(double *) RelinquishMagickMemory(parameters);
1710 break;
1711 }
1712 break;
1713 }
1714 case 'g':
1715 {
1716 if (LocaleCompare("gamma",option+1) == 0)
1717 {
1718 /*
1719 Gamma image.
1720 */
1721 (void) SyncImageSettings(mogrify_info,*image);
1722 if (*option == '+')
cristyc1acd842011-05-19 23:05:47 +00001723 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001724 else
cristyb3e7c6c2011-07-24 01:43:55 +00001725 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1726 (char **) NULL),exception);
anthonydf8ebac2011-04-27 09:03:19 +00001727 break;
1728 }
1729 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1730 (LocaleCompare("gaussian",option+1) == 0))
1731 {
1732 /*
1733 Gaussian blur image.
1734 */
1735 (void) SyncImageSettings(mogrify_info,*image);
1736 flags=ParseGeometry(argv[i+1],&geometry_info);
1737 if ((flags & SigmaValue) == 0)
1738 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001739 if ((flags & XiValue) == 0)
1740 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00001741 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001742 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001743 break;
1744 }
1745 if (LocaleCompare("geometry",option+1) == 0)
1746 {
1747 /*
1748 Record Image offset, Resize last image.
1749 */
1750 (void) SyncImageSettings(mogrify_info,*image);
1751 if (*option == '+')
1752 {
1753 if ((*image)->geometry != (char *) NULL)
1754 (*image)->geometry=DestroyString((*image)->geometry);
1755 break;
1756 }
1757 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1758 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1759 (void) CloneString(&(*image)->geometry,argv[i+1]);
1760 else
1761 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1762 (*image)->filter,(*image)->blur,exception);
1763 break;
1764 }
1765 if (LocaleCompare("gravity",option+1) == 0)
1766 {
1767 if (*option == '+')
1768 {
1769 draw_info->gravity=UndefinedGravity;
1770 break;
1771 }
1772 draw_info->gravity=(GravityType) ParseCommandOption(
1773 MagickGravityOptions,MagickFalse,argv[i+1]);
1774 break;
1775 }
1776 break;
1777 }
1778 case 'h':
1779 {
1780 if (LocaleCompare("highlight-color",option+1) == 0)
1781 {
1782 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1783 break;
1784 }
1785 break;
1786 }
1787 case 'i':
1788 {
1789 if (LocaleCompare("identify",option+1) == 0)
1790 {
1791 char
1792 *text;
1793
1794 (void) SyncImageSettings(mogrify_info,*image);
1795 if (format == (char *) NULL)
1796 {
cristya4037272011-08-28 15:11:39 +00001797 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1798 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001799 break;
1800 }
cristy018f07f2011-09-04 21:15:19 +00001801 text=InterpretImageProperties(mogrify_info,*image,format,
1802 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001803 if (text == (char *) NULL)
1804 break;
1805 (void) fputs(text,stdout);
1806 (void) fputc('\n',stdout);
1807 text=DestroyString(text);
1808 break;
1809 }
1810 if (LocaleCompare("implode",option+1) == 0)
1811 {
1812 /*
1813 Implode image.
1814 */
1815 (void) SyncImageSettings(mogrify_info,*image);
1816 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00001817 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1818 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001819 break;
1820 }
1821 if (LocaleCompare("interline-spacing",option+1) == 0)
1822 {
1823 if (*option == '+')
1824 (void) ParseGeometry("0",&geometry_info);
1825 else
1826 (void) ParseGeometry(argv[i+1],&geometry_info);
1827 draw_info->interline_spacing=geometry_info.rho;
1828 break;
1829 }
cristy28474bf2011-09-11 23:32:52 +00001830 if (LocaleCompare("interpolate",option+1) == 0)
1831 {
1832 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1833 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1834 break;
1835 }
anthonydf8ebac2011-04-27 09:03:19 +00001836 if (LocaleCompare("interword-spacing",option+1) == 0)
1837 {
1838 if (*option == '+')
1839 (void) ParseGeometry("0",&geometry_info);
1840 else
1841 (void) ParseGeometry(argv[i+1],&geometry_info);
1842 draw_info->interword_spacing=geometry_info.rho;
1843 break;
1844 }
1845 break;
1846 }
1847 case 'k':
1848 {
1849 if (LocaleCompare("kerning",option+1) == 0)
1850 {
1851 if (*option == '+')
1852 (void) ParseGeometry("0",&geometry_info);
1853 else
1854 (void) ParseGeometry(argv[i+1],&geometry_info);
1855 draw_info->kerning=geometry_info.rho;
1856 break;
1857 }
1858 break;
1859 }
1860 case 'l':
1861 {
1862 if (LocaleCompare("lat",option+1) == 0)
1863 {
1864 /*
1865 Local adaptive threshold image.
1866 */
1867 (void) SyncImageSettings(mogrify_info,*image);
1868 flags=ParseGeometry(argv[i+1],&geometry_info);
1869 if ((flags & PercentValue) != 0)
1870 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1871 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
cristyde5cc632011-07-18 14:47:00 +00001872 geometry_info.rho,(size_t) geometry_info.sigma,(double)
anthonydf8ebac2011-04-27 09:03:19 +00001873 geometry_info.xi,exception);
1874 break;
1875 }
1876 if (LocaleCompare("level",option+1) == 0)
1877 {
1878 MagickRealType
1879 black_point,
1880 gamma,
1881 white_point;
1882
1883 MagickStatusType
1884 flags;
1885
1886 /*
1887 Parse levels.
1888 */
1889 (void) SyncImageSettings(mogrify_info,*image);
1890 flags=ParseGeometry(argv[i+1],&geometry_info);
1891 black_point=geometry_info.rho;
1892 white_point=(MagickRealType) QuantumRange;
1893 if ((flags & SigmaValue) != 0)
1894 white_point=geometry_info.sigma;
1895 gamma=1.0;
1896 if ((flags & XiValue) != 0)
1897 gamma=geometry_info.xi;
1898 if ((flags & PercentValue) != 0)
1899 {
1900 black_point*=(MagickRealType) (QuantumRange/100.0);
1901 white_point*=(MagickRealType) (QuantumRange/100.0);
1902 }
1903 if ((flags & SigmaValue) == 0)
1904 white_point=(MagickRealType) QuantumRange-black_point;
1905 if ((*option == '+') || ((flags & AspectValue) != 0))
cristy7c0a0a42011-08-23 17:57:25 +00001906 (void) LevelizeImage(*image,black_point,white_point,gamma,
1907 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001908 else
cristy01e9afd2011-08-10 17:38:41 +00001909 (void) LevelImage(*image,black_point,white_point,gamma,
1910 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001911 break;
1912 }
1913 if (LocaleCompare("level-colors",option+1) == 0)
1914 {
1915 char
1916 token[MaxTextExtent];
1917
1918 const char
1919 *p;
1920
cristy4c08aed2011-07-01 19:47:50 +00001921 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001922 black_point,
1923 white_point;
1924
1925 p=(const char *) argv[i+1];
1926 GetMagickToken(p,&p,token); /* get black point color */
1927 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001928 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001929 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001930 else
cristy269c9412011-10-13 23:41:15 +00001931 (void) QueryColorCompliance("#000000",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001932 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001933 if (isalpha((int) token[0]) || (token[0] == '#'))
1934 GetMagickToken(p,&p,token);
1935 if (*token == '\0')
1936 white_point=black_point; /* set everything to that color */
1937 else
1938 {
1939 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1940 GetMagickToken(p,&p,token); /* Get white point color. */
1941 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001942 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001943 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001944 else
cristy269c9412011-10-13 23:41:15 +00001945 (void) QueryColorCompliance("#ffffff",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001946 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001947 }
cristy490408a2011-07-07 14:42:05 +00001948 (void) LevelImageColors(*image,&black_point,&white_point,
cristy7c0a0a42011-08-23 17:57:25 +00001949 *option == '+' ? MagickTrue : MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001950 break;
1951 }
1952 if (LocaleCompare("linear-stretch",option+1) == 0)
1953 {
1954 double
1955 black_point,
1956 white_point;
1957
1958 MagickStatusType
1959 flags;
1960
1961 (void) SyncImageSettings(mogrify_info,*image);
1962 flags=ParseGeometry(argv[i+1],&geometry_info);
1963 black_point=geometry_info.rho;
1964 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1965 if ((flags & SigmaValue) != 0)
1966 white_point=geometry_info.sigma;
1967 if ((flags & PercentValue) != 0)
1968 {
1969 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1970 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1971 }
1972 if ((flags & SigmaValue) == 0)
1973 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1974 black_point;
cristy33bd5152011-08-24 01:42:24 +00001975 (void) LinearStretchImage(*image,black_point,white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001976 break;
1977 }
1978 if (LocaleCompare("linewidth",option+1) == 0)
1979 {
cristyc1acd842011-05-19 23:05:47 +00001980 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1981 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001982 break;
1983 }
1984 if (LocaleCompare("liquid-rescale",option+1) == 0)
1985 {
1986 /*
1987 Liquid rescale image.
1988 */
1989 (void) SyncImageSettings(mogrify_info,*image);
1990 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1991 if ((flags & XValue) == 0)
1992 geometry.x=1;
1993 if ((flags & YValue) == 0)
1994 geometry.y=0;
1995 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1996 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1997 break;
1998 }
1999 if (LocaleCompare("lowlight-color",option+1) == 0)
2000 {
2001 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2002 break;
2003 }
2004 break;
2005 }
2006 case 'm':
2007 {
2008 if (LocaleCompare("map",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00002009 {
cristy3ed852e2009-09-05 21:47:34 +00002010 Image
anthonydf8ebac2011-04-27 09:03:19 +00002011 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002012
anthonydf8ebac2011-04-27 09:03:19 +00002013 /*
2014 Transform image colors to match this set of colors.
2015 */
2016 (void) SyncImageSettings(mogrify_info,*image);
2017 if (*option == '+')
2018 break;
2019 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2020 if (remap_image == (Image *) NULL)
2021 break;
cristy018f07f2011-09-04 21:15:19 +00002022 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002023 remap_image=DestroyImage(remap_image);
2024 break;
2025 }
2026 if (LocaleCompare("mask",option+1) == 0)
2027 {
2028 Image
2029 *mask;
2030
2031 (void) SyncImageSettings(mogrify_info,*image);
2032 if (*option == '+')
2033 {
2034 /*
2035 Remove a mask.
2036 */
cristy018f07f2011-09-04 21:15:19 +00002037 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002038 break;
2039 }
2040 /*
2041 Set the image mask.
2042 */
2043 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2044 if (mask == (Image *) NULL)
2045 break;
cristy018f07f2011-09-04 21:15:19 +00002046 (void) SetImageMask(*image,mask,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002047 mask=DestroyImage(mask);
anthonydf8ebac2011-04-27 09:03:19 +00002048 break;
2049 }
2050 if (LocaleCompare("matte",option+1) == 0)
2051 {
2052 (void) SetImageAlphaChannel(*image,(*option == '-') ?
cristy63240882011-08-05 19:05:27 +00002053 SetAlphaChannel : DeactivateAlphaChannel,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002054 break;
2055 }
2056 if (LocaleCompare("median",option+1) == 0)
2057 {
2058 /*
2059 Median filter image.
2060 */
2061 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002062 flags=ParseGeometry(argv[i+1],&geometry_info);
2063 if ((flags & SigmaValue) == 0)
2064 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002065 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002066 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002067 break;
2068 }
2069 if (LocaleCompare("mode",option+1) == 0)
2070 {
2071 /*
2072 Mode image.
2073 */
2074 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002075 flags=ParseGeometry(argv[i+1],&geometry_info);
2076 if ((flags & SigmaValue) == 0)
2077 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002078 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002079 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002080 break;
2081 }
2082 if (LocaleCompare("modulate",option+1) == 0)
2083 {
2084 (void) SyncImageSettings(mogrify_info,*image);
cristy33bd5152011-08-24 01:42:24 +00002085 (void) ModulateImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002086 break;
2087 }
2088 if (LocaleCompare("monitor",option+1) == 0)
2089 {
2090 if (*option == '+')
2091 {
2092 (void) SetImageProgressMonitor(*image,
2093 (MagickProgressMonitor) NULL,(void *) NULL);
2094 break;
2095 }
2096 (void) SetImageProgressMonitor(*image,MonitorProgress,
2097 (void *) NULL);
2098 break;
2099 }
2100 if (LocaleCompare("monochrome",option+1) == 0)
2101 {
2102 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00002103 (void) SetImageType(*image,BilevelType,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002104 break;
2105 }
2106 if (LocaleCompare("morphology",option+1) == 0)
2107 {
2108 char
2109 token[MaxTextExtent];
2110
2111 const char
2112 *p;
2113
2114 KernelInfo
2115 *kernel;
2116
2117 MorphologyMethod
2118 method;
2119
2120 ssize_t
2121 iterations;
2122
2123 /*
2124 Morphological Image Operation
2125 */
2126 (void) SyncImageSettings(mogrify_info,*image);
2127 p=argv[i+1];
2128 GetMagickToken(p,&p,token);
cristy28474bf2011-09-11 23:32:52 +00002129 method=(MorphologyMethod) ParseCommandOption(
2130 MagickMorphologyOptions,MagickFalse,token);
anthonydf8ebac2011-04-27 09:03:19 +00002131 iterations=1L;
2132 GetMagickToken(p,&p,token);
2133 if ((*p == ':') || (*p == ','))
2134 GetMagickToken(p,&p,token);
2135 if ((*p != '\0'))
2136 iterations=(ssize_t) StringToLong(p);
2137 kernel=AcquireKernelInfo(argv[i+2]);
2138 if (kernel == (KernelInfo *) NULL)
2139 {
2140 (void) ThrowMagickException(exception,GetMagickModule(),
2141 OptionError,"UnabletoParseKernel","morphology");
2142 status=MagickFalse;
2143 break;
2144 }
cristyf4ad9df2011-07-08 16:49:03 +00002145 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2146 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002147 kernel=DestroyKernelInfo(kernel);
2148 break;
2149 }
2150 if (LocaleCompare("motion-blur",option+1) == 0)
2151 {
2152 /*
2153 Motion blur image.
2154 */
2155 (void) SyncImageSettings(mogrify_info,*image);
2156 flags=ParseGeometry(argv[i+1],&geometry_info);
2157 if ((flags & SigmaValue) == 0)
2158 geometry_info.sigma=1.0;
cristyf4ad9df2011-07-08 16:49:03 +00002159 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002160 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2161 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002162 break;
2163 }
2164 break;
2165 }
2166 case 'n':
2167 {
2168 if (LocaleCompare("negate",option+1) == 0)
2169 {
2170 (void) SyncImageSettings(mogrify_info,*image);
cristy50fbc382011-07-07 02:19:17 +00002171 (void) NegateImage(*image,*option == '+' ? MagickTrue :
cristyb3e7c6c2011-07-24 01:43:55 +00002172 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002173 break;
2174 }
2175 if (LocaleCompare("noise",option+1) == 0)
2176 {
2177 (void) SyncImageSettings(mogrify_info,*image);
2178 if (*option == '-')
2179 {
cristyf36cbcb2011-09-07 13:28:22 +00002180 flags=ParseGeometry(argv[i+1],&geometry_info);
2181 if ((flags & SigmaValue) == 0)
2182 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002183 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002184 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002185 }
2186 else
2187 {
2188 NoiseType
2189 noise;
2190
2191 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2192 MagickFalse,argv[i+1]);
cristy9ed1f812011-10-08 02:00:08 +00002193 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002194 }
2195 break;
2196 }
2197 if (LocaleCompare("normalize",option+1) == 0)
2198 {
2199 (void) SyncImageSettings(mogrify_info,*image);
cristye23ec9d2011-08-16 18:15:40 +00002200 (void) NormalizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002201 break;
2202 }
2203 break;
2204 }
2205 case 'o':
2206 {
2207 if (LocaleCompare("opaque",option+1) == 0)
2208 {
cristy4c08aed2011-07-01 19:47:50 +00002209 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002210 target;
2211
2212 (void) SyncImageSettings(mogrify_info,*image);
cristy269c9412011-10-13 23:41:15 +00002213 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00002214 exception);
cristyd42d9952011-07-08 14:21:50 +00002215 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
cristy189e84c2011-08-27 18:08:53 +00002216 MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002217 break;
2218 }
2219 if (LocaleCompare("ordered-dither",option+1) == 0)
2220 {
2221 (void) SyncImageSettings(mogrify_info,*image);
cristy13020672011-07-08 02:33:26 +00002222 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002223 break;
2224 }
2225 break;
2226 }
2227 case 'p':
2228 {
2229 if (LocaleCompare("paint",option+1) == 0)
2230 {
anthonydf8ebac2011-04-27 09:03:19 +00002231 (void) SyncImageSettings(mogrify_info,*image);
2232 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy14973ba2011-08-27 23:48:07 +00002233 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2234 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002235 break;
2236 }
2237 if (LocaleCompare("pen",option+1) == 0)
2238 {
2239 if (*option == '+')
2240 {
cristy9950d572011-10-01 18:22:35 +00002241 (void) QueryColorCompliance("none",AllCompliance,
2242 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002243 break;
2244 }
cristy9950d572011-10-01 18:22:35 +00002245 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2246 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002247 break;
2248 }
2249 if (LocaleCompare("pointsize",option+1) == 0)
2250 {
2251 if (*option == '+')
2252 (void) ParseGeometry("12",&geometry_info);
2253 else
2254 (void) ParseGeometry(argv[i+1],&geometry_info);
2255 draw_info->pointsize=geometry_info.rho;
2256 break;
2257 }
2258 if (LocaleCompare("polaroid",option+1) == 0)
2259 {
2260 double
2261 angle;
2262
2263 RandomInfo
2264 *random_info;
2265
2266 /*
2267 Simulate a Polaroid picture.
2268 */
2269 (void) SyncImageSettings(mogrify_info,*image);
2270 random_info=AcquireRandomInfo();
2271 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2272 random_info=DestroyRandomInfo(random_info);
2273 if (*option == '-')
2274 {
2275 SetGeometryInfo(&geometry_info);
2276 flags=ParseGeometry(argv[i+1],&geometry_info);
2277 angle=geometry_info.rho;
2278 }
cristy5c4e2582011-09-11 19:21:03 +00002279 mogrify_image=PolaroidImage(*image,draw_info,angle,
cristy28474bf2011-09-11 23:32:52 +00002280 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002281 break;
2282 }
2283 if (LocaleCompare("posterize",option+1) == 0)
2284 {
2285 /*
2286 Posterize image.
2287 */
2288 (void) SyncImageSettings(mogrify_info,*image);
2289 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy018f07f2011-09-04 21:15:19 +00002290 quantize_info->dither,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002291 break;
2292 }
2293 if (LocaleCompare("preview",option+1) == 0)
2294 {
2295 PreviewType
2296 preview_type;
2297
2298 /*
2299 Preview image.
2300 */
2301 (void) SyncImageSettings(mogrify_info,*image);
2302 if (*option == '+')
2303 preview_type=UndefinedPreview;
2304 else
cristy28474bf2011-09-11 23:32:52 +00002305 preview_type=(PreviewType) ParseCommandOption(
2306 MagickPreviewOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002307 mogrify_image=PreviewImage(*image,preview_type,exception);
2308 break;
2309 }
2310 if (LocaleCompare("profile",option+1) == 0)
2311 {
2312 const char
2313 *name;
2314
2315 const StringInfo
2316 *profile;
2317
2318 Image
2319 *profile_image;
2320
2321 ImageInfo
2322 *profile_info;
2323
2324 (void) SyncImageSettings(mogrify_info,*image);
2325 if (*option == '+')
2326 {
2327 /*
2328 Remove a profile from the image.
2329 */
2330 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
cristy092d71c2011-10-14 18:01:29 +00002331 NULL,0,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002332 break;
2333 }
2334 /*
2335 Associate a profile with the image.
2336 */
2337 profile_info=CloneImageInfo(mogrify_info);
2338 profile=GetImageProfile(*image,"iptc");
2339 if (profile != (StringInfo *) NULL)
2340 profile_info->profile=(void *) CloneStringInfo(profile);
2341 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2342 profile_info=DestroyImageInfo(profile_info);
2343 if (profile_image == (Image *) NULL)
2344 {
2345 StringInfo
2346 *profile;
2347
2348 profile_info=CloneImageInfo(mogrify_info);
2349 (void) CopyMagickString(profile_info->filename,argv[i+1],
2350 MaxTextExtent);
2351 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2352 if (profile != (StringInfo *) NULL)
2353 {
2354 (void) ProfileImage(*image,profile_info->magick,
2355 GetStringInfoDatum(profile),(size_t)
2356 GetStringInfoLength(profile),MagickFalse);
2357 profile=DestroyStringInfo(profile);
2358 }
2359 profile_info=DestroyImageInfo(profile_info);
2360 break;
2361 }
2362 ResetImageProfileIterator(profile_image);
2363 name=GetNextImageProfile(profile_image);
2364 while (name != (const char *) NULL)
2365 {
2366 profile=GetImageProfile(profile_image,name);
2367 if (profile != (StringInfo *) NULL)
2368 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2369 (size_t) GetStringInfoLength(profile),MagickFalse);
2370 name=GetNextImageProfile(profile_image);
2371 }
2372 profile_image=DestroyImage(profile_image);
2373 break;
2374 }
2375 break;
2376 }
2377 case 'q':
2378 {
2379 if (LocaleCompare("quantize",option+1) == 0)
2380 {
2381 if (*option == '+')
2382 {
2383 quantize_info->colorspace=UndefinedColorspace;
2384 break;
2385 }
2386 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2387 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2388 break;
2389 }
2390 break;
2391 }
2392 case 'r':
2393 {
2394 if (LocaleCompare("radial-blur",option+1) == 0)
2395 {
2396 /*
2397 Radial blur image.
2398 */
2399 (void) SyncImageSettings(mogrify_info,*image);
cristy6435bd92011-09-10 02:10:07 +00002400 flags=ParseGeometry(argv[i+1],&geometry_info);
2401 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2402 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002403 break;
2404 }
2405 if (LocaleCompare("raise",option+1) == 0)
2406 {
2407 /*
2408 Surround image with a raise of solid color.
2409 */
2410 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2411 if ((flags & SigmaValue) == 0)
2412 geometry.height=geometry.width;
2413 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
cristy6170ac32011-08-28 14:15:37 +00002414 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002415 break;
2416 }
2417 if (LocaleCompare("random-threshold",option+1) == 0)
2418 {
2419 /*
2420 Threshold image.
2421 */
2422 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00002423 (void) RandomThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002424 break;
2425 }
2426 if (LocaleCompare("recolor",option+1) == 0)
2427 {
2428 KernelInfo
2429 *kernel;
2430
2431 (void) SyncImageSettings(mogrify_info,*image);
2432 kernel=AcquireKernelInfo(argv[i+1]);
2433 if (kernel == (KernelInfo *) NULL)
2434 break;
2435 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2436 kernel=DestroyKernelInfo(kernel);
2437 break;
2438 }
2439 if (LocaleCompare("region",option+1) == 0)
2440 {
2441 (void) SyncImageSettings(mogrify_info,*image);
2442 if (region_image != (Image *) NULL)
2443 {
2444 /*
2445 Composite region.
2446 */
2447 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00002448 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
cristye941a752011-10-15 01:52:48 +00002449 region_geometry.x,region_geometry.y,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002450 *image=DestroyImage(*image);
2451 *image=region_image;
2452 region_image = (Image *) NULL;
2453 }
2454 if (*option == '+')
2455 break;
2456 /*
2457 Apply transformations to a selected region of the image.
2458 */
cristy3ed852e2009-09-05 21:47:34 +00002459 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2460 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002461 mogrify_image=CropImage(*image,&region_geometry,exception);
2462 if (mogrify_image == (Image *) NULL)
2463 break;
2464 region_image=(*image);
2465 *image=mogrify_image;
2466 mogrify_image=(Image *) NULL;
2467 break;
cristy3ed852e2009-09-05 21:47:34 +00002468 }
anthonydf8ebac2011-04-27 09:03:19 +00002469 if (LocaleCompare("render",option+1) == 0)
2470 {
2471 (void) SyncImageSettings(mogrify_info,*image);
2472 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2473 break;
2474 }
2475 if (LocaleCompare("remap",option+1) == 0)
2476 {
2477 Image
2478 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002479
anthonydf8ebac2011-04-27 09:03:19 +00002480 /*
2481 Transform image colors to match this set of colors.
2482 */
2483 (void) SyncImageSettings(mogrify_info,*image);
2484 if (*option == '+')
2485 break;
2486 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2487 if (remap_image == (Image *) NULL)
2488 break;
cristy018f07f2011-09-04 21:15:19 +00002489 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002490 remap_image=DestroyImage(remap_image);
2491 break;
2492 }
2493 if (LocaleCompare("repage",option+1) == 0)
2494 {
2495 if (*option == '+')
2496 {
2497 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2498 break;
2499 }
2500 (void) ResetImagePage(*image,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002501 break;
2502 }
2503 if (LocaleCompare("resample",option+1) == 0)
2504 {
2505 /*
2506 Resample image.
2507 */
2508 (void) SyncImageSettings(mogrify_info,*image);
2509 flags=ParseGeometry(argv[i+1],&geometry_info);
2510 if ((flags & SigmaValue) == 0)
2511 geometry_info.sigma=geometry_info.rho;
2512 mogrify_image=ResampleImage(*image,geometry_info.rho,
2513 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2514 break;
2515 }
2516 if (LocaleCompare("resize",option+1) == 0)
2517 {
2518 /*
2519 Resize image.
2520 */
2521 (void) SyncImageSettings(mogrify_info,*image);
2522 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2523 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2524 (*image)->filter,(*image)->blur,exception);
2525 break;
2526 }
2527 if (LocaleCompare("roll",option+1) == 0)
2528 {
2529 /*
2530 Roll image.
2531 */
2532 (void) SyncImageSettings(mogrify_info,*image);
2533 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2534 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2535 break;
2536 }
2537 if (LocaleCompare("rotate",option+1) == 0)
2538 {
2539 char
2540 *geometry;
2541
2542 /*
2543 Check for conditional image rotation.
2544 */
2545 (void) SyncImageSettings(mogrify_info,*image);
2546 if (strchr(argv[i+1],'>') != (char *) NULL)
2547 if ((*image)->columns <= (*image)->rows)
2548 break;
2549 if (strchr(argv[i+1],'<') != (char *) NULL)
2550 if ((*image)->columns >= (*image)->rows)
2551 break;
2552 /*
2553 Rotate image.
2554 */
2555 geometry=ConstantString(argv[i+1]);
2556 (void) SubstituteString(&geometry,">","");
2557 (void) SubstituteString(&geometry,"<","");
2558 (void) ParseGeometry(geometry,&geometry_info);
2559 geometry=DestroyString(geometry);
2560 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2561 break;
2562 }
2563 break;
2564 }
2565 case 's':
2566 {
2567 if (LocaleCompare("sample",option+1) == 0)
2568 {
2569 /*
2570 Sample image with pixel replication.
2571 */
2572 (void) SyncImageSettings(mogrify_info,*image);
2573 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2574 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2575 exception);
2576 break;
2577 }
2578 if (LocaleCompare("scale",option+1) == 0)
2579 {
2580 /*
2581 Resize image.
2582 */
2583 (void) SyncImageSettings(mogrify_info,*image);
2584 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2585 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2586 exception);
2587 break;
2588 }
2589 if (LocaleCompare("selective-blur",option+1) == 0)
2590 {
2591 /*
2592 Selectively blur pixels within a contrast threshold.
2593 */
2594 (void) SyncImageSettings(mogrify_info,*image);
2595 flags=ParseGeometry(argv[i+1],&geometry_info);
2596 if ((flags & PercentValue) != 0)
2597 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristyf4ad9df2011-07-08 16:49:03 +00002598 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
cristy1e7aa312011-09-10 20:01:36 +00002599 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002600 break;
2601 }
2602 if (LocaleCompare("separate",option+1) == 0)
2603 {
2604 /*
2605 Break channels into separate images.
anthonydf8ebac2011-04-27 09:03:19 +00002606 */
2607 (void) SyncImageSettings(mogrify_info,*image);
cristy3139dc22011-07-08 00:11:42 +00002608 mogrify_image=SeparateImages(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002609 break;
2610 }
2611 if (LocaleCompare("sepia-tone",option+1) == 0)
2612 {
2613 double
2614 threshold;
2615
2616 /*
2617 Sepia-tone image.
2618 */
2619 (void) SyncImageSettings(mogrify_info,*image);
2620 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2621 mogrify_image=SepiaToneImage(*image,threshold,exception);
2622 break;
2623 }
2624 if (LocaleCompare("segment",option+1) == 0)
2625 {
2626 /*
2627 Segment image.
2628 */
2629 (void) SyncImageSettings(mogrify_info,*image);
2630 flags=ParseGeometry(argv[i+1],&geometry_info);
2631 if ((flags & SigmaValue) == 0)
2632 geometry_info.sigma=1.0;
2633 (void) SegmentImage(*image,(*image)->colorspace,
cristy018f07f2011-09-04 21:15:19 +00002634 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2635 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002636 break;
2637 }
2638 if (LocaleCompare("set",option+1) == 0)
2639 {
2640 char
2641 *value;
2642
2643 /*
2644 Set image option.
2645 */
2646 if (*option == '+')
2647 {
2648 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2649 (void) DeleteImageRegistry(argv[i+1]+9);
2650 else
2651 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2652 {
2653 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2654 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2655 }
2656 else
2657 (void) DeleteImageProperty(*image,argv[i+1]);
2658 break;
2659 }
cristy018f07f2011-09-04 21:15:19 +00002660 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2661 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002662 if (value == (char *) NULL)
2663 break;
2664 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2665 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2666 exception);
2667 else
2668 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2669 {
2670 (void) SetImageOption(image_info,argv[i+1]+7,value);
2671 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2672 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2673 }
2674 else
cristyd15e6592011-10-15 00:13:06 +00002675 (void) SetImageProperty(*image,argv[i+1],value,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002676 value=DestroyString(value);
2677 break;
2678 }
2679 if (LocaleCompare("shade",option+1) == 0)
2680 {
2681 /*
2682 Shade image.
2683 */
2684 (void) SyncImageSettings(mogrify_info,*image);
2685 flags=ParseGeometry(argv[i+1],&geometry_info);
2686 if ((flags & SigmaValue) == 0)
2687 geometry_info.sigma=1.0;
2688 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2689 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2690 break;
2691 }
2692 if (LocaleCompare("shadow",option+1) == 0)
2693 {
2694 /*
2695 Shadow image.
2696 */
2697 (void) SyncImageSettings(mogrify_info,*image);
2698 flags=ParseGeometry(argv[i+1],&geometry_info);
2699 if ((flags & SigmaValue) == 0)
2700 geometry_info.sigma=1.0;
2701 if ((flags & XiValue) == 0)
2702 geometry_info.xi=4.0;
2703 if ((flags & PsiValue) == 0)
2704 geometry_info.psi=4.0;
2705 mogrify_image=ShadowImage(*image,geometry_info.rho,
2706 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2707 ceil(geometry_info.psi-0.5),exception);
2708 break;
2709 }
2710 if (LocaleCompare("sharpen",option+1) == 0)
2711 {
2712 /*
2713 Sharpen image.
2714 */
2715 (void) SyncImageSettings(mogrify_info,*image);
2716 flags=ParseGeometry(argv[i+1],&geometry_info);
2717 if ((flags & SigmaValue) == 0)
2718 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00002719 if ((flags & XiValue) == 0)
2720 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00002721 mogrify_image=SharpenImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00002722 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002723 break;
2724 }
2725 if (LocaleCompare("shave",option+1) == 0)
2726 {
2727 /*
2728 Shave the image edges.
2729 */
2730 (void) SyncImageSettings(mogrify_info,*image);
2731 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2732 mogrify_image=ShaveImage(*image,&geometry,exception);
2733 break;
2734 }
2735 if (LocaleCompare("shear",option+1) == 0)
2736 {
2737 /*
2738 Shear image.
2739 */
2740 (void) SyncImageSettings(mogrify_info,*image);
2741 flags=ParseGeometry(argv[i+1],&geometry_info);
2742 if ((flags & SigmaValue) == 0)
2743 geometry_info.sigma=geometry_info.rho;
2744 mogrify_image=ShearImage(*image,geometry_info.rho,
2745 geometry_info.sigma,exception);
2746 break;
2747 }
2748 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2749 {
2750 /*
2751 Sigmoidal non-linearity contrast control.
2752 */
2753 (void) SyncImageSettings(mogrify_info,*image);
2754 flags=ParseGeometry(argv[i+1],&geometry_info);
2755 if ((flags & SigmaValue) == 0)
2756 geometry_info.sigma=(double) QuantumRange/2.0;
2757 if ((flags & PercentValue) != 0)
2758 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2759 100.0;
cristy9ee60942011-07-06 14:54:38 +00002760 (void) SigmoidalContrastImage(*image,(*option == '-') ?
cristy33bd5152011-08-24 01:42:24 +00002761 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2762 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002763 break;
2764 }
2765 if (LocaleCompare("sketch",option+1) == 0)
2766 {
2767 /*
2768 Sketch image.
2769 */
2770 (void) SyncImageSettings(mogrify_info,*image);
2771 flags=ParseGeometry(argv[i+1],&geometry_info);
2772 if ((flags & SigmaValue) == 0)
2773 geometry_info.sigma=1.0;
2774 mogrify_image=SketchImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002775 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002776 break;
2777 }
2778 if (LocaleCompare("solarize",option+1) == 0)
2779 {
2780 double
2781 threshold;
2782
2783 (void) SyncImageSettings(mogrify_info,*image);
2784 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy5cbc0162011-08-29 00:36:28 +00002785 (void) SolarizeImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002786 break;
2787 }
2788 if (LocaleCompare("sparse-color",option+1) == 0)
2789 {
2790 SparseColorMethod
2791 method;
2792
2793 char
2794 *arguments;
2795
2796 /*
2797 Sparse Color Interpolated Gradient
2798 */
2799 (void) SyncImageSettings(mogrify_info,*image);
2800 method=(SparseColorMethod) ParseCommandOption(
2801 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00002802 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2803 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002804 if (arguments == (char *) NULL)
2805 break;
cristy3884f692011-07-08 18:00:18 +00002806 mogrify_image=SparseColorOption(*image,method,arguments,
anthonydf8ebac2011-04-27 09:03:19 +00002807 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2808 arguments=DestroyString(arguments);
2809 break;
2810 }
2811 if (LocaleCompare("splice",option+1) == 0)
2812 {
2813 /*
2814 Splice a solid color into the image.
2815 */
2816 (void) SyncImageSettings(mogrify_info,*image);
2817 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2818 mogrify_image=SpliceImage(*image,&geometry,exception);
2819 break;
2820 }
2821 if (LocaleCompare("spread",option+1) == 0)
2822 {
2823 /*
2824 Spread an image.
2825 */
2826 (void) SyncImageSettings(mogrify_info,*image);
2827 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy5c4e2582011-09-11 19:21:03 +00002828 mogrify_image=SpreadImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00002829 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002830 break;
2831 }
2832 if (LocaleCompare("statistic",option+1) == 0)
2833 {
2834 StatisticType
2835 type;
2836
2837 (void) SyncImageSettings(mogrify_info,*image);
2838 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2839 MagickFalse,argv[i+1]);
2840 (void) ParseGeometry(argv[i+2],&geometry_info);
cristyf4ad9df2011-07-08 16:49:03 +00002841 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2842 (size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002843 break;
2844 }
2845 if (LocaleCompare("stretch",option+1) == 0)
2846 {
2847 if (*option == '+')
2848 {
2849 draw_info->stretch=UndefinedStretch;
2850 break;
2851 }
2852 draw_info->stretch=(StretchType) ParseCommandOption(
2853 MagickStretchOptions,MagickFalse,argv[i+1]);
2854 break;
2855 }
2856 if (LocaleCompare("strip",option+1) == 0)
2857 {
2858 /*
2859 Strip image of profiles and comments.
2860 */
2861 (void) SyncImageSettings(mogrify_info,*image);
cristye941a752011-10-15 01:52:48 +00002862 (void) StripImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002863 break;
2864 }
2865 if (LocaleCompare("stroke",option+1) == 0)
2866 {
2867 ExceptionInfo
2868 *sans;
2869
2870 if (*option == '+')
2871 {
cristy9950d572011-10-01 18:22:35 +00002872 (void) QueryColorCompliance("none",AllCompliance,
2873 &draw_info->stroke,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002874 if (draw_info->stroke_pattern != (Image *) NULL)
2875 draw_info->stroke_pattern=DestroyImage(
2876 draw_info->stroke_pattern);
2877 break;
2878 }
2879 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00002880 status=QueryColorCompliance(argv[i+1],AllCompliance,
2881 &draw_info->stroke,sans);
anthonydf8ebac2011-04-27 09:03:19 +00002882 sans=DestroyExceptionInfo(sans);
2883 if (status == MagickFalse)
2884 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2885 exception);
2886 break;
2887 }
2888 if (LocaleCompare("strokewidth",option+1) == 0)
2889 {
cristyc1acd842011-05-19 23:05:47 +00002890 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2891 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002892 break;
2893 }
2894 if (LocaleCompare("style",option+1) == 0)
2895 {
2896 if (*option == '+')
2897 {
2898 draw_info->style=UndefinedStyle;
2899 break;
2900 }
2901 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2902 MagickFalse,argv[i+1]);
2903 break;
2904 }
2905 if (LocaleCompare("swirl",option+1) == 0)
2906 {
2907 /*
2908 Swirl image.
2909 */
2910 (void) SyncImageSettings(mogrify_info,*image);
2911 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00002912 mogrify_image=SwirlImage(*image,geometry_info.rho,
2913 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002914 break;
2915 }
2916 break;
2917 }
2918 case 't':
2919 {
2920 if (LocaleCompare("threshold",option+1) == 0)
2921 {
2922 double
2923 threshold;
2924
2925 /*
2926 Threshold image.
2927 */
2928 (void) SyncImageSettings(mogrify_info,*image);
2929 if (*option == '+')
anthony247a86d2011-05-03 13:18:18 +00002930 threshold=(double) QuantumRange/2;
anthonydf8ebac2011-04-27 09:03:19 +00002931 else
2932 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristye941a752011-10-15 01:52:48 +00002933 (void) BilevelImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002934 break;
2935 }
2936 if (LocaleCompare("thumbnail",option+1) == 0)
2937 {
2938 /*
2939 Thumbnail image.
2940 */
2941 (void) SyncImageSettings(mogrify_info,*image);
2942 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2943 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2944 exception);
2945 break;
2946 }
2947 if (LocaleCompare("tile",option+1) == 0)
2948 {
2949 if (*option == '+')
2950 {
2951 if (draw_info->fill_pattern != (Image *) NULL)
2952 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2953 break;
2954 }
2955 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2956 exception);
2957 break;
2958 }
2959 if (LocaleCompare("tint",option+1) == 0)
2960 {
2961 /*
2962 Tint the image.
2963 */
2964 (void) SyncImageSettings(mogrify_info,*image);
cristy28474bf2011-09-11 23:32:52 +00002965 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002966 break;
2967 }
2968 if (LocaleCompare("transform",option+1) == 0)
2969 {
2970 /*
2971 Affine transform image.
2972 */
2973 (void) SyncImageSettings(mogrify_info,*image);
2974 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2975 exception);
2976 break;
2977 }
2978 if (LocaleCompare("transparent",option+1) == 0)
2979 {
cristy4c08aed2011-07-01 19:47:50 +00002980 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002981 target;
2982
2983 (void) SyncImageSettings(mogrify_info,*image);
cristy269c9412011-10-13 23:41:15 +00002984 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00002985 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002986 (void) TransparentPaintImage(*image,&target,(Quantum)
cristy189e84c2011-08-27 18:08:53 +00002987 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
cristy82d7af52011-10-16 16:26:41 +00002988 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002989 break;
2990 }
2991 if (LocaleCompare("transpose",option+1) == 0)
2992 {
2993 /*
2994 Transpose image scanlines.
2995 */
2996 (void) SyncImageSettings(mogrify_info,*image);
2997 mogrify_image=TransposeImage(*image,exception);
2998 break;
2999 }
3000 if (LocaleCompare("transverse",option+1) == 0)
3001 {
3002 /*
3003 Transverse image scanlines.
3004 */
3005 (void) SyncImageSettings(mogrify_info,*image);
3006 mogrify_image=TransverseImage(*image,exception);
3007 break;
3008 }
3009 if (LocaleCompare("treedepth",option+1) == 0)
3010 {
3011 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3012 break;
3013 }
3014 if (LocaleCompare("trim",option+1) == 0)
3015 {
3016 /*
3017 Trim image.
3018 */
3019 (void) SyncImageSettings(mogrify_info,*image);
3020 mogrify_image=TrimImage(*image,exception);
3021 break;
3022 }
3023 if (LocaleCompare("type",option+1) == 0)
3024 {
3025 ImageType
3026 type;
3027
3028 (void) SyncImageSettings(mogrify_info,*image);
3029 if (*option == '+')
3030 type=UndefinedType;
3031 else
3032 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3033 argv[i+1]);
3034 (*image)->type=UndefinedType;
cristy018f07f2011-09-04 21:15:19 +00003035 (void) SetImageType(*image,type,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003036 break;
3037 }
3038 break;
3039 }
3040 case 'u':
3041 {
3042 if (LocaleCompare("undercolor",option+1) == 0)
3043 {
cristy9950d572011-10-01 18:22:35 +00003044 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3045 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003046 break;
3047 }
3048 if (LocaleCompare("unique",option+1) == 0)
3049 {
3050 if (*option == '+')
3051 {
3052 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3053 break;
3054 }
3055 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3056 (void) SetImageArtifact(*image,"verbose","true");
3057 break;
3058 }
3059 if (LocaleCompare("unique-colors",option+1) == 0)
3060 {
3061 /*
3062 Unique image colors.
3063 */
3064 (void) SyncImageSettings(mogrify_info,*image);
3065 mogrify_image=UniqueImageColors(*image,exception);
3066 break;
3067 }
3068 if (LocaleCompare("unsharp",option+1) == 0)
3069 {
3070 /*
3071 Unsharp mask image.
3072 */
3073 (void) SyncImageSettings(mogrify_info,*image);
3074 flags=ParseGeometry(argv[i+1],&geometry_info);
3075 if ((flags & SigmaValue) == 0)
3076 geometry_info.sigma=1.0;
3077 if ((flags & XiValue) == 0)
3078 geometry_info.xi=1.0;
3079 if ((flags & PsiValue) == 0)
3080 geometry_info.psi=0.05;
cristyf4ad9df2011-07-08 16:49:03 +00003081 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3082 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003083 break;
3084 }
3085 break;
3086 }
3087 case 'v':
3088 {
3089 if (LocaleCompare("verbose",option+1) == 0)
3090 {
3091 (void) SetImageArtifact(*image,option+1,
3092 *option == '+' ? "false" : "true");
3093 break;
3094 }
3095 if (LocaleCompare("vignette",option+1) == 0)
3096 {
3097 /*
3098 Vignette image.
3099 */
3100 (void) SyncImageSettings(mogrify_info,*image);
3101 flags=ParseGeometry(argv[i+1],&geometry_info);
3102 if ((flags & SigmaValue) == 0)
3103 geometry_info.sigma=1.0;
3104 if ((flags & XiValue) == 0)
3105 geometry_info.xi=0.1*(*image)->columns;
3106 if ((flags & PsiValue) == 0)
3107 geometry_info.psi=0.1*(*image)->rows;
3108 mogrify_image=VignetteImage(*image,geometry_info.rho,
3109 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3110 ceil(geometry_info.psi-0.5),exception);
3111 break;
3112 }
3113 if (LocaleCompare("virtual-pixel",option+1) == 0)
3114 {
3115 if (*option == '+')
3116 {
3117 (void) SetImageVirtualPixelMethod(*image,
3118 UndefinedVirtualPixelMethod);
3119 break;
3120 }
3121 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3122 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3123 argv[i+1]));
3124 break;
3125 }
3126 break;
3127 }
3128 case 'w':
3129 {
3130 if (LocaleCompare("wave",option+1) == 0)
3131 {
3132 /*
3133 Wave image.
3134 */
3135 (void) SyncImageSettings(mogrify_info,*image);
3136 flags=ParseGeometry(argv[i+1],&geometry_info);
3137 if ((flags & SigmaValue) == 0)
3138 geometry_info.sigma=1.0;
3139 mogrify_image=WaveImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00003140 geometry_info.sigma,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003141 break;
3142 }
3143 if (LocaleCompare("weight",option+1) == 0)
3144 {
3145 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3146 if (LocaleCompare(argv[i+1],"all") == 0)
3147 draw_info->weight=0;
3148 if (LocaleCompare(argv[i+1],"bold") == 0)
3149 draw_info->weight=700;
3150 if (LocaleCompare(argv[i+1],"bolder") == 0)
3151 if (draw_info->weight <= 800)
3152 draw_info->weight+=100;
3153 if (LocaleCompare(argv[i+1],"lighter") == 0)
3154 if (draw_info->weight >= 100)
3155 draw_info->weight-=100;
3156 if (LocaleCompare(argv[i+1],"normal") == 0)
3157 draw_info->weight=400;
3158 break;
3159 }
3160 if (LocaleCompare("white-threshold",option+1) == 0)
3161 {
3162 /*
3163 White threshold image.
3164 */
3165 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00003166 (void) WhiteThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00003167 break;
3168 }
3169 break;
3170 }
3171 default:
3172 break;
3173 }
3174 /*
3175 Replace current image with any image that was generated
3176 */
3177 if (mogrify_image != (Image *) NULL)
3178 ReplaceImageInListReturnLast(image,mogrify_image);
cristy3ed852e2009-09-05 21:47:34 +00003179 i+=count;
3180 }
3181 if (region_image != (Image *) NULL)
3182 {
anthonydf8ebac2011-04-27 09:03:19 +00003183 /*
3184 Composite transformed region onto image.
3185 */
cristy6b3da3a2010-06-20 02:21:46 +00003186 (void) SyncImageSettings(mogrify_info,*image);
anthonya129f702011-04-14 01:08:48 +00003187 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00003188 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
cristye941a752011-10-15 01:52:48 +00003189 region_geometry.x,region_geometry.y,exception);
cristy3ed852e2009-09-05 21:47:34 +00003190 *image=DestroyImage(*image);
3191 *image=region_image;
anthonye9c27192011-03-27 08:07:06 +00003192 region_image = (Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00003193 }
3194 /*
3195 Free resources.
3196 */
anthonydf8ebac2011-04-27 09:03:19 +00003197 quantize_info=DestroyQuantizeInfo(quantize_info);
3198 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003199 mogrify_info=DestroyImageInfo(mogrify_info);
cristy82d7af52011-10-16 16:26:41 +00003200 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
cristy72988482011-03-29 16:34:38 +00003201 return(status == 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00003202}
3203
3204/*
3205%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3206% %
3207% %
3208% %
cristy5063d812010-10-19 16:28:10 +00003209+ 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 +00003210% %
3211% %
3212% %
3213%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3214%
3215% MogrifyImageCommand() transforms an image or a sequence of images. These
3216% transforms include image scaling, image rotation, color reduction, and
3217% others. The transmogrified image overwrites the original image.
3218%
3219% The format of the MogrifyImageCommand method is:
3220%
3221% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3222% const char **argv,char **metadata,ExceptionInfo *exception)
3223%
3224% A description of each parameter follows:
3225%
3226% o image_info: the image info.
3227%
3228% o argc: the number of elements in the argument vector.
3229%
3230% o argv: A text array containing the command line arguments.
3231%
3232% o metadata: any metadata is returned here.
3233%
3234% o exception: return any errors or warnings in this structure.
3235%
3236*/
3237
3238static MagickBooleanType MogrifyUsage(void)
3239{
3240 static const char
3241 *miscellaneous[]=
3242 {
3243 "-debug events display copious debugging information",
3244 "-help print program options",
3245 "-list type print a list of supported option arguments",
3246 "-log format format of debugging information",
3247 "-version print version information",
3248 (char *) NULL
3249 },
3250 *operators[]=
3251 {
3252 "-adaptive-blur geometry",
3253 " adaptively blur pixels; decrease effect near edges",
3254 "-adaptive-resize geometry",
3255 " adaptively resize image using 'mesh' interpolation",
3256 "-adaptive-sharpen geometry",
3257 " adaptively sharpen pixels; increase effect near edges",
3258 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3259 " transparent, extract, background, or shape",
3260 "-annotate geometry text",
3261 " annotate the image with text",
3262 "-auto-gamma automagically adjust gamma level of image",
3263 "-auto-level automagically adjust color levels of image",
3264 "-auto-orient automagically orient (rotate) image",
3265 "-bench iterations measure performance",
3266 "-black-threshold value",
3267 " force all pixels below the threshold into black",
3268 "-blue-shift simulate a scene at nighttime in the moonlight",
3269 "-blur geometry reduce image noise and reduce detail levels",
3270 "-border geometry surround image with a border of color",
3271 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003272 "-brightness-contrast geometry",
3273 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003274 "-cdl filename color correct with a color decision list",
cristy05c0c9a2011-09-05 23:16:13 +00003275 "-charcoal geometry simulate a charcoal drawing",
cristy3ed852e2009-09-05 21:47:34 +00003276 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003277 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003278 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003279 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003280 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003281 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003282 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003283 "-contrast enhance or reduce the image contrast",
3284 "-contrast-stretch geometry",
3285 " improve contrast by `stretching' the intensity range",
3286 "-convolve coefficients",
3287 " apply a convolution kernel to the image",
3288 "-cycle amount cycle the image colormap",
3289 "-decipher filename convert cipher pixels to plain pixels",
3290 "-deskew threshold straighten an image",
3291 "-despeckle reduce the speckles within an image",
3292 "-distort method args",
3293 " distort images according to given method ad args",
3294 "-draw string annotate the image with a graphic primitive",
3295 "-edge radius apply a filter to detect edges in the image",
3296 "-encipher filename convert plain pixels to cipher pixels",
3297 "-emboss radius emboss an image",
3298 "-enhance apply a digital filter to enhance a noisy image",
3299 "-equalize perform histogram equalization to an image",
3300 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003301 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003302 "-extent geometry set the image size",
3303 "-extract geometry extract area from image",
3304 "-fft implements the discrete Fourier transform (DFT)",
3305 "-flip flip image vertically",
3306 "-floodfill geometry color",
3307 " floodfill the image with color",
3308 "-flop flop image horizontally",
3309 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003310 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003311 " apply function over image values",
3312 "-gamma value level of gamma correction",
3313 "-gaussian-blur geometry",
3314 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003315 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003316 "-identify identify the format and characteristics of the image",
3317 "-ift implements the inverse discrete Fourier transform (DFT)",
3318 "-implode amount implode image pixels about the center",
3319 "-lat geometry local adaptive thresholding",
3320 "-layers method optimize, merge, or compare image layers",
3321 "-level value adjust the level of image contrast",
3322 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003323 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003324 "-linear-stretch geometry",
3325 " improve contrast by `stretching with saturation'",
3326 "-liquid-rescale geometry",
3327 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +00003328 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +00003329 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003330 "-modulate value vary the brightness, saturation, and hue",
3331 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003332 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003333 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003334 "-motion-blur geometry",
3335 " simulate motion blur",
3336 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +00003337 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +00003338 "-normalize transform image to span the full range of colors",
3339 "-opaque color change this color to the fill color",
3340 "-ordered-dither NxN",
3341 " add a noise pattern to the image with specific",
3342 " amplitudes",
3343 "-paint radius simulate an oil painting",
3344 "-polaroid angle simulate a Polaroid picture",
3345 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003346 "-profile filename add, delete, or apply an image profile",
3347 "-quantize colorspace reduce colors in this colorspace",
3348 "-radial-blur angle radial blur the image",
3349 "-raise value lighten/darken image edges to create a 3-D effect",
3350 "-random-threshold low,high",
3351 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003352 "-region geometry apply options to a portion of the image",
3353 "-render render vector graphics",
3354 "-repage geometry size and location of an image canvas",
3355 "-resample geometry change the resolution of an image",
3356 "-resize geometry resize the image",
3357 "-roll geometry roll an image vertically or horizontally",
3358 "-rotate degrees apply Paeth rotation to the image",
3359 "-sample geometry scale image with pixel sampling",
3360 "-scale geometry scale the image",
3361 "-segment values segment an image",
3362 "-selective-blur geometry",
3363 " selectively blur pixels within a contrast threshold",
3364 "-sepia-tone threshold",
3365 " simulate a sepia-toned photo",
3366 "-set property value set an image property",
3367 "-shade degrees shade the image using a distant light source",
3368 "-shadow geometry simulate an image shadow",
3369 "-sharpen geometry sharpen the image",
3370 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003371 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003372 "-sigmoidal-contrast geometry",
3373 " increase the contrast without saturating highlights or shadows",
3374 "-sketch geometry simulate a pencil sketch",
3375 "-solarize threshold negate all pixels above the threshold level",
3376 "-sparse-color method args",
3377 " fill in a image based on a few color points",
3378 "-splice geometry splice the background color into the image",
3379 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003380 "-statistic type radius",
3381 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003382 "-strip strip image of all profiles and comments",
3383 "-swirl degrees swirl image pixels about the center",
3384 "-threshold value threshold the image",
3385 "-thumbnail geometry create a thumbnail of the image",
3386 "-tile filename tile image when filling a graphic primitive",
3387 "-tint value tint the image with the fill color",
3388 "-transform affine transform image",
3389 "-transparent color make this color transparent within the image",
3390 "-transpose flip image vertically and rotate 90 degrees",
3391 "-transverse flop image horizontally and rotate 270 degrees",
3392 "-trim trim image edges",
3393 "-type type image type",
3394 "-unique-colors discard all but one of any pixel color",
3395 "-unsharp geometry sharpen the image",
3396 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003397 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003398 "-white-threshold value",
3399 " force all pixels above the threshold into white",
3400 (char *) NULL
3401 },
3402 *sequence_operators[]=
3403 {
cristy4285d782011-02-09 20:12:28 +00003404 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003405 "-clut apply a color lookup table to the image",
3406 "-coalesce merge a sequence of images",
3407 "-combine combine a sequence of images",
3408 "-composite composite image",
3409 "-crop geometry cut out a rectangular region of the image",
3410 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003411 "-evaluate-sequence operator",
3412 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003413 "-flatten flatten a sequence of images",
3414 "-fx expression apply mathematical expression to an image channel(s)",
3415 "-hald-clut apply a Hald color lookup table to the image",
3416 "-morph value morph an image sequence",
3417 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003418 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003419 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003420 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003421 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003422 "-write filename write images to this file",
3423 (char *) NULL
3424 },
3425 *settings[]=
3426 {
3427 "-adjoin join images into a single multi-image file",
3428 "-affine matrix affine transform matrix",
3429 "-alpha option activate, deactivate, reset, or set the alpha channel",
3430 "-antialias remove pixel-aliasing",
3431 "-authenticate password",
3432 " decipher image with this password",
3433 "-attenuate value lessen (or intensify) when adding noise to an image",
3434 "-background color background color",
3435 "-bias value add bias when convolving an image",
3436 "-black-point-compensation",
3437 " use black point compensation",
3438 "-blue-primary point chromaticity blue primary point",
3439 "-bordercolor color border color",
3440 "-caption string assign a caption to an image",
3441 "-channel type apply option to select image channels",
3442 "-colors value preferred number of colors in the image",
3443 "-colorspace type alternate image colorspace",
3444 "-comment string annotate image with comment",
3445 "-compose operator set image composite operator",
3446 "-compress type type of pixel compression when writing the image",
3447 "-define format:option",
3448 " define one or more image format options",
3449 "-delay value display the next image after pausing",
3450 "-density geometry horizontal and vertical density of the image",
3451 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003452 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003453 "-display server get image or font from this X server",
3454 "-dispose method layer disposal method",
3455 "-dither method apply error diffusion to image",
3456 "-encoding type text encoding type",
3457 "-endian type endianness (MSB or LSB) of the image",
3458 "-family name render text with this font family",
3459 "-fill color color to use when filling a graphic primitive",
3460 "-filter type use this filter when resizing an image",
3461 "-font name render text with this font",
3462 "-format \"string\" output formatted image characteristics",
3463 "-fuzz distance colors within this distance are considered equal",
3464 "-gravity type horizontal and vertical text placement",
3465 "-green-primary point chromaticity green primary point",
3466 "-intent type type of rendering intent when managing the image color",
3467 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003468 "-interline-spacing value",
3469 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003470 "-interpolate method pixel color interpolation method",
3471 "-interword-spacing value",
3472 " set the space between two words",
3473 "-kerning value set the space between two letters",
3474 "-label string assign a label to an image",
3475 "-limit type value pixel cache resource limit",
3476 "-loop iterations add Netscape loop extension to your GIF animation",
3477 "-mask filename associate a mask with the image",
3478 "-mattecolor color frame color",
3479 "-monitor monitor progress",
3480 "-orient type image orientation",
3481 "-page geometry size and location of an image canvas (setting)",
3482 "-ping efficiently determine image attributes",
3483 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003484 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003485 "-preview type image preview type",
3486 "-quality value JPEG/MIFF/PNG compression level",
3487 "-quiet suppress all warning messages",
3488 "-red-primary point chromaticity red primary point",
3489 "-regard-warnings pay attention to warning messages",
3490 "-remap filename transform image colors to match this set of colors",
3491 "-respect-parentheses settings remain in effect until parenthesis boundary",
3492 "-sampling-factor geometry",
3493 " horizontal and vertical sampling factor",
3494 "-scene value image scene number",
3495 "-seed value seed a new sequence of pseudo-random numbers",
3496 "-size geometry width and height of image",
3497 "-stretch type render text with this font stretch",
3498 "-stroke color graphic primitive stroke color",
3499 "-strokewidth value graphic primitive stroke width",
3500 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003501 "-synchronize synchronize image to storage device",
3502 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003503 "-texture filename name of texture to tile onto the image background",
3504 "-tile-offset geometry",
3505 " tile offset",
3506 "-treedepth value color tree depth",
3507 "-transparent-color color",
3508 " transparent color",
3509 "-undercolor color annotation bounding box color",
3510 "-units type the units of image resolution",
3511 "-verbose print detailed information about the image",
3512 "-view FlashPix viewing transforms",
3513 "-virtual-pixel method",
3514 " virtual pixel access method",
3515 "-weight type render text with this font weight",
3516 "-white-point point chromaticity white point",
3517 (char *) NULL
3518 },
3519 *stack_operators[]=
3520 {
anthonyb69c4b32011-03-23 04:37:44 +00003521 "-delete indexes delete the image from the image sequence",
3522 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003523 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003524 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003525 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003526 "-swap indexes swap two images in the image sequence",
3527 (char *) NULL
3528 };
3529
3530 const char
3531 **p;
3532
cristybb503372010-05-27 20:51:26 +00003533 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003534 (void) printf("Copyright: %s\n",GetMagickCopyright());
3535 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003536 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3537 GetClientName());
3538 (void) printf("\nImage Settings:\n");
3539 for (p=settings; *p != (char *) NULL; p++)
3540 (void) printf(" %s\n",*p);
3541 (void) printf("\nImage Operators:\n");
3542 for (p=operators; *p != (char *) NULL; p++)
3543 (void) printf(" %s\n",*p);
3544 (void) printf("\nImage Sequence Operators:\n");
3545 for (p=sequence_operators; *p != (char *) NULL; p++)
3546 (void) printf(" %s\n",*p);
3547 (void) printf("\nImage Stack Operators:\n");
3548 for (p=stack_operators; *p != (char *) NULL; p++)
3549 (void) printf(" %s\n",*p);
3550 (void) printf("\nMiscellaneous Options:\n");
3551 for (p=miscellaneous; *p != (char *) NULL; p++)
3552 (void) printf(" %s\n",*p);
3553 (void) printf(
3554 "\nBy default, the image format of `file' is determined by its magic\n");
3555 (void) printf(
3556 "number. To specify a particular image format, precede the filename\n");
3557 (void) printf(
3558 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3559 (void) printf(
3560 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3561 (void) printf("'-' for standard input or output.\n");
3562 return(MagickFalse);
3563}
3564
3565WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3566 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3567{
3568#define DestroyMogrify() \
3569{ \
3570 if (format != (char *) NULL) \
3571 format=DestroyString(format); \
3572 if (path != (char *) NULL) \
3573 path=DestroyString(path); \
3574 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003575 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003576 argv[i]=DestroyString(argv[i]); \
3577 argv=(char **) RelinquishMagickMemory(argv); \
3578}
3579#define ThrowMogrifyException(asperity,tag,option) \
3580{ \
3581 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3582 option); \
3583 DestroyMogrify(); \
3584 return(MagickFalse); \
3585}
3586#define ThrowMogrifyInvalidArgumentException(option,argument) \
3587{ \
3588 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3589 "InvalidArgument","`%s': %s",argument,option); \
3590 DestroyMogrify(); \
3591 return(MagickFalse); \
3592}
3593
3594 char
3595 *format,
3596 *option,
3597 *path;
3598
3599 Image
3600 *image;
3601
3602 ImageStack
3603 image_stack[MaxImageStackDepth+1];
3604
cristy3ed852e2009-09-05 21:47:34 +00003605 MagickBooleanType
3606 global_colormap;
3607
3608 MagickBooleanType
3609 fire,
cristyebbcfea2011-02-25 02:43:54 +00003610 pend,
3611 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00003612
3613 MagickStatusType
3614 status;
3615
cristyebbcfea2011-02-25 02:43:54 +00003616 register ssize_t
3617 i;
3618
3619 ssize_t
3620 j,
3621 k;
3622
cristy3ed852e2009-09-05 21:47:34 +00003623 /*
3624 Set defaults.
3625 */
3626 assert(image_info != (ImageInfo *) NULL);
3627 assert(image_info->signature == MagickSignature);
3628 if (image_info->debug != MagickFalse)
3629 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3630 assert(exception != (ExceptionInfo *) NULL);
3631 if (argc == 2)
3632 {
3633 option=argv[1];
3634 if ((LocaleCompare("version",option+1) == 0) ||
3635 (LocaleCompare("-version",option+1) == 0))
3636 {
cristyb51dff52011-05-19 16:55:47 +00003637 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00003638 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00003639 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3640 GetMagickCopyright());
3641 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3642 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003643 return(MagickFalse);
3644 }
3645 }
3646 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00003647 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00003648 format=(char *) NULL;
3649 path=(char *) NULL;
3650 global_colormap=MagickFalse;
3651 k=0;
3652 j=1;
3653 NewImageStack();
3654 option=(char *) NULL;
3655 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00003656 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003657 status=MagickTrue;
3658 /*
3659 Parse command line.
3660 */
3661 ReadCommandlLine(argc,&argv);
3662 status=ExpandFilenames(&argc,&argv);
3663 if (status == MagickFalse)
3664 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3665 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00003666 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00003667 {
3668 option=argv[i];
3669 if (LocaleCompare(option,"(") == 0)
3670 {
3671 FireImageStack(MagickFalse,MagickTrue,pend);
3672 if (k == MaxImageStackDepth)
3673 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3674 option);
3675 PushImageStack();
3676 continue;
3677 }
3678 if (LocaleCompare(option,")") == 0)
3679 {
3680 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3681 if (k == 0)
3682 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3683 PopImageStack();
3684 continue;
3685 }
cristy042ee782011-04-22 18:48:30 +00003686 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00003687 {
3688 char
3689 backup_filename[MaxTextExtent],
3690 *filename;
3691
3692 Image
3693 *images;
3694
3695 /*
3696 Option is a file name: begin by reading image from specified file.
3697 */
3698 FireImageStack(MagickFalse,MagickFalse,pend);
3699 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00003700 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00003701 filename=argv[++i];
3702 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3703 images=ReadImages(image_info,exception);
3704 status&=(images != (Image *) NULL) &&
3705 (exception->severity < ErrorException);
3706 if (images == (Image *) NULL)
3707 continue;
cristydaa76602010-06-30 13:05:11 +00003708 if (format != (char *) NULL)
3709 (void) CopyMagickString(images->filename,images->magick_filename,
3710 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00003711 if (path != (char *) NULL)
3712 {
3713 GetPathComponent(option,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +00003714 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
cristy3ed852e2009-09-05 21:47:34 +00003715 path,*DirectorySeparator,filename);
3716 }
3717 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00003718 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00003719 AppendImageStack(images);
3720 FinalizeImageSettings(image_info,image,MagickFalse);
3721 if (global_colormap != MagickFalse)
3722 {
3723 QuantizeInfo
3724 *quantize_info;
3725
3726 quantize_info=AcquireQuantizeInfo(image_info);
cristy018f07f2011-09-04 21:15:19 +00003727 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
cristy3ed852e2009-09-05 21:47:34 +00003728 quantize_info=DestroyQuantizeInfo(quantize_info);
3729 }
3730 *backup_filename='\0';
3731 if ((LocaleCompare(image->filename,"-") != 0) &&
3732 (IsPathWritable(image->filename) != MagickFalse))
3733 {
cristybb503372010-05-27 20:51:26 +00003734 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003735 i;
3736
3737 /*
3738 Rename image file as backup.
3739 */
3740 (void) CopyMagickString(backup_filename,image->filename,
3741 MaxTextExtent);
3742 for (i=0; i < 6; i++)
3743 {
3744 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3745 if (IsPathAccessible(backup_filename) == MagickFalse)
3746 break;
3747 }
3748 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
cristy320684d2011-09-23 14:55:47 +00003749 (rename_utf8(image->filename,backup_filename) != 0))
cristy3ed852e2009-09-05 21:47:34 +00003750 *backup_filename='\0';
3751 }
3752 /*
3753 Write transmogrified image to disk.
3754 */
3755 image_info->synchronize=MagickTrue;
3756 status&=WriteImages(image_info,image,image->filename,exception);
3757 if ((status == MagickFalse) && (*backup_filename != '\0'))
cristy18c6c272011-09-23 14:40:37 +00003758 (void) remove_utf8(backup_filename);
cristy3ed852e2009-09-05 21:47:34 +00003759 RemoveAllImageStack();
3760 continue;
3761 }
3762 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3763 switch (*(option+1))
3764 {
3765 case 'a':
3766 {
3767 if (LocaleCompare("adaptive-blur",option+1) == 0)
3768 {
3769 i++;
cristybb503372010-05-27 20:51:26 +00003770 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003771 ThrowMogrifyException(OptionError,"MissingArgument",option);
3772 if (IsGeometry(argv[i]) == MagickFalse)
3773 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3774 break;
3775 }
3776 if (LocaleCompare("adaptive-resize",option+1) == 0)
3777 {
3778 i++;
cristybb503372010-05-27 20:51:26 +00003779 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003780 ThrowMogrifyException(OptionError,"MissingArgument",option);
3781 if (IsGeometry(argv[i]) == MagickFalse)
3782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3783 break;
3784 }
3785 if (LocaleCompare("adaptive-sharpen",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("affine",option+1) == 0)
3795 {
3796 if (*option == '+')
3797 break;
3798 i++;
cristybb503372010-05-27 20:51:26 +00003799 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003800 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +00003801 break;
3802 }
3803 if (LocaleCompare("alpha",option+1) == 0)
3804 {
cristybb503372010-05-27 20:51:26 +00003805 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003806 type;
3807
3808 if (*option == '+')
3809 break;
3810 i++;
cristybb503372010-05-27 20:51:26 +00003811 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003812 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00003813 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00003814 if (type < 0)
3815 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3816 argv[i]);
3817 break;
3818 }
3819 if (LocaleCompare("annotate",option+1) == 0)
3820 {
3821 if (*option == '+')
3822 break;
3823 i++;
cristybb503372010-05-27 20:51:26 +00003824 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003825 ThrowMogrifyException(OptionError,"MissingArgument",option);
3826 if (IsGeometry(argv[i]) == MagickFalse)
3827 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00003828 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003829 ThrowMogrifyException(OptionError,"MissingArgument",option);
3830 i++;
3831 break;
3832 }
3833 if (LocaleCompare("antialias",option+1) == 0)
3834 break;
3835 if (LocaleCompare("append",option+1) == 0)
3836 break;
3837 if (LocaleCompare("attenuate",option+1) == 0)
3838 {
3839 if (*option == '+')
3840 break;
3841 i++;
cristybb503372010-05-27 20:51:26 +00003842 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003843 ThrowMogrifyException(OptionError,"MissingArgument",option);
3844 if (IsGeometry(argv[i]) == MagickFalse)
3845 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3846 break;
3847 }
3848 if (LocaleCompare("authenticate",option+1) == 0)
3849 {
3850 if (*option == '+')
3851 break;
3852 i++;
cristybb503372010-05-27 20:51:26 +00003853 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003854 ThrowMogrifyException(OptionError,"MissingArgument",option);
3855 break;
3856 }
3857 if (LocaleCompare("auto-gamma",option+1) == 0)
3858 break;
3859 if (LocaleCompare("auto-level",option+1) == 0)
3860 break;
3861 if (LocaleCompare("auto-orient",option+1) == 0)
3862 break;
3863 if (LocaleCompare("average",option+1) == 0)
3864 break;
3865 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3866 }
3867 case 'b':
3868 {
3869 if (LocaleCompare("background",option+1) == 0)
3870 {
3871 if (*option == '+')
3872 break;
3873 i++;
cristybb503372010-05-27 20:51:26 +00003874 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003875 ThrowMogrifyException(OptionError,"MissingArgument",option);
3876 break;
3877 }
3878 if (LocaleCompare("bias",option+1) == 0)
3879 {
3880 if (*option == '+')
3881 break;
3882 i++;
cristybb503372010-05-27 20:51:26 +00003883 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003884 ThrowMogrifyException(OptionError,"MissingArgument",option);
3885 if (IsGeometry(argv[i]) == MagickFalse)
3886 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3887 break;
3888 }
3889 if (LocaleCompare("black-point-compensation",option+1) == 0)
3890 break;
3891 if (LocaleCompare("black-threshold",option+1) == 0)
3892 {
3893 if (*option == '+')
3894 break;
3895 i++;
cristybb503372010-05-27 20:51:26 +00003896 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003897 ThrowMogrifyException(OptionError,"MissingArgument",option);
3898 if (IsGeometry(argv[i]) == MagickFalse)
3899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3900 break;
3901 }
3902 if (LocaleCompare("blue-primary",option+1) == 0)
3903 {
3904 if (*option == '+')
3905 break;
3906 i++;
cristybb503372010-05-27 20:51:26 +00003907 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003908 ThrowMogrifyException(OptionError,"MissingArgument",option);
3909 if (IsGeometry(argv[i]) == MagickFalse)
3910 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3911 break;
3912 }
3913 if (LocaleCompare("blue-shift",option+1) == 0)
3914 {
3915 i++;
cristybb503372010-05-27 20:51:26 +00003916 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003917 ThrowMogrifyException(OptionError,"MissingArgument",option);
3918 if (IsGeometry(argv[i]) == MagickFalse)
3919 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3920 break;
3921 }
3922 if (LocaleCompare("blur",option+1) == 0)
3923 {
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("border",option+1) == 0)
3932 {
3933 if (*option == '+')
3934 break;
3935 i++;
cristybb503372010-05-27 20:51:26 +00003936 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003937 ThrowMogrifyException(OptionError,"MissingArgument",option);
3938 if (IsGeometry(argv[i]) == MagickFalse)
3939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3940 break;
3941 }
3942 if (LocaleCompare("bordercolor",option+1) == 0)
3943 {
3944 if (*option == '+')
3945 break;
3946 i++;
cristybb503372010-05-27 20:51:26 +00003947 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003948 ThrowMogrifyException(OptionError,"MissingArgument",option);
3949 break;
3950 }
3951 if (LocaleCompare("box",option+1) == 0)
3952 {
3953 if (*option == '+')
3954 break;
3955 i++;
cristybb503372010-05-27 20:51:26 +00003956 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003957 ThrowMogrifyException(OptionError,"MissingArgument",option);
3958 break;
3959 }
cristya28d6b82010-01-11 20:03:47 +00003960 if (LocaleCompare("brightness-contrast",option+1) == 0)
3961 {
3962 i++;
cristybb503372010-05-27 20:51:26 +00003963 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00003964 ThrowMogrifyException(OptionError,"MissingArgument",option);
3965 if (IsGeometry(argv[i]) == MagickFalse)
3966 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3967 break;
3968 }
cristy3ed852e2009-09-05 21:47:34 +00003969 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3970 }
3971 case 'c':
3972 {
3973 if (LocaleCompare("cache",option+1) == 0)
3974 {
3975 if (*option == '+')
3976 break;
3977 i++;
cristybb503372010-05-27 20:51:26 +00003978 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003979 ThrowMogrifyException(OptionError,"MissingArgument",option);
3980 if (IsGeometry(argv[i]) == MagickFalse)
3981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3982 break;
3983 }
3984 if (LocaleCompare("caption",option+1) == 0)
3985 {
3986 if (*option == '+')
3987 break;
3988 i++;
cristybb503372010-05-27 20:51:26 +00003989 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003990 ThrowMogrifyException(OptionError,"MissingArgument",option);
3991 break;
3992 }
3993 if (LocaleCompare("channel",option+1) == 0)
3994 {
cristybb503372010-05-27 20:51:26 +00003995 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003996 channel;
3997
3998 if (*option == '+')
3999 break;
4000 i++;
cristybb503372010-05-27 20:51:26 +00004001 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004002 ThrowMogrifyException(OptionError,"MissingArgument",option);
4003 channel=ParseChannelOption(argv[i]);
4004 if (channel < 0)
4005 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4006 argv[i]);
4007 break;
4008 }
4009 if (LocaleCompare("cdl",option+1) == 0)
4010 {
4011 if (*option == '+')
4012 break;
4013 i++;
cristybb503372010-05-27 20:51:26 +00004014 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004015 ThrowMogrifyException(OptionError,"MissingArgument",option);
4016 break;
4017 }
4018 if (LocaleCompare("charcoal",option+1) == 0)
4019 {
4020 if (*option == '+')
4021 break;
4022 i++;
cristybb503372010-05-27 20:51:26 +00004023 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004024 ThrowMogrifyException(OptionError,"MissingArgument",option);
4025 if (IsGeometry(argv[i]) == MagickFalse)
4026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4027 break;
4028 }
4029 if (LocaleCompare("chop",option+1) == 0)
4030 {
4031 if (*option == '+')
4032 break;
4033 i++;
cristybb503372010-05-27 20:51:26 +00004034 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004035 ThrowMogrifyException(OptionError,"MissingArgument",option);
4036 if (IsGeometry(argv[i]) == MagickFalse)
4037 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4038 break;
4039 }
cristy1eb45dd2009-09-25 16:38:06 +00004040 if (LocaleCompare("clamp",option+1) == 0)
4041 break;
4042 if (LocaleCompare("clip",option+1) == 0)
4043 break;
cristy3ed852e2009-09-05 21:47:34 +00004044 if (LocaleCompare("clip-mask",option+1) == 0)
4045 {
4046 if (*option == '+')
4047 break;
4048 i++;
cristybb503372010-05-27 20:51:26 +00004049 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004050 ThrowMogrifyException(OptionError,"MissingArgument",option);
4051 break;
4052 }
4053 if (LocaleCompare("clut",option+1) == 0)
4054 break;
4055 if (LocaleCompare("coalesce",option+1) == 0)
4056 break;
4057 if (LocaleCompare("colorize",option+1) == 0)
4058 {
4059 if (*option == '+')
4060 break;
4061 i++;
cristybb503372010-05-27 20:51:26 +00004062 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004063 ThrowMogrifyException(OptionError,"MissingArgument",option);
4064 if (IsGeometry(argv[i]) == MagickFalse)
4065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4066 break;
4067 }
cristye6365592010-04-02 17:31:23 +00004068 if (LocaleCompare("color-matrix",option+1) == 0)
4069 {
cristyb6bd4ad2010-08-08 01:12:27 +00004070 KernelInfo
4071 *kernel_info;
4072
cristye6365592010-04-02 17:31:23 +00004073 if (*option == '+')
4074 break;
4075 i++;
cristybb503372010-05-27 20:51:26 +00004076 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004077 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004078 kernel_info=AcquireKernelInfo(argv[i]);
4079 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004080 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004081 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004082 break;
4083 }
cristy3ed852e2009-09-05 21:47:34 +00004084 if (LocaleCompare("colors",option+1) == 0)
4085 {
4086 if (*option == '+')
4087 break;
4088 i++;
cristybb503372010-05-27 20:51:26 +00004089 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004090 ThrowMogrifyException(OptionError,"MissingArgument",option);
4091 if (IsGeometry(argv[i]) == MagickFalse)
4092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4093 break;
4094 }
4095 if (LocaleCompare("colorspace",option+1) == 0)
4096 {
cristybb503372010-05-27 20:51:26 +00004097 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004098 colorspace;
4099
4100 if (*option == '+')
4101 break;
4102 i++;
cristybb503372010-05-27 20:51:26 +00004103 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004104 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004105 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004106 argv[i]);
4107 if (colorspace < 0)
4108 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4109 argv[i]);
4110 break;
4111 }
4112 if (LocaleCompare("combine",option+1) == 0)
4113 break;
4114 if (LocaleCompare("comment",option+1) == 0)
4115 {
4116 if (*option == '+')
4117 break;
4118 i++;
cristybb503372010-05-27 20:51:26 +00004119 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004120 ThrowMogrifyException(OptionError,"MissingArgument",option);
4121 break;
4122 }
4123 if (LocaleCompare("composite",option+1) == 0)
4124 break;
4125 if (LocaleCompare("compress",option+1) == 0)
4126 {
cristybb503372010-05-27 20:51:26 +00004127 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004128 compress;
4129
4130 if (*option == '+')
4131 break;
4132 i++;
cristybb503372010-05-27 20:51:26 +00004133 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004134 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004135 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004136 argv[i]);
4137 if (compress < 0)
4138 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4139 argv[i]);
4140 break;
4141 }
cristy22879752009-10-25 23:55:40 +00004142 if (LocaleCompare("concurrent",option+1) == 0)
4143 break;
cristy3ed852e2009-09-05 21:47:34 +00004144 if (LocaleCompare("contrast",option+1) == 0)
4145 break;
4146 if (LocaleCompare("contrast-stretch",option+1) == 0)
4147 {
4148 i++;
cristybb503372010-05-27 20:51:26 +00004149 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004150 ThrowMogrifyException(OptionError,"MissingArgument",option);
4151 if (IsGeometry(argv[i]) == MagickFalse)
4152 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4153 break;
4154 }
4155 if (LocaleCompare("convolve",option+1) == 0)
4156 {
cristyb6bd4ad2010-08-08 01:12:27 +00004157 KernelInfo
4158 *kernel_info;
4159
cristy3ed852e2009-09-05 21:47:34 +00004160 if (*option == '+')
4161 break;
4162 i++;
cristybb503372010-05-27 20:51:26 +00004163 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004164 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004165 kernel_info=AcquireKernelInfo(argv[i]);
4166 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004168 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004169 break;
4170 }
4171 if (LocaleCompare("crop",option+1) == 0)
4172 {
4173 if (*option == '+')
4174 break;
4175 i++;
cristybb503372010-05-27 20:51:26 +00004176 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004177 ThrowMogrifyException(OptionError,"MissingArgument",option);
4178 if (IsGeometry(argv[i]) == MagickFalse)
4179 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4180 break;
4181 }
4182 if (LocaleCompare("cycle",option+1) == 0)
4183 {
4184 if (*option == '+')
4185 break;
4186 i++;
cristybb503372010-05-27 20:51:26 +00004187 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004188 ThrowMogrifyException(OptionError,"MissingArgument",option);
4189 if (IsGeometry(argv[i]) == MagickFalse)
4190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4191 break;
4192 }
4193 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4194 }
4195 case 'd':
4196 {
4197 if (LocaleCompare("decipher",option+1) == 0)
4198 {
4199 if (*option == '+')
4200 break;
4201 i++;
cristybb503372010-05-27 20:51:26 +00004202 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004203 ThrowMogrifyException(OptionError,"MissingArgument",option);
4204 break;
4205 }
4206 if (LocaleCompare("deconstruct",option+1) == 0)
4207 break;
4208 if (LocaleCompare("debug",option+1) == 0)
4209 {
cristybb503372010-05-27 20:51:26 +00004210 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004211 event;
4212
4213 if (*option == '+')
4214 break;
4215 i++;
cristybb503372010-05-27 20:51:26 +00004216 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004217 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004218 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004219 if (event < 0)
4220 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4221 argv[i]);
4222 (void) SetLogEventMask(argv[i]);
4223 break;
4224 }
4225 if (LocaleCompare("define",option+1) == 0)
4226 {
4227 i++;
cristybb503372010-05-27 20:51:26 +00004228 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004229 ThrowMogrifyException(OptionError,"MissingArgument",option);
4230 if (*option == '+')
4231 {
4232 const char
4233 *define;
4234
4235 define=GetImageOption(image_info,argv[i]);
4236 if (define == (const char *) NULL)
4237 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4238 break;
4239 }
4240 break;
4241 }
4242 if (LocaleCompare("delay",option+1) == 0)
4243 {
4244 if (*option == '+')
4245 break;
4246 i++;
cristybb503372010-05-27 20:51:26 +00004247 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004248 ThrowMogrifyException(OptionError,"MissingArgument",option);
4249 if (IsGeometry(argv[i]) == MagickFalse)
4250 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4251 break;
4252 }
cristyecb10ff2011-03-22 13:14:03 +00004253 if (LocaleCompare("delete",option+1) == 0)
4254 {
4255 if (*option == '+')
4256 break;
4257 i++;
4258 if (i == (ssize_t) (argc-1))
4259 ThrowMogrifyException(OptionError,"MissingArgument",option);
4260 if (IsGeometry(argv[i]) == MagickFalse)
4261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4262 break;
4263 }
cristy3ed852e2009-09-05 21:47:34 +00004264 if (LocaleCompare("density",option+1) == 0)
4265 {
4266 if (*option == '+')
4267 break;
4268 i++;
cristybb503372010-05-27 20:51:26 +00004269 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004270 ThrowMogrifyException(OptionError,"MissingArgument",option);
4271 if (IsGeometry(argv[i]) == MagickFalse)
4272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4273 break;
4274 }
4275 if (LocaleCompare("depth",option+1) == 0)
4276 {
4277 if (*option == '+')
4278 break;
4279 i++;
cristybb503372010-05-27 20:51:26 +00004280 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004281 ThrowMogrifyException(OptionError,"MissingArgument",option);
4282 if (IsGeometry(argv[i]) == MagickFalse)
4283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4284 break;
4285 }
4286 if (LocaleCompare("deskew",option+1) == 0)
4287 {
4288 if (*option == '+')
4289 break;
4290 i++;
cristybb503372010-05-27 20:51:26 +00004291 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004292 ThrowMogrifyException(OptionError,"MissingArgument",option);
4293 if (IsGeometry(argv[i]) == MagickFalse)
4294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4295 break;
4296 }
4297 if (LocaleCompare("despeckle",option+1) == 0)
4298 break;
4299 if (LocaleCompare("dft",option+1) == 0)
4300 break;
cristyc9b12952010-03-28 01:12:28 +00004301 if (LocaleCompare("direction",option+1) == 0)
4302 {
cristybb503372010-05-27 20:51:26 +00004303 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004304 direction;
4305
4306 if (*option == '+')
4307 break;
4308 i++;
cristybb503372010-05-27 20:51:26 +00004309 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004310 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004311 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00004312 argv[i]);
4313 if (direction < 0)
4314 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4315 argv[i]);
4316 break;
4317 }
cristy3ed852e2009-09-05 21:47:34 +00004318 if (LocaleCompare("display",option+1) == 0)
4319 {
4320 if (*option == '+')
4321 break;
4322 i++;
cristybb503372010-05-27 20:51:26 +00004323 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004324 ThrowMogrifyException(OptionError,"MissingArgument",option);
4325 break;
4326 }
4327 if (LocaleCompare("dispose",option+1) == 0)
4328 {
cristybb503372010-05-27 20:51:26 +00004329 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004330 dispose;
4331
4332 if (*option == '+')
4333 break;
4334 i++;
cristybb503372010-05-27 20:51:26 +00004335 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004336 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004337 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004338 if (dispose < 0)
4339 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4340 argv[i]);
4341 break;
4342 }
4343 if (LocaleCompare("distort",option+1) == 0)
4344 {
cristybb503372010-05-27 20:51:26 +00004345 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004346 op;
4347
4348 i++;
cristybb503372010-05-27 20:51:26 +00004349 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004350 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004351 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004352 if (op < 0)
4353 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4354 argv[i]);
4355 i++;
cristybb503372010-05-27 20:51:26 +00004356 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004357 ThrowMogrifyException(OptionError,"MissingArgument",option);
4358 break;
4359 }
4360 if (LocaleCompare("dither",option+1) == 0)
4361 {
cristybb503372010-05-27 20:51:26 +00004362 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004363 method;
4364
4365 if (*option == '+')
4366 break;
4367 i++;
cristybb503372010-05-27 20:51:26 +00004368 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004369 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004370 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004371 if (method < 0)
4372 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4373 argv[i]);
4374 break;
4375 }
4376 if (LocaleCompare("draw",option+1) == 0)
4377 {
4378 if (*option == '+')
4379 break;
4380 i++;
cristybb503372010-05-27 20:51:26 +00004381 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004382 ThrowMogrifyException(OptionError,"MissingArgument",option);
4383 break;
4384 }
cristyecb10ff2011-03-22 13:14:03 +00004385 if (LocaleCompare("duplicate",option+1) == 0)
4386 {
4387 if (*option == '+')
4388 break;
4389 i++;
4390 if (i == (ssize_t) (argc-1))
4391 ThrowMogrifyException(OptionError,"MissingArgument",option);
4392 if (IsGeometry(argv[i]) == MagickFalse)
4393 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4394 break;
4395 }
cristy22879752009-10-25 23:55:40 +00004396 if (LocaleCompare("duration",option+1) == 0)
4397 {
4398 if (*option == '+')
4399 break;
4400 i++;
cristybb503372010-05-27 20:51:26 +00004401 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004402 ThrowMogrifyException(OptionError,"MissingArgument",option);
4403 if (IsGeometry(argv[i]) == MagickFalse)
4404 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4405 break;
4406 }
cristy3ed852e2009-09-05 21:47:34 +00004407 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4408 }
4409 case 'e':
4410 {
4411 if (LocaleCompare("edge",option+1) == 0)
4412 {
4413 if (*option == '+')
4414 break;
4415 i++;
cristybb503372010-05-27 20:51:26 +00004416 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004417 ThrowMogrifyException(OptionError,"MissingArgument",option);
4418 if (IsGeometry(argv[i]) == MagickFalse)
4419 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4420 break;
4421 }
4422 if (LocaleCompare("emboss",option+1) == 0)
4423 {
4424 if (*option == '+')
4425 break;
4426 i++;
cristybb503372010-05-27 20:51:26 +00004427 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004428 ThrowMogrifyException(OptionError,"MissingArgument",option);
4429 if (IsGeometry(argv[i]) == MagickFalse)
4430 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4431 break;
4432 }
4433 if (LocaleCompare("encipher",option+1) == 0)
4434 {
4435 if (*option == '+')
4436 break;
4437 i++;
cristybb503372010-05-27 20:51:26 +00004438 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004439 ThrowMogrifyException(OptionError,"MissingArgument",option);
4440 break;
4441 }
4442 if (LocaleCompare("encoding",option+1) == 0)
4443 {
4444 if (*option == '+')
4445 break;
4446 i++;
cristybb503372010-05-27 20:51:26 +00004447 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004448 ThrowMogrifyException(OptionError,"MissingArgument",option);
4449 break;
4450 }
4451 if (LocaleCompare("endian",option+1) == 0)
4452 {
cristybb503372010-05-27 20:51:26 +00004453 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004454 endian;
4455
4456 if (*option == '+')
4457 break;
4458 i++;
cristybb503372010-05-27 20:51:26 +00004459 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004460 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004461 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004462 if (endian < 0)
4463 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4464 argv[i]);
4465 break;
4466 }
4467 if (LocaleCompare("enhance",option+1) == 0)
4468 break;
4469 if (LocaleCompare("equalize",option+1) == 0)
4470 break;
4471 if (LocaleCompare("evaluate",option+1) == 0)
4472 {
cristybb503372010-05-27 20:51:26 +00004473 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004474 op;
4475
4476 if (*option == '+')
4477 break;
4478 i++;
cristybb503372010-05-27 20:51:26 +00004479 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004480 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004481 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004482 if (op < 0)
4483 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4484 argv[i]);
4485 i++;
cristybb503372010-05-27 20:51:26 +00004486 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004487 ThrowMogrifyException(OptionError,"MissingArgument",option);
4488 if (IsGeometry(argv[i]) == MagickFalse)
4489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4490 break;
4491 }
cristyd18ae7c2010-03-07 17:39:52 +00004492 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4493 {
cristybb503372010-05-27 20:51:26 +00004494 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004495 op;
4496
4497 if (*option == '+')
4498 break;
4499 i++;
cristybb503372010-05-27 20:51:26 +00004500 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004501 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004502 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00004503 if (op < 0)
4504 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4505 argv[i]);
4506 break;
4507 }
cristy3ed852e2009-09-05 21:47:34 +00004508 if (LocaleCompare("extent",option+1) == 0)
4509 {
4510 if (*option == '+')
4511 break;
4512 i++;
cristybb503372010-05-27 20:51:26 +00004513 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004514 ThrowMogrifyException(OptionError,"MissingArgument",option);
4515 if (IsGeometry(argv[i]) == MagickFalse)
4516 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4517 break;
4518 }
4519 if (LocaleCompare("extract",option+1) == 0)
4520 {
4521 if (*option == '+')
4522 break;
4523 i++;
cristybb503372010-05-27 20:51:26 +00004524 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004525 ThrowMogrifyException(OptionError,"MissingArgument",option);
4526 if (IsGeometry(argv[i]) == MagickFalse)
4527 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4528 break;
4529 }
4530 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4531 }
4532 case 'f':
4533 {
4534 if (LocaleCompare("family",option+1) == 0)
4535 {
4536 if (*option == '+')
4537 break;
4538 i++;
cristybb503372010-05-27 20:51:26 +00004539 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004540 ThrowMogrifyException(OptionError,"MissingArgument",option);
4541 break;
4542 }
4543 if (LocaleCompare("fill",option+1) == 0)
4544 {
4545 if (*option == '+')
4546 break;
4547 i++;
cristybb503372010-05-27 20:51:26 +00004548 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004549 ThrowMogrifyException(OptionError,"MissingArgument",option);
4550 break;
4551 }
4552 if (LocaleCompare("filter",option+1) == 0)
4553 {
cristybb503372010-05-27 20:51:26 +00004554 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004555 filter;
4556
4557 if (*option == '+')
4558 break;
4559 i++;
cristybb503372010-05-27 20:51:26 +00004560 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004561 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004562 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004563 if (filter < 0)
4564 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4565 argv[i]);
4566 break;
4567 }
4568 if (LocaleCompare("flatten",option+1) == 0)
4569 break;
4570 if (LocaleCompare("flip",option+1) == 0)
4571 break;
4572 if (LocaleCompare("flop",option+1) == 0)
4573 break;
4574 if (LocaleCompare("floodfill",option+1) == 0)
4575 {
4576 if (*option == '+')
4577 break;
4578 i++;
cristybb503372010-05-27 20:51:26 +00004579 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004580 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (IsGeometry(argv[i]) == MagickFalse)
4582 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4583 i++;
cristybb503372010-05-27 20:51:26 +00004584 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004585 ThrowMogrifyException(OptionError,"MissingArgument",option);
4586 break;
4587 }
4588 if (LocaleCompare("font",option+1) == 0)
4589 {
4590 if (*option == '+')
4591 break;
4592 i++;
cristybb503372010-05-27 20:51:26 +00004593 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004594 ThrowMogrifyException(OptionError,"MissingArgument",option);
4595 break;
4596 }
4597 if (LocaleCompare("format",option+1) == 0)
4598 {
4599 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4600 (void) CloneString(&format,(char *) NULL);
4601 if (*option == '+')
4602 break;
4603 i++;
cristybb503372010-05-27 20:51:26 +00004604 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004605 ThrowMogrifyException(OptionError,"MissingArgument",option);
4606 (void) CloneString(&format,argv[i]);
4607 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4608 (void) ConcatenateMagickString(image_info->filename,":",
4609 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00004610 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00004611 if (*image_info->magick == '\0')
4612 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4613 format);
4614 break;
4615 }
4616 if (LocaleCompare("frame",option+1) == 0)
4617 {
4618 if (*option == '+')
4619 break;
4620 i++;
cristybb503372010-05-27 20:51:26 +00004621 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004622 ThrowMogrifyException(OptionError,"MissingArgument",option);
4623 if (IsGeometry(argv[i]) == MagickFalse)
4624 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4625 break;
4626 }
4627 if (LocaleCompare("function",option+1) == 0)
4628 {
cristybb503372010-05-27 20:51:26 +00004629 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004630 op;
4631
4632 if (*option == '+')
4633 break;
4634 i++;
cristybb503372010-05-27 20:51:26 +00004635 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004636 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004637 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004638 if (op < 0)
4639 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4640 i++;
cristybb503372010-05-27 20:51:26 +00004641 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004642 ThrowMogrifyException(OptionError,"MissingArgument",option);
4643 break;
4644 }
4645 if (LocaleCompare("fuzz",option+1) == 0)
4646 {
4647 if (*option == '+')
4648 break;
4649 i++;
cristybb503372010-05-27 20:51:26 +00004650 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004651 ThrowMogrifyException(OptionError,"MissingArgument",option);
4652 if (IsGeometry(argv[i]) == MagickFalse)
4653 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4654 break;
4655 }
4656 if (LocaleCompare("fx",option+1) == 0)
4657 {
4658 if (*option == '+')
4659 break;
4660 i++;
cristybb503372010-05-27 20:51:26 +00004661 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004662 ThrowMogrifyException(OptionError,"MissingArgument",option);
4663 break;
4664 }
4665 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4666 }
4667 case 'g':
4668 {
4669 if (LocaleCompare("gamma",option+1) == 0)
4670 {
4671 i++;
cristybb503372010-05-27 20:51:26 +00004672 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004673 ThrowMogrifyException(OptionError,"MissingArgument",option);
4674 if (IsGeometry(argv[i]) == MagickFalse)
4675 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4676 break;
4677 }
4678 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4679 (LocaleCompare("gaussian",option+1) == 0))
4680 {
4681 i++;
cristybb503372010-05-27 20:51:26 +00004682 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004683 ThrowMogrifyException(OptionError,"MissingArgument",option);
4684 if (IsGeometry(argv[i]) == MagickFalse)
4685 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4686 break;
4687 }
4688 if (LocaleCompare("geometry",option+1) == 0)
4689 {
4690 if (*option == '+')
4691 break;
4692 i++;
cristybb503372010-05-27 20:51:26 +00004693 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004694 ThrowMogrifyException(OptionError,"MissingArgument",option);
4695 if (IsGeometry(argv[i]) == MagickFalse)
4696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4697 break;
4698 }
4699 if (LocaleCompare("gravity",option+1) == 0)
4700 {
cristybb503372010-05-27 20:51:26 +00004701 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004702 gravity;
4703
4704 if (*option == '+')
4705 break;
4706 i++;
cristybb503372010-05-27 20:51:26 +00004707 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004708 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004709 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004710 if (gravity < 0)
4711 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4712 argv[i]);
4713 break;
4714 }
4715 if (LocaleCompare("green-primary",option+1) == 0)
4716 {
4717 if (*option == '+')
4718 break;
4719 i++;
cristybb503372010-05-27 20:51:26 +00004720 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004721 ThrowMogrifyException(OptionError,"MissingArgument",option);
4722 if (IsGeometry(argv[i]) == MagickFalse)
4723 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4724 break;
4725 }
4726 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4727 }
4728 case 'h':
4729 {
4730 if (LocaleCompare("hald-clut",option+1) == 0)
4731 break;
4732 if ((LocaleCompare("help",option+1) == 0) ||
4733 (LocaleCompare("-help",option+1) == 0))
4734 return(MogrifyUsage());
4735 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4736 }
4737 case 'i':
4738 {
4739 if (LocaleCompare("identify",option+1) == 0)
4740 break;
4741 if (LocaleCompare("idft",option+1) == 0)
4742 break;
4743 if (LocaleCompare("implode",option+1) == 0)
4744 {
4745 if (*option == '+')
4746 break;
4747 i++;
cristybb503372010-05-27 20:51:26 +00004748 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004749 ThrowMogrifyException(OptionError,"MissingArgument",option);
4750 if (IsGeometry(argv[i]) == MagickFalse)
4751 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4752 break;
4753 }
4754 if (LocaleCompare("intent",option+1) == 0)
4755 {
cristybb503372010-05-27 20:51:26 +00004756 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004757 intent;
4758
4759 if (*option == '+')
4760 break;
4761 i++;
cristybb503372010-05-27 20:51:26 +00004762 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004763 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004764 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004765 if (intent < 0)
4766 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4767 argv[i]);
4768 break;
4769 }
4770 if (LocaleCompare("interlace",option+1) == 0)
4771 {
cristybb503372010-05-27 20:51:26 +00004772 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004773 interlace;
4774
4775 if (*option == '+')
4776 break;
4777 i++;
cristybb503372010-05-27 20:51:26 +00004778 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004779 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004780 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004781 argv[i]);
4782 if (interlace < 0)
4783 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4784 argv[i]);
4785 break;
4786 }
cristyb32b90a2009-09-07 21:45:48 +00004787 if (LocaleCompare("interline-spacing",option+1) == 0)
4788 {
4789 if (*option == '+')
4790 break;
4791 i++;
cristybb503372010-05-27 20:51:26 +00004792 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00004793 ThrowMogrifyException(OptionError,"MissingArgument",option);
4794 if (IsGeometry(argv[i]) == MagickFalse)
4795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4796 break;
4797 }
cristy3ed852e2009-09-05 21:47:34 +00004798 if (LocaleCompare("interpolate",option+1) == 0)
4799 {
cristybb503372010-05-27 20:51:26 +00004800 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004801 interpolate;
4802
4803 if (*option == '+')
4804 break;
4805 i++;
cristybb503372010-05-27 20:51:26 +00004806 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004807 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004808 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004809 argv[i]);
4810 if (interpolate < 0)
4811 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4812 argv[i]);
4813 break;
4814 }
4815 if (LocaleCompare("interword-spacing",option+1) == 0)
4816 {
4817 if (*option == '+')
4818 break;
4819 i++;
cristybb503372010-05-27 20:51:26 +00004820 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004821 ThrowMogrifyException(OptionError,"MissingArgument",option);
4822 if (IsGeometry(argv[i]) == MagickFalse)
4823 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4824 break;
4825 }
4826 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4827 }
4828 case 'k':
4829 {
4830 if (LocaleCompare("kerning",option+1) == 0)
4831 {
4832 if (*option == '+')
4833 break;
4834 i++;
cristybb503372010-05-27 20:51:26 +00004835 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004836 ThrowMogrifyException(OptionError,"MissingArgument",option);
4837 if (IsGeometry(argv[i]) == MagickFalse)
4838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4839 break;
4840 }
4841 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4842 }
4843 case 'l':
4844 {
4845 if (LocaleCompare("label",option+1) == 0)
4846 {
4847 if (*option == '+')
4848 break;
4849 i++;
cristybb503372010-05-27 20:51:26 +00004850 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004851 ThrowMogrifyException(OptionError,"MissingArgument",option);
4852 break;
4853 }
4854 if (LocaleCompare("lat",option+1) == 0)
4855 {
4856 if (*option == '+')
4857 break;
4858 i++;
cristybb503372010-05-27 20:51:26 +00004859 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004860 ThrowMogrifyException(OptionError,"MissingArgument",option);
4861 if (IsGeometry(argv[i]) == MagickFalse)
4862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4863 }
4864 if (LocaleCompare("layers",option+1) == 0)
4865 {
cristybb503372010-05-27 20:51:26 +00004866 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004867 type;
4868
4869 if (*option == '+')
4870 break;
4871 i++;
cristybb503372010-05-27 20:51:26 +00004872 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004873 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004874 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004875 if (type < 0)
4876 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4877 argv[i]);
4878 break;
4879 }
4880 if (LocaleCompare("level",option+1) == 0)
4881 {
4882 i++;
cristybb503372010-05-27 20:51:26 +00004883 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004884 ThrowMogrifyException(OptionError,"MissingArgument",option);
4885 if (IsGeometry(argv[i]) == MagickFalse)
4886 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4887 break;
4888 }
4889 if (LocaleCompare("level-colors",option+1) == 0)
4890 {
4891 i++;
cristybb503372010-05-27 20:51:26 +00004892 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004893 ThrowMogrifyException(OptionError,"MissingArgument",option);
4894 break;
4895 }
4896 if (LocaleCompare("linewidth",option+1) == 0)
4897 {
4898 if (*option == '+')
4899 break;
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("limit",option+1) == 0)
4908 {
4909 char
4910 *p;
4911
4912 double
4913 value;
4914
cristybb503372010-05-27 20:51:26 +00004915 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004916 resource;
4917
4918 if (*option == '+')
4919 break;
4920 i++;
cristybb503372010-05-27 20:51:26 +00004921 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004922 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004923 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004924 argv[i]);
4925 if (resource < 0)
4926 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4927 argv[i]);
4928 i++;
cristybb503372010-05-27 20:51:26 +00004929 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004930 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyc1acd842011-05-19 23:05:47 +00004931 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00004932 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00004933 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4934 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4935 break;
4936 }
4937 if (LocaleCompare("liquid-rescale",option+1) == 0)
4938 {
4939 i++;
cristybb503372010-05-27 20:51:26 +00004940 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004941 ThrowMogrifyException(OptionError,"MissingArgument",option);
4942 if (IsGeometry(argv[i]) == MagickFalse)
4943 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4944 break;
4945 }
4946 if (LocaleCompare("list",option+1) == 0)
4947 {
cristybb503372010-05-27 20:51:26 +00004948 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004949 list;
4950
4951 if (*option == '+')
4952 break;
4953 i++;
cristybb503372010-05-27 20:51:26 +00004954 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004955 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004956 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004957 if (list < 0)
4958 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00004959 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00004960 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00004961 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00004962 }
4963 if (LocaleCompare("log",option+1) == 0)
4964 {
4965 if (*option == '+')
4966 break;
4967 i++;
cristybb503372010-05-27 20:51:26 +00004968 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00004969 (strchr(argv[i],'%') == (char *) NULL))
4970 ThrowMogrifyException(OptionError,"MissingArgument",option);
4971 break;
4972 }
4973 if (LocaleCompare("loop",option+1) == 0)
4974 {
4975 if (*option == '+')
4976 break;
4977 i++;
cristybb503372010-05-27 20:51:26 +00004978 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004979 ThrowMogrifyException(OptionError,"MissingArgument",option);
4980 if (IsGeometry(argv[i]) == MagickFalse)
4981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4982 break;
4983 }
4984 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4985 }
4986 case 'm':
4987 {
4988 if (LocaleCompare("map",option+1) == 0)
4989 {
4990 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4991 if (*option == '+')
4992 break;
4993 i++;
cristybb503372010-05-27 20:51:26 +00004994 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004995 ThrowMogrifyException(OptionError,"MissingArgument",option);
4996 break;
4997 }
4998 if (LocaleCompare("mask",option+1) == 0)
4999 {
5000 if (*option == '+')
5001 break;
5002 i++;
cristybb503372010-05-27 20:51:26 +00005003 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005004 ThrowMogrifyException(OptionError,"MissingArgument",option);
5005 break;
5006 }
5007 if (LocaleCompare("matte",option+1) == 0)
5008 break;
5009 if (LocaleCompare("mattecolor",option+1) == 0)
5010 {
5011 if (*option == '+')
5012 break;
5013 i++;
cristybb503372010-05-27 20:51:26 +00005014 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005015 ThrowMogrifyException(OptionError,"MissingArgument",option);
5016 break;
5017 }
cristyf40785b2010-03-06 02:27:27 +00005018 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005019 break;
cristyf40785b2010-03-06 02:27:27 +00005020 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005021 break;
cristy3ed852e2009-09-05 21:47:34 +00005022 if (LocaleCompare("modulate",option+1) == 0)
5023 {
5024 if (*option == '+')
5025 break;
5026 i++;
cristybb503372010-05-27 20:51:26 +00005027 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005028 ThrowMogrifyException(OptionError,"MissingArgument",option);
5029 if (IsGeometry(argv[i]) == MagickFalse)
5030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5031 break;
5032 }
5033 if (LocaleCompare("median",option+1) == 0)
5034 {
5035 if (*option == '+')
5036 break;
5037 i++;
cristybb503372010-05-27 20:51:26 +00005038 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005039 ThrowMogrifyException(OptionError,"MissingArgument",option);
5040 if (IsGeometry(argv[i]) == MagickFalse)
5041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5042 break;
5043 }
cristy69ec32d2011-02-27 23:57:09 +00005044 if (LocaleCompare("mode",option+1) == 0)
5045 {
5046 if (*option == '+')
5047 break;
5048 i++;
5049 if (i == (ssize_t) argc)
5050 ThrowMogrifyException(OptionError,"MissingArgument",option);
5051 if (IsGeometry(argv[i]) == MagickFalse)
5052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5053 break;
5054 }
cristy3ed852e2009-09-05 21:47:34 +00005055 if (LocaleCompare("monitor",option+1) == 0)
5056 break;
5057 if (LocaleCompare("monochrome",option+1) == 0)
5058 break;
5059 if (LocaleCompare("morph",option+1) == 0)
5060 {
5061 if (*option == '+')
5062 break;
5063 i++;
cristybb503372010-05-27 20:51:26 +00005064 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005065 ThrowMogrifyException(OptionError,"MissingArgument",option);
5066 if (IsGeometry(argv[i]) == MagickFalse)
5067 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5068 break;
5069 }
anthony29188a82010-01-22 10:12:34 +00005070 if (LocaleCompare("morphology",option+1) == 0)
5071 {
anthony29188a82010-01-22 10:12:34 +00005072 char
5073 token[MaxTextExtent];
5074
cristyb6bd4ad2010-08-08 01:12:27 +00005075 KernelInfo
5076 *kernel_info;
5077
5078 ssize_t
5079 op;
5080
anthony29188a82010-01-22 10:12:34 +00005081 i++;
cristybb503372010-05-27 20:51:26 +00005082 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005083 ThrowMogrifyException(OptionError,"MissingArgument",option);
5084 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00005085 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00005086 if (op < 0)
5087 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005088 token);
anthony29188a82010-01-22 10:12:34 +00005089 i++;
cristybb503372010-05-27 20:51:26 +00005090 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005091 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005092 kernel_info=AcquireKernelInfo(argv[i]);
5093 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005094 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005095 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005096 break;
5097 }
cristy3ed852e2009-09-05 21:47:34 +00005098 if (LocaleCompare("mosaic",option+1) == 0)
5099 break;
5100 if (LocaleCompare("motion-blur",option+1) == 0)
5101 {
5102 if (*option == '+')
5103 break;
5104 i++;
cristybb503372010-05-27 20:51:26 +00005105 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005106 ThrowMogrifyException(OptionError,"MissingArgument",option);
5107 if (IsGeometry(argv[i]) == MagickFalse)
5108 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5109 break;
5110 }
5111 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5112 }
5113 case 'n':
5114 {
5115 if (LocaleCompare("negate",option+1) == 0)
5116 break;
5117 if (LocaleCompare("noise",option+1) == 0)
5118 {
5119 i++;
cristybb503372010-05-27 20:51:26 +00005120 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005121 ThrowMogrifyException(OptionError,"MissingArgument",option);
5122 if (*option == '+')
5123 {
cristybb503372010-05-27 20:51:26 +00005124 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005125 noise;
5126
cristy042ee782011-04-22 18:48:30 +00005127 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005128 if (noise < 0)
5129 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5130 argv[i]);
5131 break;
5132 }
5133 if (IsGeometry(argv[i]) == MagickFalse)
5134 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5135 break;
5136 }
5137 if (LocaleCompare("noop",option+1) == 0)
5138 break;
5139 if (LocaleCompare("normalize",option+1) == 0)
5140 break;
5141 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5142 }
5143 case 'o':
5144 {
5145 if (LocaleCompare("opaque",option+1) == 0)
5146 {
cristy3ed852e2009-09-05 21:47:34 +00005147 i++;
cristybb503372010-05-27 20:51:26 +00005148 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005149 ThrowMogrifyException(OptionError,"MissingArgument",option);
5150 break;
5151 }
5152 if (LocaleCompare("ordered-dither",option+1) == 0)
5153 {
5154 if (*option == '+')
5155 break;
5156 i++;
cristybb503372010-05-27 20:51:26 +00005157 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005158 ThrowMogrifyException(OptionError,"MissingArgument",option);
5159 break;
5160 }
5161 if (LocaleCompare("orient",option+1) == 0)
5162 {
cristybb503372010-05-27 20:51:26 +00005163 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005164 orientation;
5165
5166 orientation=UndefinedOrientation;
5167 if (*option == '+')
5168 break;
5169 i++;
cristybb503372010-05-27 20:51:26 +00005170 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005171 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005172 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005173 argv[i]);
5174 if (orientation < 0)
5175 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5176 argv[i]);
5177 break;
5178 }
5179 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5180 }
5181 case 'p':
5182 {
5183 if (LocaleCompare("page",option+1) == 0)
5184 {
5185 if (*option == '+')
5186 break;
5187 i++;
cristybb503372010-05-27 20:51:26 +00005188 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005189 ThrowMogrifyException(OptionError,"MissingArgument",option);
5190 break;
5191 }
5192 if (LocaleCompare("paint",option+1) == 0)
5193 {
5194 if (*option == '+')
5195 break;
5196 i++;
cristybb503372010-05-27 20:51:26 +00005197 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005198 ThrowMogrifyException(OptionError,"MissingArgument",option);
5199 if (IsGeometry(argv[i]) == MagickFalse)
5200 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5201 break;
5202 }
5203 if (LocaleCompare("path",option+1) == 0)
5204 {
5205 (void) CloneString(&path,(char *) NULL);
5206 if (*option == '+')
5207 break;
5208 i++;
cristybb503372010-05-27 20:51:26 +00005209 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005210 ThrowMogrifyException(OptionError,"MissingArgument",option);
5211 (void) CloneString(&path,argv[i]);
5212 break;
5213 }
5214 if (LocaleCompare("pointsize",option+1) == 0)
5215 {
5216 if (*option == '+')
5217 break;
5218 i++;
cristybb503372010-05-27 20:51:26 +00005219 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005220 ThrowMogrifyException(OptionError,"MissingArgument",option);
5221 if (IsGeometry(argv[i]) == MagickFalse)
5222 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5223 break;
5224 }
5225 if (LocaleCompare("polaroid",option+1) == 0)
5226 {
5227 if (*option == '+')
5228 break;
5229 i++;
cristybb503372010-05-27 20:51:26 +00005230 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005231 ThrowMogrifyException(OptionError,"MissingArgument",option);
5232 if (IsGeometry(argv[i]) == MagickFalse)
5233 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5234 break;
5235 }
5236 if (LocaleCompare("posterize",option+1) == 0)
5237 {
5238 if (*option == '+')
5239 break;
5240 i++;
cristybb503372010-05-27 20:51:26 +00005241 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005242 ThrowMogrifyException(OptionError,"MissingArgument",option);
5243 if (IsGeometry(argv[i]) == MagickFalse)
5244 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5245 break;
5246 }
cristye7f51092010-01-17 00:39:37 +00005247 if (LocaleCompare("precision",option+1) == 0)
5248 {
5249 if (*option == '+')
5250 break;
5251 i++;
cristybb503372010-05-27 20:51:26 +00005252 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005253 ThrowMogrifyException(OptionError,"MissingArgument",option);
5254 if (IsGeometry(argv[i]) == MagickFalse)
5255 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5256 break;
5257 }
cristy3ed852e2009-09-05 21:47:34 +00005258 if (LocaleCompare("print",option+1) == 0)
5259 {
5260 if (*option == '+')
5261 break;
5262 i++;
cristybb503372010-05-27 20:51:26 +00005263 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005264 ThrowMogrifyException(OptionError,"MissingArgument",option);
5265 break;
5266 }
5267 if (LocaleCompare("process",option+1) == 0)
5268 {
5269 if (*option == '+')
5270 break;
5271 i++;
cristybb503372010-05-27 20:51:26 +00005272 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005273 ThrowMogrifyException(OptionError,"MissingArgument",option);
5274 break;
5275 }
5276 if (LocaleCompare("profile",option+1) == 0)
5277 {
5278 i++;
cristybb503372010-05-27 20:51:26 +00005279 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005280 ThrowMogrifyException(OptionError,"MissingArgument",option);
5281 break;
5282 }
5283 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5284 }
5285 case 'q':
5286 {
5287 if (LocaleCompare("quality",option+1) == 0)
5288 {
5289 if (*option == '+')
5290 break;
5291 i++;
cristybb503372010-05-27 20:51:26 +00005292 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005293 ThrowMogrifyException(OptionError,"MissingArgument",option);
5294 if (IsGeometry(argv[i]) == MagickFalse)
5295 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5296 break;
5297 }
5298 if (LocaleCompare("quantize",option+1) == 0)
5299 {
cristybb503372010-05-27 20:51:26 +00005300 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005301 colorspace;
5302
5303 if (*option == '+')
5304 break;
5305 i++;
cristybb503372010-05-27 20:51:26 +00005306 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005307 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005308 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005309 argv[i]);
5310 if (colorspace < 0)
5311 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5312 argv[i]);
5313 break;
5314 }
5315 if (LocaleCompare("quiet",option+1) == 0)
5316 break;
5317 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5318 }
5319 case 'r':
5320 {
5321 if (LocaleCompare("radial-blur",option+1) == 0)
5322 {
5323 i++;
cristybb503372010-05-27 20:51:26 +00005324 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005325 ThrowMogrifyException(OptionError,"MissingArgument",option);
5326 if (IsGeometry(argv[i]) == MagickFalse)
5327 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5328 break;
5329 }
5330 if (LocaleCompare("raise",option+1) == 0)
5331 {
5332 i++;
cristybb503372010-05-27 20:51:26 +00005333 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005334 ThrowMogrifyException(OptionError,"MissingArgument",option);
5335 if (IsGeometry(argv[i]) == MagickFalse)
5336 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5337 break;
5338 }
5339 if (LocaleCompare("random-threshold",option+1) == 0)
5340 {
5341 if (*option == '+')
5342 break;
5343 i++;
cristybb503372010-05-27 20:51:26 +00005344 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005345 ThrowMogrifyException(OptionError,"MissingArgument",option);
5346 if (IsGeometry(argv[i]) == MagickFalse)
5347 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5348 break;
5349 }
cristye6365592010-04-02 17:31:23 +00005350 if (LocaleCompare("recolor",option+1) == 0)
5351 {
5352 if (*option == '+')
5353 break;
5354 i++;
cristybb503372010-05-27 20:51:26 +00005355 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005356 ThrowMogrifyException(OptionError,"MissingArgument",option);
5357 if (IsGeometry(argv[i]) == MagickFalse)
5358 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5359 break;
5360 }
cristy3ed852e2009-09-05 21:47:34 +00005361 if (LocaleCompare("red-primary",option+1) == 0)
5362 {
5363 if (*option == '+')
5364 break;
5365 i++;
cristybb503372010-05-27 20:51:26 +00005366 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005367 ThrowMogrifyException(OptionError,"MissingArgument",option);
5368 if (IsGeometry(argv[i]) == MagickFalse)
5369 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5370 }
cristy9f2083a2010-04-22 19:48:05 +00005371 if (LocaleCompare("regard-warnings",option+1) == 0)
5372 break;
cristy3ed852e2009-09-05 21:47:34 +00005373 if (LocaleCompare("region",option+1) == 0)
5374 {
5375 if (*option == '+')
5376 break;
5377 i++;
cristybb503372010-05-27 20:51:26 +00005378 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005379 ThrowMogrifyException(OptionError,"MissingArgument",option);
5380 if (IsGeometry(argv[i]) == MagickFalse)
5381 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5382 break;
5383 }
cristyf0c78232010-03-15 12:53:40 +00005384 if (LocaleCompare("remap",option+1) == 0)
5385 {
5386 if (*option == '+')
5387 break;
5388 i++;
cristybb503372010-05-27 20:51:26 +00005389 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005390 ThrowMogrifyException(OptionError,"MissingArgument",option);
5391 break;
5392 }
cristy3ed852e2009-09-05 21:47:34 +00005393 if (LocaleCompare("render",option+1) == 0)
5394 break;
5395 if (LocaleCompare("repage",option+1) == 0)
5396 {
5397 if (*option == '+')
5398 break;
5399 i++;
cristybb503372010-05-27 20:51:26 +00005400 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005401 ThrowMogrifyException(OptionError,"MissingArgument",option);
5402 if (IsGeometry(argv[i]) == MagickFalse)
5403 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5404 break;
5405 }
5406 if (LocaleCompare("resample",option+1) == 0)
5407 {
5408 if (*option == '+')
5409 break;
5410 i++;
cristybb503372010-05-27 20:51:26 +00005411 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005412 ThrowMogrifyException(OptionError,"MissingArgument",option);
5413 if (IsGeometry(argv[i]) == MagickFalse)
5414 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5415 break;
5416 }
5417 if (LocaleCompare("resize",option+1) == 0)
5418 {
5419 if (*option == '+')
5420 break;
5421 i++;
cristybb503372010-05-27 20:51:26 +00005422 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005423 ThrowMogrifyException(OptionError,"MissingArgument",option);
5424 if (IsGeometry(argv[i]) == MagickFalse)
5425 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5426 break;
5427 }
cristyebbcfea2011-02-25 02:43:54 +00005428 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5429 {
5430 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5431 break;
5432 }
cristy3ed852e2009-09-05 21:47:34 +00005433 if (LocaleCompare("reverse",option+1) == 0)
5434 break;
5435 if (LocaleCompare("roll",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 }
5446 if (LocaleCompare("rotate",option+1) == 0)
5447 {
5448 i++;
cristybb503372010-05-27 20:51:26 +00005449 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005450 ThrowMogrifyException(OptionError,"MissingArgument",option);
5451 if (IsGeometry(argv[i]) == MagickFalse)
5452 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5453 break;
5454 }
5455 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5456 }
5457 case 's':
5458 {
5459 if (LocaleCompare("sample",option+1) == 0)
5460 {
5461 if (*option == '+')
5462 break;
5463 i++;
cristybb503372010-05-27 20:51:26 +00005464 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005465 ThrowMogrifyException(OptionError,"MissingArgument",option);
5466 if (IsGeometry(argv[i]) == MagickFalse)
5467 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5468 break;
5469 }
5470 if (LocaleCompare("sampling-factor",option+1) == 0)
5471 {
5472 if (*option == '+')
5473 break;
5474 i++;
cristybb503372010-05-27 20:51:26 +00005475 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005476 ThrowMogrifyException(OptionError,"MissingArgument",option);
5477 if (IsGeometry(argv[i]) == MagickFalse)
5478 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5479 break;
5480 }
5481 if (LocaleCompare("scale",option+1) == 0)
5482 {
5483 if (*option == '+')
5484 break;
5485 i++;
cristybb503372010-05-27 20:51:26 +00005486 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005487 ThrowMogrifyException(OptionError,"MissingArgument",option);
5488 if (IsGeometry(argv[i]) == MagickFalse)
5489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5490 break;
5491 }
5492 if (LocaleCompare("scene",option+1) == 0)
5493 {
5494 if (*option == '+')
5495 break;
5496 i++;
cristybb503372010-05-27 20:51:26 +00005497 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005498 ThrowMogrifyException(OptionError,"MissingArgument",option);
5499 if (IsGeometry(argv[i]) == MagickFalse)
5500 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5501 break;
5502 }
5503 if (LocaleCompare("seed",option+1) == 0)
5504 {
5505 if (*option == '+')
5506 break;
5507 i++;
cristybb503372010-05-27 20:51:26 +00005508 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005509 ThrowMogrifyException(OptionError,"MissingArgument",option);
5510 if (IsGeometry(argv[i]) == MagickFalse)
5511 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5512 break;
5513 }
5514 if (LocaleCompare("segment",option+1) == 0)
5515 {
5516 if (*option == '+')
5517 break;
5518 i++;
cristybb503372010-05-27 20:51:26 +00005519 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005520 ThrowMogrifyException(OptionError,"MissingArgument",option);
5521 if (IsGeometry(argv[i]) == MagickFalse)
5522 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5523 break;
5524 }
5525 if (LocaleCompare("selective-blur",option+1) == 0)
5526 {
5527 i++;
cristybb503372010-05-27 20:51:26 +00005528 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005529 ThrowMogrifyException(OptionError,"MissingArgument",option);
5530 if (IsGeometry(argv[i]) == MagickFalse)
5531 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5532 break;
5533 }
5534 if (LocaleCompare("separate",option+1) == 0)
5535 break;
5536 if (LocaleCompare("sepia-tone",option+1) == 0)
5537 {
5538 if (*option == '+')
5539 break;
5540 i++;
cristybb503372010-05-27 20:51:26 +00005541 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005542 ThrowMogrifyException(OptionError,"MissingArgument",option);
5543 if (IsGeometry(argv[i]) == MagickFalse)
5544 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5545 break;
5546 }
5547 if (LocaleCompare("set",option+1) == 0)
5548 {
5549 i++;
cristybb503372010-05-27 20:51:26 +00005550 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005551 ThrowMogrifyException(OptionError,"MissingArgument",option);
5552 if (*option == '+')
5553 break;
5554 i++;
cristybb503372010-05-27 20:51:26 +00005555 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5557 break;
5558 }
5559 if (LocaleCompare("shade",option+1) == 0)
5560 {
5561 i++;
cristybb503372010-05-27 20:51:26 +00005562 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005563 ThrowMogrifyException(OptionError,"MissingArgument",option);
5564 if (IsGeometry(argv[i]) == MagickFalse)
5565 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5566 break;
5567 }
5568 if (LocaleCompare("shadow",option+1) == 0)
5569 {
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 if (IsGeometry(argv[i]) == MagickFalse)
5576 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5577 break;
5578 }
5579 if (LocaleCompare("sharpen",option+1) == 0)
5580 {
5581 i++;
cristybb503372010-05-27 20:51:26 +00005582 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005583 ThrowMogrifyException(OptionError,"MissingArgument",option);
5584 if (IsGeometry(argv[i]) == MagickFalse)
5585 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5586 break;
5587 }
5588 if (LocaleCompare("shave",option+1) == 0)
5589 {
5590 if (*option == '+')
5591 break;
5592 i++;
cristybb503372010-05-27 20:51:26 +00005593 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005594 ThrowMogrifyException(OptionError,"MissingArgument",option);
5595 if (IsGeometry(argv[i]) == MagickFalse)
5596 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5597 break;
5598 }
5599 if (LocaleCompare("shear",option+1) == 0)
5600 {
5601 i++;
cristybb503372010-05-27 20:51:26 +00005602 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005603 ThrowMogrifyException(OptionError,"MissingArgument",option);
5604 if (IsGeometry(argv[i]) == MagickFalse)
5605 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5606 break;
5607 }
5608 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5609 {
5610 i++;
cristybb503372010-05-27 20:51:26 +00005611 if (i == (ssize_t) (argc-1))
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("size",option+1) == 0)
5618 {
5619 if (*option == '+')
5620 break;
5621 i++;
cristybb503372010-05-27 20:51:26 +00005622 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005623 ThrowMogrifyException(OptionError,"MissingArgument",option);
5624 if (IsGeometry(argv[i]) == MagickFalse)
5625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5626 break;
5627 }
5628 if (LocaleCompare("sketch",option+1) == 0)
5629 {
5630 if (*option == '+')
5631 break;
5632 i++;
cristybb503372010-05-27 20:51:26 +00005633 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005634 ThrowMogrifyException(OptionError,"MissingArgument",option);
5635 if (IsGeometry(argv[i]) == MagickFalse)
5636 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5637 break;
5638 }
cristy4285d782011-02-09 20:12:28 +00005639 if (LocaleCompare("smush",option+1) == 0)
5640 {
cristy4285d782011-02-09 20:12:28 +00005641 i++;
5642 if (i == (ssize_t) argc)
5643 ThrowMogrifyException(OptionError,"MissingArgument",option);
5644 if (IsGeometry(argv[i]) == MagickFalse)
5645 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00005646 i++;
5647 break;
5648 }
cristy3ed852e2009-09-05 21:47:34 +00005649 if (LocaleCompare("solarize",option+1) == 0)
5650 {
5651 if (*option == '+')
5652 break;
5653 i++;
cristybb503372010-05-27 20:51:26 +00005654 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005655 ThrowMogrifyException(OptionError,"MissingArgument",option);
5656 if (IsGeometry(argv[i]) == MagickFalse)
5657 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5658 break;
5659 }
5660 if (LocaleCompare("sparse-color",option+1) == 0)
5661 {
cristybb503372010-05-27 20:51:26 +00005662 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005663 op;
5664
5665 i++;
cristybb503372010-05-27 20:51:26 +00005666 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005667 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005668 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005669 if (op < 0)
5670 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5671 argv[i]);
5672 i++;
cristybb503372010-05-27 20:51:26 +00005673 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005674 ThrowMogrifyException(OptionError,"MissingArgument",option);
5675 break;
5676 }
5677 if (LocaleCompare("spread",option+1) == 0)
5678 {
5679 if (*option == '+')
5680 break;
5681 i++;
cristybb503372010-05-27 20:51:26 +00005682 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005683 ThrowMogrifyException(OptionError,"MissingArgument",option);
5684 if (IsGeometry(argv[i]) == MagickFalse)
5685 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5686 break;
5687 }
cristy0834d642011-03-18 18:26:08 +00005688 if (LocaleCompare("statistic",option+1) == 0)
5689 {
5690 ssize_t
5691 op;
5692
5693 if (*option == '+')
5694 break;
5695 i++;
5696 if (i == (ssize_t) argc)
5697 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005698 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00005699 if (op < 0)
5700 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5701 argv[i]);
5702 i++;
5703 if (i == (ssize_t) (argc-1))
5704 ThrowMogrifyException(OptionError,"MissingArgument",option);
5705 if (IsGeometry(argv[i]) == MagickFalse)
5706 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5707 break;
5708 }
cristy3ed852e2009-09-05 21:47:34 +00005709 if (LocaleCompare("stretch",option+1) == 0)
5710 {
cristybb503372010-05-27 20:51:26 +00005711 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005712 stretch;
5713
5714 if (*option == '+')
5715 break;
5716 i++;
cristybb503372010-05-27 20:51:26 +00005717 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005718 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005719 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005720 if (stretch < 0)
5721 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5722 argv[i]);
5723 break;
5724 }
5725 if (LocaleCompare("strip",option+1) == 0)
5726 break;
5727 if (LocaleCompare("stroke",option+1) == 0)
5728 {
5729 if (*option == '+')
5730 break;
5731 i++;
cristybb503372010-05-27 20:51:26 +00005732 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005733 ThrowMogrifyException(OptionError,"MissingArgument",option);
5734 break;
5735 }
5736 if (LocaleCompare("strokewidth",option+1) == 0)
5737 {
5738 if (*option == '+')
5739 break;
5740 i++;
cristybb503372010-05-27 20:51:26 +00005741 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005742 ThrowMogrifyException(OptionError,"MissingArgument",option);
5743 if (IsGeometry(argv[i]) == MagickFalse)
5744 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5745 break;
5746 }
5747 if (LocaleCompare("style",option+1) == 0)
5748 {
cristybb503372010-05-27 20:51:26 +00005749 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005750 style;
5751
5752 if (*option == '+')
5753 break;
5754 i++;
cristybb503372010-05-27 20:51:26 +00005755 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005756 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005757 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005758 if (style < 0)
5759 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5760 argv[i]);
5761 break;
5762 }
cristyecb10ff2011-03-22 13:14:03 +00005763 if (LocaleCompare("swap",option+1) == 0)
5764 {
5765 if (*option == '+')
5766 break;
5767 i++;
5768 if (i == (ssize_t) (argc-1))
5769 ThrowMogrifyException(OptionError,"MissingArgument",option);
5770 if (IsGeometry(argv[i]) == MagickFalse)
5771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5772 break;
5773 }
cristy3ed852e2009-09-05 21:47:34 +00005774 if (LocaleCompare("swirl",option+1) == 0)
5775 {
5776 if (*option == '+')
5777 break;
5778 i++;
cristybb503372010-05-27 20:51:26 +00005779 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005780 ThrowMogrifyException(OptionError,"MissingArgument",option);
5781 if (IsGeometry(argv[i]) == MagickFalse)
5782 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5783 break;
5784 }
cristyd9a29192010-10-16 16:49:53 +00005785 if (LocaleCompare("synchronize",option+1) == 0)
5786 break;
cristy3ed852e2009-09-05 21:47:34 +00005787 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5788 }
5789 case 't':
5790 {
5791 if (LocaleCompare("taint",option+1) == 0)
5792 break;
5793 if (LocaleCompare("texture",option+1) == 0)
5794 {
5795 if (*option == '+')
5796 break;
5797 i++;
cristybb503372010-05-27 20:51:26 +00005798 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005799 ThrowMogrifyException(OptionError,"MissingArgument",option);
5800 break;
5801 }
5802 if (LocaleCompare("tile",option+1) == 0)
5803 {
5804 if (*option == '+')
5805 break;
5806 i++;
cristybb503372010-05-27 20:51:26 +00005807 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005808 ThrowMogrifyException(OptionError,"MissingArgument",option);
5809 break;
5810 }
5811 if (LocaleCompare("tile-offset",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 if (IsGeometry(argv[i]) == MagickFalse)
5819 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5820 break;
5821 }
5822 if (LocaleCompare("tint",option+1) == 0)
5823 {
5824 if (*option == '+')
5825 break;
5826 i++;
cristybb503372010-05-27 20:51:26 +00005827 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005828 ThrowMogrifyException(OptionError,"MissingArgument",option);
5829 if (IsGeometry(argv[i]) == MagickFalse)
5830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5831 break;
5832 }
5833 if (LocaleCompare("transform",option+1) == 0)
5834 break;
5835 if (LocaleCompare("transpose",option+1) == 0)
5836 break;
5837 if (LocaleCompare("transverse",option+1) == 0)
5838 break;
5839 if (LocaleCompare("threshold",option+1) == 0)
5840 {
5841 if (*option == '+')
5842 break;
5843 i++;
cristybb503372010-05-27 20:51:26 +00005844 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005845 ThrowMogrifyException(OptionError,"MissingArgument",option);
5846 if (IsGeometry(argv[i]) == MagickFalse)
5847 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5848 break;
5849 }
5850 if (LocaleCompare("thumbnail",option+1) == 0)
5851 {
5852 if (*option == '+')
5853 break;
5854 i++;
cristybb503372010-05-27 20:51:26 +00005855 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005856 ThrowMogrifyException(OptionError,"MissingArgument",option);
5857 if (IsGeometry(argv[i]) == MagickFalse)
5858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5859 break;
5860 }
5861 if (LocaleCompare("transparent",option+1) == 0)
5862 {
5863 i++;
cristybb503372010-05-27 20:51:26 +00005864 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005865 ThrowMogrifyException(OptionError,"MissingArgument",option);
5866 break;
5867 }
5868 if (LocaleCompare("transparent-color",option+1) == 0)
5869 {
5870 if (*option == '+')
5871 break;
5872 i++;
cristybb503372010-05-27 20:51:26 +00005873 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005874 ThrowMogrifyException(OptionError,"MissingArgument",option);
5875 break;
5876 }
5877 if (LocaleCompare("treedepth",option+1) == 0)
5878 {
5879 if (*option == '+')
5880 break;
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 if (IsGeometry(argv[i]) == MagickFalse)
5885 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5886 break;
5887 }
5888 if (LocaleCompare("trim",option+1) == 0)
5889 break;
5890 if (LocaleCompare("type",option+1) == 0)
5891 {
cristybb503372010-05-27 20:51:26 +00005892 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005893 type;
5894
5895 if (*option == '+')
5896 break;
5897 i++;
cristybb503372010-05-27 20:51:26 +00005898 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005899 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005900 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005901 if (type < 0)
5902 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5903 argv[i]);
5904 break;
5905 }
5906 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5907 }
5908 case 'u':
5909 {
5910 if (LocaleCompare("undercolor",option+1) == 0)
5911 {
5912 if (*option == '+')
5913 break;
5914 i++;
cristybb503372010-05-27 20:51:26 +00005915 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005916 ThrowMogrifyException(OptionError,"MissingArgument",option);
5917 break;
5918 }
5919 if (LocaleCompare("unique-colors",option+1) == 0)
5920 break;
5921 if (LocaleCompare("units",option+1) == 0)
5922 {
cristybb503372010-05-27 20:51:26 +00005923 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005924 units;
5925
5926 if (*option == '+')
5927 break;
5928 i++;
cristybb503372010-05-27 20:51:26 +00005929 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005930 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005931 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005932 argv[i]);
5933 if (units < 0)
5934 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5935 argv[i]);
5936 break;
5937 }
5938 if (LocaleCompare("unsharp",option+1) == 0)
5939 {
5940 i++;
cristybb503372010-05-27 20:51:26 +00005941 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005942 ThrowMogrifyException(OptionError,"MissingArgument",option);
5943 if (IsGeometry(argv[i]) == MagickFalse)
5944 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5945 break;
5946 }
5947 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5948 }
5949 case 'v':
5950 {
5951 if (LocaleCompare("verbose",option+1) == 0)
5952 {
5953 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5954 break;
5955 }
5956 if ((LocaleCompare("version",option+1) == 0) ||
5957 (LocaleCompare("-version",option+1) == 0))
5958 {
cristyb51dff52011-05-19 16:55:47 +00005959 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00005960 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00005961 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5962 GetMagickCopyright());
5963 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5964 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00005965 break;
5966 }
5967 if (LocaleCompare("view",option+1) == 0)
5968 {
5969 if (*option == '+')
5970 break;
5971 i++;
cristybb503372010-05-27 20:51:26 +00005972 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005973 ThrowMogrifyException(OptionError,"MissingArgument",option);
5974 break;
5975 }
5976 if (LocaleCompare("vignette",option+1) == 0)
5977 {
5978 if (*option == '+')
5979 break;
5980 i++;
cristybb503372010-05-27 20:51:26 +00005981 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005982 ThrowMogrifyException(OptionError,"MissingArgument",option);
5983 if (IsGeometry(argv[i]) == MagickFalse)
5984 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5985 break;
5986 }
5987 if (LocaleCompare("virtual-pixel",option+1) == 0)
5988 {
cristybb503372010-05-27 20:51:26 +00005989 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005990 method;
5991
5992 if (*option == '+')
5993 break;
5994 i++;
cristybb503372010-05-27 20:51:26 +00005995 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005996 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005997 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005998 argv[i]);
5999 if (method < 0)
6000 ThrowMogrifyException(OptionError,
6001 "UnrecognizedVirtualPixelMethod",argv[i]);
6002 break;
6003 }
6004 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6005 }
6006 case 'w':
6007 {
6008 if (LocaleCompare("wave",option+1) == 0)
6009 {
6010 i++;
cristybb503372010-05-27 20:51:26 +00006011 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6013 if (IsGeometry(argv[i]) == MagickFalse)
6014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6015 break;
6016 }
6017 if (LocaleCompare("weight",option+1) == 0)
6018 {
6019 if (*option == '+')
6020 break;
6021 i++;
cristybb503372010-05-27 20:51:26 +00006022 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006023 ThrowMogrifyException(OptionError,"MissingArgument",option);
6024 break;
6025 }
6026 if (LocaleCompare("white-point",option+1) == 0)
6027 {
6028 if (*option == '+')
6029 break;
6030 i++;
cristybb503372010-05-27 20:51:26 +00006031 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006032 ThrowMogrifyException(OptionError,"MissingArgument",option);
6033 if (IsGeometry(argv[i]) == MagickFalse)
6034 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6035 break;
6036 }
6037 if (LocaleCompare("white-threshold",option+1) == 0)
6038 {
6039 if (*option == '+')
6040 break;
6041 i++;
cristybb503372010-05-27 20:51:26 +00006042 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006043 ThrowMogrifyException(OptionError,"MissingArgument",option);
6044 if (IsGeometry(argv[i]) == MagickFalse)
6045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6046 break;
6047 }
6048 if (LocaleCompare("write",option+1) == 0)
6049 {
6050 i++;
cristybb503372010-05-27 20:51:26 +00006051 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006052 ThrowMogrifyException(OptionError,"MissingArgument",option);
6053 break;
6054 }
6055 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6056 }
6057 case '?':
6058 break;
6059 default:
6060 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6061 }
cristy042ee782011-04-22 18:48:30 +00006062 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6063 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00006064 if (fire != MagickFalse)
6065 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6066 }
6067 if (k != 0)
6068 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006069 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006070 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6071 DestroyMogrify();
6072 return(status != 0 ? MagickTrue : MagickFalse);
6073}
6074
6075/*
6076%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6077% %
6078% %
6079% %
6080+ M o g r i f y I m a g e I n f o %
6081% %
6082% %
6083% %
6084%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6085%
6086% MogrifyImageInfo() applies image processing settings to the image as
6087% prescribed by command line options.
6088%
6089% The format of the MogrifyImageInfo method is:
6090%
6091% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6092% const char **argv,ExceptionInfo *exception)
6093%
6094% A description of each parameter follows:
6095%
6096% o image_info: the image info..
6097%
6098% o argc: Specifies a pointer to an integer describing the number of
6099% elements in the argument vector.
6100%
6101% o argv: Specifies a pointer to a text array containing the command line
6102% arguments.
6103%
6104% o exception: return any errors or warnings in this structure.
6105%
6106*/
6107WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6108 const int argc,const char **argv,ExceptionInfo *exception)
6109{
6110 const char
6111 *option;
6112
6113 GeometryInfo
6114 geometry_info;
6115
cristybb503372010-05-27 20:51:26 +00006116 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006117 count;
6118
cristybb503372010-05-27 20:51:26 +00006119 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006120 i;
6121
6122 /*
6123 Initialize method variables.
6124 */
6125 assert(image_info != (ImageInfo *) NULL);
6126 assert(image_info->signature == MagickSignature);
6127 if (image_info->debug != MagickFalse)
6128 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6129 image_info->filename);
6130 if (argc < 0)
6131 return(MagickTrue);
6132 /*
6133 Set the image settings.
6134 */
cristybb503372010-05-27 20:51:26 +00006135 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006136 {
6137 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00006138 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00006139 continue;
cristy042ee782011-04-22 18:48:30 +00006140 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00006141 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00006142 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006143 break;
6144 switch (*(option+1))
6145 {
6146 case 'a':
6147 {
6148 if (LocaleCompare("adjoin",option+1) == 0)
6149 {
6150 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6151 break;
6152 }
6153 if (LocaleCompare("antialias",option+1) == 0)
6154 {
6155 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6156 break;
6157 }
cristy3ed852e2009-09-05 21:47:34 +00006158 if (LocaleCompare("authenticate",option+1) == 0)
6159 {
6160 if (*option == '+')
anthony1afdc7a2011-10-05 11:54:28 +00006161 (void) DeleteImageOption(image_info,option+1);
cristy3ed852e2009-09-05 21:47:34 +00006162 else
anthony1afdc7a2011-10-05 11:54:28 +00006163 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006164 break;
6165 }
6166 break;
6167 }
6168 case 'b':
6169 {
6170 if (LocaleCompare("background",option+1) == 0)
6171 {
6172 if (*option == '+')
6173 {
6174 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006175 (void) QueryColorCompliance(MogrifyBackgroundColor,
6176 AllCompliance,&image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006177 break;
6178 }
6179 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006180 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6181 &image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006182 break;
6183 }
6184 if (LocaleCompare("bias",option+1) == 0)
6185 {
6186 if (*option == '+')
6187 {
6188 (void) SetImageOption(image_info,option+1,"0.0");
6189 break;
6190 }
6191 (void) SetImageOption(image_info,option+1,argv[i+1]);
6192 break;
6193 }
6194 if (LocaleCompare("black-point-compensation",option+1) == 0)
6195 {
6196 if (*option == '+')
6197 {
6198 (void) SetImageOption(image_info,option+1,"false");
6199 break;
6200 }
6201 (void) SetImageOption(image_info,option+1,"true");
6202 break;
6203 }
6204 if (LocaleCompare("blue-primary",option+1) == 0)
6205 {
6206 if (*option == '+')
6207 {
6208 (void) SetImageOption(image_info,option+1,"0.0");
6209 break;
6210 }
6211 (void) SetImageOption(image_info,option+1,argv[i+1]);
6212 break;
6213 }
6214 if (LocaleCompare("bordercolor",option+1) == 0)
6215 {
6216 if (*option == '+')
6217 {
6218 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006219 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006220 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006221 break;
6222 }
cristy9950d572011-10-01 18:22:35 +00006223 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6224 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006225 (void) SetImageOption(image_info,option+1,argv[i+1]);
6226 break;
6227 }
6228 if (LocaleCompare("box",option+1) == 0)
6229 {
6230 if (*option == '+')
6231 {
6232 (void) SetImageOption(image_info,"undercolor","none");
6233 break;
6234 }
6235 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6236 break;
6237 }
6238 break;
6239 }
6240 case 'c':
6241 {
6242 if (LocaleCompare("cache",option+1) == 0)
6243 {
6244 MagickSizeType
6245 limit;
6246
6247 limit=MagickResourceInfinity;
6248 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006249 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006250 (void) SetMagickResourceLimit(MemoryResource,limit);
6251 (void) SetMagickResourceLimit(MapResource,2*limit);
6252 break;
6253 }
6254 if (LocaleCompare("caption",option+1) == 0)
6255 {
6256 if (*option == '+')
6257 {
6258 (void) DeleteImageOption(image_info,option+1);
6259 break;
6260 }
6261 (void) SetImageOption(image_info,option+1,argv[i+1]);
6262 break;
6263 }
6264 if (LocaleCompare("channel",option+1) == 0)
6265 {
6266 if (*option == '+')
6267 {
6268 image_info->channel=DefaultChannels;
6269 break;
6270 }
6271 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6272 break;
6273 }
cristy3ed852e2009-09-05 21:47:34 +00006274 if (LocaleCompare("colorspace",option+1) == 0)
6275 {
6276 if (*option == '+')
6277 {
6278 image_info->colorspace=UndefinedColorspace;
6279 (void) SetImageOption(image_info,option+1,"undefined");
6280 break;
6281 }
cristy042ee782011-04-22 18:48:30 +00006282 image_info->colorspace=(ColorspaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006283 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6284 (void) SetImageOption(image_info,option+1,argv[i+1]);
6285 break;
6286 }
cristy3ed852e2009-09-05 21:47:34 +00006287 if (LocaleCompare("comment",option+1) == 0)
6288 {
6289 if (*option == '+')
6290 {
6291 (void) DeleteImageOption(image_info,option+1);
6292 break;
6293 }
6294 (void) SetImageOption(image_info,option+1,argv[i+1]);
6295 break;
6296 }
6297 if (LocaleCompare("compose",option+1) == 0)
6298 {
6299 if (*option == '+')
6300 {
6301 (void) SetImageOption(image_info,option+1,"undefined");
6302 break;
6303 }
6304 (void) SetImageOption(image_info,option+1,argv[i+1]);
6305 break;
6306 }
6307 if (LocaleCompare("compress",option+1) == 0)
6308 {
6309 if (*option == '+')
6310 {
6311 image_info->compression=UndefinedCompression;
6312 (void) SetImageOption(image_info,option+1,"undefined");
6313 break;
6314 }
cristy042ee782011-04-22 18:48:30 +00006315 image_info->compression=(CompressionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006316 MagickCompressOptions,MagickFalse,argv[i+1]);
6317 (void) SetImageOption(image_info,option+1,argv[i+1]);
6318 break;
6319 }
6320 break;
6321 }
6322 case 'd':
6323 {
6324 if (LocaleCompare("debug",option+1) == 0)
6325 {
6326 if (*option == '+')
6327 (void) SetLogEventMask("none");
6328 else
6329 (void) SetLogEventMask(argv[i+1]);
6330 image_info->debug=IsEventLogging();
6331 break;
6332 }
6333 if (LocaleCompare("define",option+1) == 0)
6334 {
6335 if (*option == '+')
6336 {
6337 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6338 (void) DeleteImageRegistry(argv[i+1]+9);
6339 else
6340 (void) DeleteImageOption(image_info,argv[i+1]);
6341 break;
6342 }
6343 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6344 {
6345 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6346 exception);
6347 break;
6348 }
6349 (void) DefineImageOption(image_info,argv[i+1]);
6350 break;
6351 }
6352 if (LocaleCompare("delay",option+1) == 0)
6353 {
6354 if (*option == '+')
6355 {
6356 (void) SetImageOption(image_info,option+1,"0");
6357 break;
6358 }
6359 (void) SetImageOption(image_info,option+1,argv[i+1]);
6360 break;
6361 }
6362 if (LocaleCompare("density",option+1) == 0)
6363 {
6364 /*
6365 Set image density.
6366 */
6367 if (*option == '+')
6368 {
6369 if (image_info->density != (char *) NULL)
6370 image_info->density=DestroyString(image_info->density);
6371 (void) SetImageOption(image_info,option+1,"72");
6372 break;
6373 }
6374 (void) CloneString(&image_info->density,argv[i+1]);
6375 (void) SetImageOption(image_info,option+1,argv[i+1]);
6376 break;
6377 }
6378 if (LocaleCompare("depth",option+1) == 0)
6379 {
6380 if (*option == '+')
6381 {
6382 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6383 break;
6384 }
cristye27293e2009-12-18 02:53:20 +00006385 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006386 break;
6387 }
cristyc9b12952010-03-28 01:12:28 +00006388 if (LocaleCompare("direction",option+1) == 0)
6389 {
6390 if (*option == '+')
6391 {
6392 (void) SetImageOption(image_info,option+1,"undefined");
6393 break;
6394 }
6395 (void) SetImageOption(image_info,option+1,argv[i+1]);
6396 break;
6397 }
cristy3ed852e2009-09-05 21:47:34 +00006398 if (LocaleCompare("display",option+1) == 0)
6399 {
6400 if (*option == '+')
6401 {
6402 if (image_info->server_name != (char *) NULL)
6403 image_info->server_name=DestroyString(
6404 image_info->server_name);
6405 break;
6406 }
6407 (void) CloneString(&image_info->server_name,argv[i+1]);
6408 break;
6409 }
6410 if (LocaleCompare("dispose",option+1) == 0)
6411 {
6412 if (*option == '+')
6413 {
6414 (void) SetImageOption(image_info,option+1,"undefined");
6415 break;
6416 }
6417 (void) SetImageOption(image_info,option+1,argv[i+1]);
6418 break;
6419 }
6420 if (LocaleCompare("dither",option+1) == 0)
6421 {
6422 if (*option == '+')
6423 {
6424 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006425 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006426 break;
6427 }
6428 (void) SetImageOption(image_info,option+1,argv[i+1]);
6429 image_info->dither=MagickTrue;
6430 break;
6431 }
6432 break;
6433 }
6434 case 'e':
6435 {
6436 if (LocaleCompare("encoding",option+1) == 0)
6437 {
6438 if (*option == '+')
6439 {
6440 (void) SetImageOption(image_info,option+1,"undefined");
6441 break;
6442 }
6443 (void) SetImageOption(image_info,option+1,argv[i+1]);
6444 break;
6445 }
6446 if (LocaleCompare("endian",option+1) == 0)
6447 {
6448 if (*option == '+')
6449 {
6450 image_info->endian=UndefinedEndian;
6451 (void) SetImageOption(image_info,option+1,"undefined");
6452 break;
6453 }
cristy042ee782011-04-22 18:48:30 +00006454 image_info->endian=(EndianType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006455 MagickEndianOptions,MagickFalse,argv[i+1]);
6456 (void) SetImageOption(image_info,option+1,argv[i+1]);
6457 break;
6458 }
6459 if (LocaleCompare("extract",option+1) == 0)
6460 {
6461 /*
6462 Set image extract geometry.
6463 */
6464 if (*option == '+')
6465 {
6466 if (image_info->extract != (char *) NULL)
6467 image_info->extract=DestroyString(image_info->extract);
6468 break;
6469 }
6470 (void) CloneString(&image_info->extract,argv[i+1]);
6471 break;
6472 }
6473 break;
6474 }
6475 case 'f':
6476 {
6477 if (LocaleCompare("fill",option+1) == 0)
6478 {
6479 if (*option == '+')
6480 {
6481 (void) SetImageOption(image_info,option+1,"none");
6482 break;
6483 }
6484 (void) SetImageOption(image_info,option+1,argv[i+1]);
6485 break;
6486 }
6487 if (LocaleCompare("filter",option+1) == 0)
6488 {
6489 if (*option == '+')
6490 {
6491 (void) SetImageOption(image_info,option+1,"undefined");
6492 break;
6493 }
6494 (void) SetImageOption(image_info,option+1,argv[i+1]);
6495 break;
6496 }
6497 if (LocaleCompare("font",option+1) == 0)
6498 {
6499 if (*option == '+')
6500 {
6501 if (image_info->font != (char *) NULL)
6502 image_info->font=DestroyString(image_info->font);
6503 break;
6504 }
6505 (void) CloneString(&image_info->font,argv[i+1]);
6506 break;
6507 }
6508 if (LocaleCompare("format",option+1) == 0)
6509 {
6510 register const char
6511 *q;
6512
6513 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006514 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006515 image_info->ping=MagickFalse;
6516 (void) SetImageOption(image_info,option+1,argv[i+1]);
6517 break;
6518 }
6519 if (LocaleCompare("fuzz",option+1) == 0)
6520 {
6521 if (*option == '+')
6522 {
6523 image_info->fuzz=0.0;
6524 (void) SetImageOption(image_info,option+1,"0");
6525 break;
6526 }
cristyf2f27272009-12-17 14:48:46 +00006527 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006528 1.0);
6529 (void) SetImageOption(image_info,option+1,argv[i+1]);
6530 break;
6531 }
6532 break;
6533 }
6534 case 'g':
6535 {
6536 if (LocaleCompare("gravity",option+1) == 0)
6537 {
6538 if (*option == '+')
6539 {
6540 (void) SetImageOption(image_info,option+1,"undefined");
6541 break;
6542 }
6543 (void) SetImageOption(image_info,option+1,argv[i+1]);
6544 break;
6545 }
6546 if (LocaleCompare("green-primary",option+1) == 0)
6547 {
6548 if (*option == '+')
6549 {
6550 (void) SetImageOption(image_info,option+1,"0.0");
6551 break;
6552 }
6553 (void) SetImageOption(image_info,option+1,argv[i+1]);
6554 break;
6555 }
6556 break;
6557 }
6558 case 'i':
6559 {
6560 if (LocaleCompare("intent",option+1) == 0)
6561 {
6562 if (*option == '+')
6563 {
6564 (void) SetImageOption(image_info,option+1,"undefined");
6565 break;
6566 }
6567 (void) SetImageOption(image_info,option+1,argv[i+1]);
6568 break;
6569 }
6570 if (LocaleCompare("interlace",option+1) == 0)
6571 {
6572 if (*option == '+')
6573 {
6574 image_info->interlace=UndefinedInterlace;
6575 (void) SetImageOption(image_info,option+1,"undefined");
6576 break;
6577 }
cristy042ee782011-04-22 18:48:30 +00006578 image_info->interlace=(InterlaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006579 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6580 (void) SetImageOption(image_info,option+1,argv[i+1]);
6581 break;
6582 }
cristyb32b90a2009-09-07 21:45:48 +00006583 if (LocaleCompare("interline-spacing",option+1) == 0)
6584 {
6585 if (*option == '+')
6586 {
6587 (void) SetImageOption(image_info,option+1,"undefined");
6588 break;
6589 }
6590 (void) SetImageOption(image_info,option+1,argv[i+1]);
6591 break;
6592 }
cristy3ed852e2009-09-05 21:47:34 +00006593 if (LocaleCompare("interpolate",option+1) == 0)
6594 {
6595 if (*option == '+')
6596 {
6597 (void) SetImageOption(image_info,option+1,"undefined");
6598 break;
6599 }
6600 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 break;
6602 }
6603 if (LocaleCompare("interword-spacing",option+1) == 0)
6604 {
6605 if (*option == '+')
6606 {
6607 (void) SetImageOption(image_info,option+1,"undefined");
6608 break;
6609 }
6610 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 break;
6612 }
6613 break;
6614 }
6615 case 'k':
6616 {
6617 if (LocaleCompare("kerning",option+1) == 0)
6618 {
6619 if (*option == '+')
6620 {
6621 (void) SetImageOption(image_info,option+1,"undefined");
6622 break;
6623 }
6624 (void) SetImageOption(image_info,option+1,argv[i+1]);
6625 break;
6626 }
6627 break;
6628 }
6629 case 'l':
6630 {
6631 if (LocaleCompare("label",option+1) == 0)
6632 {
6633 if (*option == '+')
6634 {
6635 (void) DeleteImageOption(image_info,option+1);
6636 break;
6637 }
6638 (void) SetImageOption(image_info,option+1,argv[i+1]);
6639 break;
6640 }
6641 if (LocaleCompare("limit",option+1) == 0)
6642 {
6643 MagickSizeType
6644 limit;
6645
6646 ResourceType
6647 type;
6648
6649 if (*option == '+')
6650 break;
cristy042ee782011-04-22 18:48:30 +00006651 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
cristy3ed852e2009-09-05 21:47:34 +00006652 MagickFalse,argv[i+1]);
6653 limit=MagickResourceInfinity;
6654 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006655 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006656 (void) SetMagickResourceLimit(type,limit);
6657 break;
6658 }
6659 if (LocaleCompare("list",option+1) == 0)
6660 {
cristybb503372010-05-27 20:51:26 +00006661 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006662 list;
6663
6664 /*
6665 Display configuration list.
6666 */
cristy042ee782011-04-22 18:48:30 +00006667 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006668 switch (list)
6669 {
6670 case MagickCoderOptions:
6671 {
6672 (void) ListCoderInfo((FILE *) NULL,exception);
6673 break;
6674 }
6675 case MagickColorOptions:
6676 {
6677 (void) ListColorInfo((FILE *) NULL,exception);
6678 break;
6679 }
6680 case MagickConfigureOptions:
6681 {
6682 (void) ListConfigureInfo((FILE *) NULL,exception);
6683 break;
6684 }
6685 case MagickDelegateOptions:
6686 {
6687 (void) ListDelegateInfo((FILE *) NULL,exception);
6688 break;
6689 }
6690 case MagickFontOptions:
6691 {
6692 (void) ListTypeInfo((FILE *) NULL,exception);
6693 break;
6694 }
6695 case MagickFormatOptions:
6696 {
6697 (void) ListMagickInfo((FILE *) NULL,exception);
6698 break;
6699 }
6700 case MagickLocaleOptions:
6701 {
6702 (void) ListLocaleInfo((FILE *) NULL,exception);
6703 break;
6704 }
6705 case MagickLogOptions:
6706 {
6707 (void) ListLogInfo((FILE *) NULL,exception);
6708 break;
6709 }
6710 case MagickMagicOptions:
6711 {
6712 (void) ListMagicInfo((FILE *) NULL,exception);
6713 break;
6714 }
6715 case MagickMimeOptions:
6716 {
6717 (void) ListMimeInfo((FILE *) NULL,exception);
6718 break;
6719 }
6720 case MagickModuleOptions:
6721 {
6722 (void) ListModuleInfo((FILE *) NULL,exception);
6723 break;
6724 }
6725 case MagickPolicyOptions:
6726 {
6727 (void) ListPolicyInfo((FILE *) NULL,exception);
6728 break;
6729 }
6730 case MagickResourceOptions:
6731 {
6732 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6733 break;
6734 }
6735 case MagickThresholdOptions:
6736 {
6737 (void) ListThresholdMaps((FILE *) NULL,exception);
6738 break;
6739 }
6740 default:
6741 {
cristy042ee782011-04-22 18:48:30 +00006742 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
cristy3ed852e2009-09-05 21:47:34 +00006743 exception);
6744 break;
6745 }
6746 }
cristyaeb2cbc2010-05-07 13:28:58 +00006747 break;
cristy3ed852e2009-09-05 21:47:34 +00006748 }
6749 if (LocaleCompare("log",option+1) == 0)
6750 {
6751 if (*option == '+')
6752 break;
6753 (void) SetLogFormat(argv[i+1]);
6754 break;
6755 }
6756 if (LocaleCompare("loop",option+1) == 0)
6757 {
6758 if (*option == '+')
6759 {
6760 (void) SetImageOption(image_info,option+1,"0");
6761 break;
6762 }
6763 (void) SetImageOption(image_info,option+1,argv[i+1]);
6764 break;
6765 }
6766 break;
6767 }
6768 case 'm':
6769 {
6770 if (LocaleCompare("matte",option+1) == 0)
6771 {
6772 if (*option == '+')
6773 {
6774 (void) SetImageOption(image_info,option+1,"false");
6775 break;
6776 }
6777 (void) SetImageOption(image_info,option+1,"true");
6778 break;
6779 }
6780 if (LocaleCompare("mattecolor",option+1) == 0)
6781 {
6782 if (*option == '+')
6783 {
6784 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006785 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006786 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006787 break;
6788 }
6789 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006790 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6791 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006792 break;
6793 }
6794 if (LocaleCompare("monitor",option+1) == 0)
6795 {
6796 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6797 (void *) NULL);
6798 break;
6799 }
6800 if (LocaleCompare("monochrome",option+1) == 0)
6801 {
6802 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6803 break;
6804 }
6805 break;
6806 }
6807 case 'o':
6808 {
6809 if (LocaleCompare("orient",option+1) == 0)
6810 {
6811 if (*option == '+')
6812 {
6813 image_info->orientation=UndefinedOrientation;
6814 (void) SetImageOption(image_info,option+1,"undefined");
6815 break;
6816 }
cristy042ee782011-04-22 18:48:30 +00006817 image_info->orientation=(OrientationType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006818 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00006819 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006820 break;
6821 }
6822 }
6823 case 'p':
6824 {
6825 if (LocaleCompare("page",option+1) == 0)
6826 {
6827 char
6828 *canonical_page,
6829 page[MaxTextExtent];
6830
6831 const char
6832 *image_option;
6833
6834 MagickStatusType
6835 flags;
6836
6837 RectangleInfo
6838 geometry;
6839
6840 if (*option == '+')
6841 {
6842 (void) DeleteImageOption(image_info,option+1);
6843 (void) CloneString(&image_info->page,(char *) NULL);
6844 break;
6845 }
6846 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6847 image_option=GetImageOption(image_info,"page");
6848 if (image_option != (const char *) NULL)
6849 flags=ParseAbsoluteGeometry(image_option,&geometry);
6850 canonical_page=GetPageGeometry(argv[i+1]);
6851 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6852 canonical_page=DestroyString(canonical_page);
cristyb51dff52011-05-19 16:55:47 +00006853 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00006854 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00006855 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
cristyb51dff52011-05-19 16:55:47 +00006856 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00006857 (unsigned long) geometry.width,(unsigned long) geometry.height,
6858 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00006859 (void) SetImageOption(image_info,option+1,page);
6860 (void) CloneString(&image_info->page,page);
6861 break;
6862 }
6863 if (LocaleCompare("pen",option+1) == 0)
6864 {
6865 if (*option == '+')
6866 {
6867 (void) SetImageOption(image_info,option+1,"none");
6868 break;
6869 }
6870 (void) SetImageOption(image_info,option+1,argv[i+1]);
6871 break;
6872 }
6873 if (LocaleCompare("ping",option+1) == 0)
6874 {
6875 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6876 break;
6877 }
6878 if (LocaleCompare("pointsize",option+1) == 0)
6879 {
6880 if (*option == '+')
6881 geometry_info.rho=0.0;
6882 else
6883 (void) ParseGeometry(argv[i+1],&geometry_info);
6884 image_info->pointsize=geometry_info.rho;
6885 break;
6886 }
cristye7f51092010-01-17 00:39:37 +00006887 if (LocaleCompare("precision",option+1) == 0)
6888 {
cristybf2766a2010-01-17 03:33:23 +00006889 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00006890 break;
6891 }
cristy3ed852e2009-09-05 21:47:34 +00006892 if (LocaleCompare("preview",option+1) == 0)
6893 {
6894 /*
6895 Preview image.
6896 */
6897 if (*option == '+')
6898 {
6899 image_info->preview_type=UndefinedPreview;
6900 break;
6901 }
cristy042ee782011-04-22 18:48:30 +00006902 image_info->preview_type=(PreviewType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006903 MagickPreviewOptions,MagickFalse,argv[i+1]);
6904 break;
6905 }
6906 break;
6907 }
6908 case 'q':
6909 {
6910 if (LocaleCompare("quality",option+1) == 0)
6911 {
6912 /*
6913 Set image compression quality.
6914 */
6915 if (*option == '+')
6916 {
6917 image_info->quality=UndefinedCompressionQuality;
6918 (void) SetImageOption(image_info,option+1,"0");
6919 break;
6920 }
cristye27293e2009-12-18 02:53:20 +00006921 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006922 (void) SetImageOption(image_info,option+1,argv[i+1]);
6923 break;
6924 }
6925 if (LocaleCompare("quiet",option+1) == 0)
6926 {
6927 static WarningHandler
6928 warning_handler = (WarningHandler) NULL;
6929
6930 if (*option == '+')
6931 {
6932 /*
6933 Restore error or warning messages.
6934 */
6935 warning_handler=SetWarningHandler(warning_handler);
6936 break;
6937 }
6938 /*
6939 Suppress error or warning messages.
6940 */
6941 warning_handler=SetWarningHandler((WarningHandler) NULL);
6942 break;
6943 }
6944 break;
6945 }
6946 case 'r':
6947 {
6948 if (LocaleCompare("red-primary",option+1) == 0)
6949 {
6950 if (*option == '+')
6951 {
6952 (void) SetImageOption(image_info,option+1,"0.0");
6953 break;
6954 }
6955 (void) SetImageOption(image_info,option+1,argv[i+1]);
6956 break;
6957 }
6958 break;
6959 }
6960 case 's':
6961 {
6962 if (LocaleCompare("sampling-factor",option+1) == 0)
6963 {
6964 /*
6965 Set image sampling factor.
6966 */
6967 if (*option == '+')
6968 {
6969 if (image_info->sampling_factor != (char *) NULL)
6970 image_info->sampling_factor=DestroyString(
6971 image_info->sampling_factor);
6972 break;
6973 }
6974 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6975 break;
6976 }
6977 if (LocaleCompare("scene",option+1) == 0)
6978 {
6979 /*
6980 Set image scene.
6981 */
6982 if (*option == '+')
6983 {
6984 image_info->scene=0;
6985 (void) SetImageOption(image_info,option+1,"0");
6986 break;
6987 }
cristye27293e2009-12-18 02:53:20 +00006988 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006989 (void) SetImageOption(image_info,option+1,argv[i+1]);
6990 break;
6991 }
6992 if (LocaleCompare("seed",option+1) == 0)
6993 {
cristybb503372010-05-27 20:51:26 +00006994 size_t
cristy3ed852e2009-09-05 21:47:34 +00006995 seed;
6996
6997 if (*option == '+')
6998 {
cristybb503372010-05-27 20:51:26 +00006999 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007000 SeedPseudoRandomGenerator(seed);
7001 break;
7002 }
cristye27293e2009-12-18 02:53:20 +00007003 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007004 SeedPseudoRandomGenerator(seed);
7005 break;
7006 }
7007 if (LocaleCompare("size",option+1) == 0)
7008 {
7009 if (*option == '+')
7010 {
7011 if (image_info->size != (char *) NULL)
7012 image_info->size=DestroyString(image_info->size);
7013 break;
7014 }
7015 (void) CloneString(&image_info->size,argv[i+1]);
7016 break;
7017 }
7018 if (LocaleCompare("stroke",option+1) == 0)
7019 {
7020 if (*option == '+')
7021 {
7022 (void) SetImageOption(image_info,option+1,"none");
7023 break;
7024 }
7025 (void) SetImageOption(image_info,option+1,argv[i+1]);
7026 break;
7027 }
7028 if (LocaleCompare("strokewidth",option+1) == 0)
7029 {
7030 if (*option == '+')
7031 {
7032 (void) SetImageOption(image_info,option+1,"0");
7033 break;
7034 }
7035 (void) SetImageOption(image_info,option+1,argv[i+1]);
7036 break;
7037 }
cristyd9a29192010-10-16 16:49:53 +00007038 if (LocaleCompare("synchronize",option+1) == 0)
7039 {
7040 if (*option == '+')
7041 {
7042 image_info->synchronize=MagickFalse;
7043 break;
7044 }
7045 image_info->synchronize=MagickTrue;
7046 break;
7047 }
cristy3ed852e2009-09-05 21:47:34 +00007048 break;
7049 }
7050 case 't':
7051 {
7052 if (LocaleCompare("taint",option+1) == 0)
7053 {
7054 if (*option == '+')
7055 {
7056 (void) SetImageOption(image_info,option+1,"false");
7057 break;
7058 }
7059 (void) SetImageOption(image_info,option+1,"true");
7060 break;
7061 }
7062 if (LocaleCompare("texture",option+1) == 0)
7063 {
7064 if (*option == '+')
7065 {
7066 if (image_info->texture != (char *) NULL)
7067 image_info->texture=DestroyString(image_info->texture);
7068 break;
7069 }
7070 (void) CloneString(&image_info->texture,argv[i+1]);
7071 break;
7072 }
7073 if (LocaleCompare("tile-offset",option+1) == 0)
7074 {
7075 if (*option == '+')
7076 {
7077 (void) SetImageOption(image_info,option+1,"0");
7078 break;
7079 }
7080 (void) SetImageOption(image_info,option+1,argv[i+1]);
7081 break;
7082 }
7083 if (LocaleCompare("transparent-color",option+1) == 0)
7084 {
7085 if (*option == '+')
7086 {
cristy9950d572011-10-01 18:22:35 +00007087 (void) QueryColorCompliance("none",AllCompliance,
7088 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007089 (void) SetImageOption(image_info,option+1,"none");
7090 break;
7091 }
cristy9950d572011-10-01 18:22:35 +00007092 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7093 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007094 (void) SetImageOption(image_info,option+1,argv[i+1]);
7095 break;
7096 }
7097 if (LocaleCompare("type",option+1) == 0)
7098 {
7099 if (*option == '+')
7100 {
cristy5f1c1ff2010-12-23 21:38:06 +00007101 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007102 (void) SetImageOption(image_info,option+1,"undefined");
7103 break;
7104 }
cristy042ee782011-04-22 18:48:30 +00007105 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
cristy3ed852e2009-09-05 21:47:34 +00007106 MagickFalse,argv[i+1]);
7107 (void) SetImageOption(image_info,option+1,argv[i+1]);
7108 break;
7109 }
7110 break;
7111 }
7112 case 'u':
7113 {
7114 if (LocaleCompare("undercolor",option+1) == 0)
7115 {
7116 if (*option == '+')
7117 {
7118 (void) DeleteImageOption(image_info,option+1);
7119 break;
7120 }
7121 (void) SetImageOption(image_info,option+1,argv[i+1]);
7122 break;
7123 }
7124 if (LocaleCompare("units",option+1) == 0)
7125 {
7126 if (*option == '+')
7127 {
7128 image_info->units=UndefinedResolution;
7129 (void) SetImageOption(image_info,option+1,"undefined");
7130 break;
7131 }
cristy042ee782011-04-22 18:48:30 +00007132 image_info->units=(ResolutionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007133 MagickResolutionOptions,MagickFalse,argv[i+1]);
7134 (void) SetImageOption(image_info,option+1,argv[i+1]);
7135 break;
7136 }
7137 break;
7138 }
7139 case 'v':
7140 {
7141 if (LocaleCompare("verbose",option+1) == 0)
7142 {
7143 if (*option == '+')
7144 {
7145 image_info->verbose=MagickFalse;
7146 break;
7147 }
7148 image_info->verbose=MagickTrue;
7149 image_info->ping=MagickFalse;
7150 break;
7151 }
7152 if (LocaleCompare("view",option+1) == 0)
7153 {
7154 if (*option == '+')
7155 {
7156 if (image_info->view != (char *) NULL)
7157 image_info->view=DestroyString(image_info->view);
7158 break;
7159 }
7160 (void) CloneString(&image_info->view,argv[i+1]);
7161 break;
7162 }
7163 if (LocaleCompare("virtual-pixel",option+1) == 0)
7164 {
7165 if (*option == '+')
7166 {
7167 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7168 (void) SetImageOption(image_info,option+1,"undefined");
7169 break;
7170 }
7171 image_info->virtual_pixel_method=(VirtualPixelMethod)
cristy042ee782011-04-22 18:48:30 +00007172 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00007173 argv[i+1]);
7174 (void) SetImageOption(image_info,option+1,argv[i+1]);
7175 break;
7176 }
7177 break;
7178 }
7179 case 'w':
7180 {
7181 if (LocaleCompare("white-point",option+1) == 0)
7182 {
7183 if (*option == '+')
7184 {
7185 (void) SetImageOption(image_info,option+1,"0.0");
7186 break;
7187 }
7188 (void) SetImageOption(image_info,option+1,argv[i+1]);
7189 break;
7190 }
7191 break;
7192 }
7193 default:
7194 break;
7195 }
7196 i+=count;
7197 }
7198 return(MagickTrue);
7199}
7200
7201/*
7202%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7203% %
7204% %
7205% %
7206+ M o g r i f y I m a g e L i s t %
7207% %
7208% %
7209% %
7210%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7211%
7212% MogrifyImageList() applies any command line options that might affect the
7213% entire image list (e.g. -append, -coalesce, etc.).
7214%
7215% The format of the MogrifyImage method is:
7216%
7217% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7218% const char **argv,Image **images,ExceptionInfo *exception)
7219%
7220% A description of each parameter follows:
7221%
7222% o image_info: the image info..
7223%
7224% o argc: Specifies a pointer to an integer describing the number of
7225% elements in the argument vector.
7226%
7227% o argv: Specifies a pointer to a text array containing the command line
7228% arguments.
7229%
anthonye9c27192011-03-27 08:07:06 +00007230% o images: pointer to pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00007231%
7232% o exception: return any errors or warnings in this structure.
7233%
7234*/
7235WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7236 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7237{
cristy3ed852e2009-09-05 21:47:34 +00007238 const char
7239 *option;
7240
cristy6b3da3a2010-06-20 02:21:46 +00007241 ImageInfo
7242 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007243
7244 MagickStatusType
7245 status;
7246
cristy28474bf2011-09-11 23:32:52 +00007247 PixelInterpolateMethod
7248 interpolate_method;
7249
cristy3ed852e2009-09-05 21:47:34 +00007250 QuantizeInfo
7251 *quantize_info;
7252
cristybb503372010-05-27 20:51:26 +00007253 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007254 i;
7255
cristy6b3da3a2010-06-20 02:21:46 +00007256 ssize_t
7257 count,
7258 index;
7259
cristy3ed852e2009-09-05 21:47:34 +00007260 /*
7261 Apply options to the image list.
7262 */
7263 assert(image_info != (ImageInfo *) NULL);
7264 assert(image_info->signature == MagickSignature);
7265 assert(images != (Image **) NULL);
anthonye9c27192011-03-27 08:07:06 +00007266 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007267 assert((*images)->signature == MagickSignature);
7268 if ((*images)->debug != MagickFalse)
7269 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7270 (*images)->filename);
7271 if ((argc <= 0) || (*argv == (char *) NULL))
7272 return(MagickTrue);
cristy28474bf2011-09-11 23:32:52 +00007273 interpolate_method=UndefinedInterpolatePixel;
cristy6b3da3a2010-06-20 02:21:46 +00007274 mogrify_info=CloneImageInfo(image_info);
7275 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00007276 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007277 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007278 {
cristy74fe8f12009-10-03 19:09:01 +00007279 if (*images == (Image *) NULL)
7280 break;
cristy3ed852e2009-09-05 21:47:34 +00007281 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00007282 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00007283 continue;
cristy042ee782011-04-22 18:48:30 +00007284 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00007285 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00007286 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007287 break;
cristy6b3da3a2010-06-20 02:21:46 +00007288 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007289 switch (*(option+1))
7290 {
7291 case 'a':
7292 {
7293 if (LocaleCompare("affinity",option+1) == 0)
7294 {
cristy6b3da3a2010-06-20 02:21:46 +00007295 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007296 if (*option == '+')
7297 {
cristy018f07f2011-09-04 21:15:19 +00007298 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7299 exception);
cristy3ed852e2009-09-05 21:47:34 +00007300 break;
7301 }
7302 i++;
7303 break;
7304 }
7305 if (LocaleCompare("append",option+1) == 0)
7306 {
7307 Image
7308 *append_image;
7309
cristy6b3da3a2010-06-20 02:21:46 +00007310 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007311 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7312 MagickFalse,exception);
7313 if (append_image == (Image *) NULL)
7314 {
7315 status=MagickFalse;
7316 break;
7317 }
7318 *images=DestroyImageList(*images);
7319 *images=append_image;
7320 break;
7321 }
7322 if (LocaleCompare("average",option+1) == 0)
7323 {
7324 Image
7325 *average_image;
7326
cristyd18ae7c2010-03-07 17:39:52 +00007327 /*
7328 Average an image sequence (deprecated).
7329 */
cristy6b3da3a2010-06-20 02:21:46 +00007330 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007331 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7332 exception);
cristy3ed852e2009-09-05 21:47:34 +00007333 if (average_image == (Image *) NULL)
7334 {
7335 status=MagickFalse;
7336 break;
7337 }
7338 *images=DestroyImageList(*images);
7339 *images=average_image;
7340 break;
7341 }
7342 break;
7343 }
7344 case 'c':
7345 {
7346 if (LocaleCompare("channel",option+1) == 0)
7347 {
cristyf4ad9df2011-07-08 16:49:03 +00007348 ChannelType
7349 channel;
7350
cristy3ed852e2009-09-05 21:47:34 +00007351 if (*option == '+')
7352 {
7353 channel=DefaultChannels;
7354 break;
7355 }
7356 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00007357 SetPixelChannelMap(*images,channel);
cristy3ed852e2009-09-05 21:47:34 +00007358 break;
7359 }
7360 if (LocaleCompare("clut",option+1) == 0)
7361 {
7362 Image
7363 *clut_image,
7364 *image;
7365
cristy6b3da3a2010-06-20 02:21:46 +00007366 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007367 image=RemoveFirstImageFromList(images);
7368 clut_image=RemoveFirstImageFromList(images);
7369 if (clut_image == (Image *) NULL)
7370 {
7371 status=MagickFalse;
7372 break;
7373 }
cristy28474bf2011-09-11 23:32:52 +00007374 (void) ClutImage(image,clut_image,interpolate_method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007375 clut_image=DestroyImage(clut_image);
cristy3ed852e2009-09-05 21:47:34 +00007376 *images=DestroyImageList(*images);
7377 *images=image;
7378 break;
7379 }
7380 if (LocaleCompare("coalesce",option+1) == 0)
7381 {
7382 Image
7383 *coalesce_image;
7384
cristy6b3da3a2010-06-20 02:21:46 +00007385 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007386 coalesce_image=CoalesceImages(*images,exception);
7387 if (coalesce_image == (Image *) NULL)
7388 {
7389 status=MagickFalse;
7390 break;
7391 }
7392 *images=DestroyImageList(*images);
7393 *images=coalesce_image;
7394 break;
7395 }
7396 if (LocaleCompare("combine",option+1) == 0)
7397 {
7398 Image
7399 *combine_image;
7400
cristy6b3da3a2010-06-20 02:21:46 +00007401 (void) SyncImagesSettings(mogrify_info,*images);
cristy3139dc22011-07-08 00:11:42 +00007402 combine_image=CombineImages(*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007403 if (combine_image == (Image *) NULL)
7404 {
7405 status=MagickFalse;
7406 break;
7407 }
7408 *images=DestroyImageList(*images);
7409 *images=combine_image;
7410 break;
7411 }
7412 if (LocaleCompare("composite",option+1) == 0)
7413 {
7414 Image
7415 *mask_image,
7416 *composite_image,
7417 *image;
7418
7419 RectangleInfo
7420 geometry;
7421
cristy6b3da3a2010-06-20 02:21:46 +00007422 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007423 image=RemoveFirstImageFromList(images);
7424 composite_image=RemoveFirstImageFromList(images);
7425 if (composite_image == (Image *) NULL)
7426 {
7427 status=MagickFalse;
7428 break;
7429 }
7430 (void) TransformImage(&composite_image,(char *) NULL,
cristye941a752011-10-15 01:52:48 +00007431 composite_image->geometry,exception);
cristy3ed852e2009-09-05 21:47:34 +00007432 SetGeometry(composite_image,&geometry);
7433 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7434 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7435 &geometry);
7436 mask_image=RemoveFirstImageFromList(images);
7437 if (mask_image != (Image *) NULL)
7438 {
7439 if ((image->compose == DisplaceCompositeOp) ||
7440 (image->compose == DistortCompositeOp))
7441 {
7442 /*
7443 Merge Y displacement into X displacement image.
7444 */
7445 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
cristye941a752011-10-15 01:52:48 +00007446 mask_image,0,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00007447 mask_image=DestroyImage(mask_image);
7448 }
7449 else
7450 {
7451 /*
7452 Set a blending mask for the composition.
cristy28474bf2011-09-11 23:32:52 +00007453 Posible error, what if image->mask already set.
cristy3ed852e2009-09-05 21:47:34 +00007454 */
7455 image->mask=mask_image;
cristyb3e7c6c2011-07-24 01:43:55 +00007456 (void) NegateImage(image->mask,MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007457 }
7458 }
cristyf4ad9df2011-07-08 16:49:03 +00007459 (void) CompositeImage(image,image->compose,composite_image,
cristye941a752011-10-15 01:52:48 +00007460 geometry.x,geometry.y,exception);
anthonya129f702011-04-14 01:08:48 +00007461 if (mask_image != (Image *) NULL)
7462 mask_image=image->mask=DestroyImage(image->mask);
cristy3ed852e2009-09-05 21:47:34 +00007463 composite_image=DestroyImage(composite_image);
cristy3ed852e2009-09-05 21:47:34 +00007464 *images=DestroyImageList(*images);
7465 *images=image;
7466 break;
7467 }
cristy3ed852e2009-09-05 21:47:34 +00007468 break;
7469 }
7470 case 'd':
7471 {
7472 if (LocaleCompare("deconstruct",option+1) == 0)
7473 {
7474 Image
7475 *deconstruct_image;
7476
cristy6b3da3a2010-06-20 02:21:46 +00007477 (void) SyncImagesSettings(mogrify_info,*images);
cristy8a9106f2011-07-05 14:39:26 +00007478 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
cristy4c08aed2011-07-01 19:47:50 +00007479 exception);
cristy3ed852e2009-09-05 21:47:34 +00007480 if (deconstruct_image == (Image *) NULL)
7481 {
7482 status=MagickFalse;
7483 break;
7484 }
7485 *images=DestroyImageList(*images);
7486 *images=deconstruct_image;
7487 break;
7488 }
7489 if (LocaleCompare("delete",option+1) == 0)
7490 {
7491 if (*option == '+')
7492 DeleteImages(images,"-1",exception);
7493 else
7494 DeleteImages(images,argv[i+1],exception);
7495 break;
7496 }
7497 if (LocaleCompare("dither",option+1) == 0)
7498 {
7499 if (*option == '+')
7500 {
7501 quantize_info->dither=MagickFalse;
7502 break;
7503 }
7504 quantize_info->dither=MagickTrue;
cristy042ee782011-04-22 18:48:30 +00007505 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007506 MagickDitherOptions,MagickFalse,argv[i+1]);
7507 break;
7508 }
cristyecb10ff2011-03-22 13:14:03 +00007509 if (LocaleCompare("duplicate",option+1) == 0)
7510 {
cristy72988482011-03-29 16:34:38 +00007511 Image
7512 *duplicate_images;
cristybf95deb2011-03-23 00:25:36 +00007513
anthony2b6bcae2011-03-23 13:05:34 +00007514 if (*option == '+')
cristy72988482011-03-29 16:34:38 +00007515 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7516 else
7517 {
7518 const char
7519 *p;
7520
anthony2b6bcae2011-03-23 13:05:34 +00007521 size_t
7522 number_duplicates;
anthony9bd15492011-03-23 02:11:13 +00007523
anthony2b6bcae2011-03-23 13:05:34 +00007524 number_duplicates=(size_t) StringToLong(argv[i+1]);
cristy72988482011-03-29 16:34:38 +00007525 p=strchr(argv[i+1],',');
7526 if (p == (const char *) NULL)
7527 duplicate_images=DuplicateImages(*images,number_duplicates,
7528 "-1",exception);
anthony2b6bcae2011-03-23 13:05:34 +00007529 else
cristy72988482011-03-29 16:34:38 +00007530 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7531 exception);
anthony2b6bcae2011-03-23 13:05:34 +00007532 }
7533 AppendImageToList(images, duplicate_images);
7534 (void) SyncImagesSettings(mogrify_info,*images);
cristyecb10ff2011-03-22 13:14:03 +00007535 break;
7536 }
cristy3ed852e2009-09-05 21:47:34 +00007537 break;
7538 }
cristyd18ae7c2010-03-07 17:39:52 +00007539 case 'e':
7540 {
7541 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7542 {
7543 Image
7544 *evaluate_image;
7545
7546 MagickEvaluateOperator
7547 op;
7548
cristy6b3da3a2010-06-20 02:21:46 +00007549 (void) SyncImageSettings(mogrify_info,*images);
cristy28474bf2011-09-11 23:32:52 +00007550 op=(MagickEvaluateOperator) ParseCommandOption(
7551 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristyd18ae7c2010-03-07 17:39:52 +00007552 evaluate_image=EvaluateImages(*images,op,exception);
7553 if (evaluate_image == (Image *) NULL)
7554 {
7555 status=MagickFalse;
7556 break;
7557 }
7558 *images=DestroyImageList(*images);
7559 *images=evaluate_image;
7560 break;
7561 }
7562 break;
7563 }
cristy3ed852e2009-09-05 21:47:34 +00007564 case 'f':
7565 {
cristyf0a247f2009-10-04 00:20:03 +00007566 if (LocaleCompare("fft",option+1) == 0)
7567 {
7568 Image
7569 *fourier_image;
7570
7571 /*
7572 Implements the discrete Fourier transform (DFT).
7573 */
cristy6b3da3a2010-06-20 02:21:46 +00007574 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00007575 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7576 MagickTrue : MagickFalse,exception);
7577 if (fourier_image == (Image *) NULL)
7578 break;
7579 *images=DestroyImage(*images);
7580 *images=fourier_image;
7581 break;
7582 }
cristy3ed852e2009-09-05 21:47:34 +00007583 if (LocaleCompare("flatten",option+1) == 0)
7584 {
7585 Image
7586 *flatten_image;
7587
cristy6b3da3a2010-06-20 02:21:46 +00007588 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007589 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7590 if (flatten_image == (Image *) NULL)
7591 break;
7592 *images=DestroyImageList(*images);
7593 *images=flatten_image;
7594 break;
7595 }
7596 if (LocaleCompare("fx",option+1) == 0)
7597 {
7598 Image
7599 *fx_image;
7600
cristy6b3da3a2010-06-20 02:21:46 +00007601 (void) SyncImagesSettings(mogrify_info,*images);
cristy490408a2011-07-07 14:42:05 +00007602 fx_image=FxImage(*images,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00007603 if (fx_image == (Image *) NULL)
7604 {
7605 status=MagickFalse;
7606 break;
7607 }
7608 *images=DestroyImageList(*images);
7609 *images=fx_image;
7610 break;
7611 }
7612 break;
7613 }
7614 case 'h':
7615 {
7616 if (LocaleCompare("hald-clut",option+1) == 0)
7617 {
7618 Image
7619 *hald_image,
7620 *image;
7621
cristy6b3da3a2010-06-20 02:21:46 +00007622 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007623 image=RemoveFirstImageFromList(images);
7624 hald_image=RemoveFirstImageFromList(images);
7625 if (hald_image == (Image *) NULL)
7626 {
7627 status=MagickFalse;
7628 break;
7629 }
cristy7c0a0a42011-08-23 17:57:25 +00007630 (void) HaldClutImage(image,hald_image,exception);
cristy3ed852e2009-09-05 21:47:34 +00007631 hald_image=DestroyImage(hald_image);
cristy0aff6ea2009-11-14 01:40:53 +00007632 if (*images != (Image *) NULL)
7633 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00007634 *images=image;
7635 break;
7636 }
7637 break;
7638 }
7639 case 'i':
7640 {
7641 if (LocaleCompare("ift",option+1) == 0)
7642 {
7643 Image
cristy8587f882009-11-13 20:28:49 +00007644 *fourier_image,
7645 *magnitude_image,
7646 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00007647
7648 /*
7649 Implements the inverse fourier discrete Fourier transform (DFT).
7650 */
cristy6b3da3a2010-06-20 02:21:46 +00007651 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00007652 magnitude_image=RemoveFirstImageFromList(images);
7653 phase_image=RemoveFirstImageFromList(images);
7654 if (phase_image == (Image *) NULL)
7655 {
7656 status=MagickFalse;
7657 break;
7658 }
7659 fourier_image=InverseFourierTransformImage(magnitude_image,
7660 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007661 if (fourier_image == (Image *) NULL)
7662 break;
cristy0aff6ea2009-11-14 01:40:53 +00007663 if (*images != (Image *) NULL)
7664 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00007665 *images=fourier_image;
7666 break;
7667 }
7668 if (LocaleCompare("insert",option+1) == 0)
7669 {
7670 Image
7671 *p,
7672 *q;
7673
7674 index=0;
7675 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00007676 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007677 p=RemoveLastImageFromList(images);
7678 if (p == (Image *) NULL)
7679 {
7680 (void) ThrowMagickException(exception,GetMagickModule(),
7681 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7682 status=MagickFalse;
7683 break;
7684 }
7685 q=p;
7686 if (index == 0)
7687 PrependImageToList(images,q);
7688 else
cristybb503372010-05-27 20:51:26 +00007689 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00007690 AppendImageToList(images,q);
7691 else
7692 {
7693 q=GetImageFromList(*images,index-1);
7694 if (q == (Image *) NULL)
7695 {
7696 (void) ThrowMagickException(exception,GetMagickModule(),
7697 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7698 status=MagickFalse;
7699 break;
7700 }
7701 InsertImageInList(&q,p);
7702 }
7703 *images=GetFirstImageInList(q);
7704 break;
7705 }
cristy28474bf2011-09-11 23:32:52 +00007706 if (LocaleCompare("interpolate",option+1) == 0)
7707 {
7708 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7709 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7710 break;
7711 }
cristy3ed852e2009-09-05 21:47:34 +00007712 break;
7713 }
7714 case 'l':
7715 {
7716 if (LocaleCompare("layers",option+1) == 0)
7717 {
7718 Image
7719 *layers;
7720
7721 ImageLayerMethod
7722 method;
7723
cristy6b3da3a2010-06-20 02:21:46 +00007724 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007725 layers=(Image *) NULL;
cristy042ee782011-04-22 18:48:30 +00007726 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
cristy3ed852e2009-09-05 21:47:34 +00007727 MagickFalse,argv[i+1]);
7728 switch (method)
7729 {
7730 case CoalesceLayer:
7731 {
7732 layers=CoalesceImages(*images,exception);
7733 break;
7734 }
7735 case CompareAnyLayer:
7736 case CompareClearLayer:
7737 case CompareOverlayLayer:
7738 default:
7739 {
cristy8a9106f2011-07-05 14:39:26 +00007740 layers=CompareImagesLayers(*images,method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007741 break;
7742 }
7743 case MergeLayer:
7744 case FlattenLayer:
7745 case MosaicLayer:
7746 case TrimBoundsLayer:
7747 {
7748 layers=MergeImageLayers(*images,method,exception);
7749 break;
7750 }
7751 case DisposeLayer:
7752 {
7753 layers=DisposeImages(*images,exception);
7754 break;
7755 }
7756 case OptimizeImageLayer:
7757 {
7758 layers=OptimizeImageLayers(*images,exception);
7759 break;
7760 }
7761 case OptimizePlusLayer:
7762 {
7763 layers=OptimizePlusImageLayers(*images,exception);
7764 break;
7765 }
7766 case OptimizeTransLayer:
7767 {
7768 OptimizeImageTransparency(*images,exception);
7769 break;
7770 }
7771 case RemoveDupsLayer:
7772 {
7773 RemoveDuplicateLayers(images,exception);
7774 break;
7775 }
7776 case RemoveZeroLayer:
7777 {
7778 RemoveZeroDelayLayers(images,exception);
7779 break;
7780 }
7781 case OptimizeLayer:
7782 {
7783 /*
7784 General Purpose, GIF Animation Optimizer.
7785 */
7786 layers=CoalesceImages(*images,exception);
7787 if (layers == (Image *) NULL)
7788 {
7789 status=MagickFalse;
7790 break;
7791 }
cristy3ed852e2009-09-05 21:47:34 +00007792 *images=DestroyImageList(*images);
7793 *images=layers;
7794 layers=OptimizeImageLayers(*images,exception);
7795 if (layers == (Image *) NULL)
7796 {
7797 status=MagickFalse;
7798 break;
7799 }
cristy3ed852e2009-09-05 21:47:34 +00007800 *images=DestroyImageList(*images);
7801 *images=layers;
7802 layers=(Image *) NULL;
7803 OptimizeImageTransparency(*images,exception);
cristy018f07f2011-09-04 21:15:19 +00007804 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7805 exception);
cristy3ed852e2009-09-05 21:47:34 +00007806 break;
7807 }
7808 case CompositeLayer:
7809 {
7810 CompositeOperator
7811 compose;
7812
7813 Image
7814 *source;
7815
7816 RectangleInfo
7817 geometry;
7818
7819 /*
7820 Split image sequence at the first 'NULL:' image.
7821 */
7822 source=(*images);
7823 while (source != (Image *) NULL)
7824 {
7825 source=GetNextImageInList(source);
7826 if ((source != (Image *) NULL) &&
7827 (LocaleCompare(source->magick,"NULL") == 0))
7828 break;
7829 }
7830 if (source != (Image *) NULL)
7831 {
7832 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7833 (GetNextImageInList(source) == (Image *) NULL))
7834 source=(Image *) NULL;
7835 else
7836 {
7837 /*
7838 Separate the two lists, junk the null: image.
7839 */
7840 source=SplitImageList(source->previous);
7841 DeleteImageFromList(&source);
7842 }
7843 }
7844 if (source == (Image *) NULL)
7845 {
7846 (void) ThrowMagickException(exception,GetMagickModule(),
7847 OptionError,"MissingNullSeparator","layers Composite");
7848 status=MagickFalse;
7849 break;
7850 }
7851 /*
7852 Adjust offset with gravity and virtual canvas.
7853 */
7854 SetGeometry(*images,&geometry);
7855 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7856 geometry.width=source->page.width != 0 ?
7857 source->page.width : source->columns;
7858 geometry.height=source->page.height != 0 ?
7859 source->page.height : source->rows;
7860 GravityAdjustGeometry((*images)->page.width != 0 ?
7861 (*images)->page.width : (*images)->columns,
7862 (*images)->page.height != 0 ? (*images)->page.height :
7863 (*images)->rows,(*images)->gravity,&geometry);
7864 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00007865 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00007866 if (option != (const char *) NULL)
cristy042ee782011-04-22 18:48:30 +00007867 compose=(CompositeOperator) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007868 MagickComposeOptions,MagickFalse,option);
7869 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7870 exception);
7871 source=DestroyImageList(source);
7872 break;
7873 }
7874 }
7875 if (layers == (Image *) NULL)
7876 break;
cristy3ed852e2009-09-05 21:47:34 +00007877 *images=DestroyImageList(*images);
7878 *images=layers;
7879 break;
7880 }
7881 break;
7882 }
7883 case 'm':
7884 {
7885 if (LocaleCompare("map",option+1) == 0)
7886 {
cristy6b3da3a2010-06-20 02:21:46 +00007887 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007888 if (*option == '+')
7889 {
cristy018f07f2011-09-04 21:15:19 +00007890 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7891 exception);
cristy3ed852e2009-09-05 21:47:34 +00007892 break;
7893 }
7894 i++;
7895 break;
7896 }
cristyf40785b2010-03-06 02:27:27 +00007897 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007898 {
7899 Image
cristyf40785b2010-03-06 02:27:27 +00007900 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007901
cristyd18ae7c2010-03-07 17:39:52 +00007902 /*
7903 Maximum image sequence (deprecated).
7904 */
cristy6b3da3a2010-06-20 02:21:46 +00007905 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007906 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007907 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007908 {
7909 status=MagickFalse;
7910 break;
7911 }
7912 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007913 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007914 break;
7915 }
cristyf40785b2010-03-06 02:27:27 +00007916 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007917 {
7918 Image
cristyf40785b2010-03-06 02:27:27 +00007919 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007920
cristyd18ae7c2010-03-07 17:39:52 +00007921 /*
7922 Minimum image sequence (deprecated).
7923 */
cristy6b3da3a2010-06-20 02:21:46 +00007924 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007925 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007926 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007927 {
7928 status=MagickFalse;
7929 break;
7930 }
7931 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007932 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007933 break;
7934 }
cristy3ed852e2009-09-05 21:47:34 +00007935 if (LocaleCompare("morph",option+1) == 0)
7936 {
7937 Image
7938 *morph_image;
7939
cristy6b3da3a2010-06-20 02:21:46 +00007940 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00007941 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00007942 exception);
7943 if (morph_image == (Image *) NULL)
7944 {
7945 status=MagickFalse;
7946 break;
7947 }
7948 *images=DestroyImageList(*images);
7949 *images=morph_image;
7950 break;
7951 }
7952 if (LocaleCompare("mosaic",option+1) == 0)
7953 {
7954 Image
7955 *mosaic_image;
7956
cristy6b3da3a2010-06-20 02:21:46 +00007957 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007958 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7959 if (mosaic_image == (Image *) NULL)
7960 {
7961 status=MagickFalse;
7962 break;
7963 }
7964 *images=DestroyImageList(*images);
7965 *images=mosaic_image;
7966 break;
7967 }
7968 break;
7969 }
7970 case 'p':
7971 {
7972 if (LocaleCompare("print",option+1) == 0)
7973 {
7974 char
7975 *string;
7976
cristy6b3da3a2010-06-20 02:21:46 +00007977 (void) SyncImagesSettings(mogrify_info,*images);
cristy018f07f2011-09-04 21:15:19 +00007978 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
7979 exception);
cristy3ed852e2009-09-05 21:47:34 +00007980 if (string == (char *) NULL)
7981 break;
cristyb51dff52011-05-19 16:55:47 +00007982 (void) FormatLocaleFile(stdout,"%s",string);
cristy3ed852e2009-09-05 21:47:34 +00007983 string=DestroyString(string);
7984 }
7985 if (LocaleCompare("process",option+1) == 0)
7986 {
7987 char
7988 **arguments;
7989
7990 int
7991 j,
7992 number_arguments;
7993
cristy6b3da3a2010-06-20 02:21:46 +00007994 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007995 arguments=StringToArgv(argv[i+1],&number_arguments);
7996 if (arguments == (char **) NULL)
7997 break;
7998 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
7999 {
8000 char
8001 breaker,
8002 quote,
8003 *token;
8004
8005 const char
8006 *arguments;
8007
8008 int
8009 next,
8010 status;
8011
8012 size_t
8013 length;
8014
8015 TokenInfo
8016 *token_info;
8017
8018 /*
8019 Support old style syntax, filter="-option arg".
8020 */
8021 length=strlen(argv[i+1]);
8022 token=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +00008023 if (~length >= (MaxTextExtent-1))
cristy3ed852e2009-09-05 21:47:34 +00008024 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8025 sizeof(*token));
8026 if (token == (char *) NULL)
8027 break;
8028 next=0;
8029 arguments=argv[i+1];
8030 token_info=AcquireTokenInfo();
8031 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8032 "\"",'\0',&breaker,&next,&quote);
8033 token_info=DestroyTokenInfo(token_info);
8034 if (status == 0)
8035 {
8036 const char
8037 *argv;
8038
8039 argv=(&(arguments[next]));
8040 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8041 exception);
8042 }
8043 token=DestroyString(token);
8044 break;
8045 }
cristy91c0da22010-05-02 01:44:07 +00008046 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008047 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8048 number_arguments-2,(const char **) arguments+2,exception);
8049 for (j=0; j < number_arguments; j++)
8050 arguments[j]=DestroyString(arguments[j]);
8051 arguments=(char **) RelinquishMagickMemory(arguments);
8052 break;
8053 }
8054 break;
8055 }
8056 case 'r':
8057 {
8058 if (LocaleCompare("reverse",option+1) == 0)
8059 {
8060 ReverseImageList(images);
cristy3ed852e2009-09-05 21:47:34 +00008061 break;
8062 }
8063 break;
8064 }
8065 case 's':
8066 {
cristy4285d782011-02-09 20:12:28 +00008067 if (LocaleCompare("smush",option+1) == 0)
8068 {
8069 Image
8070 *smush_image;
8071
8072 ssize_t
8073 offset;
8074
8075 (void) SyncImagesSettings(mogrify_info,*images);
8076 offset=(ssize_t) StringToLong(argv[i+1]);
8077 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8078 MagickFalse,offset,exception);
8079 if (smush_image == (Image *) NULL)
8080 {
8081 status=MagickFalse;
8082 break;
8083 }
8084 *images=DestroyImageList(*images);
8085 *images=smush_image;
8086 break;
8087 }
cristy3ed852e2009-09-05 21:47:34 +00008088 if (LocaleCompare("swap",option+1) == 0)
8089 {
8090 Image
8091 *p,
8092 *q,
8093 *swap;
8094
cristybb503372010-05-27 20:51:26 +00008095 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008096 swap_index;
8097
8098 index=(-1);
8099 swap_index=(-2);
8100 if (*option != '+')
8101 {
8102 GeometryInfo
8103 geometry_info;
8104
8105 MagickStatusType
8106 flags;
8107
8108 swap_index=(-1);
8109 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008110 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008111 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008112 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008113 }
8114 p=GetImageFromList(*images,index);
8115 q=GetImageFromList(*images,swap_index);
8116 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8117 {
8118 (void) ThrowMagickException(exception,GetMagickModule(),
8119 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8120 status=MagickFalse;
8121 break;
8122 }
8123 if (p == q)
8124 break;
8125 swap=CloneImage(p,0,0,MagickTrue,exception);
8126 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8127 ReplaceImageInList(&q,swap);
8128 *images=GetFirstImageInList(q);
8129 break;
8130 }
8131 break;
8132 }
8133 case 'w':
8134 {
8135 if (LocaleCompare("write",option+1) == 0)
8136 {
cristy071dd7b2010-04-09 13:04:54 +00008137 char
cristy06609ee2010-03-17 20:21:27 +00008138 key[MaxTextExtent];
8139
cristy3ed852e2009-09-05 21:47:34 +00008140 Image
8141 *write_images;
8142
8143 ImageInfo
8144 *write_info;
8145
cristy6b3da3a2010-06-20 02:21:46 +00008146 (void) SyncImagesSettings(mogrify_info,*images);
cristyb51dff52011-05-19 16:55:47 +00008147 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
cristy06609ee2010-03-17 20:21:27 +00008148 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008149 write_images=(*images);
8150 if (*option == '+')
8151 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008152 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008153 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8154 write_info=DestroyImageInfo(write_info);
8155 if (*option == '+')
8156 write_images=DestroyImageList(write_images);
8157 break;
8158 }
8159 break;
8160 }
8161 default:
8162 break;
8163 }
8164 i+=count;
8165 }
8166 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008167 mogrify_info=DestroyImageInfo(mogrify_info);
8168 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008169 return(status != 0 ? MagickTrue : MagickFalse);
8170}
8171
8172/*
8173%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8174% %
8175% %
8176% %
8177+ M o g r i f y I m a g e s %
8178% %
8179% %
8180% %
8181%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8182%
8183% MogrifyImages() applies image processing options to a sequence of images as
8184% prescribed by command line options.
8185%
8186% The format of the MogrifyImage method is:
8187%
8188% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8189% const MagickBooleanType post,const int argc,const char **argv,
8190% Image **images,Exceptioninfo *exception)
8191%
8192% A description of each parameter follows:
8193%
8194% o image_info: the image info..
8195%
8196% o post: If true, post process image list operators otherwise pre-process.
8197%
8198% o argc: Specifies a pointer to an integer describing the number of
8199% elements in the argument vector.
8200%
8201% o argv: Specifies a pointer to a text array containing the command line
8202% arguments.
8203%
anthonye9c27192011-03-27 08:07:06 +00008204% o images: pointer to a pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00008205%
8206% o exception: return any errors or warnings in this structure.
8207%
8208*/
8209WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8210 const MagickBooleanType post,const int argc,const char **argv,
8211 Image **images,ExceptionInfo *exception)
8212{
8213#define MogrifyImageTag "Mogrify/Image"
8214
anthonye9c27192011-03-27 08:07:06 +00008215 MagickStatusType
8216 status;
cristy3ed852e2009-09-05 21:47:34 +00008217
cristy0e9f9c12010-02-11 03:00:47 +00008218 MagickBooleanType
8219 proceed;
8220
anthonye9c27192011-03-27 08:07:06 +00008221 size_t
8222 n;
cristy3ed852e2009-09-05 21:47:34 +00008223
cristybb503372010-05-27 20:51:26 +00008224 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008225 i;
8226
cristy3ed852e2009-09-05 21:47:34 +00008227 assert(image_info != (ImageInfo *) NULL);
8228 assert(image_info->signature == MagickSignature);
8229 if (images == (Image **) NULL)
8230 return(MogrifyImage(image_info,argc,argv,images,exception));
anthonye9c27192011-03-27 08:07:06 +00008231 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008232 assert((*images)->signature == MagickSignature);
8233 if ((*images)->debug != MagickFalse)
8234 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8235 (*images)->filename);
8236 if ((argc <= 0) || (*argv == (char *) NULL))
8237 return(MagickTrue);
8238 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8239 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008240 status=0;
anthonye9c27192011-03-27 08:07:06 +00008241
anthonyce2716b2011-04-22 09:51:34 +00008242#if 0
cristy1e604812011-05-19 18:07:50 +00008243 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8244 post?"post":"pre");
anthonyce2716b2011-04-22 09:51:34 +00008245#endif
8246
anthonye9c27192011-03-27 08:07:06 +00008247 /*
8248 Pre-process multi-image sequence operators
8249 */
cristy3ed852e2009-09-05 21:47:34 +00008250 if (post == MagickFalse)
8251 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthonye9c27192011-03-27 08:07:06 +00008252 /*
8253 For each image, process simple single image operators
8254 */
8255 i=0;
8256 n=GetImageListLength(*images);
cristy9f027d12011-09-21 01:17:17 +00008257 for ( ; ; )
cristy3ed852e2009-09-05 21:47:34 +00008258 {
anthonyce2716b2011-04-22 09:51:34 +00008259#if 0
cristy1e604812011-05-19 18:07:50 +00008260 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8261 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008262#endif
anthonye9c27192011-03-27 08:07:06 +00008263 status&=MogrifyImage(image_info,argc,argv,images,exception);
8264 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
cristy0e9f9c12010-02-11 03:00:47 +00008265 if (proceed == MagickFalse)
8266 break;
anthonye9c27192011-03-27 08:07:06 +00008267 if ( (*images)->next == (Image *) NULL )
8268 break;
8269 *images=(*images)->next;
8270 i++;
cristy3ed852e2009-09-05 21:47:34 +00008271 }
anthonye9c27192011-03-27 08:07:06 +00008272 assert( *images != (Image *) NULL );
anthonyce2716b2011-04-22 09:51:34 +00008273#if 0
cristy1e604812011-05-19 18:07:50 +00008274 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8275 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008276#endif
anthonye9c27192011-03-27 08:07:06 +00008277
8278 /*
8279 Post-process, multi-image sequence operators
8280 */
8281 *images=GetFirstImageInList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008282 if (post != MagickFalse)
anthonye9c27192011-03-27 08:07:06 +00008283 status&=MogrifyImageList(image_info,argc,argv,images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008284 return(status != 0 ? MagickTrue : MagickFalse);
8285}