blob: 8da0dabcf1ad651afa449031b2728815dd288859 [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"
cristy0740a982011-10-13 15:01:01 +000054#include "MagickCore/nt-base-private.h"
cristy4c08aed2011-07-01 19:47:50 +000055#include "MagickCore/string-private.h"
cristy0740a982011-10-13 15:01:01 +000056#include "MagickCore/thread-private.h"
cristy18c6c272011-09-23 14:40:37 +000057#include "MagickCore/utility-private.h"
cristy3ed852e2009-09-05 21:47:34 +000058
59/*
cristy154fa9d2011-08-05 14:25:15 +000060 Constant declaration.
61*/
cristy3a557c02011-08-06 19:48:02 +000062static const char
cristy638895a2011-08-06 23:19:14 +000063 MogrifyBackgroundColor[] = "#ffffff", /* white */
64 MogrifyBorderColor[] = "#dfdfdf", /* gray */
65 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
cristy154fa9d2011-08-05 14:25:15 +000066
67/*
cristy3ed852e2009-09-05 21:47:34 +000068 Define declarations.
69*/
70#define UndefinedCompressionQuality 0UL
71
72/*
cristy3ed852e2009-09-05 21:47:34 +000073%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74% %
75% %
76% %
cristy5063d812010-10-19 16:28:10 +000077% 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 +000078% %
79% %
80% %
81%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82%
83% MagickCommandGenesis() applies image processing options to an image as
84% prescribed by command line options.
85%
86% The format of the MagickCommandGenesis method is:
87%
88% MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
cristy5063d812010-10-19 16:28:10 +000089% MagickCommand command,int argc,char **argv,char **metadata,
90% ExceptionInfo *exception)
cristy3980b0d2009-10-25 14:37:13 +000091%
92% A description of each parameter follows:
93%
94% o image_info: the image info.
95%
cristy5063d812010-10-19 16:28:10 +000096% o command: Choose from ConvertImageCommand, IdentifyImageCommand,
cristy8a9106f2011-07-05 14:39:26 +000097% MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
cristy5063d812010-10-19 16:28:10 +000098% ConjureImageCommand, StreamImageCommand, ImportImageCommand,
99% DisplayImageCommand, or AnimateImageCommand.
cristy3980b0d2009-10-25 14:37:13 +0000100%
101% o argc: Specifies a pointer to an integer describing the number of
102% elements in the argument vector.
103%
104% o argv: Specifies a pointer to a text array containing the command line
105% arguments.
106%
cristy5063d812010-10-19 16:28:10 +0000107% o metadata: any metadata is returned here.
cristy3980b0d2009-10-25 14:37:13 +0000108%
109% o exception: return any errors or warnings in this structure.
110%
111*/
112WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
113 MagickCommand command,int argc,char **argv,char **metadata,
114 ExceptionInfo *exception)
115{
116 char
117 *option;
118
119 double
120 duration,
121 elapsed_time,
122 user_time;
123
cristy3980b0d2009-10-25 14:37:13 +0000124 MagickBooleanType
125 concurrent,
126 regard_warnings,
127 status;
128
cristybb503372010-05-27 20:51:26 +0000129 register ssize_t
cristy3980b0d2009-10-25 14:37:13 +0000130 i;
131
132 TimerInfo
133 *timer;
134
cristybb503372010-05-27 20:51:26 +0000135 size_t
cristy3980b0d2009-10-25 14:37:13 +0000136 iterations;
137
cristyd0a94fa2010-03-12 14:18:11 +0000138 (void) setlocale(LC_ALL,"");
139 (void) setlocale(LC_NUMERIC,"C");
cristy3980b0d2009-10-25 14:37:13 +0000140 concurrent=MagickFalse;
141 duration=(-1.0);
142 iterations=1;
cristy33557d72009-11-06 00:54:33 +0000143 status=MagickFalse;
cristy3980b0d2009-10-25 14:37:13 +0000144 regard_warnings=MagickFalse;
cristybb503372010-05-27 20:51:26 +0000145 for (i=1; i < (ssize_t) (argc-1); i++)
cristy3980b0d2009-10-25 14:37:13 +0000146 {
147 option=argv[i];
148 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
149 continue;
150 if (LocaleCompare("bench",option+1) == 0)
cristye27293e2009-12-18 02:53:20 +0000151 iterations=StringToUnsignedLong(argv[++i]);
cristy3980b0d2009-10-25 14:37:13 +0000152 if (LocaleCompare("concurrent",option+1) == 0)
153 concurrent=MagickTrue;
154 if (LocaleCompare("debug",option+1) == 0)
155 (void) SetLogEventMask(argv[++i]);
156 if (LocaleCompare("duration",option+1) == 0)
cristyc1acd842011-05-19 23:05:47 +0000157 duration=InterpretLocaleValue(argv[++i],(char **) NULL);
cristy3980b0d2009-10-25 14:37:13 +0000158 if (LocaleCompare("regard-warnings",option+1) == 0)
159 regard_warnings=MagickTrue;
160 }
161 timer=AcquireTimerInfo();
cristyceae09d2009-10-28 17:18:47 +0000162 if (concurrent == MagickFalse)
cristy3980b0d2009-10-25 14:37:13 +0000163 {
cristybb503372010-05-27 20:51:26 +0000164 for (i=0; i < (ssize_t) iterations; i++)
cristy3980b0d2009-10-25 14:37:13 +0000165 {
cristy33557d72009-11-06 00:54:33 +0000166 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000167 continue;
168 if (duration > 0)
169 {
170 if (GetElapsedTime(timer) > duration)
171 continue;
172 (void) ContinueTimer(timer);
173 }
174 status=command(image_info,argc,argv,metadata,exception);
cristy3980b0d2009-10-25 14:37:13 +0000175 if (exception->severity != UndefinedException)
176 {
177 if ((exception->severity > ErrorException) ||
178 (regard_warnings != MagickFalse))
179 status=MagickTrue;
180 CatchException(exception);
181 }
cristy3d1a5512009-10-25 21:23:27 +0000182 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
cristy3980b0d2009-10-25 14:37:13 +0000183 {
184 (void) fputs(*metadata,stdout);
185 (void) fputc('\n',stdout);
186 *metadata=DestroyString(*metadata);
187 }
188 }
189 }
cristyceae09d2009-10-28 17:18:47 +0000190 else
191 {
192 SetOpenMPNested(1);
cristyb5d5f722009-11-04 03:03:49 +0000193#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristyceae09d2009-10-28 17:18:47 +0000194 # pragma omp parallel for shared(status)
195#endif
cristybb503372010-05-27 20:51:26 +0000196 for (i=0; i < (ssize_t) iterations; i++)
cristyceae09d2009-10-28 17:18:47 +0000197 {
cristy33557d72009-11-06 00:54:33 +0000198 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000199 continue;
200 if (duration > 0)
201 {
202 if (GetElapsedTime(timer) > duration)
203 continue;
204 (void) ContinueTimer(timer);
205 }
206 status=command(image_info,argc,argv,metadata,exception);
cristyb5d5f722009-11-04 03:03:49 +0000207#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristy524549f2010-06-20 21:10:20 +0000208 # pragma omp critical (MagickCore_CommandGenesis)
cristyceae09d2009-10-28 17:18:47 +0000209#endif
210 {
211 if (exception->severity != UndefinedException)
212 {
213 if ((exception->severity > ErrorException) ||
214 (regard_warnings != MagickFalse))
215 status=MagickTrue;
216 CatchException(exception);
217 }
218 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
219 {
220 (void) fputs(*metadata,stdout);
221 (void) fputc('\n',stdout);
222 *metadata=DestroyString(*metadata);
223 }
224 }
225 }
226 }
cristy3980b0d2009-10-25 14:37:13 +0000227 if (iterations > 1)
228 {
229 elapsed_time=GetElapsedTime(timer);
230 user_time=GetUserTime(timer);
cristyb51dff52011-05-19 16:55:47 +0000231 (void) FormatLocaleFile(stderr,
cristye8c25f92010-06-03 00:53:06 +0000232 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
233 iterations,1.0*iterations/elapsed_time,user_time,(double)
234 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
235 (1000.0*(elapsed_time-floor(elapsed_time))));
cristy524549f2010-06-20 21:10:20 +0000236 (void) fflush(stderr);
cristy3980b0d2009-10-25 14:37:13 +0000237 }
238 timer=DestroyTimerInfo(timer);
cristy1f9e1ed2009-11-18 04:09:38 +0000239 return(status);
cristy3980b0d2009-10-25 14:37:13 +0000240}
241
242/*
243%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244% %
245% %
246% %
cristy3ed852e2009-09-05 21:47:34 +0000247+ M o g r i f y I m a g e %
248% %
249% %
250% %
251%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252%
anthonye9c27192011-03-27 08:07:06 +0000253% MogrifyImage() applies simple single image processing options to a single
anthonydf8ebac2011-04-27 09:03:19 +0000254% image that may be part of a large list, but also handles any 'region'
255% image handling.
anthonye9c27192011-03-27 08:07:06 +0000256%
257% The image in the list may be modified in three different ways...
258%
259% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
260% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
261% * replace by a list of images (only the -separate option!)
262%
263% In each case the result is returned into the list, and a pointer to the
264% modified image (last image added if replaced by a list of images) is
265% returned.
266%
267% ASIDE: The -crop is present but restricted to non-tile single image crops
268%
269% This means if all the images are being processed (such as by
270% MogrifyImages(), next image to be processed will be as per the pointer
271% (*image)->next. Also the image list may grow as a result of some specific
272% operations but as images are never merged or deleted, it will never shrink
273% in length. Typically the list will remain the same length.
274%
275% WARNING: As the image pointed to may be replaced, the first image in the
276% list may also change. GetFirstImageInList() should be used by caller if
277% they wish return the Image pointer to the first image in list.
278%
cristy3ed852e2009-09-05 21:47:34 +0000279%
280% The format of the MogrifyImage method is:
281%
282% MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
283% const char **argv,Image **image)
284%
285% A description of each parameter follows:
286%
287% o image_info: the image info..
288%
289% o argc: Specifies a pointer to an integer describing the number of
290% elements in the argument vector.
291%
292% o argv: Specifies a pointer to a text array containing the command line
293% arguments.
294%
295% o image: the image.
296%
297% o exception: return any errors or warnings in this structure.
298%
299*/
300
cristy4c08aed2011-07-01 19:47:50 +0000301/*
anthony0d0fd352011-10-04 11:09:07 +0000302 GetImageCache() will read an image into a image cache if not already
303 present then return the image that is in the cache under that filename.
cristy4c08aed2011-07-01 19:47:50 +0000304*/
anthonydf8ebac2011-04-27 09:03:19 +0000305static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
306 ExceptionInfo *exception)
307{
308 char
309 key[MaxTextExtent];
310
311 ExceptionInfo
312 *sans_exception;
313
314 Image
315 *image;
316
317 ImageInfo
318 *read_info;
319
cristyb51dff52011-05-19 16:55:47 +0000320 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
anthonydf8ebac2011-04-27 09:03:19 +0000321 sans_exception=AcquireExceptionInfo();
322 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
323 sans_exception=DestroyExceptionInfo(sans_exception);
324 if (image != (Image *) NULL)
325 return(image);
326 read_info=CloneImageInfo(image_info);
327 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
328 image=ReadImage(read_info,exception);
329 read_info=DestroyImageInfo(read_info);
330 if (image != (Image *) NULL)
331 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
332 return(image);
333}
334
cristy3ed852e2009-09-05 21:47:34 +0000335static MagickBooleanType IsPathWritable(const char *path)
336{
337 if (IsPathAccessible(path) == MagickFalse)
338 return(MagickFalse);
cristy18c6c272011-09-23 14:40:37 +0000339 if (access_utf8(path,W_OK) != 0)
cristy3ed852e2009-09-05 21:47:34 +0000340 return(MagickFalse);
341 return(MagickTrue);
342}
343
cristybb503372010-05-27 20:51:26 +0000344static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
cristy3ed852e2009-09-05 21:47:34 +0000345{
346 if (x > y)
347 return(x);
348 return(y);
349}
350
anthonydf8ebac2011-04-27 09:03:19 +0000351static MagickBooleanType MonitorProgress(const char *text,
352 const MagickOffsetType offset,const MagickSizeType extent,
353 void *wand_unused(client_data))
354{
355 char
356 message[MaxTextExtent],
357 tag[MaxTextExtent];
358
359 const char
360 *locale_message;
361
362 register char
363 *p;
364
365 if (extent < 2)
366 return(MagickTrue);
367 (void) CopyMagickMemory(tag,text,MaxTextExtent);
368 p=strrchr(tag,'/');
369 if (p != (char *) NULL)
370 *p='\0';
cristyb51dff52011-05-19 16:55:47 +0000371 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
anthonydf8ebac2011-04-27 09:03:19 +0000372 locale_message=GetLocaleMessage(message);
373 if (locale_message == message)
374 locale_message=tag;
375 if (p == (char *) NULL)
cristy1e604812011-05-19 18:07:50 +0000376 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
377 locale_message,(long) offset,(unsigned long) extent,(long)
378 (100L*offset/(extent-1)));
anthonydf8ebac2011-04-27 09:03:19 +0000379 else
cristyb51dff52011-05-19 16:55:47 +0000380 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
anthonydf8ebac2011-04-27 09:03:19 +0000381 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
382 (100L*offset/(extent-1)));
383 if (offset == (MagickOffsetType) (extent-1))
cristyb51dff52011-05-19 16:55:47 +0000384 (void) FormatLocaleFile(stderr,"\n");
anthonydf8ebac2011-04-27 09:03:19 +0000385 (void) fflush(stderr);
386 return(MagickTrue);
387}
388
anthony0d0fd352011-10-04 11:09:07 +0000389 /*
390 SparseColorOption() parses the complex -sparse-color argument into an
391 an array of floating point values then calls SparseColorImage().
392 Argument is a complex mix of floating-point pixel coodinates, and color
393 specifications (or direct floating point numbers). The number of floats
394 needed to represent a color varies depending on the current channel
395 setting.
396 */
cristy3884f692011-07-08 18:00:18 +0000397static Image *SparseColorOption(const Image *image,
anthonydf8ebac2011-04-27 09:03:19 +0000398 const SparseColorMethod method,const char *arguments,
399 const MagickBooleanType color_from_image,ExceptionInfo *exception)
400{
anthonydf8ebac2011-04-27 09:03:19 +0000401 char
402 token[MaxTextExtent];
403
404 const char
405 *p;
406
407 double
408 *sparse_arguments;
409
anthonydf8ebac2011-04-27 09:03:19 +0000410 Image
411 *sparse_image;
412
cristy4c08aed2011-07-01 19:47:50 +0000413 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000414 color;
415
416 MagickBooleanType
417 error;
418
cristy5f09d852011-05-29 01:39:29 +0000419 register size_t
420 x;
421
422 size_t
423 number_arguments,
424 number_colors;
425
anthonydf8ebac2011-04-27 09:03:19 +0000426 assert(image != (Image *) NULL);
427 assert(image->signature == MagickSignature);
428 if (image->debug != MagickFalse)
429 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
430 assert(exception != (ExceptionInfo *) NULL);
431 assert(exception->signature == MagickSignature);
432 /*
433 Limit channels according to image - and add up number of color channel.
434 */
anthonydf8ebac2011-04-27 09:03:19 +0000435 number_colors=0;
cristyed231572011-07-14 02:18:59 +0000436 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000437 number_colors++;
cristyed231572011-07-14 02:18:59 +0000438 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000439 number_colors++;
cristyed231572011-07-14 02:18:59 +0000440 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000441 number_colors++;
cristyed231572011-07-14 02:18:59 +0000442 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000443 (image->colorspace == CMYKColorspace))
anthonydf8ebac2011-04-27 09:03:19 +0000444 number_colors++;
cristyed231572011-07-14 02:18:59 +0000445 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000446 (image->matte != MagickFalse))
anthonydf8ebac2011-04-27 09:03:19 +0000447 number_colors++;
448
449 /*
450 Read string, to determine number of arguments needed,
451 */
452 p=arguments;
453 x=0;
454 while( *p != '\0' )
455 {
456 GetMagickToken(p,&p,token);
457 if ( token[0] == ',' ) continue;
458 if ( isalpha((int) token[0]) || token[0] == '#' ) {
459 if ( color_from_image ) {
460 (void) ThrowMagickException(exception,GetMagickModule(),
461 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
462 "Color arg given, when colors are coming from image");
463 return( (Image *)NULL);
464 }
465 x += number_colors; /* color argument */
466 }
467 else {
468 x++; /* floating point argument */
469 }
470 }
471 error=MagickTrue;
472 if ( color_from_image ) {
473 /* just the control points are being given */
474 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
475 number_arguments=(x/2)*(2+number_colors);
476 }
477 else {
478 /* control points and color values */
479 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
480 number_arguments=x;
481 }
482 if ( error ) {
483 (void) ThrowMagickException(exception,GetMagickModule(),
484 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
485 "Invalid number of Arguments");
486 return( (Image *)NULL);
487 }
488
489 /* Allocate and fill in the floating point arguments */
490 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
491 sizeof(*sparse_arguments));
492 if (sparse_arguments == (double *) NULL) {
493 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
494 "MemoryAllocationFailed","%s","SparseColorOption");
495 return( (Image *)NULL);
496 }
497 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
498 sizeof(*sparse_arguments));
499 p=arguments;
500 x=0;
501 while( *p != '\0' && x < number_arguments ) {
502 /* X coordinate */
503 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
504 if ( token[0] == '\0' ) break;
505 if ( isalpha((int) token[0]) || token[0] == '#' ) {
506 (void) ThrowMagickException(exception,GetMagickModule(),
507 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
508 "Color found, instead of X-coord");
509 error = MagickTrue;
510 break;
511 }
cristyc1acd842011-05-19 23:05:47 +0000512 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000513 /* Y coordinate */
514 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
515 if ( token[0] == '\0' ) break;
516 if ( isalpha((int) token[0]) || token[0] == '#' ) {
517 (void) ThrowMagickException(exception,GetMagickModule(),
518 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
519 "Color found, instead of Y-coord");
520 error = MagickTrue;
521 break;
522 }
cristyc1acd842011-05-19 23:05:47 +0000523 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000524 /* color values for this control point */
525#if 0
526 if ( (color_from_image ) {
527 /* get color from image */
528 /* HOW??? */
529 }
530 else
531#endif
532 {
533 /* color name or function given in string argument */
534 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
535 if ( token[0] == '\0' ) break;
536 if ( isalpha((int) token[0]) || token[0] == '#' ) {
537 /* Color string given */
cristy9950d572011-10-01 18:22:35 +0000538 (void) QueryMagickColorCompliance(token,AllCompliance,&color,exception);
cristyed231572011-07-14 02:18:59 +0000539 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000540 sparse_arguments[x++] = QuantumScale*color.red;
cristyed231572011-07-14 02:18:59 +0000541 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000542 sparse_arguments[x++] = QuantumScale*color.green;
cristyed231572011-07-14 02:18:59 +0000543 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000544 sparse_arguments[x++] = QuantumScale*color.blue;
cristyed231572011-07-14 02:18:59 +0000545 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000546 (image->colorspace == CMYKColorspace))
cristy4c08aed2011-07-01 19:47:50 +0000547 sparse_arguments[x++] = QuantumScale*color.black;
cristyed231572011-07-14 02:18:59 +0000548 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000549 (image->matte != MagickFalse))
cristy4c08aed2011-07-01 19:47:50 +0000550 sparse_arguments[x++] = QuantumScale*color.alpha;
anthonydf8ebac2011-04-27 09:03:19 +0000551 }
552 else {
553 /* Colors given as a set of floating point values - experimental */
554 /* NB: token contains the first floating point value to use! */
cristyed231572011-07-14 02:18:59 +0000555 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000556 {
anthonydf8ebac2011-04-27 09:03:19 +0000557 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
558 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
559 break;
cristyc1acd842011-05-19 23:05:47 +0000560 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000561 token[0] = ','; /* used this token - get another */
562 }
cristyed231572011-07-14 02:18:59 +0000563 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000564 {
anthonydf8ebac2011-04-27 09:03:19 +0000565 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
566 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
567 break;
cristyc1acd842011-05-19 23:05:47 +0000568 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000569 token[0] = ','; /* used this token - get another */
570 }
cristyed231572011-07-14 02:18:59 +0000571 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000572 {
anthonydf8ebac2011-04-27 09:03:19 +0000573 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
574 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
575 break;
cristyc1acd842011-05-19 23:05:47 +0000576 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000577 token[0] = ','; /* used this token - get another */
578 }
cristyed231572011-07-14 02:18:59 +0000579 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000580 (image->colorspace == CMYKColorspace))
581 {
anthonydf8ebac2011-04-27 09:03:19 +0000582 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
583 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
584 break;
cristyc1acd842011-05-19 23:05:47 +0000585 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000586 token[0] = ','; /* used this token - get another */
587 }
cristyed231572011-07-14 02:18:59 +0000588 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000589 (image->matte != MagickFalse))
590 {
anthonydf8ebac2011-04-27 09:03:19 +0000591 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
592 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
593 break;
cristyc1acd842011-05-19 23:05:47 +0000594 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000595 token[0] = ','; /* used this token - get another */
596 }
597 }
598 }
599 }
600 if ( number_arguments != x && !error ) {
601 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
602 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
603 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
604 return( (Image *)NULL);
605 }
606 if ( error )
607 return( (Image *)NULL);
608
609 /* Call the Interpolation function with the parsed arguments */
cristy3884f692011-07-08 18:00:18 +0000610 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
611 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000612 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
613 return( sparse_image );
614}
615
cristy3ed852e2009-09-05 21:47:34 +0000616WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
617 const char **argv,Image **image,ExceptionInfo *exception)
618{
anthonydf8ebac2011-04-27 09:03:19 +0000619 ChannelType
620 channel;
621
cristy633f0c62011-09-15 13:27:36 +0000622 CompositeOperator
623 compose;
624
anthonydf8ebac2011-04-27 09:03:19 +0000625 const char
626 *format,
627 *option;
628
cristy9ed1f812011-10-08 02:00:08 +0000629 double
630 attenuate;
631
anthonydf8ebac2011-04-27 09:03:19 +0000632 DrawInfo
633 *draw_info;
634
635 GeometryInfo
636 geometry_info;
637
cristy3ed852e2009-09-05 21:47:34 +0000638 Image
639 *region_image;
640
anthonydf8ebac2011-04-27 09:03:19 +0000641 ImageInfo
642 *mogrify_info;
643
cristyebbcfea2011-02-25 02:43:54 +0000644 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000645 status;
646
cristy4c08aed2011-07-01 19:47:50 +0000647 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000648 fill;
cristy3ed852e2009-09-05 21:47:34 +0000649
anthonydf8ebac2011-04-27 09:03:19 +0000650 MagickStatusType
651 flags;
652
cristy28474bf2011-09-11 23:32:52 +0000653 PixelInterpolateMethod
654 interpolate_method;
655
anthonydf8ebac2011-04-27 09:03:19 +0000656 QuantizeInfo
657 *quantize_info;
658
659 RectangleInfo
660 geometry,
661 region_geometry;
anthony56ad4222011-04-25 11:04:27 +0000662
cristybb503372010-05-27 20:51:26 +0000663 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000664 i;
665
666 /*
667 Initialize method variables.
668 */
669 assert(image_info != (const ImageInfo *) NULL);
670 assert(image_info->signature == MagickSignature);
671 assert(image != (Image **) NULL);
672 assert((*image)->signature == MagickSignature);
673 if ((*image)->debug != MagickFalse)
674 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
675 if (argc < 0)
676 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +0000677 mogrify_info=CloneImageInfo(image_info);
anthonydf8ebac2011-04-27 09:03:19 +0000678 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
679 quantize_info=AcquireQuantizeInfo(mogrify_info);
680 SetGeometryInfo(&geometry_info);
cristy4c08aed2011-07-01 19:47:50 +0000681 GetPixelInfo(*image,&fill);
682 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
cristy9ed1f812011-10-08 02:00:08 +0000683 attenuate=1.0;
cristy633f0c62011-09-15 13:27:36 +0000684 compose=(*image)->compose;
cristy28474bf2011-09-11 23:32:52 +0000685 interpolate_method=UndefinedInterpolatePixel;
anthonydf8ebac2011-04-27 09:03:19 +0000686 channel=mogrify_info->channel;
687 format=GetImageOption(mogrify_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000688 SetGeometry(*image,&region_geometry);
689 region_image=NewImageList();
690 /*
691 Transmogrify the image.
692 */
cristybb503372010-05-27 20:51:26 +0000693 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000694 {
anthonydf8ebac2011-04-27 09:03:19 +0000695 Image
696 *mogrify_image;
697
anthonye9c27192011-03-27 08:07:06 +0000698 ssize_t
699 count;
700
anthonydf8ebac2011-04-27 09:03:19 +0000701 option=argv[i];
702 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000703 continue;
anthonydf8ebac2011-04-27 09:03:19 +0000704 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
705 0L);
cristycee97112010-05-28 00:44:52 +0000706 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000707 break;
cristy6b3da3a2010-06-20 02:21:46 +0000708 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000709 mogrify_image=(Image *)NULL;
710 switch (*(option+1))
711 {
712 case 'a':
cristy3ed852e2009-09-05 21:47:34 +0000713 {
anthonydf8ebac2011-04-27 09:03:19 +0000714 if (LocaleCompare("adaptive-blur",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000715 {
anthonydf8ebac2011-04-27 09:03:19 +0000716 /*
717 Adaptive blur image.
718 */
719 (void) SyncImageSettings(mogrify_info,*image);
720 flags=ParseGeometry(argv[i+1],&geometry_info);
721 if ((flags & SigmaValue) == 0)
722 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000723 if ((flags & XiValue) == 0)
724 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000725 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000726 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000727 break;
cristy3ed852e2009-09-05 21:47:34 +0000728 }
anthonydf8ebac2011-04-27 09:03:19 +0000729 if (LocaleCompare("adaptive-resize",option+1) == 0)
730 {
731 /*
732 Adaptive resize image.
733 */
734 (void) SyncImageSettings(mogrify_info,*image);
735 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
736 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
cristy28474bf2011-09-11 23:32:52 +0000737 geometry.height,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000738 break;
739 }
740 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
741 {
742 /*
743 Adaptive sharpen image.
744 */
745 (void) SyncImageSettings(mogrify_info,*image);
746 flags=ParseGeometry(argv[i+1],&geometry_info);
747 if ((flags & SigmaValue) == 0)
748 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000749 if ((flags & XiValue) == 0)
750 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000751 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000752 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000753 break;
754 }
755 if (LocaleCompare("affine",option+1) == 0)
756 {
757 /*
758 Affine matrix.
759 */
760 if (*option == '+')
761 {
762 GetAffineMatrix(&draw_info->affine);
763 break;
764 }
765 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
766 break;
767 }
768 if (LocaleCompare("alpha",option+1) == 0)
769 {
770 AlphaChannelType
771 alpha_type;
cristy3ed852e2009-09-05 21:47:34 +0000772
anthonydf8ebac2011-04-27 09:03:19 +0000773 (void) SyncImageSettings(mogrify_info,*image);
774 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
775 MagickFalse,argv[i+1]);
cristy63240882011-08-05 19:05:27 +0000776 (void) SetImageAlphaChannel(*image,alpha_type,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000777 break;
778 }
779 if (LocaleCompare("annotate",option+1) == 0)
780 {
781 char
782 *text,
783 geometry[MaxTextExtent];
784
785 /*
786 Annotate image.
787 */
788 (void) SyncImageSettings(mogrify_info,*image);
789 SetGeometryInfo(&geometry_info);
790 flags=ParseGeometry(argv[i+1],&geometry_info);
791 if ((flags & SigmaValue) == 0)
792 geometry_info.sigma=geometry_info.rho;
cristy018f07f2011-09-04 21:15:19 +0000793 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
794 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000795 if (text == (char *) NULL)
796 break;
797 (void) CloneString(&draw_info->text,text);
798 text=DestroyString(text);
cristyb51dff52011-05-19 16:55:47 +0000799 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
anthonydf8ebac2011-04-27 09:03:19 +0000800 geometry_info.xi,geometry_info.psi);
801 (void) CloneString(&draw_info->geometry,geometry);
802 draw_info->affine.sx=cos(DegreesToRadians(
803 fmod(geometry_info.rho,360.0)));
804 draw_info->affine.rx=sin(DegreesToRadians(
805 fmod(geometry_info.rho,360.0)));
806 draw_info->affine.ry=(-sin(DegreesToRadians(
807 fmod(geometry_info.sigma,360.0))));
808 draw_info->affine.sy=cos(DegreesToRadians(
809 fmod(geometry_info.sigma,360.0)));
cristy5cbc0162011-08-29 00:36:28 +0000810 (void) AnnotateImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000811 break;
812 }
813 if (LocaleCompare("antialias",option+1) == 0)
814 {
815 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
816 MagickFalse;
817 draw_info->text_antialias=(*option == '-') ? MagickTrue :
818 MagickFalse;
819 break;
820 }
cristy9ed1f812011-10-08 02:00:08 +0000821 if (LocaleCompare("attenuate",option+1) == 0)
822 {
823 if (*option == '+')
824 {
825 attenuate=1.0;
826 break;
827 }
828 attenuate=InterpretLocaleValue(argv[i+1],(char **) NULL);
829 break;
830 }
anthonydf8ebac2011-04-27 09:03:19 +0000831 if (LocaleCompare("auto-gamma",option+1) == 0)
832 {
833 /*
834 Auto Adjust Gamma of image based on its mean
835 */
836 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000837 (void) AutoGammaImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000838 break;
839 }
840 if (LocaleCompare("auto-level",option+1) == 0)
841 {
842 /*
843 Perfectly Normalize (max/min stretch) the image
844 */
845 (void) SyncImageSettings(mogrify_info,*image);
cristy95111202011-08-09 19:41:42 +0000846 (void) AutoLevelImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000847 break;
848 }
849 if (LocaleCompare("auto-orient",option+1) == 0)
850 {
851 (void) SyncImageSettings(mogrify_info,*image);
852 switch ((*image)->orientation)
853 {
854 case TopRightOrientation:
855 {
856 mogrify_image=FlopImage(*image,exception);
857 break;
858 }
859 case BottomRightOrientation:
860 {
861 mogrify_image=RotateImage(*image,180.0,exception);
862 break;
863 }
864 case BottomLeftOrientation:
865 {
866 mogrify_image=FlipImage(*image,exception);
867 break;
868 }
869 case LeftTopOrientation:
870 {
871 mogrify_image=TransposeImage(*image,exception);
872 break;
873 }
874 case RightTopOrientation:
875 {
876 mogrify_image=RotateImage(*image,90.0,exception);
877 break;
878 }
879 case RightBottomOrientation:
880 {
881 mogrify_image=TransverseImage(*image,exception);
882 break;
883 }
884 case LeftBottomOrientation:
885 {
886 mogrify_image=RotateImage(*image,270.0,exception);
887 break;
888 }
889 default:
890 break;
891 }
892 if (mogrify_image != (Image *) NULL)
893 mogrify_image->orientation=TopLeftOrientation;
894 break;
895 }
896 break;
897 }
898 case 'b':
899 {
900 if (LocaleCompare("black-threshold",option+1) == 0)
901 {
902 /*
903 Black threshold image.
904 */
905 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +0000906 (void) BlackThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +0000907 InheritException(exception,&(*image)->exception);
908 break;
909 }
910 if (LocaleCompare("blue-shift",option+1) == 0)
911 {
912 /*
913 Blue shift image.
914 */
915 (void) SyncImageSettings(mogrify_info,*image);
916 geometry_info.rho=1.5;
917 if (*option == '-')
918 flags=ParseGeometry(argv[i+1],&geometry_info);
919 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
920 break;
921 }
922 if (LocaleCompare("blur",option+1) == 0)
923 {
924 /*
925 Gaussian blur image.
926 */
927 (void) SyncImageSettings(mogrify_info,*image);
928 flags=ParseGeometry(argv[i+1],&geometry_info);
929 if ((flags & SigmaValue) == 0)
930 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000931 if ((flags & XiValue) == 0)
932 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000933 mogrify_image=BlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +0000934 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000935 break;
936 }
937 if (LocaleCompare("border",option+1) == 0)
938 {
939 /*
940 Surround image with a border of solid color.
941 */
942 (void) SyncImageSettings(mogrify_info,*image);
943 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
944 if ((flags & SigmaValue) == 0)
945 geometry.height=geometry.width;
cristy633f0c62011-09-15 13:27:36 +0000946 mogrify_image=BorderImage(*image,&geometry,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000947 break;
948 }
949 if (LocaleCompare("bordercolor",option+1) == 0)
950 {
951 if (*option == '+')
952 {
cristy9950d572011-10-01 18:22:35 +0000953 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy05c0c9a2011-09-05 23:16:13 +0000954 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000955 break;
956 }
cristy9950d572011-10-01 18:22:35 +0000957 (void) QueryColorCompliance(argv[i+1],AllCompliance,
958 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000959 break;
960 }
961 if (LocaleCompare("box",option+1) == 0)
962 {
cristy9950d572011-10-01 18:22:35 +0000963 (void) QueryColorCompliance(argv[i+1],AllCompliance,
964 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000965 break;
966 }
967 if (LocaleCompare("brightness-contrast",option+1) == 0)
968 {
969 double
970 brightness,
971 contrast;
972
973 GeometryInfo
974 geometry_info;
975
976 MagickStatusType
977 flags;
978
979 /*
980 Brightness / contrast image.
981 */
982 (void) SyncImageSettings(mogrify_info,*image);
983 flags=ParseGeometry(argv[i+1],&geometry_info);
984 brightness=geometry_info.rho;
985 contrast=0.0;
986 if ((flags & SigmaValue) != 0)
987 contrast=geometry_info.sigma;
cristy444eda62011-08-10 02:07:46 +0000988 (void) BrightnessContrastImage(*image,brightness,contrast,
989 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000990 InheritException(exception,&(*image)->exception);
991 break;
992 }
993 break;
994 }
995 case 'c':
996 {
997 if (LocaleCompare("cdl",option+1) == 0)
998 {
999 char
1000 *color_correction_collection;
1001
1002 /*
1003 Color correct with a color decision list.
1004 */
1005 (void) SyncImageSettings(mogrify_info,*image);
1006 color_correction_collection=FileToString(argv[i+1],~0,exception);
1007 if (color_correction_collection == (char *) NULL)
1008 break;
cristy1bfa9f02011-08-11 02:35:43 +00001009 (void) ColorDecisionListImage(*image,color_correction_collection,
1010 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001011 InheritException(exception,&(*image)->exception);
1012 break;
1013 }
1014 if (LocaleCompare("channel",option+1) == 0)
1015 {
1016 if (*option == '+')
cristyfa806a72011-07-04 02:06:13 +00001017 channel=DefaultChannels;
anthonydf8ebac2011-04-27 09:03:19 +00001018 else
cristyfa806a72011-07-04 02:06:13 +00001019 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00001020 SetPixelChannelMap(*image,channel);
anthonydf8ebac2011-04-27 09:03:19 +00001021 break;
1022 }
1023 if (LocaleCompare("charcoal",option+1) == 0)
1024 {
1025 /*
1026 Charcoal image.
1027 */
1028 (void) SyncImageSettings(mogrify_info,*image);
1029 flags=ParseGeometry(argv[i+1],&geometry_info);
1030 if ((flags & SigmaValue) == 0)
1031 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001032 if ((flags & XiValue) == 0)
1033 geometry_info.xi=1.0;
anthonydf8ebac2011-04-27 09:03:19 +00001034 mogrify_image=CharcoalImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001035 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001036 break;
1037 }
1038 if (LocaleCompare("chop",option+1) == 0)
1039 {
1040 /*
1041 Chop the image.
1042 */
1043 (void) SyncImageSettings(mogrify_info,*image);
1044 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1045 mogrify_image=ChopImage(*image,&geometry,exception);
1046 break;
1047 }
1048 if (LocaleCompare("clamp",option+1) == 0)
1049 {
1050 /*
1051 Clamp image.
1052 */
1053 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00001054 (void) ClampImage(*image);
anthonydf8ebac2011-04-27 09:03:19 +00001055 InheritException(exception,&(*image)->exception);
1056 break;
1057 }
1058 if (LocaleCompare("clip",option+1) == 0)
1059 {
1060 (void) SyncImageSettings(mogrify_info,*image);
1061 if (*option == '+')
1062 {
cristy018f07f2011-09-04 21:15:19 +00001063 (void) SetImageClipMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001064 break;
1065 }
cristy018f07f2011-09-04 21:15:19 +00001066 (void) ClipImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001067 break;
1068 }
1069 if (LocaleCompare("clip-mask",option+1) == 0)
1070 {
1071 CacheView
1072 *mask_view;
1073
1074 Image
1075 *mask_image;
1076
cristy4c08aed2011-07-01 19:47:50 +00001077 register Quantum
anthonydf8ebac2011-04-27 09:03:19 +00001078 *restrict q;
1079
1080 register ssize_t
1081 x;
1082
1083 ssize_t
1084 y;
1085
1086 (void) SyncImageSettings(mogrify_info,*image);
1087 if (*option == '+')
1088 {
1089 /*
1090 Remove a mask.
1091 */
cristy018f07f2011-09-04 21:15:19 +00001092 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001093 break;
1094 }
1095 /*
1096 Set the image mask.
1097 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1098 */
1099 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1100 if (mask_image == (Image *) NULL)
1101 break;
cristy574cc262011-08-05 01:23:58 +00001102 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
anthonydf8ebac2011-04-27 09:03:19 +00001103 return(MagickFalse);
1104 mask_view=AcquireCacheView(mask_image);
1105 for (y=0; y < (ssize_t) mask_image->rows; y++)
1106 {
1107 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1108 exception);
cristyacd2ed22011-08-30 01:44:23 +00001109 if (q == (Quantum *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001110 break;
1111 for (x=0; x < (ssize_t) mask_image->columns; x++)
1112 {
1113 if (mask_image->matte == MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +00001114 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1115 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1116 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1117 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
cristyed231572011-07-14 02:18:59 +00001118 q+=GetPixelChannels(mask_image);
anthonydf8ebac2011-04-27 09:03:19 +00001119 }
1120 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1121 break;
1122 }
1123 mask_view=DestroyCacheView(mask_view);
1124 mask_image->matte=MagickTrue;
cristy018f07f2011-09-04 21:15:19 +00001125 (void) SetImageClipMask(*image,mask_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001126 InheritException(exception,&(*image)->exception);
1127 break;
1128 }
1129 if (LocaleCompare("clip-path",option+1) == 0)
1130 {
1131 (void) SyncImageSettings(mogrify_info,*image);
1132 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
cristy018f07f2011-09-04 21:15:19 +00001133 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001134 break;
1135 }
1136 if (LocaleCompare("colorize",option+1) == 0)
1137 {
1138 /*
1139 Colorize the image.
1140 */
1141 (void) SyncImageSettings(mogrify_info,*image);
cristyc7e6ff62011-10-03 13:46:11 +00001142 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001143 break;
1144 }
1145 if (LocaleCompare("color-matrix",option+1) == 0)
1146 {
1147 KernelInfo
1148 *kernel;
1149
1150 (void) SyncImageSettings(mogrify_info,*image);
1151 kernel=AcquireKernelInfo(argv[i+1]);
1152 if (kernel == (KernelInfo *) NULL)
1153 break;
1154 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1155 kernel=DestroyKernelInfo(kernel);
1156 break;
1157 }
1158 if (LocaleCompare("colors",option+1) == 0)
1159 {
1160 /*
1161 Reduce the number of colors in the image.
1162 */
1163 (void) SyncImageSettings(mogrify_info,*image);
1164 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1165 if (quantize_info->number_colors == 0)
1166 break;
1167 if (((*image)->storage_class == DirectClass) ||
1168 (*image)->colors > quantize_info->number_colors)
cristy018f07f2011-09-04 21:15:19 +00001169 (void) QuantizeImage(quantize_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001170 else
cristy018f07f2011-09-04 21:15:19 +00001171 (void) CompressImageColormap(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001172 break;
1173 }
1174 if (LocaleCompare("colorspace",option+1) == 0)
1175 {
1176 ColorspaceType
1177 colorspace;
1178
1179 (void) SyncImageSettings(mogrify_info,*image);
1180 if (*option == '+')
1181 {
1182 (void) TransformImageColorspace(*image,RGBColorspace);
1183 InheritException(exception,&(*image)->exception);
1184 break;
1185 }
1186 colorspace=(ColorspaceType) ParseCommandOption(
1187 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1188 (void) TransformImageColorspace(*image,colorspace);
1189 InheritException(exception,&(*image)->exception);
1190 break;
1191 }
cristy633f0c62011-09-15 13:27:36 +00001192 if (LocaleCompare("compose",option+1) == 0)
1193 {
1194 (void) SyncImageSettings(mogrify_info,*image);
1195 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1196 MagickFalse,argv[i+1]);
1197 break;
1198 }
anthonydf8ebac2011-04-27 09:03:19 +00001199 if (LocaleCompare("contrast",option+1) == 0)
1200 {
1201 (void) SyncImageSettings(mogrify_info,*image);
1202 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
cristye23ec9d2011-08-16 18:15:40 +00001203 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001204 break;
1205 }
1206 if (LocaleCompare("contrast-stretch",option+1) == 0)
1207 {
1208 double
1209 black_point,
1210 white_point;
1211
1212 MagickStatusType
1213 flags;
1214
1215 /*
1216 Contrast stretch image.
1217 */
1218 (void) SyncImageSettings(mogrify_info,*image);
1219 flags=ParseGeometry(argv[i+1],&geometry_info);
1220 black_point=geometry_info.rho;
1221 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1222 black_point;
1223 if ((flags & PercentValue) != 0)
1224 {
1225 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1226 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1227 }
1228 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1229 white_point;
cristye23ec9d2011-08-16 18:15:40 +00001230 (void) ContrastStretchImage(*image,black_point,white_point,
1231 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001232 InheritException(exception,&(*image)->exception);
1233 break;
1234 }
1235 if (LocaleCompare("convolve",option+1) == 0)
1236 {
anthonydf8ebac2011-04-27 09:03:19 +00001237 KernelInfo
cristy41cbe682011-07-15 19:12:37 +00001238 *kernel_info;
anthonydf8ebac2011-04-27 09:03:19 +00001239
anthonydf8ebac2011-04-27 09:03:19 +00001240 (void) SyncImageSettings(mogrify_info,*image);
cristy41cbe682011-07-15 19:12:37 +00001241 kernel_info=AcquireKernelInfo(argv[i+1]);
1242 if (kernel_info == (KernelInfo *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001243 break;
cristy0a922382011-07-16 15:30:34 +00001244 kernel_info->bias=(*image)->bias;
cristy5e6be1e2011-07-16 01:23:39 +00001245 mogrify_image=ConvolveImage(*image,kernel_info,exception);
cristy41cbe682011-07-15 19:12:37 +00001246 kernel_info=DestroyKernelInfo(kernel_info);
anthonydf8ebac2011-04-27 09:03:19 +00001247 break;
1248 }
1249 if (LocaleCompare("crop",option+1) == 0)
1250 {
1251 /*
1252 Crop a image to a smaller size
1253 */
1254 (void) SyncImageSettings(mogrify_info,*image);
anthonydf8ebac2011-04-27 09:03:19 +00001255 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00001256 break;
1257 }
1258 if (LocaleCompare("cycle",option+1) == 0)
1259 {
1260 /*
1261 Cycle an image colormap.
1262 */
1263 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00001264 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1265 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001266 break;
1267 }
1268 break;
1269 }
1270 case 'd':
1271 {
1272 if (LocaleCompare("decipher",option+1) == 0)
1273 {
1274 StringInfo
1275 *passkey;
1276
1277 /*
1278 Decipher pixels.
1279 */
1280 (void) SyncImageSettings(mogrify_info,*image);
1281 passkey=FileToStringInfo(argv[i+1],~0,exception);
1282 if (passkey != (StringInfo *) NULL)
1283 {
1284 (void) PasskeyDecipherImage(*image,passkey,exception);
1285 passkey=DestroyStringInfo(passkey);
1286 }
1287 break;
1288 }
1289 if (LocaleCompare("density",option+1) == 0)
1290 {
1291 /*
1292 Set image density.
1293 */
1294 (void) CloneString(&draw_info->density,argv[i+1]);
1295 break;
1296 }
1297 if (LocaleCompare("depth",option+1) == 0)
1298 {
1299 (void) SyncImageSettings(mogrify_info,*image);
1300 if (*option == '+')
1301 {
1302 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1303 break;
1304 }
1305 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1306 break;
1307 }
1308 if (LocaleCompare("deskew",option+1) == 0)
1309 {
1310 double
1311 threshold;
1312
1313 /*
1314 Straighten the image.
1315 */
1316 (void) SyncImageSettings(mogrify_info,*image);
1317 if (*option == '+')
1318 threshold=40.0*QuantumRange/100.0;
1319 else
1320 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1321 mogrify_image=DeskewImage(*image,threshold,exception);
1322 break;
1323 }
1324 if (LocaleCompare("despeckle",option+1) == 0)
1325 {
1326 /*
1327 Reduce the speckles within an image.
1328 */
1329 (void) SyncImageSettings(mogrify_info,*image);
1330 mogrify_image=DespeckleImage(*image,exception);
1331 break;
1332 }
1333 if (LocaleCompare("display",option+1) == 0)
1334 {
1335 (void) CloneString(&draw_info->server_name,argv[i+1]);
1336 break;
1337 }
1338 if (LocaleCompare("distort",option+1) == 0)
1339 {
1340 char
1341 *args,
1342 token[MaxTextExtent];
1343
1344 const char
1345 *p;
1346
1347 DistortImageMethod
1348 method;
1349
1350 double
1351 *arguments;
1352
1353 register ssize_t
1354 x;
1355
1356 size_t
1357 number_arguments;
1358
1359 /*
1360 Distort image.
1361 */
1362 (void) SyncImageSettings(mogrify_info,*image);
1363 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1364 MagickFalse,argv[i+1]);
1365 if ( method == ResizeDistortion )
1366 {
1367 /* Special Case - Argument is actually a resize geometry!
1368 ** Convert that to an appropriate distortion argument array.
1369 */
1370 double
1371 resize_args[2];
1372 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1373 exception);
1374 resize_args[0]=(double)geometry.width;
1375 resize_args[1]=(double)geometry.height;
1376 mogrify_image=DistortImage(*image,method,(size_t)2,
1377 resize_args,MagickTrue,exception);
1378 break;
1379 }
cristy018f07f2011-09-04 21:15:19 +00001380 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1381 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001382 if (args == (char *) NULL)
1383 break;
1384 p=(char *) args;
1385 for (x=0; *p != '\0'; x++)
1386 {
1387 GetMagickToken(p,&p,token);
1388 if (*token == ',')
1389 GetMagickToken(p,&p,token);
1390 }
1391 number_arguments=(size_t) x;
1392 arguments=(double *) AcquireQuantumMemory(number_arguments,
1393 sizeof(*arguments));
1394 if (arguments == (double *) NULL)
1395 ThrowWandFatalException(ResourceLimitFatalError,
1396 "MemoryAllocationFailed",(*image)->filename);
1397 (void) ResetMagickMemory(arguments,0,number_arguments*
1398 sizeof(*arguments));
1399 p=(char *) args;
1400 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1401 {
1402 GetMagickToken(p,&p,token);
1403 if (*token == ',')
1404 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001405 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001406 }
1407 args=DestroyString(args);
1408 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1409 (*option == '+') ? MagickTrue : MagickFalse,exception);
1410 arguments=(double *) RelinquishMagickMemory(arguments);
1411 break;
1412 }
1413 if (LocaleCompare("dither",option+1) == 0)
1414 {
1415 if (*option == '+')
1416 {
1417 quantize_info->dither=MagickFalse;
1418 break;
1419 }
1420 quantize_info->dither=MagickTrue;
1421 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1422 MagickDitherOptions,MagickFalse,argv[i+1]);
1423 if (quantize_info->dither_method == NoDitherMethod)
1424 quantize_info->dither=MagickFalse;
1425 break;
1426 }
1427 if (LocaleCompare("draw",option+1) == 0)
1428 {
1429 /*
1430 Draw image.
1431 */
1432 (void) SyncImageSettings(mogrify_info,*image);
1433 (void) CloneString(&draw_info->primitive,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001434 (void) DrawImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001435 break;
1436 }
1437 break;
1438 }
1439 case 'e':
1440 {
1441 if (LocaleCompare("edge",option+1) == 0)
1442 {
1443 /*
1444 Enhance edges in the image.
1445 */
1446 (void) SyncImageSettings(mogrify_info,*image);
1447 flags=ParseGeometry(argv[i+1],&geometry_info);
1448 if ((flags & SigmaValue) == 0)
1449 geometry_info.sigma=1.0;
cristy8ae632d2011-09-05 17:29:53 +00001450 mogrify_image=EdgeImage(*image,geometry_info.rho,
1451 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001452 break;
1453 }
1454 if (LocaleCompare("emboss",option+1) == 0)
1455 {
1456 /*
1457 Gaussian embossen image.
1458 */
1459 (void) SyncImageSettings(mogrify_info,*image);
1460 flags=ParseGeometry(argv[i+1],&geometry_info);
1461 if ((flags & SigmaValue) == 0)
1462 geometry_info.sigma=1.0;
1463 mogrify_image=EmbossImage(*image,geometry_info.rho,
1464 geometry_info.sigma,exception);
1465 break;
1466 }
1467 if (LocaleCompare("encipher",option+1) == 0)
1468 {
1469 StringInfo
1470 *passkey;
1471
1472 /*
1473 Encipher pixels.
1474 */
1475 (void) SyncImageSettings(mogrify_info,*image);
1476 passkey=FileToStringInfo(argv[i+1],~0,exception);
1477 if (passkey != (StringInfo *) NULL)
1478 {
1479 (void) PasskeyEncipherImage(*image,passkey,exception);
1480 passkey=DestroyStringInfo(passkey);
1481 }
1482 break;
1483 }
1484 if (LocaleCompare("encoding",option+1) == 0)
1485 {
1486 (void) CloneString(&draw_info->encoding,argv[i+1]);
1487 break;
1488 }
1489 if (LocaleCompare("enhance",option+1) == 0)
1490 {
1491 /*
1492 Enhance image.
1493 */
1494 (void) SyncImageSettings(mogrify_info,*image);
1495 mogrify_image=EnhanceImage(*image,exception);
1496 break;
1497 }
1498 if (LocaleCompare("equalize",option+1) == 0)
1499 {
1500 /*
1501 Equalize image.
1502 */
1503 (void) SyncImageSettings(mogrify_info,*image);
cristy6d8c3d72011-08-22 01:20:01 +00001504 (void) EqualizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001505 break;
1506 }
1507 if (LocaleCompare("evaluate",option+1) == 0)
1508 {
1509 double
1510 constant;
1511
1512 MagickEvaluateOperator
1513 op;
1514
1515 (void) SyncImageSettings(mogrify_info,*image);
cristyd42d9952011-07-08 14:21:50 +00001516 op=(MagickEvaluateOperator) ParseCommandOption(
1517 MagickEvaluateOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00001518 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
cristyd42d9952011-07-08 14:21:50 +00001519 (void) EvaluateImage(*image,op,constant,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001520 break;
1521 }
1522 if (LocaleCompare("extent",option+1) == 0)
1523 {
1524 /*
1525 Set the image extent.
1526 */
1527 (void) SyncImageSettings(mogrify_info,*image);
1528 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1529 if (geometry.width == 0)
1530 geometry.width=(*image)->columns;
1531 if (geometry.height == 0)
1532 geometry.height=(*image)->rows;
1533 mogrify_image=ExtentImage(*image,&geometry,exception);
1534 break;
1535 }
1536 break;
1537 }
1538 case 'f':
1539 {
1540 if (LocaleCompare("family",option+1) == 0)
1541 {
1542 if (*option == '+')
1543 {
1544 if (draw_info->family != (char *) NULL)
1545 draw_info->family=DestroyString(draw_info->family);
1546 break;
1547 }
1548 (void) CloneString(&draw_info->family,argv[i+1]);
1549 break;
1550 }
1551 if (LocaleCompare("features",option+1) == 0)
1552 {
1553 if (*option == '+')
1554 {
1555 (void) DeleteImageArtifact(*image,"identify:features");
1556 break;
1557 }
1558 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1559 break;
1560 }
1561 if (LocaleCompare("fill",option+1) == 0)
1562 {
1563 ExceptionInfo
1564 *sans;
1565
cristy4c08aed2011-07-01 19:47:50 +00001566 GetPixelInfo(*image,&fill);
anthonydf8ebac2011-04-27 09:03:19 +00001567 if (*option == '+')
1568 {
cristy9950d572011-10-01 18:22:35 +00001569 (void) QueryMagickColorCompliance("none",AllCompliance,&fill,
1570 exception);
1571 (void) QueryColorCompliance("none",AllCompliance,
1572 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001573 if (draw_info->fill_pattern != (Image *) NULL)
1574 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1575 break;
1576 }
1577 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00001578 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&fill,
1579 sans);
1580 status=QueryColorCompliance(argv[i+1],AllCompliance,
1581 &draw_info->fill,sans);
anthonydf8ebac2011-04-27 09:03:19 +00001582 sans=DestroyExceptionInfo(sans);
1583 if (status == MagickFalse)
1584 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1585 exception);
1586 break;
1587 }
1588 if (LocaleCompare("flip",option+1) == 0)
1589 {
1590 /*
1591 Flip image scanlines.
1592 */
1593 (void) SyncImageSettings(mogrify_info,*image);
1594 mogrify_image=FlipImage(*image,exception);
1595 break;
1596 }
anthonydf8ebac2011-04-27 09:03:19 +00001597 if (LocaleCompare("floodfill",option+1) == 0)
1598 {
cristy4c08aed2011-07-01 19:47:50 +00001599 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001600 target;
1601
1602 /*
1603 Floodfill image.
1604 */
1605 (void) SyncImageSettings(mogrify_info,*image);
1606 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
cristy9950d572011-10-01 18:22:35 +00001607 (void) QueryMagickColorCompliance(argv[i+2],AllCompliance,&target,
1608 exception);
cristyd42d9952011-07-08 14:21:50 +00001609 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
cristy189e84c2011-08-27 18:08:53 +00001610 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001611 break;
1612 }
anthony3d2f4862011-05-01 13:48:16 +00001613 if (LocaleCompare("flop",option+1) == 0)
1614 {
1615 /*
1616 Flop image scanlines.
1617 */
1618 (void) SyncImageSettings(mogrify_info,*image);
1619 mogrify_image=FlopImage(*image,exception);
1620 break;
1621 }
anthonydf8ebac2011-04-27 09:03:19 +00001622 if (LocaleCompare("font",option+1) == 0)
1623 {
1624 if (*option == '+')
1625 {
1626 if (draw_info->font != (char *) NULL)
1627 draw_info->font=DestroyString(draw_info->font);
1628 break;
1629 }
1630 (void) CloneString(&draw_info->font,argv[i+1]);
1631 break;
1632 }
1633 if (LocaleCompare("format",option+1) == 0)
1634 {
1635 format=argv[i+1];
1636 break;
1637 }
1638 if (LocaleCompare("frame",option+1) == 0)
1639 {
1640 FrameInfo
1641 frame_info;
1642
1643 /*
1644 Surround image with an ornamental border.
1645 */
1646 (void) SyncImageSettings(mogrify_info,*image);
1647 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1648 frame_info.width=geometry.width;
1649 frame_info.height=geometry.height;
1650 if ((flags & HeightValue) == 0)
1651 frame_info.height=geometry.width;
1652 frame_info.outer_bevel=geometry.x;
1653 frame_info.inner_bevel=geometry.y;
1654 frame_info.x=(ssize_t) frame_info.width;
1655 frame_info.y=(ssize_t) frame_info.height;
1656 frame_info.width=(*image)->columns+2*frame_info.width;
1657 frame_info.height=(*image)->rows+2*frame_info.height;
cristy633f0c62011-09-15 13:27:36 +00001658 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001659 break;
1660 }
1661 if (LocaleCompare("function",option+1) == 0)
1662 {
1663 char
1664 *arguments,
1665 token[MaxTextExtent];
1666
1667 const char
1668 *p;
1669
1670 double
1671 *parameters;
1672
1673 MagickFunction
1674 function;
1675
1676 register ssize_t
1677 x;
1678
1679 size_t
1680 number_parameters;
1681
1682 /*
1683 Function Modify Image Values
1684 */
1685 (void) SyncImageSettings(mogrify_info,*image);
1686 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1687 MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001688 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1689 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001690 if (arguments == (char *) NULL)
1691 break;
1692 p=(char *) arguments;
1693 for (x=0; *p != '\0'; x++)
1694 {
1695 GetMagickToken(p,&p,token);
1696 if (*token == ',')
1697 GetMagickToken(p,&p,token);
1698 }
1699 number_parameters=(size_t) x;
1700 parameters=(double *) AcquireQuantumMemory(number_parameters,
1701 sizeof(*parameters));
1702 if (parameters == (double *) NULL)
1703 ThrowWandFatalException(ResourceLimitFatalError,
1704 "MemoryAllocationFailed",(*image)->filename);
1705 (void) ResetMagickMemory(parameters,0,number_parameters*
1706 sizeof(*parameters));
1707 p=(char *) arguments;
1708 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1709 {
1710 GetMagickToken(p,&p,token);
1711 if (*token == ',')
1712 GetMagickToken(p,&p,token);
cristyc1acd842011-05-19 23:05:47 +00001713 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001714 }
1715 arguments=DestroyString(arguments);
cristyd42d9952011-07-08 14:21:50 +00001716 (void) FunctionImage(*image,function,number_parameters,parameters,
1717 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001718 parameters=(double *) RelinquishMagickMemory(parameters);
1719 break;
1720 }
1721 break;
1722 }
1723 case 'g':
1724 {
1725 if (LocaleCompare("gamma",option+1) == 0)
1726 {
1727 /*
1728 Gamma image.
1729 */
1730 (void) SyncImageSettings(mogrify_info,*image);
1731 if (*option == '+')
cristyc1acd842011-05-19 23:05:47 +00001732 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001733 else
cristyb3e7c6c2011-07-24 01:43:55 +00001734 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1735 (char **) NULL),exception);
anthonydf8ebac2011-04-27 09:03:19 +00001736 break;
1737 }
1738 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1739 (LocaleCompare("gaussian",option+1) == 0))
1740 {
1741 /*
1742 Gaussian blur image.
1743 */
1744 (void) SyncImageSettings(mogrify_info,*image);
1745 flags=ParseGeometry(argv[i+1],&geometry_info);
1746 if ((flags & SigmaValue) == 0)
1747 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001748 if ((flags & XiValue) == 0)
1749 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00001750 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001751 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001752 break;
1753 }
1754 if (LocaleCompare("geometry",option+1) == 0)
1755 {
1756 /*
1757 Record Image offset, Resize last image.
1758 */
1759 (void) SyncImageSettings(mogrify_info,*image);
1760 if (*option == '+')
1761 {
1762 if ((*image)->geometry != (char *) NULL)
1763 (*image)->geometry=DestroyString((*image)->geometry);
1764 break;
1765 }
1766 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1767 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1768 (void) CloneString(&(*image)->geometry,argv[i+1]);
1769 else
1770 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1771 (*image)->filter,(*image)->blur,exception);
1772 break;
1773 }
1774 if (LocaleCompare("gravity",option+1) == 0)
1775 {
1776 if (*option == '+')
1777 {
1778 draw_info->gravity=UndefinedGravity;
1779 break;
1780 }
1781 draw_info->gravity=(GravityType) ParseCommandOption(
1782 MagickGravityOptions,MagickFalse,argv[i+1]);
1783 break;
1784 }
1785 break;
1786 }
1787 case 'h':
1788 {
1789 if (LocaleCompare("highlight-color",option+1) == 0)
1790 {
1791 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1792 break;
1793 }
1794 break;
1795 }
1796 case 'i':
1797 {
1798 if (LocaleCompare("identify",option+1) == 0)
1799 {
1800 char
1801 *text;
1802
1803 (void) SyncImageSettings(mogrify_info,*image);
1804 if (format == (char *) NULL)
1805 {
cristya4037272011-08-28 15:11:39 +00001806 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1807 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001808 break;
1809 }
cristy018f07f2011-09-04 21:15:19 +00001810 text=InterpretImageProperties(mogrify_info,*image,format,
1811 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001812 if (text == (char *) NULL)
1813 break;
1814 (void) fputs(text,stdout);
1815 (void) fputc('\n',stdout);
1816 text=DestroyString(text);
1817 break;
1818 }
1819 if (LocaleCompare("implode",option+1) == 0)
1820 {
1821 /*
1822 Implode image.
1823 */
1824 (void) SyncImageSettings(mogrify_info,*image);
1825 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00001826 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1827 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001828 break;
1829 }
1830 if (LocaleCompare("interline-spacing",option+1) == 0)
1831 {
1832 if (*option == '+')
1833 (void) ParseGeometry("0",&geometry_info);
1834 else
1835 (void) ParseGeometry(argv[i+1],&geometry_info);
1836 draw_info->interline_spacing=geometry_info.rho;
1837 break;
1838 }
cristy28474bf2011-09-11 23:32:52 +00001839 if (LocaleCompare("interpolate",option+1) == 0)
1840 {
1841 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1842 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1843 break;
1844 }
anthonydf8ebac2011-04-27 09:03:19 +00001845 if (LocaleCompare("interword-spacing",option+1) == 0)
1846 {
1847 if (*option == '+')
1848 (void) ParseGeometry("0",&geometry_info);
1849 else
1850 (void) ParseGeometry(argv[i+1],&geometry_info);
1851 draw_info->interword_spacing=geometry_info.rho;
1852 break;
1853 }
1854 break;
1855 }
1856 case 'k':
1857 {
1858 if (LocaleCompare("kerning",option+1) == 0)
1859 {
1860 if (*option == '+')
1861 (void) ParseGeometry("0",&geometry_info);
1862 else
1863 (void) ParseGeometry(argv[i+1],&geometry_info);
1864 draw_info->kerning=geometry_info.rho;
1865 break;
1866 }
1867 break;
1868 }
1869 case 'l':
1870 {
1871 if (LocaleCompare("lat",option+1) == 0)
1872 {
1873 /*
1874 Local adaptive threshold image.
1875 */
1876 (void) SyncImageSettings(mogrify_info,*image);
1877 flags=ParseGeometry(argv[i+1],&geometry_info);
1878 if ((flags & PercentValue) != 0)
1879 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1880 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
cristyde5cc632011-07-18 14:47:00 +00001881 geometry_info.rho,(size_t) geometry_info.sigma,(double)
anthonydf8ebac2011-04-27 09:03:19 +00001882 geometry_info.xi,exception);
1883 break;
1884 }
1885 if (LocaleCompare("level",option+1) == 0)
1886 {
1887 MagickRealType
1888 black_point,
1889 gamma,
1890 white_point;
1891
1892 MagickStatusType
1893 flags;
1894
1895 /*
1896 Parse levels.
1897 */
1898 (void) SyncImageSettings(mogrify_info,*image);
1899 flags=ParseGeometry(argv[i+1],&geometry_info);
1900 black_point=geometry_info.rho;
1901 white_point=(MagickRealType) QuantumRange;
1902 if ((flags & SigmaValue) != 0)
1903 white_point=geometry_info.sigma;
1904 gamma=1.0;
1905 if ((flags & XiValue) != 0)
1906 gamma=geometry_info.xi;
1907 if ((flags & PercentValue) != 0)
1908 {
1909 black_point*=(MagickRealType) (QuantumRange/100.0);
1910 white_point*=(MagickRealType) (QuantumRange/100.0);
1911 }
1912 if ((flags & SigmaValue) == 0)
1913 white_point=(MagickRealType) QuantumRange-black_point;
1914 if ((*option == '+') || ((flags & AspectValue) != 0))
cristy7c0a0a42011-08-23 17:57:25 +00001915 (void) LevelizeImage(*image,black_point,white_point,gamma,
1916 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001917 else
cristy01e9afd2011-08-10 17:38:41 +00001918 (void) LevelImage(*image,black_point,white_point,gamma,
1919 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001920 InheritException(exception,&(*image)->exception);
1921 break;
1922 }
1923 if (LocaleCompare("level-colors",option+1) == 0)
1924 {
1925 char
1926 token[MaxTextExtent];
1927
1928 const char
1929 *p;
1930
cristy4c08aed2011-07-01 19:47:50 +00001931 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001932 black_point,
1933 white_point;
1934
1935 p=(const char *) argv[i+1];
1936 GetMagickToken(p,&p,token); /* get black point color */
1937 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy9950d572011-10-01 18:22:35 +00001938 (void) QueryMagickColorCompliance(token,AllCompliance,
1939 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001940 else
cristy9950d572011-10-01 18:22:35 +00001941 (void) QueryMagickColorCompliance("#000000",AllCompliance,
1942 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001943 if (isalpha((int) token[0]) || (token[0] == '#'))
1944 GetMagickToken(p,&p,token);
1945 if (*token == '\0')
1946 white_point=black_point; /* set everything to that color */
1947 else
1948 {
1949 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1950 GetMagickToken(p,&p,token); /* Get white point color. */
1951 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy9950d572011-10-01 18:22:35 +00001952 (void) QueryMagickColorCompliance(token,AllCompliance,
1953 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001954 else
cristy9950d572011-10-01 18:22:35 +00001955 (void) QueryMagickColorCompliance("#ffffff",AllCompliance,
1956 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001957 }
cristy490408a2011-07-07 14:42:05 +00001958 (void) LevelImageColors(*image,&black_point,&white_point,
cristy7c0a0a42011-08-23 17:57:25 +00001959 *option == '+' ? MagickTrue : MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001960 break;
1961 }
1962 if (LocaleCompare("linear-stretch",option+1) == 0)
1963 {
1964 double
1965 black_point,
1966 white_point;
1967
1968 MagickStatusType
1969 flags;
1970
1971 (void) SyncImageSettings(mogrify_info,*image);
1972 flags=ParseGeometry(argv[i+1],&geometry_info);
1973 black_point=geometry_info.rho;
1974 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1975 if ((flags & SigmaValue) != 0)
1976 white_point=geometry_info.sigma;
1977 if ((flags & PercentValue) != 0)
1978 {
1979 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1980 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1981 }
1982 if ((flags & SigmaValue) == 0)
1983 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1984 black_point;
cristy33bd5152011-08-24 01:42:24 +00001985 (void) LinearStretchImage(*image,black_point,white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001986 InheritException(exception,&(*image)->exception);
1987 break;
1988 }
1989 if (LocaleCompare("linewidth",option+1) == 0)
1990 {
cristyc1acd842011-05-19 23:05:47 +00001991 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1992 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001993 break;
1994 }
1995 if (LocaleCompare("liquid-rescale",option+1) == 0)
1996 {
1997 /*
1998 Liquid rescale image.
1999 */
2000 (void) SyncImageSettings(mogrify_info,*image);
2001 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2002 if ((flags & XValue) == 0)
2003 geometry.x=1;
2004 if ((flags & YValue) == 0)
2005 geometry.y=0;
2006 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2007 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2008 break;
2009 }
2010 if (LocaleCompare("lowlight-color",option+1) == 0)
2011 {
2012 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2013 break;
2014 }
2015 break;
2016 }
2017 case 'm':
2018 {
2019 if (LocaleCompare("map",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00002020 {
cristy3ed852e2009-09-05 21:47:34 +00002021 Image
anthonydf8ebac2011-04-27 09:03:19 +00002022 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002023
anthonydf8ebac2011-04-27 09:03:19 +00002024 /*
2025 Transform image colors to match this set of colors.
2026 */
2027 (void) SyncImageSettings(mogrify_info,*image);
2028 if (*option == '+')
2029 break;
2030 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2031 if (remap_image == (Image *) NULL)
2032 break;
cristy018f07f2011-09-04 21:15:19 +00002033 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002034 remap_image=DestroyImage(remap_image);
2035 break;
2036 }
2037 if (LocaleCompare("mask",option+1) == 0)
2038 {
2039 Image
2040 *mask;
2041
2042 (void) SyncImageSettings(mogrify_info,*image);
2043 if (*option == '+')
2044 {
2045 /*
2046 Remove a mask.
2047 */
cristy018f07f2011-09-04 21:15:19 +00002048 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002049 break;
2050 }
2051 /*
2052 Set the image mask.
2053 */
2054 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2055 if (mask == (Image *) NULL)
2056 break;
cristy018f07f2011-09-04 21:15:19 +00002057 (void) SetImageMask(*image,mask,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002058 mask=DestroyImage(mask);
anthonydf8ebac2011-04-27 09:03:19 +00002059 break;
2060 }
2061 if (LocaleCompare("matte",option+1) == 0)
2062 {
2063 (void) SetImageAlphaChannel(*image,(*option == '-') ?
cristy63240882011-08-05 19:05:27 +00002064 SetAlphaChannel : DeactivateAlphaChannel,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002065 break;
2066 }
2067 if (LocaleCompare("median",option+1) == 0)
2068 {
2069 /*
2070 Median filter image.
2071 */
2072 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002073 flags=ParseGeometry(argv[i+1],&geometry_info);
2074 if ((flags & SigmaValue) == 0)
2075 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002076 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002077 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002078 break;
2079 }
2080 if (LocaleCompare("mode",option+1) == 0)
2081 {
2082 /*
2083 Mode image.
2084 */
2085 (void) SyncImageSettings(mogrify_info,*image);
cristyf36cbcb2011-09-07 13:28:22 +00002086 flags=ParseGeometry(argv[i+1],&geometry_info);
2087 if ((flags & SigmaValue) == 0)
2088 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002089 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002090 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002091 break;
2092 }
2093 if (LocaleCompare("modulate",option+1) == 0)
2094 {
2095 (void) SyncImageSettings(mogrify_info,*image);
cristy33bd5152011-08-24 01:42:24 +00002096 (void) ModulateImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002097 break;
2098 }
2099 if (LocaleCompare("monitor",option+1) == 0)
2100 {
2101 if (*option == '+')
2102 {
2103 (void) SetImageProgressMonitor(*image,
2104 (MagickProgressMonitor) NULL,(void *) NULL);
2105 break;
2106 }
2107 (void) SetImageProgressMonitor(*image,MonitorProgress,
2108 (void *) NULL);
2109 break;
2110 }
2111 if (LocaleCompare("monochrome",option+1) == 0)
2112 {
2113 (void) SyncImageSettings(mogrify_info,*image);
cristy018f07f2011-09-04 21:15:19 +00002114 (void) SetImageType(*image,BilevelType,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002115 break;
2116 }
2117 if (LocaleCompare("morphology",option+1) == 0)
2118 {
2119 char
2120 token[MaxTextExtent];
2121
2122 const char
2123 *p;
2124
2125 KernelInfo
2126 *kernel;
2127
2128 MorphologyMethod
2129 method;
2130
2131 ssize_t
2132 iterations;
2133
2134 /*
2135 Morphological Image Operation
2136 */
2137 (void) SyncImageSettings(mogrify_info,*image);
2138 p=argv[i+1];
2139 GetMagickToken(p,&p,token);
cristy28474bf2011-09-11 23:32:52 +00002140 method=(MorphologyMethod) ParseCommandOption(
2141 MagickMorphologyOptions,MagickFalse,token);
anthonydf8ebac2011-04-27 09:03:19 +00002142 iterations=1L;
2143 GetMagickToken(p,&p,token);
2144 if ((*p == ':') || (*p == ','))
2145 GetMagickToken(p,&p,token);
2146 if ((*p != '\0'))
2147 iterations=(ssize_t) StringToLong(p);
2148 kernel=AcquireKernelInfo(argv[i+2]);
2149 if (kernel == (KernelInfo *) NULL)
2150 {
2151 (void) ThrowMagickException(exception,GetMagickModule(),
2152 OptionError,"UnabletoParseKernel","morphology");
2153 status=MagickFalse;
2154 break;
2155 }
cristyf4ad9df2011-07-08 16:49:03 +00002156 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2157 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002158 kernel=DestroyKernelInfo(kernel);
2159 break;
2160 }
2161 if (LocaleCompare("motion-blur",option+1) == 0)
2162 {
2163 /*
2164 Motion blur image.
2165 */
2166 (void) SyncImageSettings(mogrify_info,*image);
2167 flags=ParseGeometry(argv[i+1],&geometry_info);
2168 if ((flags & SigmaValue) == 0)
2169 geometry_info.sigma=1.0;
cristyf4ad9df2011-07-08 16:49:03 +00002170 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002171 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
2172 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002173 break;
2174 }
2175 break;
2176 }
2177 case 'n':
2178 {
2179 if (LocaleCompare("negate",option+1) == 0)
2180 {
2181 (void) SyncImageSettings(mogrify_info,*image);
cristy50fbc382011-07-07 02:19:17 +00002182 (void) NegateImage(*image,*option == '+' ? MagickTrue :
cristyb3e7c6c2011-07-24 01:43:55 +00002183 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002184 break;
2185 }
2186 if (LocaleCompare("noise",option+1) == 0)
2187 {
2188 (void) SyncImageSettings(mogrify_info,*image);
2189 if (*option == '-')
2190 {
cristyf36cbcb2011-09-07 13:28:22 +00002191 flags=ParseGeometry(argv[i+1],&geometry_info);
2192 if ((flags & SigmaValue) == 0)
2193 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002194 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002195 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002196 }
2197 else
2198 {
2199 NoiseType
2200 noise;
2201
2202 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2203 MagickFalse,argv[i+1]);
cristy9ed1f812011-10-08 02:00:08 +00002204 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002205 }
2206 break;
2207 }
2208 if (LocaleCompare("normalize",option+1) == 0)
2209 {
2210 (void) SyncImageSettings(mogrify_info,*image);
cristye23ec9d2011-08-16 18:15:40 +00002211 (void) NormalizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002212 break;
2213 }
2214 break;
2215 }
2216 case 'o':
2217 {
2218 if (LocaleCompare("opaque",option+1) == 0)
2219 {
cristy4c08aed2011-07-01 19:47:50 +00002220 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002221 target;
2222
2223 (void) SyncImageSettings(mogrify_info,*image);
cristy9950d572011-10-01 18:22:35 +00002224 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
2225 exception);
cristyd42d9952011-07-08 14:21:50 +00002226 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
cristy189e84c2011-08-27 18:08:53 +00002227 MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002228 break;
2229 }
2230 if (LocaleCompare("ordered-dither",option+1) == 0)
2231 {
2232 (void) SyncImageSettings(mogrify_info,*image);
cristy13020672011-07-08 02:33:26 +00002233 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002234 break;
2235 }
2236 break;
2237 }
2238 case 'p':
2239 {
2240 if (LocaleCompare("paint",option+1) == 0)
2241 {
anthonydf8ebac2011-04-27 09:03:19 +00002242 (void) SyncImageSettings(mogrify_info,*image);
2243 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy14973ba2011-08-27 23:48:07 +00002244 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2245 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002246 break;
2247 }
2248 if (LocaleCompare("pen",option+1) == 0)
2249 {
2250 if (*option == '+')
2251 {
cristy9950d572011-10-01 18:22:35 +00002252 (void) QueryColorCompliance("none",AllCompliance,
2253 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002254 break;
2255 }
cristy9950d572011-10-01 18:22:35 +00002256 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2257 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002258 break;
2259 }
2260 if (LocaleCompare("pointsize",option+1) == 0)
2261 {
2262 if (*option == '+')
2263 (void) ParseGeometry("12",&geometry_info);
2264 else
2265 (void) ParseGeometry(argv[i+1],&geometry_info);
2266 draw_info->pointsize=geometry_info.rho;
2267 break;
2268 }
2269 if (LocaleCompare("polaroid",option+1) == 0)
2270 {
2271 double
2272 angle;
2273
2274 RandomInfo
2275 *random_info;
2276
2277 /*
2278 Simulate a Polaroid picture.
2279 */
2280 (void) SyncImageSettings(mogrify_info,*image);
2281 random_info=AcquireRandomInfo();
2282 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2283 random_info=DestroyRandomInfo(random_info);
2284 if (*option == '-')
2285 {
2286 SetGeometryInfo(&geometry_info);
2287 flags=ParseGeometry(argv[i+1],&geometry_info);
2288 angle=geometry_info.rho;
2289 }
cristy5c4e2582011-09-11 19:21:03 +00002290 mogrify_image=PolaroidImage(*image,draw_info,angle,
cristy28474bf2011-09-11 23:32:52 +00002291 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002292 break;
2293 }
2294 if (LocaleCompare("posterize",option+1) == 0)
2295 {
2296 /*
2297 Posterize image.
2298 */
2299 (void) SyncImageSettings(mogrify_info,*image);
2300 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy018f07f2011-09-04 21:15:19 +00002301 quantize_info->dither,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002302 break;
2303 }
2304 if (LocaleCompare("preview",option+1) == 0)
2305 {
2306 PreviewType
2307 preview_type;
2308
2309 /*
2310 Preview image.
2311 */
2312 (void) SyncImageSettings(mogrify_info,*image);
2313 if (*option == '+')
2314 preview_type=UndefinedPreview;
2315 else
cristy28474bf2011-09-11 23:32:52 +00002316 preview_type=(PreviewType) ParseCommandOption(
2317 MagickPreviewOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002318 mogrify_image=PreviewImage(*image,preview_type,exception);
2319 break;
2320 }
2321 if (LocaleCompare("profile",option+1) == 0)
2322 {
2323 const char
2324 *name;
2325
2326 const StringInfo
2327 *profile;
2328
2329 Image
2330 *profile_image;
2331
2332 ImageInfo
2333 *profile_info;
2334
2335 (void) SyncImageSettings(mogrify_info,*image);
2336 if (*option == '+')
2337 {
2338 /*
2339 Remove a profile from the image.
2340 */
2341 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2342 NULL,0,MagickTrue);
2343 InheritException(exception,&(*image)->exception);
2344 break;
2345 }
2346 /*
2347 Associate a profile with the image.
2348 */
2349 profile_info=CloneImageInfo(mogrify_info);
2350 profile=GetImageProfile(*image,"iptc");
2351 if (profile != (StringInfo *) NULL)
2352 profile_info->profile=(void *) CloneStringInfo(profile);
2353 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2354 profile_info=DestroyImageInfo(profile_info);
2355 if (profile_image == (Image *) NULL)
2356 {
2357 StringInfo
2358 *profile;
2359
2360 profile_info=CloneImageInfo(mogrify_info);
2361 (void) CopyMagickString(profile_info->filename,argv[i+1],
2362 MaxTextExtent);
2363 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2364 if (profile != (StringInfo *) NULL)
2365 {
2366 (void) ProfileImage(*image,profile_info->magick,
2367 GetStringInfoDatum(profile),(size_t)
2368 GetStringInfoLength(profile),MagickFalse);
2369 profile=DestroyStringInfo(profile);
2370 }
2371 profile_info=DestroyImageInfo(profile_info);
2372 break;
2373 }
2374 ResetImageProfileIterator(profile_image);
2375 name=GetNextImageProfile(profile_image);
2376 while (name != (const char *) NULL)
2377 {
2378 profile=GetImageProfile(profile_image,name);
2379 if (profile != (StringInfo *) NULL)
2380 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2381 (size_t) GetStringInfoLength(profile),MagickFalse);
2382 name=GetNextImageProfile(profile_image);
2383 }
2384 profile_image=DestroyImage(profile_image);
2385 break;
2386 }
2387 break;
2388 }
2389 case 'q':
2390 {
2391 if (LocaleCompare("quantize",option+1) == 0)
2392 {
2393 if (*option == '+')
2394 {
2395 quantize_info->colorspace=UndefinedColorspace;
2396 break;
2397 }
2398 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2399 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2400 break;
2401 }
2402 break;
2403 }
2404 case 'r':
2405 {
2406 if (LocaleCompare("radial-blur",option+1) == 0)
2407 {
2408 /*
2409 Radial blur image.
2410 */
2411 (void) SyncImageSettings(mogrify_info,*image);
cristy6435bd92011-09-10 02:10:07 +00002412 flags=ParseGeometry(argv[i+1],&geometry_info);
2413 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2414 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002415 break;
2416 }
2417 if (LocaleCompare("raise",option+1) == 0)
2418 {
2419 /*
2420 Surround image with a raise of solid color.
2421 */
2422 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2423 if ((flags & SigmaValue) == 0)
2424 geometry.height=geometry.width;
2425 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
cristy6170ac32011-08-28 14:15:37 +00002426 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002427 break;
2428 }
2429 if (LocaleCompare("random-threshold",option+1) == 0)
2430 {
2431 /*
2432 Threshold image.
2433 */
2434 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00002435 (void) RandomThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002436 break;
2437 }
2438 if (LocaleCompare("recolor",option+1) == 0)
2439 {
2440 KernelInfo
2441 *kernel;
2442
2443 (void) SyncImageSettings(mogrify_info,*image);
2444 kernel=AcquireKernelInfo(argv[i+1]);
2445 if (kernel == (KernelInfo *) NULL)
2446 break;
2447 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2448 kernel=DestroyKernelInfo(kernel);
2449 break;
2450 }
2451 if (LocaleCompare("region",option+1) == 0)
2452 {
2453 (void) SyncImageSettings(mogrify_info,*image);
2454 if (region_image != (Image *) NULL)
2455 {
2456 /*
2457 Composite region.
2458 */
2459 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00002460 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2461 region_geometry.x,region_geometry.y);
anthonydf8ebac2011-04-27 09:03:19 +00002462 InheritException(exception,&region_image->exception);
2463 *image=DestroyImage(*image);
2464 *image=region_image;
2465 region_image = (Image *) NULL;
2466 }
2467 if (*option == '+')
2468 break;
2469 /*
2470 Apply transformations to a selected region of the image.
2471 */
cristy3ed852e2009-09-05 21:47:34 +00002472 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2473 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002474 mogrify_image=CropImage(*image,&region_geometry,exception);
2475 if (mogrify_image == (Image *) NULL)
2476 break;
2477 region_image=(*image);
2478 *image=mogrify_image;
2479 mogrify_image=(Image *) NULL;
2480 break;
cristy3ed852e2009-09-05 21:47:34 +00002481 }
anthonydf8ebac2011-04-27 09:03:19 +00002482 if (LocaleCompare("render",option+1) == 0)
2483 {
2484 (void) SyncImageSettings(mogrify_info,*image);
2485 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2486 break;
2487 }
2488 if (LocaleCompare("remap",option+1) == 0)
2489 {
2490 Image
2491 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002492
anthonydf8ebac2011-04-27 09:03:19 +00002493 /*
2494 Transform image colors to match this set of colors.
2495 */
2496 (void) SyncImageSettings(mogrify_info,*image);
2497 if (*option == '+')
2498 break;
2499 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2500 if (remap_image == (Image *) NULL)
2501 break;
cristy018f07f2011-09-04 21:15:19 +00002502 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002503 remap_image=DestroyImage(remap_image);
2504 break;
2505 }
2506 if (LocaleCompare("repage",option+1) == 0)
2507 {
2508 if (*option == '+')
2509 {
2510 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2511 break;
2512 }
2513 (void) ResetImagePage(*image,argv[i+1]);
2514 InheritException(exception,&(*image)->exception);
2515 break;
2516 }
2517 if (LocaleCompare("resample",option+1) == 0)
2518 {
2519 /*
2520 Resample image.
2521 */
2522 (void) SyncImageSettings(mogrify_info,*image);
2523 flags=ParseGeometry(argv[i+1],&geometry_info);
2524 if ((flags & SigmaValue) == 0)
2525 geometry_info.sigma=geometry_info.rho;
2526 mogrify_image=ResampleImage(*image,geometry_info.rho,
2527 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2528 break;
2529 }
2530 if (LocaleCompare("resize",option+1) == 0)
2531 {
2532 /*
2533 Resize image.
2534 */
2535 (void) SyncImageSettings(mogrify_info,*image);
2536 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2537 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2538 (*image)->filter,(*image)->blur,exception);
2539 break;
2540 }
2541 if (LocaleCompare("roll",option+1) == 0)
2542 {
2543 /*
2544 Roll image.
2545 */
2546 (void) SyncImageSettings(mogrify_info,*image);
2547 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2548 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2549 break;
2550 }
2551 if (LocaleCompare("rotate",option+1) == 0)
2552 {
2553 char
2554 *geometry;
2555
2556 /*
2557 Check for conditional image rotation.
2558 */
2559 (void) SyncImageSettings(mogrify_info,*image);
2560 if (strchr(argv[i+1],'>') != (char *) NULL)
2561 if ((*image)->columns <= (*image)->rows)
2562 break;
2563 if (strchr(argv[i+1],'<') != (char *) NULL)
2564 if ((*image)->columns >= (*image)->rows)
2565 break;
2566 /*
2567 Rotate image.
2568 */
2569 geometry=ConstantString(argv[i+1]);
2570 (void) SubstituteString(&geometry,">","");
2571 (void) SubstituteString(&geometry,"<","");
2572 (void) ParseGeometry(geometry,&geometry_info);
2573 geometry=DestroyString(geometry);
2574 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2575 break;
2576 }
2577 break;
2578 }
2579 case 's':
2580 {
2581 if (LocaleCompare("sample",option+1) == 0)
2582 {
2583 /*
2584 Sample image with pixel replication.
2585 */
2586 (void) SyncImageSettings(mogrify_info,*image);
2587 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2588 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2589 exception);
2590 break;
2591 }
2592 if (LocaleCompare("scale",option+1) == 0)
2593 {
2594 /*
2595 Resize image.
2596 */
2597 (void) SyncImageSettings(mogrify_info,*image);
2598 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2599 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2600 exception);
2601 break;
2602 }
2603 if (LocaleCompare("selective-blur",option+1) == 0)
2604 {
2605 /*
2606 Selectively blur pixels within a contrast threshold.
2607 */
2608 (void) SyncImageSettings(mogrify_info,*image);
2609 flags=ParseGeometry(argv[i+1],&geometry_info);
2610 if ((flags & PercentValue) != 0)
2611 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristyf4ad9df2011-07-08 16:49:03 +00002612 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
cristy1e7aa312011-09-10 20:01:36 +00002613 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002614 break;
2615 }
2616 if (LocaleCompare("separate",option+1) == 0)
2617 {
2618 /*
2619 Break channels into separate images.
anthonydf8ebac2011-04-27 09:03:19 +00002620 */
2621 (void) SyncImageSettings(mogrify_info,*image);
cristy3139dc22011-07-08 00:11:42 +00002622 mogrify_image=SeparateImages(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002623 break;
2624 }
2625 if (LocaleCompare("sepia-tone",option+1) == 0)
2626 {
2627 double
2628 threshold;
2629
2630 /*
2631 Sepia-tone image.
2632 */
2633 (void) SyncImageSettings(mogrify_info,*image);
2634 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2635 mogrify_image=SepiaToneImage(*image,threshold,exception);
2636 break;
2637 }
2638 if (LocaleCompare("segment",option+1) == 0)
2639 {
2640 /*
2641 Segment image.
2642 */
2643 (void) SyncImageSettings(mogrify_info,*image);
2644 flags=ParseGeometry(argv[i+1],&geometry_info);
2645 if ((flags & SigmaValue) == 0)
2646 geometry_info.sigma=1.0;
2647 (void) SegmentImage(*image,(*image)->colorspace,
cristy018f07f2011-09-04 21:15:19 +00002648 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2649 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002650 break;
2651 }
2652 if (LocaleCompare("set",option+1) == 0)
2653 {
2654 char
2655 *value;
2656
2657 /*
2658 Set image option.
2659 */
2660 if (*option == '+')
2661 {
2662 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2663 (void) DeleteImageRegistry(argv[i+1]+9);
2664 else
2665 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2666 {
2667 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2668 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2669 }
2670 else
2671 (void) DeleteImageProperty(*image,argv[i+1]);
2672 break;
2673 }
cristy018f07f2011-09-04 21:15:19 +00002674 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2675 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002676 if (value == (char *) NULL)
2677 break;
2678 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2679 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2680 exception);
2681 else
2682 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2683 {
2684 (void) SetImageOption(image_info,argv[i+1]+7,value);
2685 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2686 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2687 }
2688 else
2689 (void) SetImageProperty(*image,argv[i+1],value);
2690 value=DestroyString(value);
2691 break;
2692 }
2693 if (LocaleCompare("shade",option+1) == 0)
2694 {
2695 /*
2696 Shade image.
2697 */
2698 (void) SyncImageSettings(mogrify_info,*image);
2699 flags=ParseGeometry(argv[i+1],&geometry_info);
2700 if ((flags & SigmaValue) == 0)
2701 geometry_info.sigma=1.0;
2702 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2703 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2704 break;
2705 }
2706 if (LocaleCompare("shadow",option+1) == 0)
2707 {
2708 /*
2709 Shadow image.
2710 */
2711 (void) SyncImageSettings(mogrify_info,*image);
2712 flags=ParseGeometry(argv[i+1],&geometry_info);
2713 if ((flags & SigmaValue) == 0)
2714 geometry_info.sigma=1.0;
2715 if ((flags & XiValue) == 0)
2716 geometry_info.xi=4.0;
2717 if ((flags & PsiValue) == 0)
2718 geometry_info.psi=4.0;
2719 mogrify_image=ShadowImage(*image,geometry_info.rho,
2720 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2721 ceil(geometry_info.psi-0.5),exception);
2722 break;
2723 }
2724 if (LocaleCompare("sharpen",option+1) == 0)
2725 {
2726 /*
2727 Sharpen image.
2728 */
2729 (void) SyncImageSettings(mogrify_info,*image);
2730 flags=ParseGeometry(argv[i+1],&geometry_info);
2731 if ((flags & SigmaValue) == 0)
2732 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00002733 if ((flags & XiValue) == 0)
2734 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00002735 mogrify_image=SharpenImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00002736 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002737 break;
2738 }
2739 if (LocaleCompare("shave",option+1) == 0)
2740 {
2741 /*
2742 Shave the image edges.
2743 */
2744 (void) SyncImageSettings(mogrify_info,*image);
2745 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2746 mogrify_image=ShaveImage(*image,&geometry,exception);
2747 break;
2748 }
2749 if (LocaleCompare("shear",option+1) == 0)
2750 {
2751 /*
2752 Shear image.
2753 */
2754 (void) SyncImageSettings(mogrify_info,*image);
2755 flags=ParseGeometry(argv[i+1],&geometry_info);
2756 if ((flags & SigmaValue) == 0)
2757 geometry_info.sigma=geometry_info.rho;
2758 mogrify_image=ShearImage(*image,geometry_info.rho,
2759 geometry_info.sigma,exception);
2760 break;
2761 }
2762 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2763 {
2764 /*
2765 Sigmoidal non-linearity contrast control.
2766 */
2767 (void) SyncImageSettings(mogrify_info,*image);
2768 flags=ParseGeometry(argv[i+1],&geometry_info);
2769 if ((flags & SigmaValue) == 0)
2770 geometry_info.sigma=(double) QuantumRange/2.0;
2771 if ((flags & PercentValue) != 0)
2772 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2773 100.0;
cristy9ee60942011-07-06 14:54:38 +00002774 (void) SigmoidalContrastImage(*image,(*option == '-') ?
cristy33bd5152011-08-24 01:42:24 +00002775 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2776 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002777 break;
2778 }
2779 if (LocaleCompare("sketch",option+1) == 0)
2780 {
2781 /*
2782 Sketch image.
2783 */
2784 (void) SyncImageSettings(mogrify_info,*image);
2785 flags=ParseGeometry(argv[i+1],&geometry_info);
2786 if ((flags & SigmaValue) == 0)
2787 geometry_info.sigma=1.0;
2788 mogrify_image=SketchImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002789 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002790 break;
2791 }
2792 if (LocaleCompare("solarize",option+1) == 0)
2793 {
2794 double
2795 threshold;
2796
2797 (void) SyncImageSettings(mogrify_info,*image);
2798 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy5cbc0162011-08-29 00:36:28 +00002799 (void) SolarizeImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002800 break;
2801 }
2802 if (LocaleCompare("sparse-color",option+1) == 0)
2803 {
2804 SparseColorMethod
2805 method;
2806
2807 char
2808 *arguments;
2809
2810 /*
2811 Sparse Color Interpolated Gradient
2812 */
2813 (void) SyncImageSettings(mogrify_info,*image);
2814 method=(SparseColorMethod) ParseCommandOption(
2815 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00002816 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2817 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002818 if (arguments == (char *) NULL)
2819 break;
cristy3884f692011-07-08 18:00:18 +00002820 mogrify_image=SparseColorOption(*image,method,arguments,
anthonydf8ebac2011-04-27 09:03:19 +00002821 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2822 arguments=DestroyString(arguments);
2823 break;
2824 }
2825 if (LocaleCompare("splice",option+1) == 0)
2826 {
2827 /*
2828 Splice a solid color into the image.
2829 */
2830 (void) SyncImageSettings(mogrify_info,*image);
2831 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2832 mogrify_image=SpliceImage(*image,&geometry,exception);
2833 break;
2834 }
2835 if (LocaleCompare("spread",option+1) == 0)
2836 {
2837 /*
2838 Spread an image.
2839 */
2840 (void) SyncImageSettings(mogrify_info,*image);
2841 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy5c4e2582011-09-11 19:21:03 +00002842 mogrify_image=SpreadImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00002843 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002844 break;
2845 }
2846 if (LocaleCompare("statistic",option+1) == 0)
2847 {
2848 StatisticType
2849 type;
2850
2851 (void) SyncImageSettings(mogrify_info,*image);
2852 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2853 MagickFalse,argv[i+1]);
2854 (void) ParseGeometry(argv[i+2],&geometry_info);
cristyf4ad9df2011-07-08 16:49:03 +00002855 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2856 (size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002857 break;
2858 }
2859 if (LocaleCompare("stretch",option+1) == 0)
2860 {
2861 if (*option == '+')
2862 {
2863 draw_info->stretch=UndefinedStretch;
2864 break;
2865 }
2866 draw_info->stretch=(StretchType) ParseCommandOption(
2867 MagickStretchOptions,MagickFalse,argv[i+1]);
2868 break;
2869 }
2870 if (LocaleCompare("strip",option+1) == 0)
2871 {
2872 /*
2873 Strip image of profiles and comments.
2874 */
2875 (void) SyncImageSettings(mogrify_info,*image);
2876 (void) StripImage(*image);
2877 InheritException(exception,&(*image)->exception);
2878 break;
2879 }
2880 if (LocaleCompare("stroke",option+1) == 0)
2881 {
2882 ExceptionInfo
2883 *sans;
2884
2885 if (*option == '+')
2886 {
cristy9950d572011-10-01 18:22:35 +00002887 (void) QueryColorCompliance("none",AllCompliance,
2888 &draw_info->stroke,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002889 if (draw_info->stroke_pattern != (Image *) NULL)
2890 draw_info->stroke_pattern=DestroyImage(
2891 draw_info->stroke_pattern);
2892 break;
2893 }
2894 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00002895 status=QueryColorCompliance(argv[i+1],AllCompliance,
2896 &draw_info->stroke,sans);
anthonydf8ebac2011-04-27 09:03:19 +00002897 sans=DestroyExceptionInfo(sans);
2898 if (status == MagickFalse)
2899 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2900 exception);
2901 break;
2902 }
2903 if (LocaleCompare("strokewidth",option+1) == 0)
2904 {
cristyc1acd842011-05-19 23:05:47 +00002905 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2906 (char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002907 break;
2908 }
2909 if (LocaleCompare("style",option+1) == 0)
2910 {
2911 if (*option == '+')
2912 {
2913 draw_info->style=UndefinedStyle;
2914 break;
2915 }
2916 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2917 MagickFalse,argv[i+1]);
2918 break;
2919 }
2920 if (LocaleCompare("swirl",option+1) == 0)
2921 {
2922 /*
2923 Swirl image.
2924 */
2925 (void) SyncImageSettings(mogrify_info,*image);
2926 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00002927 mogrify_image=SwirlImage(*image,geometry_info.rho,
2928 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002929 break;
2930 }
2931 break;
2932 }
2933 case 't':
2934 {
2935 if (LocaleCompare("threshold",option+1) == 0)
2936 {
2937 double
2938 threshold;
2939
2940 /*
2941 Threshold image.
2942 */
2943 (void) SyncImageSettings(mogrify_info,*image);
2944 if (*option == '+')
anthony247a86d2011-05-03 13:18:18 +00002945 threshold=(double) QuantumRange/2;
anthonydf8ebac2011-04-27 09:03:19 +00002946 else
2947 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristyf4ad9df2011-07-08 16:49:03 +00002948 (void) BilevelImage(*image,threshold);
anthonydf8ebac2011-04-27 09:03:19 +00002949 InheritException(exception,&(*image)->exception);
2950 break;
2951 }
2952 if (LocaleCompare("thumbnail",option+1) == 0)
2953 {
2954 /*
2955 Thumbnail image.
2956 */
2957 (void) SyncImageSettings(mogrify_info,*image);
2958 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2959 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2960 exception);
2961 break;
2962 }
2963 if (LocaleCompare("tile",option+1) == 0)
2964 {
2965 if (*option == '+')
2966 {
2967 if (draw_info->fill_pattern != (Image *) NULL)
2968 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2969 break;
2970 }
2971 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2972 exception);
2973 break;
2974 }
2975 if (LocaleCompare("tint",option+1) == 0)
2976 {
2977 /*
2978 Tint the image.
2979 */
2980 (void) SyncImageSettings(mogrify_info,*image);
cristy28474bf2011-09-11 23:32:52 +00002981 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002982 break;
2983 }
2984 if (LocaleCompare("transform",option+1) == 0)
2985 {
2986 /*
2987 Affine transform image.
2988 */
2989 (void) SyncImageSettings(mogrify_info,*image);
2990 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2991 exception);
2992 break;
2993 }
2994 if (LocaleCompare("transparent",option+1) == 0)
2995 {
cristy4c08aed2011-07-01 19:47:50 +00002996 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002997 target;
2998
2999 (void) SyncImageSettings(mogrify_info,*image);
cristy9950d572011-10-01 18:22:35 +00003000 (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target,
3001 exception);
anthonydf8ebac2011-04-27 09:03:19 +00003002 (void) TransparentPaintImage(*image,&target,(Quantum)
cristy189e84c2011-08-27 18:08:53 +00003003 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3004 &(*image)->exception);
anthonydf8ebac2011-04-27 09:03:19 +00003005 break;
3006 }
3007 if (LocaleCompare("transpose",option+1) == 0)
3008 {
3009 /*
3010 Transpose image scanlines.
3011 */
3012 (void) SyncImageSettings(mogrify_info,*image);
3013 mogrify_image=TransposeImage(*image,exception);
3014 break;
3015 }
3016 if (LocaleCompare("transverse",option+1) == 0)
3017 {
3018 /*
3019 Transverse image scanlines.
3020 */
3021 (void) SyncImageSettings(mogrify_info,*image);
3022 mogrify_image=TransverseImage(*image,exception);
3023 break;
3024 }
3025 if (LocaleCompare("treedepth",option+1) == 0)
3026 {
3027 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3028 break;
3029 }
3030 if (LocaleCompare("trim",option+1) == 0)
3031 {
3032 /*
3033 Trim image.
3034 */
3035 (void) SyncImageSettings(mogrify_info,*image);
3036 mogrify_image=TrimImage(*image,exception);
3037 break;
3038 }
3039 if (LocaleCompare("type",option+1) == 0)
3040 {
3041 ImageType
3042 type;
3043
3044 (void) SyncImageSettings(mogrify_info,*image);
3045 if (*option == '+')
3046 type=UndefinedType;
3047 else
3048 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3049 argv[i+1]);
3050 (*image)->type=UndefinedType;
cristy018f07f2011-09-04 21:15:19 +00003051 (void) SetImageType(*image,type,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003052 break;
3053 }
3054 break;
3055 }
3056 case 'u':
3057 {
3058 if (LocaleCompare("undercolor",option+1) == 0)
3059 {
cristy9950d572011-10-01 18:22:35 +00003060 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3061 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003062 break;
3063 }
3064 if (LocaleCompare("unique",option+1) == 0)
3065 {
3066 if (*option == '+')
3067 {
3068 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3069 break;
3070 }
3071 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3072 (void) SetImageArtifact(*image,"verbose","true");
3073 break;
3074 }
3075 if (LocaleCompare("unique-colors",option+1) == 0)
3076 {
3077 /*
3078 Unique image colors.
3079 */
3080 (void) SyncImageSettings(mogrify_info,*image);
3081 mogrify_image=UniqueImageColors(*image,exception);
3082 break;
3083 }
3084 if (LocaleCompare("unsharp",option+1) == 0)
3085 {
3086 /*
3087 Unsharp mask image.
3088 */
3089 (void) SyncImageSettings(mogrify_info,*image);
3090 flags=ParseGeometry(argv[i+1],&geometry_info);
3091 if ((flags & SigmaValue) == 0)
3092 geometry_info.sigma=1.0;
3093 if ((flags & XiValue) == 0)
3094 geometry_info.xi=1.0;
3095 if ((flags & PsiValue) == 0)
3096 geometry_info.psi=0.05;
cristyf4ad9df2011-07-08 16:49:03 +00003097 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3098 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003099 break;
3100 }
3101 break;
3102 }
3103 case 'v':
3104 {
3105 if (LocaleCompare("verbose",option+1) == 0)
3106 {
3107 (void) SetImageArtifact(*image,option+1,
3108 *option == '+' ? "false" : "true");
3109 break;
3110 }
3111 if (LocaleCompare("vignette",option+1) == 0)
3112 {
3113 /*
3114 Vignette image.
3115 */
3116 (void) SyncImageSettings(mogrify_info,*image);
3117 flags=ParseGeometry(argv[i+1],&geometry_info);
3118 if ((flags & SigmaValue) == 0)
3119 geometry_info.sigma=1.0;
3120 if ((flags & XiValue) == 0)
3121 geometry_info.xi=0.1*(*image)->columns;
3122 if ((flags & PsiValue) == 0)
3123 geometry_info.psi=0.1*(*image)->rows;
3124 mogrify_image=VignetteImage(*image,geometry_info.rho,
3125 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3126 ceil(geometry_info.psi-0.5),exception);
3127 break;
3128 }
3129 if (LocaleCompare("virtual-pixel",option+1) == 0)
3130 {
3131 if (*option == '+')
3132 {
3133 (void) SetImageVirtualPixelMethod(*image,
3134 UndefinedVirtualPixelMethod);
3135 break;
3136 }
3137 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3138 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3139 argv[i+1]));
3140 break;
3141 }
3142 break;
3143 }
3144 case 'w':
3145 {
3146 if (LocaleCompare("wave",option+1) == 0)
3147 {
3148 /*
3149 Wave image.
3150 */
3151 (void) SyncImageSettings(mogrify_info,*image);
3152 flags=ParseGeometry(argv[i+1],&geometry_info);
3153 if ((flags & SigmaValue) == 0)
3154 geometry_info.sigma=1.0;
3155 mogrify_image=WaveImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00003156 geometry_info.sigma,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003157 break;
3158 }
3159 if (LocaleCompare("weight",option+1) == 0)
3160 {
3161 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3162 if (LocaleCompare(argv[i+1],"all") == 0)
3163 draw_info->weight=0;
3164 if (LocaleCompare(argv[i+1],"bold") == 0)
3165 draw_info->weight=700;
3166 if (LocaleCompare(argv[i+1],"bolder") == 0)
3167 if (draw_info->weight <= 800)
3168 draw_info->weight+=100;
3169 if (LocaleCompare(argv[i+1],"lighter") == 0)
3170 if (draw_info->weight >= 100)
3171 draw_info->weight-=100;
3172 if (LocaleCompare(argv[i+1],"normal") == 0)
3173 draw_info->weight=400;
3174 break;
3175 }
3176 if (LocaleCompare("white-threshold",option+1) == 0)
3177 {
3178 /*
3179 White threshold image.
3180 */
3181 (void) SyncImageSettings(mogrify_info,*image);
cristyf4ad9df2011-07-08 16:49:03 +00003182 (void) WhiteThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00003183 InheritException(exception,&(*image)->exception);
3184 break;
3185 }
3186 break;
3187 }
3188 default:
3189 break;
3190 }
3191 /*
3192 Replace current image with any image that was generated
3193 */
3194 if (mogrify_image != (Image *) NULL)
3195 ReplaceImageInListReturnLast(image,mogrify_image);
cristy3ed852e2009-09-05 21:47:34 +00003196 i+=count;
3197 }
3198 if (region_image != (Image *) NULL)
3199 {
anthonydf8ebac2011-04-27 09:03:19 +00003200 /*
3201 Composite transformed region onto image.
3202 */
cristy6b3da3a2010-06-20 02:21:46 +00003203 (void) SyncImageSettings(mogrify_info,*image);
anthonya129f702011-04-14 01:08:48 +00003204 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00003205 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3206 region_geometry.x,region_geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00003207 InheritException(exception,&region_image->exception);
3208 *image=DestroyImage(*image);
3209 *image=region_image;
anthonye9c27192011-03-27 08:07:06 +00003210 region_image = (Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00003211 }
3212 /*
3213 Free resources.
3214 */
anthonydf8ebac2011-04-27 09:03:19 +00003215 quantize_info=DestroyQuantizeInfo(quantize_info);
3216 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003217 mogrify_info=DestroyImageInfo(mogrify_info);
cristy4c08aed2011-07-01 19:47:50 +00003218 status=(MagickStatusType) ((*image)->exception.severity ==
cristy5f09d852011-05-29 01:39:29 +00003219 UndefinedException ? 1 : 0);
cristy72988482011-03-29 16:34:38 +00003220 return(status == 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00003221}
3222
3223/*
3224%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3225% %
3226% %
3227% %
cristy5063d812010-10-19 16:28:10 +00003228+ 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 +00003229% %
3230% %
3231% %
3232%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3233%
3234% MogrifyImageCommand() transforms an image or a sequence of images. These
3235% transforms include image scaling, image rotation, color reduction, and
3236% others. The transmogrified image overwrites the original image.
3237%
3238% The format of the MogrifyImageCommand method is:
3239%
3240% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3241% const char **argv,char **metadata,ExceptionInfo *exception)
3242%
3243% A description of each parameter follows:
3244%
3245% o image_info: the image info.
3246%
3247% o argc: the number of elements in the argument vector.
3248%
3249% o argv: A text array containing the command line arguments.
3250%
3251% o metadata: any metadata is returned here.
3252%
3253% o exception: return any errors or warnings in this structure.
3254%
3255*/
3256
3257static MagickBooleanType MogrifyUsage(void)
3258{
3259 static const char
3260 *miscellaneous[]=
3261 {
3262 "-debug events display copious debugging information",
3263 "-help print program options",
3264 "-list type print a list of supported option arguments",
3265 "-log format format of debugging information",
3266 "-version print version information",
3267 (char *) NULL
3268 },
3269 *operators[]=
3270 {
3271 "-adaptive-blur geometry",
3272 " adaptively blur pixels; decrease effect near edges",
3273 "-adaptive-resize geometry",
3274 " adaptively resize image using 'mesh' interpolation",
3275 "-adaptive-sharpen geometry",
3276 " adaptively sharpen pixels; increase effect near edges",
3277 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3278 " transparent, extract, background, or shape",
3279 "-annotate geometry text",
3280 " annotate the image with text",
3281 "-auto-gamma automagically adjust gamma level of image",
3282 "-auto-level automagically adjust color levels of image",
3283 "-auto-orient automagically orient (rotate) image",
3284 "-bench iterations measure performance",
3285 "-black-threshold value",
3286 " force all pixels below the threshold into black",
3287 "-blue-shift simulate a scene at nighttime in the moonlight",
3288 "-blur geometry reduce image noise and reduce detail levels",
3289 "-border geometry surround image with a border of color",
3290 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003291 "-brightness-contrast geometry",
3292 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003293 "-cdl filename color correct with a color decision list",
cristy05c0c9a2011-09-05 23:16:13 +00003294 "-charcoal geometry simulate a charcoal drawing",
cristy3ed852e2009-09-05 21:47:34 +00003295 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003296 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003297 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003298 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003299 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003300 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003301 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003302 "-contrast enhance or reduce the image contrast",
3303 "-contrast-stretch geometry",
3304 " improve contrast by `stretching' the intensity range",
3305 "-convolve coefficients",
3306 " apply a convolution kernel to the image",
3307 "-cycle amount cycle the image colormap",
3308 "-decipher filename convert cipher pixels to plain pixels",
3309 "-deskew threshold straighten an image",
3310 "-despeckle reduce the speckles within an image",
3311 "-distort method args",
3312 " distort images according to given method ad args",
3313 "-draw string annotate the image with a graphic primitive",
3314 "-edge radius apply a filter to detect edges in the image",
3315 "-encipher filename convert plain pixels to cipher pixels",
3316 "-emboss radius emboss an image",
3317 "-enhance apply a digital filter to enhance a noisy image",
3318 "-equalize perform histogram equalization to an image",
3319 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003320 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003321 "-extent geometry set the image size",
3322 "-extract geometry extract area from image",
3323 "-fft implements the discrete Fourier transform (DFT)",
3324 "-flip flip image vertically",
3325 "-floodfill geometry color",
3326 " floodfill the image with color",
3327 "-flop flop image horizontally",
3328 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003329 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003330 " apply function over image values",
3331 "-gamma value level of gamma correction",
3332 "-gaussian-blur geometry",
3333 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003334 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003335 "-identify identify the format and characteristics of the image",
3336 "-ift implements the inverse discrete Fourier transform (DFT)",
3337 "-implode amount implode image pixels about the center",
3338 "-lat geometry local adaptive thresholding",
3339 "-layers method optimize, merge, or compare image layers",
3340 "-level value adjust the level of image contrast",
3341 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003342 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003343 "-linear-stretch geometry",
3344 " improve contrast by `stretching with saturation'",
3345 "-liquid-rescale geometry",
3346 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +00003347 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +00003348 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003349 "-modulate value vary the brightness, saturation, and hue",
3350 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003351 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003352 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003353 "-motion-blur geometry",
3354 " simulate motion blur",
3355 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +00003356 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +00003357 "-normalize transform image to span the full range of colors",
3358 "-opaque color change this color to the fill color",
3359 "-ordered-dither NxN",
3360 " add a noise pattern to the image with specific",
3361 " amplitudes",
3362 "-paint radius simulate an oil painting",
3363 "-polaroid angle simulate a Polaroid picture",
3364 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003365 "-profile filename add, delete, or apply an image profile",
3366 "-quantize colorspace reduce colors in this colorspace",
3367 "-radial-blur angle radial blur the image",
3368 "-raise value lighten/darken image edges to create a 3-D effect",
3369 "-random-threshold low,high",
3370 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003371 "-region geometry apply options to a portion of the image",
3372 "-render render vector graphics",
3373 "-repage geometry size and location of an image canvas",
3374 "-resample geometry change the resolution of an image",
3375 "-resize geometry resize the image",
3376 "-roll geometry roll an image vertically or horizontally",
3377 "-rotate degrees apply Paeth rotation to the image",
3378 "-sample geometry scale image with pixel sampling",
3379 "-scale geometry scale the image",
3380 "-segment values segment an image",
3381 "-selective-blur geometry",
3382 " selectively blur pixels within a contrast threshold",
3383 "-sepia-tone threshold",
3384 " simulate a sepia-toned photo",
3385 "-set property value set an image property",
3386 "-shade degrees shade the image using a distant light source",
3387 "-shadow geometry simulate an image shadow",
3388 "-sharpen geometry sharpen the image",
3389 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003390 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003391 "-sigmoidal-contrast geometry",
3392 " increase the contrast without saturating highlights or shadows",
3393 "-sketch geometry simulate a pencil sketch",
3394 "-solarize threshold negate all pixels above the threshold level",
3395 "-sparse-color method args",
3396 " fill in a image based on a few color points",
3397 "-splice geometry splice the background color into the image",
3398 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003399 "-statistic type radius",
3400 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003401 "-strip strip image of all profiles and comments",
3402 "-swirl degrees swirl image pixels about the center",
3403 "-threshold value threshold the image",
3404 "-thumbnail geometry create a thumbnail of the image",
3405 "-tile filename tile image when filling a graphic primitive",
3406 "-tint value tint the image with the fill color",
3407 "-transform affine transform image",
3408 "-transparent color make this color transparent within the image",
3409 "-transpose flip image vertically and rotate 90 degrees",
3410 "-transverse flop image horizontally and rotate 270 degrees",
3411 "-trim trim image edges",
3412 "-type type image type",
3413 "-unique-colors discard all but one of any pixel color",
3414 "-unsharp geometry sharpen the image",
3415 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003416 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003417 "-white-threshold value",
3418 " force all pixels above the threshold into white",
3419 (char *) NULL
3420 },
3421 *sequence_operators[]=
3422 {
cristy4285d782011-02-09 20:12:28 +00003423 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003424 "-clut apply a color lookup table to the image",
3425 "-coalesce merge a sequence of images",
3426 "-combine combine a sequence of images",
3427 "-composite composite image",
3428 "-crop geometry cut out a rectangular region of the image",
3429 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003430 "-evaluate-sequence operator",
3431 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003432 "-flatten flatten a sequence of images",
3433 "-fx expression apply mathematical expression to an image channel(s)",
3434 "-hald-clut apply a Hald color lookup table to the image",
3435 "-morph value morph an image sequence",
3436 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003437 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003438 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003439 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003440 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003441 "-write filename write images to this file",
3442 (char *) NULL
3443 },
3444 *settings[]=
3445 {
3446 "-adjoin join images into a single multi-image file",
3447 "-affine matrix affine transform matrix",
3448 "-alpha option activate, deactivate, reset, or set the alpha channel",
3449 "-antialias remove pixel-aliasing",
3450 "-authenticate password",
3451 " decipher image with this password",
3452 "-attenuate value lessen (or intensify) when adding noise to an image",
3453 "-background color background color",
3454 "-bias value add bias when convolving an image",
3455 "-black-point-compensation",
3456 " use black point compensation",
3457 "-blue-primary point chromaticity blue primary point",
3458 "-bordercolor color border color",
3459 "-caption string assign a caption to an image",
3460 "-channel type apply option to select image channels",
3461 "-colors value preferred number of colors in the image",
3462 "-colorspace type alternate image colorspace",
3463 "-comment string annotate image with comment",
3464 "-compose operator set image composite operator",
3465 "-compress type type of pixel compression when writing the image",
3466 "-define format:option",
3467 " define one or more image format options",
3468 "-delay value display the next image after pausing",
3469 "-density geometry horizontal and vertical density of the image",
3470 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003471 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003472 "-display server get image or font from this X server",
3473 "-dispose method layer disposal method",
3474 "-dither method apply error diffusion to image",
3475 "-encoding type text encoding type",
3476 "-endian type endianness (MSB or LSB) of the image",
3477 "-family name render text with this font family",
3478 "-fill color color to use when filling a graphic primitive",
3479 "-filter type use this filter when resizing an image",
3480 "-font name render text with this font",
3481 "-format \"string\" output formatted image characteristics",
3482 "-fuzz distance colors within this distance are considered equal",
3483 "-gravity type horizontal and vertical text placement",
3484 "-green-primary point chromaticity green primary point",
3485 "-intent type type of rendering intent when managing the image color",
3486 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003487 "-interline-spacing value",
3488 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003489 "-interpolate method pixel color interpolation method",
3490 "-interword-spacing value",
3491 " set the space between two words",
3492 "-kerning value set the space between two letters",
3493 "-label string assign a label to an image",
3494 "-limit type value pixel cache resource limit",
3495 "-loop iterations add Netscape loop extension to your GIF animation",
3496 "-mask filename associate a mask with the image",
3497 "-mattecolor color frame color",
3498 "-monitor monitor progress",
3499 "-orient type image orientation",
3500 "-page geometry size and location of an image canvas (setting)",
3501 "-ping efficiently determine image attributes",
3502 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003503 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003504 "-preview type image preview type",
3505 "-quality value JPEG/MIFF/PNG compression level",
3506 "-quiet suppress all warning messages",
3507 "-red-primary point chromaticity red primary point",
3508 "-regard-warnings pay attention to warning messages",
3509 "-remap filename transform image colors to match this set of colors",
3510 "-respect-parentheses settings remain in effect until parenthesis boundary",
3511 "-sampling-factor geometry",
3512 " horizontal and vertical sampling factor",
3513 "-scene value image scene number",
3514 "-seed value seed a new sequence of pseudo-random numbers",
3515 "-size geometry width and height of image",
3516 "-stretch type render text with this font stretch",
3517 "-stroke color graphic primitive stroke color",
3518 "-strokewidth value graphic primitive stroke width",
3519 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003520 "-synchronize synchronize image to storage device",
3521 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003522 "-texture filename name of texture to tile onto the image background",
3523 "-tile-offset geometry",
3524 " tile offset",
3525 "-treedepth value color tree depth",
3526 "-transparent-color color",
3527 " transparent color",
3528 "-undercolor color annotation bounding box color",
3529 "-units type the units of image resolution",
3530 "-verbose print detailed information about the image",
3531 "-view FlashPix viewing transforms",
3532 "-virtual-pixel method",
3533 " virtual pixel access method",
3534 "-weight type render text with this font weight",
3535 "-white-point point chromaticity white point",
3536 (char *) NULL
3537 },
3538 *stack_operators[]=
3539 {
anthonyb69c4b32011-03-23 04:37:44 +00003540 "-delete indexes delete the image from the image sequence",
3541 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003542 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003543 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003544 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003545 "-swap indexes swap two images in the image sequence",
3546 (char *) NULL
3547 };
3548
3549 const char
3550 **p;
3551
cristybb503372010-05-27 20:51:26 +00003552 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003553 (void) printf("Copyright: %s\n",GetMagickCopyright());
3554 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003555 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3556 GetClientName());
3557 (void) printf("\nImage Settings:\n");
3558 for (p=settings; *p != (char *) NULL; p++)
3559 (void) printf(" %s\n",*p);
3560 (void) printf("\nImage Operators:\n");
3561 for (p=operators; *p != (char *) NULL; p++)
3562 (void) printf(" %s\n",*p);
3563 (void) printf("\nImage Sequence Operators:\n");
3564 for (p=sequence_operators; *p != (char *) NULL; p++)
3565 (void) printf(" %s\n",*p);
3566 (void) printf("\nImage Stack Operators:\n");
3567 for (p=stack_operators; *p != (char *) NULL; p++)
3568 (void) printf(" %s\n",*p);
3569 (void) printf("\nMiscellaneous Options:\n");
3570 for (p=miscellaneous; *p != (char *) NULL; p++)
3571 (void) printf(" %s\n",*p);
3572 (void) printf(
3573 "\nBy default, the image format of `file' is determined by its magic\n");
3574 (void) printf(
3575 "number. To specify a particular image format, precede the filename\n");
3576 (void) printf(
3577 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3578 (void) printf(
3579 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3580 (void) printf("'-' for standard input or output.\n");
3581 return(MagickFalse);
3582}
3583
3584WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3585 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3586{
3587#define DestroyMogrify() \
3588{ \
3589 if (format != (char *) NULL) \
3590 format=DestroyString(format); \
3591 if (path != (char *) NULL) \
3592 path=DestroyString(path); \
3593 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003594 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003595 argv[i]=DestroyString(argv[i]); \
3596 argv=(char **) RelinquishMagickMemory(argv); \
3597}
3598#define ThrowMogrifyException(asperity,tag,option) \
3599{ \
3600 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3601 option); \
3602 DestroyMogrify(); \
3603 return(MagickFalse); \
3604}
3605#define ThrowMogrifyInvalidArgumentException(option,argument) \
3606{ \
3607 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3608 "InvalidArgument","`%s': %s",argument,option); \
3609 DestroyMogrify(); \
3610 return(MagickFalse); \
3611}
3612
3613 char
3614 *format,
3615 *option,
3616 *path;
3617
3618 Image
3619 *image;
3620
3621 ImageStack
3622 image_stack[MaxImageStackDepth+1];
3623
cristy3ed852e2009-09-05 21:47:34 +00003624 MagickBooleanType
3625 global_colormap;
3626
3627 MagickBooleanType
3628 fire,
cristyebbcfea2011-02-25 02:43:54 +00003629 pend,
3630 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00003631
3632 MagickStatusType
3633 status;
3634
cristyebbcfea2011-02-25 02:43:54 +00003635 register ssize_t
3636 i;
3637
3638 ssize_t
3639 j,
3640 k;
3641
cristy3ed852e2009-09-05 21:47:34 +00003642 /*
3643 Set defaults.
3644 */
3645 assert(image_info != (ImageInfo *) NULL);
3646 assert(image_info->signature == MagickSignature);
3647 if (image_info->debug != MagickFalse)
3648 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3649 assert(exception != (ExceptionInfo *) NULL);
3650 if (argc == 2)
3651 {
3652 option=argv[1];
3653 if ((LocaleCompare("version",option+1) == 0) ||
3654 (LocaleCompare("-version",option+1) == 0))
3655 {
cristyb51dff52011-05-19 16:55:47 +00003656 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00003657 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00003658 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3659 GetMagickCopyright());
3660 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3661 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003662 return(MagickFalse);
3663 }
3664 }
3665 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00003666 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00003667 format=(char *) NULL;
3668 path=(char *) NULL;
3669 global_colormap=MagickFalse;
3670 k=0;
3671 j=1;
3672 NewImageStack();
3673 option=(char *) NULL;
3674 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00003675 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003676 status=MagickTrue;
3677 /*
3678 Parse command line.
3679 */
3680 ReadCommandlLine(argc,&argv);
3681 status=ExpandFilenames(&argc,&argv);
3682 if (status == MagickFalse)
3683 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3684 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00003685 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00003686 {
3687 option=argv[i];
3688 if (LocaleCompare(option,"(") == 0)
3689 {
3690 FireImageStack(MagickFalse,MagickTrue,pend);
3691 if (k == MaxImageStackDepth)
3692 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3693 option);
3694 PushImageStack();
3695 continue;
3696 }
3697 if (LocaleCompare(option,")") == 0)
3698 {
3699 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3700 if (k == 0)
3701 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3702 PopImageStack();
3703 continue;
3704 }
cristy042ee782011-04-22 18:48:30 +00003705 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00003706 {
3707 char
3708 backup_filename[MaxTextExtent],
3709 *filename;
3710
3711 Image
3712 *images;
3713
3714 /*
3715 Option is a file name: begin by reading image from specified file.
3716 */
3717 FireImageStack(MagickFalse,MagickFalse,pend);
3718 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00003719 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00003720 filename=argv[++i];
3721 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3722 images=ReadImages(image_info,exception);
3723 status&=(images != (Image *) NULL) &&
3724 (exception->severity < ErrorException);
3725 if (images == (Image *) NULL)
3726 continue;
cristydaa76602010-06-30 13:05:11 +00003727 if (format != (char *) NULL)
3728 (void) CopyMagickString(images->filename,images->magick_filename,
3729 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00003730 if (path != (char *) NULL)
3731 {
3732 GetPathComponent(option,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +00003733 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
cristy3ed852e2009-09-05 21:47:34 +00003734 path,*DirectorySeparator,filename);
3735 }
3736 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00003737 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00003738 AppendImageStack(images);
3739 FinalizeImageSettings(image_info,image,MagickFalse);
3740 if (global_colormap != MagickFalse)
3741 {
3742 QuantizeInfo
3743 *quantize_info;
3744
3745 quantize_info=AcquireQuantizeInfo(image_info);
cristy018f07f2011-09-04 21:15:19 +00003746 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
cristy3ed852e2009-09-05 21:47:34 +00003747 quantize_info=DestroyQuantizeInfo(quantize_info);
3748 }
3749 *backup_filename='\0';
3750 if ((LocaleCompare(image->filename,"-") != 0) &&
3751 (IsPathWritable(image->filename) != MagickFalse))
3752 {
cristybb503372010-05-27 20:51:26 +00003753 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003754 i;
3755
3756 /*
3757 Rename image file as backup.
3758 */
3759 (void) CopyMagickString(backup_filename,image->filename,
3760 MaxTextExtent);
3761 for (i=0; i < 6; i++)
3762 {
3763 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3764 if (IsPathAccessible(backup_filename) == MagickFalse)
3765 break;
3766 }
3767 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
cristy320684d2011-09-23 14:55:47 +00003768 (rename_utf8(image->filename,backup_filename) != 0))
cristy3ed852e2009-09-05 21:47:34 +00003769 *backup_filename='\0';
3770 }
3771 /*
3772 Write transmogrified image to disk.
3773 */
3774 image_info->synchronize=MagickTrue;
3775 status&=WriteImages(image_info,image,image->filename,exception);
3776 if ((status == MagickFalse) && (*backup_filename != '\0'))
cristy18c6c272011-09-23 14:40:37 +00003777 (void) remove_utf8(backup_filename);
cristy3ed852e2009-09-05 21:47:34 +00003778 RemoveAllImageStack();
3779 continue;
3780 }
3781 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3782 switch (*(option+1))
3783 {
3784 case 'a':
3785 {
3786 if (LocaleCompare("adaptive-blur",option+1) == 0)
3787 {
3788 i++;
cristybb503372010-05-27 20:51:26 +00003789 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003790 ThrowMogrifyException(OptionError,"MissingArgument",option);
3791 if (IsGeometry(argv[i]) == MagickFalse)
3792 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3793 break;
3794 }
3795 if (LocaleCompare("adaptive-resize",option+1) == 0)
3796 {
3797 i++;
cristybb503372010-05-27 20:51:26 +00003798 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003799 ThrowMogrifyException(OptionError,"MissingArgument",option);
3800 if (IsGeometry(argv[i]) == MagickFalse)
3801 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3802 break;
3803 }
3804 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3805 {
3806 i++;
cristybb503372010-05-27 20:51:26 +00003807 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003808 ThrowMogrifyException(OptionError,"MissingArgument",option);
3809 if (IsGeometry(argv[i]) == MagickFalse)
3810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3811 break;
3812 }
3813 if (LocaleCompare("affine",option+1) == 0)
3814 {
3815 if (*option == '+')
3816 break;
3817 i++;
cristybb503372010-05-27 20:51:26 +00003818 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003819 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +00003820 break;
3821 }
3822 if (LocaleCompare("alpha",option+1) == 0)
3823 {
cristybb503372010-05-27 20:51:26 +00003824 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003825 type;
3826
3827 if (*option == '+')
3828 break;
3829 i++;
cristybb503372010-05-27 20:51:26 +00003830 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003831 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00003832 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00003833 if (type < 0)
3834 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3835 argv[i]);
3836 break;
3837 }
3838 if (LocaleCompare("annotate",option+1) == 0)
3839 {
3840 if (*option == '+')
3841 break;
3842 i++;
cristybb503372010-05-27 20:51:26 +00003843 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003844 ThrowMogrifyException(OptionError,"MissingArgument",option);
3845 if (IsGeometry(argv[i]) == MagickFalse)
3846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00003847 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003848 ThrowMogrifyException(OptionError,"MissingArgument",option);
3849 i++;
3850 break;
3851 }
3852 if (LocaleCompare("antialias",option+1) == 0)
3853 break;
3854 if (LocaleCompare("append",option+1) == 0)
3855 break;
3856 if (LocaleCompare("attenuate",option+1) == 0)
3857 {
3858 if (*option == '+')
3859 break;
3860 i++;
cristybb503372010-05-27 20:51:26 +00003861 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003862 ThrowMogrifyException(OptionError,"MissingArgument",option);
3863 if (IsGeometry(argv[i]) == MagickFalse)
3864 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3865 break;
3866 }
3867 if (LocaleCompare("authenticate",option+1) == 0)
3868 {
3869 if (*option == '+')
3870 break;
3871 i++;
cristybb503372010-05-27 20:51:26 +00003872 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003873 ThrowMogrifyException(OptionError,"MissingArgument",option);
3874 break;
3875 }
3876 if (LocaleCompare("auto-gamma",option+1) == 0)
3877 break;
3878 if (LocaleCompare("auto-level",option+1) == 0)
3879 break;
3880 if (LocaleCompare("auto-orient",option+1) == 0)
3881 break;
3882 if (LocaleCompare("average",option+1) == 0)
3883 break;
3884 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3885 }
3886 case 'b':
3887 {
3888 if (LocaleCompare("background",option+1) == 0)
3889 {
3890 if (*option == '+')
3891 break;
3892 i++;
cristybb503372010-05-27 20:51:26 +00003893 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003894 ThrowMogrifyException(OptionError,"MissingArgument",option);
3895 break;
3896 }
3897 if (LocaleCompare("bias",option+1) == 0)
3898 {
3899 if (*option == '+')
3900 break;
3901 i++;
cristybb503372010-05-27 20:51:26 +00003902 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003903 ThrowMogrifyException(OptionError,"MissingArgument",option);
3904 if (IsGeometry(argv[i]) == MagickFalse)
3905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3906 break;
3907 }
3908 if (LocaleCompare("black-point-compensation",option+1) == 0)
3909 break;
3910 if (LocaleCompare("black-threshold",option+1) == 0)
3911 {
3912 if (*option == '+')
3913 break;
3914 i++;
cristybb503372010-05-27 20:51:26 +00003915 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003916 ThrowMogrifyException(OptionError,"MissingArgument",option);
3917 if (IsGeometry(argv[i]) == MagickFalse)
3918 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3919 break;
3920 }
3921 if (LocaleCompare("blue-primary",option+1) == 0)
3922 {
3923 if (*option == '+')
3924 break;
3925 i++;
cristybb503372010-05-27 20:51:26 +00003926 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003927 ThrowMogrifyException(OptionError,"MissingArgument",option);
3928 if (IsGeometry(argv[i]) == MagickFalse)
3929 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3930 break;
3931 }
3932 if (LocaleCompare("blue-shift",option+1) == 0)
3933 {
3934 i++;
cristybb503372010-05-27 20:51:26 +00003935 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003936 ThrowMogrifyException(OptionError,"MissingArgument",option);
3937 if (IsGeometry(argv[i]) == MagickFalse)
3938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3939 break;
3940 }
3941 if (LocaleCompare("blur",option+1) == 0)
3942 {
3943 i++;
cristybb503372010-05-27 20:51:26 +00003944 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003945 ThrowMogrifyException(OptionError,"MissingArgument",option);
3946 if (IsGeometry(argv[i]) == MagickFalse)
3947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3948 break;
3949 }
3950 if (LocaleCompare("border",option+1) == 0)
3951 {
3952 if (*option == '+')
3953 break;
3954 i++;
cristybb503372010-05-27 20:51:26 +00003955 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003956 ThrowMogrifyException(OptionError,"MissingArgument",option);
3957 if (IsGeometry(argv[i]) == MagickFalse)
3958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3959 break;
3960 }
3961 if (LocaleCompare("bordercolor",option+1) == 0)
3962 {
3963 if (*option == '+')
3964 break;
3965 i++;
cristybb503372010-05-27 20:51:26 +00003966 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003967 ThrowMogrifyException(OptionError,"MissingArgument",option);
3968 break;
3969 }
3970 if (LocaleCompare("box",option+1) == 0)
3971 {
3972 if (*option == '+')
3973 break;
3974 i++;
cristybb503372010-05-27 20:51:26 +00003975 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003976 ThrowMogrifyException(OptionError,"MissingArgument",option);
3977 break;
3978 }
cristya28d6b82010-01-11 20:03:47 +00003979 if (LocaleCompare("brightness-contrast",option+1) == 0)
3980 {
3981 i++;
cristybb503372010-05-27 20:51:26 +00003982 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00003983 ThrowMogrifyException(OptionError,"MissingArgument",option);
3984 if (IsGeometry(argv[i]) == MagickFalse)
3985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3986 break;
3987 }
cristy3ed852e2009-09-05 21:47:34 +00003988 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3989 }
3990 case 'c':
3991 {
3992 if (LocaleCompare("cache",option+1) == 0)
3993 {
3994 if (*option == '+')
3995 break;
3996 i++;
cristybb503372010-05-27 20:51:26 +00003997 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003998 ThrowMogrifyException(OptionError,"MissingArgument",option);
3999 if (IsGeometry(argv[i]) == MagickFalse)
4000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4001 break;
4002 }
4003 if (LocaleCompare("caption",option+1) == 0)
4004 {
4005 if (*option == '+')
4006 break;
4007 i++;
cristybb503372010-05-27 20:51:26 +00004008 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004009 ThrowMogrifyException(OptionError,"MissingArgument",option);
4010 break;
4011 }
4012 if (LocaleCompare("channel",option+1) == 0)
4013 {
cristybb503372010-05-27 20:51:26 +00004014 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004015 channel;
4016
4017 if (*option == '+')
4018 break;
4019 i++;
cristybb503372010-05-27 20:51:26 +00004020 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004021 ThrowMogrifyException(OptionError,"MissingArgument",option);
4022 channel=ParseChannelOption(argv[i]);
4023 if (channel < 0)
4024 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4025 argv[i]);
4026 break;
4027 }
4028 if (LocaleCompare("cdl",option+1) == 0)
4029 {
4030 if (*option == '+')
4031 break;
4032 i++;
cristybb503372010-05-27 20:51:26 +00004033 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004034 ThrowMogrifyException(OptionError,"MissingArgument",option);
4035 break;
4036 }
4037 if (LocaleCompare("charcoal",option+1) == 0)
4038 {
4039 if (*option == '+')
4040 break;
4041 i++;
cristybb503372010-05-27 20:51:26 +00004042 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004043 ThrowMogrifyException(OptionError,"MissingArgument",option);
4044 if (IsGeometry(argv[i]) == MagickFalse)
4045 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4046 break;
4047 }
4048 if (LocaleCompare("chop",option+1) == 0)
4049 {
4050 if (*option == '+')
4051 break;
4052 i++;
cristybb503372010-05-27 20:51:26 +00004053 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004054 ThrowMogrifyException(OptionError,"MissingArgument",option);
4055 if (IsGeometry(argv[i]) == MagickFalse)
4056 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4057 break;
4058 }
cristy1eb45dd2009-09-25 16:38:06 +00004059 if (LocaleCompare("clamp",option+1) == 0)
4060 break;
4061 if (LocaleCompare("clip",option+1) == 0)
4062 break;
cristy3ed852e2009-09-05 21:47:34 +00004063 if (LocaleCompare("clip-mask",option+1) == 0)
4064 {
4065 if (*option == '+')
4066 break;
4067 i++;
cristybb503372010-05-27 20:51:26 +00004068 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004069 ThrowMogrifyException(OptionError,"MissingArgument",option);
4070 break;
4071 }
4072 if (LocaleCompare("clut",option+1) == 0)
4073 break;
4074 if (LocaleCompare("coalesce",option+1) == 0)
4075 break;
4076 if (LocaleCompare("colorize",option+1) == 0)
4077 {
4078 if (*option == '+')
4079 break;
4080 i++;
cristybb503372010-05-27 20:51:26 +00004081 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004082 ThrowMogrifyException(OptionError,"MissingArgument",option);
4083 if (IsGeometry(argv[i]) == MagickFalse)
4084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4085 break;
4086 }
cristye6365592010-04-02 17:31:23 +00004087 if (LocaleCompare("color-matrix",option+1) == 0)
4088 {
cristyb6bd4ad2010-08-08 01:12:27 +00004089 KernelInfo
4090 *kernel_info;
4091
cristye6365592010-04-02 17:31:23 +00004092 if (*option == '+')
4093 break;
4094 i++;
cristybb503372010-05-27 20:51:26 +00004095 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004096 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004097 kernel_info=AcquireKernelInfo(argv[i]);
4098 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004100 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004101 break;
4102 }
cristy3ed852e2009-09-05 21:47:34 +00004103 if (LocaleCompare("colors",option+1) == 0)
4104 {
4105 if (*option == '+')
4106 break;
4107 i++;
cristybb503372010-05-27 20:51:26 +00004108 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004109 ThrowMogrifyException(OptionError,"MissingArgument",option);
4110 if (IsGeometry(argv[i]) == MagickFalse)
4111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4112 break;
4113 }
4114 if (LocaleCompare("colorspace",option+1) == 0)
4115 {
cristybb503372010-05-27 20:51:26 +00004116 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004117 colorspace;
4118
4119 if (*option == '+')
4120 break;
4121 i++;
cristybb503372010-05-27 20:51:26 +00004122 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004123 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004124 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004125 argv[i]);
4126 if (colorspace < 0)
4127 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4128 argv[i]);
4129 break;
4130 }
4131 if (LocaleCompare("combine",option+1) == 0)
4132 break;
4133 if (LocaleCompare("comment",option+1) == 0)
4134 {
4135 if (*option == '+')
4136 break;
4137 i++;
cristybb503372010-05-27 20:51:26 +00004138 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004139 ThrowMogrifyException(OptionError,"MissingArgument",option);
4140 break;
4141 }
4142 if (LocaleCompare("composite",option+1) == 0)
4143 break;
4144 if (LocaleCompare("compress",option+1) == 0)
4145 {
cristybb503372010-05-27 20:51:26 +00004146 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004147 compress;
4148
4149 if (*option == '+')
4150 break;
4151 i++;
cristybb503372010-05-27 20:51:26 +00004152 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004153 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004154 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004155 argv[i]);
4156 if (compress < 0)
4157 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4158 argv[i]);
4159 break;
4160 }
cristy22879752009-10-25 23:55:40 +00004161 if (LocaleCompare("concurrent",option+1) == 0)
4162 break;
cristy3ed852e2009-09-05 21:47:34 +00004163 if (LocaleCompare("contrast",option+1) == 0)
4164 break;
4165 if (LocaleCompare("contrast-stretch",option+1) == 0)
4166 {
4167 i++;
cristybb503372010-05-27 20:51:26 +00004168 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004169 ThrowMogrifyException(OptionError,"MissingArgument",option);
4170 if (IsGeometry(argv[i]) == MagickFalse)
4171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4172 break;
4173 }
4174 if (LocaleCompare("convolve",option+1) == 0)
4175 {
cristyb6bd4ad2010-08-08 01:12:27 +00004176 KernelInfo
4177 *kernel_info;
4178
cristy3ed852e2009-09-05 21:47:34 +00004179 if (*option == '+')
4180 break;
4181 i++;
cristybb503372010-05-27 20:51:26 +00004182 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004183 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004184 kernel_info=AcquireKernelInfo(argv[i]);
4185 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004186 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004187 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004188 break;
4189 }
4190 if (LocaleCompare("crop",option+1) == 0)
4191 {
4192 if (*option == '+')
4193 break;
4194 i++;
cristybb503372010-05-27 20:51:26 +00004195 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004196 ThrowMogrifyException(OptionError,"MissingArgument",option);
4197 if (IsGeometry(argv[i]) == MagickFalse)
4198 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4199 break;
4200 }
4201 if (LocaleCompare("cycle",option+1) == 0)
4202 {
4203 if (*option == '+')
4204 break;
4205 i++;
cristybb503372010-05-27 20:51:26 +00004206 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004207 ThrowMogrifyException(OptionError,"MissingArgument",option);
4208 if (IsGeometry(argv[i]) == MagickFalse)
4209 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4210 break;
4211 }
4212 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4213 }
4214 case 'd':
4215 {
4216 if (LocaleCompare("decipher",option+1) == 0)
4217 {
4218 if (*option == '+')
4219 break;
4220 i++;
cristybb503372010-05-27 20:51:26 +00004221 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004222 ThrowMogrifyException(OptionError,"MissingArgument",option);
4223 break;
4224 }
4225 if (LocaleCompare("deconstruct",option+1) == 0)
4226 break;
4227 if (LocaleCompare("debug",option+1) == 0)
4228 {
cristybb503372010-05-27 20:51:26 +00004229 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004230 event;
4231
4232 if (*option == '+')
4233 break;
4234 i++;
cristybb503372010-05-27 20:51:26 +00004235 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004236 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004237 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004238 if (event < 0)
4239 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4240 argv[i]);
4241 (void) SetLogEventMask(argv[i]);
4242 break;
4243 }
4244 if (LocaleCompare("define",option+1) == 0)
4245 {
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 (*option == '+')
4250 {
4251 const char
4252 *define;
4253
4254 define=GetImageOption(image_info,argv[i]);
4255 if (define == (const char *) NULL)
4256 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4257 break;
4258 }
4259 break;
4260 }
4261 if (LocaleCompare("delay",option+1) == 0)
4262 {
4263 if (*option == '+')
4264 break;
4265 i++;
cristybb503372010-05-27 20:51:26 +00004266 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004267 ThrowMogrifyException(OptionError,"MissingArgument",option);
4268 if (IsGeometry(argv[i]) == MagickFalse)
4269 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4270 break;
4271 }
cristyecb10ff2011-03-22 13:14:03 +00004272 if (LocaleCompare("delete",option+1) == 0)
4273 {
4274 if (*option == '+')
4275 break;
4276 i++;
4277 if (i == (ssize_t) (argc-1))
4278 ThrowMogrifyException(OptionError,"MissingArgument",option);
4279 if (IsGeometry(argv[i]) == MagickFalse)
4280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4281 break;
4282 }
cristy3ed852e2009-09-05 21:47:34 +00004283 if (LocaleCompare("density",option+1) == 0)
4284 {
4285 if (*option == '+')
4286 break;
4287 i++;
cristybb503372010-05-27 20:51:26 +00004288 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004289 ThrowMogrifyException(OptionError,"MissingArgument",option);
4290 if (IsGeometry(argv[i]) == MagickFalse)
4291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4292 break;
4293 }
4294 if (LocaleCompare("depth",option+1) == 0)
4295 {
4296 if (*option == '+')
4297 break;
4298 i++;
cristybb503372010-05-27 20:51:26 +00004299 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004300 ThrowMogrifyException(OptionError,"MissingArgument",option);
4301 if (IsGeometry(argv[i]) == MagickFalse)
4302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4303 break;
4304 }
4305 if (LocaleCompare("deskew",option+1) == 0)
4306 {
4307 if (*option == '+')
4308 break;
4309 i++;
cristybb503372010-05-27 20:51:26 +00004310 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004311 ThrowMogrifyException(OptionError,"MissingArgument",option);
4312 if (IsGeometry(argv[i]) == MagickFalse)
4313 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4314 break;
4315 }
4316 if (LocaleCompare("despeckle",option+1) == 0)
4317 break;
4318 if (LocaleCompare("dft",option+1) == 0)
4319 break;
cristyc9b12952010-03-28 01:12:28 +00004320 if (LocaleCompare("direction",option+1) == 0)
4321 {
cristybb503372010-05-27 20:51:26 +00004322 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004323 direction;
4324
4325 if (*option == '+')
4326 break;
4327 i++;
cristybb503372010-05-27 20:51:26 +00004328 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004329 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004330 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00004331 argv[i]);
4332 if (direction < 0)
4333 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4334 argv[i]);
4335 break;
4336 }
cristy3ed852e2009-09-05 21:47:34 +00004337 if (LocaleCompare("display",option+1) == 0)
4338 {
4339 if (*option == '+')
4340 break;
4341 i++;
cristybb503372010-05-27 20:51:26 +00004342 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004343 ThrowMogrifyException(OptionError,"MissingArgument",option);
4344 break;
4345 }
4346 if (LocaleCompare("dispose",option+1) == 0)
4347 {
cristybb503372010-05-27 20:51:26 +00004348 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004349 dispose;
4350
4351 if (*option == '+')
4352 break;
4353 i++;
cristybb503372010-05-27 20:51:26 +00004354 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004355 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004356 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004357 if (dispose < 0)
4358 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4359 argv[i]);
4360 break;
4361 }
4362 if (LocaleCompare("distort",option+1) == 0)
4363 {
cristybb503372010-05-27 20:51:26 +00004364 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004365 op;
4366
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 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004371 if (op < 0)
4372 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4373 argv[i]);
4374 i++;
cristybb503372010-05-27 20:51:26 +00004375 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004376 ThrowMogrifyException(OptionError,"MissingArgument",option);
4377 break;
4378 }
4379 if (LocaleCompare("dither",option+1) == 0)
4380 {
cristybb503372010-05-27 20:51:26 +00004381 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004382 method;
4383
4384 if (*option == '+')
4385 break;
4386 i++;
cristybb503372010-05-27 20:51:26 +00004387 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004388 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004389 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004390 if (method < 0)
4391 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4392 argv[i]);
4393 break;
4394 }
4395 if (LocaleCompare("draw",option+1) == 0)
4396 {
4397 if (*option == '+')
4398 break;
4399 i++;
cristybb503372010-05-27 20:51:26 +00004400 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004401 ThrowMogrifyException(OptionError,"MissingArgument",option);
4402 break;
4403 }
cristyecb10ff2011-03-22 13:14:03 +00004404 if (LocaleCompare("duplicate",option+1) == 0)
4405 {
4406 if (*option == '+')
4407 break;
4408 i++;
4409 if (i == (ssize_t) (argc-1))
4410 ThrowMogrifyException(OptionError,"MissingArgument",option);
4411 if (IsGeometry(argv[i]) == MagickFalse)
4412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4413 break;
4414 }
cristy22879752009-10-25 23:55:40 +00004415 if (LocaleCompare("duration",option+1) == 0)
4416 {
4417 if (*option == '+')
4418 break;
4419 i++;
cristybb503372010-05-27 20:51:26 +00004420 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004421 ThrowMogrifyException(OptionError,"MissingArgument",option);
4422 if (IsGeometry(argv[i]) == MagickFalse)
4423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4424 break;
4425 }
cristy3ed852e2009-09-05 21:47:34 +00004426 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4427 }
4428 case 'e':
4429 {
4430 if (LocaleCompare("edge",option+1) == 0)
4431 {
4432 if (*option == '+')
4433 break;
4434 i++;
cristybb503372010-05-27 20:51:26 +00004435 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004436 ThrowMogrifyException(OptionError,"MissingArgument",option);
4437 if (IsGeometry(argv[i]) == MagickFalse)
4438 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4439 break;
4440 }
4441 if (LocaleCompare("emboss",option+1) == 0)
4442 {
4443 if (*option == '+')
4444 break;
4445 i++;
cristybb503372010-05-27 20:51:26 +00004446 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004447 ThrowMogrifyException(OptionError,"MissingArgument",option);
4448 if (IsGeometry(argv[i]) == MagickFalse)
4449 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4450 break;
4451 }
4452 if (LocaleCompare("encipher",option+1) == 0)
4453 {
4454 if (*option == '+')
4455 break;
4456 i++;
cristybb503372010-05-27 20:51:26 +00004457 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004458 ThrowMogrifyException(OptionError,"MissingArgument",option);
4459 break;
4460 }
4461 if (LocaleCompare("encoding",option+1) == 0)
4462 {
4463 if (*option == '+')
4464 break;
4465 i++;
cristybb503372010-05-27 20:51:26 +00004466 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004467 ThrowMogrifyException(OptionError,"MissingArgument",option);
4468 break;
4469 }
4470 if (LocaleCompare("endian",option+1) == 0)
4471 {
cristybb503372010-05-27 20:51:26 +00004472 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004473 endian;
4474
4475 if (*option == '+')
4476 break;
4477 i++;
cristybb503372010-05-27 20:51:26 +00004478 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004479 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004480 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004481 if (endian < 0)
4482 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4483 argv[i]);
4484 break;
4485 }
4486 if (LocaleCompare("enhance",option+1) == 0)
4487 break;
4488 if (LocaleCompare("equalize",option+1) == 0)
4489 break;
4490 if (LocaleCompare("evaluate",option+1) == 0)
4491 {
cristybb503372010-05-27 20:51:26 +00004492 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004493 op;
4494
4495 if (*option == '+')
4496 break;
4497 i++;
cristybb503372010-05-27 20:51:26 +00004498 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004499 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004500 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004501 if (op < 0)
4502 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4503 argv[i]);
4504 i++;
cristybb503372010-05-27 20:51:26 +00004505 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004506 ThrowMogrifyException(OptionError,"MissingArgument",option);
4507 if (IsGeometry(argv[i]) == MagickFalse)
4508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4509 break;
4510 }
cristyd18ae7c2010-03-07 17:39:52 +00004511 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4512 {
cristybb503372010-05-27 20:51:26 +00004513 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004514 op;
4515
4516 if (*option == '+')
4517 break;
4518 i++;
cristybb503372010-05-27 20:51:26 +00004519 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004520 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004521 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00004522 if (op < 0)
4523 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4524 argv[i]);
4525 break;
4526 }
cristy3ed852e2009-09-05 21:47:34 +00004527 if (LocaleCompare("extent",option+1) == 0)
4528 {
4529 if (*option == '+')
4530 break;
4531 i++;
cristybb503372010-05-27 20:51:26 +00004532 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004533 ThrowMogrifyException(OptionError,"MissingArgument",option);
4534 if (IsGeometry(argv[i]) == MagickFalse)
4535 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4536 break;
4537 }
4538 if (LocaleCompare("extract",option+1) == 0)
4539 {
4540 if (*option == '+')
4541 break;
4542 i++;
cristybb503372010-05-27 20:51:26 +00004543 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004544 ThrowMogrifyException(OptionError,"MissingArgument",option);
4545 if (IsGeometry(argv[i]) == MagickFalse)
4546 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4547 break;
4548 }
4549 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4550 }
4551 case 'f':
4552 {
4553 if (LocaleCompare("family",option+1) == 0)
4554 {
4555 if (*option == '+')
4556 break;
4557 i++;
cristybb503372010-05-27 20:51:26 +00004558 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004559 ThrowMogrifyException(OptionError,"MissingArgument",option);
4560 break;
4561 }
4562 if (LocaleCompare("fill",option+1) == 0)
4563 {
4564 if (*option == '+')
4565 break;
4566 i++;
cristybb503372010-05-27 20:51:26 +00004567 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004568 ThrowMogrifyException(OptionError,"MissingArgument",option);
4569 break;
4570 }
4571 if (LocaleCompare("filter",option+1) == 0)
4572 {
cristybb503372010-05-27 20:51:26 +00004573 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004574 filter;
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);
cristy042ee782011-04-22 18:48:30 +00004581 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004582 if (filter < 0)
4583 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4584 argv[i]);
4585 break;
4586 }
4587 if (LocaleCompare("flatten",option+1) == 0)
4588 break;
4589 if (LocaleCompare("flip",option+1) == 0)
4590 break;
4591 if (LocaleCompare("flop",option+1) == 0)
4592 break;
4593 if (LocaleCompare("floodfill",option+1) == 0)
4594 {
4595 if (*option == '+')
4596 break;
4597 i++;
cristybb503372010-05-27 20:51:26 +00004598 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 if (IsGeometry(argv[i]) == MagickFalse)
4601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4602 i++;
cristybb503372010-05-27 20:51:26 +00004603 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004604 ThrowMogrifyException(OptionError,"MissingArgument",option);
4605 break;
4606 }
4607 if (LocaleCompare("font",option+1) == 0)
4608 {
4609 if (*option == '+')
4610 break;
4611 i++;
cristybb503372010-05-27 20:51:26 +00004612 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004613 ThrowMogrifyException(OptionError,"MissingArgument",option);
4614 break;
4615 }
4616 if (LocaleCompare("format",option+1) == 0)
4617 {
4618 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4619 (void) CloneString(&format,(char *) NULL);
4620 if (*option == '+')
4621 break;
4622 i++;
cristybb503372010-05-27 20:51:26 +00004623 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004624 ThrowMogrifyException(OptionError,"MissingArgument",option);
4625 (void) CloneString(&format,argv[i]);
4626 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4627 (void) ConcatenateMagickString(image_info->filename,":",
4628 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00004629 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00004630 if (*image_info->magick == '\0')
4631 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4632 format);
4633 break;
4634 }
4635 if (LocaleCompare("frame",option+1) == 0)
4636 {
4637 if (*option == '+')
4638 break;
4639 i++;
cristybb503372010-05-27 20:51:26 +00004640 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004641 ThrowMogrifyException(OptionError,"MissingArgument",option);
4642 if (IsGeometry(argv[i]) == MagickFalse)
4643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4644 break;
4645 }
4646 if (LocaleCompare("function",option+1) == 0)
4647 {
cristybb503372010-05-27 20:51:26 +00004648 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004649 op;
4650
4651 if (*option == '+')
4652 break;
4653 i++;
cristybb503372010-05-27 20:51:26 +00004654 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004655 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004656 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004657 if (op < 0)
4658 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4659 i++;
cristybb503372010-05-27 20:51:26 +00004660 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004661 ThrowMogrifyException(OptionError,"MissingArgument",option);
4662 break;
4663 }
4664 if (LocaleCompare("fuzz",option+1) == 0)
4665 {
4666 if (*option == '+')
4667 break;
4668 i++;
cristybb503372010-05-27 20:51:26 +00004669 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004670 ThrowMogrifyException(OptionError,"MissingArgument",option);
4671 if (IsGeometry(argv[i]) == MagickFalse)
4672 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4673 break;
4674 }
4675 if (LocaleCompare("fx",option+1) == 0)
4676 {
4677 if (*option == '+')
4678 break;
4679 i++;
cristybb503372010-05-27 20:51:26 +00004680 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004681 ThrowMogrifyException(OptionError,"MissingArgument",option);
4682 break;
4683 }
4684 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4685 }
4686 case 'g':
4687 {
4688 if (LocaleCompare("gamma",option+1) == 0)
4689 {
4690 i++;
cristybb503372010-05-27 20:51:26 +00004691 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004692 ThrowMogrifyException(OptionError,"MissingArgument",option);
4693 if (IsGeometry(argv[i]) == MagickFalse)
4694 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4695 break;
4696 }
4697 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4698 (LocaleCompare("gaussian",option+1) == 0))
4699 {
4700 i++;
cristybb503372010-05-27 20:51:26 +00004701 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004702 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 if (IsGeometry(argv[i]) == MagickFalse)
4704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4705 break;
4706 }
4707 if (LocaleCompare("geometry",option+1) == 0)
4708 {
4709 if (*option == '+')
4710 break;
4711 i++;
cristybb503372010-05-27 20:51:26 +00004712 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4714 if (IsGeometry(argv[i]) == MagickFalse)
4715 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4716 break;
4717 }
4718 if (LocaleCompare("gravity",option+1) == 0)
4719 {
cristybb503372010-05-27 20:51:26 +00004720 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004721 gravity;
4722
4723 if (*option == '+')
4724 break;
4725 i++;
cristybb503372010-05-27 20:51:26 +00004726 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004727 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004728 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004729 if (gravity < 0)
4730 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4731 argv[i]);
4732 break;
4733 }
4734 if (LocaleCompare("green-primary",option+1) == 0)
4735 {
4736 if (*option == '+')
4737 break;
4738 i++;
cristybb503372010-05-27 20:51:26 +00004739 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004740 ThrowMogrifyException(OptionError,"MissingArgument",option);
4741 if (IsGeometry(argv[i]) == MagickFalse)
4742 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4743 break;
4744 }
4745 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4746 }
4747 case 'h':
4748 {
4749 if (LocaleCompare("hald-clut",option+1) == 0)
4750 break;
4751 if ((LocaleCompare("help",option+1) == 0) ||
4752 (LocaleCompare("-help",option+1) == 0))
4753 return(MogrifyUsage());
4754 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4755 }
4756 case 'i':
4757 {
4758 if (LocaleCompare("identify",option+1) == 0)
4759 break;
4760 if (LocaleCompare("idft",option+1) == 0)
4761 break;
4762 if (LocaleCompare("implode",option+1) == 0)
4763 {
4764 if (*option == '+')
4765 break;
4766 i++;
cristybb503372010-05-27 20:51:26 +00004767 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004768 ThrowMogrifyException(OptionError,"MissingArgument",option);
4769 if (IsGeometry(argv[i]) == MagickFalse)
4770 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4771 break;
4772 }
4773 if (LocaleCompare("intent",option+1) == 0)
4774 {
cristybb503372010-05-27 20:51:26 +00004775 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004776 intent;
4777
4778 if (*option == '+')
4779 break;
4780 i++;
cristybb503372010-05-27 20:51:26 +00004781 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004782 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004783 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004784 if (intent < 0)
4785 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4786 argv[i]);
4787 break;
4788 }
4789 if (LocaleCompare("interlace",option+1) == 0)
4790 {
cristybb503372010-05-27 20:51:26 +00004791 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004792 interlace;
4793
4794 if (*option == '+')
4795 break;
4796 i++;
cristybb503372010-05-27 20:51:26 +00004797 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004798 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004799 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004800 argv[i]);
4801 if (interlace < 0)
4802 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4803 argv[i]);
4804 break;
4805 }
cristyb32b90a2009-09-07 21:45:48 +00004806 if (LocaleCompare("interline-spacing",option+1) == 0)
4807 {
4808 if (*option == '+')
4809 break;
4810 i++;
cristybb503372010-05-27 20:51:26 +00004811 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00004812 ThrowMogrifyException(OptionError,"MissingArgument",option);
4813 if (IsGeometry(argv[i]) == MagickFalse)
4814 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4815 break;
4816 }
cristy3ed852e2009-09-05 21:47:34 +00004817 if (LocaleCompare("interpolate",option+1) == 0)
4818 {
cristybb503372010-05-27 20:51:26 +00004819 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004820 interpolate;
4821
4822 if (*option == '+')
4823 break;
4824 i++;
cristybb503372010-05-27 20:51:26 +00004825 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004826 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004827 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004828 argv[i]);
4829 if (interpolate < 0)
4830 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4831 argv[i]);
4832 break;
4833 }
4834 if (LocaleCompare("interword-spacing",option+1) == 0)
4835 {
4836 if (*option == '+')
4837 break;
4838 i++;
cristybb503372010-05-27 20:51:26 +00004839 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004840 ThrowMogrifyException(OptionError,"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4843 break;
4844 }
4845 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4846 }
4847 case 'k':
4848 {
4849 if (LocaleCompare("kerning",option+1) == 0)
4850 {
4851 if (*option == '+')
4852 break;
4853 i++;
cristybb503372010-05-27 20:51:26 +00004854 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004855 ThrowMogrifyException(OptionError,"MissingArgument",option);
4856 if (IsGeometry(argv[i]) == MagickFalse)
4857 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4858 break;
4859 }
4860 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4861 }
4862 case 'l':
4863 {
4864 if (LocaleCompare("label",option+1) == 0)
4865 {
4866 if (*option == '+')
4867 break;
4868 i++;
cristybb503372010-05-27 20:51:26 +00004869 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004870 ThrowMogrifyException(OptionError,"MissingArgument",option);
4871 break;
4872 }
4873 if (LocaleCompare("lat",option+1) == 0)
4874 {
4875 if (*option == '+')
4876 break;
4877 i++;
cristybb503372010-05-27 20:51:26 +00004878 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004879 ThrowMogrifyException(OptionError,"MissingArgument",option);
4880 if (IsGeometry(argv[i]) == MagickFalse)
4881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4882 }
4883 if (LocaleCompare("layers",option+1) == 0)
4884 {
cristybb503372010-05-27 20:51:26 +00004885 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004886 type;
4887
4888 if (*option == '+')
4889 break;
4890 i++;
cristybb503372010-05-27 20:51:26 +00004891 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004892 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004893 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004894 if (type < 0)
4895 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4896 argv[i]);
4897 break;
4898 }
4899 if (LocaleCompare("level",option+1) == 0)
4900 {
4901 i++;
cristybb503372010-05-27 20:51:26 +00004902 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004903 ThrowMogrifyException(OptionError,"MissingArgument",option);
4904 if (IsGeometry(argv[i]) == MagickFalse)
4905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4906 break;
4907 }
4908 if (LocaleCompare("level-colors",option+1) == 0)
4909 {
4910 i++;
cristybb503372010-05-27 20:51:26 +00004911 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004912 ThrowMogrifyException(OptionError,"MissingArgument",option);
4913 break;
4914 }
4915 if (LocaleCompare("linewidth",option+1) == 0)
4916 {
4917 if (*option == '+')
4918 break;
4919 i++;
cristybb503372010-05-27 20:51:26 +00004920 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004921 ThrowMogrifyException(OptionError,"MissingArgument",option);
4922 if (IsGeometry(argv[i]) == MagickFalse)
4923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4924 break;
4925 }
4926 if (LocaleCompare("limit",option+1) == 0)
4927 {
4928 char
4929 *p;
4930
4931 double
4932 value;
4933
cristybb503372010-05-27 20:51:26 +00004934 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004935 resource;
4936
4937 if (*option == '+')
4938 break;
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);
cristy042ee782011-04-22 18:48:30 +00004942 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004943 argv[i]);
4944 if (resource < 0)
4945 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4946 argv[i]);
4947 i++;
cristybb503372010-05-27 20:51:26 +00004948 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004949 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyc1acd842011-05-19 23:05:47 +00004950 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00004951 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00004952 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4953 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4954 break;
4955 }
4956 if (LocaleCompare("liquid-rescale",option+1) == 0)
4957 {
4958 i++;
cristybb503372010-05-27 20:51:26 +00004959 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004960 ThrowMogrifyException(OptionError,"MissingArgument",option);
4961 if (IsGeometry(argv[i]) == MagickFalse)
4962 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4963 break;
4964 }
4965 if (LocaleCompare("list",option+1) == 0)
4966 {
cristybb503372010-05-27 20:51:26 +00004967 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004968 list;
4969
4970 if (*option == '+')
4971 break;
4972 i++;
cristybb503372010-05-27 20:51:26 +00004973 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004974 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004975 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004976 if (list < 0)
4977 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00004978 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00004979 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00004980 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00004981 }
4982 if (LocaleCompare("log",option+1) == 0)
4983 {
4984 if (*option == '+')
4985 break;
4986 i++;
cristybb503372010-05-27 20:51:26 +00004987 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00004988 (strchr(argv[i],'%') == (char *) NULL))
4989 ThrowMogrifyException(OptionError,"MissingArgument",option);
4990 break;
4991 }
4992 if (LocaleCompare("loop",option+1) == 0)
4993 {
4994 if (*option == '+')
4995 break;
4996 i++;
cristybb503372010-05-27 20:51:26 +00004997 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004998 ThrowMogrifyException(OptionError,"MissingArgument",option);
4999 if (IsGeometry(argv[i]) == MagickFalse)
5000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5001 break;
5002 }
5003 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5004 }
5005 case 'm':
5006 {
5007 if (LocaleCompare("map",option+1) == 0)
5008 {
5009 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5010 if (*option == '+')
5011 break;
5012 i++;
cristybb503372010-05-27 20:51:26 +00005013 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005014 ThrowMogrifyException(OptionError,"MissingArgument",option);
5015 break;
5016 }
5017 if (LocaleCompare("mask",option+1) == 0)
5018 {
5019 if (*option == '+')
5020 break;
5021 i++;
cristybb503372010-05-27 20:51:26 +00005022 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005023 ThrowMogrifyException(OptionError,"MissingArgument",option);
5024 break;
5025 }
5026 if (LocaleCompare("matte",option+1) == 0)
5027 break;
5028 if (LocaleCompare("mattecolor",option+1) == 0)
5029 {
5030 if (*option == '+')
5031 break;
5032 i++;
cristybb503372010-05-27 20:51:26 +00005033 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005034 ThrowMogrifyException(OptionError,"MissingArgument",option);
5035 break;
5036 }
cristyf40785b2010-03-06 02:27:27 +00005037 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005038 break;
cristyf40785b2010-03-06 02:27:27 +00005039 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005040 break;
cristy3ed852e2009-09-05 21:47:34 +00005041 if (LocaleCompare("modulate",option+1) == 0)
5042 {
5043 if (*option == '+')
5044 break;
5045 i++;
cristybb503372010-05-27 20:51:26 +00005046 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005047 ThrowMogrifyException(OptionError,"MissingArgument",option);
5048 if (IsGeometry(argv[i]) == MagickFalse)
5049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5050 break;
5051 }
5052 if (LocaleCompare("median",option+1) == 0)
5053 {
5054 if (*option == '+')
5055 break;
5056 i++;
cristybb503372010-05-27 20:51:26 +00005057 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005058 ThrowMogrifyException(OptionError,"MissingArgument",option);
5059 if (IsGeometry(argv[i]) == MagickFalse)
5060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5061 break;
5062 }
cristy69ec32d2011-02-27 23:57:09 +00005063 if (LocaleCompare("mode",option+1) == 0)
5064 {
5065 if (*option == '+')
5066 break;
5067 i++;
5068 if (i == (ssize_t) argc)
5069 ThrowMogrifyException(OptionError,"MissingArgument",option);
5070 if (IsGeometry(argv[i]) == MagickFalse)
5071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5072 break;
5073 }
cristy3ed852e2009-09-05 21:47:34 +00005074 if (LocaleCompare("monitor",option+1) == 0)
5075 break;
5076 if (LocaleCompare("monochrome",option+1) == 0)
5077 break;
5078 if (LocaleCompare("morph",option+1) == 0)
5079 {
5080 if (*option == '+')
5081 break;
5082 i++;
cristybb503372010-05-27 20:51:26 +00005083 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005084 ThrowMogrifyException(OptionError,"MissingArgument",option);
5085 if (IsGeometry(argv[i]) == MagickFalse)
5086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5087 break;
5088 }
anthony29188a82010-01-22 10:12:34 +00005089 if (LocaleCompare("morphology",option+1) == 0)
5090 {
anthony29188a82010-01-22 10:12:34 +00005091 char
5092 token[MaxTextExtent];
5093
cristyb6bd4ad2010-08-08 01:12:27 +00005094 KernelInfo
5095 *kernel_info;
5096
5097 ssize_t
5098 op;
5099
anthony29188a82010-01-22 10:12:34 +00005100 i++;
cristybb503372010-05-27 20:51:26 +00005101 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005102 ThrowMogrifyException(OptionError,"MissingArgument",option);
5103 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00005104 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00005105 if (op < 0)
5106 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005107 token);
anthony29188a82010-01-22 10:12:34 +00005108 i++;
cristybb503372010-05-27 20:51:26 +00005109 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005110 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005111 kernel_info=AcquireKernelInfo(argv[i]);
5112 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005113 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005114 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005115 break;
5116 }
cristy3ed852e2009-09-05 21:47:34 +00005117 if (LocaleCompare("mosaic",option+1) == 0)
5118 break;
5119 if (LocaleCompare("motion-blur",option+1) == 0)
5120 {
5121 if (*option == '+')
5122 break;
5123 i++;
cristybb503372010-05-27 20:51:26 +00005124 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005125 ThrowMogrifyException(OptionError,"MissingArgument",option);
5126 if (IsGeometry(argv[i]) == MagickFalse)
5127 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5128 break;
5129 }
5130 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5131 }
5132 case 'n':
5133 {
5134 if (LocaleCompare("negate",option+1) == 0)
5135 break;
5136 if (LocaleCompare("noise",option+1) == 0)
5137 {
5138 i++;
cristybb503372010-05-27 20:51:26 +00005139 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005140 ThrowMogrifyException(OptionError,"MissingArgument",option);
5141 if (*option == '+')
5142 {
cristybb503372010-05-27 20:51:26 +00005143 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005144 noise;
5145
cristy042ee782011-04-22 18:48:30 +00005146 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005147 if (noise < 0)
5148 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5149 argv[i]);
5150 break;
5151 }
5152 if (IsGeometry(argv[i]) == MagickFalse)
5153 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5154 break;
5155 }
5156 if (LocaleCompare("noop",option+1) == 0)
5157 break;
5158 if (LocaleCompare("normalize",option+1) == 0)
5159 break;
5160 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5161 }
5162 case 'o':
5163 {
5164 if (LocaleCompare("opaque",option+1) == 0)
5165 {
cristy3ed852e2009-09-05 21:47:34 +00005166 i++;
cristybb503372010-05-27 20:51:26 +00005167 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005168 ThrowMogrifyException(OptionError,"MissingArgument",option);
5169 break;
5170 }
5171 if (LocaleCompare("ordered-dither",option+1) == 0)
5172 {
5173 if (*option == '+')
5174 break;
5175 i++;
cristybb503372010-05-27 20:51:26 +00005176 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005177 ThrowMogrifyException(OptionError,"MissingArgument",option);
5178 break;
5179 }
5180 if (LocaleCompare("orient",option+1) == 0)
5181 {
cristybb503372010-05-27 20:51:26 +00005182 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005183 orientation;
5184
5185 orientation=UndefinedOrientation;
5186 if (*option == '+')
5187 break;
5188 i++;
cristybb503372010-05-27 20:51:26 +00005189 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005190 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005191 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005192 argv[i]);
5193 if (orientation < 0)
5194 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5195 argv[i]);
5196 break;
5197 }
5198 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5199 }
5200 case 'p':
5201 {
5202 if (LocaleCompare("page",option+1) == 0)
5203 {
5204 if (*option == '+')
5205 break;
5206 i++;
cristybb503372010-05-27 20:51:26 +00005207 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005208 ThrowMogrifyException(OptionError,"MissingArgument",option);
5209 break;
5210 }
5211 if (LocaleCompare("paint",option+1) == 0)
5212 {
5213 if (*option == '+')
5214 break;
5215 i++;
cristybb503372010-05-27 20:51:26 +00005216 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005217 ThrowMogrifyException(OptionError,"MissingArgument",option);
5218 if (IsGeometry(argv[i]) == MagickFalse)
5219 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5220 break;
5221 }
5222 if (LocaleCompare("path",option+1) == 0)
5223 {
5224 (void) CloneString(&path,(char *) NULL);
5225 if (*option == '+')
5226 break;
5227 i++;
cristybb503372010-05-27 20:51:26 +00005228 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005229 ThrowMogrifyException(OptionError,"MissingArgument",option);
5230 (void) CloneString(&path,argv[i]);
5231 break;
5232 }
5233 if (LocaleCompare("pointsize",option+1) == 0)
5234 {
5235 if (*option == '+')
5236 break;
5237 i++;
cristybb503372010-05-27 20:51:26 +00005238 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005239 ThrowMogrifyException(OptionError,"MissingArgument",option);
5240 if (IsGeometry(argv[i]) == MagickFalse)
5241 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5242 break;
5243 }
5244 if (LocaleCompare("polaroid",option+1) == 0)
5245 {
5246 if (*option == '+')
5247 break;
5248 i++;
cristybb503372010-05-27 20:51:26 +00005249 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005250 ThrowMogrifyException(OptionError,"MissingArgument",option);
5251 if (IsGeometry(argv[i]) == MagickFalse)
5252 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5253 break;
5254 }
5255 if (LocaleCompare("posterize",option+1) == 0)
5256 {
5257 if (*option == '+')
5258 break;
5259 i++;
cristybb503372010-05-27 20:51:26 +00005260 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005261 ThrowMogrifyException(OptionError,"MissingArgument",option);
5262 if (IsGeometry(argv[i]) == MagickFalse)
5263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5264 break;
5265 }
cristye7f51092010-01-17 00:39:37 +00005266 if (LocaleCompare("precision",option+1) == 0)
5267 {
5268 if (*option == '+')
5269 break;
5270 i++;
cristybb503372010-05-27 20:51:26 +00005271 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005272 ThrowMogrifyException(OptionError,"MissingArgument",option);
5273 if (IsGeometry(argv[i]) == MagickFalse)
5274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5275 break;
5276 }
cristy3ed852e2009-09-05 21:47:34 +00005277 if (LocaleCompare("print",option+1) == 0)
5278 {
5279 if (*option == '+')
5280 break;
5281 i++;
cristybb503372010-05-27 20:51:26 +00005282 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005283 ThrowMogrifyException(OptionError,"MissingArgument",option);
5284 break;
5285 }
5286 if (LocaleCompare("process",option+1) == 0)
5287 {
5288 if (*option == '+')
5289 break;
5290 i++;
cristybb503372010-05-27 20:51:26 +00005291 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005292 ThrowMogrifyException(OptionError,"MissingArgument",option);
5293 break;
5294 }
5295 if (LocaleCompare("profile",option+1) == 0)
5296 {
5297 i++;
cristybb503372010-05-27 20:51:26 +00005298 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005299 ThrowMogrifyException(OptionError,"MissingArgument",option);
5300 break;
5301 }
5302 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5303 }
5304 case 'q':
5305 {
5306 if (LocaleCompare("quality",option+1) == 0)
5307 {
5308 if (*option == '+')
5309 break;
5310 i++;
cristybb503372010-05-27 20:51:26 +00005311 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005312 ThrowMogrifyException(OptionError,"MissingArgument",option);
5313 if (IsGeometry(argv[i]) == MagickFalse)
5314 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5315 break;
5316 }
5317 if (LocaleCompare("quantize",option+1) == 0)
5318 {
cristybb503372010-05-27 20:51:26 +00005319 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005320 colorspace;
5321
5322 if (*option == '+')
5323 break;
5324 i++;
cristybb503372010-05-27 20:51:26 +00005325 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005326 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005327 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005328 argv[i]);
5329 if (colorspace < 0)
5330 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5331 argv[i]);
5332 break;
5333 }
5334 if (LocaleCompare("quiet",option+1) == 0)
5335 break;
5336 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5337 }
5338 case 'r':
5339 {
5340 if (LocaleCompare("radial-blur",option+1) == 0)
5341 {
5342 i++;
cristybb503372010-05-27 20:51:26 +00005343 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005344 ThrowMogrifyException(OptionError,"MissingArgument",option);
5345 if (IsGeometry(argv[i]) == MagickFalse)
5346 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5347 break;
5348 }
5349 if (LocaleCompare("raise",option+1) == 0)
5350 {
5351 i++;
cristybb503372010-05-27 20:51:26 +00005352 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005353 ThrowMogrifyException(OptionError,"MissingArgument",option);
5354 if (IsGeometry(argv[i]) == MagickFalse)
5355 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5356 break;
5357 }
5358 if (LocaleCompare("random-threshold",option+1) == 0)
5359 {
5360 if (*option == '+')
5361 break;
5362 i++;
cristybb503372010-05-27 20:51:26 +00005363 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005364 ThrowMogrifyException(OptionError,"MissingArgument",option);
5365 if (IsGeometry(argv[i]) == MagickFalse)
5366 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5367 break;
5368 }
cristye6365592010-04-02 17:31:23 +00005369 if (LocaleCompare("recolor",option+1) == 0)
5370 {
5371 if (*option == '+')
5372 break;
5373 i++;
cristybb503372010-05-27 20:51:26 +00005374 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005375 ThrowMogrifyException(OptionError,"MissingArgument",option);
5376 if (IsGeometry(argv[i]) == MagickFalse)
5377 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5378 break;
5379 }
cristy3ed852e2009-09-05 21:47:34 +00005380 if (LocaleCompare("red-primary",option+1) == 0)
5381 {
5382 if (*option == '+')
5383 break;
5384 i++;
cristybb503372010-05-27 20:51:26 +00005385 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005386 ThrowMogrifyException(OptionError,"MissingArgument",option);
5387 if (IsGeometry(argv[i]) == MagickFalse)
5388 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5389 }
cristy9f2083a2010-04-22 19:48:05 +00005390 if (LocaleCompare("regard-warnings",option+1) == 0)
5391 break;
cristy3ed852e2009-09-05 21:47:34 +00005392 if (LocaleCompare("region",option+1) == 0)
5393 {
5394 if (*option == '+')
5395 break;
5396 i++;
cristybb503372010-05-27 20:51:26 +00005397 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005398 ThrowMogrifyException(OptionError,"MissingArgument",option);
5399 if (IsGeometry(argv[i]) == MagickFalse)
5400 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5401 break;
5402 }
cristyf0c78232010-03-15 12:53:40 +00005403 if (LocaleCompare("remap",option+1) == 0)
5404 {
5405 if (*option == '+')
5406 break;
5407 i++;
cristybb503372010-05-27 20:51:26 +00005408 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005409 ThrowMogrifyException(OptionError,"MissingArgument",option);
5410 break;
5411 }
cristy3ed852e2009-09-05 21:47:34 +00005412 if (LocaleCompare("render",option+1) == 0)
5413 break;
5414 if (LocaleCompare("repage",option+1) == 0)
5415 {
5416 if (*option == '+')
5417 break;
5418 i++;
cristybb503372010-05-27 20:51:26 +00005419 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005420 ThrowMogrifyException(OptionError,"MissingArgument",option);
5421 if (IsGeometry(argv[i]) == MagickFalse)
5422 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5423 break;
5424 }
5425 if (LocaleCompare("resample",option+1) == 0)
5426 {
5427 if (*option == '+')
5428 break;
5429 i++;
cristybb503372010-05-27 20:51:26 +00005430 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005431 ThrowMogrifyException(OptionError,"MissingArgument",option);
5432 if (IsGeometry(argv[i]) == MagickFalse)
5433 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5434 break;
5435 }
5436 if (LocaleCompare("resize",option+1) == 0)
5437 {
5438 if (*option == '+')
5439 break;
5440 i++;
cristybb503372010-05-27 20:51:26 +00005441 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005442 ThrowMogrifyException(OptionError,"MissingArgument",option);
5443 if (IsGeometry(argv[i]) == MagickFalse)
5444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5445 break;
5446 }
cristyebbcfea2011-02-25 02:43:54 +00005447 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5448 {
5449 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5450 break;
5451 }
cristy3ed852e2009-09-05 21:47:34 +00005452 if (LocaleCompare("reverse",option+1) == 0)
5453 break;
5454 if (LocaleCompare("roll",option+1) == 0)
5455 {
5456 if (*option == '+')
5457 break;
5458 i++;
cristybb503372010-05-27 20:51:26 +00005459 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005460 ThrowMogrifyException(OptionError,"MissingArgument",option);
5461 if (IsGeometry(argv[i]) == MagickFalse)
5462 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5463 break;
5464 }
5465 if (LocaleCompare("rotate",option+1) == 0)
5466 {
5467 i++;
cristybb503372010-05-27 20:51:26 +00005468 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005469 ThrowMogrifyException(OptionError,"MissingArgument",option);
5470 if (IsGeometry(argv[i]) == MagickFalse)
5471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5472 break;
5473 }
5474 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5475 }
5476 case 's':
5477 {
5478 if (LocaleCompare("sample",option+1) == 0)
5479 {
5480 if (*option == '+')
5481 break;
5482 i++;
cristybb503372010-05-27 20:51:26 +00005483 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005484 ThrowMogrifyException(OptionError,"MissingArgument",option);
5485 if (IsGeometry(argv[i]) == MagickFalse)
5486 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5487 break;
5488 }
5489 if (LocaleCompare("sampling-factor",option+1) == 0)
5490 {
5491 if (*option == '+')
5492 break;
5493 i++;
cristybb503372010-05-27 20:51:26 +00005494 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005495 ThrowMogrifyException(OptionError,"MissingArgument",option);
5496 if (IsGeometry(argv[i]) == MagickFalse)
5497 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5498 break;
5499 }
5500 if (LocaleCompare("scale",option+1) == 0)
5501 {
5502 if (*option == '+')
5503 break;
5504 i++;
cristybb503372010-05-27 20:51:26 +00005505 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005506 ThrowMogrifyException(OptionError,"MissingArgument",option);
5507 if (IsGeometry(argv[i]) == MagickFalse)
5508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5509 break;
5510 }
5511 if (LocaleCompare("scene",option+1) == 0)
5512 {
5513 if (*option == '+')
5514 break;
5515 i++;
cristybb503372010-05-27 20:51:26 +00005516 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005517 ThrowMogrifyException(OptionError,"MissingArgument",option);
5518 if (IsGeometry(argv[i]) == MagickFalse)
5519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5520 break;
5521 }
5522 if (LocaleCompare("seed",option+1) == 0)
5523 {
5524 if (*option == '+')
5525 break;
5526 i++;
cristybb503372010-05-27 20:51:26 +00005527 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005528 ThrowMogrifyException(OptionError,"MissingArgument",option);
5529 if (IsGeometry(argv[i]) == MagickFalse)
5530 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5531 break;
5532 }
5533 if (LocaleCompare("segment",option+1) == 0)
5534 {
5535 if (*option == '+')
5536 break;
5537 i++;
cristybb503372010-05-27 20:51:26 +00005538 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005539 ThrowMogrifyException(OptionError,"MissingArgument",option);
5540 if (IsGeometry(argv[i]) == MagickFalse)
5541 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5542 break;
5543 }
5544 if (LocaleCompare("selective-blur",option+1) == 0)
5545 {
5546 i++;
cristybb503372010-05-27 20:51:26 +00005547 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005548 ThrowMogrifyException(OptionError,"MissingArgument",option);
5549 if (IsGeometry(argv[i]) == MagickFalse)
5550 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5551 break;
5552 }
5553 if (LocaleCompare("separate",option+1) == 0)
5554 break;
5555 if (LocaleCompare("sepia-tone",option+1) == 0)
5556 {
5557 if (*option == '+')
5558 break;
5559 i++;
cristybb503372010-05-27 20:51:26 +00005560 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005561 ThrowMogrifyException(OptionError,"MissingArgument",option);
5562 if (IsGeometry(argv[i]) == MagickFalse)
5563 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5564 break;
5565 }
5566 if (LocaleCompare("set",option+1) == 0)
5567 {
5568 i++;
cristybb503372010-05-27 20:51:26 +00005569 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005570 ThrowMogrifyException(OptionError,"MissingArgument",option);
5571 if (*option == '+')
5572 break;
5573 i++;
cristybb503372010-05-27 20:51:26 +00005574 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005575 ThrowMogrifyException(OptionError,"MissingArgument",option);
5576 break;
5577 }
5578 if (LocaleCompare("shade",option+1) == 0)
5579 {
5580 i++;
cristybb503372010-05-27 20:51:26 +00005581 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005582 ThrowMogrifyException(OptionError,"MissingArgument",option);
5583 if (IsGeometry(argv[i]) == MagickFalse)
5584 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5585 break;
5586 }
5587 if (LocaleCompare("shadow",option+1) == 0)
5588 {
5589 if (*option == '+')
5590 break;
5591 i++;
cristybb503372010-05-27 20:51:26 +00005592 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (IsGeometry(argv[i]) == MagickFalse)
5595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5596 break;
5597 }
5598 if (LocaleCompare("sharpen",option+1) == 0)
5599 {
5600 i++;
cristybb503372010-05-27 20:51:26 +00005601 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005602 ThrowMogrifyException(OptionError,"MissingArgument",option);
5603 if (IsGeometry(argv[i]) == MagickFalse)
5604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5605 break;
5606 }
5607 if (LocaleCompare("shave",option+1) == 0)
5608 {
5609 if (*option == '+')
5610 break;
5611 i++;
cristybb503372010-05-27 20:51:26 +00005612 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005613 ThrowMogrifyException(OptionError,"MissingArgument",option);
5614 if (IsGeometry(argv[i]) == MagickFalse)
5615 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5616 break;
5617 }
5618 if (LocaleCompare("shear",option+1) == 0)
5619 {
5620 i++;
cristybb503372010-05-27 20:51:26 +00005621 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005622 ThrowMogrifyException(OptionError,"MissingArgument",option);
5623 if (IsGeometry(argv[i]) == MagickFalse)
5624 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5625 break;
5626 }
5627 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5628 {
5629 i++;
cristybb503372010-05-27 20:51:26 +00005630 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005631 ThrowMogrifyException(OptionError,"MissingArgument",option);
5632 if (IsGeometry(argv[i]) == MagickFalse)
5633 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5634 break;
5635 }
5636 if (LocaleCompare("size",option+1) == 0)
5637 {
5638 if (*option == '+')
5639 break;
5640 i++;
cristybb503372010-05-27 20:51:26 +00005641 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005642 ThrowMogrifyException(OptionError,"MissingArgument",option);
5643 if (IsGeometry(argv[i]) == MagickFalse)
5644 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5645 break;
5646 }
5647 if (LocaleCompare("sketch",option+1) == 0)
5648 {
5649 if (*option == '+')
5650 break;
5651 i++;
cristybb503372010-05-27 20:51:26 +00005652 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005653 ThrowMogrifyException(OptionError,"MissingArgument",option);
5654 if (IsGeometry(argv[i]) == MagickFalse)
5655 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5656 break;
5657 }
cristy4285d782011-02-09 20:12:28 +00005658 if (LocaleCompare("smush",option+1) == 0)
5659 {
cristy4285d782011-02-09 20:12:28 +00005660 i++;
5661 if (i == (ssize_t) argc)
5662 ThrowMogrifyException(OptionError,"MissingArgument",option);
5663 if (IsGeometry(argv[i]) == MagickFalse)
5664 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00005665 i++;
5666 break;
5667 }
cristy3ed852e2009-09-05 21:47:34 +00005668 if (LocaleCompare("solarize",option+1) == 0)
5669 {
5670 if (*option == '+')
5671 break;
5672 i++;
cristybb503372010-05-27 20:51:26 +00005673 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005674 ThrowMogrifyException(OptionError,"MissingArgument",option);
5675 if (IsGeometry(argv[i]) == MagickFalse)
5676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5677 break;
5678 }
5679 if (LocaleCompare("sparse-color",option+1) == 0)
5680 {
cristybb503372010-05-27 20:51:26 +00005681 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005682 op;
5683
5684 i++;
cristybb503372010-05-27 20:51:26 +00005685 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005686 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005687 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005688 if (op < 0)
5689 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5690 argv[i]);
5691 i++;
cristybb503372010-05-27 20:51:26 +00005692 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005693 ThrowMogrifyException(OptionError,"MissingArgument",option);
5694 break;
5695 }
5696 if (LocaleCompare("spread",option+1) == 0)
5697 {
5698 if (*option == '+')
5699 break;
5700 i++;
cristybb503372010-05-27 20:51:26 +00005701 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005702 ThrowMogrifyException(OptionError,"MissingArgument",option);
5703 if (IsGeometry(argv[i]) == MagickFalse)
5704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5705 break;
5706 }
cristy0834d642011-03-18 18:26:08 +00005707 if (LocaleCompare("statistic",option+1) == 0)
5708 {
5709 ssize_t
5710 op;
5711
5712 if (*option == '+')
5713 break;
5714 i++;
5715 if (i == (ssize_t) argc)
5716 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005717 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00005718 if (op < 0)
5719 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5720 argv[i]);
5721 i++;
5722 if (i == (ssize_t) (argc-1))
5723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5724 if (IsGeometry(argv[i]) == MagickFalse)
5725 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5726 break;
5727 }
cristy3ed852e2009-09-05 21:47:34 +00005728 if (LocaleCompare("stretch",option+1) == 0)
5729 {
cristybb503372010-05-27 20:51:26 +00005730 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005731 stretch;
5732
5733 if (*option == '+')
5734 break;
5735 i++;
cristybb503372010-05-27 20:51:26 +00005736 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005737 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005738 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005739 if (stretch < 0)
5740 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5741 argv[i]);
5742 break;
5743 }
5744 if (LocaleCompare("strip",option+1) == 0)
5745 break;
5746 if (LocaleCompare("stroke",option+1) == 0)
5747 {
5748 if (*option == '+')
5749 break;
5750 i++;
cristybb503372010-05-27 20:51:26 +00005751 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005752 ThrowMogrifyException(OptionError,"MissingArgument",option);
5753 break;
5754 }
5755 if (LocaleCompare("strokewidth",option+1) == 0)
5756 {
5757 if (*option == '+')
5758 break;
5759 i++;
cristybb503372010-05-27 20:51:26 +00005760 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005761 ThrowMogrifyException(OptionError,"MissingArgument",option);
5762 if (IsGeometry(argv[i]) == MagickFalse)
5763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5764 break;
5765 }
5766 if (LocaleCompare("style",option+1) == 0)
5767 {
cristybb503372010-05-27 20:51:26 +00005768 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005769 style;
5770
5771 if (*option == '+')
5772 break;
5773 i++;
cristybb503372010-05-27 20:51:26 +00005774 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005775 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005776 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005777 if (style < 0)
5778 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5779 argv[i]);
5780 break;
5781 }
cristyecb10ff2011-03-22 13:14:03 +00005782 if (LocaleCompare("swap",option+1) == 0)
5783 {
5784 if (*option == '+')
5785 break;
5786 i++;
5787 if (i == (ssize_t) (argc-1))
5788 ThrowMogrifyException(OptionError,"MissingArgument",option);
5789 if (IsGeometry(argv[i]) == MagickFalse)
5790 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5791 break;
5792 }
cristy3ed852e2009-09-05 21:47:34 +00005793 if (LocaleCompare("swirl",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 if (IsGeometry(argv[i]) == MagickFalse)
5801 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5802 break;
5803 }
cristyd9a29192010-10-16 16:49:53 +00005804 if (LocaleCompare("synchronize",option+1) == 0)
5805 break;
cristy3ed852e2009-09-05 21:47:34 +00005806 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5807 }
5808 case 't':
5809 {
5810 if (LocaleCompare("taint",option+1) == 0)
5811 break;
5812 if (LocaleCompare("texture",option+1) == 0)
5813 {
5814 if (*option == '+')
5815 break;
5816 i++;
cristybb503372010-05-27 20:51:26 +00005817 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005818 ThrowMogrifyException(OptionError,"MissingArgument",option);
5819 break;
5820 }
5821 if (LocaleCompare("tile",option+1) == 0)
5822 {
5823 if (*option == '+')
5824 break;
5825 i++;
cristybb503372010-05-27 20:51:26 +00005826 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005827 ThrowMogrifyException(OptionError,"MissingArgument",option);
5828 break;
5829 }
5830 if (LocaleCompare("tile-offset",option+1) == 0)
5831 {
5832 if (*option == '+')
5833 break;
5834 i++;
cristybb503372010-05-27 20:51:26 +00005835 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005836 ThrowMogrifyException(OptionError,"MissingArgument",option);
5837 if (IsGeometry(argv[i]) == MagickFalse)
5838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5839 break;
5840 }
5841 if (LocaleCompare("tint",option+1) == 0)
5842 {
5843 if (*option == '+')
5844 break;
5845 i++;
cristybb503372010-05-27 20:51:26 +00005846 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005847 ThrowMogrifyException(OptionError,"MissingArgument",option);
5848 if (IsGeometry(argv[i]) == MagickFalse)
5849 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5850 break;
5851 }
5852 if (LocaleCompare("transform",option+1) == 0)
5853 break;
5854 if (LocaleCompare("transpose",option+1) == 0)
5855 break;
5856 if (LocaleCompare("transverse",option+1) == 0)
5857 break;
5858 if (LocaleCompare("threshold",option+1) == 0)
5859 {
5860 if (*option == '+')
5861 break;
5862 i++;
cristybb503372010-05-27 20:51:26 +00005863 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005864 ThrowMogrifyException(OptionError,"MissingArgument",option);
5865 if (IsGeometry(argv[i]) == MagickFalse)
5866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5867 break;
5868 }
5869 if (LocaleCompare("thumbnail",option+1) == 0)
5870 {
5871 if (*option == '+')
5872 break;
5873 i++;
cristybb503372010-05-27 20:51:26 +00005874 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005875 ThrowMogrifyException(OptionError,"MissingArgument",option);
5876 if (IsGeometry(argv[i]) == MagickFalse)
5877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5878 break;
5879 }
5880 if (LocaleCompare("transparent",option+1) == 0)
5881 {
5882 i++;
cristybb503372010-05-27 20:51:26 +00005883 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005884 ThrowMogrifyException(OptionError,"MissingArgument",option);
5885 break;
5886 }
5887 if (LocaleCompare("transparent-color",option+1) == 0)
5888 {
5889 if (*option == '+')
5890 break;
5891 i++;
cristybb503372010-05-27 20:51:26 +00005892 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005893 ThrowMogrifyException(OptionError,"MissingArgument",option);
5894 break;
5895 }
5896 if (LocaleCompare("treedepth",option+1) == 0)
5897 {
5898 if (*option == '+')
5899 break;
5900 i++;
cristybb503372010-05-27 20:51:26 +00005901 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005902 ThrowMogrifyException(OptionError,"MissingArgument",option);
5903 if (IsGeometry(argv[i]) == MagickFalse)
5904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5905 break;
5906 }
5907 if (LocaleCompare("trim",option+1) == 0)
5908 break;
5909 if (LocaleCompare("type",option+1) == 0)
5910 {
cristybb503372010-05-27 20:51:26 +00005911 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005912 type;
5913
5914 if (*option == '+')
5915 break;
5916 i++;
cristybb503372010-05-27 20:51:26 +00005917 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005918 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005919 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005920 if (type < 0)
5921 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5922 argv[i]);
5923 break;
5924 }
5925 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5926 }
5927 case 'u':
5928 {
5929 if (LocaleCompare("undercolor",option+1) == 0)
5930 {
5931 if (*option == '+')
5932 break;
5933 i++;
cristybb503372010-05-27 20:51:26 +00005934 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005935 ThrowMogrifyException(OptionError,"MissingArgument",option);
5936 break;
5937 }
5938 if (LocaleCompare("unique-colors",option+1) == 0)
5939 break;
5940 if (LocaleCompare("units",option+1) == 0)
5941 {
cristybb503372010-05-27 20:51:26 +00005942 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005943 units;
5944
5945 if (*option == '+')
5946 break;
5947 i++;
cristybb503372010-05-27 20:51:26 +00005948 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005949 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005950 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005951 argv[i]);
5952 if (units < 0)
5953 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5954 argv[i]);
5955 break;
5956 }
5957 if (LocaleCompare("unsharp",option+1) == 0)
5958 {
5959 i++;
cristybb503372010-05-27 20:51:26 +00005960 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005961 ThrowMogrifyException(OptionError,"MissingArgument",option);
5962 if (IsGeometry(argv[i]) == MagickFalse)
5963 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5964 break;
5965 }
5966 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5967 }
5968 case 'v':
5969 {
5970 if (LocaleCompare("verbose",option+1) == 0)
5971 {
5972 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5973 break;
5974 }
5975 if ((LocaleCompare("version",option+1) == 0) ||
5976 (LocaleCompare("-version",option+1) == 0))
5977 {
cristyb51dff52011-05-19 16:55:47 +00005978 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00005979 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00005980 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5981 GetMagickCopyright());
5982 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5983 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00005984 break;
5985 }
5986 if (LocaleCompare("view",option+1) == 0)
5987 {
5988 if (*option == '+')
5989 break;
5990 i++;
cristybb503372010-05-27 20:51:26 +00005991 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005992 ThrowMogrifyException(OptionError,"MissingArgument",option);
5993 break;
5994 }
5995 if (LocaleCompare("vignette",option+1) == 0)
5996 {
5997 if (*option == '+')
5998 break;
5999 i++;
cristybb503372010-05-27 20:51:26 +00006000 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006001 ThrowMogrifyException(OptionError,"MissingArgument",option);
6002 if (IsGeometry(argv[i]) == MagickFalse)
6003 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6004 break;
6005 }
6006 if (LocaleCompare("virtual-pixel",option+1) == 0)
6007 {
cristybb503372010-05-27 20:51:26 +00006008 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006009 method;
6010
6011 if (*option == '+')
6012 break;
6013 i++;
cristybb503372010-05-27 20:51:26 +00006014 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006015 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00006016 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00006017 argv[i]);
6018 if (method < 0)
6019 ThrowMogrifyException(OptionError,
6020 "UnrecognizedVirtualPixelMethod",argv[i]);
6021 break;
6022 }
6023 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6024 }
6025 case 'w':
6026 {
6027 if (LocaleCompare("wave",option+1) == 0)
6028 {
6029 i++;
cristybb503372010-05-27 20:51:26 +00006030 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006031 ThrowMogrifyException(OptionError,"MissingArgument",option);
6032 if (IsGeometry(argv[i]) == MagickFalse)
6033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6034 break;
6035 }
6036 if (LocaleCompare("weight",option+1) == 0)
6037 {
6038 if (*option == '+')
6039 break;
6040 i++;
cristybb503372010-05-27 20:51:26 +00006041 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006042 ThrowMogrifyException(OptionError,"MissingArgument",option);
6043 break;
6044 }
6045 if (LocaleCompare("white-point",option+1) == 0)
6046 {
6047 if (*option == '+')
6048 break;
6049 i++;
cristybb503372010-05-27 20:51:26 +00006050 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006051 ThrowMogrifyException(OptionError,"MissingArgument",option);
6052 if (IsGeometry(argv[i]) == MagickFalse)
6053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6054 break;
6055 }
6056 if (LocaleCompare("white-threshold",option+1) == 0)
6057 {
6058 if (*option == '+')
6059 break;
6060 i++;
cristybb503372010-05-27 20:51:26 +00006061 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006062 ThrowMogrifyException(OptionError,"MissingArgument",option);
6063 if (IsGeometry(argv[i]) == MagickFalse)
6064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6065 break;
6066 }
6067 if (LocaleCompare("write",option+1) == 0)
6068 {
6069 i++;
cristybb503372010-05-27 20:51:26 +00006070 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006071 ThrowMogrifyException(OptionError,"MissingArgument",option);
6072 break;
6073 }
6074 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6075 }
6076 case '?':
6077 break;
6078 default:
6079 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6080 }
cristy042ee782011-04-22 18:48:30 +00006081 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6082 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00006083 if (fire != MagickFalse)
6084 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6085 }
6086 if (k != 0)
6087 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006088 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006089 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6090 DestroyMogrify();
6091 return(status != 0 ? MagickTrue : MagickFalse);
6092}
6093
6094/*
6095%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6096% %
6097% %
6098% %
6099+ M o g r i f y I m a g e I n f o %
6100% %
6101% %
6102% %
6103%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6104%
6105% MogrifyImageInfo() applies image processing settings to the image as
6106% prescribed by command line options.
6107%
6108% The format of the MogrifyImageInfo method is:
6109%
6110% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6111% const char **argv,ExceptionInfo *exception)
6112%
6113% A description of each parameter follows:
6114%
6115% o image_info: the image info..
6116%
6117% o argc: Specifies a pointer to an integer describing the number of
6118% elements in the argument vector.
6119%
6120% o argv: Specifies a pointer to a text array containing the command line
6121% arguments.
6122%
6123% o exception: return any errors or warnings in this structure.
6124%
6125*/
6126WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6127 const int argc,const char **argv,ExceptionInfo *exception)
6128{
6129 const char
6130 *option;
6131
6132 GeometryInfo
6133 geometry_info;
6134
cristybb503372010-05-27 20:51:26 +00006135 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006136 count;
6137
cristybb503372010-05-27 20:51:26 +00006138 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006139 i;
6140
6141 /*
6142 Initialize method variables.
6143 */
6144 assert(image_info != (ImageInfo *) NULL);
6145 assert(image_info->signature == MagickSignature);
6146 if (image_info->debug != MagickFalse)
6147 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6148 image_info->filename);
6149 if (argc < 0)
6150 return(MagickTrue);
6151 /*
6152 Set the image settings.
6153 */
cristybb503372010-05-27 20:51:26 +00006154 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006155 {
6156 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00006157 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00006158 continue;
cristy042ee782011-04-22 18:48:30 +00006159 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00006160 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00006161 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006162 break;
6163 switch (*(option+1))
6164 {
6165 case 'a':
6166 {
6167 if (LocaleCompare("adjoin",option+1) == 0)
6168 {
6169 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6170 break;
6171 }
6172 if (LocaleCompare("antialias",option+1) == 0)
6173 {
6174 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6175 break;
6176 }
cristy3ed852e2009-09-05 21:47:34 +00006177 if (LocaleCompare("authenticate",option+1) == 0)
6178 {
6179 if (*option == '+')
anthony1afdc7a2011-10-05 11:54:28 +00006180 (void) DeleteImageOption(image_info,option+1);
cristy3ed852e2009-09-05 21:47:34 +00006181 else
anthony1afdc7a2011-10-05 11:54:28 +00006182 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006183 break;
6184 }
6185 break;
6186 }
6187 case 'b':
6188 {
6189 if (LocaleCompare("background",option+1) == 0)
6190 {
6191 if (*option == '+')
6192 {
6193 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006194 (void) QueryColorCompliance(MogrifyBackgroundColor,
6195 AllCompliance,&image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006196 break;
6197 }
6198 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006199 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6200 &image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006201 break;
6202 }
6203 if (LocaleCompare("bias",option+1) == 0)
6204 {
6205 if (*option == '+')
6206 {
6207 (void) SetImageOption(image_info,option+1,"0.0");
6208 break;
6209 }
6210 (void) SetImageOption(image_info,option+1,argv[i+1]);
6211 break;
6212 }
6213 if (LocaleCompare("black-point-compensation",option+1) == 0)
6214 {
6215 if (*option == '+')
6216 {
6217 (void) SetImageOption(image_info,option+1,"false");
6218 break;
6219 }
6220 (void) SetImageOption(image_info,option+1,"true");
6221 break;
6222 }
6223 if (LocaleCompare("blue-primary",option+1) == 0)
6224 {
6225 if (*option == '+')
6226 {
6227 (void) SetImageOption(image_info,option+1,"0.0");
6228 break;
6229 }
6230 (void) SetImageOption(image_info,option+1,argv[i+1]);
6231 break;
6232 }
6233 if (LocaleCompare("bordercolor",option+1) == 0)
6234 {
6235 if (*option == '+')
6236 {
6237 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006238 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006239 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006240 break;
6241 }
cristy9950d572011-10-01 18:22:35 +00006242 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6243 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006244 (void) SetImageOption(image_info,option+1,argv[i+1]);
6245 break;
6246 }
6247 if (LocaleCompare("box",option+1) == 0)
6248 {
6249 if (*option == '+')
6250 {
6251 (void) SetImageOption(image_info,"undercolor","none");
6252 break;
6253 }
6254 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6255 break;
6256 }
6257 break;
6258 }
6259 case 'c':
6260 {
6261 if (LocaleCompare("cache",option+1) == 0)
6262 {
6263 MagickSizeType
6264 limit;
6265
6266 limit=MagickResourceInfinity;
6267 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006268 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006269 (void) SetMagickResourceLimit(MemoryResource,limit);
6270 (void) SetMagickResourceLimit(MapResource,2*limit);
6271 break;
6272 }
6273 if (LocaleCompare("caption",option+1) == 0)
6274 {
6275 if (*option == '+')
6276 {
6277 (void) DeleteImageOption(image_info,option+1);
6278 break;
6279 }
6280 (void) SetImageOption(image_info,option+1,argv[i+1]);
6281 break;
6282 }
6283 if (LocaleCompare("channel",option+1) == 0)
6284 {
6285 if (*option == '+')
6286 {
6287 image_info->channel=DefaultChannels;
6288 break;
6289 }
6290 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6291 break;
6292 }
cristy3ed852e2009-09-05 21:47:34 +00006293 if (LocaleCompare("colorspace",option+1) == 0)
6294 {
6295 if (*option == '+')
6296 {
6297 image_info->colorspace=UndefinedColorspace;
6298 (void) SetImageOption(image_info,option+1,"undefined");
6299 break;
6300 }
cristy042ee782011-04-22 18:48:30 +00006301 image_info->colorspace=(ColorspaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006302 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6303 (void) SetImageOption(image_info,option+1,argv[i+1]);
6304 break;
6305 }
cristy3ed852e2009-09-05 21:47:34 +00006306 if (LocaleCompare("comment",option+1) == 0)
6307 {
6308 if (*option == '+')
6309 {
6310 (void) DeleteImageOption(image_info,option+1);
6311 break;
6312 }
6313 (void) SetImageOption(image_info,option+1,argv[i+1]);
6314 break;
6315 }
6316 if (LocaleCompare("compose",option+1) == 0)
6317 {
6318 if (*option == '+')
6319 {
6320 (void) SetImageOption(image_info,option+1,"undefined");
6321 break;
6322 }
6323 (void) SetImageOption(image_info,option+1,argv[i+1]);
6324 break;
6325 }
6326 if (LocaleCompare("compress",option+1) == 0)
6327 {
6328 if (*option == '+')
6329 {
6330 image_info->compression=UndefinedCompression;
6331 (void) SetImageOption(image_info,option+1,"undefined");
6332 break;
6333 }
cristy042ee782011-04-22 18:48:30 +00006334 image_info->compression=(CompressionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006335 MagickCompressOptions,MagickFalse,argv[i+1]);
6336 (void) SetImageOption(image_info,option+1,argv[i+1]);
6337 break;
6338 }
6339 break;
6340 }
6341 case 'd':
6342 {
6343 if (LocaleCompare("debug",option+1) == 0)
6344 {
6345 if (*option == '+')
6346 (void) SetLogEventMask("none");
6347 else
6348 (void) SetLogEventMask(argv[i+1]);
6349 image_info->debug=IsEventLogging();
6350 break;
6351 }
6352 if (LocaleCompare("define",option+1) == 0)
6353 {
6354 if (*option == '+')
6355 {
6356 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6357 (void) DeleteImageRegistry(argv[i+1]+9);
6358 else
6359 (void) DeleteImageOption(image_info,argv[i+1]);
6360 break;
6361 }
6362 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6363 {
6364 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6365 exception);
6366 break;
6367 }
6368 (void) DefineImageOption(image_info,argv[i+1]);
6369 break;
6370 }
6371 if (LocaleCompare("delay",option+1) == 0)
6372 {
6373 if (*option == '+')
6374 {
6375 (void) SetImageOption(image_info,option+1,"0");
6376 break;
6377 }
6378 (void) SetImageOption(image_info,option+1,argv[i+1]);
6379 break;
6380 }
6381 if (LocaleCompare("density",option+1) == 0)
6382 {
6383 /*
6384 Set image density.
6385 */
6386 if (*option == '+')
6387 {
6388 if (image_info->density != (char *) NULL)
6389 image_info->density=DestroyString(image_info->density);
6390 (void) SetImageOption(image_info,option+1,"72");
6391 break;
6392 }
6393 (void) CloneString(&image_info->density,argv[i+1]);
6394 (void) SetImageOption(image_info,option+1,argv[i+1]);
6395 break;
6396 }
6397 if (LocaleCompare("depth",option+1) == 0)
6398 {
6399 if (*option == '+')
6400 {
6401 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6402 break;
6403 }
cristye27293e2009-12-18 02:53:20 +00006404 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006405 break;
6406 }
cristyc9b12952010-03-28 01:12:28 +00006407 if (LocaleCompare("direction",option+1) == 0)
6408 {
6409 if (*option == '+')
6410 {
6411 (void) SetImageOption(image_info,option+1,"undefined");
6412 break;
6413 }
6414 (void) SetImageOption(image_info,option+1,argv[i+1]);
6415 break;
6416 }
cristy3ed852e2009-09-05 21:47:34 +00006417 if (LocaleCompare("display",option+1) == 0)
6418 {
6419 if (*option == '+')
6420 {
6421 if (image_info->server_name != (char *) NULL)
6422 image_info->server_name=DestroyString(
6423 image_info->server_name);
6424 break;
6425 }
6426 (void) CloneString(&image_info->server_name,argv[i+1]);
6427 break;
6428 }
6429 if (LocaleCompare("dispose",option+1) == 0)
6430 {
6431 if (*option == '+')
6432 {
6433 (void) SetImageOption(image_info,option+1,"undefined");
6434 break;
6435 }
6436 (void) SetImageOption(image_info,option+1,argv[i+1]);
6437 break;
6438 }
6439 if (LocaleCompare("dither",option+1) == 0)
6440 {
6441 if (*option == '+')
6442 {
6443 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006444 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006445 break;
6446 }
6447 (void) SetImageOption(image_info,option+1,argv[i+1]);
6448 image_info->dither=MagickTrue;
6449 break;
6450 }
6451 break;
6452 }
6453 case 'e':
6454 {
6455 if (LocaleCompare("encoding",option+1) == 0)
6456 {
6457 if (*option == '+')
6458 {
6459 (void) SetImageOption(image_info,option+1,"undefined");
6460 break;
6461 }
6462 (void) SetImageOption(image_info,option+1,argv[i+1]);
6463 break;
6464 }
6465 if (LocaleCompare("endian",option+1) == 0)
6466 {
6467 if (*option == '+')
6468 {
6469 image_info->endian=UndefinedEndian;
6470 (void) SetImageOption(image_info,option+1,"undefined");
6471 break;
6472 }
cristy042ee782011-04-22 18:48:30 +00006473 image_info->endian=(EndianType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006474 MagickEndianOptions,MagickFalse,argv[i+1]);
6475 (void) SetImageOption(image_info,option+1,argv[i+1]);
6476 break;
6477 }
6478 if (LocaleCompare("extract",option+1) == 0)
6479 {
6480 /*
6481 Set image extract geometry.
6482 */
6483 if (*option == '+')
6484 {
6485 if (image_info->extract != (char *) NULL)
6486 image_info->extract=DestroyString(image_info->extract);
6487 break;
6488 }
6489 (void) CloneString(&image_info->extract,argv[i+1]);
6490 break;
6491 }
6492 break;
6493 }
6494 case 'f':
6495 {
6496 if (LocaleCompare("fill",option+1) == 0)
6497 {
6498 if (*option == '+')
6499 {
6500 (void) SetImageOption(image_info,option+1,"none");
6501 break;
6502 }
6503 (void) SetImageOption(image_info,option+1,argv[i+1]);
6504 break;
6505 }
6506 if (LocaleCompare("filter",option+1) == 0)
6507 {
6508 if (*option == '+')
6509 {
6510 (void) SetImageOption(image_info,option+1,"undefined");
6511 break;
6512 }
6513 (void) SetImageOption(image_info,option+1,argv[i+1]);
6514 break;
6515 }
6516 if (LocaleCompare("font",option+1) == 0)
6517 {
6518 if (*option == '+')
6519 {
6520 if (image_info->font != (char *) NULL)
6521 image_info->font=DestroyString(image_info->font);
6522 break;
6523 }
6524 (void) CloneString(&image_info->font,argv[i+1]);
6525 break;
6526 }
6527 if (LocaleCompare("format",option+1) == 0)
6528 {
6529 register const char
6530 *q;
6531
6532 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006533 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006534 image_info->ping=MagickFalse;
6535 (void) SetImageOption(image_info,option+1,argv[i+1]);
6536 break;
6537 }
6538 if (LocaleCompare("fuzz",option+1) == 0)
6539 {
6540 if (*option == '+')
6541 {
6542 image_info->fuzz=0.0;
6543 (void) SetImageOption(image_info,option+1,"0");
6544 break;
6545 }
cristyf2f27272009-12-17 14:48:46 +00006546 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006547 1.0);
6548 (void) SetImageOption(image_info,option+1,argv[i+1]);
6549 break;
6550 }
6551 break;
6552 }
6553 case 'g':
6554 {
6555 if (LocaleCompare("gravity",option+1) == 0)
6556 {
6557 if (*option == '+')
6558 {
6559 (void) SetImageOption(image_info,option+1,"undefined");
6560 break;
6561 }
6562 (void) SetImageOption(image_info,option+1,argv[i+1]);
6563 break;
6564 }
6565 if (LocaleCompare("green-primary",option+1) == 0)
6566 {
6567 if (*option == '+')
6568 {
6569 (void) SetImageOption(image_info,option+1,"0.0");
6570 break;
6571 }
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6573 break;
6574 }
6575 break;
6576 }
6577 case 'i':
6578 {
6579 if (LocaleCompare("intent",option+1) == 0)
6580 {
6581 if (*option == '+')
6582 {
6583 (void) SetImageOption(image_info,option+1,"undefined");
6584 break;
6585 }
6586 (void) SetImageOption(image_info,option+1,argv[i+1]);
6587 break;
6588 }
6589 if (LocaleCompare("interlace",option+1) == 0)
6590 {
6591 if (*option == '+')
6592 {
6593 image_info->interlace=UndefinedInterlace;
6594 (void) SetImageOption(image_info,option+1,"undefined");
6595 break;
6596 }
cristy042ee782011-04-22 18:48:30 +00006597 image_info->interlace=(InterlaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006598 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6599 (void) SetImageOption(image_info,option+1,argv[i+1]);
6600 break;
6601 }
cristyb32b90a2009-09-07 21:45:48 +00006602 if (LocaleCompare("interline-spacing",option+1) == 0)
6603 {
6604 if (*option == '+')
6605 {
6606 (void) SetImageOption(image_info,option+1,"undefined");
6607 break;
6608 }
6609 (void) SetImageOption(image_info,option+1,argv[i+1]);
6610 break;
6611 }
cristy3ed852e2009-09-05 21:47:34 +00006612 if (LocaleCompare("interpolate",option+1) == 0)
6613 {
6614 if (*option == '+')
6615 {
6616 (void) SetImageOption(image_info,option+1,"undefined");
6617 break;
6618 }
6619 (void) SetImageOption(image_info,option+1,argv[i+1]);
6620 break;
6621 }
6622 if (LocaleCompare("interword-spacing",option+1) == 0)
6623 {
6624 if (*option == '+')
6625 {
6626 (void) SetImageOption(image_info,option+1,"undefined");
6627 break;
6628 }
6629 (void) SetImageOption(image_info,option+1,argv[i+1]);
6630 break;
6631 }
6632 break;
6633 }
6634 case 'k':
6635 {
6636 if (LocaleCompare("kerning",option+1) == 0)
6637 {
6638 if (*option == '+')
6639 {
6640 (void) SetImageOption(image_info,option+1,"undefined");
6641 break;
6642 }
6643 (void) SetImageOption(image_info,option+1,argv[i+1]);
6644 break;
6645 }
6646 break;
6647 }
6648 case 'l':
6649 {
6650 if (LocaleCompare("label",option+1) == 0)
6651 {
6652 if (*option == '+')
6653 {
6654 (void) DeleteImageOption(image_info,option+1);
6655 break;
6656 }
6657 (void) SetImageOption(image_info,option+1,argv[i+1]);
6658 break;
6659 }
6660 if (LocaleCompare("limit",option+1) == 0)
6661 {
6662 MagickSizeType
6663 limit;
6664
6665 ResourceType
6666 type;
6667
6668 if (*option == '+')
6669 break;
cristy042ee782011-04-22 18:48:30 +00006670 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
cristy3ed852e2009-09-05 21:47:34 +00006671 MagickFalse,argv[i+1]);
6672 limit=MagickResourceInfinity;
6673 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006674 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006675 (void) SetMagickResourceLimit(type,limit);
6676 break;
6677 }
6678 if (LocaleCompare("list",option+1) == 0)
6679 {
cristybb503372010-05-27 20:51:26 +00006680 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006681 list;
6682
6683 /*
6684 Display configuration list.
6685 */
cristy042ee782011-04-22 18:48:30 +00006686 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006687 switch (list)
6688 {
6689 case MagickCoderOptions:
6690 {
6691 (void) ListCoderInfo((FILE *) NULL,exception);
6692 break;
6693 }
6694 case MagickColorOptions:
6695 {
6696 (void) ListColorInfo((FILE *) NULL,exception);
6697 break;
6698 }
6699 case MagickConfigureOptions:
6700 {
6701 (void) ListConfigureInfo((FILE *) NULL,exception);
6702 break;
6703 }
6704 case MagickDelegateOptions:
6705 {
6706 (void) ListDelegateInfo((FILE *) NULL,exception);
6707 break;
6708 }
6709 case MagickFontOptions:
6710 {
6711 (void) ListTypeInfo((FILE *) NULL,exception);
6712 break;
6713 }
6714 case MagickFormatOptions:
6715 {
6716 (void) ListMagickInfo((FILE *) NULL,exception);
6717 break;
6718 }
6719 case MagickLocaleOptions:
6720 {
6721 (void) ListLocaleInfo((FILE *) NULL,exception);
6722 break;
6723 }
6724 case MagickLogOptions:
6725 {
6726 (void) ListLogInfo((FILE *) NULL,exception);
6727 break;
6728 }
6729 case MagickMagicOptions:
6730 {
6731 (void) ListMagicInfo((FILE *) NULL,exception);
6732 break;
6733 }
6734 case MagickMimeOptions:
6735 {
6736 (void) ListMimeInfo((FILE *) NULL,exception);
6737 break;
6738 }
6739 case MagickModuleOptions:
6740 {
6741 (void) ListModuleInfo((FILE *) NULL,exception);
6742 break;
6743 }
6744 case MagickPolicyOptions:
6745 {
6746 (void) ListPolicyInfo((FILE *) NULL,exception);
6747 break;
6748 }
6749 case MagickResourceOptions:
6750 {
6751 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6752 break;
6753 }
6754 case MagickThresholdOptions:
6755 {
6756 (void) ListThresholdMaps((FILE *) NULL,exception);
6757 break;
6758 }
6759 default:
6760 {
cristy042ee782011-04-22 18:48:30 +00006761 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
cristy3ed852e2009-09-05 21:47:34 +00006762 exception);
6763 break;
6764 }
6765 }
cristyaeb2cbc2010-05-07 13:28:58 +00006766 break;
cristy3ed852e2009-09-05 21:47:34 +00006767 }
6768 if (LocaleCompare("log",option+1) == 0)
6769 {
6770 if (*option == '+')
6771 break;
6772 (void) SetLogFormat(argv[i+1]);
6773 break;
6774 }
6775 if (LocaleCompare("loop",option+1) == 0)
6776 {
6777 if (*option == '+')
6778 {
6779 (void) SetImageOption(image_info,option+1,"0");
6780 break;
6781 }
6782 (void) SetImageOption(image_info,option+1,argv[i+1]);
6783 break;
6784 }
6785 break;
6786 }
6787 case 'm':
6788 {
6789 if (LocaleCompare("matte",option+1) == 0)
6790 {
6791 if (*option == '+')
6792 {
6793 (void) SetImageOption(image_info,option+1,"false");
6794 break;
6795 }
6796 (void) SetImageOption(image_info,option+1,"true");
6797 break;
6798 }
6799 if (LocaleCompare("mattecolor",option+1) == 0)
6800 {
6801 if (*option == '+')
6802 {
6803 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006804 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006805 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006806 break;
6807 }
6808 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006809 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6810 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006811 break;
6812 }
6813 if (LocaleCompare("monitor",option+1) == 0)
6814 {
6815 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6816 (void *) NULL);
6817 break;
6818 }
6819 if (LocaleCompare("monochrome",option+1) == 0)
6820 {
6821 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6822 break;
6823 }
6824 break;
6825 }
6826 case 'o':
6827 {
6828 if (LocaleCompare("orient",option+1) == 0)
6829 {
6830 if (*option == '+')
6831 {
6832 image_info->orientation=UndefinedOrientation;
6833 (void) SetImageOption(image_info,option+1,"undefined");
6834 break;
6835 }
cristy042ee782011-04-22 18:48:30 +00006836 image_info->orientation=(OrientationType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006837 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00006838 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006839 break;
6840 }
6841 }
6842 case 'p':
6843 {
6844 if (LocaleCompare("page",option+1) == 0)
6845 {
6846 char
6847 *canonical_page,
6848 page[MaxTextExtent];
6849
6850 const char
6851 *image_option;
6852
6853 MagickStatusType
6854 flags;
6855
6856 RectangleInfo
6857 geometry;
6858
6859 if (*option == '+')
6860 {
6861 (void) DeleteImageOption(image_info,option+1);
6862 (void) CloneString(&image_info->page,(char *) NULL);
6863 break;
6864 }
6865 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6866 image_option=GetImageOption(image_info,"page");
6867 if (image_option != (const char *) NULL)
6868 flags=ParseAbsoluteGeometry(image_option,&geometry);
6869 canonical_page=GetPageGeometry(argv[i+1]);
6870 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6871 canonical_page=DestroyString(canonical_page);
cristyb51dff52011-05-19 16:55:47 +00006872 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00006873 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00006874 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
cristyb51dff52011-05-19 16:55:47 +00006875 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00006876 (unsigned long) geometry.width,(unsigned long) geometry.height,
6877 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00006878 (void) SetImageOption(image_info,option+1,page);
6879 (void) CloneString(&image_info->page,page);
6880 break;
6881 }
6882 if (LocaleCompare("pen",option+1) == 0)
6883 {
6884 if (*option == '+')
6885 {
6886 (void) SetImageOption(image_info,option+1,"none");
6887 break;
6888 }
6889 (void) SetImageOption(image_info,option+1,argv[i+1]);
6890 break;
6891 }
6892 if (LocaleCompare("ping",option+1) == 0)
6893 {
6894 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6895 break;
6896 }
6897 if (LocaleCompare("pointsize",option+1) == 0)
6898 {
6899 if (*option == '+')
6900 geometry_info.rho=0.0;
6901 else
6902 (void) ParseGeometry(argv[i+1],&geometry_info);
6903 image_info->pointsize=geometry_info.rho;
6904 break;
6905 }
cristye7f51092010-01-17 00:39:37 +00006906 if (LocaleCompare("precision",option+1) == 0)
6907 {
cristybf2766a2010-01-17 03:33:23 +00006908 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00006909 break;
6910 }
cristy3ed852e2009-09-05 21:47:34 +00006911 if (LocaleCompare("preview",option+1) == 0)
6912 {
6913 /*
6914 Preview image.
6915 */
6916 if (*option == '+')
6917 {
6918 image_info->preview_type=UndefinedPreview;
6919 break;
6920 }
cristy042ee782011-04-22 18:48:30 +00006921 image_info->preview_type=(PreviewType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006922 MagickPreviewOptions,MagickFalse,argv[i+1]);
6923 break;
6924 }
6925 break;
6926 }
6927 case 'q':
6928 {
6929 if (LocaleCompare("quality",option+1) == 0)
6930 {
6931 /*
6932 Set image compression quality.
6933 */
6934 if (*option == '+')
6935 {
6936 image_info->quality=UndefinedCompressionQuality;
6937 (void) SetImageOption(image_info,option+1,"0");
6938 break;
6939 }
cristye27293e2009-12-18 02:53:20 +00006940 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006941 (void) SetImageOption(image_info,option+1,argv[i+1]);
6942 break;
6943 }
6944 if (LocaleCompare("quiet",option+1) == 0)
6945 {
6946 static WarningHandler
6947 warning_handler = (WarningHandler) NULL;
6948
6949 if (*option == '+')
6950 {
6951 /*
6952 Restore error or warning messages.
6953 */
6954 warning_handler=SetWarningHandler(warning_handler);
6955 break;
6956 }
6957 /*
6958 Suppress error or warning messages.
6959 */
6960 warning_handler=SetWarningHandler((WarningHandler) NULL);
6961 break;
6962 }
6963 break;
6964 }
6965 case 'r':
6966 {
6967 if (LocaleCompare("red-primary",option+1) == 0)
6968 {
6969 if (*option == '+')
6970 {
6971 (void) SetImageOption(image_info,option+1,"0.0");
6972 break;
6973 }
6974 (void) SetImageOption(image_info,option+1,argv[i+1]);
6975 break;
6976 }
6977 break;
6978 }
6979 case 's':
6980 {
6981 if (LocaleCompare("sampling-factor",option+1) == 0)
6982 {
6983 /*
6984 Set image sampling factor.
6985 */
6986 if (*option == '+')
6987 {
6988 if (image_info->sampling_factor != (char *) NULL)
6989 image_info->sampling_factor=DestroyString(
6990 image_info->sampling_factor);
6991 break;
6992 }
6993 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6994 break;
6995 }
6996 if (LocaleCompare("scene",option+1) == 0)
6997 {
6998 /*
6999 Set image scene.
7000 */
7001 if (*option == '+')
7002 {
7003 image_info->scene=0;
7004 (void) SetImageOption(image_info,option+1,"0");
7005 break;
7006 }
cristye27293e2009-12-18 02:53:20 +00007007 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007008 (void) SetImageOption(image_info,option+1,argv[i+1]);
7009 break;
7010 }
7011 if (LocaleCompare("seed",option+1) == 0)
7012 {
cristybb503372010-05-27 20:51:26 +00007013 size_t
cristy3ed852e2009-09-05 21:47:34 +00007014 seed;
7015
7016 if (*option == '+')
7017 {
cristybb503372010-05-27 20:51:26 +00007018 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007019 SeedPseudoRandomGenerator(seed);
7020 break;
7021 }
cristye27293e2009-12-18 02:53:20 +00007022 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007023 SeedPseudoRandomGenerator(seed);
7024 break;
7025 }
7026 if (LocaleCompare("size",option+1) == 0)
7027 {
7028 if (*option == '+')
7029 {
7030 if (image_info->size != (char *) NULL)
7031 image_info->size=DestroyString(image_info->size);
7032 break;
7033 }
7034 (void) CloneString(&image_info->size,argv[i+1]);
7035 break;
7036 }
7037 if (LocaleCompare("stroke",option+1) == 0)
7038 {
7039 if (*option == '+')
7040 {
7041 (void) SetImageOption(image_info,option+1,"none");
7042 break;
7043 }
7044 (void) SetImageOption(image_info,option+1,argv[i+1]);
7045 break;
7046 }
7047 if (LocaleCompare("strokewidth",option+1) == 0)
7048 {
7049 if (*option == '+')
7050 {
7051 (void) SetImageOption(image_info,option+1,"0");
7052 break;
7053 }
7054 (void) SetImageOption(image_info,option+1,argv[i+1]);
7055 break;
7056 }
cristyd9a29192010-10-16 16:49:53 +00007057 if (LocaleCompare("synchronize",option+1) == 0)
7058 {
7059 if (*option == '+')
7060 {
7061 image_info->synchronize=MagickFalse;
7062 break;
7063 }
7064 image_info->synchronize=MagickTrue;
7065 break;
7066 }
cristy3ed852e2009-09-05 21:47:34 +00007067 break;
7068 }
7069 case 't':
7070 {
7071 if (LocaleCompare("taint",option+1) == 0)
7072 {
7073 if (*option == '+')
7074 {
7075 (void) SetImageOption(image_info,option+1,"false");
7076 break;
7077 }
7078 (void) SetImageOption(image_info,option+1,"true");
7079 break;
7080 }
7081 if (LocaleCompare("texture",option+1) == 0)
7082 {
7083 if (*option == '+')
7084 {
7085 if (image_info->texture != (char *) NULL)
7086 image_info->texture=DestroyString(image_info->texture);
7087 break;
7088 }
7089 (void) CloneString(&image_info->texture,argv[i+1]);
7090 break;
7091 }
7092 if (LocaleCompare("tile-offset",option+1) == 0)
7093 {
7094 if (*option == '+')
7095 {
7096 (void) SetImageOption(image_info,option+1,"0");
7097 break;
7098 }
7099 (void) SetImageOption(image_info,option+1,argv[i+1]);
7100 break;
7101 }
7102 if (LocaleCompare("transparent-color",option+1) == 0)
7103 {
7104 if (*option == '+')
7105 {
cristy9950d572011-10-01 18:22:35 +00007106 (void) QueryColorCompliance("none",AllCompliance,
7107 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007108 (void) SetImageOption(image_info,option+1,"none");
7109 break;
7110 }
cristy9950d572011-10-01 18:22:35 +00007111 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7112 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007113 (void) SetImageOption(image_info,option+1,argv[i+1]);
7114 break;
7115 }
7116 if (LocaleCompare("type",option+1) == 0)
7117 {
7118 if (*option == '+')
7119 {
cristy5f1c1ff2010-12-23 21:38:06 +00007120 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007121 (void) SetImageOption(image_info,option+1,"undefined");
7122 break;
7123 }
cristy042ee782011-04-22 18:48:30 +00007124 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
cristy3ed852e2009-09-05 21:47:34 +00007125 MagickFalse,argv[i+1]);
7126 (void) SetImageOption(image_info,option+1,argv[i+1]);
7127 break;
7128 }
7129 break;
7130 }
7131 case 'u':
7132 {
7133 if (LocaleCompare("undercolor",option+1) == 0)
7134 {
7135 if (*option == '+')
7136 {
7137 (void) DeleteImageOption(image_info,option+1);
7138 break;
7139 }
7140 (void) SetImageOption(image_info,option+1,argv[i+1]);
7141 break;
7142 }
7143 if (LocaleCompare("units",option+1) == 0)
7144 {
7145 if (*option == '+')
7146 {
7147 image_info->units=UndefinedResolution;
7148 (void) SetImageOption(image_info,option+1,"undefined");
7149 break;
7150 }
cristy042ee782011-04-22 18:48:30 +00007151 image_info->units=(ResolutionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007152 MagickResolutionOptions,MagickFalse,argv[i+1]);
7153 (void) SetImageOption(image_info,option+1,argv[i+1]);
7154 break;
7155 }
7156 break;
7157 }
7158 case 'v':
7159 {
7160 if (LocaleCompare("verbose",option+1) == 0)
7161 {
7162 if (*option == '+')
7163 {
7164 image_info->verbose=MagickFalse;
7165 break;
7166 }
7167 image_info->verbose=MagickTrue;
7168 image_info->ping=MagickFalse;
7169 break;
7170 }
7171 if (LocaleCompare("view",option+1) == 0)
7172 {
7173 if (*option == '+')
7174 {
7175 if (image_info->view != (char *) NULL)
7176 image_info->view=DestroyString(image_info->view);
7177 break;
7178 }
7179 (void) CloneString(&image_info->view,argv[i+1]);
7180 break;
7181 }
7182 if (LocaleCompare("virtual-pixel",option+1) == 0)
7183 {
7184 if (*option == '+')
7185 {
7186 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7187 (void) SetImageOption(image_info,option+1,"undefined");
7188 break;
7189 }
7190 image_info->virtual_pixel_method=(VirtualPixelMethod)
cristy042ee782011-04-22 18:48:30 +00007191 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00007192 argv[i+1]);
7193 (void) SetImageOption(image_info,option+1,argv[i+1]);
7194 break;
7195 }
7196 break;
7197 }
7198 case 'w':
7199 {
7200 if (LocaleCompare("white-point",option+1) == 0)
7201 {
7202 if (*option == '+')
7203 {
7204 (void) SetImageOption(image_info,option+1,"0.0");
7205 break;
7206 }
7207 (void) SetImageOption(image_info,option+1,argv[i+1]);
7208 break;
7209 }
7210 break;
7211 }
7212 default:
7213 break;
7214 }
7215 i+=count;
7216 }
7217 return(MagickTrue);
7218}
7219
7220/*
7221%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7222% %
7223% %
7224% %
7225+ M o g r i f y I m a g e L i s t %
7226% %
7227% %
7228% %
7229%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7230%
7231% MogrifyImageList() applies any command line options that might affect the
7232% entire image list (e.g. -append, -coalesce, etc.).
7233%
7234% The format of the MogrifyImage method is:
7235%
7236% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7237% const char **argv,Image **images,ExceptionInfo *exception)
7238%
7239% A description of each parameter follows:
7240%
7241% o image_info: the image info..
7242%
7243% o argc: Specifies a pointer to an integer describing the number of
7244% elements in the argument vector.
7245%
7246% o argv: Specifies a pointer to a text array containing the command line
7247% arguments.
7248%
anthonye9c27192011-03-27 08:07:06 +00007249% o images: pointer to pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00007250%
7251% o exception: return any errors or warnings in this structure.
7252%
7253*/
7254WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7255 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7256{
cristy3ed852e2009-09-05 21:47:34 +00007257 const char
7258 *option;
7259
cristy6b3da3a2010-06-20 02:21:46 +00007260 ImageInfo
7261 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007262
7263 MagickStatusType
7264 status;
7265
cristy28474bf2011-09-11 23:32:52 +00007266 PixelInterpolateMethod
7267 interpolate_method;
7268
cristy3ed852e2009-09-05 21:47:34 +00007269 QuantizeInfo
7270 *quantize_info;
7271
cristybb503372010-05-27 20:51:26 +00007272 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007273 i;
7274
cristy6b3da3a2010-06-20 02:21:46 +00007275 ssize_t
7276 count,
7277 index;
7278
cristy3ed852e2009-09-05 21:47:34 +00007279 /*
7280 Apply options to the image list.
7281 */
7282 assert(image_info != (ImageInfo *) NULL);
7283 assert(image_info->signature == MagickSignature);
7284 assert(images != (Image **) NULL);
anthonye9c27192011-03-27 08:07:06 +00007285 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007286 assert((*images)->signature == MagickSignature);
7287 if ((*images)->debug != MagickFalse)
7288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7289 (*images)->filename);
7290 if ((argc <= 0) || (*argv == (char *) NULL))
7291 return(MagickTrue);
cristy28474bf2011-09-11 23:32:52 +00007292 interpolate_method=UndefinedInterpolatePixel;
cristy6b3da3a2010-06-20 02:21:46 +00007293 mogrify_info=CloneImageInfo(image_info);
7294 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00007295 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007296 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007297 {
cristy74fe8f12009-10-03 19:09:01 +00007298 if (*images == (Image *) NULL)
7299 break;
cristy3ed852e2009-09-05 21:47:34 +00007300 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00007301 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00007302 continue;
cristy042ee782011-04-22 18:48:30 +00007303 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00007304 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00007305 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007306 break;
cristy6b3da3a2010-06-20 02:21:46 +00007307 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007308 switch (*(option+1))
7309 {
7310 case 'a':
7311 {
7312 if (LocaleCompare("affinity",option+1) == 0)
7313 {
cristy6b3da3a2010-06-20 02:21:46 +00007314 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007315 if (*option == '+')
7316 {
cristy018f07f2011-09-04 21:15:19 +00007317 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7318 exception);
cristy3ed852e2009-09-05 21:47:34 +00007319 break;
7320 }
7321 i++;
7322 break;
7323 }
7324 if (LocaleCompare("append",option+1) == 0)
7325 {
7326 Image
7327 *append_image;
7328
cristy6b3da3a2010-06-20 02:21:46 +00007329 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007330 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7331 MagickFalse,exception);
7332 if (append_image == (Image *) NULL)
7333 {
7334 status=MagickFalse;
7335 break;
7336 }
7337 *images=DestroyImageList(*images);
7338 *images=append_image;
7339 break;
7340 }
7341 if (LocaleCompare("average",option+1) == 0)
7342 {
7343 Image
7344 *average_image;
7345
cristyd18ae7c2010-03-07 17:39:52 +00007346 /*
7347 Average an image sequence (deprecated).
7348 */
cristy6b3da3a2010-06-20 02:21:46 +00007349 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007350 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7351 exception);
cristy3ed852e2009-09-05 21:47:34 +00007352 if (average_image == (Image *) NULL)
7353 {
7354 status=MagickFalse;
7355 break;
7356 }
7357 *images=DestroyImageList(*images);
7358 *images=average_image;
7359 break;
7360 }
7361 break;
7362 }
7363 case 'c':
7364 {
7365 if (LocaleCompare("channel",option+1) == 0)
7366 {
cristyf4ad9df2011-07-08 16:49:03 +00007367 ChannelType
7368 channel;
7369
cristy3ed852e2009-09-05 21:47:34 +00007370 if (*option == '+')
7371 {
7372 channel=DefaultChannels;
7373 break;
7374 }
7375 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristyed231572011-07-14 02:18:59 +00007376 SetPixelChannelMap(*images,channel);
cristy3ed852e2009-09-05 21:47:34 +00007377 break;
7378 }
7379 if (LocaleCompare("clut",option+1) == 0)
7380 {
7381 Image
7382 *clut_image,
7383 *image;
7384
cristy6b3da3a2010-06-20 02:21:46 +00007385 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007386 image=RemoveFirstImageFromList(images);
7387 clut_image=RemoveFirstImageFromList(images);
7388 if (clut_image == (Image *) NULL)
7389 {
7390 status=MagickFalse;
7391 break;
7392 }
cristy28474bf2011-09-11 23:32:52 +00007393 (void) ClutImage(image,clut_image,interpolate_method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007394 clut_image=DestroyImage(clut_image);
cristy3ed852e2009-09-05 21:47:34 +00007395 *images=DestroyImageList(*images);
7396 *images=image;
7397 break;
7398 }
7399 if (LocaleCompare("coalesce",option+1) == 0)
7400 {
7401 Image
7402 *coalesce_image;
7403
cristy6b3da3a2010-06-20 02:21:46 +00007404 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007405 coalesce_image=CoalesceImages(*images,exception);
7406 if (coalesce_image == (Image *) NULL)
7407 {
7408 status=MagickFalse;
7409 break;
7410 }
7411 *images=DestroyImageList(*images);
7412 *images=coalesce_image;
7413 break;
7414 }
7415 if (LocaleCompare("combine",option+1) == 0)
7416 {
7417 Image
7418 *combine_image;
7419
cristy6b3da3a2010-06-20 02:21:46 +00007420 (void) SyncImagesSettings(mogrify_info,*images);
cristy3139dc22011-07-08 00:11:42 +00007421 combine_image=CombineImages(*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007422 if (combine_image == (Image *) NULL)
7423 {
7424 status=MagickFalse;
7425 break;
7426 }
7427 *images=DestroyImageList(*images);
7428 *images=combine_image;
7429 break;
7430 }
7431 if (LocaleCompare("composite",option+1) == 0)
7432 {
7433 Image
7434 *mask_image,
7435 *composite_image,
7436 *image;
7437
7438 RectangleInfo
7439 geometry;
7440
cristy6b3da3a2010-06-20 02:21:46 +00007441 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007442 image=RemoveFirstImageFromList(images);
7443 composite_image=RemoveFirstImageFromList(images);
7444 if (composite_image == (Image *) NULL)
7445 {
7446 status=MagickFalse;
7447 break;
7448 }
7449 (void) TransformImage(&composite_image,(char *) NULL,
7450 composite_image->geometry);
7451 SetGeometry(composite_image,&geometry);
7452 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7453 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7454 &geometry);
7455 mask_image=RemoveFirstImageFromList(images);
7456 if (mask_image != (Image *) NULL)
7457 {
7458 if ((image->compose == DisplaceCompositeOp) ||
7459 (image->compose == DistortCompositeOp))
7460 {
7461 /*
7462 Merge Y displacement into X displacement image.
7463 */
7464 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7465 mask_image,0,0);
7466 mask_image=DestroyImage(mask_image);
7467 }
7468 else
7469 {
7470 /*
7471 Set a blending mask for the composition.
cristy28474bf2011-09-11 23:32:52 +00007472 Posible error, what if image->mask already set.
cristy3ed852e2009-09-05 21:47:34 +00007473 */
7474 image->mask=mask_image;
cristyb3e7c6c2011-07-24 01:43:55 +00007475 (void) NegateImage(image->mask,MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007476 }
7477 }
cristyf4ad9df2011-07-08 16:49:03 +00007478 (void) CompositeImage(image,image->compose,composite_image,
7479 geometry.x,geometry.y);
anthonya129f702011-04-14 01:08:48 +00007480 if (mask_image != (Image *) NULL)
7481 mask_image=image->mask=DestroyImage(image->mask);
cristy3ed852e2009-09-05 21:47:34 +00007482 composite_image=DestroyImage(composite_image);
7483 InheritException(exception,&image->exception);
7484 *images=DestroyImageList(*images);
7485 *images=image;
7486 break;
7487 }
cristy3ed852e2009-09-05 21:47:34 +00007488 break;
7489 }
7490 case 'd':
7491 {
7492 if (LocaleCompare("deconstruct",option+1) == 0)
7493 {
7494 Image
7495 *deconstruct_image;
7496
cristy6b3da3a2010-06-20 02:21:46 +00007497 (void) SyncImagesSettings(mogrify_info,*images);
cristy8a9106f2011-07-05 14:39:26 +00007498 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
cristy4c08aed2011-07-01 19:47:50 +00007499 exception);
cristy3ed852e2009-09-05 21:47:34 +00007500 if (deconstruct_image == (Image *) NULL)
7501 {
7502 status=MagickFalse;
7503 break;
7504 }
7505 *images=DestroyImageList(*images);
7506 *images=deconstruct_image;
7507 break;
7508 }
7509 if (LocaleCompare("delete",option+1) == 0)
7510 {
7511 if (*option == '+')
7512 DeleteImages(images,"-1",exception);
7513 else
7514 DeleteImages(images,argv[i+1],exception);
7515 break;
7516 }
7517 if (LocaleCompare("dither",option+1) == 0)
7518 {
7519 if (*option == '+')
7520 {
7521 quantize_info->dither=MagickFalse;
7522 break;
7523 }
7524 quantize_info->dither=MagickTrue;
cristy042ee782011-04-22 18:48:30 +00007525 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007526 MagickDitherOptions,MagickFalse,argv[i+1]);
7527 break;
7528 }
cristyecb10ff2011-03-22 13:14:03 +00007529 if (LocaleCompare("duplicate",option+1) == 0)
7530 {
cristy72988482011-03-29 16:34:38 +00007531 Image
7532 *duplicate_images;
cristybf95deb2011-03-23 00:25:36 +00007533
anthony2b6bcae2011-03-23 13:05:34 +00007534 if (*option == '+')
cristy72988482011-03-29 16:34:38 +00007535 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7536 else
7537 {
7538 const char
7539 *p;
7540
anthony2b6bcae2011-03-23 13:05:34 +00007541 size_t
7542 number_duplicates;
anthony9bd15492011-03-23 02:11:13 +00007543
anthony2b6bcae2011-03-23 13:05:34 +00007544 number_duplicates=(size_t) StringToLong(argv[i+1]);
cristy72988482011-03-29 16:34:38 +00007545 p=strchr(argv[i+1],',');
7546 if (p == (const char *) NULL)
7547 duplicate_images=DuplicateImages(*images,number_duplicates,
7548 "-1",exception);
anthony2b6bcae2011-03-23 13:05:34 +00007549 else
cristy72988482011-03-29 16:34:38 +00007550 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7551 exception);
anthony2b6bcae2011-03-23 13:05:34 +00007552 }
7553 AppendImageToList(images, duplicate_images);
7554 (void) SyncImagesSettings(mogrify_info,*images);
cristyecb10ff2011-03-22 13:14:03 +00007555 break;
7556 }
cristy3ed852e2009-09-05 21:47:34 +00007557 break;
7558 }
cristyd18ae7c2010-03-07 17:39:52 +00007559 case 'e':
7560 {
7561 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7562 {
7563 Image
7564 *evaluate_image;
7565
7566 MagickEvaluateOperator
7567 op;
7568
cristy6b3da3a2010-06-20 02:21:46 +00007569 (void) SyncImageSettings(mogrify_info,*images);
cristy28474bf2011-09-11 23:32:52 +00007570 op=(MagickEvaluateOperator) ParseCommandOption(
7571 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristyd18ae7c2010-03-07 17:39:52 +00007572 evaluate_image=EvaluateImages(*images,op,exception);
7573 if (evaluate_image == (Image *) NULL)
7574 {
7575 status=MagickFalse;
7576 break;
7577 }
7578 *images=DestroyImageList(*images);
7579 *images=evaluate_image;
7580 break;
7581 }
7582 break;
7583 }
cristy3ed852e2009-09-05 21:47:34 +00007584 case 'f':
7585 {
cristyf0a247f2009-10-04 00:20:03 +00007586 if (LocaleCompare("fft",option+1) == 0)
7587 {
7588 Image
7589 *fourier_image;
7590
7591 /*
7592 Implements the discrete Fourier transform (DFT).
7593 */
cristy6b3da3a2010-06-20 02:21:46 +00007594 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00007595 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7596 MagickTrue : MagickFalse,exception);
7597 if (fourier_image == (Image *) NULL)
7598 break;
7599 *images=DestroyImage(*images);
7600 *images=fourier_image;
7601 break;
7602 }
cristy3ed852e2009-09-05 21:47:34 +00007603 if (LocaleCompare("flatten",option+1) == 0)
7604 {
7605 Image
7606 *flatten_image;
7607
cristy6b3da3a2010-06-20 02:21:46 +00007608 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007609 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7610 if (flatten_image == (Image *) NULL)
7611 break;
7612 *images=DestroyImageList(*images);
7613 *images=flatten_image;
7614 break;
7615 }
7616 if (LocaleCompare("fx",option+1) == 0)
7617 {
7618 Image
7619 *fx_image;
7620
cristy6b3da3a2010-06-20 02:21:46 +00007621 (void) SyncImagesSettings(mogrify_info,*images);
cristy490408a2011-07-07 14:42:05 +00007622 fx_image=FxImage(*images,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00007623 if (fx_image == (Image *) NULL)
7624 {
7625 status=MagickFalse;
7626 break;
7627 }
7628 *images=DestroyImageList(*images);
7629 *images=fx_image;
7630 break;
7631 }
7632 break;
7633 }
7634 case 'h':
7635 {
7636 if (LocaleCompare("hald-clut",option+1) == 0)
7637 {
7638 Image
7639 *hald_image,
7640 *image;
7641
cristy6b3da3a2010-06-20 02:21:46 +00007642 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007643 image=RemoveFirstImageFromList(images);
7644 hald_image=RemoveFirstImageFromList(images);
7645 if (hald_image == (Image *) NULL)
7646 {
7647 status=MagickFalse;
7648 break;
7649 }
cristy7c0a0a42011-08-23 17:57:25 +00007650 (void) HaldClutImage(image,hald_image,exception);
cristy3ed852e2009-09-05 21:47:34 +00007651 hald_image=DestroyImage(hald_image);
cristy0aff6ea2009-11-14 01:40:53 +00007652 if (*images != (Image *) NULL)
7653 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00007654 *images=image;
7655 break;
7656 }
7657 break;
7658 }
7659 case 'i':
7660 {
7661 if (LocaleCompare("ift",option+1) == 0)
7662 {
7663 Image
cristy8587f882009-11-13 20:28:49 +00007664 *fourier_image,
7665 *magnitude_image,
7666 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00007667
7668 /*
7669 Implements the inverse fourier discrete Fourier transform (DFT).
7670 */
cristy6b3da3a2010-06-20 02:21:46 +00007671 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00007672 magnitude_image=RemoveFirstImageFromList(images);
7673 phase_image=RemoveFirstImageFromList(images);
7674 if (phase_image == (Image *) NULL)
7675 {
7676 status=MagickFalse;
7677 break;
7678 }
7679 fourier_image=InverseFourierTransformImage(magnitude_image,
7680 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007681 if (fourier_image == (Image *) NULL)
7682 break;
cristy0aff6ea2009-11-14 01:40:53 +00007683 if (*images != (Image *) NULL)
7684 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00007685 *images=fourier_image;
7686 break;
7687 }
7688 if (LocaleCompare("insert",option+1) == 0)
7689 {
7690 Image
7691 *p,
7692 *q;
7693
7694 index=0;
7695 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00007696 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007697 p=RemoveLastImageFromList(images);
7698 if (p == (Image *) NULL)
7699 {
7700 (void) ThrowMagickException(exception,GetMagickModule(),
7701 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7702 status=MagickFalse;
7703 break;
7704 }
7705 q=p;
7706 if (index == 0)
7707 PrependImageToList(images,q);
7708 else
cristybb503372010-05-27 20:51:26 +00007709 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00007710 AppendImageToList(images,q);
7711 else
7712 {
7713 q=GetImageFromList(*images,index-1);
7714 if (q == (Image *) NULL)
7715 {
7716 (void) ThrowMagickException(exception,GetMagickModule(),
7717 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7718 status=MagickFalse;
7719 break;
7720 }
7721 InsertImageInList(&q,p);
7722 }
7723 *images=GetFirstImageInList(q);
7724 break;
7725 }
cristy28474bf2011-09-11 23:32:52 +00007726 if (LocaleCompare("interpolate",option+1) == 0)
7727 {
7728 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7729 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7730 break;
7731 }
cristy3ed852e2009-09-05 21:47:34 +00007732 break;
7733 }
7734 case 'l':
7735 {
7736 if (LocaleCompare("layers",option+1) == 0)
7737 {
7738 Image
7739 *layers;
7740
7741 ImageLayerMethod
7742 method;
7743
cristy6b3da3a2010-06-20 02:21:46 +00007744 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007745 layers=(Image *) NULL;
cristy042ee782011-04-22 18:48:30 +00007746 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
cristy3ed852e2009-09-05 21:47:34 +00007747 MagickFalse,argv[i+1]);
7748 switch (method)
7749 {
7750 case CoalesceLayer:
7751 {
7752 layers=CoalesceImages(*images,exception);
7753 break;
7754 }
7755 case CompareAnyLayer:
7756 case CompareClearLayer:
7757 case CompareOverlayLayer:
7758 default:
7759 {
cristy8a9106f2011-07-05 14:39:26 +00007760 layers=CompareImagesLayers(*images,method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007761 break;
7762 }
7763 case MergeLayer:
7764 case FlattenLayer:
7765 case MosaicLayer:
7766 case TrimBoundsLayer:
7767 {
7768 layers=MergeImageLayers(*images,method,exception);
7769 break;
7770 }
7771 case DisposeLayer:
7772 {
7773 layers=DisposeImages(*images,exception);
7774 break;
7775 }
7776 case OptimizeImageLayer:
7777 {
7778 layers=OptimizeImageLayers(*images,exception);
7779 break;
7780 }
7781 case OptimizePlusLayer:
7782 {
7783 layers=OptimizePlusImageLayers(*images,exception);
7784 break;
7785 }
7786 case OptimizeTransLayer:
7787 {
7788 OptimizeImageTransparency(*images,exception);
7789 break;
7790 }
7791 case RemoveDupsLayer:
7792 {
7793 RemoveDuplicateLayers(images,exception);
7794 break;
7795 }
7796 case RemoveZeroLayer:
7797 {
7798 RemoveZeroDelayLayers(images,exception);
7799 break;
7800 }
7801 case OptimizeLayer:
7802 {
7803 /*
7804 General Purpose, GIF Animation Optimizer.
7805 */
7806 layers=CoalesceImages(*images,exception);
7807 if (layers == (Image *) NULL)
7808 {
7809 status=MagickFalse;
7810 break;
7811 }
cristy3ed852e2009-09-05 21:47:34 +00007812 *images=DestroyImageList(*images);
7813 *images=layers;
7814 layers=OptimizeImageLayers(*images,exception);
7815 if (layers == (Image *) NULL)
7816 {
7817 status=MagickFalse;
7818 break;
7819 }
cristy3ed852e2009-09-05 21:47:34 +00007820 *images=DestroyImageList(*images);
7821 *images=layers;
7822 layers=(Image *) NULL;
7823 OptimizeImageTransparency(*images,exception);
cristy018f07f2011-09-04 21:15:19 +00007824 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7825 exception);
cristy3ed852e2009-09-05 21:47:34 +00007826 break;
7827 }
7828 case CompositeLayer:
7829 {
7830 CompositeOperator
7831 compose;
7832
7833 Image
7834 *source;
7835
7836 RectangleInfo
7837 geometry;
7838
7839 /*
7840 Split image sequence at the first 'NULL:' image.
7841 */
7842 source=(*images);
7843 while (source != (Image *) NULL)
7844 {
7845 source=GetNextImageInList(source);
7846 if ((source != (Image *) NULL) &&
7847 (LocaleCompare(source->magick,"NULL") == 0))
7848 break;
7849 }
7850 if (source != (Image *) NULL)
7851 {
7852 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7853 (GetNextImageInList(source) == (Image *) NULL))
7854 source=(Image *) NULL;
7855 else
7856 {
7857 /*
7858 Separate the two lists, junk the null: image.
7859 */
7860 source=SplitImageList(source->previous);
7861 DeleteImageFromList(&source);
7862 }
7863 }
7864 if (source == (Image *) NULL)
7865 {
7866 (void) ThrowMagickException(exception,GetMagickModule(),
7867 OptionError,"MissingNullSeparator","layers Composite");
7868 status=MagickFalse;
7869 break;
7870 }
7871 /*
7872 Adjust offset with gravity and virtual canvas.
7873 */
7874 SetGeometry(*images,&geometry);
7875 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7876 geometry.width=source->page.width != 0 ?
7877 source->page.width : source->columns;
7878 geometry.height=source->page.height != 0 ?
7879 source->page.height : source->rows;
7880 GravityAdjustGeometry((*images)->page.width != 0 ?
7881 (*images)->page.width : (*images)->columns,
7882 (*images)->page.height != 0 ? (*images)->page.height :
7883 (*images)->rows,(*images)->gravity,&geometry);
7884 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00007885 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00007886 if (option != (const char *) NULL)
cristy042ee782011-04-22 18:48:30 +00007887 compose=(CompositeOperator) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007888 MagickComposeOptions,MagickFalse,option);
7889 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7890 exception);
7891 source=DestroyImageList(source);
7892 break;
7893 }
7894 }
7895 if (layers == (Image *) NULL)
7896 break;
7897 InheritException(exception,&layers->exception);
7898 *images=DestroyImageList(*images);
7899 *images=layers;
7900 break;
7901 }
7902 break;
7903 }
7904 case 'm':
7905 {
7906 if (LocaleCompare("map",option+1) == 0)
7907 {
cristy6b3da3a2010-06-20 02:21:46 +00007908 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007909 if (*option == '+')
7910 {
cristy018f07f2011-09-04 21:15:19 +00007911 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7912 exception);
cristy3ed852e2009-09-05 21:47:34 +00007913 break;
7914 }
7915 i++;
7916 break;
7917 }
cristyf40785b2010-03-06 02:27:27 +00007918 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007919 {
7920 Image
cristyf40785b2010-03-06 02:27:27 +00007921 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007922
cristyd18ae7c2010-03-07 17:39:52 +00007923 /*
7924 Maximum image sequence (deprecated).
7925 */
cristy6b3da3a2010-06-20 02:21:46 +00007926 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007927 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007928 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007929 {
7930 status=MagickFalse;
7931 break;
7932 }
7933 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007934 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007935 break;
7936 }
cristyf40785b2010-03-06 02:27:27 +00007937 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007938 {
7939 Image
cristyf40785b2010-03-06 02:27:27 +00007940 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007941
cristyd18ae7c2010-03-07 17:39:52 +00007942 /*
7943 Minimum image sequence (deprecated).
7944 */
cristy6b3da3a2010-06-20 02:21:46 +00007945 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007946 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007947 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007948 {
7949 status=MagickFalse;
7950 break;
7951 }
7952 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007953 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007954 break;
7955 }
cristy3ed852e2009-09-05 21:47:34 +00007956 if (LocaleCompare("morph",option+1) == 0)
7957 {
7958 Image
7959 *morph_image;
7960
cristy6b3da3a2010-06-20 02:21:46 +00007961 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00007962 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00007963 exception);
7964 if (morph_image == (Image *) NULL)
7965 {
7966 status=MagickFalse;
7967 break;
7968 }
7969 *images=DestroyImageList(*images);
7970 *images=morph_image;
7971 break;
7972 }
7973 if (LocaleCompare("mosaic",option+1) == 0)
7974 {
7975 Image
7976 *mosaic_image;
7977
cristy6b3da3a2010-06-20 02:21:46 +00007978 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007979 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7980 if (mosaic_image == (Image *) NULL)
7981 {
7982 status=MagickFalse;
7983 break;
7984 }
7985 *images=DestroyImageList(*images);
7986 *images=mosaic_image;
7987 break;
7988 }
7989 break;
7990 }
7991 case 'p':
7992 {
7993 if (LocaleCompare("print",option+1) == 0)
7994 {
7995 char
7996 *string;
7997
cristy6b3da3a2010-06-20 02:21:46 +00007998 (void) SyncImagesSettings(mogrify_info,*images);
cristy018f07f2011-09-04 21:15:19 +00007999 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8000 exception);
cristy3ed852e2009-09-05 21:47:34 +00008001 if (string == (char *) NULL)
8002 break;
cristyb51dff52011-05-19 16:55:47 +00008003 (void) FormatLocaleFile(stdout,"%s",string);
cristy3ed852e2009-09-05 21:47:34 +00008004 string=DestroyString(string);
8005 }
8006 if (LocaleCompare("process",option+1) == 0)
8007 {
8008 char
8009 **arguments;
8010
8011 int
8012 j,
8013 number_arguments;
8014
cristy6b3da3a2010-06-20 02:21:46 +00008015 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008016 arguments=StringToArgv(argv[i+1],&number_arguments);
8017 if (arguments == (char **) NULL)
8018 break;
8019 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8020 {
8021 char
8022 breaker,
8023 quote,
8024 *token;
8025
8026 const char
8027 *arguments;
8028
8029 int
8030 next,
8031 status;
8032
8033 size_t
8034 length;
8035
8036 TokenInfo
8037 *token_info;
8038
8039 /*
8040 Support old style syntax, filter="-option arg".
8041 */
8042 length=strlen(argv[i+1]);
8043 token=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +00008044 if (~length >= (MaxTextExtent-1))
cristy3ed852e2009-09-05 21:47:34 +00008045 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8046 sizeof(*token));
8047 if (token == (char *) NULL)
8048 break;
8049 next=0;
8050 arguments=argv[i+1];
8051 token_info=AcquireTokenInfo();
8052 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8053 "\"",'\0',&breaker,&next,&quote);
8054 token_info=DestroyTokenInfo(token_info);
8055 if (status == 0)
8056 {
8057 const char
8058 *argv;
8059
8060 argv=(&(arguments[next]));
8061 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8062 exception);
8063 }
8064 token=DestroyString(token);
8065 break;
8066 }
cristy91c0da22010-05-02 01:44:07 +00008067 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008068 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8069 number_arguments-2,(const char **) arguments+2,exception);
8070 for (j=0; j < number_arguments; j++)
8071 arguments[j]=DestroyString(arguments[j]);
8072 arguments=(char **) RelinquishMagickMemory(arguments);
8073 break;
8074 }
8075 break;
8076 }
8077 case 'r':
8078 {
8079 if (LocaleCompare("reverse",option+1) == 0)
8080 {
8081 ReverseImageList(images);
8082 InheritException(exception,&(*images)->exception);
8083 break;
8084 }
8085 break;
8086 }
8087 case 's':
8088 {
cristy4285d782011-02-09 20:12:28 +00008089 if (LocaleCompare("smush",option+1) == 0)
8090 {
8091 Image
8092 *smush_image;
8093
8094 ssize_t
8095 offset;
8096
8097 (void) SyncImagesSettings(mogrify_info,*images);
8098 offset=(ssize_t) StringToLong(argv[i+1]);
8099 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8100 MagickFalse,offset,exception);
8101 if (smush_image == (Image *) NULL)
8102 {
8103 status=MagickFalse;
8104 break;
8105 }
8106 *images=DestroyImageList(*images);
8107 *images=smush_image;
8108 break;
8109 }
cristy3ed852e2009-09-05 21:47:34 +00008110 if (LocaleCompare("swap",option+1) == 0)
8111 {
8112 Image
8113 *p,
8114 *q,
8115 *swap;
8116
cristybb503372010-05-27 20:51:26 +00008117 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008118 swap_index;
8119
8120 index=(-1);
8121 swap_index=(-2);
8122 if (*option != '+')
8123 {
8124 GeometryInfo
8125 geometry_info;
8126
8127 MagickStatusType
8128 flags;
8129
8130 swap_index=(-1);
8131 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008132 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008133 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008134 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008135 }
8136 p=GetImageFromList(*images,index);
8137 q=GetImageFromList(*images,swap_index);
8138 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8139 {
8140 (void) ThrowMagickException(exception,GetMagickModule(),
8141 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8142 status=MagickFalse;
8143 break;
8144 }
8145 if (p == q)
8146 break;
8147 swap=CloneImage(p,0,0,MagickTrue,exception);
8148 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8149 ReplaceImageInList(&q,swap);
8150 *images=GetFirstImageInList(q);
8151 break;
8152 }
8153 break;
8154 }
8155 case 'w':
8156 {
8157 if (LocaleCompare("write",option+1) == 0)
8158 {
cristy071dd7b2010-04-09 13:04:54 +00008159 char
cristy06609ee2010-03-17 20:21:27 +00008160 key[MaxTextExtent];
8161
cristy3ed852e2009-09-05 21:47:34 +00008162 Image
8163 *write_images;
8164
8165 ImageInfo
8166 *write_info;
8167
cristy6b3da3a2010-06-20 02:21:46 +00008168 (void) SyncImagesSettings(mogrify_info,*images);
cristyb51dff52011-05-19 16:55:47 +00008169 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
cristy06609ee2010-03-17 20:21:27 +00008170 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008171 write_images=(*images);
8172 if (*option == '+')
8173 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008174 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008175 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8176 write_info=DestroyImageInfo(write_info);
8177 if (*option == '+')
8178 write_images=DestroyImageList(write_images);
8179 break;
8180 }
8181 break;
8182 }
8183 default:
8184 break;
8185 }
8186 i+=count;
8187 }
8188 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008189 mogrify_info=DestroyImageInfo(mogrify_info);
8190 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008191 return(status != 0 ? MagickTrue : MagickFalse);
8192}
8193
8194/*
8195%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8196% %
8197% %
8198% %
8199+ M o g r i f y I m a g e s %
8200% %
8201% %
8202% %
8203%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8204%
8205% MogrifyImages() applies image processing options to a sequence of images as
8206% prescribed by command line options.
8207%
8208% The format of the MogrifyImage method is:
8209%
8210% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8211% const MagickBooleanType post,const int argc,const char **argv,
8212% Image **images,Exceptioninfo *exception)
8213%
8214% A description of each parameter follows:
8215%
8216% o image_info: the image info..
8217%
8218% o post: If true, post process image list operators otherwise pre-process.
8219%
8220% o argc: Specifies a pointer to an integer describing the number of
8221% elements in the argument vector.
8222%
8223% o argv: Specifies a pointer to a text array containing the command line
8224% arguments.
8225%
anthonye9c27192011-03-27 08:07:06 +00008226% o images: pointer to a pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00008227%
8228% o exception: return any errors or warnings in this structure.
8229%
8230*/
8231WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8232 const MagickBooleanType post,const int argc,const char **argv,
8233 Image **images,ExceptionInfo *exception)
8234{
8235#define MogrifyImageTag "Mogrify/Image"
8236
anthonye9c27192011-03-27 08:07:06 +00008237 MagickStatusType
8238 status;
cristy3ed852e2009-09-05 21:47:34 +00008239
cristy0e9f9c12010-02-11 03:00:47 +00008240 MagickBooleanType
8241 proceed;
8242
anthonye9c27192011-03-27 08:07:06 +00008243 size_t
8244 n;
cristy3ed852e2009-09-05 21:47:34 +00008245
cristybb503372010-05-27 20:51:26 +00008246 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008247 i;
8248
cristy3ed852e2009-09-05 21:47:34 +00008249 assert(image_info != (ImageInfo *) NULL);
8250 assert(image_info->signature == MagickSignature);
8251 if (images == (Image **) NULL)
8252 return(MogrifyImage(image_info,argc,argv,images,exception));
anthonye9c27192011-03-27 08:07:06 +00008253 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008254 assert((*images)->signature == MagickSignature);
8255 if ((*images)->debug != MagickFalse)
8256 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8257 (*images)->filename);
8258 if ((argc <= 0) || (*argv == (char *) NULL))
8259 return(MagickTrue);
8260 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8261 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008262 status=0;
anthonye9c27192011-03-27 08:07:06 +00008263
anthonyce2716b2011-04-22 09:51:34 +00008264#if 0
cristy1e604812011-05-19 18:07:50 +00008265 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8266 post?"post":"pre");
anthonyce2716b2011-04-22 09:51:34 +00008267#endif
8268
anthonye9c27192011-03-27 08:07:06 +00008269 /*
8270 Pre-process multi-image sequence operators
8271 */
cristy3ed852e2009-09-05 21:47:34 +00008272 if (post == MagickFalse)
8273 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthonye9c27192011-03-27 08:07:06 +00008274 /*
8275 For each image, process simple single image operators
8276 */
8277 i=0;
8278 n=GetImageListLength(*images);
cristy9f027d12011-09-21 01:17:17 +00008279 for ( ; ; )
cristy3ed852e2009-09-05 21:47:34 +00008280 {
anthonyce2716b2011-04-22 09:51:34 +00008281#if 0
cristy1e604812011-05-19 18:07:50 +00008282 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8283 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008284#endif
anthonye9c27192011-03-27 08:07:06 +00008285 status&=MogrifyImage(image_info,argc,argv,images,exception);
8286 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
cristy0e9f9c12010-02-11 03:00:47 +00008287 if (proceed == MagickFalse)
8288 break;
anthonye9c27192011-03-27 08:07:06 +00008289 if ( (*images)->next == (Image *) NULL )
8290 break;
8291 *images=(*images)->next;
8292 i++;
cristy3ed852e2009-09-05 21:47:34 +00008293 }
anthonye9c27192011-03-27 08:07:06 +00008294 assert( *images != (Image *) NULL );
anthonyce2716b2011-04-22 09:51:34 +00008295#if 0
cristy1e604812011-05-19 18:07:50 +00008296 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8297 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008298#endif
anthonye9c27192011-03-27 08:07:06 +00008299
8300 /*
8301 Post-process, multi-image sequence operators
8302 */
8303 *images=GetFirstImageInList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008304 if (post != MagickFalse)
anthonye9c27192011-03-27 08:07:06 +00008305 status&=MogrifyImageList(image_info,argc,argv,images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008306 return(status != 0 ? MagickTrue : MagickFalse);
8307}