blob: c6c41f90fab3bd4498d695c06815efc88675cf5d [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% M M OOO GGGGG RRRR IIIII FFFFF Y Y %
7% MM MM O O G R R I F Y Y %
8% M M M O O G GGG RRRR I FFF Y %
9% M M O O G G R R I F Y %
10% M M OOO GGGG R R IIIII F Y %
11% %
12% %
13% MagickWand Module Methods %
14% %
15% Software Design %
16% John Cristy %
17% March 2000 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36% Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37% draw on, flip, join, re-sample, and much more. This tool is similiar to
38% convert except that the original image file is overwritten (unless you
39% change the file suffix with the -format option) with any changes you
cristy6a917d92009-10-06 19:23:54 +000040% request.
cristy3ed852e2009-09-05 21:47:34 +000041%
42*/
43
44/*
45 Include declarations.
46*/
cristy4c08aed2011-07-01 19:47:50 +000047#include "MagickWand/studio.h"
48#include "MagickWand/MagickWand.h"
49#include "MagickWand/mogrify-private.h"
50#undef DegreesToRadians
51#undef RadiansToDegrees
52#include "MagickCore/image-private.h"
53#include "MagickCore/monitor-private.h"
cristy4c08aed2011-07-01 19:47:50 +000054#include "MagickCore/string-private.h"
cristy0740a982011-10-13 15:01:01 +000055#include "MagickCore/thread-private.h"
cristy18c6c272011-09-23 14:40:37 +000056#include "MagickCore/utility-private.h"
cristy3ed852e2009-09-05 21:47:34 +000057
58/*
cristy154fa9d2011-08-05 14:25:15 +000059 Constant declaration.
60*/
cristy3a557c02011-08-06 19:48:02 +000061static const char
cristy638895a2011-08-06 23:19:14 +000062 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
cristy154fa9d2011-08-05 14:25:15 +000065
66/*
cristy3ed852e2009-09-05 21:47:34 +000067 Define declarations.
68*/
69#define UndefinedCompressionQuality 0UL
70
71/*
cristy3ed852e2009-09-05 21:47:34 +000072%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73% %
74% %
75% %
cristy5063d812010-10-19 16:28:10 +000076% M a g i c k C o m m a n d G e n e s i s %
cristy3980b0d2009-10-25 14:37:13 +000077% %
78% %
79% %
80%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81%
82% MagickCommandGenesis() applies image processing options to an image as
83% prescribed by command line options.
84%
85% The format of the MagickCommandGenesis method is:
86%
87% MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
cristy5063d812010-10-19 16:28:10 +000088% MagickCommand command,int argc,char **argv,char **metadata,
89% ExceptionInfo *exception)
cristy3980b0d2009-10-25 14:37:13 +000090%
91% A description of each parameter follows:
92%
93% o image_info: the image info.
94%
cristy5063d812010-10-19 16:28:10 +000095% o command: Choose from ConvertImageCommand, IdentifyImageCommand,
cristy8a9106f2011-07-05 14:39:26 +000096% MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
cristy5063d812010-10-19 16:28:10 +000097% ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98% DisplayImageCommand, or AnimateImageCommand.
cristy3980b0d2009-10-25 14:37:13 +000099%
100% o argc: Specifies a pointer to an integer describing the number of
101% elements in the argument vector.
102%
103% o argv: Specifies a pointer to a text array containing the command line
104% arguments.
105%
cristy5063d812010-10-19 16:28:10 +0000106% o metadata: any metadata is returned here.
cristy3980b0d2009-10-25 14:37:13 +0000107%
108% o exception: return any errors or warnings in this structure.
109%
110*/
cristyc2e3aeb2011-12-09 11:09:38 +0000111
112static inline double MagickMin(const double x,const double y)
113{
114 if (x < y)
115 return(x);
116 return(y);
117}
118
cristy3980b0d2009-10-25 14:37:13 +0000119WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
120 MagickCommand command,int argc,char **argv,char **metadata,
121 ExceptionInfo *exception)
122{
123 char
124 *option;
125
126 double
127 duration,
cristy8ea926d2011-12-09 12:25:04 +0000128 serial;
cristy3980b0d2009-10-25 14:37:13 +0000129
cristy3980b0d2009-10-25 14:37:13 +0000130 MagickBooleanType
131 concurrent,
132 regard_warnings,
133 status;
134
cristybb503372010-05-27 20:51:26 +0000135 register ssize_t
cristy3980b0d2009-10-25 14:37:13 +0000136 i;
137
cristybb503372010-05-27 20:51:26 +0000138 size_t
cristyc2e3aeb2011-12-09 11:09:38 +0000139 iterations,
140 n,
141 number_threads;
cristy3980b0d2009-10-25 14:37:13 +0000142
cristyd0a94fa2010-03-12 14:18:11 +0000143 (void) setlocale(LC_ALL,"");
144 (void) setlocale(LC_NUMERIC,"C");
cristy3980b0d2009-10-25 14:37:13 +0000145 concurrent=MagickFalse;
146 duration=(-1.0);
147 iterations=1;
cristy33557d72009-11-06 00:54:33 +0000148 status=MagickFalse;
cristy3980b0d2009-10-25 14:37:13 +0000149 regard_warnings=MagickFalse;
cristybb503372010-05-27 20:51:26 +0000150 for (i=1; i < (ssize_t) (argc-1); i++)
cristy3980b0d2009-10-25 14:37:13 +0000151 {
152 option=argv[i];
153 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
154 continue;
155 if (LocaleCompare("bench",option+1) == 0)
cristye27293e2009-12-18 02:53:20 +0000156 iterations=StringToUnsignedLong(argv[++i]);
cristy3980b0d2009-10-25 14:37:13 +0000157 if (LocaleCompare("concurrent",option+1) == 0)
158 concurrent=MagickTrue;
159 if (LocaleCompare("debug",option+1) == 0)
160 (void) SetLogEventMask(argv[++i]);
161 if (LocaleCompare("duration",option+1) == 0)
cristydbdd0e32011-11-04 23:29:40 +0000162 duration=StringToDouble(argv[++i],(char **) NULL);
cristy3980b0d2009-10-25 14:37:13 +0000163 if (LocaleCompare("regard-warnings",option+1) == 0)
164 regard_warnings=MagickTrue;
165 }
cristy8ea926d2011-12-09 12:25:04 +0000166 if (iterations == 1)
167 {
168 status=command(image_info,argc,argv,metadata,exception);
169 if (exception->severity != UndefinedException)
170 {
171 if ((exception->severity > ErrorException) ||
172 (regard_warnings != MagickFalse))
173 status=MagickTrue;
174 CatchException(exception);
175 }
176 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
177 {
178 (void) fputs(*metadata,stdout);
179 (void) fputc('\n',stdout);
180 *metadata=DestroyString(*metadata);
181 }
182 return(status);
183 }
cristyc2e3aeb2011-12-09 11:09:38 +0000184 number_threads=GetOpenMPMaximumThreads();
cristy8ea926d2011-12-09 12:25:04 +0000185 serial=0.0;
cristyc2e3aeb2011-12-09 11:09:38 +0000186 for (n=1; n <= number_threads; n++)
187 {
188 double
cristy8ea926d2011-12-09 12:25:04 +0000189 e,
190 parallel,
cristyc2e3aeb2011-12-09 11:09:38 +0000191 user_time;
192
193 TimerInfo
194 *timer;
195
196 SetOpenMPMaximumThreads(n);
197 timer=AcquireTimerInfo();
198 if (concurrent == MagickFalse)
cristy3980b0d2009-10-25 14:37:13 +0000199 {
cristyc2e3aeb2011-12-09 11:09:38 +0000200 for (i=0; i < (ssize_t) iterations; i++)
cristyceae09d2009-10-28 17:18:47 +0000201 {
cristyc2e3aeb2011-12-09 11:09:38 +0000202 if (status != MagickFalse)
203 continue;
204 if (duration > 0)
205 {
206 if (GetElapsedTime(timer) > duration)
207 continue;
208 (void) ContinueTimer(timer);
209 }
210 status=command(image_info,argc,argv,metadata,exception);
cristyceae09d2009-10-28 17:18:47 +0000211 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 }
cristyc2e3aeb2011-12-09 11:09:38 +0000226 else
227 {
228 SetOpenMPNested(1);
229#if defined(MAGICKCORE_OPENMP_SUPPORT)
230 # pragma omp parallel for shared(status)
231#endif
232 for (i=0; i < (ssize_t) iterations; i++)
233 {
234 if (status != MagickFalse)
235 continue;
236 if (duration > 0)
237 {
238 if (GetElapsedTime(timer) > duration)
239 continue;
240 (void) ContinueTimer(timer);
241 }
242 status=command(image_info,argc,argv,metadata,exception);
243#if defined(MAGICKCORE_OPENMP_SUPPORT)
244 # pragma omp critical (MagickCore_CommandGenesis)
245#endif
246 {
247 if (exception->severity != UndefinedException)
248 {
249 if ((exception->severity > ErrorException) ||
250 (regard_warnings != MagickFalse))
251 status=MagickTrue;
252 CatchException(exception);
253 }
254 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
255 {
256 (void) fputs(*metadata,stdout);
257 (void) fputc('\n',stdout);
258 *metadata=DestroyString(*metadata);
259 }
260 }
261 }
262 }
cristyc2e3aeb2011-12-09 11:09:38 +0000263 user_time=GetUserTime(timer);
cristy8ea926d2011-12-09 12:25:04 +0000264 parallel=GetElapsedTime(timer);
265 e=1.0;
266 if (n == 1)
267 serial=parallel;
268 else
269 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
270 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
cristyc2e3aeb2011-12-09 11:09:38 +0000271 (void) FormatLocaleFile(stderr,
272 "Performance[%.20g]: %.20gi %gips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
cristy8ea926d2011-12-09 12:25:04 +0000273 (double) n,(double) iterations,(double) iterations/parallel,e,
274 user_time,(unsigned long) (parallel/60.0),(unsigned long)
275 floor(fmod(parallel,60.0)),(unsigned long)
276 (1000.0*(parallel-floor(parallel))+0.5));
cristyc2e3aeb2011-12-09 11:09:38 +0000277 timer=DestroyTimerInfo(timer);
278 }
cristy1f9e1ed2009-11-18 04:09:38 +0000279 return(status);
cristy3980b0d2009-10-25 14:37:13 +0000280}
281
282/*
283%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284% %
285% %
286% %
cristy3ed852e2009-09-05 21:47:34 +0000287+ M o g r i f y I m a g e %
288% %
289% %
290% %
291%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
292%
anthonye9c27192011-03-27 08:07:06 +0000293% MogrifyImage() applies simple single image processing options to a single
anthonydf8ebac2011-04-27 09:03:19 +0000294% image that may be part of a large list, but also handles any 'region'
295% image handling.
anthonye9c27192011-03-27 08:07:06 +0000296%
297% The image in the list may be modified in three different ways...
298%
299% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
300% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
301% * replace by a list of images (only the -separate option!)
302%
303% In each case the result is returned into the list, and a pointer to the
304% modified image (last image added if replaced by a list of images) is
305% returned.
306%
307% ASIDE: The -crop is present but restricted to non-tile single image crops
308%
309% This means if all the images are being processed (such as by
310% MogrifyImages(), next image to be processed will be as per the pointer
311% (*image)->next. Also the image list may grow as a result of some specific
312% operations but as images are never merged or deleted, it will never shrink
313% in length. Typically the list will remain the same length.
314%
315% WARNING: As the image pointed to may be replaced, the first image in the
316% list may also change. GetFirstImageInList() should be used by caller if
317% they wish return the Image pointer to the first image in list.
318%
cristy3ed852e2009-09-05 21:47:34 +0000319%
320% The format of the MogrifyImage method is:
321%
322% MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
323% const char **argv,Image **image)
324%
325% A description of each parameter follows:
326%
327% o image_info: the image info..
328%
329% o argc: Specifies a pointer to an integer describing the number of
330% elements in the argument vector.
331%
332% o argv: Specifies a pointer to a text array containing the command line
333% arguments.
334%
335% o image: the image.
336%
337% o exception: return any errors or warnings in this structure.
338%
339*/
340
anthonydf8ebac2011-04-27 09:03:19 +0000341static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
342 ExceptionInfo *exception)
343{
344 char
345 key[MaxTextExtent];
346
347 ExceptionInfo
348 *sans_exception;
349
350 Image
351 *image;
352
353 ImageInfo
354 *read_info;
355
cristyfcd785b2011-11-08 01:48:33 +0000356 /*
357 Read an image into a image cache if not already present. Return the image
358 that is in the cache under that filename.
359 */
cristyb51dff52011-05-19 16:55:47 +0000360 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
anthonydf8ebac2011-04-27 09:03:19 +0000361 sans_exception=AcquireExceptionInfo();
362 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
363 sans_exception=DestroyExceptionInfo(sans_exception);
364 if (image != (Image *) NULL)
365 return(image);
366 read_info=CloneImageInfo(image_info);
367 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
368 image=ReadImage(read_info,exception);
369 read_info=DestroyImageInfo(read_info);
370 if (image != (Image *) NULL)
371 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
372 return(image);
373}
374
cristy3ed852e2009-09-05 21:47:34 +0000375static MagickBooleanType IsPathWritable(const char *path)
376{
377 if (IsPathAccessible(path) == MagickFalse)
378 return(MagickFalse);
cristy18c6c272011-09-23 14:40:37 +0000379 if (access_utf8(path,W_OK) != 0)
cristy3ed852e2009-09-05 21:47:34 +0000380 return(MagickFalse);
381 return(MagickTrue);
382}
383
cristybb503372010-05-27 20:51:26 +0000384static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
cristy3ed852e2009-09-05 21:47:34 +0000385{
386 if (x > y)
387 return(x);
388 return(y);
389}
390
anthonydf8ebac2011-04-27 09:03:19 +0000391static MagickBooleanType MonitorProgress(const char *text,
392 const MagickOffsetType offset,const MagickSizeType extent,
393 void *wand_unused(client_data))
394{
395 char
396 message[MaxTextExtent],
397 tag[MaxTextExtent];
398
399 const char
400 *locale_message;
401
402 register char
403 *p;
404
405 if (extent < 2)
406 return(MagickTrue);
407 (void) CopyMagickMemory(tag,text,MaxTextExtent);
408 p=strrchr(tag,'/');
409 if (p != (char *) NULL)
410 *p='\0';
cristyb51dff52011-05-19 16:55:47 +0000411 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
anthonydf8ebac2011-04-27 09:03:19 +0000412 locale_message=GetLocaleMessage(message);
413 if (locale_message == message)
414 locale_message=tag;
415 if (p == (char *) NULL)
cristy1e604812011-05-19 18:07:50 +0000416 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
417 locale_message,(long) offset,(unsigned long) extent,(long)
418 (100L*offset/(extent-1)));
anthonydf8ebac2011-04-27 09:03:19 +0000419 else
cristyb51dff52011-05-19 16:55:47 +0000420 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
anthonydf8ebac2011-04-27 09:03:19 +0000421 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
422 (100L*offset/(extent-1)));
423 if (offset == (MagickOffsetType) (extent-1))
cristyb51dff52011-05-19 16:55:47 +0000424 (void) FormatLocaleFile(stderr,"\n");
anthonydf8ebac2011-04-27 09:03:19 +0000425 (void) fflush(stderr);
426 return(MagickTrue);
427}
428
cristy3884f692011-07-08 18:00:18 +0000429static Image *SparseColorOption(const Image *image,
anthonydf8ebac2011-04-27 09:03:19 +0000430 const SparseColorMethod method,const char *arguments,
431 const MagickBooleanType color_from_image,ExceptionInfo *exception)
432{
anthonydf8ebac2011-04-27 09:03:19 +0000433 char
434 token[MaxTextExtent];
435
436 const char
437 *p;
438
439 double
440 *sparse_arguments;
441
anthonydf8ebac2011-04-27 09:03:19 +0000442 Image
443 *sparse_image;
444
cristy4c08aed2011-07-01 19:47:50 +0000445 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000446 color;
447
448 MagickBooleanType
449 error;
450
cristy5f09d852011-05-29 01:39:29 +0000451 register size_t
452 x;
453
454 size_t
455 number_arguments,
456 number_colors;
457
cristyf4425a72011-11-08 01:52:04 +0000458 /*
459 SparseColorOption() parses the complex -sparse-color argument into an an
460 array of floating point values then calls SparseColorImage(). Argument is
461 a complex mix of floating-point pixel coodinates, and color specifications
462 (or direct floating point numbers). The number of floats needed to
463 represent a color varies depending on the current channel setting.
464 */
anthonydf8ebac2011-04-27 09:03:19 +0000465 assert(image != (Image *) NULL);
466 assert(image->signature == MagickSignature);
467 if (image->debug != MagickFalse)
468 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
469 assert(exception != (ExceptionInfo *) NULL);
470 assert(exception->signature == MagickSignature);
471 /*
472 Limit channels according to image - and add up number of color channel.
473 */
anthonydf8ebac2011-04-27 09:03:19 +0000474 number_colors=0;
cristyed231572011-07-14 02:18:59 +0000475 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000476 number_colors++;
cristyed231572011-07-14 02:18:59 +0000477 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000478 number_colors++;
cristyed231572011-07-14 02:18:59 +0000479 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000480 number_colors++;
cristyed231572011-07-14 02:18:59 +0000481 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000482 (image->colorspace == CMYKColorspace))
anthonydf8ebac2011-04-27 09:03:19 +0000483 number_colors++;
cristyed231572011-07-14 02:18:59 +0000484 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000485 (image->matte != MagickFalse))
anthonydf8ebac2011-04-27 09:03:19 +0000486 number_colors++;
487
488 /*
489 Read string, to determine number of arguments needed,
490 */
491 p=arguments;
492 x=0;
493 while( *p != '\0' )
494 {
495 GetMagickToken(p,&p,token);
496 if ( token[0] == ',' ) continue;
497 if ( isalpha((int) token[0]) || token[0] == '#' ) {
498 if ( color_from_image ) {
499 (void) ThrowMagickException(exception,GetMagickModule(),
500 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
501 "Color arg given, when colors are coming from image");
502 return( (Image *)NULL);
503 }
504 x += number_colors; /* color argument */
505 }
506 else {
507 x++; /* floating point argument */
508 }
509 }
510 error=MagickTrue;
511 if ( color_from_image ) {
512 /* just the control points are being given */
513 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
514 number_arguments=(x/2)*(2+number_colors);
515 }
516 else {
517 /* control points and color values */
518 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
519 number_arguments=x;
520 }
521 if ( error ) {
522 (void) ThrowMagickException(exception,GetMagickModule(),
523 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
524 "Invalid number of Arguments");
525 return( (Image *)NULL);
526 }
527
528 /* Allocate and fill in the floating point arguments */
529 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
530 sizeof(*sparse_arguments));
531 if (sparse_arguments == (double *) NULL) {
532 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
533 "MemoryAllocationFailed","%s","SparseColorOption");
534 return( (Image *)NULL);
535 }
536 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
537 sizeof(*sparse_arguments));
538 p=arguments;
539 x=0;
540 while( *p != '\0' && x < number_arguments ) {
541 /* X coordinate */
542 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
543 if ( token[0] == '\0' ) break;
544 if ( isalpha((int) token[0]) || token[0] == '#' ) {
545 (void) ThrowMagickException(exception,GetMagickModule(),
546 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
547 "Color found, instead of X-coord");
548 error = MagickTrue;
549 break;
550 }
cristydbdd0e32011-11-04 23:29:40 +0000551 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000552 /* Y coordinate */
553 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
554 if ( token[0] == '\0' ) break;
555 if ( isalpha((int) token[0]) || token[0] == '#' ) {
556 (void) ThrowMagickException(exception,GetMagickModule(),
557 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
558 "Color found, instead of Y-coord");
559 error = MagickTrue;
560 break;
561 }
cristydbdd0e32011-11-04 23:29:40 +0000562 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000563 /* color values for this control point */
564#if 0
565 if ( (color_from_image ) {
566 /* get color from image */
567 /* HOW??? */
568 }
569 else
570#endif
571 {
572 /* color name or function given in string argument */
573 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
574 if ( token[0] == '\0' ) break;
575 if ( isalpha((int) token[0]) || token[0] == '#' ) {
576 /* Color string given */
cristy269c9412011-10-13 23:41:15 +0000577 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
cristyed231572011-07-14 02:18:59 +0000578 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000579 sparse_arguments[x++] = QuantumScale*color.red;
cristyed231572011-07-14 02:18:59 +0000580 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000581 sparse_arguments[x++] = QuantumScale*color.green;
cristyed231572011-07-14 02:18:59 +0000582 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
anthonydf8ebac2011-04-27 09:03:19 +0000583 sparse_arguments[x++] = QuantumScale*color.blue;
cristyed231572011-07-14 02:18:59 +0000584 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000585 (image->colorspace == CMYKColorspace))
cristy4c08aed2011-07-01 19:47:50 +0000586 sparse_arguments[x++] = QuantumScale*color.black;
cristyed231572011-07-14 02:18:59 +0000587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000588 (image->matte != MagickFalse))
cristy4c08aed2011-07-01 19:47:50 +0000589 sparse_arguments[x++] = QuantumScale*color.alpha;
anthonydf8ebac2011-04-27 09:03:19 +0000590 }
591 else {
592 /* Colors given as a set of floating point values - experimental */
593 /* NB: token contains the first floating point value to use! */
cristyed231572011-07-14 02:18:59 +0000594 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000595 {
anthonydf8ebac2011-04-27 09:03:19 +0000596 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
597 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
598 break;
cristydbdd0e32011-11-04 23:29:40 +0000599 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000600 token[0] = ','; /* used this token - get another */
601 }
cristyed231572011-07-14 02:18:59 +0000602 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000603 {
anthonydf8ebac2011-04-27 09:03:19 +0000604 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
605 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
606 break;
cristydbdd0e32011-11-04 23:29:40 +0000607 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000608 token[0] = ','; /* used this token - get another */
609 }
cristyed231572011-07-14 02:18:59 +0000610 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
cristy3884f692011-07-08 18:00:18 +0000611 {
anthonydf8ebac2011-04-27 09:03:19 +0000612 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
613 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
614 break;
cristydbdd0e32011-11-04 23:29:40 +0000615 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000616 token[0] = ','; /* used this token - get another */
617 }
cristyed231572011-07-14 02:18:59 +0000618 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000619 (image->colorspace == CMYKColorspace))
620 {
anthonydf8ebac2011-04-27 09:03:19 +0000621 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
622 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
623 break;
cristydbdd0e32011-11-04 23:29:40 +0000624 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000625 token[0] = ','; /* used this token - get another */
626 }
cristyed231572011-07-14 02:18:59 +0000627 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
cristy3884f692011-07-08 18:00:18 +0000628 (image->matte != MagickFalse))
629 {
anthonydf8ebac2011-04-27 09:03:19 +0000630 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
631 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
632 break;
cristydbdd0e32011-11-04 23:29:40 +0000633 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +0000634 token[0] = ','; /* used this token - get another */
635 }
636 }
637 }
638 }
639 if ( number_arguments != x && !error ) {
640 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
641 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
642 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
643 return( (Image *)NULL);
644 }
645 if ( error )
646 return( (Image *)NULL);
647
648 /* Call the Interpolation function with the parsed arguments */
cristy3884f692011-07-08 18:00:18 +0000649 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
650 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000651 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
652 return( sparse_image );
653}
654
cristy3ed852e2009-09-05 21:47:34 +0000655WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
656 const char **argv,Image **image,ExceptionInfo *exception)
657{
anthonydf8ebac2011-04-27 09:03:19 +0000658 ChannelType
659 channel;
660
cristy633f0c62011-09-15 13:27:36 +0000661 CompositeOperator
662 compose;
663
anthonydf8ebac2011-04-27 09:03:19 +0000664 const char
665 *format,
666 *option;
667
cristy9ed1f812011-10-08 02:00:08 +0000668 double
669 attenuate;
670
anthonydf8ebac2011-04-27 09:03:19 +0000671 DrawInfo
672 *draw_info;
673
674 GeometryInfo
675 geometry_info;
676
cristy3ed852e2009-09-05 21:47:34 +0000677 Image
678 *region_image;
679
anthonydf8ebac2011-04-27 09:03:19 +0000680 ImageInfo
681 *mogrify_info;
682
cristyebbcfea2011-02-25 02:43:54 +0000683 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000684 status;
685
cristy4c08aed2011-07-01 19:47:50 +0000686 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +0000687 fill;
cristy3ed852e2009-09-05 21:47:34 +0000688
anthonydf8ebac2011-04-27 09:03:19 +0000689 MagickStatusType
690 flags;
691
cristy28474bf2011-09-11 23:32:52 +0000692 PixelInterpolateMethod
693 interpolate_method;
694
anthonydf8ebac2011-04-27 09:03:19 +0000695 QuantizeInfo
696 *quantize_info;
697
698 RectangleInfo
699 geometry,
700 region_geometry;
anthony56ad4222011-04-25 11:04:27 +0000701
cristybb503372010-05-27 20:51:26 +0000702 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000703 i;
704
705 /*
706 Initialize method variables.
707 */
708 assert(image_info != (const ImageInfo *) NULL);
709 assert(image_info->signature == MagickSignature);
710 assert(image != (Image **) NULL);
711 assert((*image)->signature == MagickSignature);
712 if ((*image)->debug != MagickFalse)
713 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
714 if (argc < 0)
715 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +0000716 mogrify_info=CloneImageInfo(image_info);
anthonydf8ebac2011-04-27 09:03:19 +0000717 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
718 quantize_info=AcquireQuantizeInfo(mogrify_info);
719 SetGeometryInfo(&geometry_info);
cristy4c08aed2011-07-01 19:47:50 +0000720 GetPixelInfo(*image,&fill);
cristy9d8c8ce2011-10-25 16:13:52 +0000721 fill=(*image)->background_color;
cristy9ed1f812011-10-08 02:00:08 +0000722 attenuate=1.0;
cristy633f0c62011-09-15 13:27:36 +0000723 compose=(*image)->compose;
cristy28474bf2011-09-11 23:32:52 +0000724 interpolate_method=UndefinedInterpolatePixel;
anthonydf8ebac2011-04-27 09:03:19 +0000725 channel=mogrify_info->channel;
726 format=GetImageOption(mogrify_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000727 SetGeometry(*image,&region_geometry);
728 region_image=NewImageList();
729 /*
730 Transmogrify the image.
731 */
cristybb503372010-05-27 20:51:26 +0000732 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000733 {
anthonydf8ebac2011-04-27 09:03:19 +0000734 Image
735 *mogrify_image;
736
anthonye9c27192011-03-27 08:07:06 +0000737 ssize_t
738 count;
739
anthonydf8ebac2011-04-27 09:03:19 +0000740 option=argv[i];
741 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000742 continue;
anthonydf8ebac2011-04-27 09:03:19 +0000743 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
744 0L);
cristycee97112010-05-28 00:44:52 +0000745 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000746 break;
cristy6b3da3a2010-06-20 02:21:46 +0000747 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000748 mogrify_image=(Image *)NULL;
749 switch (*(option+1))
750 {
751 case 'a':
cristy3ed852e2009-09-05 21:47:34 +0000752 {
anthonydf8ebac2011-04-27 09:03:19 +0000753 if (LocaleCompare("adaptive-blur",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000754 {
anthonydf8ebac2011-04-27 09:03:19 +0000755 /*
756 Adaptive blur image.
757 */
cristy6fccee12011-10-20 18:43:18 +0000758 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000759 flags=ParseGeometry(argv[i+1],&geometry_info);
760 if ((flags & SigmaValue) == 0)
761 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000762 if ((flags & XiValue) == 0)
763 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000764 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000765 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000766 break;
cristy3ed852e2009-09-05 21:47:34 +0000767 }
anthonydf8ebac2011-04-27 09:03:19 +0000768 if (LocaleCompare("adaptive-resize",option+1) == 0)
769 {
770 /*
771 Adaptive resize image.
772 */
cristy6fccee12011-10-20 18:43:18 +0000773 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000774 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
775 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
cristy28474bf2011-09-11 23:32:52 +0000776 geometry.height,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000777 break;
778 }
779 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
780 {
781 /*
782 Adaptive sharpen image.
783 */
cristy6fccee12011-10-20 18:43:18 +0000784 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000785 flags=ParseGeometry(argv[i+1],&geometry_info);
786 if ((flags & SigmaValue) == 0)
787 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000788 if ((flags & XiValue) == 0)
789 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000790 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
cristy4c11c2b2011-09-05 20:17:07 +0000791 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000792 break;
793 }
794 if (LocaleCompare("affine",option+1) == 0)
795 {
796 /*
797 Affine matrix.
798 */
799 if (*option == '+')
800 {
801 GetAffineMatrix(&draw_info->affine);
802 break;
803 }
804 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
805 break;
806 }
807 if (LocaleCompare("alpha",option+1) == 0)
808 {
809 AlphaChannelType
810 alpha_type;
cristy3ed852e2009-09-05 21:47:34 +0000811
cristy6fccee12011-10-20 18:43:18 +0000812 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000813 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
814 MagickFalse,argv[i+1]);
cristy63240882011-08-05 19:05:27 +0000815 (void) SetImageAlphaChannel(*image,alpha_type,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000816 break;
817 }
818 if (LocaleCompare("annotate",option+1) == 0)
819 {
820 char
821 *text,
822 geometry[MaxTextExtent];
823
824 /*
825 Annotate image.
826 */
cristy6fccee12011-10-20 18:43:18 +0000827 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000828 SetGeometryInfo(&geometry_info);
829 flags=ParseGeometry(argv[i+1],&geometry_info);
830 if ((flags & SigmaValue) == 0)
831 geometry_info.sigma=geometry_info.rho;
cristy018f07f2011-09-04 21:15:19 +0000832 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
833 exception);
anthonydf8ebac2011-04-27 09:03:19 +0000834 if (text == (char *) NULL)
835 break;
836 (void) CloneString(&draw_info->text,text);
837 text=DestroyString(text);
cristyb51dff52011-05-19 16:55:47 +0000838 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
anthonydf8ebac2011-04-27 09:03:19 +0000839 geometry_info.xi,geometry_info.psi);
840 (void) CloneString(&draw_info->geometry,geometry);
841 draw_info->affine.sx=cos(DegreesToRadians(
842 fmod(geometry_info.rho,360.0)));
843 draw_info->affine.rx=sin(DegreesToRadians(
844 fmod(geometry_info.rho,360.0)));
845 draw_info->affine.ry=(-sin(DegreesToRadians(
846 fmod(geometry_info.sigma,360.0))));
847 draw_info->affine.sy=cos(DegreesToRadians(
848 fmod(geometry_info.sigma,360.0)));
cristy5cbc0162011-08-29 00:36:28 +0000849 (void) AnnotateImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000850 break;
851 }
852 if (LocaleCompare("antialias",option+1) == 0)
853 {
854 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
855 MagickFalse;
856 draw_info->text_antialias=(*option == '-') ? MagickTrue :
857 MagickFalse;
858 break;
859 }
cristy9ed1f812011-10-08 02:00:08 +0000860 if (LocaleCompare("attenuate",option+1) == 0)
861 {
862 if (*option == '+')
863 {
864 attenuate=1.0;
865 break;
866 }
cristydbdd0e32011-11-04 23:29:40 +0000867 attenuate=StringToDouble(argv[i+1],(char **) NULL);
cristy9ed1f812011-10-08 02:00:08 +0000868 break;
869 }
anthonydf8ebac2011-04-27 09:03:19 +0000870 if (LocaleCompare("auto-gamma",option+1) == 0)
871 {
872 /*
873 Auto Adjust Gamma of image based on its mean
874 */
cristy6fccee12011-10-20 18:43:18 +0000875 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy95111202011-08-09 19:41:42 +0000876 (void) AutoGammaImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000877 break;
878 }
879 if (LocaleCompare("auto-level",option+1) == 0)
880 {
881 /*
882 Perfectly Normalize (max/min stretch) the image
883 */
cristy6fccee12011-10-20 18:43:18 +0000884 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy95111202011-08-09 19:41:42 +0000885 (void) AutoLevelImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000886 break;
887 }
888 if (LocaleCompare("auto-orient",option+1) == 0)
889 {
cristy6fccee12011-10-20 18:43:18 +0000890 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000891 switch ((*image)->orientation)
892 {
893 case TopRightOrientation:
894 {
895 mogrify_image=FlopImage(*image,exception);
896 break;
897 }
898 case BottomRightOrientation:
899 {
900 mogrify_image=RotateImage(*image,180.0,exception);
901 break;
902 }
903 case BottomLeftOrientation:
904 {
905 mogrify_image=FlipImage(*image,exception);
906 break;
907 }
908 case LeftTopOrientation:
909 {
910 mogrify_image=TransposeImage(*image,exception);
911 break;
912 }
913 case RightTopOrientation:
914 {
915 mogrify_image=RotateImage(*image,90.0,exception);
916 break;
917 }
918 case RightBottomOrientation:
919 {
920 mogrify_image=TransverseImage(*image,exception);
921 break;
922 }
923 case LeftBottomOrientation:
924 {
925 mogrify_image=RotateImage(*image,270.0,exception);
926 break;
927 }
928 default:
929 break;
930 }
931 if (mogrify_image != (Image *) NULL)
932 mogrify_image->orientation=TopLeftOrientation;
933 break;
934 }
935 break;
936 }
937 case 'b':
938 {
939 if (LocaleCompare("black-threshold",option+1) == 0)
940 {
941 /*
942 Black threshold image.
943 */
cristy6fccee12011-10-20 18:43:18 +0000944 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyf4ad9df2011-07-08 16:49:03 +0000945 (void) BlackThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +0000946 break;
947 }
948 if (LocaleCompare("blue-shift",option+1) == 0)
949 {
950 /*
951 Blue shift image.
952 */
cristy6fccee12011-10-20 18:43:18 +0000953 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000954 geometry_info.rho=1.5;
955 if (*option == '-')
956 flags=ParseGeometry(argv[i+1],&geometry_info);
957 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
958 break;
959 }
960 if (LocaleCompare("blur",option+1) == 0)
961 {
962 /*
963 Gaussian blur image.
964 */
cristy6fccee12011-10-20 18:43:18 +0000965 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000966 flags=ParseGeometry(argv[i+1],&geometry_info);
967 if ((flags & SigmaValue) == 0)
968 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +0000969 if ((flags & XiValue) == 0)
970 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +0000971 mogrify_image=BlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +0000972 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000973 break;
974 }
975 if (LocaleCompare("border",option+1) == 0)
976 {
977 /*
978 Surround image with a border of solid color.
979 */
cristy6fccee12011-10-20 18:43:18 +0000980 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000981 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
982 if ((flags & SigmaValue) == 0)
983 geometry.height=geometry.width;
cristy633f0c62011-09-15 13:27:36 +0000984 mogrify_image=BorderImage(*image,&geometry,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000985 break;
986 }
987 if (LocaleCompare("bordercolor",option+1) == 0)
988 {
989 if (*option == '+')
990 {
cristy9950d572011-10-01 18:22:35 +0000991 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy05c0c9a2011-09-05 23:16:13 +0000992 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000993 break;
994 }
cristy9950d572011-10-01 18:22:35 +0000995 (void) QueryColorCompliance(argv[i+1],AllCompliance,
996 &draw_info->border_color,exception);
anthonydf8ebac2011-04-27 09:03:19 +0000997 break;
998 }
999 if (LocaleCompare("box",option+1) == 0)
1000 {
cristy9950d572011-10-01 18:22:35 +00001001 (void) QueryColorCompliance(argv[i+1],AllCompliance,
1002 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001003 break;
1004 }
1005 if (LocaleCompare("brightness-contrast",option+1) == 0)
1006 {
1007 double
1008 brightness,
1009 contrast;
1010
1011 GeometryInfo
1012 geometry_info;
1013
1014 MagickStatusType
1015 flags;
1016
1017 /*
1018 Brightness / contrast image.
1019 */
cristy6fccee12011-10-20 18:43:18 +00001020 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001021 flags=ParseGeometry(argv[i+1],&geometry_info);
1022 brightness=geometry_info.rho;
1023 contrast=0.0;
1024 if ((flags & SigmaValue) != 0)
1025 contrast=geometry_info.sigma;
cristy444eda62011-08-10 02:07:46 +00001026 (void) BrightnessContrastImage(*image,brightness,contrast,
1027 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001028 break;
1029 }
1030 break;
1031 }
1032 case 'c':
1033 {
1034 if (LocaleCompare("cdl",option+1) == 0)
1035 {
1036 char
1037 *color_correction_collection;
1038
1039 /*
1040 Color correct with a color decision list.
1041 */
cristy6fccee12011-10-20 18:43:18 +00001042 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001043 color_correction_collection=FileToString(argv[i+1],~0,exception);
1044 if (color_correction_collection == (char *) NULL)
1045 break;
cristy1bfa9f02011-08-11 02:35:43 +00001046 (void) ColorDecisionListImage(*image,color_correction_collection,
1047 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001048 break;
1049 }
1050 if (LocaleCompare("channel",option+1) == 0)
1051 {
1052 if (*option == '+')
cristyfa806a72011-07-04 02:06:13 +00001053 channel=DefaultChannels;
anthonydf8ebac2011-04-27 09:03:19 +00001054 else
cristyfa806a72011-07-04 02:06:13 +00001055 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristye2a912b2011-12-05 20:02:07 +00001056 SetPixelChannelMapMask(*image,channel);
anthonydf8ebac2011-04-27 09:03:19 +00001057 break;
1058 }
1059 if (LocaleCompare("charcoal",option+1) == 0)
1060 {
1061 /*
1062 Charcoal image.
1063 */
cristy6fccee12011-10-20 18:43:18 +00001064 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001065 flags=ParseGeometry(argv[i+1],&geometry_info);
1066 if ((flags & SigmaValue) == 0)
1067 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001068 if ((flags & XiValue) == 0)
1069 geometry_info.xi=1.0;
anthonydf8ebac2011-04-27 09:03:19 +00001070 mogrify_image=CharcoalImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001071 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001072 break;
1073 }
1074 if (LocaleCompare("chop",option+1) == 0)
1075 {
1076 /*
1077 Chop the image.
1078 */
cristy6fccee12011-10-20 18:43:18 +00001079 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001080 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1081 mogrify_image=ChopImage(*image,&geometry,exception);
1082 break;
1083 }
1084 if (LocaleCompare("clamp",option+1) == 0)
1085 {
1086 /*
1087 Clamp image.
1088 */
cristy6fccee12011-10-20 18:43:18 +00001089 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy092d71c2011-10-14 18:01:29 +00001090 (void) ClampImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001091 break;
1092 }
1093 if (LocaleCompare("clip",option+1) == 0)
1094 {
cristy6fccee12011-10-20 18:43:18 +00001095 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001096 if (*option == '+')
1097 {
cristy018f07f2011-09-04 21:15:19 +00001098 (void) SetImageClipMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001099 break;
1100 }
cristy018f07f2011-09-04 21:15:19 +00001101 (void) ClipImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001102 break;
1103 }
1104 if (LocaleCompare("clip-mask",option+1) == 0)
1105 {
1106 CacheView
1107 *mask_view;
1108
1109 Image
1110 *mask_image;
1111
cristy4c08aed2011-07-01 19:47:50 +00001112 register Quantum
anthonydf8ebac2011-04-27 09:03:19 +00001113 *restrict q;
1114
1115 register ssize_t
1116 x;
1117
1118 ssize_t
1119 y;
1120
cristy6fccee12011-10-20 18:43:18 +00001121 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001122 if (*option == '+')
1123 {
1124 /*
1125 Remove a mask.
1126 */
cristy018f07f2011-09-04 21:15:19 +00001127 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001128 break;
1129 }
1130 /*
1131 Set the image mask.
1132 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1133 */
1134 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1135 if (mask_image == (Image *) NULL)
1136 break;
cristy574cc262011-08-05 01:23:58 +00001137 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
anthonydf8ebac2011-04-27 09:03:19 +00001138 return(MagickFalse);
1139 mask_view=AcquireCacheView(mask_image);
1140 for (y=0; y < (ssize_t) mask_image->rows; y++)
1141 {
1142 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1143 exception);
cristyacd2ed22011-08-30 01:44:23 +00001144 if (q == (Quantum *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001145 break;
1146 for (x=0; x < (ssize_t) mask_image->columns; x++)
1147 {
1148 if (mask_image->matte == MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +00001149 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1150 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1151 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1152 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
cristyed231572011-07-14 02:18:59 +00001153 q+=GetPixelChannels(mask_image);
anthonydf8ebac2011-04-27 09:03:19 +00001154 }
1155 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1156 break;
1157 }
1158 mask_view=DestroyCacheView(mask_view);
1159 mask_image->matte=MagickTrue;
cristy018f07f2011-09-04 21:15:19 +00001160 (void) SetImageClipMask(*image,mask_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001161 break;
1162 }
1163 if (LocaleCompare("clip-path",option+1) == 0)
1164 {
cristy6fccee12011-10-20 18:43:18 +00001165 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001166 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
cristy018f07f2011-09-04 21:15:19 +00001167 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001168 break;
1169 }
1170 if (LocaleCompare("colorize",option+1) == 0)
1171 {
1172 /*
1173 Colorize the image.
1174 */
cristy6fccee12011-10-20 18:43:18 +00001175 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyc7e6ff62011-10-03 13:46:11 +00001176 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001177 break;
1178 }
1179 if (LocaleCompare("color-matrix",option+1) == 0)
1180 {
1181 KernelInfo
1182 *kernel;
1183
cristy6fccee12011-10-20 18:43:18 +00001184 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001185 kernel=AcquireKernelInfo(argv[i+1]);
1186 if (kernel == (KernelInfo *) NULL)
1187 break;
1188 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1189 kernel=DestroyKernelInfo(kernel);
1190 break;
1191 }
1192 if (LocaleCompare("colors",option+1) == 0)
1193 {
1194 /*
1195 Reduce the number of colors in the image.
1196 */
cristy6fccee12011-10-20 18:43:18 +00001197 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001198 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1199 if (quantize_info->number_colors == 0)
1200 break;
1201 if (((*image)->storage_class == DirectClass) ||
1202 (*image)->colors > quantize_info->number_colors)
cristy018f07f2011-09-04 21:15:19 +00001203 (void) QuantizeImage(quantize_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001204 else
cristy018f07f2011-09-04 21:15:19 +00001205 (void) CompressImageColormap(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001206 break;
1207 }
1208 if (LocaleCompare("colorspace",option+1) == 0)
1209 {
1210 ColorspaceType
1211 colorspace;
1212
cristy6fccee12011-10-20 18:43:18 +00001213 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001214 if (*option == '+')
1215 {
cristye941a752011-10-15 01:52:48 +00001216 (void) TransformImageColorspace(*image,RGBColorspace,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001217 break;
1218 }
1219 colorspace=(ColorspaceType) ParseCommandOption(
1220 MagickColorspaceOptions,MagickFalse,argv[i+1]);
cristye941a752011-10-15 01:52:48 +00001221 (void) TransformImageColorspace(*image,colorspace,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001222 break;
1223 }
cristy633f0c62011-09-15 13:27:36 +00001224 if (LocaleCompare("compose",option+1) == 0)
1225 {
cristy6fccee12011-10-20 18:43:18 +00001226 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy633f0c62011-09-15 13:27:36 +00001227 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1228 MagickFalse,argv[i+1]);
1229 break;
1230 }
anthonydf8ebac2011-04-27 09:03:19 +00001231 if (LocaleCompare("contrast",option+1) == 0)
1232 {
cristy6fccee12011-10-20 18:43:18 +00001233 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001234 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
cristye23ec9d2011-08-16 18:15:40 +00001235 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001236 break;
1237 }
1238 if (LocaleCompare("contrast-stretch",option+1) == 0)
1239 {
1240 double
1241 black_point,
1242 white_point;
1243
1244 MagickStatusType
1245 flags;
1246
1247 /*
1248 Contrast stretch image.
1249 */
cristy6fccee12011-10-20 18:43:18 +00001250 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001251 flags=ParseGeometry(argv[i+1],&geometry_info);
1252 black_point=geometry_info.rho;
1253 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1254 black_point;
1255 if ((flags & PercentValue) != 0)
1256 {
1257 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1258 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1259 }
1260 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1261 white_point;
cristye23ec9d2011-08-16 18:15:40 +00001262 (void) ContrastStretchImage(*image,black_point,white_point,
1263 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001264 break;
1265 }
1266 if (LocaleCompare("convolve",option+1) == 0)
1267 {
anthonydf8ebac2011-04-27 09:03:19 +00001268 KernelInfo
cristy41cbe682011-07-15 19:12:37 +00001269 *kernel_info;
anthonydf8ebac2011-04-27 09:03:19 +00001270
cristy6fccee12011-10-20 18:43:18 +00001271 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy41cbe682011-07-15 19:12:37 +00001272 kernel_info=AcquireKernelInfo(argv[i+1]);
1273 if (kernel_info == (KernelInfo *) NULL)
anthonydf8ebac2011-04-27 09:03:19 +00001274 break;
cristy0a922382011-07-16 15:30:34 +00001275 kernel_info->bias=(*image)->bias;
cristy5e6be1e2011-07-16 01:23:39 +00001276 mogrify_image=ConvolveImage(*image,kernel_info,exception);
cristy41cbe682011-07-15 19:12:37 +00001277 kernel_info=DestroyKernelInfo(kernel_info);
anthonydf8ebac2011-04-27 09:03:19 +00001278 break;
1279 }
1280 if (LocaleCompare("crop",option+1) == 0)
1281 {
1282 /*
1283 Crop a image to a smaller size
1284 */
cristy6fccee12011-10-20 18:43:18 +00001285 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001286 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00001287 break;
1288 }
1289 if (LocaleCompare("cycle",option+1) == 0)
1290 {
1291 /*
1292 Cycle an image colormap.
1293 */
cristy6fccee12011-10-20 18:43:18 +00001294 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy018f07f2011-09-04 21:15:19 +00001295 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1296 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001297 break;
1298 }
1299 break;
1300 }
1301 case 'd':
1302 {
1303 if (LocaleCompare("decipher",option+1) == 0)
1304 {
1305 StringInfo
1306 *passkey;
1307
1308 /*
1309 Decipher pixels.
1310 */
cristy6fccee12011-10-20 18:43:18 +00001311 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001312 passkey=FileToStringInfo(argv[i+1],~0,exception);
1313 if (passkey != (StringInfo *) NULL)
1314 {
1315 (void) PasskeyDecipherImage(*image,passkey,exception);
1316 passkey=DestroyStringInfo(passkey);
1317 }
1318 break;
1319 }
1320 if (LocaleCompare("density",option+1) == 0)
1321 {
1322 /*
1323 Set image density.
1324 */
1325 (void) CloneString(&draw_info->density,argv[i+1]);
1326 break;
1327 }
1328 if (LocaleCompare("depth",option+1) == 0)
1329 {
cristy6fccee12011-10-20 18:43:18 +00001330 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001331 if (*option == '+')
1332 {
cristy8a11cb12011-10-19 23:53:34 +00001333 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001334 break;
1335 }
cristy8a11cb12011-10-19 23:53:34 +00001336 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1337 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001338 break;
1339 }
1340 if (LocaleCompare("deskew",option+1) == 0)
1341 {
1342 double
1343 threshold;
1344
1345 /*
1346 Straighten the image.
1347 */
cristy6fccee12011-10-20 18:43:18 +00001348 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001349 if (*option == '+')
1350 threshold=40.0*QuantumRange/100.0;
1351 else
cristy9b34e302011-11-05 02:15:45 +00001352 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1353 1.0);
anthonydf8ebac2011-04-27 09:03:19 +00001354 mogrify_image=DeskewImage(*image,threshold,exception);
1355 break;
1356 }
1357 if (LocaleCompare("despeckle",option+1) == 0)
1358 {
1359 /*
1360 Reduce the speckles within an image.
1361 */
cristy6fccee12011-10-20 18:43:18 +00001362 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001363 mogrify_image=DespeckleImage(*image,exception);
1364 break;
1365 }
1366 if (LocaleCompare("display",option+1) == 0)
1367 {
1368 (void) CloneString(&draw_info->server_name,argv[i+1]);
1369 break;
1370 }
1371 if (LocaleCompare("distort",option+1) == 0)
1372 {
1373 char
1374 *args,
1375 token[MaxTextExtent];
1376
1377 const char
1378 *p;
1379
1380 DistortImageMethod
1381 method;
1382
1383 double
1384 *arguments;
1385
1386 register ssize_t
1387 x;
1388
1389 size_t
1390 number_arguments;
1391
1392 /*
1393 Distort image.
1394 */
cristy6fccee12011-10-20 18:43:18 +00001395 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001396 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1397 MagickFalse,argv[i+1]);
cristy56835872011-11-06 01:19:13 +00001398 if (method == ResizeDistortion)
anthonydf8ebac2011-04-27 09:03:19 +00001399 {
anthonydf8ebac2011-04-27 09:03:19 +00001400 double
1401 resize_args[2];
cristy56835872011-11-06 01:19:13 +00001402
1403 /*
1404 Special Case - Argument is actually a resize geometry!
1405 Convert that to an appropriate distortion argument array.
1406 */
anthonydf8ebac2011-04-27 09:03:19 +00001407 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
cristy56835872011-11-06 01:19:13 +00001408 exception);
1409 resize_args[0]=(double) geometry.width;
1410 resize_args[1]=(double) geometry.height;
anthonydf8ebac2011-04-27 09:03:19 +00001411 mogrify_image=DistortImage(*image,method,(size_t)2,
cristy56835872011-11-06 01:19:13 +00001412 resize_args,MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001413 break;
1414 }
cristy018f07f2011-09-04 21:15:19 +00001415 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1416 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001417 if (args == (char *) NULL)
1418 break;
1419 p=(char *) args;
1420 for (x=0; *p != '\0'; x++)
1421 {
1422 GetMagickToken(p,&p,token);
1423 if (*token == ',')
1424 GetMagickToken(p,&p,token);
1425 }
1426 number_arguments=(size_t) x;
1427 arguments=(double *) AcquireQuantumMemory(number_arguments,
1428 sizeof(*arguments));
1429 if (arguments == (double *) NULL)
1430 ThrowWandFatalException(ResourceLimitFatalError,
1431 "MemoryAllocationFailed",(*image)->filename);
1432 (void) ResetMagickMemory(arguments,0,number_arguments*
1433 sizeof(*arguments));
1434 p=(char *) args;
1435 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1436 {
1437 GetMagickToken(p,&p,token);
1438 if (*token == ',')
1439 GetMagickToken(p,&p,token);
cristydbdd0e32011-11-04 23:29:40 +00001440 arguments[x]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001441 }
1442 args=DestroyString(args);
1443 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1444 (*option == '+') ? MagickTrue : MagickFalse,exception);
1445 arguments=(double *) RelinquishMagickMemory(arguments);
1446 break;
1447 }
1448 if (LocaleCompare("dither",option+1) == 0)
1449 {
1450 if (*option == '+')
1451 {
1452 quantize_info->dither=MagickFalse;
1453 break;
1454 }
1455 quantize_info->dither=MagickTrue;
1456 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1457 MagickDitherOptions,MagickFalse,argv[i+1]);
1458 if (quantize_info->dither_method == NoDitherMethod)
1459 quantize_info->dither=MagickFalse;
1460 break;
1461 }
1462 if (LocaleCompare("draw",option+1) == 0)
1463 {
1464 /*
1465 Draw image.
1466 */
cristy6fccee12011-10-20 18:43:18 +00001467 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001468 (void) CloneString(&draw_info->primitive,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001469 (void) DrawImage(*image,draw_info,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001470 break;
1471 }
1472 break;
1473 }
1474 case 'e':
1475 {
1476 if (LocaleCompare("edge",option+1) == 0)
1477 {
1478 /*
1479 Enhance edges in the image.
1480 */
cristy6fccee12011-10-20 18:43:18 +00001481 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001482 flags=ParseGeometry(argv[i+1],&geometry_info);
1483 if ((flags & SigmaValue) == 0)
1484 geometry_info.sigma=1.0;
cristy8ae632d2011-09-05 17:29:53 +00001485 mogrify_image=EdgeImage(*image,geometry_info.rho,
1486 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001487 break;
1488 }
1489 if (LocaleCompare("emboss",option+1) == 0)
1490 {
1491 /*
1492 Gaussian embossen image.
1493 */
cristy6fccee12011-10-20 18:43:18 +00001494 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001495 flags=ParseGeometry(argv[i+1],&geometry_info);
1496 if ((flags & SigmaValue) == 0)
1497 geometry_info.sigma=1.0;
1498 mogrify_image=EmbossImage(*image,geometry_info.rho,
1499 geometry_info.sigma,exception);
1500 break;
1501 }
1502 if (LocaleCompare("encipher",option+1) == 0)
1503 {
1504 StringInfo
1505 *passkey;
1506
1507 /*
1508 Encipher pixels.
1509 */
cristy6fccee12011-10-20 18:43:18 +00001510 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001511 passkey=FileToStringInfo(argv[i+1],~0,exception);
1512 if (passkey != (StringInfo *) NULL)
1513 {
1514 (void) PasskeyEncipherImage(*image,passkey,exception);
1515 passkey=DestroyStringInfo(passkey);
1516 }
1517 break;
1518 }
1519 if (LocaleCompare("encoding",option+1) == 0)
1520 {
1521 (void) CloneString(&draw_info->encoding,argv[i+1]);
1522 break;
1523 }
1524 if (LocaleCompare("enhance",option+1) == 0)
1525 {
1526 /*
1527 Enhance image.
1528 */
cristy6fccee12011-10-20 18:43:18 +00001529 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001530 mogrify_image=EnhanceImage(*image,exception);
1531 break;
1532 }
1533 if (LocaleCompare("equalize",option+1) == 0)
1534 {
1535 /*
1536 Equalize image.
1537 */
cristy6fccee12011-10-20 18:43:18 +00001538 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy6d8c3d72011-08-22 01:20:01 +00001539 (void) EqualizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001540 break;
1541 }
1542 if (LocaleCompare("evaluate",option+1) == 0)
1543 {
1544 double
1545 constant;
1546
1547 MagickEvaluateOperator
1548 op;
1549
cristy6fccee12011-10-20 18:43:18 +00001550 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyd42d9952011-07-08 14:21:50 +00001551 op=(MagickEvaluateOperator) ParseCommandOption(
1552 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristy9b34e302011-11-05 02:15:45 +00001553 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1554 1.0);
cristyd42d9952011-07-08 14:21:50 +00001555 (void) EvaluateImage(*image,op,constant,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001556 break;
1557 }
1558 if (LocaleCompare("extent",option+1) == 0)
1559 {
1560 /*
1561 Set the image extent.
1562 */
cristy6fccee12011-10-20 18:43:18 +00001563 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001564 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1565 if (geometry.width == 0)
1566 geometry.width=(*image)->columns;
1567 if (geometry.height == 0)
1568 geometry.height=(*image)->rows;
1569 mogrify_image=ExtentImage(*image,&geometry,exception);
1570 break;
1571 }
1572 break;
1573 }
1574 case 'f':
1575 {
1576 if (LocaleCompare("family",option+1) == 0)
1577 {
1578 if (*option == '+')
1579 {
1580 if (draw_info->family != (char *) NULL)
1581 draw_info->family=DestroyString(draw_info->family);
1582 break;
1583 }
1584 (void) CloneString(&draw_info->family,argv[i+1]);
1585 break;
1586 }
1587 if (LocaleCompare("features",option+1) == 0)
1588 {
1589 if (*option == '+')
1590 {
1591 (void) DeleteImageArtifact(*image,"identify:features");
1592 break;
1593 }
1594 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1595 break;
1596 }
1597 if (LocaleCompare("fill",option+1) == 0)
1598 {
1599 ExceptionInfo
1600 *sans;
1601
cristy4c08aed2011-07-01 19:47:50 +00001602 GetPixelInfo(*image,&fill);
anthonydf8ebac2011-04-27 09:03:19 +00001603 if (*option == '+')
1604 {
cristy269c9412011-10-13 23:41:15 +00001605 (void) QueryColorCompliance("none",AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001606 exception);
1607 (void) QueryColorCompliance("none",AllCompliance,
1608 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001609 if (draw_info->fill_pattern != (Image *) NULL)
1610 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1611 break;
1612 }
1613 sans=AcquireExceptionInfo();
cristy269c9412011-10-13 23:41:15 +00001614 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
cristy9950d572011-10-01 18:22:35 +00001615 sans);
1616 status=QueryColorCompliance(argv[i+1],AllCompliance,
1617 &draw_info->fill,sans);
anthonydf8ebac2011-04-27 09:03:19 +00001618 sans=DestroyExceptionInfo(sans);
1619 if (status == MagickFalse)
1620 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1621 exception);
1622 break;
1623 }
1624 if (LocaleCompare("flip",option+1) == 0)
1625 {
1626 /*
1627 Flip image scanlines.
1628 */
cristy6fccee12011-10-20 18:43:18 +00001629 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001630 mogrify_image=FlipImage(*image,exception);
1631 break;
1632 }
anthonydf8ebac2011-04-27 09:03:19 +00001633 if (LocaleCompare("floodfill",option+1) == 0)
1634 {
cristy4c08aed2011-07-01 19:47:50 +00001635 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001636 target;
1637
1638 /*
1639 Floodfill image.
1640 */
cristy6fccee12011-10-20 18:43:18 +00001641 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001642 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
cristy269c9412011-10-13 23:41:15 +00001643 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00001644 exception);
cristyd42d9952011-07-08 14:21:50 +00001645 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
cristy189e84c2011-08-27 18:08:53 +00001646 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001647 break;
1648 }
anthony3d2f4862011-05-01 13:48:16 +00001649 if (LocaleCompare("flop",option+1) == 0)
1650 {
1651 /*
1652 Flop image scanlines.
1653 */
cristy6fccee12011-10-20 18:43:18 +00001654 (void) SyncImageSettings(mogrify_info,*image,exception);
anthony3d2f4862011-05-01 13:48:16 +00001655 mogrify_image=FlopImage(*image,exception);
1656 break;
1657 }
anthonydf8ebac2011-04-27 09:03:19 +00001658 if (LocaleCompare("font",option+1) == 0)
1659 {
1660 if (*option == '+')
1661 {
1662 if (draw_info->font != (char *) NULL)
1663 draw_info->font=DestroyString(draw_info->font);
1664 break;
1665 }
1666 (void) CloneString(&draw_info->font,argv[i+1]);
1667 break;
1668 }
1669 if (LocaleCompare("format",option+1) == 0)
1670 {
1671 format=argv[i+1];
1672 break;
1673 }
1674 if (LocaleCompare("frame",option+1) == 0)
1675 {
1676 FrameInfo
1677 frame_info;
1678
1679 /*
1680 Surround image with an ornamental border.
1681 */
cristy6fccee12011-10-20 18:43:18 +00001682 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001683 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1684 frame_info.width=geometry.width;
1685 frame_info.height=geometry.height;
1686 if ((flags & HeightValue) == 0)
1687 frame_info.height=geometry.width;
1688 frame_info.outer_bevel=geometry.x;
1689 frame_info.inner_bevel=geometry.y;
1690 frame_info.x=(ssize_t) frame_info.width;
1691 frame_info.y=(ssize_t) frame_info.height;
1692 frame_info.width=(*image)->columns+2*frame_info.width;
1693 frame_info.height=(*image)->rows+2*frame_info.height;
cristy633f0c62011-09-15 13:27:36 +00001694 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001695 break;
1696 }
1697 if (LocaleCompare("function",option+1) == 0)
1698 {
1699 char
1700 *arguments,
1701 token[MaxTextExtent];
1702
1703 const char
1704 *p;
1705
1706 double
1707 *parameters;
1708
1709 MagickFunction
1710 function;
1711
1712 register ssize_t
1713 x;
1714
1715 size_t
1716 number_parameters;
1717
1718 /*
1719 Function Modify Image Values
1720 */
cristy6fccee12011-10-20 18:43:18 +00001721 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001722 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1723 MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00001724 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1725 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001726 if (arguments == (char *) NULL)
1727 break;
1728 p=(char *) arguments;
1729 for (x=0; *p != '\0'; x++)
1730 {
1731 GetMagickToken(p,&p,token);
1732 if (*token == ',')
1733 GetMagickToken(p,&p,token);
1734 }
1735 number_parameters=(size_t) x;
1736 parameters=(double *) AcquireQuantumMemory(number_parameters,
1737 sizeof(*parameters));
1738 if (parameters == (double *) NULL)
1739 ThrowWandFatalException(ResourceLimitFatalError,
1740 "MemoryAllocationFailed",(*image)->filename);
1741 (void) ResetMagickMemory(parameters,0,number_parameters*
1742 sizeof(*parameters));
1743 p=(char *) arguments;
1744 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1745 {
1746 GetMagickToken(p,&p,token);
1747 if (*token == ',')
1748 GetMagickToken(p,&p,token);
cristydbdd0e32011-11-04 23:29:40 +00001749 parameters[x]=StringToDouble(token,(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001750 }
1751 arguments=DestroyString(arguments);
cristyd42d9952011-07-08 14:21:50 +00001752 (void) FunctionImage(*image,function,number_parameters,parameters,
1753 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001754 parameters=(double *) RelinquishMagickMemory(parameters);
1755 break;
1756 }
1757 break;
1758 }
1759 case 'g':
1760 {
1761 if (LocaleCompare("gamma",option+1) == 0)
1762 {
1763 /*
1764 Gamma image.
1765 */
cristy6fccee12011-10-20 18:43:18 +00001766 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001767 if (*option == '+')
cristydbdd0e32011-11-04 23:29:40 +00001768 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00001769 else
cristydbdd0e32011-11-04 23:29:40 +00001770 (void) GammaImage(*image,StringToDouble(argv[i+1],
cristyb3e7c6c2011-07-24 01:43:55 +00001771 (char **) NULL),exception);
anthonydf8ebac2011-04-27 09:03:19 +00001772 break;
1773 }
1774 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1775 (LocaleCompare("gaussian",option+1) == 0))
1776 {
1777 /*
1778 Gaussian blur image.
1779 */
cristy6fccee12011-10-20 18:43:18 +00001780 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001781 flags=ParseGeometry(argv[i+1],&geometry_info);
1782 if ((flags & SigmaValue) == 0)
1783 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00001784 if ((flags & XiValue) == 0)
1785 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00001786 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00001787 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001788 break;
1789 }
1790 if (LocaleCompare("geometry",option+1) == 0)
1791 {
1792 /*
1793 Record Image offset, Resize last image.
1794 */
cristy6fccee12011-10-20 18:43:18 +00001795 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001796 if (*option == '+')
1797 {
1798 if ((*image)->geometry != (char *) NULL)
1799 (*image)->geometry=DestroyString((*image)->geometry);
1800 break;
1801 }
1802 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1803 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1804 (void) CloneString(&(*image)->geometry,argv[i+1]);
1805 else
1806 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1807 (*image)->filter,(*image)->blur,exception);
1808 break;
1809 }
1810 if (LocaleCompare("gravity",option+1) == 0)
1811 {
1812 if (*option == '+')
1813 {
1814 draw_info->gravity=UndefinedGravity;
1815 break;
1816 }
1817 draw_info->gravity=(GravityType) ParseCommandOption(
1818 MagickGravityOptions,MagickFalse,argv[i+1]);
1819 break;
1820 }
1821 break;
1822 }
1823 case 'h':
1824 {
1825 if (LocaleCompare("highlight-color",option+1) == 0)
1826 {
1827 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1828 break;
1829 }
1830 break;
1831 }
1832 case 'i':
1833 {
1834 if (LocaleCompare("identify",option+1) == 0)
1835 {
1836 char
1837 *text;
1838
cristy6fccee12011-10-20 18:43:18 +00001839 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001840 if (format == (char *) NULL)
1841 {
cristya4037272011-08-28 15:11:39 +00001842 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1843 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001844 break;
1845 }
cristy018f07f2011-09-04 21:15:19 +00001846 text=InterpretImageProperties(mogrify_info,*image,format,
1847 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001848 if (text == (char *) NULL)
1849 break;
1850 (void) fputs(text,stdout);
1851 (void) fputc('\n',stdout);
1852 text=DestroyString(text);
1853 break;
1854 }
1855 if (LocaleCompare("implode",option+1) == 0)
1856 {
1857 /*
1858 Implode image.
1859 */
cristy6fccee12011-10-20 18:43:18 +00001860 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001861 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00001862 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1863 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001864 break;
1865 }
1866 if (LocaleCompare("interline-spacing",option+1) == 0)
1867 {
1868 if (*option == '+')
1869 (void) ParseGeometry("0",&geometry_info);
1870 else
1871 (void) ParseGeometry(argv[i+1],&geometry_info);
1872 draw_info->interline_spacing=geometry_info.rho;
1873 break;
1874 }
cristy28474bf2011-09-11 23:32:52 +00001875 if (LocaleCompare("interpolate",option+1) == 0)
1876 {
1877 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1878 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1879 break;
1880 }
anthonydf8ebac2011-04-27 09:03:19 +00001881 if (LocaleCompare("interword-spacing",option+1) == 0)
1882 {
1883 if (*option == '+')
1884 (void) ParseGeometry("0",&geometry_info);
1885 else
1886 (void) ParseGeometry(argv[i+1],&geometry_info);
1887 draw_info->interword_spacing=geometry_info.rho;
1888 break;
1889 }
1890 break;
1891 }
1892 case 'k':
1893 {
1894 if (LocaleCompare("kerning",option+1) == 0)
1895 {
1896 if (*option == '+')
1897 (void) ParseGeometry("0",&geometry_info);
1898 else
1899 (void) ParseGeometry(argv[i+1],&geometry_info);
1900 draw_info->kerning=geometry_info.rho;
1901 break;
1902 }
1903 break;
1904 }
1905 case 'l':
1906 {
1907 if (LocaleCompare("lat",option+1) == 0)
1908 {
1909 /*
1910 Local adaptive threshold image.
1911 */
cristy6fccee12011-10-20 18:43:18 +00001912 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001913 flags=ParseGeometry(argv[i+1],&geometry_info);
1914 if ((flags & PercentValue) != 0)
1915 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1916 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
cristyde5cc632011-07-18 14:47:00 +00001917 geometry_info.rho,(size_t) geometry_info.sigma,(double)
anthonydf8ebac2011-04-27 09:03:19 +00001918 geometry_info.xi,exception);
1919 break;
1920 }
1921 if (LocaleCompare("level",option+1) == 0)
1922 {
1923 MagickRealType
1924 black_point,
1925 gamma,
1926 white_point;
1927
1928 MagickStatusType
1929 flags;
1930
1931 /*
1932 Parse levels.
1933 */
cristy6fccee12011-10-20 18:43:18 +00001934 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001935 flags=ParseGeometry(argv[i+1],&geometry_info);
1936 black_point=geometry_info.rho;
1937 white_point=(MagickRealType) QuantumRange;
1938 if ((flags & SigmaValue) != 0)
1939 white_point=geometry_info.sigma;
1940 gamma=1.0;
1941 if ((flags & XiValue) != 0)
1942 gamma=geometry_info.xi;
1943 if ((flags & PercentValue) != 0)
1944 {
1945 black_point*=(MagickRealType) (QuantumRange/100.0);
1946 white_point*=(MagickRealType) (QuantumRange/100.0);
1947 }
1948 if ((flags & SigmaValue) == 0)
1949 white_point=(MagickRealType) QuantumRange-black_point;
1950 if ((*option == '+') || ((flags & AspectValue) != 0))
cristy7c0a0a42011-08-23 17:57:25 +00001951 (void) LevelizeImage(*image,black_point,white_point,gamma,
1952 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001953 else
cristy01e9afd2011-08-10 17:38:41 +00001954 (void) LevelImage(*image,black_point,white_point,gamma,
1955 exception);
anthonydf8ebac2011-04-27 09:03:19 +00001956 break;
1957 }
1958 if (LocaleCompare("level-colors",option+1) == 0)
1959 {
1960 char
1961 token[MaxTextExtent];
1962
1963 const char
1964 *p;
1965
cristy4c08aed2011-07-01 19:47:50 +00001966 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00001967 black_point,
1968 white_point;
1969
1970 p=(const char *) argv[i+1];
1971 GetMagickToken(p,&p,token); /* get black point color */
1972 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001973 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001974 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001975 else
cristy269c9412011-10-13 23:41:15 +00001976 (void) QueryColorCompliance("#000000",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001977 &black_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001978 if (isalpha((int) token[0]) || (token[0] == '#'))
1979 GetMagickToken(p,&p,token);
1980 if (*token == '\0')
1981 white_point=black_point; /* set everything to that color */
1982 else
1983 {
1984 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1985 GetMagickToken(p,&p,token); /* Get white point color. */
1986 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy269c9412011-10-13 23:41:15 +00001987 (void) QueryColorCompliance(token,AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001988 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001989 else
cristy269c9412011-10-13 23:41:15 +00001990 (void) QueryColorCompliance("#ffffff",AllCompliance,
cristy9950d572011-10-01 18:22:35 +00001991 &white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001992 }
cristy490408a2011-07-07 14:42:05 +00001993 (void) LevelImageColors(*image,&black_point,&white_point,
cristy7c0a0a42011-08-23 17:57:25 +00001994 *option == '+' ? MagickTrue : MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00001995 break;
1996 }
1997 if (LocaleCompare("linear-stretch",option+1) == 0)
1998 {
1999 double
2000 black_point,
2001 white_point;
2002
2003 MagickStatusType
2004 flags;
2005
cristy6fccee12011-10-20 18:43:18 +00002006 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002007 flags=ParseGeometry(argv[i+1],&geometry_info);
2008 black_point=geometry_info.rho;
2009 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2010 if ((flags & SigmaValue) != 0)
2011 white_point=geometry_info.sigma;
2012 if ((flags & PercentValue) != 0)
2013 {
2014 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2015 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2016 }
2017 if ((flags & SigmaValue) == 0)
2018 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2019 black_point;
cristy33bd5152011-08-24 01:42:24 +00002020 (void) LinearStretchImage(*image,black_point,white_point,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002021 break;
2022 }
2023 if (LocaleCompare("linewidth",option+1) == 0)
2024 {
cristy9b34e302011-11-05 02:15:45 +00002025 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002026 break;
2027 }
2028 if (LocaleCompare("liquid-rescale",option+1) == 0)
2029 {
2030 /*
2031 Liquid rescale image.
2032 */
cristy6fccee12011-10-20 18:43:18 +00002033 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002034 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2035 if ((flags & XValue) == 0)
2036 geometry.x=1;
2037 if ((flags & YValue) == 0)
2038 geometry.y=0;
2039 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2040 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2041 break;
2042 }
2043 if (LocaleCompare("lowlight-color",option+1) == 0)
2044 {
2045 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2046 break;
2047 }
2048 break;
2049 }
2050 case 'm':
2051 {
2052 if (LocaleCompare("map",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00002053 {
cristy3ed852e2009-09-05 21:47:34 +00002054 Image
anthonydf8ebac2011-04-27 09:03:19 +00002055 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002056
anthonydf8ebac2011-04-27 09:03:19 +00002057 /*
2058 Transform image colors to match this set of colors.
2059 */
cristy6fccee12011-10-20 18:43:18 +00002060 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002061 if (*option == '+')
2062 break;
2063 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2064 if (remap_image == (Image *) NULL)
2065 break;
cristy018f07f2011-09-04 21:15:19 +00002066 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002067 remap_image=DestroyImage(remap_image);
2068 break;
2069 }
2070 if (LocaleCompare("mask",option+1) == 0)
2071 {
2072 Image
2073 *mask;
2074
cristy6fccee12011-10-20 18:43:18 +00002075 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002076 if (*option == '+')
2077 {
2078 /*
2079 Remove a mask.
2080 */
cristy018f07f2011-09-04 21:15:19 +00002081 (void) SetImageMask(*image,(Image *) NULL,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002082 break;
2083 }
2084 /*
2085 Set the image mask.
2086 */
2087 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2088 if (mask == (Image *) NULL)
2089 break;
cristy018f07f2011-09-04 21:15:19 +00002090 (void) SetImageMask(*image,mask,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002091 mask=DestroyImage(mask);
anthonydf8ebac2011-04-27 09:03:19 +00002092 break;
2093 }
2094 if (LocaleCompare("matte",option+1) == 0)
2095 {
2096 (void) SetImageAlphaChannel(*image,(*option == '-') ?
cristy63240882011-08-05 19:05:27 +00002097 SetAlphaChannel : DeactivateAlphaChannel,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002098 break;
2099 }
2100 if (LocaleCompare("median",option+1) == 0)
2101 {
2102 /*
2103 Median filter image.
2104 */
cristy6fccee12011-10-20 18:43:18 +00002105 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyf36cbcb2011-09-07 13:28:22 +00002106 flags=ParseGeometry(argv[i+1],&geometry_info);
2107 if ((flags & SigmaValue) == 0)
2108 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002109 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002110 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002111 break;
2112 }
2113 if (LocaleCompare("mode",option+1) == 0)
2114 {
2115 /*
2116 Mode image.
2117 */
cristy6fccee12011-10-20 18:43:18 +00002118 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyf36cbcb2011-09-07 13:28:22 +00002119 flags=ParseGeometry(argv[i+1],&geometry_info);
2120 if ((flags & SigmaValue) == 0)
2121 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002122 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002123 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002124 break;
2125 }
2126 if (LocaleCompare("modulate",option+1) == 0)
2127 {
cristy6fccee12011-10-20 18:43:18 +00002128 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy33bd5152011-08-24 01:42:24 +00002129 (void) ModulateImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002130 break;
2131 }
2132 if (LocaleCompare("monitor",option+1) == 0)
2133 {
2134 if (*option == '+')
2135 {
2136 (void) SetImageProgressMonitor(*image,
2137 (MagickProgressMonitor) NULL,(void *) NULL);
2138 break;
2139 }
2140 (void) SetImageProgressMonitor(*image,MonitorProgress,
2141 (void *) NULL);
2142 break;
2143 }
2144 if (LocaleCompare("monochrome",option+1) == 0)
2145 {
cristy6fccee12011-10-20 18:43:18 +00002146 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy018f07f2011-09-04 21:15:19 +00002147 (void) SetImageType(*image,BilevelType,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002148 break;
2149 }
2150 if (LocaleCompare("morphology",option+1) == 0)
2151 {
2152 char
2153 token[MaxTextExtent];
2154
2155 const char
2156 *p;
2157
2158 KernelInfo
2159 *kernel;
2160
2161 MorphologyMethod
2162 method;
2163
2164 ssize_t
2165 iterations;
2166
2167 /*
2168 Morphological Image Operation
2169 */
cristy6fccee12011-10-20 18:43:18 +00002170 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002171 p=argv[i+1];
2172 GetMagickToken(p,&p,token);
cristy28474bf2011-09-11 23:32:52 +00002173 method=(MorphologyMethod) ParseCommandOption(
2174 MagickMorphologyOptions,MagickFalse,token);
anthonydf8ebac2011-04-27 09:03:19 +00002175 iterations=1L;
2176 GetMagickToken(p,&p,token);
2177 if ((*p == ':') || (*p == ','))
2178 GetMagickToken(p,&p,token);
2179 if ((*p != '\0'))
2180 iterations=(ssize_t) StringToLong(p);
2181 kernel=AcquireKernelInfo(argv[i+2]);
2182 if (kernel == (KernelInfo *) NULL)
2183 {
2184 (void) ThrowMagickException(exception,GetMagickModule(),
2185 OptionError,"UnabletoParseKernel","morphology");
2186 status=MagickFalse;
2187 break;
2188 }
cristyf4ad9df2011-07-08 16:49:03 +00002189 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2190 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002191 kernel=DestroyKernelInfo(kernel);
2192 break;
2193 }
2194 if (LocaleCompare("motion-blur",option+1) == 0)
2195 {
2196 /*
2197 Motion blur image.
2198 */
cristy6fccee12011-10-20 18:43:18 +00002199 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002200 flags=ParseGeometry(argv[i+1],&geometry_info);
2201 if ((flags & SigmaValue) == 0)
2202 geometry_info.sigma=1.0;
cristyf4ad9df2011-07-08 16:49:03 +00002203 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
cristy7497f482011-12-08 01:57:31 +00002204 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002205 break;
2206 }
2207 break;
2208 }
2209 case 'n':
2210 {
2211 if (LocaleCompare("negate",option+1) == 0)
2212 {
cristy6fccee12011-10-20 18:43:18 +00002213 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy50fbc382011-07-07 02:19:17 +00002214 (void) NegateImage(*image,*option == '+' ? MagickTrue :
cristyb3e7c6c2011-07-24 01:43:55 +00002215 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002216 break;
2217 }
2218 if (LocaleCompare("noise",option+1) == 0)
2219 {
cristy6fccee12011-10-20 18:43:18 +00002220 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002221 if (*option == '-')
2222 {
cristyf36cbcb2011-09-07 13:28:22 +00002223 flags=ParseGeometry(argv[i+1],&geometry_info);
2224 if ((flags & SigmaValue) == 0)
2225 geometry_info.sigma=geometry_info.rho;
cristyf4ad9df2011-07-08 16:49:03 +00002226 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
cristyf36cbcb2011-09-07 13:28:22 +00002227 geometry_info.rho,(size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002228 }
2229 else
2230 {
2231 NoiseType
2232 noise;
2233
2234 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2235 MagickFalse,argv[i+1]);
cristy9ed1f812011-10-08 02:00:08 +00002236 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002237 }
2238 break;
2239 }
2240 if (LocaleCompare("normalize",option+1) == 0)
2241 {
cristy6fccee12011-10-20 18:43:18 +00002242 (void) SyncImageSettings(mogrify_info,*image,exception);
cristye23ec9d2011-08-16 18:15:40 +00002243 (void) NormalizeImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002244 break;
2245 }
2246 break;
2247 }
2248 case 'o':
2249 {
2250 if (LocaleCompare("opaque",option+1) == 0)
2251 {
cristy4c08aed2011-07-01 19:47:50 +00002252 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00002253 target;
2254
cristy6fccee12011-10-20 18:43:18 +00002255 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy269c9412011-10-13 23:41:15 +00002256 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00002257 exception);
cristyd42d9952011-07-08 14:21:50 +00002258 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
cristy189e84c2011-08-27 18:08:53 +00002259 MagickFalse : MagickTrue,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002260 break;
2261 }
2262 if (LocaleCompare("ordered-dither",option+1) == 0)
2263 {
cristy6fccee12011-10-20 18:43:18 +00002264 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy13020672011-07-08 02:33:26 +00002265 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002266 break;
2267 }
2268 break;
2269 }
2270 case 'p':
2271 {
2272 if (LocaleCompare("paint",option+1) == 0)
2273 {
cristy6fccee12011-10-20 18:43:18 +00002274 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002275 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy14973ba2011-08-27 23:48:07 +00002276 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2277 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002278 break;
2279 }
2280 if (LocaleCompare("pen",option+1) == 0)
2281 {
2282 if (*option == '+')
2283 {
cristy9950d572011-10-01 18:22:35 +00002284 (void) QueryColorCompliance("none",AllCompliance,
2285 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002286 break;
2287 }
cristy9950d572011-10-01 18:22:35 +00002288 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2289 &draw_info->fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002290 break;
2291 }
2292 if (LocaleCompare("pointsize",option+1) == 0)
2293 {
2294 if (*option == '+')
2295 (void) ParseGeometry("12",&geometry_info);
2296 else
2297 (void) ParseGeometry(argv[i+1],&geometry_info);
2298 draw_info->pointsize=geometry_info.rho;
2299 break;
2300 }
2301 if (LocaleCompare("polaroid",option+1) == 0)
2302 {
2303 double
2304 angle;
2305
2306 RandomInfo
2307 *random_info;
2308
2309 /*
2310 Simulate a Polaroid picture.
2311 */
cristy6fccee12011-10-20 18:43:18 +00002312 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002313 random_info=AcquireRandomInfo();
2314 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2315 random_info=DestroyRandomInfo(random_info);
2316 if (*option == '-')
2317 {
2318 SetGeometryInfo(&geometry_info);
2319 flags=ParseGeometry(argv[i+1],&geometry_info);
2320 angle=geometry_info.rho;
2321 }
cristy5c4e2582011-09-11 19:21:03 +00002322 mogrify_image=PolaroidImage(*image,draw_info,angle,
cristy28474bf2011-09-11 23:32:52 +00002323 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002324 break;
2325 }
2326 if (LocaleCompare("posterize",option+1) == 0)
2327 {
2328 /*
2329 Posterize image.
2330 */
cristy6fccee12011-10-20 18:43:18 +00002331 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002332 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy018f07f2011-09-04 21:15:19 +00002333 quantize_info->dither,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002334 break;
2335 }
2336 if (LocaleCompare("preview",option+1) == 0)
2337 {
2338 PreviewType
2339 preview_type;
2340
2341 /*
2342 Preview image.
2343 */
cristy6fccee12011-10-20 18:43:18 +00002344 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002345 if (*option == '+')
2346 preview_type=UndefinedPreview;
2347 else
cristy28474bf2011-09-11 23:32:52 +00002348 preview_type=(PreviewType) ParseCommandOption(
2349 MagickPreviewOptions,MagickFalse,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002350 mogrify_image=PreviewImage(*image,preview_type,exception);
2351 break;
2352 }
2353 if (LocaleCompare("profile",option+1) == 0)
2354 {
2355 const char
2356 *name;
2357
2358 const StringInfo
2359 *profile;
2360
2361 Image
2362 *profile_image;
2363
2364 ImageInfo
2365 *profile_info;
2366
cristy6fccee12011-10-20 18:43:18 +00002367 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002368 if (*option == '+')
2369 {
2370 /*
2371 Remove a profile from the image.
2372 */
2373 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
cristy092d71c2011-10-14 18:01:29 +00002374 NULL,0,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002375 break;
2376 }
2377 /*
2378 Associate a profile with the image.
2379 */
2380 profile_info=CloneImageInfo(mogrify_info);
2381 profile=GetImageProfile(*image,"iptc");
2382 if (profile != (StringInfo *) NULL)
2383 profile_info->profile=(void *) CloneStringInfo(profile);
2384 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2385 profile_info=DestroyImageInfo(profile_info);
2386 if (profile_image == (Image *) NULL)
2387 {
2388 StringInfo
2389 *profile;
2390
2391 profile_info=CloneImageInfo(mogrify_info);
2392 (void) CopyMagickString(profile_info->filename,argv[i+1],
2393 MaxTextExtent);
2394 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2395 if (profile != (StringInfo *) NULL)
2396 {
2397 (void) ProfileImage(*image,profile_info->magick,
2398 GetStringInfoDatum(profile),(size_t)
cristy3fac9ec2011-11-17 18:04:39 +00002399 GetStringInfoLength(profile),exception);
anthonydf8ebac2011-04-27 09:03:19 +00002400 profile=DestroyStringInfo(profile);
2401 }
2402 profile_info=DestroyImageInfo(profile_info);
2403 break;
2404 }
2405 ResetImageProfileIterator(profile_image);
2406 name=GetNextImageProfile(profile_image);
2407 while (name != (const char *) NULL)
2408 {
2409 profile=GetImageProfile(profile_image,name);
2410 if (profile != (StringInfo *) NULL)
2411 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
cristy3fac9ec2011-11-17 18:04:39 +00002412 (size_t) GetStringInfoLength(profile),exception);
anthonydf8ebac2011-04-27 09:03:19 +00002413 name=GetNextImageProfile(profile_image);
2414 }
2415 profile_image=DestroyImage(profile_image);
2416 break;
2417 }
2418 break;
2419 }
2420 case 'q':
2421 {
2422 if (LocaleCompare("quantize",option+1) == 0)
2423 {
2424 if (*option == '+')
2425 {
2426 quantize_info->colorspace=UndefinedColorspace;
2427 break;
2428 }
2429 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2430 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2431 break;
2432 }
2433 break;
2434 }
2435 case 'r':
2436 {
2437 if (LocaleCompare("radial-blur",option+1) == 0)
2438 {
2439 /*
2440 Radial blur image.
2441 */
cristy6fccee12011-10-20 18:43:18 +00002442 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy6435bd92011-09-10 02:10:07 +00002443 flags=ParseGeometry(argv[i+1],&geometry_info);
2444 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2445 geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002446 break;
2447 }
2448 if (LocaleCompare("raise",option+1) == 0)
2449 {
2450 /*
2451 Surround image with a raise of solid color.
2452 */
2453 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2454 if ((flags & SigmaValue) == 0)
2455 geometry.height=geometry.width;
2456 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
cristy6170ac32011-08-28 14:15:37 +00002457 MagickFalse,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002458 break;
2459 }
2460 if (LocaleCompare("random-threshold",option+1) == 0)
2461 {
2462 /*
2463 Threshold image.
2464 */
cristy6fccee12011-10-20 18:43:18 +00002465 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyf4ad9df2011-07-08 16:49:03 +00002466 (void) RandomThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00002467 break;
2468 }
2469 if (LocaleCompare("recolor",option+1) == 0)
2470 {
2471 KernelInfo
2472 *kernel;
2473
cristy6fccee12011-10-20 18:43:18 +00002474 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002475 kernel=AcquireKernelInfo(argv[i+1]);
2476 if (kernel == (KernelInfo *) NULL)
2477 break;
2478 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2479 kernel=DestroyKernelInfo(kernel);
2480 break;
2481 }
2482 if (LocaleCompare("region",option+1) == 0)
2483 {
cristy6fccee12011-10-20 18:43:18 +00002484 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002485 if (region_image != (Image *) NULL)
2486 {
2487 /*
2488 Composite region.
2489 */
2490 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00002491 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
cristye941a752011-10-15 01:52:48 +00002492 region_geometry.x,region_geometry.y,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002493 *image=DestroyImage(*image);
2494 *image=region_image;
2495 region_image = (Image *) NULL;
2496 }
2497 if (*option == '+')
2498 break;
2499 /*
2500 Apply transformations to a selected region of the image.
2501 */
cristy3ed852e2009-09-05 21:47:34 +00002502 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2503 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002504 mogrify_image=CropImage(*image,&region_geometry,exception);
2505 if (mogrify_image == (Image *) NULL)
2506 break;
2507 region_image=(*image);
2508 *image=mogrify_image;
2509 mogrify_image=(Image *) NULL;
2510 break;
cristy3ed852e2009-09-05 21:47:34 +00002511 }
anthonydf8ebac2011-04-27 09:03:19 +00002512 if (LocaleCompare("render",option+1) == 0)
2513 {
cristy6fccee12011-10-20 18:43:18 +00002514 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002515 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2516 break;
2517 }
2518 if (LocaleCompare("remap",option+1) == 0)
2519 {
2520 Image
2521 *remap_image;
cristy3ed852e2009-09-05 21:47:34 +00002522
anthonydf8ebac2011-04-27 09:03:19 +00002523 /*
2524 Transform image colors to match this set of colors.
2525 */
cristy6fccee12011-10-20 18:43:18 +00002526 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002527 if (*option == '+')
2528 break;
2529 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2530 if (remap_image == (Image *) NULL)
2531 break;
cristy018f07f2011-09-04 21:15:19 +00002532 (void) RemapImage(quantize_info,*image,remap_image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002533 remap_image=DestroyImage(remap_image);
2534 break;
2535 }
2536 if (LocaleCompare("repage",option+1) == 0)
2537 {
2538 if (*option == '+')
2539 {
2540 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2541 break;
2542 }
2543 (void) ResetImagePage(*image,argv[i+1]);
anthonydf8ebac2011-04-27 09:03:19 +00002544 break;
2545 }
2546 if (LocaleCompare("resample",option+1) == 0)
2547 {
2548 /*
2549 Resample image.
2550 */
cristy6fccee12011-10-20 18:43:18 +00002551 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002552 flags=ParseGeometry(argv[i+1],&geometry_info);
2553 if ((flags & SigmaValue) == 0)
2554 geometry_info.sigma=geometry_info.rho;
2555 mogrify_image=ResampleImage(*image,geometry_info.rho,
2556 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2557 break;
2558 }
2559 if (LocaleCompare("resize",option+1) == 0)
2560 {
2561 /*
2562 Resize image.
2563 */
cristy6fccee12011-10-20 18:43:18 +00002564 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002565 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2566 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2567 (*image)->filter,(*image)->blur,exception);
2568 break;
2569 }
2570 if (LocaleCompare("roll",option+1) == 0)
2571 {
2572 /*
2573 Roll image.
2574 */
cristy6fccee12011-10-20 18:43:18 +00002575 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002576 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2577 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2578 break;
2579 }
2580 if (LocaleCompare("rotate",option+1) == 0)
2581 {
2582 char
2583 *geometry;
2584
2585 /*
2586 Check for conditional image rotation.
2587 */
cristy6fccee12011-10-20 18:43:18 +00002588 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002589 if (strchr(argv[i+1],'>') != (char *) NULL)
2590 if ((*image)->columns <= (*image)->rows)
2591 break;
2592 if (strchr(argv[i+1],'<') != (char *) NULL)
2593 if ((*image)->columns >= (*image)->rows)
2594 break;
2595 /*
2596 Rotate image.
2597 */
2598 geometry=ConstantString(argv[i+1]);
2599 (void) SubstituteString(&geometry,">","");
2600 (void) SubstituteString(&geometry,"<","");
2601 (void) ParseGeometry(geometry,&geometry_info);
2602 geometry=DestroyString(geometry);
2603 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2604 break;
2605 }
2606 break;
2607 }
2608 case 's':
2609 {
2610 if (LocaleCompare("sample",option+1) == 0)
2611 {
2612 /*
2613 Sample image with pixel replication.
2614 */
cristy6fccee12011-10-20 18:43:18 +00002615 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002616 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2617 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2618 exception);
2619 break;
2620 }
2621 if (LocaleCompare("scale",option+1) == 0)
2622 {
2623 /*
2624 Resize image.
2625 */
cristy6fccee12011-10-20 18:43:18 +00002626 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002627 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2628 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2629 exception);
2630 break;
2631 }
2632 if (LocaleCompare("selective-blur",option+1) == 0)
2633 {
2634 /*
2635 Selectively blur pixels within a contrast threshold.
2636 */
cristy6fccee12011-10-20 18:43:18 +00002637 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002638 flags=ParseGeometry(argv[i+1],&geometry_info);
2639 if ((flags & PercentValue) != 0)
2640 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristyf4ad9df2011-07-08 16:49:03 +00002641 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
cristy1e7aa312011-09-10 20:01:36 +00002642 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002643 break;
2644 }
2645 if (LocaleCompare("separate",option+1) == 0)
2646 {
2647 /*
2648 Break channels into separate images.
anthonydf8ebac2011-04-27 09:03:19 +00002649 */
cristy6fccee12011-10-20 18:43:18 +00002650 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy3139dc22011-07-08 00:11:42 +00002651 mogrify_image=SeparateImages(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002652 break;
2653 }
2654 if (LocaleCompare("sepia-tone",option+1) == 0)
2655 {
2656 double
2657 threshold;
2658
2659 /*
2660 Sepia-tone image.
2661 */
cristy6fccee12011-10-20 18:43:18 +00002662 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy9b34e302011-11-05 02:15:45 +00002663 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2664 1.0);
anthonydf8ebac2011-04-27 09:03:19 +00002665 mogrify_image=SepiaToneImage(*image,threshold,exception);
2666 break;
2667 }
2668 if (LocaleCompare("segment",option+1) == 0)
2669 {
2670 /*
2671 Segment image.
2672 */
cristy6fccee12011-10-20 18:43:18 +00002673 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002674 flags=ParseGeometry(argv[i+1],&geometry_info);
2675 if ((flags & SigmaValue) == 0)
2676 geometry_info.sigma=1.0;
2677 (void) SegmentImage(*image,(*image)->colorspace,
cristy018f07f2011-09-04 21:15:19 +00002678 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2679 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002680 break;
2681 }
2682 if (LocaleCompare("set",option+1) == 0)
2683 {
2684 char
2685 *value;
2686
2687 /*
2688 Set image option.
2689 */
2690 if (*option == '+')
2691 {
2692 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2693 (void) DeleteImageRegistry(argv[i+1]+9);
2694 else
2695 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2696 {
2697 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2698 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2699 }
2700 else
2701 (void) DeleteImageProperty(*image,argv[i+1]);
2702 break;
2703 }
cristy018f07f2011-09-04 21:15:19 +00002704 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2705 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002706 if (value == (char *) NULL)
2707 break;
2708 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2709 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2710 exception);
2711 else
2712 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2713 {
2714 (void) SetImageOption(image_info,argv[i+1]+7,value);
2715 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2716 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2717 }
2718 else
cristyd15e6592011-10-15 00:13:06 +00002719 (void) SetImageProperty(*image,argv[i+1],value,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002720 value=DestroyString(value);
2721 break;
2722 }
2723 if (LocaleCompare("shade",option+1) == 0)
2724 {
2725 /*
2726 Shade image.
2727 */
cristy6fccee12011-10-20 18:43:18 +00002728 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002729 flags=ParseGeometry(argv[i+1],&geometry_info);
2730 if ((flags & SigmaValue) == 0)
2731 geometry_info.sigma=1.0;
2732 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2733 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2734 break;
2735 }
2736 if (LocaleCompare("shadow",option+1) == 0)
2737 {
2738 /*
2739 Shadow image.
2740 */
cristy6fccee12011-10-20 18:43:18 +00002741 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002742 flags=ParseGeometry(argv[i+1],&geometry_info);
2743 if ((flags & SigmaValue) == 0)
2744 geometry_info.sigma=1.0;
2745 if ((flags & XiValue) == 0)
2746 geometry_info.xi=4.0;
2747 if ((flags & PsiValue) == 0)
2748 geometry_info.psi=4.0;
2749 mogrify_image=ShadowImage(*image,geometry_info.rho,
cristyeb6e6582011-12-09 09:14:23 +00002750 geometry_info.sigma,(*image)->bias,(ssize_t)
2751 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
2752 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002753 break;
2754 }
2755 if (LocaleCompare("sharpen",option+1) == 0)
2756 {
2757 /*
2758 Sharpen image.
2759 */
cristy6fccee12011-10-20 18:43:18 +00002760 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002761 flags=ParseGeometry(argv[i+1],&geometry_info);
2762 if ((flags & SigmaValue) == 0)
2763 geometry_info.sigma=1.0;
cristy05c0c9a2011-09-05 23:16:13 +00002764 if ((flags & XiValue) == 0)
2765 geometry_info.xi=0.0;
cristyf4ad9df2011-07-08 16:49:03 +00002766 mogrify_image=SharpenImage(*image,geometry_info.rho,
cristy05c0c9a2011-09-05 23:16:13 +00002767 geometry_info.sigma,geometry_info.xi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002768 break;
2769 }
2770 if (LocaleCompare("shave",option+1) == 0)
2771 {
2772 /*
2773 Shave the image edges.
2774 */
cristy6fccee12011-10-20 18:43:18 +00002775 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002776 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2777 mogrify_image=ShaveImage(*image,&geometry,exception);
2778 break;
2779 }
2780 if (LocaleCompare("shear",option+1) == 0)
2781 {
2782 /*
2783 Shear image.
2784 */
cristy6fccee12011-10-20 18:43:18 +00002785 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002786 flags=ParseGeometry(argv[i+1],&geometry_info);
2787 if ((flags & SigmaValue) == 0)
2788 geometry_info.sigma=geometry_info.rho;
2789 mogrify_image=ShearImage(*image,geometry_info.rho,
2790 geometry_info.sigma,exception);
2791 break;
2792 }
2793 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2794 {
2795 /*
2796 Sigmoidal non-linearity contrast control.
2797 */
cristy6fccee12011-10-20 18:43:18 +00002798 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002799 flags=ParseGeometry(argv[i+1],&geometry_info);
2800 if ((flags & SigmaValue) == 0)
2801 geometry_info.sigma=(double) QuantumRange/2.0;
2802 if ((flags & PercentValue) != 0)
2803 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2804 100.0;
cristy9ee60942011-07-06 14:54:38 +00002805 (void) SigmoidalContrastImage(*image,(*option == '-') ?
cristy33bd5152011-08-24 01:42:24 +00002806 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2807 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002808 break;
2809 }
2810 if (LocaleCompare("sketch",option+1) == 0)
2811 {
2812 /*
2813 Sketch image.
2814 */
cristy6fccee12011-10-20 18:43:18 +00002815 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002816 flags=ParseGeometry(argv[i+1],&geometry_info);
2817 if ((flags & SigmaValue) == 0)
2818 geometry_info.sigma=1.0;
2819 mogrify_image=SketchImage(*image,geometry_info.rho,
cristyf7ef0252011-09-09 14:50:06 +00002820 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002821 break;
2822 }
2823 if (LocaleCompare("solarize",option+1) == 0)
2824 {
2825 double
2826 threshold;
2827
cristy6fccee12011-10-20 18:43:18 +00002828 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy9b34e302011-11-05 02:15:45 +00002829 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2830 1.0);
cristy5cbc0162011-08-29 00:36:28 +00002831 (void) SolarizeImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002832 break;
2833 }
2834 if (LocaleCompare("sparse-color",option+1) == 0)
2835 {
2836 SparseColorMethod
2837 method;
2838
2839 char
2840 *arguments;
2841
2842 /*
2843 Sparse Color Interpolated Gradient
2844 */
cristy6fccee12011-10-20 18:43:18 +00002845 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002846 method=(SparseColorMethod) ParseCommandOption(
2847 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy018f07f2011-09-04 21:15:19 +00002848 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2849 exception);
anthonydf8ebac2011-04-27 09:03:19 +00002850 if (arguments == (char *) NULL)
2851 break;
cristy3884f692011-07-08 18:00:18 +00002852 mogrify_image=SparseColorOption(*image,method,arguments,
anthonydf8ebac2011-04-27 09:03:19 +00002853 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2854 arguments=DestroyString(arguments);
2855 break;
2856 }
2857 if (LocaleCompare("splice",option+1) == 0)
2858 {
2859 /*
2860 Splice a solid color into the image.
2861 */
cristy6fccee12011-10-20 18:43:18 +00002862 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002863 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2864 mogrify_image=SpliceImage(*image,&geometry,exception);
2865 break;
2866 }
2867 if (LocaleCompare("spread",option+1) == 0)
2868 {
2869 /*
2870 Spread an image.
2871 */
cristy6fccee12011-10-20 18:43:18 +00002872 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002873 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy5c4e2582011-09-11 19:21:03 +00002874 mogrify_image=SpreadImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00002875 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002876 break;
2877 }
2878 if (LocaleCompare("statistic",option+1) == 0)
2879 {
2880 StatisticType
2881 type;
2882
cristy6fccee12011-10-20 18:43:18 +00002883 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002884 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2885 MagickFalse,argv[i+1]);
2886 (void) ParseGeometry(argv[i+2],&geometry_info);
cristyf4ad9df2011-07-08 16:49:03 +00002887 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2888 (size_t) geometry_info.sigma,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002889 break;
2890 }
2891 if (LocaleCompare("stretch",option+1) == 0)
2892 {
2893 if (*option == '+')
2894 {
2895 draw_info->stretch=UndefinedStretch;
2896 break;
2897 }
2898 draw_info->stretch=(StretchType) ParseCommandOption(
2899 MagickStretchOptions,MagickFalse,argv[i+1]);
2900 break;
2901 }
2902 if (LocaleCompare("strip",option+1) == 0)
2903 {
2904 /*
2905 Strip image of profiles and comments.
2906 */
cristy6fccee12011-10-20 18:43:18 +00002907 (void) SyncImageSettings(mogrify_info,*image,exception);
cristye941a752011-10-15 01:52:48 +00002908 (void) StripImage(*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002909 break;
2910 }
2911 if (LocaleCompare("stroke",option+1) == 0)
2912 {
2913 ExceptionInfo
2914 *sans;
2915
2916 if (*option == '+')
2917 {
cristy9950d572011-10-01 18:22:35 +00002918 (void) QueryColorCompliance("none",AllCompliance,
2919 &draw_info->stroke,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002920 if (draw_info->stroke_pattern != (Image *) NULL)
2921 draw_info->stroke_pattern=DestroyImage(
2922 draw_info->stroke_pattern);
2923 break;
2924 }
2925 sans=AcquireExceptionInfo();
cristy9950d572011-10-01 18:22:35 +00002926 status=QueryColorCompliance(argv[i+1],AllCompliance,
2927 &draw_info->stroke,sans);
anthonydf8ebac2011-04-27 09:03:19 +00002928 sans=DestroyExceptionInfo(sans);
2929 if (status == MagickFalse)
2930 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2931 exception);
2932 break;
2933 }
2934 if (LocaleCompare("strokewidth",option+1) == 0)
2935 {
cristy9b34e302011-11-05 02:15:45 +00002936 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
anthonydf8ebac2011-04-27 09:03:19 +00002937 break;
2938 }
2939 if (LocaleCompare("style",option+1) == 0)
2940 {
2941 if (*option == '+')
2942 {
2943 draw_info->style=UndefinedStyle;
2944 break;
2945 }
2946 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2947 MagickFalse,argv[i+1]);
2948 break;
2949 }
2950 if (LocaleCompare("swirl",option+1) == 0)
2951 {
2952 /*
2953 Swirl image.
2954 */
cristy6fccee12011-10-20 18:43:18 +00002955 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002956 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy76f512e2011-09-12 01:26:56 +00002957 mogrify_image=SwirlImage(*image,geometry_info.rho,
2958 interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002959 break;
2960 }
2961 break;
2962 }
2963 case 't':
2964 {
2965 if (LocaleCompare("threshold",option+1) == 0)
2966 {
2967 double
2968 threshold;
2969
2970 /*
2971 Threshold image.
2972 */
cristy6fccee12011-10-20 18:43:18 +00002973 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002974 if (*option == '+')
anthony247a86d2011-05-03 13:18:18 +00002975 threshold=(double) QuantumRange/2;
anthonydf8ebac2011-04-27 09:03:19 +00002976 else
cristy9b34e302011-11-05 02:15:45 +00002977 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2978 1.0);
cristye941a752011-10-15 01:52:48 +00002979 (void) BilevelImage(*image,threshold,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002980 break;
2981 }
2982 if (LocaleCompare("thumbnail",option+1) == 0)
2983 {
2984 /*
2985 Thumbnail image.
2986 */
cristy6fccee12011-10-20 18:43:18 +00002987 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00002988 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2989 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2990 exception);
2991 break;
2992 }
2993 if (LocaleCompare("tile",option+1) == 0)
2994 {
2995 if (*option == '+')
2996 {
2997 if (draw_info->fill_pattern != (Image *) NULL)
2998 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2999 break;
3000 }
3001 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3002 exception);
3003 break;
3004 }
3005 if (LocaleCompare("tint",option+1) == 0)
3006 {
3007 /*
3008 Tint the image.
3009 */
cristy6fccee12011-10-20 18:43:18 +00003010 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy28474bf2011-09-11 23:32:52 +00003011 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003012 break;
3013 }
3014 if (LocaleCompare("transform",option+1) == 0)
3015 {
3016 /*
3017 Affine transform image.
3018 */
cristy6fccee12011-10-20 18:43:18 +00003019 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003020 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3021 exception);
3022 break;
3023 }
3024 if (LocaleCompare("transparent",option+1) == 0)
3025 {
cristy4c08aed2011-07-01 19:47:50 +00003026 PixelInfo
anthonydf8ebac2011-04-27 09:03:19 +00003027 target;
3028
cristy6fccee12011-10-20 18:43:18 +00003029 (void) SyncImageSettings(mogrify_info,*image,exception);
cristy269c9412011-10-13 23:41:15 +00003030 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
cristy9950d572011-10-01 18:22:35 +00003031 exception);
anthonydf8ebac2011-04-27 09:03:19 +00003032 (void) TransparentPaintImage(*image,&target,(Quantum)
cristy189e84c2011-08-27 18:08:53 +00003033 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
cristy82d7af52011-10-16 16:26:41 +00003034 exception);
anthonydf8ebac2011-04-27 09:03:19 +00003035 break;
3036 }
3037 if (LocaleCompare("transpose",option+1) == 0)
3038 {
3039 /*
3040 Transpose image scanlines.
3041 */
cristy6fccee12011-10-20 18:43:18 +00003042 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003043 mogrify_image=TransposeImage(*image,exception);
3044 break;
3045 }
3046 if (LocaleCompare("transverse",option+1) == 0)
3047 {
3048 /*
3049 Transverse image scanlines.
3050 */
cristy6fccee12011-10-20 18:43:18 +00003051 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003052 mogrify_image=TransverseImage(*image,exception);
3053 break;
3054 }
3055 if (LocaleCompare("treedepth",option+1) == 0)
3056 {
3057 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3058 break;
3059 }
3060 if (LocaleCompare("trim",option+1) == 0)
3061 {
3062 /*
3063 Trim image.
3064 */
cristy6fccee12011-10-20 18:43:18 +00003065 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003066 mogrify_image=TrimImage(*image,exception);
3067 break;
3068 }
3069 if (LocaleCompare("type",option+1) == 0)
3070 {
3071 ImageType
3072 type;
3073
cristy6fccee12011-10-20 18:43:18 +00003074 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003075 if (*option == '+')
3076 type=UndefinedType;
3077 else
3078 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3079 argv[i+1]);
3080 (*image)->type=UndefinedType;
cristy018f07f2011-09-04 21:15:19 +00003081 (void) SetImageType(*image,type,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003082 break;
3083 }
3084 break;
3085 }
3086 case 'u':
3087 {
3088 if (LocaleCompare("undercolor",option+1) == 0)
3089 {
cristy9950d572011-10-01 18:22:35 +00003090 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3091 &draw_info->undercolor,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003092 break;
3093 }
3094 if (LocaleCompare("unique",option+1) == 0)
3095 {
3096 if (*option == '+')
3097 {
3098 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3099 break;
3100 }
3101 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3102 (void) SetImageArtifact(*image,"verbose","true");
3103 break;
3104 }
3105 if (LocaleCompare("unique-colors",option+1) == 0)
3106 {
3107 /*
3108 Unique image colors.
3109 */
cristy6fccee12011-10-20 18:43:18 +00003110 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003111 mogrify_image=UniqueImageColors(*image,exception);
3112 break;
3113 }
3114 if (LocaleCompare("unsharp",option+1) == 0)
3115 {
3116 /*
3117 Unsharp mask image.
3118 */
cristy6fccee12011-10-20 18:43:18 +00003119 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003120 flags=ParseGeometry(argv[i+1],&geometry_info);
3121 if ((flags & SigmaValue) == 0)
3122 geometry_info.sigma=1.0;
3123 if ((flags & XiValue) == 0)
3124 geometry_info.xi=1.0;
3125 if ((flags & PsiValue) == 0)
3126 geometry_info.psi=0.05;
cristyf4ad9df2011-07-08 16:49:03 +00003127 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3128 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003129 break;
3130 }
3131 break;
3132 }
3133 case 'v':
3134 {
3135 if (LocaleCompare("verbose",option+1) == 0)
3136 {
3137 (void) SetImageArtifact(*image,option+1,
3138 *option == '+' ? "false" : "true");
3139 break;
3140 }
3141 if (LocaleCompare("vignette",option+1) == 0)
3142 {
3143 /*
3144 Vignette image.
3145 */
cristy6fccee12011-10-20 18:43:18 +00003146 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003147 flags=ParseGeometry(argv[i+1],&geometry_info);
3148 if ((flags & SigmaValue) == 0)
3149 geometry_info.sigma=1.0;
3150 if ((flags & XiValue) == 0)
3151 geometry_info.xi=0.1*(*image)->columns;
3152 if ((flags & PsiValue) == 0)
3153 geometry_info.psi=0.1*(*image)->rows;
3154 mogrify_image=VignetteImage(*image,geometry_info.rho,
cristyeb6e6582011-12-09 09:14:23 +00003155 geometry_info.sigma,(*image)->bias,(ssize_t)
3156 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
3157 exception);
anthonydf8ebac2011-04-27 09:03:19 +00003158 break;
3159 }
3160 if (LocaleCompare("virtual-pixel",option+1) == 0)
3161 {
3162 if (*option == '+')
3163 {
3164 (void) SetImageVirtualPixelMethod(*image,
3165 UndefinedVirtualPixelMethod);
3166 break;
3167 }
3168 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3169 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3170 argv[i+1]));
3171 break;
3172 }
3173 break;
3174 }
3175 case 'w':
3176 {
3177 if (LocaleCompare("wave",option+1) == 0)
3178 {
3179 /*
3180 Wave image.
3181 */
cristy6fccee12011-10-20 18:43:18 +00003182 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003183 flags=ParseGeometry(argv[i+1],&geometry_info);
3184 if ((flags & SigmaValue) == 0)
3185 geometry_info.sigma=1.0;
3186 mogrify_image=WaveImage(*image,geometry_info.rho,
cristy28474bf2011-09-11 23:32:52 +00003187 geometry_info.sigma,interpolate_method,exception);
anthonydf8ebac2011-04-27 09:03:19 +00003188 break;
3189 }
3190 if (LocaleCompare("weight",option+1) == 0)
3191 {
3192 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3193 if (LocaleCompare(argv[i+1],"all") == 0)
3194 draw_info->weight=0;
3195 if (LocaleCompare(argv[i+1],"bold") == 0)
3196 draw_info->weight=700;
3197 if (LocaleCompare(argv[i+1],"bolder") == 0)
3198 if (draw_info->weight <= 800)
3199 draw_info->weight+=100;
3200 if (LocaleCompare(argv[i+1],"lighter") == 0)
3201 if (draw_info->weight >= 100)
3202 draw_info->weight-=100;
3203 if (LocaleCompare(argv[i+1],"normal") == 0)
3204 draw_info->weight=400;
3205 break;
3206 }
3207 if (LocaleCompare("white-threshold",option+1) == 0)
3208 {
3209 /*
3210 White threshold image.
3211 */
cristy6fccee12011-10-20 18:43:18 +00003212 (void) SyncImageSettings(mogrify_info,*image,exception);
cristyf4ad9df2011-07-08 16:49:03 +00003213 (void) WhiteThresholdImage(*image,argv[i+1],exception);
anthonydf8ebac2011-04-27 09:03:19 +00003214 break;
3215 }
3216 break;
3217 }
3218 default:
3219 break;
3220 }
3221 /*
3222 Replace current image with any image that was generated
3223 */
3224 if (mogrify_image != (Image *) NULL)
3225 ReplaceImageInListReturnLast(image,mogrify_image);
cristy3ed852e2009-09-05 21:47:34 +00003226 i+=count;
3227 }
3228 if (region_image != (Image *) NULL)
3229 {
anthonydf8ebac2011-04-27 09:03:19 +00003230 /*
3231 Composite transformed region onto image.
3232 */
cristy6fccee12011-10-20 18:43:18 +00003233 (void) SyncImageSettings(mogrify_info,*image,exception);
anthonya129f702011-04-14 01:08:48 +00003234 (void) CompositeImage(region_image,region_image->matte !=
cristyf4ad9df2011-07-08 16:49:03 +00003235 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
cristye941a752011-10-15 01:52:48 +00003236 region_geometry.x,region_geometry.y,exception);
cristy3ed852e2009-09-05 21:47:34 +00003237 *image=DestroyImage(*image);
3238 *image=region_image;
anthonye9c27192011-03-27 08:07:06 +00003239 region_image = (Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00003240 }
3241 /*
3242 Free resources.
3243 */
anthonydf8ebac2011-04-27 09:03:19 +00003244 quantize_info=DestroyQuantizeInfo(quantize_info);
3245 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003246 mogrify_info=DestroyImageInfo(mogrify_info);
cristy82d7af52011-10-16 16:26:41 +00003247 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
cristy72988482011-03-29 16:34:38 +00003248 return(status == 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00003249}
3250
3251/*
3252%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3253% %
3254% %
3255% %
cristy5063d812010-10-19 16:28:10 +00003256+ 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 +00003257% %
3258% %
3259% %
3260%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3261%
3262% MogrifyImageCommand() transforms an image or a sequence of images. These
3263% transforms include image scaling, image rotation, color reduction, and
3264% others. The transmogrified image overwrites the original image.
3265%
3266% The format of the MogrifyImageCommand method is:
3267%
3268% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3269% const char **argv,char **metadata,ExceptionInfo *exception)
3270%
3271% A description of each parameter follows:
3272%
3273% o image_info: the image info.
3274%
3275% o argc: the number of elements in the argument vector.
3276%
3277% o argv: A text array containing the command line arguments.
3278%
3279% o metadata: any metadata is returned here.
3280%
3281% o exception: return any errors or warnings in this structure.
3282%
3283*/
3284
3285static MagickBooleanType MogrifyUsage(void)
3286{
3287 static const char
3288 *miscellaneous[]=
3289 {
3290 "-debug events display copious debugging information",
3291 "-help print program options",
3292 "-list type print a list of supported option arguments",
3293 "-log format format of debugging information",
3294 "-version print version information",
3295 (char *) NULL
3296 },
3297 *operators[]=
3298 {
3299 "-adaptive-blur geometry",
3300 " adaptively blur pixels; decrease effect near edges",
3301 "-adaptive-resize geometry",
3302 " adaptively resize image using 'mesh' interpolation",
3303 "-adaptive-sharpen geometry",
3304 " adaptively sharpen pixels; increase effect near edges",
3305 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3306 " transparent, extract, background, or shape",
3307 "-annotate geometry text",
3308 " annotate the image with text",
3309 "-auto-gamma automagically adjust gamma level of image",
3310 "-auto-level automagically adjust color levels of image",
3311 "-auto-orient automagically orient (rotate) image",
3312 "-bench iterations measure performance",
3313 "-black-threshold value",
3314 " force all pixels below the threshold into black",
3315 "-blue-shift simulate a scene at nighttime in the moonlight",
3316 "-blur geometry reduce image noise and reduce detail levels",
3317 "-border geometry surround image with a border of color",
3318 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003319 "-brightness-contrast geometry",
3320 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003321 "-cdl filename color correct with a color decision list",
cristy05c0c9a2011-09-05 23:16:13 +00003322 "-charcoal geometry simulate a charcoal drawing",
cristy3ed852e2009-09-05 21:47:34 +00003323 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003324 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003325 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003326 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003327 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003328 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003329 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003330 "-contrast enhance or reduce the image contrast",
3331 "-contrast-stretch geometry",
3332 " improve contrast by `stretching' the intensity range",
3333 "-convolve coefficients",
3334 " apply a convolution kernel to the image",
3335 "-cycle amount cycle the image colormap",
3336 "-decipher filename convert cipher pixels to plain pixels",
3337 "-deskew threshold straighten an image",
3338 "-despeckle reduce the speckles within an image",
3339 "-distort method args",
3340 " distort images according to given method ad args",
3341 "-draw string annotate the image with a graphic primitive",
3342 "-edge radius apply a filter to detect edges in the image",
3343 "-encipher filename convert plain pixels to cipher pixels",
3344 "-emboss radius emboss an image",
3345 "-enhance apply a digital filter to enhance a noisy image",
3346 "-equalize perform histogram equalization to an image",
3347 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003348 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003349 "-extent geometry set the image size",
3350 "-extract geometry extract area from image",
3351 "-fft implements the discrete Fourier transform (DFT)",
3352 "-flip flip image vertically",
3353 "-floodfill geometry color",
3354 " floodfill the image with color",
3355 "-flop flop image horizontally",
3356 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003357 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003358 " apply function over image values",
3359 "-gamma value level of gamma correction",
3360 "-gaussian-blur geometry",
3361 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003362 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003363 "-identify identify the format and characteristics of the image",
3364 "-ift implements the inverse discrete Fourier transform (DFT)",
3365 "-implode amount implode image pixels about the center",
3366 "-lat geometry local adaptive thresholding",
3367 "-layers method optimize, merge, or compare image layers",
3368 "-level value adjust the level of image contrast",
3369 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003370 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003371 "-linear-stretch geometry",
3372 " improve contrast by `stretching with saturation'",
3373 "-liquid-rescale geometry",
3374 " rescale image with seam-carving",
cristy3c741502011-04-01 23:21:16 +00003375 "-median geometry apply a median filter to the image",
glennrp30d2dc62011-06-25 03:17:16 +00003376 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003377 "-modulate value vary the brightness, saturation, and hue",
3378 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003379 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003380 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003381 "-motion-blur geometry",
3382 " simulate motion blur",
3383 "-negate replace every pixel with its complementary color ",
cristy3c741502011-04-01 23:21:16 +00003384 "-noise geometry add or reduce noise in an image",
cristy3ed852e2009-09-05 21:47:34 +00003385 "-normalize transform image to span the full range of colors",
3386 "-opaque color change this color to the fill color",
3387 "-ordered-dither NxN",
3388 " add a noise pattern to the image with specific",
3389 " amplitudes",
3390 "-paint radius simulate an oil painting",
3391 "-polaroid angle simulate a Polaroid picture",
3392 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003393 "-profile filename add, delete, or apply an image profile",
3394 "-quantize colorspace reduce colors in this colorspace",
3395 "-radial-blur angle radial blur the image",
3396 "-raise value lighten/darken image edges to create a 3-D effect",
3397 "-random-threshold low,high",
3398 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003399 "-region geometry apply options to a portion of the image",
3400 "-render render vector graphics",
3401 "-repage geometry size and location of an image canvas",
3402 "-resample geometry change the resolution of an image",
3403 "-resize geometry resize the image",
3404 "-roll geometry roll an image vertically or horizontally",
3405 "-rotate degrees apply Paeth rotation to the image",
3406 "-sample geometry scale image with pixel sampling",
3407 "-scale geometry scale the image",
3408 "-segment values segment an image",
3409 "-selective-blur geometry",
3410 " selectively blur pixels within a contrast threshold",
3411 "-sepia-tone threshold",
3412 " simulate a sepia-toned photo",
3413 "-set property value set an image property",
3414 "-shade degrees shade the image using a distant light source",
3415 "-shadow geometry simulate an image shadow",
3416 "-sharpen geometry sharpen the image",
3417 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003418 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003419 "-sigmoidal-contrast geometry",
3420 " increase the contrast without saturating highlights or shadows",
3421 "-sketch geometry simulate a pencil sketch",
3422 "-solarize threshold negate all pixels above the threshold level",
3423 "-sparse-color method args",
3424 " fill in a image based on a few color points",
3425 "-splice geometry splice the background color into the image",
3426 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003427 "-statistic type radius",
3428 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003429 "-strip strip image of all profiles and comments",
3430 "-swirl degrees swirl image pixels about the center",
3431 "-threshold value threshold the image",
3432 "-thumbnail geometry create a thumbnail of the image",
3433 "-tile filename tile image when filling a graphic primitive",
3434 "-tint value tint the image with the fill color",
3435 "-transform affine transform image",
3436 "-transparent color make this color transparent within the image",
3437 "-transpose flip image vertically and rotate 90 degrees",
3438 "-transverse flop image horizontally and rotate 270 degrees",
3439 "-trim trim image edges",
3440 "-type type image type",
3441 "-unique-colors discard all but one of any pixel color",
3442 "-unsharp geometry sharpen the image",
3443 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003444 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003445 "-white-threshold value",
3446 " force all pixels above the threshold into white",
3447 (char *) NULL
3448 },
3449 *sequence_operators[]=
3450 {
cristy4285d782011-02-09 20:12:28 +00003451 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003452 "-clut apply a color lookup table to the image",
3453 "-coalesce merge a sequence of images",
3454 "-combine combine a sequence of images",
3455 "-composite composite image",
3456 "-crop geometry cut out a rectangular region of the image",
3457 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003458 "-evaluate-sequence operator",
3459 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003460 "-flatten flatten a sequence of images",
3461 "-fx expression apply mathematical expression to an image channel(s)",
3462 "-hald-clut apply a Hald color lookup table to the image",
3463 "-morph value morph an image sequence",
3464 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003465 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003466 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003467 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003468 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003469 "-write filename write images to this file",
3470 (char *) NULL
3471 },
3472 *settings[]=
3473 {
3474 "-adjoin join images into a single multi-image file",
3475 "-affine matrix affine transform matrix",
3476 "-alpha option activate, deactivate, reset, or set the alpha channel",
3477 "-antialias remove pixel-aliasing",
3478 "-authenticate password",
3479 " decipher image with this password",
3480 "-attenuate value lessen (or intensify) when adding noise to an image",
3481 "-background color background color",
3482 "-bias value add bias when convolving an image",
3483 "-black-point-compensation",
3484 " use black point compensation",
3485 "-blue-primary point chromaticity blue primary point",
3486 "-bordercolor color border color",
3487 "-caption string assign a caption to an image",
3488 "-channel type apply option to select image channels",
3489 "-colors value preferred number of colors in the image",
3490 "-colorspace type alternate image colorspace",
3491 "-comment string annotate image with comment",
3492 "-compose operator set image composite operator",
3493 "-compress type type of pixel compression when writing the image",
3494 "-define format:option",
3495 " define one or more image format options",
3496 "-delay value display the next image after pausing",
3497 "-density geometry horizontal and vertical density of the image",
3498 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003499 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003500 "-display server get image or font from this X server",
3501 "-dispose method layer disposal method",
3502 "-dither method apply error diffusion to image",
3503 "-encoding type text encoding type",
3504 "-endian type endianness (MSB or LSB) of the image",
3505 "-family name render text with this font family",
3506 "-fill color color to use when filling a graphic primitive",
3507 "-filter type use this filter when resizing an image",
3508 "-font name render text with this font",
3509 "-format \"string\" output formatted image characteristics",
3510 "-fuzz distance colors within this distance are considered equal",
3511 "-gravity type horizontal and vertical text placement",
3512 "-green-primary point chromaticity green primary point",
3513 "-intent type type of rendering intent when managing the image color",
3514 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003515 "-interline-spacing value",
3516 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003517 "-interpolate method pixel color interpolation method",
3518 "-interword-spacing value",
3519 " set the space between two words",
3520 "-kerning value set the space between two letters",
3521 "-label string assign a label to an image",
3522 "-limit type value pixel cache resource limit",
3523 "-loop iterations add Netscape loop extension to your GIF animation",
3524 "-mask filename associate a mask with the image",
3525 "-mattecolor color frame color",
3526 "-monitor monitor progress",
3527 "-orient type image orientation",
3528 "-page geometry size and location of an image canvas (setting)",
3529 "-ping efficiently determine image attributes",
3530 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003531 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003532 "-preview type image preview type",
3533 "-quality value JPEG/MIFF/PNG compression level",
3534 "-quiet suppress all warning messages",
3535 "-red-primary point chromaticity red primary point",
3536 "-regard-warnings pay attention to warning messages",
3537 "-remap filename transform image colors to match this set of colors",
3538 "-respect-parentheses settings remain in effect until parenthesis boundary",
3539 "-sampling-factor geometry",
3540 " horizontal and vertical sampling factor",
3541 "-scene value image scene number",
3542 "-seed value seed a new sequence of pseudo-random numbers",
3543 "-size geometry width and height of image",
3544 "-stretch type render text with this font stretch",
3545 "-stroke color graphic primitive stroke color",
3546 "-strokewidth value graphic primitive stroke width",
3547 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003548 "-synchronize synchronize image to storage device",
3549 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003550 "-texture filename name of texture to tile onto the image background",
3551 "-tile-offset geometry",
3552 " tile offset",
3553 "-treedepth value color tree depth",
3554 "-transparent-color color",
3555 " transparent color",
3556 "-undercolor color annotation bounding box color",
3557 "-units type the units of image resolution",
3558 "-verbose print detailed information about the image",
3559 "-view FlashPix viewing transforms",
3560 "-virtual-pixel method",
3561 " virtual pixel access method",
3562 "-weight type render text with this font weight",
3563 "-white-point point chromaticity white point",
3564 (char *) NULL
3565 },
3566 *stack_operators[]=
3567 {
anthonyb69c4b32011-03-23 04:37:44 +00003568 "-delete indexes delete the image from the image sequence",
3569 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003570 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003571 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003572 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003573 "-swap indexes swap two images in the image sequence",
3574 (char *) NULL
3575 };
3576
3577 const char
3578 **p;
3579
cristybb503372010-05-27 20:51:26 +00003580 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003581 (void) printf("Copyright: %s\n",GetMagickCopyright());
3582 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003583 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3584 GetClientName());
3585 (void) printf("\nImage Settings:\n");
3586 for (p=settings; *p != (char *) NULL; p++)
3587 (void) printf(" %s\n",*p);
3588 (void) printf("\nImage Operators:\n");
3589 for (p=operators; *p != (char *) NULL; p++)
3590 (void) printf(" %s\n",*p);
3591 (void) printf("\nImage Sequence Operators:\n");
3592 for (p=sequence_operators; *p != (char *) NULL; p++)
3593 (void) printf(" %s\n",*p);
3594 (void) printf("\nImage Stack Operators:\n");
3595 for (p=stack_operators; *p != (char *) NULL; p++)
3596 (void) printf(" %s\n",*p);
3597 (void) printf("\nMiscellaneous Options:\n");
3598 for (p=miscellaneous; *p != (char *) NULL; p++)
3599 (void) printf(" %s\n",*p);
3600 (void) printf(
3601 "\nBy default, the image format of `file' is determined by its magic\n");
3602 (void) printf(
3603 "number. To specify a particular image format, precede the filename\n");
3604 (void) printf(
3605 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3606 (void) printf(
3607 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3608 (void) printf("'-' for standard input or output.\n");
3609 return(MagickFalse);
3610}
3611
3612WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3613 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3614{
3615#define DestroyMogrify() \
3616{ \
3617 if (format != (char *) NULL) \
3618 format=DestroyString(format); \
3619 if (path != (char *) NULL) \
3620 path=DestroyString(path); \
3621 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003622 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003623 argv[i]=DestroyString(argv[i]); \
3624 argv=(char **) RelinquishMagickMemory(argv); \
3625}
3626#define ThrowMogrifyException(asperity,tag,option) \
3627{ \
3628 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3629 option); \
3630 DestroyMogrify(); \
3631 return(MagickFalse); \
3632}
3633#define ThrowMogrifyInvalidArgumentException(option,argument) \
3634{ \
3635 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3636 "InvalidArgument","`%s': %s",argument,option); \
3637 DestroyMogrify(); \
3638 return(MagickFalse); \
3639}
3640
3641 char
3642 *format,
3643 *option,
3644 *path;
3645
3646 Image
3647 *image;
3648
3649 ImageStack
3650 image_stack[MaxImageStackDepth+1];
3651
cristy3ed852e2009-09-05 21:47:34 +00003652 MagickBooleanType
3653 global_colormap;
3654
3655 MagickBooleanType
3656 fire,
cristyebbcfea2011-02-25 02:43:54 +00003657 pend,
3658 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00003659
3660 MagickStatusType
3661 status;
3662
cristyebbcfea2011-02-25 02:43:54 +00003663 register ssize_t
3664 i;
3665
3666 ssize_t
3667 j,
3668 k;
3669
cristy3ed852e2009-09-05 21:47:34 +00003670 /*
3671 Set defaults.
3672 */
3673 assert(image_info != (ImageInfo *) NULL);
3674 assert(image_info->signature == MagickSignature);
3675 if (image_info->debug != MagickFalse)
3676 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3677 assert(exception != (ExceptionInfo *) NULL);
3678 if (argc == 2)
3679 {
3680 option=argv[1];
3681 if ((LocaleCompare("version",option+1) == 0) ||
3682 (LocaleCompare("-version",option+1) == 0))
3683 {
cristyb51dff52011-05-19 16:55:47 +00003684 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00003685 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00003686 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3687 GetMagickCopyright());
3688 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3689 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003690 return(MagickFalse);
3691 }
3692 }
3693 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00003694 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00003695 format=(char *) NULL;
3696 path=(char *) NULL;
3697 global_colormap=MagickFalse;
3698 k=0;
3699 j=1;
3700 NewImageStack();
3701 option=(char *) NULL;
3702 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00003703 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003704 status=MagickTrue;
3705 /*
3706 Parse command line.
3707 */
3708 ReadCommandlLine(argc,&argv);
3709 status=ExpandFilenames(&argc,&argv);
3710 if (status == MagickFalse)
3711 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3712 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00003713 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00003714 {
3715 option=argv[i];
3716 if (LocaleCompare(option,"(") == 0)
3717 {
3718 FireImageStack(MagickFalse,MagickTrue,pend);
3719 if (k == MaxImageStackDepth)
3720 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3721 option);
3722 PushImageStack();
3723 continue;
3724 }
3725 if (LocaleCompare(option,")") == 0)
3726 {
3727 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3728 if (k == 0)
3729 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3730 PopImageStack();
3731 continue;
3732 }
cristy042ee782011-04-22 18:48:30 +00003733 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00003734 {
3735 char
3736 backup_filename[MaxTextExtent],
3737 *filename;
3738
3739 Image
3740 *images;
3741
3742 /*
3743 Option is a file name: begin by reading image from specified file.
3744 */
3745 FireImageStack(MagickFalse,MagickFalse,pend);
3746 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00003747 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00003748 filename=argv[++i];
3749 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3750 images=ReadImages(image_info,exception);
3751 status&=(images != (Image *) NULL) &&
3752 (exception->severity < ErrorException);
3753 if (images == (Image *) NULL)
3754 continue;
cristydaa76602010-06-30 13:05:11 +00003755 if (format != (char *) NULL)
3756 (void) CopyMagickString(images->filename,images->magick_filename,
3757 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00003758 if (path != (char *) NULL)
3759 {
3760 GetPathComponent(option,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +00003761 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
cristy3ed852e2009-09-05 21:47:34 +00003762 path,*DirectorySeparator,filename);
3763 }
3764 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00003765 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00003766 AppendImageStack(images);
3767 FinalizeImageSettings(image_info,image,MagickFalse);
3768 if (global_colormap != MagickFalse)
3769 {
3770 QuantizeInfo
3771 *quantize_info;
3772
3773 quantize_info=AcquireQuantizeInfo(image_info);
cristy018f07f2011-09-04 21:15:19 +00003774 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
cristy3ed852e2009-09-05 21:47:34 +00003775 quantize_info=DestroyQuantizeInfo(quantize_info);
3776 }
3777 *backup_filename='\0';
3778 if ((LocaleCompare(image->filename,"-") != 0) &&
3779 (IsPathWritable(image->filename) != MagickFalse))
3780 {
cristybb503372010-05-27 20:51:26 +00003781 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003782 i;
3783
3784 /*
3785 Rename image file as backup.
3786 */
3787 (void) CopyMagickString(backup_filename,image->filename,
3788 MaxTextExtent);
3789 for (i=0; i < 6; i++)
3790 {
3791 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3792 if (IsPathAccessible(backup_filename) == MagickFalse)
3793 break;
3794 }
3795 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
cristy320684d2011-09-23 14:55:47 +00003796 (rename_utf8(image->filename,backup_filename) != 0))
cristy3ed852e2009-09-05 21:47:34 +00003797 *backup_filename='\0';
3798 }
3799 /*
3800 Write transmogrified image to disk.
3801 */
3802 image_info->synchronize=MagickTrue;
3803 status&=WriteImages(image_info,image,image->filename,exception);
3804 if ((status == MagickFalse) && (*backup_filename != '\0'))
cristy18c6c272011-09-23 14:40:37 +00003805 (void) remove_utf8(backup_filename);
cristy3ed852e2009-09-05 21:47:34 +00003806 RemoveAllImageStack();
3807 continue;
3808 }
3809 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3810 switch (*(option+1))
3811 {
3812 case 'a':
3813 {
3814 if (LocaleCompare("adaptive-blur",option+1) == 0)
3815 {
3816 i++;
cristybb503372010-05-27 20:51:26 +00003817 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003818 ThrowMogrifyException(OptionError,"MissingArgument",option);
3819 if (IsGeometry(argv[i]) == MagickFalse)
3820 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3821 break;
3822 }
3823 if (LocaleCompare("adaptive-resize",option+1) == 0)
3824 {
3825 i++;
cristybb503372010-05-27 20:51:26 +00003826 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003827 ThrowMogrifyException(OptionError,"MissingArgument",option);
3828 if (IsGeometry(argv[i]) == MagickFalse)
3829 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3830 break;
3831 }
3832 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3833 {
3834 i++;
cristybb503372010-05-27 20:51:26 +00003835 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003836 ThrowMogrifyException(OptionError,"MissingArgument",option);
3837 if (IsGeometry(argv[i]) == MagickFalse)
3838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3839 break;
3840 }
3841 if (LocaleCompare("affine",option+1) == 0)
3842 {
3843 if (*option == '+')
3844 break;
3845 i++;
cristybb503372010-05-27 20:51:26 +00003846 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003847 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy3ed852e2009-09-05 21:47:34 +00003848 break;
3849 }
3850 if (LocaleCompare("alpha",option+1) == 0)
3851 {
cristybb503372010-05-27 20:51:26 +00003852 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00003853 type;
3854
3855 if (*option == '+')
3856 break;
3857 i++;
cristybb503372010-05-27 20:51:26 +00003858 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003859 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00003860 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00003861 if (type < 0)
3862 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3863 argv[i]);
3864 break;
3865 }
3866 if (LocaleCompare("annotate",option+1) == 0)
3867 {
3868 if (*option == '+')
3869 break;
3870 i++;
cristybb503372010-05-27 20:51:26 +00003871 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003872 ThrowMogrifyException(OptionError,"MissingArgument",option);
3873 if (IsGeometry(argv[i]) == MagickFalse)
3874 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00003875 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003876 ThrowMogrifyException(OptionError,"MissingArgument",option);
3877 i++;
3878 break;
3879 }
3880 if (LocaleCompare("antialias",option+1) == 0)
3881 break;
3882 if (LocaleCompare("append",option+1) == 0)
3883 break;
3884 if (LocaleCompare("attenuate",option+1) == 0)
3885 {
3886 if (*option == '+')
3887 break;
3888 i++;
cristybb503372010-05-27 20:51:26 +00003889 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003890 ThrowMogrifyException(OptionError,"MissingArgument",option);
3891 if (IsGeometry(argv[i]) == MagickFalse)
3892 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3893 break;
3894 }
3895 if (LocaleCompare("authenticate",option+1) == 0)
3896 {
3897 if (*option == '+')
3898 break;
3899 i++;
cristybb503372010-05-27 20:51:26 +00003900 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003901 ThrowMogrifyException(OptionError,"MissingArgument",option);
3902 break;
3903 }
3904 if (LocaleCompare("auto-gamma",option+1) == 0)
3905 break;
3906 if (LocaleCompare("auto-level",option+1) == 0)
3907 break;
3908 if (LocaleCompare("auto-orient",option+1) == 0)
3909 break;
3910 if (LocaleCompare("average",option+1) == 0)
3911 break;
3912 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3913 }
3914 case 'b':
3915 {
3916 if (LocaleCompare("background",option+1) == 0)
3917 {
3918 if (*option == '+')
3919 break;
3920 i++;
cristybb503372010-05-27 20:51:26 +00003921 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003922 ThrowMogrifyException(OptionError,"MissingArgument",option);
3923 break;
3924 }
3925 if (LocaleCompare("bias",option+1) == 0)
3926 {
3927 if (*option == '+')
3928 break;
3929 i++;
cristybb503372010-05-27 20:51:26 +00003930 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00003931 ThrowMogrifyException(OptionError,"MissingArgument",option);
3932 if (IsGeometry(argv[i]) == MagickFalse)
3933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3934 break;
3935 }
3936 if (LocaleCompare("black-point-compensation",option+1) == 0)
3937 break;
3938 if (LocaleCompare("black-threshold",option+1) == 0)
3939 {
3940 if (*option == '+')
3941 break;
3942 i++;
cristybb503372010-05-27 20:51:26 +00003943 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003944 ThrowMogrifyException(OptionError,"MissingArgument",option);
3945 if (IsGeometry(argv[i]) == MagickFalse)
3946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3947 break;
3948 }
3949 if (LocaleCompare("blue-primary",option+1) == 0)
3950 {
3951 if (*option == '+')
3952 break;
3953 i++;
cristybb503372010-05-27 20:51:26 +00003954 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003955 ThrowMogrifyException(OptionError,"MissingArgument",option);
3956 if (IsGeometry(argv[i]) == MagickFalse)
3957 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3958 break;
3959 }
3960 if (LocaleCompare("blue-shift",option+1) == 0)
3961 {
3962 i++;
cristybb503372010-05-27 20:51:26 +00003963 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003964 ThrowMogrifyException(OptionError,"MissingArgument",option);
3965 if (IsGeometry(argv[i]) == MagickFalse)
3966 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3967 break;
3968 }
3969 if (LocaleCompare("blur",option+1) == 0)
3970 {
3971 i++;
cristybb503372010-05-27 20:51:26 +00003972 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003973 ThrowMogrifyException(OptionError,"MissingArgument",option);
3974 if (IsGeometry(argv[i]) == MagickFalse)
3975 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3976 break;
3977 }
3978 if (LocaleCompare("border",option+1) == 0)
3979 {
3980 if (*option == '+')
3981 break;
3982 i++;
cristybb503372010-05-27 20:51:26 +00003983 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003984 ThrowMogrifyException(OptionError,"MissingArgument",option);
3985 if (IsGeometry(argv[i]) == MagickFalse)
3986 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3987 break;
3988 }
3989 if (LocaleCompare("bordercolor",option+1) == 0)
3990 {
3991 if (*option == '+')
3992 break;
3993 i++;
cristybb503372010-05-27 20:51:26 +00003994 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00003995 ThrowMogrifyException(OptionError,"MissingArgument",option);
3996 break;
3997 }
3998 if (LocaleCompare("box",option+1) == 0)
3999 {
4000 if (*option == '+')
4001 break;
4002 i++;
cristybb503372010-05-27 20:51:26 +00004003 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004004 ThrowMogrifyException(OptionError,"MissingArgument",option);
4005 break;
4006 }
cristya28d6b82010-01-11 20:03:47 +00004007 if (LocaleCompare("brightness-contrast",option+1) == 0)
4008 {
4009 i++;
cristybb503372010-05-27 20:51:26 +00004010 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00004011 ThrowMogrifyException(OptionError,"MissingArgument",option);
4012 if (IsGeometry(argv[i]) == MagickFalse)
4013 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4014 break;
4015 }
cristy3ed852e2009-09-05 21:47:34 +00004016 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4017 }
4018 case 'c':
4019 {
4020 if (LocaleCompare("cache",option+1) == 0)
4021 {
4022 if (*option == '+')
4023 break;
4024 i++;
cristybb503372010-05-27 20:51:26 +00004025 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004026 ThrowMogrifyException(OptionError,"MissingArgument",option);
4027 if (IsGeometry(argv[i]) == MagickFalse)
4028 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4029 break;
4030 }
4031 if (LocaleCompare("caption",option+1) == 0)
4032 {
4033 if (*option == '+')
4034 break;
4035 i++;
cristybb503372010-05-27 20:51:26 +00004036 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004037 ThrowMogrifyException(OptionError,"MissingArgument",option);
4038 break;
4039 }
4040 if (LocaleCompare("channel",option+1) == 0)
4041 {
cristybb503372010-05-27 20:51:26 +00004042 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004043 channel;
4044
4045 if (*option == '+')
4046 break;
4047 i++;
cristybb503372010-05-27 20:51:26 +00004048 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004049 ThrowMogrifyException(OptionError,"MissingArgument",option);
4050 channel=ParseChannelOption(argv[i]);
4051 if (channel < 0)
4052 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4053 argv[i]);
4054 break;
4055 }
4056 if (LocaleCompare("cdl",option+1) == 0)
4057 {
4058 if (*option == '+')
4059 break;
4060 i++;
cristybb503372010-05-27 20:51:26 +00004061 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004062 ThrowMogrifyException(OptionError,"MissingArgument",option);
4063 break;
4064 }
4065 if (LocaleCompare("charcoal",option+1) == 0)
4066 {
4067 if (*option == '+')
4068 break;
4069 i++;
cristybb503372010-05-27 20:51:26 +00004070 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004071 ThrowMogrifyException(OptionError,"MissingArgument",option);
4072 if (IsGeometry(argv[i]) == MagickFalse)
4073 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4074 break;
4075 }
4076 if (LocaleCompare("chop",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 }
cristy1eb45dd2009-09-25 16:38:06 +00004087 if (LocaleCompare("clamp",option+1) == 0)
4088 break;
4089 if (LocaleCompare("clip",option+1) == 0)
4090 break;
cristy3ed852e2009-09-05 21:47:34 +00004091 if (LocaleCompare("clip-mask",option+1) == 0)
4092 {
4093 if (*option == '+')
4094 break;
4095 i++;
cristybb503372010-05-27 20:51:26 +00004096 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004097 ThrowMogrifyException(OptionError,"MissingArgument",option);
4098 break;
4099 }
4100 if (LocaleCompare("clut",option+1) == 0)
4101 break;
4102 if (LocaleCompare("coalesce",option+1) == 0)
4103 break;
4104 if (LocaleCompare("colorize",option+1) == 0)
4105 {
4106 if (*option == '+')
4107 break;
4108 i++;
cristybb503372010-05-27 20:51:26 +00004109 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004110 ThrowMogrifyException(OptionError,"MissingArgument",option);
4111 if (IsGeometry(argv[i]) == MagickFalse)
4112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4113 break;
4114 }
cristye6365592010-04-02 17:31:23 +00004115 if (LocaleCompare("color-matrix",option+1) == 0)
4116 {
cristyb6bd4ad2010-08-08 01:12:27 +00004117 KernelInfo
4118 *kernel_info;
4119
cristye6365592010-04-02 17:31:23 +00004120 if (*option == '+')
4121 break;
4122 i++;
cristybb503372010-05-27 20:51:26 +00004123 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004124 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004125 kernel_info=AcquireKernelInfo(argv[i]);
4126 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004127 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004128 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004129 break;
4130 }
cristy3ed852e2009-09-05 21:47:34 +00004131 if (LocaleCompare("colors",option+1) == 0)
4132 {
4133 if (*option == '+')
4134 break;
4135 i++;
cristybb503372010-05-27 20:51:26 +00004136 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004137 ThrowMogrifyException(OptionError,"MissingArgument",option);
4138 if (IsGeometry(argv[i]) == MagickFalse)
4139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4140 break;
4141 }
4142 if (LocaleCompare("colorspace",option+1) == 0)
4143 {
cristybb503372010-05-27 20:51:26 +00004144 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004145 colorspace;
4146
4147 if (*option == '+')
4148 break;
4149 i++;
cristybb503372010-05-27 20:51:26 +00004150 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004151 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004152 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004153 argv[i]);
4154 if (colorspace < 0)
4155 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4156 argv[i]);
4157 break;
4158 }
4159 if (LocaleCompare("combine",option+1) == 0)
4160 break;
4161 if (LocaleCompare("comment",option+1) == 0)
4162 {
4163 if (*option == '+')
4164 break;
4165 i++;
cristybb503372010-05-27 20:51:26 +00004166 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4168 break;
4169 }
4170 if (LocaleCompare("composite",option+1) == 0)
4171 break;
4172 if (LocaleCompare("compress",option+1) == 0)
4173 {
cristybb503372010-05-27 20:51:26 +00004174 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004175 compress;
4176
4177 if (*option == '+')
4178 break;
4179 i++;
cristybb503372010-05-27 20:51:26 +00004180 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004181 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004182 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004183 argv[i]);
4184 if (compress < 0)
4185 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4186 argv[i]);
4187 break;
4188 }
cristy22879752009-10-25 23:55:40 +00004189 if (LocaleCompare("concurrent",option+1) == 0)
4190 break;
cristy3ed852e2009-09-05 21:47:34 +00004191 if (LocaleCompare("contrast",option+1) == 0)
4192 break;
4193 if (LocaleCompare("contrast-stretch",option+1) == 0)
4194 {
4195 i++;
cristybb503372010-05-27 20:51:26 +00004196 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004197 ThrowMogrifyException(OptionError,"MissingArgument",option);
4198 if (IsGeometry(argv[i]) == MagickFalse)
4199 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4200 break;
4201 }
4202 if (LocaleCompare("convolve",option+1) == 0)
4203 {
cristyb6bd4ad2010-08-08 01:12:27 +00004204 KernelInfo
4205 *kernel_info;
4206
cristy3ed852e2009-09-05 21:47:34 +00004207 if (*option == '+')
4208 break;
4209 i++;
cristybb503372010-05-27 20:51:26 +00004210 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004211 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004212 kernel_info=AcquireKernelInfo(argv[i]);
4213 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004214 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004215 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004216 break;
4217 }
4218 if (LocaleCompare("crop",option+1) == 0)
4219 {
4220 if (*option == '+')
4221 break;
4222 i++;
cristybb503372010-05-27 20:51:26 +00004223 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004224 ThrowMogrifyException(OptionError,"MissingArgument",option);
4225 if (IsGeometry(argv[i]) == MagickFalse)
4226 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4227 break;
4228 }
4229 if (LocaleCompare("cycle",option+1) == 0)
4230 {
4231 if (*option == '+')
4232 break;
4233 i++;
cristybb503372010-05-27 20:51:26 +00004234 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004235 ThrowMogrifyException(OptionError,"MissingArgument",option);
4236 if (IsGeometry(argv[i]) == MagickFalse)
4237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4238 break;
4239 }
4240 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4241 }
4242 case 'd':
4243 {
4244 if (LocaleCompare("decipher",option+1) == 0)
4245 {
4246 if (*option == '+')
4247 break;
4248 i++;
cristybb503372010-05-27 20:51:26 +00004249 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004250 ThrowMogrifyException(OptionError,"MissingArgument",option);
4251 break;
4252 }
4253 if (LocaleCompare("deconstruct",option+1) == 0)
4254 break;
4255 if (LocaleCompare("debug",option+1) == 0)
4256 {
cristybb503372010-05-27 20:51:26 +00004257 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004258 event;
4259
4260 if (*option == '+')
4261 break;
4262 i++;
cristybb503372010-05-27 20:51:26 +00004263 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004264 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004265 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004266 if (event < 0)
4267 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4268 argv[i]);
4269 (void) SetLogEventMask(argv[i]);
4270 break;
4271 }
4272 if (LocaleCompare("define",option+1) == 0)
4273 {
4274 i++;
cristybb503372010-05-27 20:51:26 +00004275 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004276 ThrowMogrifyException(OptionError,"MissingArgument",option);
4277 if (*option == '+')
4278 {
4279 const char
4280 *define;
4281
4282 define=GetImageOption(image_info,argv[i]);
4283 if (define == (const char *) NULL)
4284 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4285 break;
4286 }
4287 break;
4288 }
4289 if (LocaleCompare("delay",option+1) == 0)
4290 {
4291 if (*option == '+')
4292 break;
4293 i++;
cristybb503372010-05-27 20:51:26 +00004294 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004295 ThrowMogrifyException(OptionError,"MissingArgument",option);
4296 if (IsGeometry(argv[i]) == MagickFalse)
4297 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4298 break;
4299 }
cristyecb10ff2011-03-22 13:14:03 +00004300 if (LocaleCompare("delete",option+1) == 0)
4301 {
4302 if (*option == '+')
4303 break;
4304 i++;
4305 if (i == (ssize_t) (argc-1))
4306 ThrowMogrifyException(OptionError,"MissingArgument",option);
4307 if (IsGeometry(argv[i]) == MagickFalse)
4308 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4309 break;
4310 }
cristy3ed852e2009-09-05 21:47:34 +00004311 if (LocaleCompare("density",option+1) == 0)
4312 {
4313 if (*option == '+')
4314 break;
4315 i++;
cristybb503372010-05-27 20:51:26 +00004316 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004317 ThrowMogrifyException(OptionError,"MissingArgument",option);
4318 if (IsGeometry(argv[i]) == MagickFalse)
4319 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4320 break;
4321 }
4322 if (LocaleCompare("depth",option+1) == 0)
4323 {
4324 if (*option == '+')
4325 break;
4326 i++;
cristybb503372010-05-27 20:51:26 +00004327 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004328 ThrowMogrifyException(OptionError,"MissingArgument",option);
4329 if (IsGeometry(argv[i]) == MagickFalse)
4330 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4331 break;
4332 }
4333 if (LocaleCompare("deskew",option+1) == 0)
4334 {
4335 if (*option == '+')
4336 break;
4337 i++;
cristybb503372010-05-27 20:51:26 +00004338 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004339 ThrowMogrifyException(OptionError,"MissingArgument",option);
4340 if (IsGeometry(argv[i]) == MagickFalse)
4341 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4342 break;
4343 }
4344 if (LocaleCompare("despeckle",option+1) == 0)
4345 break;
4346 if (LocaleCompare("dft",option+1) == 0)
4347 break;
cristyc9b12952010-03-28 01:12:28 +00004348 if (LocaleCompare("direction",option+1) == 0)
4349 {
cristybb503372010-05-27 20:51:26 +00004350 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004351 direction;
4352
4353 if (*option == '+')
4354 break;
4355 i++;
cristybb503372010-05-27 20:51:26 +00004356 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004357 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004358 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
cristyc9b12952010-03-28 01:12:28 +00004359 argv[i]);
4360 if (direction < 0)
4361 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4362 argv[i]);
4363 break;
4364 }
cristy3ed852e2009-09-05 21:47:34 +00004365 if (LocaleCompare("display",option+1) == 0)
4366 {
4367 if (*option == '+')
4368 break;
4369 i++;
cristybb503372010-05-27 20:51:26 +00004370 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004371 ThrowMogrifyException(OptionError,"MissingArgument",option);
4372 break;
4373 }
4374 if (LocaleCompare("dispose",option+1) == 0)
4375 {
cristybb503372010-05-27 20:51:26 +00004376 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004377 dispose;
4378
4379 if (*option == '+')
4380 break;
4381 i++;
cristybb503372010-05-27 20:51:26 +00004382 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004383 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004384 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004385 if (dispose < 0)
4386 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4387 argv[i]);
4388 break;
4389 }
4390 if (LocaleCompare("distort",option+1) == 0)
4391 {
cristybb503372010-05-27 20:51:26 +00004392 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004393 op;
4394
4395 i++;
cristybb503372010-05-27 20:51:26 +00004396 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004397 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004398 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004399 if (op < 0)
4400 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4401 argv[i]);
4402 i++;
cristybb503372010-05-27 20:51:26 +00004403 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004404 ThrowMogrifyException(OptionError,"MissingArgument",option);
4405 break;
4406 }
4407 if (LocaleCompare("dither",option+1) == 0)
4408 {
cristybb503372010-05-27 20:51:26 +00004409 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004410 method;
4411
4412 if (*option == '+')
4413 break;
4414 i++;
cristybb503372010-05-27 20:51:26 +00004415 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004416 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004417 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004418 if (method < 0)
4419 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4420 argv[i]);
4421 break;
4422 }
4423 if (LocaleCompare("draw",option+1) == 0)
4424 {
4425 if (*option == '+')
4426 break;
4427 i++;
cristybb503372010-05-27 20:51:26 +00004428 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004429 ThrowMogrifyException(OptionError,"MissingArgument",option);
4430 break;
4431 }
cristyecb10ff2011-03-22 13:14:03 +00004432 if (LocaleCompare("duplicate",option+1) == 0)
4433 {
4434 if (*option == '+')
4435 break;
4436 i++;
4437 if (i == (ssize_t) (argc-1))
4438 ThrowMogrifyException(OptionError,"MissingArgument",option);
4439 if (IsGeometry(argv[i]) == MagickFalse)
4440 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4441 break;
4442 }
cristy22879752009-10-25 23:55:40 +00004443 if (LocaleCompare("duration",option+1) == 0)
4444 {
4445 if (*option == '+')
4446 break;
4447 i++;
cristybb503372010-05-27 20:51:26 +00004448 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004449 ThrowMogrifyException(OptionError,"MissingArgument",option);
4450 if (IsGeometry(argv[i]) == MagickFalse)
4451 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4452 break;
4453 }
cristy3ed852e2009-09-05 21:47:34 +00004454 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4455 }
4456 case 'e':
4457 {
4458 if (LocaleCompare("edge",option+1) == 0)
4459 {
4460 if (*option == '+')
4461 break;
4462 i++;
cristybb503372010-05-27 20:51:26 +00004463 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004464 ThrowMogrifyException(OptionError,"MissingArgument",option);
4465 if (IsGeometry(argv[i]) == MagickFalse)
4466 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4467 break;
4468 }
4469 if (LocaleCompare("emboss",option+1) == 0)
4470 {
4471 if (*option == '+')
4472 break;
4473 i++;
cristybb503372010-05-27 20:51:26 +00004474 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004475 ThrowMogrifyException(OptionError,"MissingArgument",option);
4476 if (IsGeometry(argv[i]) == MagickFalse)
4477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4478 break;
4479 }
4480 if (LocaleCompare("encipher",option+1) == 0)
4481 {
4482 if (*option == '+')
4483 break;
4484 i++;
cristybb503372010-05-27 20:51:26 +00004485 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004486 ThrowMogrifyException(OptionError,"MissingArgument",option);
4487 break;
4488 }
4489 if (LocaleCompare("encoding",option+1) == 0)
4490 {
4491 if (*option == '+')
4492 break;
4493 i++;
cristybb503372010-05-27 20:51:26 +00004494 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004495 ThrowMogrifyException(OptionError,"MissingArgument",option);
4496 break;
4497 }
4498 if (LocaleCompare("endian",option+1) == 0)
4499 {
cristybb503372010-05-27 20:51:26 +00004500 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004501 endian;
4502
4503 if (*option == '+')
4504 break;
4505 i++;
cristybb503372010-05-27 20:51:26 +00004506 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004507 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004508 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004509 if (endian < 0)
4510 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4511 argv[i]);
4512 break;
4513 }
4514 if (LocaleCompare("enhance",option+1) == 0)
4515 break;
4516 if (LocaleCompare("equalize",option+1) == 0)
4517 break;
4518 if (LocaleCompare("evaluate",option+1) == 0)
4519 {
cristybb503372010-05-27 20:51:26 +00004520 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004521 op;
4522
4523 if (*option == '+')
4524 break;
4525 i++;
cristybb503372010-05-27 20:51:26 +00004526 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004527 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004528 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004529 if (op < 0)
4530 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4531 argv[i]);
4532 i++;
cristybb503372010-05-27 20:51:26 +00004533 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004534 ThrowMogrifyException(OptionError,"MissingArgument",option);
4535 if (IsGeometry(argv[i]) == MagickFalse)
4536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4537 break;
4538 }
cristyd18ae7c2010-03-07 17:39:52 +00004539 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4540 {
cristybb503372010-05-27 20:51:26 +00004541 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004542 op;
4543
4544 if (*option == '+')
4545 break;
4546 i++;
cristybb503372010-05-27 20:51:26 +00004547 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004548 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004549 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
cristyd18ae7c2010-03-07 17:39:52 +00004550 if (op < 0)
4551 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4552 argv[i]);
4553 break;
4554 }
cristy3ed852e2009-09-05 21:47:34 +00004555 if (LocaleCompare("extent",option+1) == 0)
4556 {
4557 if (*option == '+')
4558 break;
4559 i++;
cristybb503372010-05-27 20:51:26 +00004560 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004561 ThrowMogrifyException(OptionError,"MissingArgument",option);
4562 if (IsGeometry(argv[i]) == MagickFalse)
4563 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4564 break;
4565 }
4566 if (LocaleCompare("extract",option+1) == 0)
4567 {
4568 if (*option == '+')
4569 break;
4570 i++;
cristybb503372010-05-27 20:51:26 +00004571 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004572 ThrowMogrifyException(OptionError,"MissingArgument",option);
4573 if (IsGeometry(argv[i]) == MagickFalse)
4574 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4575 break;
4576 }
4577 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4578 }
4579 case 'f':
4580 {
4581 if (LocaleCompare("family",option+1) == 0)
4582 {
4583 if (*option == '+')
4584 break;
4585 i++;
cristybb503372010-05-27 20:51:26 +00004586 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004587 ThrowMogrifyException(OptionError,"MissingArgument",option);
4588 break;
4589 }
4590 if (LocaleCompare("fill",option+1) == 0)
4591 {
4592 if (*option == '+')
4593 break;
4594 i++;
cristybb503372010-05-27 20:51:26 +00004595 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004596 ThrowMogrifyException(OptionError,"MissingArgument",option);
4597 break;
4598 }
4599 if (LocaleCompare("filter",option+1) == 0)
4600 {
cristybb503372010-05-27 20:51:26 +00004601 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004602 filter;
4603
4604 if (*option == '+')
4605 break;
4606 i++;
cristybb503372010-05-27 20:51:26 +00004607 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004608 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004609 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004610 if (filter < 0)
4611 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4612 argv[i]);
4613 break;
4614 }
4615 if (LocaleCompare("flatten",option+1) == 0)
4616 break;
4617 if (LocaleCompare("flip",option+1) == 0)
4618 break;
4619 if (LocaleCompare("flop",option+1) == 0)
4620 break;
4621 if (LocaleCompare("floodfill",option+1) == 0)
4622 {
4623 if (*option == '+')
4624 break;
4625 i++;
cristybb503372010-05-27 20:51:26 +00004626 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004627 ThrowMogrifyException(OptionError,"MissingArgument",option);
4628 if (IsGeometry(argv[i]) == MagickFalse)
4629 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4630 i++;
cristybb503372010-05-27 20:51:26 +00004631 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004632 ThrowMogrifyException(OptionError,"MissingArgument",option);
4633 break;
4634 }
4635 if (LocaleCompare("font",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 break;
4643 }
4644 if (LocaleCompare("format",option+1) == 0)
4645 {
4646 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4647 (void) CloneString(&format,(char *) NULL);
4648 if (*option == '+')
4649 break;
4650 i++;
cristybb503372010-05-27 20:51:26 +00004651 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004652 ThrowMogrifyException(OptionError,"MissingArgument",option);
4653 (void) CloneString(&format,argv[i]);
4654 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4655 (void) ConcatenateMagickString(image_info->filename,":",
4656 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00004657 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00004658 if (*image_info->magick == '\0')
4659 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4660 format);
4661 break;
4662 }
4663 if (LocaleCompare("frame",option+1) == 0)
4664 {
4665 if (*option == '+')
4666 break;
4667 i++;
cristybb503372010-05-27 20:51:26 +00004668 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004669 ThrowMogrifyException(OptionError,"MissingArgument",option);
4670 if (IsGeometry(argv[i]) == MagickFalse)
4671 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4672 break;
4673 }
4674 if (LocaleCompare("function",option+1) == 0)
4675 {
cristybb503372010-05-27 20:51:26 +00004676 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004677 op;
4678
4679 if (*option == '+')
4680 break;
4681 i++;
cristybb503372010-05-27 20:51:26 +00004682 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004683 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004684 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004685 if (op < 0)
4686 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4687 i++;
cristybb503372010-05-27 20:51:26 +00004688 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004689 ThrowMogrifyException(OptionError,"MissingArgument",option);
4690 break;
4691 }
4692 if (LocaleCompare("fuzz",option+1) == 0)
4693 {
4694 if (*option == '+')
4695 break;
4696 i++;
cristybb503372010-05-27 20:51:26 +00004697 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004698 ThrowMogrifyException(OptionError,"MissingArgument",option);
4699 if (IsGeometry(argv[i]) == MagickFalse)
4700 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4701 break;
4702 }
4703 if (LocaleCompare("fx",option+1) == 0)
4704 {
4705 if (*option == '+')
4706 break;
4707 i++;
cristybb503372010-05-27 20:51:26 +00004708 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004709 ThrowMogrifyException(OptionError,"MissingArgument",option);
4710 break;
4711 }
4712 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4713 }
4714 case 'g':
4715 {
4716 if (LocaleCompare("gamma",option+1) == 0)
4717 {
4718 i++;
cristybb503372010-05-27 20:51:26 +00004719 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004720 ThrowMogrifyException(OptionError,"MissingArgument",option);
4721 if (IsGeometry(argv[i]) == MagickFalse)
4722 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4723 break;
4724 }
4725 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4726 (LocaleCompare("gaussian",option+1) == 0))
4727 {
4728 i++;
cristybb503372010-05-27 20:51:26 +00004729 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004730 ThrowMogrifyException(OptionError,"MissingArgument",option);
4731 if (IsGeometry(argv[i]) == MagickFalse)
4732 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4733 break;
4734 }
4735 if (LocaleCompare("geometry",option+1) == 0)
4736 {
4737 if (*option == '+')
4738 break;
4739 i++;
cristybb503372010-05-27 20:51:26 +00004740 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004741 ThrowMogrifyException(OptionError,"MissingArgument",option);
4742 if (IsGeometry(argv[i]) == MagickFalse)
4743 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4744 break;
4745 }
4746 if (LocaleCompare("gravity",option+1) == 0)
4747 {
cristybb503372010-05-27 20:51:26 +00004748 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004749 gravity;
4750
4751 if (*option == '+')
4752 break;
4753 i++;
cristybb503372010-05-27 20:51:26 +00004754 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004755 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004756 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004757 if (gravity < 0)
4758 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4759 argv[i]);
4760 break;
4761 }
4762 if (LocaleCompare("green-primary",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 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4774 }
4775 case 'h':
4776 {
4777 if (LocaleCompare("hald-clut",option+1) == 0)
4778 break;
4779 if ((LocaleCompare("help",option+1) == 0) ||
4780 (LocaleCompare("-help",option+1) == 0))
4781 return(MogrifyUsage());
4782 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4783 }
4784 case 'i':
4785 {
4786 if (LocaleCompare("identify",option+1) == 0)
4787 break;
4788 if (LocaleCompare("idft",option+1) == 0)
4789 break;
4790 if (LocaleCompare("implode",option+1) == 0)
4791 {
4792 if (*option == '+')
4793 break;
4794 i++;
cristybb503372010-05-27 20:51:26 +00004795 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004796 ThrowMogrifyException(OptionError,"MissingArgument",option);
4797 if (IsGeometry(argv[i]) == MagickFalse)
4798 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4799 break;
4800 }
4801 if (LocaleCompare("intent",option+1) == 0)
4802 {
cristybb503372010-05-27 20:51:26 +00004803 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004804 intent;
4805
4806 if (*option == '+')
4807 break;
4808 i++;
cristybb503372010-05-27 20:51:26 +00004809 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004810 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004811 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004812 if (intent < 0)
4813 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4814 argv[i]);
4815 break;
4816 }
4817 if (LocaleCompare("interlace",option+1) == 0)
4818 {
cristybb503372010-05-27 20:51:26 +00004819 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004820 interlace;
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 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004828 argv[i]);
4829 if (interlace < 0)
4830 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4831 argv[i]);
4832 break;
4833 }
cristyb32b90a2009-09-07 21:45:48 +00004834 if (LocaleCompare("interline-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))
cristyb32b90a2009-09-07 21:45:48 +00004840 ThrowMogrifyException(OptionError,"MissingArgument",option);
4841 if (IsGeometry(argv[i]) == MagickFalse)
4842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4843 break;
4844 }
cristy3ed852e2009-09-05 21:47:34 +00004845 if (LocaleCompare("interpolate",option+1) == 0)
4846 {
cristybb503372010-05-27 20:51:26 +00004847 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004848 interpolate;
4849
4850 if (*option == '+')
4851 break;
4852 i++;
cristybb503372010-05-27 20:51:26 +00004853 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004854 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004855 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004856 argv[i]);
4857 if (interpolate < 0)
4858 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4859 argv[i]);
4860 break;
4861 }
4862 if (LocaleCompare("interword-spacing",option+1) == 0)
4863 {
4864 if (*option == '+')
4865 break;
4866 i++;
cristybb503372010-05-27 20:51:26 +00004867 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004868 ThrowMogrifyException(OptionError,"MissingArgument",option);
4869 if (IsGeometry(argv[i]) == MagickFalse)
4870 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4871 break;
4872 }
4873 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4874 }
4875 case 'k':
4876 {
4877 if (LocaleCompare("kerning",option+1) == 0)
4878 {
4879 if (*option == '+')
4880 break;
4881 i++;
cristybb503372010-05-27 20:51:26 +00004882 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004883 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 if (IsGeometry(argv[i]) == MagickFalse)
4885 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4886 break;
4887 }
4888 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4889 }
4890 case 'l':
4891 {
4892 if (LocaleCompare("label",option+1) == 0)
4893 {
4894 if (*option == '+')
4895 break;
4896 i++;
cristybb503372010-05-27 20:51:26 +00004897 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004898 ThrowMogrifyException(OptionError,"MissingArgument",option);
4899 break;
4900 }
4901 if (LocaleCompare("lat",option+1) == 0)
4902 {
4903 if (*option == '+')
4904 break;
4905 i++;
cristybb503372010-05-27 20:51:26 +00004906 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004907 ThrowMogrifyException(OptionError,"MissingArgument",option);
4908 if (IsGeometry(argv[i]) == MagickFalse)
4909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4910 }
4911 if (LocaleCompare("layers",option+1) == 0)
4912 {
cristybb503372010-05-27 20:51:26 +00004913 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004914 type;
4915
4916 if (*option == '+')
4917 break;
4918 i++;
cristybb503372010-05-27 20:51:26 +00004919 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004920 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004921 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00004922 if (type < 0)
4923 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4924 argv[i]);
4925 break;
4926 }
4927 if (LocaleCompare("level",option+1) == 0)
4928 {
4929 i++;
cristybb503372010-05-27 20:51:26 +00004930 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004931 ThrowMogrifyException(OptionError,"MissingArgument",option);
4932 if (IsGeometry(argv[i]) == MagickFalse)
4933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4934 break;
4935 }
4936 if (LocaleCompare("level-colors",option+1) == 0)
4937 {
4938 i++;
cristybb503372010-05-27 20:51:26 +00004939 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004940 ThrowMogrifyException(OptionError,"MissingArgument",option);
4941 break;
4942 }
4943 if (LocaleCompare("linewidth",option+1) == 0)
4944 {
4945 if (*option == '+')
4946 break;
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);
4950 if (IsGeometry(argv[i]) == MagickFalse)
4951 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4952 break;
4953 }
4954 if (LocaleCompare("limit",option+1) == 0)
4955 {
4956 char
4957 *p;
4958
4959 double
4960 value;
4961
cristybb503372010-05-27 20:51:26 +00004962 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004963 resource;
4964
4965 if (*option == '+')
4966 break;
4967 i++;
cristybb503372010-05-27 20:51:26 +00004968 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004969 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00004970 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00004971 argv[i]);
4972 if (resource < 0)
4973 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4974 argv[i]);
4975 i++;
cristybb503372010-05-27 20:51:26 +00004976 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004977 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +00004978 value=StringToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00004979 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00004980 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4982 break;
4983 }
4984 if (LocaleCompare("liquid-rescale",option+1) == 0)
4985 {
4986 i++;
cristybb503372010-05-27 20:51:26 +00004987 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004988 ThrowMogrifyException(OptionError,"MissingArgument",option);
4989 if (IsGeometry(argv[i]) == MagickFalse)
4990 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4991 break;
4992 }
4993 if (LocaleCompare("list",option+1) == 0)
4994 {
cristybb503372010-05-27 20:51:26 +00004995 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004996 list;
4997
4998 if (*option == '+')
4999 break;
5000 i++;
cristybb503372010-05-27 20:51:26 +00005001 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005002 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005003 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005004 if (list < 0)
5005 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00005006 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00005007 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00005008 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00005009 }
5010 if (LocaleCompare("log",option+1) == 0)
5011 {
5012 if (*option == '+')
5013 break;
5014 i++;
cristybb503372010-05-27 20:51:26 +00005015 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00005016 (strchr(argv[i],'%') == (char *) NULL))
5017 ThrowMogrifyException(OptionError,"MissingArgument",option);
5018 break;
5019 }
5020 if (LocaleCompare("loop",option+1) == 0)
5021 {
5022 if (*option == '+')
5023 break;
5024 i++;
cristybb503372010-05-27 20:51:26 +00005025 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005026 ThrowMogrifyException(OptionError,"MissingArgument",option);
5027 if (IsGeometry(argv[i]) == MagickFalse)
5028 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5029 break;
5030 }
5031 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5032 }
5033 case 'm':
5034 {
5035 if (LocaleCompare("map",option+1) == 0)
5036 {
5037 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5038 if (*option == '+')
5039 break;
5040 i++;
cristybb503372010-05-27 20:51:26 +00005041 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5043 break;
5044 }
5045 if (LocaleCompare("mask",option+1) == 0)
5046 {
5047 if (*option == '+')
5048 break;
5049 i++;
cristybb503372010-05-27 20:51:26 +00005050 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005051 ThrowMogrifyException(OptionError,"MissingArgument",option);
5052 break;
5053 }
5054 if (LocaleCompare("matte",option+1) == 0)
5055 break;
5056 if (LocaleCompare("mattecolor",option+1) == 0)
5057 {
5058 if (*option == '+')
5059 break;
5060 i++;
cristybb503372010-05-27 20:51:26 +00005061 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005062 ThrowMogrifyException(OptionError,"MissingArgument",option);
5063 break;
5064 }
cristyf40785b2010-03-06 02:27:27 +00005065 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005066 break;
cristyf40785b2010-03-06 02:27:27 +00005067 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005068 break;
cristy3ed852e2009-09-05 21:47:34 +00005069 if (LocaleCompare("modulate",option+1) == 0)
5070 {
5071 if (*option == '+')
5072 break;
5073 i++;
cristybb503372010-05-27 20:51:26 +00005074 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005075 ThrowMogrifyException(OptionError,"MissingArgument",option);
5076 if (IsGeometry(argv[i]) == MagickFalse)
5077 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5078 break;
5079 }
5080 if (LocaleCompare("median",option+1) == 0)
5081 {
5082 if (*option == '+')
5083 break;
5084 i++;
cristybb503372010-05-27 20:51:26 +00005085 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005086 ThrowMogrifyException(OptionError,"MissingArgument",option);
5087 if (IsGeometry(argv[i]) == MagickFalse)
5088 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5089 break;
5090 }
cristy69ec32d2011-02-27 23:57:09 +00005091 if (LocaleCompare("mode",option+1) == 0)
5092 {
5093 if (*option == '+')
5094 break;
5095 i++;
5096 if (i == (ssize_t) argc)
5097 ThrowMogrifyException(OptionError,"MissingArgument",option);
5098 if (IsGeometry(argv[i]) == MagickFalse)
5099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5100 break;
5101 }
cristy3ed852e2009-09-05 21:47:34 +00005102 if (LocaleCompare("monitor",option+1) == 0)
5103 break;
5104 if (LocaleCompare("monochrome",option+1) == 0)
5105 break;
5106 if (LocaleCompare("morph",option+1) == 0)
5107 {
5108 if (*option == '+')
5109 break;
5110 i++;
cristybb503372010-05-27 20:51:26 +00005111 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005112 ThrowMogrifyException(OptionError,"MissingArgument",option);
5113 if (IsGeometry(argv[i]) == MagickFalse)
5114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5115 break;
5116 }
anthony29188a82010-01-22 10:12:34 +00005117 if (LocaleCompare("morphology",option+1) == 0)
5118 {
anthony29188a82010-01-22 10:12:34 +00005119 char
5120 token[MaxTextExtent];
5121
cristyb6bd4ad2010-08-08 01:12:27 +00005122 KernelInfo
5123 *kernel_info;
5124
5125 ssize_t
5126 op;
5127
anthony29188a82010-01-22 10:12:34 +00005128 i++;
cristybb503372010-05-27 20:51:26 +00005129 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005130 ThrowMogrifyException(OptionError,"MissingArgument",option);
5131 GetMagickToken(argv[i],NULL,token);
cristy042ee782011-04-22 18:48:30 +00005132 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
anthony29188a82010-01-22 10:12:34 +00005133 if (op < 0)
5134 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005135 token);
anthony29188a82010-01-22 10:12:34 +00005136 i++;
cristybb503372010-05-27 20:51:26 +00005137 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005138 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005139 kernel_info=AcquireKernelInfo(argv[i]);
5140 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005141 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005142 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005143 break;
5144 }
cristy3ed852e2009-09-05 21:47:34 +00005145 if (LocaleCompare("mosaic",option+1) == 0)
5146 break;
5147 if (LocaleCompare("motion-blur",option+1) == 0)
5148 {
5149 if (*option == '+')
5150 break;
5151 i++;
cristybb503372010-05-27 20:51:26 +00005152 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005153 ThrowMogrifyException(OptionError,"MissingArgument",option);
5154 if (IsGeometry(argv[i]) == MagickFalse)
5155 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5156 break;
5157 }
5158 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5159 }
5160 case 'n':
5161 {
5162 if (LocaleCompare("negate",option+1) == 0)
5163 break;
5164 if (LocaleCompare("noise",option+1) == 0)
5165 {
5166 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 if (*option == '+')
5170 {
cristybb503372010-05-27 20:51:26 +00005171 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005172 noise;
5173
cristy042ee782011-04-22 18:48:30 +00005174 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005175 if (noise < 0)
5176 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5177 argv[i]);
5178 break;
5179 }
5180 if (IsGeometry(argv[i]) == MagickFalse)
5181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5182 break;
5183 }
5184 if (LocaleCompare("noop",option+1) == 0)
5185 break;
5186 if (LocaleCompare("normalize",option+1) == 0)
5187 break;
5188 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5189 }
5190 case 'o':
5191 {
5192 if (LocaleCompare("opaque",option+1) == 0)
5193 {
cristy3ed852e2009-09-05 21:47:34 +00005194 i++;
cristybb503372010-05-27 20:51:26 +00005195 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005196 ThrowMogrifyException(OptionError,"MissingArgument",option);
5197 break;
5198 }
5199 if (LocaleCompare("ordered-dither",option+1) == 0)
5200 {
5201 if (*option == '+')
5202 break;
5203 i++;
cristybb503372010-05-27 20:51:26 +00005204 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005205 ThrowMogrifyException(OptionError,"MissingArgument",option);
5206 break;
5207 }
5208 if (LocaleCompare("orient",option+1) == 0)
5209 {
cristybb503372010-05-27 20:51:26 +00005210 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005211 orientation;
5212
5213 orientation=UndefinedOrientation;
5214 if (*option == '+')
5215 break;
5216 i++;
cristybb503372010-05-27 20:51:26 +00005217 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005218 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005219 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005220 argv[i]);
5221 if (orientation < 0)
5222 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5223 argv[i]);
5224 break;
5225 }
5226 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5227 }
5228 case 'p':
5229 {
5230 if (LocaleCompare("page",option+1) == 0)
5231 {
5232 if (*option == '+')
5233 break;
5234 i++;
cristybb503372010-05-27 20:51:26 +00005235 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005236 ThrowMogrifyException(OptionError,"MissingArgument",option);
5237 break;
5238 }
5239 if (LocaleCompare("paint",option+1) == 0)
5240 {
5241 if (*option == '+')
5242 break;
5243 i++;
cristybb503372010-05-27 20:51:26 +00005244 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005245 ThrowMogrifyException(OptionError,"MissingArgument",option);
5246 if (IsGeometry(argv[i]) == MagickFalse)
5247 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5248 break;
5249 }
5250 if (LocaleCompare("path",option+1) == 0)
5251 {
5252 (void) CloneString(&path,(char *) NULL);
5253 if (*option == '+')
5254 break;
5255 i++;
cristybb503372010-05-27 20:51:26 +00005256 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005257 ThrowMogrifyException(OptionError,"MissingArgument",option);
5258 (void) CloneString(&path,argv[i]);
5259 break;
5260 }
5261 if (LocaleCompare("pointsize",option+1) == 0)
5262 {
5263 if (*option == '+')
5264 break;
5265 i++;
cristybb503372010-05-27 20:51:26 +00005266 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005267 ThrowMogrifyException(OptionError,"MissingArgument",option);
5268 if (IsGeometry(argv[i]) == MagickFalse)
5269 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5270 break;
5271 }
5272 if (LocaleCompare("polaroid",option+1) == 0)
5273 {
5274 if (*option == '+')
5275 break;
5276 i++;
cristybb503372010-05-27 20:51:26 +00005277 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005278 ThrowMogrifyException(OptionError,"MissingArgument",option);
5279 if (IsGeometry(argv[i]) == MagickFalse)
5280 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5281 break;
5282 }
5283 if (LocaleCompare("posterize",option+1) == 0)
5284 {
5285 if (*option == '+')
5286 break;
5287 i++;
cristybb503372010-05-27 20:51:26 +00005288 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005289 ThrowMogrifyException(OptionError,"MissingArgument",option);
5290 if (IsGeometry(argv[i]) == MagickFalse)
5291 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5292 break;
5293 }
cristye7f51092010-01-17 00:39:37 +00005294 if (LocaleCompare("precision",option+1) == 0)
5295 {
5296 if (*option == '+')
5297 break;
5298 i++;
cristybb503372010-05-27 20:51:26 +00005299 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005300 ThrowMogrifyException(OptionError,"MissingArgument",option);
5301 if (IsGeometry(argv[i]) == MagickFalse)
5302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5303 break;
5304 }
cristy3ed852e2009-09-05 21:47:34 +00005305 if (LocaleCompare("print",option+1) == 0)
5306 {
5307 if (*option == '+')
5308 break;
5309 i++;
cristybb503372010-05-27 20:51:26 +00005310 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005311 ThrowMogrifyException(OptionError,"MissingArgument",option);
5312 break;
5313 }
5314 if (LocaleCompare("process",option+1) == 0)
5315 {
5316 if (*option == '+')
5317 break;
5318 i++;
cristybb503372010-05-27 20:51:26 +00005319 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005320 ThrowMogrifyException(OptionError,"MissingArgument",option);
5321 break;
5322 }
5323 if (LocaleCompare("profile",option+1) == 0)
5324 {
5325 i++;
cristybb503372010-05-27 20:51:26 +00005326 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005327 ThrowMogrifyException(OptionError,"MissingArgument",option);
5328 break;
5329 }
5330 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5331 }
5332 case 'q':
5333 {
5334 if (LocaleCompare("quality",option+1) == 0)
5335 {
5336 if (*option == '+')
5337 break;
5338 i++;
cristybb503372010-05-27 20:51:26 +00005339 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005340 ThrowMogrifyException(OptionError,"MissingArgument",option);
5341 if (IsGeometry(argv[i]) == MagickFalse)
5342 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5343 break;
5344 }
5345 if (LocaleCompare("quantize",option+1) == 0)
5346 {
cristybb503372010-05-27 20:51:26 +00005347 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005348 colorspace;
5349
5350 if (*option == '+')
5351 break;
5352 i++;
cristybb503372010-05-27 20:51:26 +00005353 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005354 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005355 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005356 argv[i]);
5357 if (colorspace < 0)
5358 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5359 argv[i]);
5360 break;
5361 }
5362 if (LocaleCompare("quiet",option+1) == 0)
5363 break;
5364 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5365 }
5366 case 'r':
5367 {
5368 if (LocaleCompare("radial-blur",option+1) == 0)
5369 {
5370 i++;
cristybb503372010-05-27 20:51:26 +00005371 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005372 ThrowMogrifyException(OptionError,"MissingArgument",option);
5373 if (IsGeometry(argv[i]) == MagickFalse)
5374 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5375 break;
5376 }
5377 if (LocaleCompare("raise",option+1) == 0)
5378 {
5379 i++;
cristybb503372010-05-27 20:51:26 +00005380 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005381 ThrowMogrifyException(OptionError,"MissingArgument",option);
5382 if (IsGeometry(argv[i]) == MagickFalse)
5383 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5384 break;
5385 }
5386 if (LocaleCompare("random-threshold",option+1) == 0)
5387 {
5388 if (*option == '+')
5389 break;
5390 i++;
cristybb503372010-05-27 20:51:26 +00005391 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 if (IsGeometry(argv[i]) == MagickFalse)
5394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5395 break;
5396 }
cristye6365592010-04-02 17:31:23 +00005397 if (LocaleCompare("recolor",option+1) == 0)
5398 {
5399 if (*option == '+')
5400 break;
5401 i++;
cristybb503372010-05-27 20:51:26 +00005402 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005403 ThrowMogrifyException(OptionError,"MissingArgument",option);
5404 if (IsGeometry(argv[i]) == MagickFalse)
5405 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5406 break;
5407 }
cristy3ed852e2009-09-05 21:47:34 +00005408 if (LocaleCompare("red-primary",option+1) == 0)
5409 {
5410 if (*option == '+')
5411 break;
5412 i++;
cristybb503372010-05-27 20:51:26 +00005413 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005414 ThrowMogrifyException(OptionError,"MissingArgument",option);
5415 if (IsGeometry(argv[i]) == MagickFalse)
5416 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5417 }
cristy9f2083a2010-04-22 19:48:05 +00005418 if (LocaleCompare("regard-warnings",option+1) == 0)
5419 break;
cristy3ed852e2009-09-05 21:47:34 +00005420 if (LocaleCompare("region",option+1) == 0)
5421 {
5422 if (*option == '+')
5423 break;
5424 i++;
cristybb503372010-05-27 20:51:26 +00005425 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005426 ThrowMogrifyException(OptionError,"MissingArgument",option);
5427 if (IsGeometry(argv[i]) == MagickFalse)
5428 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5429 break;
5430 }
cristyf0c78232010-03-15 12:53:40 +00005431 if (LocaleCompare("remap",option+1) == 0)
5432 {
5433 if (*option == '+')
5434 break;
5435 i++;
cristybb503372010-05-27 20:51:26 +00005436 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005437 ThrowMogrifyException(OptionError,"MissingArgument",option);
5438 break;
5439 }
cristy3ed852e2009-09-05 21:47:34 +00005440 if (LocaleCompare("render",option+1) == 0)
5441 break;
5442 if (LocaleCompare("repage",option+1) == 0)
5443 {
5444 if (*option == '+')
5445 break;
5446 i++;
cristybb503372010-05-27 20:51:26 +00005447 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005448 ThrowMogrifyException(OptionError,"MissingArgument",option);
5449 if (IsGeometry(argv[i]) == MagickFalse)
5450 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5451 break;
5452 }
5453 if (LocaleCompare("resample",option+1) == 0)
5454 {
5455 if (*option == '+')
5456 break;
5457 i++;
cristybb503372010-05-27 20:51:26 +00005458 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005459 ThrowMogrifyException(OptionError,"MissingArgument",option);
5460 if (IsGeometry(argv[i]) == MagickFalse)
5461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5462 break;
5463 }
5464 if (LocaleCompare("resize",option+1) == 0)
5465 {
5466 if (*option == '+')
5467 break;
5468 i++;
cristybb503372010-05-27 20:51:26 +00005469 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005470 ThrowMogrifyException(OptionError,"MissingArgument",option);
5471 if (IsGeometry(argv[i]) == MagickFalse)
5472 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5473 break;
5474 }
cristyebbcfea2011-02-25 02:43:54 +00005475 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5476 {
5477 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5478 break;
5479 }
cristy3ed852e2009-09-05 21:47:34 +00005480 if (LocaleCompare("reverse",option+1) == 0)
5481 break;
5482 if (LocaleCompare("roll",option+1) == 0)
5483 {
5484 if (*option == '+')
5485 break;
5486 i++;
cristybb503372010-05-27 20:51:26 +00005487 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005488 ThrowMogrifyException(OptionError,"MissingArgument",option);
5489 if (IsGeometry(argv[i]) == MagickFalse)
5490 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5491 break;
5492 }
5493 if (LocaleCompare("rotate",option+1) == 0)
5494 {
5495 i++;
cristybb503372010-05-27 20:51:26 +00005496 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005497 ThrowMogrifyException(OptionError,"MissingArgument",option);
5498 if (IsGeometry(argv[i]) == MagickFalse)
5499 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5500 break;
5501 }
5502 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5503 }
5504 case 's':
5505 {
5506 if (LocaleCompare("sample",option+1) == 0)
5507 {
5508 if (*option == '+')
5509 break;
5510 i++;
cristybb503372010-05-27 20:51:26 +00005511 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005512 ThrowMogrifyException(OptionError,"MissingArgument",option);
5513 if (IsGeometry(argv[i]) == MagickFalse)
5514 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5515 break;
5516 }
5517 if (LocaleCompare("sampling-factor",option+1) == 0)
5518 {
5519 if (*option == '+')
5520 break;
5521 i++;
cristybb503372010-05-27 20:51:26 +00005522 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005523 ThrowMogrifyException(OptionError,"MissingArgument",option);
5524 if (IsGeometry(argv[i]) == MagickFalse)
5525 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5526 break;
5527 }
5528 if (LocaleCompare("scale",option+1) == 0)
5529 {
5530 if (*option == '+')
5531 break;
5532 i++;
cristybb503372010-05-27 20:51:26 +00005533 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005534 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 if (IsGeometry(argv[i]) == MagickFalse)
5536 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5537 break;
5538 }
5539 if (LocaleCompare("scene",option+1) == 0)
5540 {
5541 if (*option == '+')
5542 break;
5543 i++;
cristybb503372010-05-27 20:51:26 +00005544 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005545 ThrowMogrifyException(OptionError,"MissingArgument",option);
5546 if (IsGeometry(argv[i]) == MagickFalse)
5547 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5548 break;
5549 }
5550 if (LocaleCompare("seed",option+1) == 0)
5551 {
5552 if (*option == '+')
5553 break;
5554 i++;
cristybb503372010-05-27 20:51:26 +00005555 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005556 ThrowMogrifyException(OptionError,"MissingArgument",option);
5557 if (IsGeometry(argv[i]) == MagickFalse)
5558 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5559 break;
5560 }
5561 if (LocaleCompare("segment",option+1) == 0)
5562 {
5563 if (*option == '+')
5564 break;
5565 i++;
cristybb503372010-05-27 20:51:26 +00005566 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005567 ThrowMogrifyException(OptionError,"MissingArgument",option);
5568 if (IsGeometry(argv[i]) == MagickFalse)
5569 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5570 break;
5571 }
5572 if (LocaleCompare("selective-blur",option+1) == 0)
5573 {
5574 i++;
cristybb503372010-05-27 20:51:26 +00005575 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005576 ThrowMogrifyException(OptionError,"MissingArgument",option);
5577 if (IsGeometry(argv[i]) == MagickFalse)
5578 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5579 break;
5580 }
5581 if (LocaleCompare("separate",option+1) == 0)
5582 break;
5583 if (LocaleCompare("sepia-tone",option+1) == 0)
5584 {
5585 if (*option == '+')
5586 break;
5587 i++;
cristybb503372010-05-27 20:51:26 +00005588 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005589 ThrowMogrifyException(OptionError,"MissingArgument",option);
5590 if (IsGeometry(argv[i]) == MagickFalse)
5591 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5592 break;
5593 }
5594 if (LocaleCompare("set",option+1) == 0)
5595 {
5596 i++;
cristybb503372010-05-27 20:51:26 +00005597 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005598 ThrowMogrifyException(OptionError,"MissingArgument",option);
5599 if (*option == '+')
5600 break;
5601 i++;
cristybb503372010-05-27 20:51:26 +00005602 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005603 ThrowMogrifyException(OptionError,"MissingArgument",option);
5604 break;
5605 }
5606 if (LocaleCompare("shade",option+1) == 0)
5607 {
5608 i++;
cristybb503372010-05-27 20:51:26 +00005609 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005610 ThrowMogrifyException(OptionError,"MissingArgument",option);
5611 if (IsGeometry(argv[i]) == MagickFalse)
5612 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5613 break;
5614 }
5615 if (LocaleCompare("shadow",option+1) == 0)
5616 {
5617 if (*option == '+')
5618 break;
5619 i++;
cristybb503372010-05-27 20:51:26 +00005620 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005621 ThrowMogrifyException(OptionError,"MissingArgument",option);
5622 if (IsGeometry(argv[i]) == MagickFalse)
5623 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5624 break;
5625 }
5626 if (LocaleCompare("sharpen",option+1) == 0)
5627 {
5628 i++;
cristybb503372010-05-27 20:51:26 +00005629 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005630 ThrowMogrifyException(OptionError,"MissingArgument",option);
5631 if (IsGeometry(argv[i]) == MagickFalse)
5632 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5633 break;
5634 }
5635 if (LocaleCompare("shave",option+1) == 0)
5636 {
5637 if (*option == '+')
5638 break;
5639 i++;
cristybb503372010-05-27 20:51:26 +00005640 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005641 ThrowMogrifyException(OptionError,"MissingArgument",option);
5642 if (IsGeometry(argv[i]) == MagickFalse)
5643 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5644 break;
5645 }
5646 if (LocaleCompare("shear",option+1) == 0)
5647 {
5648 i++;
cristybb503372010-05-27 20:51:26 +00005649 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005650 ThrowMogrifyException(OptionError,"MissingArgument",option);
5651 if (IsGeometry(argv[i]) == MagickFalse)
5652 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653 break;
5654 }
5655 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5656 {
5657 i++;
cristybb503372010-05-27 20:51:26 +00005658 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005659 ThrowMogrifyException(OptionError,"MissingArgument",option);
5660 if (IsGeometry(argv[i]) == MagickFalse)
5661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5662 break;
5663 }
5664 if (LocaleCompare("size",option+1) == 0)
5665 {
5666 if (*option == '+')
5667 break;
5668 i++;
cristybb503372010-05-27 20:51:26 +00005669 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005670 ThrowMogrifyException(OptionError,"MissingArgument",option);
5671 if (IsGeometry(argv[i]) == MagickFalse)
5672 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5673 break;
5674 }
5675 if (LocaleCompare("sketch",option+1) == 0)
5676 {
5677 if (*option == '+')
5678 break;
5679 i++;
cristybb503372010-05-27 20:51:26 +00005680 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005681 ThrowMogrifyException(OptionError,"MissingArgument",option);
5682 if (IsGeometry(argv[i]) == MagickFalse)
5683 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5684 break;
5685 }
cristy4285d782011-02-09 20:12:28 +00005686 if (LocaleCompare("smush",option+1) == 0)
5687 {
cristy4285d782011-02-09 20:12:28 +00005688 i++;
5689 if (i == (ssize_t) argc)
5690 ThrowMogrifyException(OptionError,"MissingArgument",option);
5691 if (IsGeometry(argv[i]) == MagickFalse)
5692 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00005693 i++;
5694 break;
5695 }
cristy3ed852e2009-09-05 21:47:34 +00005696 if (LocaleCompare("solarize",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 }
5707 if (LocaleCompare("sparse-color",option+1) == 0)
5708 {
cristybb503372010-05-27 20:51:26 +00005709 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005710 op;
5711
5712 i++;
cristybb503372010-05-27 20:51:26 +00005713 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005714 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005715 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005716 if (op < 0)
5717 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5718 argv[i]);
5719 i++;
cristybb503372010-05-27 20:51:26 +00005720 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005721 ThrowMogrifyException(OptionError,"MissingArgument",option);
5722 break;
5723 }
5724 if (LocaleCompare("spread",option+1) == 0)
5725 {
5726 if (*option == '+')
5727 break;
5728 i++;
cristybb503372010-05-27 20:51:26 +00005729 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005730 ThrowMogrifyException(OptionError,"MissingArgument",option);
5731 if (IsGeometry(argv[i]) == MagickFalse)
5732 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5733 break;
5734 }
cristy0834d642011-03-18 18:26:08 +00005735 if (LocaleCompare("statistic",option+1) == 0)
5736 {
5737 ssize_t
5738 op;
5739
5740 if (*option == '+')
5741 break;
5742 i++;
5743 if (i == (ssize_t) argc)
5744 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005745 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
cristy0834d642011-03-18 18:26:08 +00005746 if (op < 0)
5747 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5748 argv[i]);
5749 i++;
5750 if (i == (ssize_t) (argc-1))
5751 ThrowMogrifyException(OptionError,"MissingArgument",option);
5752 if (IsGeometry(argv[i]) == MagickFalse)
5753 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5754 break;
5755 }
cristy3ed852e2009-09-05 21:47:34 +00005756 if (LocaleCompare("stretch",option+1) == 0)
5757 {
cristybb503372010-05-27 20:51:26 +00005758 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005759 stretch;
5760
5761 if (*option == '+')
5762 break;
5763 i++;
cristybb503372010-05-27 20:51:26 +00005764 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005765 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005766 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005767 if (stretch < 0)
5768 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5769 argv[i]);
5770 break;
5771 }
5772 if (LocaleCompare("strip",option+1) == 0)
5773 break;
5774 if (LocaleCompare("stroke",option+1) == 0)
5775 {
5776 if (*option == '+')
5777 break;
5778 i++;
cristybb503372010-05-27 20:51:26 +00005779 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005780 ThrowMogrifyException(OptionError,"MissingArgument",option);
5781 break;
5782 }
5783 if (LocaleCompare("strokewidth",option+1) == 0)
5784 {
5785 if (*option == '+')
5786 break;
5787 i++;
cristybb503372010-05-27 20:51:26 +00005788 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005789 ThrowMogrifyException(OptionError,"MissingArgument",option);
5790 if (IsGeometry(argv[i]) == MagickFalse)
5791 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5792 break;
5793 }
5794 if (LocaleCompare("style",option+1) == 0)
5795 {
cristybb503372010-05-27 20:51:26 +00005796 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005797 style;
5798
5799 if (*option == '+')
5800 break;
5801 i++;
cristybb503372010-05-27 20:51:26 +00005802 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005803 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005804 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005805 if (style < 0)
5806 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5807 argv[i]);
5808 break;
5809 }
cristyecb10ff2011-03-22 13:14:03 +00005810 if (LocaleCompare("swap",option+1) == 0)
5811 {
5812 if (*option == '+')
5813 break;
5814 i++;
5815 if (i == (ssize_t) (argc-1))
5816 ThrowMogrifyException(OptionError,"MissingArgument",option);
5817 if (IsGeometry(argv[i]) == MagickFalse)
5818 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5819 break;
5820 }
cristy3ed852e2009-09-05 21:47:34 +00005821 if (LocaleCompare("swirl",option+1) == 0)
5822 {
5823 if (*option == '+')
5824 break;
5825 i++;
cristybb503372010-05-27 20:51:26 +00005826 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005827 ThrowMogrifyException(OptionError,"MissingArgument",option);
5828 if (IsGeometry(argv[i]) == MagickFalse)
5829 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5830 break;
5831 }
cristyd9a29192010-10-16 16:49:53 +00005832 if (LocaleCompare("synchronize",option+1) == 0)
5833 break;
cristy3ed852e2009-09-05 21:47:34 +00005834 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5835 }
5836 case 't':
5837 {
5838 if (LocaleCompare("taint",option+1) == 0)
5839 break;
5840 if (LocaleCompare("texture",option+1) == 0)
5841 {
5842 if (*option == '+')
5843 break;
5844 i++;
cristybb503372010-05-27 20:51:26 +00005845 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005846 ThrowMogrifyException(OptionError,"MissingArgument",option);
5847 break;
5848 }
5849 if (LocaleCompare("tile",option+1) == 0)
5850 {
5851 if (*option == '+')
5852 break;
5853 i++;
cristybb503372010-05-27 20:51:26 +00005854 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005855 ThrowMogrifyException(OptionError,"MissingArgument",option);
5856 break;
5857 }
5858 if (LocaleCompare("tile-offset",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("tint",option+1) == 0)
5870 {
5871 if (*option == '+')
5872 break;
5873 i++;
cristybb503372010-05-27 20:51:26 +00005874 if (i == (ssize_t) (argc-1))
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("transform",option+1) == 0)
5881 break;
5882 if (LocaleCompare("transpose",option+1) == 0)
5883 break;
5884 if (LocaleCompare("transverse",option+1) == 0)
5885 break;
5886 if (LocaleCompare("threshold",option+1) == 0)
5887 {
5888 if (*option == '+')
5889 break;
5890 i++;
cristybb503372010-05-27 20:51:26 +00005891 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005892 ThrowMogrifyException(OptionError,"MissingArgument",option);
5893 if (IsGeometry(argv[i]) == MagickFalse)
5894 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5895 break;
5896 }
5897 if (LocaleCompare("thumbnail",option+1) == 0)
5898 {
5899 if (*option == '+')
5900 break;
5901 i++;
cristybb503372010-05-27 20:51:26 +00005902 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005903 ThrowMogrifyException(OptionError,"MissingArgument",option);
5904 if (IsGeometry(argv[i]) == MagickFalse)
5905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5906 break;
5907 }
5908 if (LocaleCompare("transparent",option+1) == 0)
5909 {
5910 i++;
cristybb503372010-05-27 20:51:26 +00005911 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005912 ThrowMogrifyException(OptionError,"MissingArgument",option);
5913 break;
5914 }
5915 if (LocaleCompare("transparent-color",option+1) == 0)
5916 {
5917 if (*option == '+')
5918 break;
5919 i++;
cristybb503372010-05-27 20:51:26 +00005920 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005921 ThrowMogrifyException(OptionError,"MissingArgument",option);
5922 break;
5923 }
5924 if (LocaleCompare("treedepth",option+1) == 0)
5925 {
5926 if (*option == '+')
5927 break;
5928 i++;
cristybb503372010-05-27 20:51:26 +00005929 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005930 ThrowMogrifyException(OptionError,"MissingArgument",option);
5931 if (IsGeometry(argv[i]) == MagickFalse)
5932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5933 break;
5934 }
5935 if (LocaleCompare("trim",option+1) == 0)
5936 break;
5937 if (LocaleCompare("type",option+1) == 0)
5938 {
cristybb503372010-05-27 20:51:26 +00005939 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005940 type;
5941
5942 if (*option == '+')
5943 break;
5944 i++;
cristybb503372010-05-27 20:51:26 +00005945 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005946 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005947 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00005948 if (type < 0)
5949 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5950 argv[i]);
5951 break;
5952 }
5953 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5954 }
5955 case 'u':
5956 {
5957 if (LocaleCompare("undercolor",option+1) == 0)
5958 {
5959 if (*option == '+')
5960 break;
5961 i++;
cristybb503372010-05-27 20:51:26 +00005962 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005963 ThrowMogrifyException(OptionError,"MissingArgument",option);
5964 break;
5965 }
5966 if (LocaleCompare("unique-colors",option+1) == 0)
5967 break;
5968 if (LocaleCompare("units",option+1) == 0)
5969 {
cristybb503372010-05-27 20:51:26 +00005970 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005971 units;
5972
5973 if (*option == '+')
5974 break;
5975 i++;
cristybb503372010-05-27 20:51:26 +00005976 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005977 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00005978 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00005979 argv[i]);
5980 if (units < 0)
5981 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5982 argv[i]);
5983 break;
5984 }
5985 if (LocaleCompare("unsharp",option+1) == 0)
5986 {
5987 i++;
cristybb503372010-05-27 20:51:26 +00005988 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005989 ThrowMogrifyException(OptionError,"MissingArgument",option);
5990 if (IsGeometry(argv[i]) == MagickFalse)
5991 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5992 break;
5993 }
5994 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5995 }
5996 case 'v':
5997 {
5998 if (LocaleCompare("verbose",option+1) == 0)
5999 {
6000 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6001 break;
6002 }
6003 if ((LocaleCompare("version",option+1) == 0) ||
6004 (LocaleCompare("-version",option+1) == 0))
6005 {
cristyb51dff52011-05-19 16:55:47 +00006006 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00006007 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00006008 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
6009 GetMagickCopyright());
6010 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
6011 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00006012 break;
6013 }
6014 if (LocaleCompare("view",option+1) == 0)
6015 {
6016 if (*option == '+')
6017 break;
6018 i++;
cristybb503372010-05-27 20:51:26 +00006019 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006020 ThrowMogrifyException(OptionError,"MissingArgument",option);
6021 break;
6022 }
6023 if (LocaleCompare("vignette",option+1) == 0)
6024 {
6025 if (*option == '+')
6026 break;
6027 i++;
cristybb503372010-05-27 20:51:26 +00006028 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006029 ThrowMogrifyException(OptionError,"MissingArgument",option);
6030 if (IsGeometry(argv[i]) == MagickFalse)
6031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6032 break;
6033 }
6034 if (LocaleCompare("virtual-pixel",option+1) == 0)
6035 {
cristybb503372010-05-27 20:51:26 +00006036 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006037 method;
6038
6039 if (*option == '+')
6040 break;
6041 i++;
cristybb503372010-05-27 20:51:26 +00006042 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006043 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00006044 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00006045 argv[i]);
6046 if (method < 0)
6047 ThrowMogrifyException(OptionError,
6048 "UnrecognizedVirtualPixelMethod",argv[i]);
6049 break;
6050 }
6051 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6052 }
6053 case 'w':
6054 {
6055 if (LocaleCompare("wave",option+1) == 0)
6056 {
6057 i++;
cristybb503372010-05-27 20:51:26 +00006058 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006059 ThrowMogrifyException(OptionError,"MissingArgument",option);
6060 if (IsGeometry(argv[i]) == MagickFalse)
6061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6062 break;
6063 }
6064 if (LocaleCompare("weight",option+1) == 0)
6065 {
6066 if (*option == '+')
6067 break;
6068 i++;
cristybb503372010-05-27 20:51:26 +00006069 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006070 ThrowMogrifyException(OptionError,"MissingArgument",option);
6071 break;
6072 }
6073 if (LocaleCompare("white-point",option+1) == 0)
6074 {
6075 if (*option == '+')
6076 break;
6077 i++;
cristybb503372010-05-27 20:51:26 +00006078 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006079 ThrowMogrifyException(OptionError,"MissingArgument",option);
6080 if (IsGeometry(argv[i]) == MagickFalse)
6081 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6082 break;
6083 }
6084 if (LocaleCompare("white-threshold",option+1) == 0)
6085 {
6086 if (*option == '+')
6087 break;
6088 i++;
cristybb503372010-05-27 20:51:26 +00006089 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6091 if (IsGeometry(argv[i]) == MagickFalse)
6092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6093 break;
6094 }
6095 if (LocaleCompare("write",option+1) == 0)
6096 {
6097 i++;
cristybb503372010-05-27 20:51:26 +00006098 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6100 break;
6101 }
6102 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6103 }
6104 case '?':
6105 break;
6106 default:
6107 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6108 }
cristy042ee782011-04-22 18:48:30 +00006109 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6110 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00006111 if (fire != MagickFalse)
6112 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6113 }
6114 if (k != 0)
6115 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006116 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006117 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6118 DestroyMogrify();
6119 return(status != 0 ? MagickTrue : MagickFalse);
6120}
6121
6122/*
6123%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6124% %
6125% %
6126% %
6127+ M o g r i f y I m a g e I n f o %
6128% %
6129% %
6130% %
6131%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6132%
6133% MogrifyImageInfo() applies image processing settings to the image as
6134% prescribed by command line options.
6135%
6136% The format of the MogrifyImageInfo method is:
6137%
6138% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6139% const char **argv,ExceptionInfo *exception)
6140%
6141% A description of each parameter follows:
6142%
6143% o image_info: the image info..
6144%
6145% o argc: Specifies a pointer to an integer describing the number of
6146% elements in the argument vector.
6147%
6148% o argv: Specifies a pointer to a text array containing the command line
6149% arguments.
6150%
6151% o exception: return any errors or warnings in this structure.
6152%
6153*/
6154WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6155 const int argc,const char **argv,ExceptionInfo *exception)
6156{
6157 const char
6158 *option;
6159
6160 GeometryInfo
6161 geometry_info;
6162
cristybb503372010-05-27 20:51:26 +00006163 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006164 count;
6165
cristybb503372010-05-27 20:51:26 +00006166 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006167 i;
6168
6169 /*
6170 Initialize method variables.
6171 */
6172 assert(image_info != (ImageInfo *) NULL);
6173 assert(image_info->signature == MagickSignature);
6174 if (image_info->debug != MagickFalse)
6175 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6176 image_info->filename);
6177 if (argc < 0)
6178 return(MagickTrue);
6179 /*
6180 Set the image settings.
6181 */
cristybb503372010-05-27 20:51:26 +00006182 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006183 {
6184 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00006185 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00006186 continue;
cristy042ee782011-04-22 18:48:30 +00006187 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00006188 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00006189 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006190 break;
6191 switch (*(option+1))
6192 {
6193 case 'a':
6194 {
6195 if (LocaleCompare("adjoin",option+1) == 0)
6196 {
6197 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6198 break;
6199 }
6200 if (LocaleCompare("antialias",option+1) == 0)
6201 {
6202 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6203 break;
6204 }
cristy3ed852e2009-09-05 21:47:34 +00006205 if (LocaleCompare("authenticate",option+1) == 0)
6206 {
6207 if (*option == '+')
anthony1afdc7a2011-10-05 11:54:28 +00006208 (void) DeleteImageOption(image_info,option+1);
cristy3ed852e2009-09-05 21:47:34 +00006209 else
anthony1afdc7a2011-10-05 11:54:28 +00006210 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006211 break;
6212 }
6213 break;
6214 }
6215 case 'b':
6216 {
6217 if (LocaleCompare("background",option+1) == 0)
6218 {
6219 if (*option == '+')
6220 {
6221 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006222 (void) QueryColorCompliance(MogrifyBackgroundColor,
6223 AllCompliance,&image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006224 break;
6225 }
6226 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006227 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6228 &image_info->background_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006229 break;
6230 }
6231 if (LocaleCompare("bias",option+1) == 0)
6232 {
6233 if (*option == '+')
6234 {
6235 (void) SetImageOption(image_info,option+1,"0.0");
6236 break;
6237 }
6238 (void) SetImageOption(image_info,option+1,argv[i+1]);
6239 break;
6240 }
6241 if (LocaleCompare("black-point-compensation",option+1) == 0)
6242 {
6243 if (*option == '+')
6244 {
6245 (void) SetImageOption(image_info,option+1,"false");
6246 break;
6247 }
6248 (void) SetImageOption(image_info,option+1,"true");
6249 break;
6250 }
6251 if (LocaleCompare("blue-primary",option+1) == 0)
6252 {
6253 if (*option == '+')
6254 {
6255 (void) SetImageOption(image_info,option+1,"0.0");
6256 break;
6257 }
6258 (void) SetImageOption(image_info,option+1,argv[i+1]);
6259 break;
6260 }
6261 if (LocaleCompare("bordercolor",option+1) == 0)
6262 {
6263 if (*option == '+')
6264 {
6265 (void) DeleteImageOption(image_info,option+1);
cristy9950d572011-10-01 18:22:35 +00006266 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006267 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006268 break;
6269 }
cristy9950d572011-10-01 18:22:35 +00006270 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6271 &image_info->border_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006272 (void) SetImageOption(image_info,option+1,argv[i+1]);
6273 break;
6274 }
6275 if (LocaleCompare("box",option+1) == 0)
6276 {
6277 if (*option == '+')
6278 {
6279 (void) SetImageOption(image_info,"undercolor","none");
6280 break;
6281 }
6282 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6283 break;
6284 }
6285 break;
6286 }
6287 case 'c':
6288 {
6289 if (LocaleCompare("cache",option+1) == 0)
6290 {
6291 MagickSizeType
6292 limit;
6293
6294 limit=MagickResourceInfinity;
6295 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristy9b34e302011-11-05 02:15:45 +00006296 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6297 100.0);
cristy3ed852e2009-09-05 21:47:34 +00006298 (void) SetMagickResourceLimit(MemoryResource,limit);
6299 (void) SetMagickResourceLimit(MapResource,2*limit);
6300 break;
6301 }
6302 if (LocaleCompare("caption",option+1) == 0)
6303 {
6304 if (*option == '+')
6305 {
6306 (void) DeleteImageOption(image_info,option+1);
6307 break;
6308 }
6309 (void) SetImageOption(image_info,option+1,argv[i+1]);
6310 break;
6311 }
6312 if (LocaleCompare("channel",option+1) == 0)
6313 {
6314 if (*option == '+')
6315 {
6316 image_info->channel=DefaultChannels;
6317 break;
6318 }
6319 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6320 break;
6321 }
cristy3ed852e2009-09-05 21:47:34 +00006322 if (LocaleCompare("colorspace",option+1) == 0)
6323 {
6324 if (*option == '+')
6325 {
6326 image_info->colorspace=UndefinedColorspace;
6327 (void) SetImageOption(image_info,option+1,"undefined");
6328 break;
6329 }
cristy042ee782011-04-22 18:48:30 +00006330 image_info->colorspace=(ColorspaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006331 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6332 (void) SetImageOption(image_info,option+1,argv[i+1]);
6333 break;
6334 }
cristy3ed852e2009-09-05 21:47:34 +00006335 if (LocaleCompare("comment",option+1) == 0)
6336 {
6337 if (*option == '+')
6338 {
6339 (void) DeleteImageOption(image_info,option+1);
6340 break;
6341 }
6342 (void) SetImageOption(image_info,option+1,argv[i+1]);
6343 break;
6344 }
6345 if (LocaleCompare("compose",option+1) == 0)
6346 {
6347 if (*option == '+')
6348 {
6349 (void) SetImageOption(image_info,option+1,"undefined");
6350 break;
6351 }
6352 (void) SetImageOption(image_info,option+1,argv[i+1]);
6353 break;
6354 }
6355 if (LocaleCompare("compress",option+1) == 0)
6356 {
6357 if (*option == '+')
6358 {
6359 image_info->compression=UndefinedCompression;
6360 (void) SetImageOption(image_info,option+1,"undefined");
6361 break;
6362 }
cristy042ee782011-04-22 18:48:30 +00006363 image_info->compression=(CompressionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006364 MagickCompressOptions,MagickFalse,argv[i+1]);
6365 (void) SetImageOption(image_info,option+1,argv[i+1]);
6366 break;
6367 }
6368 break;
6369 }
6370 case 'd':
6371 {
6372 if (LocaleCompare("debug",option+1) == 0)
6373 {
6374 if (*option == '+')
6375 (void) SetLogEventMask("none");
6376 else
6377 (void) SetLogEventMask(argv[i+1]);
6378 image_info->debug=IsEventLogging();
6379 break;
6380 }
6381 if (LocaleCompare("define",option+1) == 0)
6382 {
6383 if (*option == '+')
6384 {
6385 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6386 (void) DeleteImageRegistry(argv[i+1]+9);
6387 else
6388 (void) DeleteImageOption(image_info,argv[i+1]);
6389 break;
6390 }
6391 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6392 {
6393 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6394 exception);
6395 break;
6396 }
6397 (void) DefineImageOption(image_info,argv[i+1]);
6398 break;
6399 }
6400 if (LocaleCompare("delay",option+1) == 0)
6401 {
6402 if (*option == '+')
6403 {
6404 (void) SetImageOption(image_info,option+1,"0");
6405 break;
6406 }
6407 (void) SetImageOption(image_info,option+1,argv[i+1]);
6408 break;
6409 }
6410 if (LocaleCompare("density",option+1) == 0)
6411 {
6412 /*
6413 Set image density.
6414 */
6415 if (*option == '+')
6416 {
6417 if (image_info->density != (char *) NULL)
6418 image_info->density=DestroyString(image_info->density);
6419 (void) SetImageOption(image_info,option+1,"72");
6420 break;
6421 }
6422 (void) CloneString(&image_info->density,argv[i+1]);
6423 (void) SetImageOption(image_info,option+1,argv[i+1]);
6424 break;
6425 }
6426 if (LocaleCompare("depth",option+1) == 0)
6427 {
6428 if (*option == '+')
6429 {
6430 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6431 break;
6432 }
cristye27293e2009-12-18 02:53:20 +00006433 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006434 break;
6435 }
cristyc9b12952010-03-28 01:12:28 +00006436 if (LocaleCompare("direction",option+1) == 0)
6437 {
6438 if (*option == '+')
6439 {
6440 (void) SetImageOption(image_info,option+1,"undefined");
6441 break;
6442 }
6443 (void) SetImageOption(image_info,option+1,argv[i+1]);
6444 break;
6445 }
cristy3ed852e2009-09-05 21:47:34 +00006446 if (LocaleCompare("display",option+1) == 0)
6447 {
6448 if (*option == '+')
6449 {
6450 if (image_info->server_name != (char *) NULL)
6451 image_info->server_name=DestroyString(
6452 image_info->server_name);
6453 break;
6454 }
6455 (void) CloneString(&image_info->server_name,argv[i+1]);
6456 break;
6457 }
6458 if (LocaleCompare("dispose",option+1) == 0)
6459 {
6460 if (*option == '+')
6461 {
6462 (void) SetImageOption(image_info,option+1,"undefined");
6463 break;
6464 }
6465 (void) SetImageOption(image_info,option+1,argv[i+1]);
6466 break;
6467 }
6468 if (LocaleCompare("dither",option+1) == 0)
6469 {
6470 if (*option == '+')
6471 {
6472 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006473 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006474 break;
6475 }
6476 (void) SetImageOption(image_info,option+1,argv[i+1]);
6477 image_info->dither=MagickTrue;
6478 break;
6479 }
6480 break;
6481 }
6482 case 'e':
6483 {
6484 if (LocaleCompare("encoding",option+1) == 0)
6485 {
6486 if (*option == '+')
6487 {
6488 (void) SetImageOption(image_info,option+1,"undefined");
6489 break;
6490 }
6491 (void) SetImageOption(image_info,option+1,argv[i+1]);
6492 break;
6493 }
6494 if (LocaleCompare("endian",option+1) == 0)
6495 {
6496 if (*option == '+')
6497 {
6498 image_info->endian=UndefinedEndian;
6499 (void) SetImageOption(image_info,option+1,"undefined");
6500 break;
6501 }
cristy042ee782011-04-22 18:48:30 +00006502 image_info->endian=(EndianType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006503 MagickEndianOptions,MagickFalse,argv[i+1]);
6504 (void) SetImageOption(image_info,option+1,argv[i+1]);
6505 break;
6506 }
6507 if (LocaleCompare("extract",option+1) == 0)
6508 {
6509 /*
6510 Set image extract geometry.
6511 */
6512 if (*option == '+')
6513 {
6514 if (image_info->extract != (char *) NULL)
6515 image_info->extract=DestroyString(image_info->extract);
6516 break;
6517 }
6518 (void) CloneString(&image_info->extract,argv[i+1]);
6519 break;
6520 }
6521 break;
6522 }
6523 case 'f':
6524 {
6525 if (LocaleCompare("fill",option+1) == 0)
6526 {
6527 if (*option == '+')
6528 {
6529 (void) SetImageOption(image_info,option+1,"none");
6530 break;
6531 }
6532 (void) SetImageOption(image_info,option+1,argv[i+1]);
6533 break;
6534 }
6535 if (LocaleCompare("filter",option+1) == 0)
6536 {
6537 if (*option == '+')
6538 {
6539 (void) SetImageOption(image_info,option+1,"undefined");
6540 break;
6541 }
6542 (void) SetImageOption(image_info,option+1,argv[i+1]);
6543 break;
6544 }
6545 if (LocaleCompare("font",option+1) == 0)
6546 {
6547 if (*option == '+')
6548 {
6549 if (image_info->font != (char *) NULL)
6550 image_info->font=DestroyString(image_info->font);
6551 break;
6552 }
6553 (void) CloneString(&image_info->font,argv[i+1]);
6554 break;
6555 }
6556 if (LocaleCompare("format",option+1) == 0)
6557 {
6558 register const char
6559 *q;
6560
6561 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006562 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006563 image_info->ping=MagickFalse;
6564 (void) SetImageOption(image_info,option+1,argv[i+1]);
6565 break;
6566 }
6567 if (LocaleCompare("fuzz",option+1) == 0)
6568 {
6569 if (*option == '+')
6570 {
6571 image_info->fuzz=0.0;
6572 (void) SetImageOption(image_info,option+1,"0");
6573 break;
6574 }
cristydbdd0e32011-11-04 23:29:40 +00006575 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6576 QuantumRange+1.0);
cristy3ed852e2009-09-05 21:47:34 +00006577 (void) SetImageOption(image_info,option+1,argv[i+1]);
6578 break;
6579 }
6580 break;
6581 }
6582 case 'g':
6583 {
6584 if (LocaleCompare("gravity",option+1) == 0)
6585 {
6586 if (*option == '+')
6587 {
6588 (void) SetImageOption(image_info,option+1,"undefined");
6589 break;
6590 }
6591 (void) SetImageOption(image_info,option+1,argv[i+1]);
6592 break;
6593 }
6594 if (LocaleCompare("green-primary",option+1) == 0)
6595 {
6596 if (*option == '+')
6597 {
6598 (void) SetImageOption(image_info,option+1,"0.0");
6599 break;
6600 }
6601 (void) SetImageOption(image_info,option+1,argv[i+1]);
6602 break;
6603 }
6604 break;
6605 }
6606 case 'i':
6607 {
6608 if (LocaleCompare("intent",option+1) == 0)
6609 {
6610 if (*option == '+')
6611 {
6612 (void) SetImageOption(image_info,option+1,"undefined");
6613 break;
6614 }
6615 (void) SetImageOption(image_info,option+1,argv[i+1]);
6616 break;
6617 }
6618 if (LocaleCompare("interlace",option+1) == 0)
6619 {
6620 if (*option == '+')
6621 {
6622 image_info->interlace=UndefinedInterlace;
6623 (void) SetImageOption(image_info,option+1,"undefined");
6624 break;
6625 }
cristy042ee782011-04-22 18:48:30 +00006626 image_info->interlace=(InterlaceType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006627 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6628 (void) SetImageOption(image_info,option+1,argv[i+1]);
6629 break;
6630 }
cristyb32b90a2009-09-07 21:45:48 +00006631 if (LocaleCompare("interline-spacing",option+1) == 0)
6632 {
6633 if (*option == '+')
6634 {
6635 (void) SetImageOption(image_info,option+1,"undefined");
6636 break;
6637 }
6638 (void) SetImageOption(image_info,option+1,argv[i+1]);
6639 break;
6640 }
cristy3ed852e2009-09-05 21:47:34 +00006641 if (LocaleCompare("interpolate",option+1) == 0)
6642 {
6643 if (*option == '+')
6644 {
6645 (void) SetImageOption(image_info,option+1,"undefined");
6646 break;
6647 }
6648 (void) SetImageOption(image_info,option+1,argv[i+1]);
6649 break;
6650 }
6651 if (LocaleCompare("interword-spacing",option+1) == 0)
6652 {
6653 if (*option == '+')
6654 {
6655 (void) SetImageOption(image_info,option+1,"undefined");
6656 break;
6657 }
6658 (void) SetImageOption(image_info,option+1,argv[i+1]);
6659 break;
6660 }
6661 break;
6662 }
6663 case 'k':
6664 {
6665 if (LocaleCompare("kerning",option+1) == 0)
6666 {
6667 if (*option == '+')
6668 {
6669 (void) SetImageOption(image_info,option+1,"undefined");
6670 break;
6671 }
6672 (void) SetImageOption(image_info,option+1,argv[i+1]);
6673 break;
6674 }
6675 break;
6676 }
6677 case 'l':
6678 {
6679 if (LocaleCompare("label",option+1) == 0)
6680 {
6681 if (*option == '+')
6682 {
6683 (void) DeleteImageOption(image_info,option+1);
6684 break;
6685 }
6686 (void) SetImageOption(image_info,option+1,argv[i+1]);
6687 break;
6688 }
6689 if (LocaleCompare("limit",option+1) == 0)
6690 {
6691 MagickSizeType
6692 limit;
6693
6694 ResourceType
6695 type;
6696
6697 if (*option == '+')
6698 break;
cristy042ee782011-04-22 18:48:30 +00006699 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
cristy3ed852e2009-09-05 21:47:34 +00006700 MagickFalse,argv[i+1]);
6701 limit=MagickResourceInfinity;
6702 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyc0627342011-11-18 21:15:24 +00006703 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006704 (void) SetMagickResourceLimit(type,limit);
6705 break;
6706 }
6707 if (LocaleCompare("list",option+1) == 0)
6708 {
cristybb503372010-05-27 20:51:26 +00006709 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006710 list;
6711
6712 /*
6713 Display configuration list.
6714 */
cristy042ee782011-04-22 18:48:30 +00006715 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006716 switch (list)
6717 {
6718 case MagickCoderOptions:
6719 {
6720 (void) ListCoderInfo((FILE *) NULL,exception);
6721 break;
6722 }
6723 case MagickColorOptions:
6724 {
6725 (void) ListColorInfo((FILE *) NULL,exception);
6726 break;
6727 }
6728 case MagickConfigureOptions:
6729 {
6730 (void) ListConfigureInfo((FILE *) NULL,exception);
6731 break;
6732 }
6733 case MagickDelegateOptions:
6734 {
6735 (void) ListDelegateInfo((FILE *) NULL,exception);
6736 break;
6737 }
6738 case MagickFontOptions:
6739 {
6740 (void) ListTypeInfo((FILE *) NULL,exception);
6741 break;
6742 }
6743 case MagickFormatOptions:
6744 {
6745 (void) ListMagickInfo((FILE *) NULL,exception);
6746 break;
6747 }
6748 case MagickLocaleOptions:
6749 {
6750 (void) ListLocaleInfo((FILE *) NULL,exception);
6751 break;
6752 }
6753 case MagickLogOptions:
6754 {
6755 (void) ListLogInfo((FILE *) NULL,exception);
6756 break;
6757 }
6758 case MagickMagicOptions:
6759 {
6760 (void) ListMagicInfo((FILE *) NULL,exception);
6761 break;
6762 }
6763 case MagickMimeOptions:
6764 {
6765 (void) ListMimeInfo((FILE *) NULL,exception);
6766 break;
6767 }
6768 case MagickModuleOptions:
6769 {
6770 (void) ListModuleInfo((FILE *) NULL,exception);
6771 break;
6772 }
6773 case MagickPolicyOptions:
6774 {
6775 (void) ListPolicyInfo((FILE *) NULL,exception);
6776 break;
6777 }
6778 case MagickResourceOptions:
6779 {
6780 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6781 break;
6782 }
6783 case MagickThresholdOptions:
6784 {
6785 (void) ListThresholdMaps((FILE *) NULL,exception);
6786 break;
6787 }
6788 default:
6789 {
cristy042ee782011-04-22 18:48:30 +00006790 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
cristy3ed852e2009-09-05 21:47:34 +00006791 exception);
6792 break;
6793 }
6794 }
cristyaeb2cbc2010-05-07 13:28:58 +00006795 break;
cristy3ed852e2009-09-05 21:47:34 +00006796 }
6797 if (LocaleCompare("log",option+1) == 0)
6798 {
6799 if (*option == '+')
6800 break;
6801 (void) SetLogFormat(argv[i+1]);
6802 break;
6803 }
6804 if (LocaleCompare("loop",option+1) == 0)
6805 {
6806 if (*option == '+')
6807 {
6808 (void) SetImageOption(image_info,option+1,"0");
6809 break;
6810 }
6811 (void) SetImageOption(image_info,option+1,argv[i+1]);
6812 break;
6813 }
6814 break;
6815 }
6816 case 'm':
6817 {
6818 if (LocaleCompare("matte",option+1) == 0)
6819 {
6820 if (*option == '+')
6821 {
6822 (void) SetImageOption(image_info,option+1,"false");
6823 break;
6824 }
6825 (void) SetImageOption(image_info,option+1,"true");
6826 break;
6827 }
6828 if (LocaleCompare("mattecolor",option+1) == 0)
6829 {
6830 if (*option == '+')
6831 {
6832 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006833 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
cristy638895a2011-08-06 23:19:14 +00006834 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006835 break;
6836 }
6837 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy9950d572011-10-01 18:22:35 +00006838 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6839 &image_info->matte_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00006840 break;
6841 }
6842 if (LocaleCompare("monitor",option+1) == 0)
6843 {
6844 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6845 (void *) NULL);
6846 break;
6847 }
6848 if (LocaleCompare("monochrome",option+1) == 0)
6849 {
6850 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6851 break;
6852 }
6853 break;
6854 }
6855 case 'o':
6856 {
6857 if (LocaleCompare("orient",option+1) == 0)
6858 {
6859 if (*option == '+')
6860 {
6861 image_info->orientation=UndefinedOrientation;
6862 (void) SetImageOption(image_info,option+1,"undefined");
6863 break;
6864 }
cristy042ee782011-04-22 18:48:30 +00006865 image_info->orientation=(OrientationType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006866 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00006867 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006868 break;
6869 }
6870 }
6871 case 'p':
6872 {
6873 if (LocaleCompare("page",option+1) == 0)
6874 {
6875 char
6876 *canonical_page,
6877 page[MaxTextExtent];
6878
6879 const char
6880 *image_option;
6881
6882 MagickStatusType
6883 flags;
6884
6885 RectangleInfo
6886 geometry;
6887
6888 if (*option == '+')
6889 {
6890 (void) DeleteImageOption(image_info,option+1);
6891 (void) CloneString(&image_info->page,(char *) NULL);
6892 break;
6893 }
6894 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6895 image_option=GetImageOption(image_info,"page");
6896 if (image_option != (const char *) NULL)
6897 flags=ParseAbsoluteGeometry(image_option,&geometry);
6898 canonical_page=GetPageGeometry(argv[i+1]);
6899 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6900 canonical_page=DestroyString(canonical_page);
cristyb51dff52011-05-19 16:55:47 +00006901 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00006902 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00006903 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
cristyb51dff52011-05-19 16:55:47 +00006904 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00006905 (unsigned long) geometry.width,(unsigned long) geometry.height,
6906 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00006907 (void) SetImageOption(image_info,option+1,page);
6908 (void) CloneString(&image_info->page,page);
6909 break;
6910 }
6911 if (LocaleCompare("pen",option+1) == 0)
6912 {
6913 if (*option == '+')
6914 {
6915 (void) SetImageOption(image_info,option+1,"none");
6916 break;
6917 }
6918 (void) SetImageOption(image_info,option+1,argv[i+1]);
6919 break;
6920 }
6921 if (LocaleCompare("ping",option+1) == 0)
6922 {
6923 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6924 break;
6925 }
6926 if (LocaleCompare("pointsize",option+1) == 0)
6927 {
6928 if (*option == '+')
6929 geometry_info.rho=0.0;
6930 else
6931 (void) ParseGeometry(argv[i+1],&geometry_info);
6932 image_info->pointsize=geometry_info.rho;
6933 break;
6934 }
cristye7f51092010-01-17 00:39:37 +00006935 if (LocaleCompare("precision",option+1) == 0)
6936 {
cristybf2766a2010-01-17 03:33:23 +00006937 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00006938 break;
6939 }
cristy3ed852e2009-09-05 21:47:34 +00006940 if (LocaleCompare("preview",option+1) == 0)
6941 {
6942 /*
6943 Preview image.
6944 */
6945 if (*option == '+')
6946 {
6947 image_info->preview_type=UndefinedPreview;
6948 break;
6949 }
cristy042ee782011-04-22 18:48:30 +00006950 image_info->preview_type=(PreviewType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00006951 MagickPreviewOptions,MagickFalse,argv[i+1]);
6952 break;
6953 }
6954 break;
6955 }
6956 case 'q':
6957 {
6958 if (LocaleCompare("quality",option+1) == 0)
6959 {
6960 /*
6961 Set image compression quality.
6962 */
6963 if (*option == '+')
6964 {
6965 image_info->quality=UndefinedCompressionQuality;
6966 (void) SetImageOption(image_info,option+1,"0");
6967 break;
6968 }
cristye27293e2009-12-18 02:53:20 +00006969 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006970 (void) SetImageOption(image_info,option+1,argv[i+1]);
6971 break;
6972 }
6973 if (LocaleCompare("quiet",option+1) == 0)
6974 {
6975 static WarningHandler
6976 warning_handler = (WarningHandler) NULL;
6977
6978 if (*option == '+')
6979 {
6980 /*
6981 Restore error or warning messages.
6982 */
6983 warning_handler=SetWarningHandler(warning_handler);
6984 break;
6985 }
6986 /*
6987 Suppress error or warning messages.
6988 */
6989 warning_handler=SetWarningHandler((WarningHandler) NULL);
6990 break;
6991 }
6992 break;
6993 }
6994 case 'r':
6995 {
6996 if (LocaleCompare("red-primary",option+1) == 0)
6997 {
6998 if (*option == '+')
6999 {
7000 (void) SetImageOption(image_info,option+1,"0.0");
7001 break;
7002 }
7003 (void) SetImageOption(image_info,option+1,argv[i+1]);
7004 break;
7005 }
7006 break;
7007 }
7008 case 's':
7009 {
7010 if (LocaleCompare("sampling-factor",option+1) == 0)
7011 {
7012 /*
7013 Set image sampling factor.
7014 */
7015 if (*option == '+')
7016 {
7017 if (image_info->sampling_factor != (char *) NULL)
7018 image_info->sampling_factor=DestroyString(
7019 image_info->sampling_factor);
7020 break;
7021 }
7022 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7023 break;
7024 }
7025 if (LocaleCompare("scene",option+1) == 0)
7026 {
7027 /*
7028 Set image scene.
7029 */
7030 if (*option == '+')
7031 {
7032 image_info->scene=0;
7033 (void) SetImageOption(image_info,option+1,"0");
7034 break;
7035 }
cristye27293e2009-12-18 02:53:20 +00007036 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007037 (void) SetImageOption(image_info,option+1,argv[i+1]);
7038 break;
7039 }
7040 if (LocaleCompare("seed",option+1) == 0)
7041 {
cristybb503372010-05-27 20:51:26 +00007042 size_t
cristy3ed852e2009-09-05 21:47:34 +00007043 seed;
7044
7045 if (*option == '+')
7046 {
cristybb503372010-05-27 20:51:26 +00007047 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007048 SeedPseudoRandomGenerator(seed);
7049 break;
7050 }
cristye27293e2009-12-18 02:53:20 +00007051 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007052 SeedPseudoRandomGenerator(seed);
7053 break;
7054 }
7055 if (LocaleCompare("size",option+1) == 0)
7056 {
7057 if (*option == '+')
7058 {
7059 if (image_info->size != (char *) NULL)
7060 image_info->size=DestroyString(image_info->size);
7061 break;
7062 }
7063 (void) CloneString(&image_info->size,argv[i+1]);
7064 break;
7065 }
7066 if (LocaleCompare("stroke",option+1) == 0)
7067 {
7068 if (*option == '+')
7069 {
7070 (void) SetImageOption(image_info,option+1,"none");
7071 break;
7072 }
7073 (void) SetImageOption(image_info,option+1,argv[i+1]);
7074 break;
7075 }
7076 if (LocaleCompare("strokewidth",option+1) == 0)
7077 {
7078 if (*option == '+')
7079 {
7080 (void) SetImageOption(image_info,option+1,"0");
7081 break;
7082 }
7083 (void) SetImageOption(image_info,option+1,argv[i+1]);
7084 break;
7085 }
cristyd9a29192010-10-16 16:49:53 +00007086 if (LocaleCompare("synchronize",option+1) == 0)
7087 {
7088 if (*option == '+')
7089 {
7090 image_info->synchronize=MagickFalse;
7091 break;
7092 }
7093 image_info->synchronize=MagickTrue;
7094 break;
7095 }
cristy3ed852e2009-09-05 21:47:34 +00007096 break;
7097 }
7098 case 't':
7099 {
7100 if (LocaleCompare("taint",option+1) == 0)
7101 {
7102 if (*option == '+')
7103 {
7104 (void) SetImageOption(image_info,option+1,"false");
7105 break;
7106 }
7107 (void) SetImageOption(image_info,option+1,"true");
7108 break;
7109 }
7110 if (LocaleCompare("texture",option+1) == 0)
7111 {
7112 if (*option == '+')
7113 {
7114 if (image_info->texture != (char *) NULL)
7115 image_info->texture=DestroyString(image_info->texture);
7116 break;
7117 }
7118 (void) CloneString(&image_info->texture,argv[i+1]);
7119 break;
7120 }
7121 if (LocaleCompare("tile-offset",option+1) == 0)
7122 {
7123 if (*option == '+')
7124 {
7125 (void) SetImageOption(image_info,option+1,"0");
7126 break;
7127 }
7128 (void) SetImageOption(image_info,option+1,argv[i+1]);
7129 break;
7130 }
7131 if (LocaleCompare("transparent-color",option+1) == 0)
7132 {
7133 if (*option == '+')
7134 {
cristy9950d572011-10-01 18:22:35 +00007135 (void) QueryColorCompliance("none",AllCompliance,
7136 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007137 (void) SetImageOption(image_info,option+1,"none");
7138 break;
7139 }
cristy9950d572011-10-01 18:22:35 +00007140 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7141 &image_info->transparent_color,exception);
cristy3ed852e2009-09-05 21:47:34 +00007142 (void) SetImageOption(image_info,option+1,argv[i+1]);
7143 break;
7144 }
7145 if (LocaleCompare("type",option+1) == 0)
7146 {
7147 if (*option == '+')
7148 {
cristy5f1c1ff2010-12-23 21:38:06 +00007149 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007150 (void) SetImageOption(image_info,option+1,"undefined");
7151 break;
7152 }
cristy042ee782011-04-22 18:48:30 +00007153 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
cristy3ed852e2009-09-05 21:47:34 +00007154 MagickFalse,argv[i+1]);
7155 (void) SetImageOption(image_info,option+1,argv[i+1]);
7156 break;
7157 }
7158 break;
7159 }
7160 case 'u':
7161 {
7162 if (LocaleCompare("undercolor",option+1) == 0)
7163 {
7164 if (*option == '+')
7165 {
7166 (void) DeleteImageOption(image_info,option+1);
7167 break;
7168 }
7169 (void) SetImageOption(image_info,option+1,argv[i+1]);
7170 break;
7171 }
7172 if (LocaleCompare("units",option+1) == 0)
7173 {
7174 if (*option == '+')
7175 {
7176 image_info->units=UndefinedResolution;
7177 (void) SetImageOption(image_info,option+1,"undefined");
7178 break;
7179 }
cristy042ee782011-04-22 18:48:30 +00007180 image_info->units=(ResolutionType) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007181 MagickResolutionOptions,MagickFalse,argv[i+1]);
7182 (void) SetImageOption(image_info,option+1,argv[i+1]);
7183 break;
7184 }
7185 break;
7186 }
7187 case 'v':
7188 {
7189 if (LocaleCompare("verbose",option+1) == 0)
7190 {
7191 if (*option == '+')
7192 {
7193 image_info->verbose=MagickFalse;
7194 break;
7195 }
7196 image_info->verbose=MagickTrue;
7197 image_info->ping=MagickFalse;
7198 break;
7199 }
7200 if (LocaleCompare("view",option+1) == 0)
7201 {
7202 if (*option == '+')
7203 {
7204 if (image_info->view != (char *) NULL)
7205 image_info->view=DestroyString(image_info->view);
7206 break;
7207 }
7208 (void) CloneString(&image_info->view,argv[i+1]);
7209 break;
7210 }
7211 if (LocaleCompare("virtual-pixel",option+1) == 0)
7212 {
7213 if (*option == '+')
7214 {
7215 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7216 (void) SetImageOption(image_info,option+1,"undefined");
7217 break;
7218 }
7219 image_info->virtual_pixel_method=(VirtualPixelMethod)
cristy042ee782011-04-22 18:48:30 +00007220 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00007221 argv[i+1]);
7222 (void) SetImageOption(image_info,option+1,argv[i+1]);
7223 break;
7224 }
7225 break;
7226 }
7227 case 'w':
7228 {
7229 if (LocaleCompare("white-point",option+1) == 0)
7230 {
7231 if (*option == '+')
7232 {
7233 (void) SetImageOption(image_info,option+1,"0.0");
7234 break;
7235 }
7236 (void) SetImageOption(image_info,option+1,argv[i+1]);
7237 break;
7238 }
7239 break;
7240 }
7241 default:
7242 break;
7243 }
7244 i+=count;
7245 }
7246 return(MagickTrue);
7247}
7248
7249/*
7250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7251% %
7252% %
7253% %
7254+ M o g r i f y I m a g e L i s t %
7255% %
7256% %
7257% %
7258%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7259%
7260% MogrifyImageList() applies any command line options that might affect the
7261% entire image list (e.g. -append, -coalesce, etc.).
7262%
7263% The format of the MogrifyImage method is:
7264%
7265% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7266% const char **argv,Image **images,ExceptionInfo *exception)
7267%
7268% A description of each parameter follows:
7269%
7270% o image_info: the image info..
7271%
7272% o argc: Specifies a pointer to an integer describing the number of
7273% elements in the argument vector.
7274%
7275% o argv: Specifies a pointer to a text array containing the command line
7276% arguments.
7277%
anthonye9c27192011-03-27 08:07:06 +00007278% o images: pointer to pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00007279%
7280% o exception: return any errors or warnings in this structure.
7281%
7282*/
7283WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7284 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7285{
cristy3ed852e2009-09-05 21:47:34 +00007286 const char
7287 *option;
7288
cristy6b3da3a2010-06-20 02:21:46 +00007289 ImageInfo
7290 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007291
7292 MagickStatusType
7293 status;
7294
cristy28474bf2011-09-11 23:32:52 +00007295 PixelInterpolateMethod
7296 interpolate_method;
7297
cristy3ed852e2009-09-05 21:47:34 +00007298 QuantizeInfo
7299 *quantize_info;
7300
cristybb503372010-05-27 20:51:26 +00007301 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007302 i;
7303
cristy6b3da3a2010-06-20 02:21:46 +00007304 ssize_t
7305 count,
7306 index;
7307
cristy3ed852e2009-09-05 21:47:34 +00007308 /*
7309 Apply options to the image list.
7310 */
7311 assert(image_info != (ImageInfo *) NULL);
7312 assert(image_info->signature == MagickSignature);
7313 assert(images != (Image **) NULL);
anthonye9c27192011-03-27 08:07:06 +00007314 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007315 assert((*images)->signature == MagickSignature);
7316 if ((*images)->debug != MagickFalse)
7317 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7318 (*images)->filename);
7319 if ((argc <= 0) || (*argv == (char *) NULL))
7320 return(MagickTrue);
cristy28474bf2011-09-11 23:32:52 +00007321 interpolate_method=UndefinedInterpolatePixel;
cristy6b3da3a2010-06-20 02:21:46 +00007322 mogrify_info=CloneImageInfo(image_info);
7323 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00007324 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007325 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007326 {
cristy74fe8f12009-10-03 19:09:01 +00007327 if (*images == (Image *) NULL)
7328 break;
cristy3ed852e2009-09-05 21:47:34 +00007329 option=argv[i];
cristy042ee782011-04-22 18:48:30 +00007330 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00007331 continue;
cristy042ee782011-04-22 18:48:30 +00007332 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
anthonyce2716b2011-04-22 09:51:34 +00007333 count=MagickMax(count,0L);
cristycee97112010-05-28 00:44:52 +00007334 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007335 break;
cristy6b3da3a2010-06-20 02:21:46 +00007336 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007337 switch (*(option+1))
7338 {
7339 case 'a':
7340 {
7341 if (LocaleCompare("affinity",option+1) == 0)
7342 {
cristy6fccee12011-10-20 18:43:18 +00007343 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007344 if (*option == '+')
7345 {
cristy018f07f2011-09-04 21:15:19 +00007346 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7347 exception);
cristy3ed852e2009-09-05 21:47:34 +00007348 break;
7349 }
7350 i++;
7351 break;
7352 }
7353 if (LocaleCompare("append",option+1) == 0)
7354 {
7355 Image
7356 *append_image;
7357
cristy6fccee12011-10-20 18:43:18 +00007358 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007359 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7360 MagickFalse,exception);
7361 if (append_image == (Image *) NULL)
7362 {
7363 status=MagickFalse;
7364 break;
7365 }
7366 *images=DestroyImageList(*images);
7367 *images=append_image;
7368 break;
7369 }
7370 if (LocaleCompare("average",option+1) == 0)
7371 {
7372 Image
7373 *average_image;
7374
cristyd18ae7c2010-03-07 17:39:52 +00007375 /*
7376 Average an image sequence (deprecated).
7377 */
cristy6fccee12011-10-20 18:43:18 +00007378 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristyd18ae7c2010-03-07 17:39:52 +00007379 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7380 exception);
cristy3ed852e2009-09-05 21:47:34 +00007381 if (average_image == (Image *) NULL)
7382 {
7383 status=MagickFalse;
7384 break;
7385 }
7386 *images=DestroyImageList(*images);
7387 *images=average_image;
7388 break;
7389 }
7390 break;
7391 }
7392 case 'c':
7393 {
7394 if (LocaleCompare("channel",option+1) == 0)
7395 {
cristyf4ad9df2011-07-08 16:49:03 +00007396 ChannelType
7397 channel;
7398
cristy3ed852e2009-09-05 21:47:34 +00007399 if (*option == '+')
7400 {
7401 channel=DefaultChannels;
7402 break;
7403 }
7404 channel=(ChannelType) ParseChannelOption(argv[i+1]);
cristye2a912b2011-12-05 20:02:07 +00007405 SetPixelChannelMapMask(*images,channel);
cristy3ed852e2009-09-05 21:47:34 +00007406 break;
7407 }
7408 if (LocaleCompare("clut",option+1) == 0)
7409 {
7410 Image
7411 *clut_image,
7412 *image;
7413
cristy6fccee12011-10-20 18:43:18 +00007414 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007415 image=RemoveFirstImageFromList(images);
7416 clut_image=RemoveFirstImageFromList(images);
7417 if (clut_image == (Image *) NULL)
7418 {
7419 status=MagickFalse;
7420 break;
7421 }
cristy28474bf2011-09-11 23:32:52 +00007422 (void) ClutImage(image,clut_image,interpolate_method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007423 clut_image=DestroyImage(clut_image);
cristy3ed852e2009-09-05 21:47:34 +00007424 *images=DestroyImageList(*images);
7425 *images=image;
7426 break;
7427 }
7428 if (LocaleCompare("coalesce",option+1) == 0)
7429 {
7430 Image
7431 *coalesce_image;
7432
cristy6fccee12011-10-20 18:43:18 +00007433 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007434 coalesce_image=CoalesceImages(*images,exception);
7435 if (coalesce_image == (Image *) NULL)
7436 {
7437 status=MagickFalse;
7438 break;
7439 }
7440 *images=DestroyImageList(*images);
7441 *images=coalesce_image;
7442 break;
7443 }
7444 if (LocaleCompare("combine",option+1) == 0)
7445 {
7446 Image
7447 *combine_image;
7448
cristy6fccee12011-10-20 18:43:18 +00007449 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3139dc22011-07-08 00:11:42 +00007450 combine_image=CombineImages(*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007451 if (combine_image == (Image *) NULL)
7452 {
7453 status=MagickFalse;
7454 break;
7455 }
7456 *images=DestroyImageList(*images);
7457 *images=combine_image;
7458 break;
7459 }
7460 if (LocaleCompare("composite",option+1) == 0)
7461 {
7462 Image
7463 *mask_image,
7464 *composite_image,
7465 *image;
7466
7467 RectangleInfo
7468 geometry;
7469
cristy6fccee12011-10-20 18:43:18 +00007470 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007471 image=RemoveFirstImageFromList(images);
7472 composite_image=RemoveFirstImageFromList(images);
7473 if (composite_image == (Image *) NULL)
7474 {
7475 status=MagickFalse;
7476 break;
7477 }
7478 (void) TransformImage(&composite_image,(char *) NULL,
cristye941a752011-10-15 01:52:48 +00007479 composite_image->geometry,exception);
cristy3ed852e2009-09-05 21:47:34 +00007480 SetGeometry(composite_image,&geometry);
7481 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7482 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7483 &geometry);
7484 mask_image=RemoveFirstImageFromList(images);
7485 if (mask_image != (Image *) NULL)
7486 {
7487 if ((image->compose == DisplaceCompositeOp) ||
7488 (image->compose == DistortCompositeOp))
7489 {
7490 /*
7491 Merge Y displacement into X displacement image.
7492 */
7493 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
cristye941a752011-10-15 01:52:48 +00007494 mask_image,0,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00007495 mask_image=DestroyImage(mask_image);
7496 }
7497 else
7498 {
7499 /*
7500 Set a blending mask for the composition.
cristy28474bf2011-09-11 23:32:52 +00007501 Posible error, what if image->mask already set.
cristy3ed852e2009-09-05 21:47:34 +00007502 */
7503 image->mask=mask_image;
cristyb3e7c6c2011-07-24 01:43:55 +00007504 (void) NegateImage(image->mask,MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007505 }
7506 }
cristyf4ad9df2011-07-08 16:49:03 +00007507 (void) CompositeImage(image,image->compose,composite_image,
cristye941a752011-10-15 01:52:48 +00007508 geometry.x,geometry.y,exception);
anthonya129f702011-04-14 01:08:48 +00007509 if (mask_image != (Image *) NULL)
7510 mask_image=image->mask=DestroyImage(image->mask);
cristy3ed852e2009-09-05 21:47:34 +00007511 composite_image=DestroyImage(composite_image);
cristy3ed852e2009-09-05 21:47:34 +00007512 *images=DestroyImageList(*images);
7513 *images=image;
7514 break;
7515 }
cristy3ed852e2009-09-05 21:47:34 +00007516 break;
7517 }
7518 case 'd':
7519 {
7520 if (LocaleCompare("deconstruct",option+1) == 0)
7521 {
7522 Image
7523 *deconstruct_image;
7524
cristy6fccee12011-10-20 18:43:18 +00007525 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy8a9106f2011-07-05 14:39:26 +00007526 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
cristy4c08aed2011-07-01 19:47:50 +00007527 exception);
cristy3ed852e2009-09-05 21:47:34 +00007528 if (deconstruct_image == (Image *) NULL)
7529 {
7530 status=MagickFalse;
7531 break;
7532 }
7533 *images=DestroyImageList(*images);
7534 *images=deconstruct_image;
7535 break;
7536 }
7537 if (LocaleCompare("delete",option+1) == 0)
7538 {
7539 if (*option == '+')
7540 DeleteImages(images,"-1",exception);
7541 else
7542 DeleteImages(images,argv[i+1],exception);
7543 break;
7544 }
7545 if (LocaleCompare("dither",option+1) == 0)
7546 {
7547 if (*option == '+')
7548 {
7549 quantize_info->dither=MagickFalse;
7550 break;
7551 }
7552 quantize_info->dither=MagickTrue;
cristy042ee782011-04-22 18:48:30 +00007553 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007554 MagickDitherOptions,MagickFalse,argv[i+1]);
7555 break;
7556 }
cristyecb10ff2011-03-22 13:14:03 +00007557 if (LocaleCompare("duplicate",option+1) == 0)
7558 {
cristy72988482011-03-29 16:34:38 +00007559 Image
7560 *duplicate_images;
cristybf95deb2011-03-23 00:25:36 +00007561
anthony2b6bcae2011-03-23 13:05:34 +00007562 if (*option == '+')
cristy72988482011-03-29 16:34:38 +00007563 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7564 else
7565 {
7566 const char
7567 *p;
7568
anthony2b6bcae2011-03-23 13:05:34 +00007569 size_t
7570 number_duplicates;
anthony9bd15492011-03-23 02:11:13 +00007571
anthony2b6bcae2011-03-23 13:05:34 +00007572 number_duplicates=(size_t) StringToLong(argv[i+1]);
cristy72988482011-03-29 16:34:38 +00007573 p=strchr(argv[i+1],',');
7574 if (p == (const char *) NULL)
7575 duplicate_images=DuplicateImages(*images,number_duplicates,
7576 "-1",exception);
anthony2b6bcae2011-03-23 13:05:34 +00007577 else
cristy72988482011-03-29 16:34:38 +00007578 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7579 exception);
anthony2b6bcae2011-03-23 13:05:34 +00007580 }
7581 AppendImageToList(images, duplicate_images);
cristy6fccee12011-10-20 18:43:18 +00007582 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristyecb10ff2011-03-22 13:14:03 +00007583 break;
7584 }
cristy3ed852e2009-09-05 21:47:34 +00007585 break;
7586 }
cristyd18ae7c2010-03-07 17:39:52 +00007587 case 'e':
7588 {
7589 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7590 {
7591 Image
7592 *evaluate_image;
7593
7594 MagickEvaluateOperator
7595 op;
7596
cristy6fccee12011-10-20 18:43:18 +00007597 (void) SyncImageSettings(mogrify_info,*images,exception);
cristy28474bf2011-09-11 23:32:52 +00007598 op=(MagickEvaluateOperator) ParseCommandOption(
7599 MagickEvaluateOptions,MagickFalse,argv[i+1]);
cristyd18ae7c2010-03-07 17:39:52 +00007600 evaluate_image=EvaluateImages(*images,op,exception);
7601 if (evaluate_image == (Image *) NULL)
7602 {
7603 status=MagickFalse;
7604 break;
7605 }
7606 *images=DestroyImageList(*images);
7607 *images=evaluate_image;
7608 break;
7609 }
7610 break;
7611 }
cristy3ed852e2009-09-05 21:47:34 +00007612 case 'f':
7613 {
cristyf0a247f2009-10-04 00:20:03 +00007614 if (LocaleCompare("fft",option+1) == 0)
7615 {
7616 Image
7617 *fourier_image;
7618
7619 /*
7620 Implements the discrete Fourier transform (DFT).
7621 */
cristy6fccee12011-10-20 18:43:18 +00007622 (void) SyncImageSettings(mogrify_info,*images,exception);
cristyf0a247f2009-10-04 00:20:03 +00007623 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7624 MagickTrue : MagickFalse,exception);
7625 if (fourier_image == (Image *) NULL)
7626 break;
7627 *images=DestroyImage(*images);
7628 *images=fourier_image;
7629 break;
7630 }
cristy3ed852e2009-09-05 21:47:34 +00007631 if (LocaleCompare("flatten",option+1) == 0)
7632 {
7633 Image
7634 *flatten_image;
7635
cristy6fccee12011-10-20 18:43:18 +00007636 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007637 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7638 if (flatten_image == (Image *) NULL)
7639 break;
7640 *images=DestroyImageList(*images);
7641 *images=flatten_image;
7642 break;
7643 }
7644 if (LocaleCompare("fx",option+1) == 0)
7645 {
7646 Image
7647 *fx_image;
7648
cristy6fccee12011-10-20 18:43:18 +00007649 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy490408a2011-07-07 14:42:05 +00007650 fx_image=FxImage(*images,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00007651 if (fx_image == (Image *) NULL)
7652 {
7653 status=MagickFalse;
7654 break;
7655 }
7656 *images=DestroyImageList(*images);
7657 *images=fx_image;
7658 break;
7659 }
7660 break;
7661 }
7662 case 'h':
7663 {
7664 if (LocaleCompare("hald-clut",option+1) == 0)
7665 {
7666 Image
7667 *hald_image,
7668 *image;
7669
cristy6fccee12011-10-20 18:43:18 +00007670 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007671 image=RemoveFirstImageFromList(images);
7672 hald_image=RemoveFirstImageFromList(images);
7673 if (hald_image == (Image *) NULL)
7674 {
7675 status=MagickFalse;
7676 break;
7677 }
cristy7c0a0a42011-08-23 17:57:25 +00007678 (void) HaldClutImage(image,hald_image,exception);
cristy3ed852e2009-09-05 21:47:34 +00007679 hald_image=DestroyImage(hald_image);
cristy0aff6ea2009-11-14 01:40:53 +00007680 if (*images != (Image *) NULL)
7681 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00007682 *images=image;
7683 break;
7684 }
7685 break;
7686 }
7687 case 'i':
7688 {
7689 if (LocaleCompare("ift",option+1) == 0)
7690 {
7691 Image
cristy8587f882009-11-13 20:28:49 +00007692 *fourier_image,
7693 *magnitude_image,
7694 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00007695
7696 /*
7697 Implements the inverse fourier discrete Fourier transform (DFT).
7698 */
cristy6fccee12011-10-20 18:43:18 +00007699 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy8587f882009-11-13 20:28:49 +00007700 magnitude_image=RemoveFirstImageFromList(images);
7701 phase_image=RemoveFirstImageFromList(images);
7702 if (phase_image == (Image *) NULL)
7703 {
7704 status=MagickFalse;
7705 break;
7706 }
7707 fourier_image=InverseFourierTransformImage(magnitude_image,
7708 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00007709 if (fourier_image == (Image *) NULL)
7710 break;
cristy0aff6ea2009-11-14 01:40:53 +00007711 if (*images != (Image *) NULL)
7712 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00007713 *images=fourier_image;
7714 break;
7715 }
7716 if (LocaleCompare("insert",option+1) == 0)
7717 {
7718 Image
7719 *p,
7720 *q;
7721
7722 index=0;
7723 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00007724 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007725 p=RemoveLastImageFromList(images);
7726 if (p == (Image *) NULL)
7727 {
7728 (void) ThrowMagickException(exception,GetMagickModule(),
7729 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7730 status=MagickFalse;
7731 break;
7732 }
7733 q=p;
7734 if (index == 0)
7735 PrependImageToList(images,q);
7736 else
cristybb503372010-05-27 20:51:26 +00007737 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00007738 AppendImageToList(images,q);
7739 else
7740 {
7741 q=GetImageFromList(*images,index-1);
7742 if (q == (Image *) NULL)
7743 {
7744 (void) ThrowMagickException(exception,GetMagickModule(),
7745 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7746 status=MagickFalse;
7747 break;
7748 }
7749 InsertImageInList(&q,p);
7750 }
7751 *images=GetFirstImageInList(q);
7752 break;
7753 }
cristy28474bf2011-09-11 23:32:52 +00007754 if (LocaleCompare("interpolate",option+1) == 0)
7755 {
7756 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7757 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7758 break;
7759 }
cristy3ed852e2009-09-05 21:47:34 +00007760 break;
7761 }
7762 case 'l':
7763 {
7764 if (LocaleCompare("layers",option+1) == 0)
7765 {
7766 Image
7767 *layers;
7768
7769 ImageLayerMethod
7770 method;
7771
cristy6fccee12011-10-20 18:43:18 +00007772 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007773 layers=(Image *) NULL;
cristy042ee782011-04-22 18:48:30 +00007774 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
cristy3ed852e2009-09-05 21:47:34 +00007775 MagickFalse,argv[i+1]);
7776 switch (method)
7777 {
7778 case CoalesceLayer:
7779 {
7780 layers=CoalesceImages(*images,exception);
7781 break;
7782 }
7783 case CompareAnyLayer:
7784 case CompareClearLayer:
7785 case CompareOverlayLayer:
7786 default:
7787 {
cristy8a9106f2011-07-05 14:39:26 +00007788 layers=CompareImagesLayers(*images,method,exception);
cristy3ed852e2009-09-05 21:47:34 +00007789 break;
7790 }
7791 case MergeLayer:
7792 case FlattenLayer:
7793 case MosaicLayer:
7794 case TrimBoundsLayer:
7795 {
7796 layers=MergeImageLayers(*images,method,exception);
7797 break;
7798 }
7799 case DisposeLayer:
7800 {
7801 layers=DisposeImages(*images,exception);
7802 break;
7803 }
7804 case OptimizeImageLayer:
7805 {
7806 layers=OptimizeImageLayers(*images,exception);
7807 break;
7808 }
7809 case OptimizePlusLayer:
7810 {
7811 layers=OptimizePlusImageLayers(*images,exception);
7812 break;
7813 }
7814 case OptimizeTransLayer:
7815 {
7816 OptimizeImageTransparency(*images,exception);
7817 break;
7818 }
7819 case RemoveDupsLayer:
7820 {
7821 RemoveDuplicateLayers(images,exception);
7822 break;
7823 }
7824 case RemoveZeroLayer:
7825 {
7826 RemoveZeroDelayLayers(images,exception);
7827 break;
7828 }
7829 case OptimizeLayer:
7830 {
7831 /*
7832 General Purpose, GIF Animation Optimizer.
7833 */
7834 layers=CoalesceImages(*images,exception);
7835 if (layers == (Image *) NULL)
7836 {
7837 status=MagickFalse;
7838 break;
7839 }
cristy3ed852e2009-09-05 21:47:34 +00007840 *images=DestroyImageList(*images);
7841 *images=layers;
7842 layers=OptimizeImageLayers(*images,exception);
7843 if (layers == (Image *) NULL)
7844 {
7845 status=MagickFalse;
7846 break;
7847 }
cristy3ed852e2009-09-05 21:47:34 +00007848 *images=DestroyImageList(*images);
7849 *images=layers;
7850 layers=(Image *) NULL;
7851 OptimizeImageTransparency(*images,exception);
cristy018f07f2011-09-04 21:15:19 +00007852 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7853 exception);
cristy3ed852e2009-09-05 21:47:34 +00007854 break;
7855 }
7856 case CompositeLayer:
7857 {
7858 CompositeOperator
7859 compose;
7860
7861 Image
7862 *source;
7863
7864 RectangleInfo
7865 geometry;
7866
7867 /*
7868 Split image sequence at the first 'NULL:' image.
7869 */
7870 source=(*images);
7871 while (source != (Image *) NULL)
7872 {
7873 source=GetNextImageInList(source);
7874 if ((source != (Image *) NULL) &&
7875 (LocaleCompare(source->magick,"NULL") == 0))
7876 break;
7877 }
7878 if (source != (Image *) NULL)
7879 {
7880 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7881 (GetNextImageInList(source) == (Image *) NULL))
7882 source=(Image *) NULL;
7883 else
7884 {
7885 /*
7886 Separate the two lists, junk the null: image.
7887 */
7888 source=SplitImageList(source->previous);
7889 DeleteImageFromList(&source);
7890 }
7891 }
7892 if (source == (Image *) NULL)
7893 {
7894 (void) ThrowMagickException(exception,GetMagickModule(),
7895 OptionError,"MissingNullSeparator","layers Composite");
7896 status=MagickFalse;
7897 break;
7898 }
7899 /*
7900 Adjust offset with gravity and virtual canvas.
7901 */
7902 SetGeometry(*images,&geometry);
7903 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7904 geometry.width=source->page.width != 0 ?
7905 source->page.width : source->columns;
7906 geometry.height=source->page.height != 0 ?
7907 source->page.height : source->rows;
7908 GravityAdjustGeometry((*images)->page.width != 0 ?
7909 (*images)->page.width : (*images)->columns,
7910 (*images)->page.height != 0 ? (*images)->page.height :
7911 (*images)->rows,(*images)->gravity,&geometry);
7912 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00007913 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00007914 if (option != (const char *) NULL)
cristy042ee782011-04-22 18:48:30 +00007915 compose=(CompositeOperator) ParseCommandOption(
cristy3ed852e2009-09-05 21:47:34 +00007916 MagickComposeOptions,MagickFalse,option);
7917 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7918 exception);
7919 source=DestroyImageList(source);
7920 break;
7921 }
7922 }
7923 if (layers == (Image *) NULL)
7924 break;
cristy3ed852e2009-09-05 21:47:34 +00007925 *images=DestroyImageList(*images);
7926 *images=layers;
7927 break;
7928 }
7929 break;
7930 }
7931 case 'm':
7932 {
7933 if (LocaleCompare("map",option+1) == 0)
7934 {
cristy6fccee12011-10-20 18:43:18 +00007935 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00007936 if (*option == '+')
7937 {
cristy018f07f2011-09-04 21:15:19 +00007938 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7939 exception);
cristy3ed852e2009-09-05 21:47:34 +00007940 break;
7941 }
7942 i++;
7943 break;
7944 }
cristyf40785b2010-03-06 02:27:27 +00007945 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007946 {
7947 Image
cristyf40785b2010-03-06 02:27:27 +00007948 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007949
cristyd18ae7c2010-03-07 17:39:52 +00007950 /*
7951 Maximum image sequence (deprecated).
7952 */
cristy6fccee12011-10-20 18:43:18 +00007953 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristyd18ae7c2010-03-07 17:39:52 +00007954 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007955 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007956 {
7957 status=MagickFalse;
7958 break;
7959 }
7960 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007961 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00007962 break;
7963 }
cristyf40785b2010-03-06 02:27:27 +00007964 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00007965 {
7966 Image
cristyf40785b2010-03-06 02:27:27 +00007967 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007968
cristyd18ae7c2010-03-07 17:39:52 +00007969 /*
7970 Minimum image sequence (deprecated).
7971 */
cristy6fccee12011-10-20 18:43:18 +00007972 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristyd18ae7c2010-03-07 17:39:52 +00007973 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00007974 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00007975 {
7976 status=MagickFalse;
7977 break;
7978 }
7979 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00007980 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00007981 break;
7982 }
cristy3ed852e2009-09-05 21:47:34 +00007983 if (LocaleCompare("morph",option+1) == 0)
7984 {
7985 Image
7986 *morph_image;
7987
cristy6fccee12011-10-20 18:43:18 +00007988 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristye27293e2009-12-18 02:53:20 +00007989 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00007990 exception);
7991 if (morph_image == (Image *) NULL)
7992 {
7993 status=MagickFalse;
7994 break;
7995 }
7996 *images=DestroyImageList(*images);
7997 *images=morph_image;
7998 break;
7999 }
8000 if (LocaleCompare("mosaic",option+1) == 0)
8001 {
8002 Image
8003 *mosaic_image;
8004
cristy6fccee12011-10-20 18:43:18 +00008005 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008006 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8007 if (mosaic_image == (Image *) NULL)
8008 {
8009 status=MagickFalse;
8010 break;
8011 }
8012 *images=DestroyImageList(*images);
8013 *images=mosaic_image;
8014 break;
8015 }
8016 break;
8017 }
8018 case 'p':
8019 {
8020 if (LocaleCompare("print",option+1) == 0)
8021 {
8022 char
8023 *string;
8024
cristy6fccee12011-10-20 18:43:18 +00008025 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy018f07f2011-09-04 21:15:19 +00008026 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8027 exception);
cristy3ed852e2009-09-05 21:47:34 +00008028 if (string == (char *) NULL)
8029 break;
cristyb51dff52011-05-19 16:55:47 +00008030 (void) FormatLocaleFile(stdout,"%s",string);
cristy3ed852e2009-09-05 21:47:34 +00008031 string=DestroyString(string);
8032 }
8033 if (LocaleCompare("process",option+1) == 0)
8034 {
8035 char
8036 **arguments;
8037
8038 int
8039 j,
8040 number_arguments;
8041
cristy6fccee12011-10-20 18:43:18 +00008042 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008043 arguments=StringToArgv(argv[i+1],&number_arguments);
8044 if (arguments == (char **) NULL)
8045 break;
8046 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8047 {
8048 char
8049 breaker,
8050 quote,
8051 *token;
8052
8053 const char
8054 *arguments;
8055
8056 int
8057 next,
8058 status;
8059
8060 size_t
8061 length;
8062
8063 TokenInfo
8064 *token_info;
8065
8066 /*
8067 Support old style syntax, filter="-option arg".
8068 */
8069 length=strlen(argv[i+1]);
8070 token=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +00008071 if (~length >= (MaxTextExtent-1))
cristy3ed852e2009-09-05 21:47:34 +00008072 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8073 sizeof(*token));
8074 if (token == (char *) NULL)
8075 break;
8076 next=0;
8077 arguments=argv[i+1];
8078 token_info=AcquireTokenInfo();
8079 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8080 "\"",'\0',&breaker,&next,&quote);
8081 token_info=DestroyTokenInfo(token_info);
8082 if (status == 0)
8083 {
8084 const char
8085 *argv;
8086
8087 argv=(&(arguments[next]));
8088 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8089 exception);
8090 }
8091 token=DestroyString(token);
8092 break;
8093 }
cristy91c0da22010-05-02 01:44:07 +00008094 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008095 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8096 number_arguments-2,(const char **) arguments+2,exception);
8097 for (j=0; j < number_arguments; j++)
8098 arguments[j]=DestroyString(arguments[j]);
8099 arguments=(char **) RelinquishMagickMemory(arguments);
8100 break;
8101 }
8102 break;
8103 }
8104 case 'r':
8105 {
8106 if (LocaleCompare("reverse",option+1) == 0)
8107 {
8108 ReverseImageList(images);
cristy3ed852e2009-09-05 21:47:34 +00008109 break;
8110 }
8111 break;
8112 }
8113 case 's':
8114 {
cristy4285d782011-02-09 20:12:28 +00008115 if (LocaleCompare("smush",option+1) == 0)
8116 {
8117 Image
8118 *smush_image;
8119
8120 ssize_t
8121 offset;
8122
cristy6fccee12011-10-20 18:43:18 +00008123 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristy4285d782011-02-09 20:12:28 +00008124 offset=(ssize_t) StringToLong(argv[i+1]);
8125 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8126 MagickFalse,offset,exception);
8127 if (smush_image == (Image *) NULL)
8128 {
8129 status=MagickFalse;
8130 break;
8131 }
8132 *images=DestroyImageList(*images);
8133 *images=smush_image;
8134 break;
8135 }
cristy3ed852e2009-09-05 21:47:34 +00008136 if (LocaleCompare("swap",option+1) == 0)
8137 {
8138 Image
8139 *p,
8140 *q,
8141 *swap;
8142
cristybb503372010-05-27 20:51:26 +00008143 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008144 swap_index;
8145
8146 index=(-1);
8147 swap_index=(-2);
8148 if (*option != '+')
8149 {
8150 GeometryInfo
8151 geometry_info;
8152
8153 MagickStatusType
8154 flags;
8155
8156 swap_index=(-1);
8157 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008158 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008159 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008160 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008161 }
8162 p=GetImageFromList(*images,index);
8163 q=GetImageFromList(*images,swap_index);
8164 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8165 {
8166 (void) ThrowMagickException(exception,GetMagickModule(),
8167 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8168 status=MagickFalse;
8169 break;
8170 }
8171 if (p == q)
8172 break;
8173 swap=CloneImage(p,0,0,MagickTrue,exception);
8174 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8175 ReplaceImageInList(&q,swap);
8176 *images=GetFirstImageInList(q);
8177 break;
8178 }
8179 break;
8180 }
8181 case 'w':
8182 {
8183 if (LocaleCompare("write",option+1) == 0)
8184 {
cristy071dd7b2010-04-09 13:04:54 +00008185 char
cristy06609ee2010-03-17 20:21:27 +00008186 key[MaxTextExtent];
8187
cristy3ed852e2009-09-05 21:47:34 +00008188 Image
8189 *write_images;
8190
8191 ImageInfo
8192 *write_info;
8193
cristy6fccee12011-10-20 18:43:18 +00008194 (void) SyncImagesSettings(mogrify_info,*images,exception);
cristyb51dff52011-05-19 16:55:47 +00008195 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
cristy06609ee2010-03-17 20:21:27 +00008196 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008197 write_images=(*images);
8198 if (*option == '+')
8199 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008200 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008201 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8202 write_info=DestroyImageInfo(write_info);
8203 if (*option == '+')
8204 write_images=DestroyImageList(write_images);
8205 break;
8206 }
8207 break;
8208 }
8209 default:
8210 break;
8211 }
8212 i+=count;
8213 }
8214 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008215 mogrify_info=DestroyImageInfo(mogrify_info);
8216 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008217 return(status != 0 ? MagickTrue : MagickFalse);
8218}
8219
8220/*
8221%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8222% %
8223% %
8224% %
8225+ M o g r i f y I m a g e s %
8226% %
8227% %
8228% %
8229%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8230%
8231% MogrifyImages() applies image processing options to a sequence of images as
8232% prescribed by command line options.
8233%
8234% The format of the MogrifyImage method is:
8235%
8236% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8237% const MagickBooleanType post,const int argc,const char **argv,
8238% Image **images,Exceptioninfo *exception)
8239%
8240% A description of each parameter follows:
8241%
8242% o image_info: the image info..
8243%
8244% o post: If true, post process image list operators otherwise pre-process.
8245%
8246% o argc: Specifies a pointer to an integer describing the number of
8247% elements in the argument vector.
8248%
8249% o argv: Specifies a pointer to a text array containing the command line
8250% arguments.
8251%
anthonye9c27192011-03-27 08:07:06 +00008252% o images: pointer to a pointer of the first image in image list.
cristy3ed852e2009-09-05 21:47:34 +00008253%
8254% o exception: return any errors or warnings in this structure.
8255%
8256*/
8257WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8258 const MagickBooleanType post,const int argc,const char **argv,
8259 Image **images,ExceptionInfo *exception)
8260{
8261#define MogrifyImageTag "Mogrify/Image"
8262
anthonye9c27192011-03-27 08:07:06 +00008263 MagickStatusType
8264 status;
cristy3ed852e2009-09-05 21:47:34 +00008265
cristy0e9f9c12010-02-11 03:00:47 +00008266 MagickBooleanType
8267 proceed;
8268
anthonye9c27192011-03-27 08:07:06 +00008269 size_t
8270 n;
cristy3ed852e2009-09-05 21:47:34 +00008271
cristybb503372010-05-27 20:51:26 +00008272 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008273 i;
8274
cristy3ed852e2009-09-05 21:47:34 +00008275 assert(image_info != (ImageInfo *) NULL);
8276 assert(image_info->signature == MagickSignature);
8277 if (images == (Image **) NULL)
8278 return(MogrifyImage(image_info,argc,argv,images,exception));
anthonye9c27192011-03-27 08:07:06 +00008279 assert((*images)->previous == (Image *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008280 assert((*images)->signature == MagickSignature);
8281 if ((*images)->debug != MagickFalse)
8282 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8283 (*images)->filename);
8284 if ((argc <= 0) || (*argv == (char *) NULL))
8285 return(MagickTrue);
8286 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8287 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008288 status=0;
anthonye9c27192011-03-27 08:07:06 +00008289
anthonyce2716b2011-04-22 09:51:34 +00008290#if 0
cristy1e604812011-05-19 18:07:50 +00008291 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8292 post?"post":"pre");
anthonyce2716b2011-04-22 09:51:34 +00008293#endif
8294
anthonye9c27192011-03-27 08:07:06 +00008295 /*
8296 Pre-process multi-image sequence operators
8297 */
cristy3ed852e2009-09-05 21:47:34 +00008298 if (post == MagickFalse)
8299 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthonye9c27192011-03-27 08:07:06 +00008300 /*
8301 For each image, process simple single image operators
8302 */
8303 i=0;
8304 n=GetImageListLength(*images);
cristy9f027d12011-09-21 01:17:17 +00008305 for ( ; ; )
cristy3ed852e2009-09-05 21:47:34 +00008306 {
anthonyce2716b2011-04-22 09:51:34 +00008307#if 0
cristy1e604812011-05-19 18:07:50 +00008308 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8309 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008310#endif
anthonye9c27192011-03-27 08:07:06 +00008311 status&=MogrifyImage(image_info,argc,argv,images,exception);
8312 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
cristy0e9f9c12010-02-11 03:00:47 +00008313 if (proceed == MagickFalse)
8314 break;
anthonye9c27192011-03-27 08:07:06 +00008315 if ( (*images)->next == (Image *) NULL )
8316 break;
8317 *images=(*images)->next;
8318 i++;
cristy3ed852e2009-09-05 21:47:34 +00008319 }
anthonye9c27192011-03-27 08:07:06 +00008320 assert( *images != (Image *) NULL );
anthonyce2716b2011-04-22 09:51:34 +00008321#if 0
cristy1e604812011-05-19 18:07:50 +00008322 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8323 GetImageIndexInList(*images),(long)GetImageListLength(*images));
anthonyce2716b2011-04-22 09:51:34 +00008324#endif
anthonye9c27192011-03-27 08:07:06 +00008325
8326 /*
8327 Post-process, multi-image sequence operators
8328 */
8329 *images=GetFirstImageInList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008330 if (post != MagickFalse)
anthonye9c27192011-03-27 08:07:06 +00008331 status&=MogrifyImageList(image_info,argc,argv,images,exception);
cristy3ed852e2009-09-05 21:47:34 +00008332 return(status != 0 ? MagickTrue : MagickFalse);
8333}