blob: 3d2e604f89baa83c92251ad3666e801cc94bffd3 [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*/
47#include "wand/studio.h"
48#include "wand/MagickWand.h"
49#include "wand/mogrify-private.h"
cristy0e9f9c12010-02-11 03:00:47 +000050#include "magick/monitor-private.h"
cristy3980b0d2009-10-25 14:37:13 +000051#include "magick/thread-private.h"
cristyf2f27272009-12-17 14:48:46 +000052#include "magick/string-private.h"
cristy3ed852e2009-09-05 21:47:34 +000053
54/*
55 Define declarations.
56*/
57#define UndefinedCompressionQuality 0UL
58
59/*
60 Constant declaration.
61*/
62static const char
cristy7138c592009-09-08 13:58:52 +000063 BackgroundColor[] = "#fff", /* white */
64 BorderColor[] = "#dfdfdf", /* gray */
65 MatteColor[] = "#bdbdbd"; /* gray */
cristy3ed852e2009-09-05 21:47:34 +000066
67/*
68%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69% %
70% %
71% %
cristy5063d812010-10-19 16:28:10 +000072% 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 +000073% %
74% %
75% %
76%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77%
78% MagickCommandGenesis() applies image processing options to an image as
79% prescribed by command line options.
80%
81% The format of the MagickCommandGenesis method is:
82%
83% MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
cristy5063d812010-10-19 16:28:10 +000084% MagickCommand command,int argc,char **argv,char **metadata,
85% ExceptionInfo *exception)
cristy3980b0d2009-10-25 14:37:13 +000086%
87% A description of each parameter follows:
88%
89% o image_info: the image info.
90%
cristy5063d812010-10-19 16:28:10 +000091% o command: Choose from ConvertImageCommand, IdentifyImageCommand,
92% MogrifyImageCommand, CompositeImageCommand, CompareImageCommand,
93% ConjureImageCommand, StreamImageCommand, ImportImageCommand,
94% DisplayImageCommand, or AnimateImageCommand.
cristy3980b0d2009-10-25 14:37:13 +000095%
96% o argc: Specifies a pointer to an integer describing the number of
97% elements in the argument vector.
98%
99% o argv: Specifies a pointer to a text array containing the command line
100% arguments.
101%
cristy5063d812010-10-19 16:28:10 +0000102% o metadata: any metadata is returned here.
cristy3980b0d2009-10-25 14:37:13 +0000103%
104% o exception: return any errors or warnings in this structure.
105%
106*/
107WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
108 MagickCommand command,int argc,char **argv,char **metadata,
109 ExceptionInfo *exception)
110{
111 char
112 *option;
113
114 double
115 duration,
116 elapsed_time,
117 user_time;
118
cristy3980b0d2009-10-25 14:37:13 +0000119 MagickBooleanType
120 concurrent,
121 regard_warnings,
122 status;
123
cristybb503372010-05-27 20:51:26 +0000124 register ssize_t
cristy3980b0d2009-10-25 14:37:13 +0000125 i;
126
127 TimerInfo
128 *timer;
129
cristybb503372010-05-27 20:51:26 +0000130 size_t
cristy3980b0d2009-10-25 14:37:13 +0000131 iterations;
132
cristyd0a94fa2010-03-12 14:18:11 +0000133 (void) setlocale(LC_ALL,"");
134 (void) setlocale(LC_NUMERIC,"C");
cristy3980b0d2009-10-25 14:37:13 +0000135 concurrent=MagickFalse;
136 duration=(-1.0);
137 iterations=1;
cristy33557d72009-11-06 00:54:33 +0000138 status=MagickFalse;
cristy3980b0d2009-10-25 14:37:13 +0000139 regard_warnings=MagickFalse;
cristybb503372010-05-27 20:51:26 +0000140 for (i=1; i < (ssize_t) (argc-1); i++)
cristy3980b0d2009-10-25 14:37:13 +0000141 {
142 option=argv[i];
143 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
144 continue;
145 if (LocaleCompare("bench",option+1) == 0)
cristye27293e2009-12-18 02:53:20 +0000146 iterations=StringToUnsignedLong(argv[++i]);
cristy3980b0d2009-10-25 14:37:13 +0000147 if (LocaleCompare("concurrent",option+1) == 0)
148 concurrent=MagickTrue;
149 if (LocaleCompare("debug",option+1) == 0)
150 (void) SetLogEventMask(argv[++i]);
151 if (LocaleCompare("duration",option+1) == 0)
cristyf2f27272009-12-17 14:48:46 +0000152 duration=StringToDouble(argv[++i]);
cristy3980b0d2009-10-25 14:37:13 +0000153 if (LocaleCompare("regard-warnings",option+1) == 0)
154 regard_warnings=MagickTrue;
155 }
156 timer=AcquireTimerInfo();
cristyceae09d2009-10-28 17:18:47 +0000157 if (concurrent == MagickFalse)
cristy3980b0d2009-10-25 14:37:13 +0000158 {
cristybb503372010-05-27 20:51:26 +0000159 for (i=0; i < (ssize_t) iterations; i++)
cristy3980b0d2009-10-25 14:37:13 +0000160 {
cristy33557d72009-11-06 00:54:33 +0000161 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000162 continue;
163 if (duration > 0)
164 {
165 if (GetElapsedTime(timer) > duration)
166 continue;
167 (void) ContinueTimer(timer);
168 }
169 status=command(image_info,argc,argv,metadata,exception);
cristy3980b0d2009-10-25 14:37:13 +0000170 if (exception->severity != UndefinedException)
171 {
172 if ((exception->severity > ErrorException) ||
173 (regard_warnings != MagickFalse))
174 status=MagickTrue;
175 CatchException(exception);
176 }
cristy3d1a5512009-10-25 21:23:27 +0000177 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
cristy3980b0d2009-10-25 14:37:13 +0000178 {
179 (void) fputs(*metadata,stdout);
180 (void) fputc('\n',stdout);
181 *metadata=DestroyString(*metadata);
182 }
183 }
184 }
cristyceae09d2009-10-28 17:18:47 +0000185 else
186 {
187 SetOpenMPNested(1);
cristyb5d5f722009-11-04 03:03:49 +0000188#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristyceae09d2009-10-28 17:18:47 +0000189 # pragma omp parallel for shared(status)
190#endif
cristybb503372010-05-27 20:51:26 +0000191 for (i=0; i < (ssize_t) iterations; i++)
cristyceae09d2009-10-28 17:18:47 +0000192 {
cristy33557d72009-11-06 00:54:33 +0000193 if (status != MagickFalse)
cristyceae09d2009-10-28 17:18:47 +0000194 continue;
195 if (duration > 0)
196 {
197 if (GetElapsedTime(timer) > duration)
198 continue;
199 (void) ContinueTimer(timer);
200 }
201 status=command(image_info,argc,argv,metadata,exception);
cristyb5d5f722009-11-04 03:03:49 +0000202#if defined(MAGICKCORE_OPENMP_SUPPORT)
cristy524549f2010-06-20 21:10:20 +0000203 # pragma omp critical (MagickCore_CommandGenesis)
cristyceae09d2009-10-28 17:18:47 +0000204#endif
205 {
206 if (exception->severity != UndefinedException)
207 {
208 if ((exception->severity > ErrorException) ||
209 (regard_warnings != MagickFalse))
210 status=MagickTrue;
211 CatchException(exception);
212 }
213 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
214 {
215 (void) fputs(*metadata,stdout);
216 (void) fputc('\n',stdout);
217 *metadata=DestroyString(*metadata);
218 }
219 }
220 }
221 }
cristy3980b0d2009-10-25 14:37:13 +0000222 if (iterations > 1)
223 {
224 elapsed_time=GetElapsedTime(timer);
225 user_time=GetUserTime(timer);
cristy8cd5b312010-01-07 01:10:24 +0000226 (void) fprintf(stderr,
cristye8c25f92010-06-03 00:53:06 +0000227 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
228 iterations,1.0*iterations/elapsed_time,user_time,(double)
229 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
230 (1000.0*(elapsed_time-floor(elapsed_time))));
cristy524549f2010-06-20 21:10:20 +0000231 (void) fflush(stderr);
cristy3980b0d2009-10-25 14:37:13 +0000232 }
233 timer=DestroyTimerInfo(timer);
cristy1f9e1ed2009-11-18 04:09:38 +0000234 return(status);
cristy3980b0d2009-10-25 14:37:13 +0000235}
236
237/*
238%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239% %
240% %
241% %
cristy3ed852e2009-09-05 21:47:34 +0000242+ M o g r i f y I m a g e %
243% %
244% %
245% %
246%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247%
248% MogrifyImage() applies image processing options to an image as prescribed
249% by command line options.
250%
251% The format of the MogrifyImage method is:
252%
253% MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
254% const char **argv,Image **image)
255%
256% A description of each parameter follows:
257%
258% o image_info: the image info..
259%
260% o argc: Specifies a pointer to an integer describing the number of
261% elements in the argument vector.
262%
263% o argv: Specifies a pointer to a text array containing the command line
264% arguments.
265%
266% o image: the image.
267%
268% o exception: return any errors or warnings in this structure.
269%
270*/
271
272static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
273 ExceptionInfo *exception)
274{
275 char
276 key[MaxTextExtent];
277
278 ExceptionInfo
279 *sans_exception;
280
281 Image
282 *image;
283
284 ImageInfo
285 *read_info;
286
287 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
288 sans_exception=AcquireExceptionInfo();
289 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
290 sans_exception=DestroyExceptionInfo(sans_exception);
291 if (image != (Image *) NULL)
292 return(image);
293 read_info=CloneImageInfo(image_info);
294 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
295 image=ReadImage(read_info,exception);
296 read_info=DestroyImageInfo(read_info);
297 if (image != (Image *) NULL)
298 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
299 return(image);
300}
301
cristy3ed852e2009-09-05 21:47:34 +0000302static MagickBooleanType IsPathWritable(const char *path)
303{
304 if (IsPathAccessible(path) == MagickFalse)
305 return(MagickFalse);
306 if (access(path,W_OK) != 0)
307 return(MagickFalse);
308 return(MagickTrue);
309}
310
cristybb503372010-05-27 20:51:26 +0000311static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
cristy3ed852e2009-09-05 21:47:34 +0000312{
313 if (x > y)
314 return(x);
315 return(y);
316}
317
318static MagickBooleanType MonitorProgress(const char *text,
cristyb32b90a2009-09-07 21:45:48 +0000319 const MagickOffsetType offset,const MagickSizeType extent,
cristy3ed852e2009-09-05 21:47:34 +0000320 void *wand_unused(client_data))
321{
322 char
323 message[MaxTextExtent],
324 tag[MaxTextExtent];
325
326 const char
327 *locale_message;
328
329 register char
330 *p;
331
cristyb32b90a2009-09-07 21:45:48 +0000332 if (extent < 2)
cristy3ed852e2009-09-05 21:47:34 +0000333 return(MagickTrue);
334 (void) CopyMagickMemory(tag,text,MaxTextExtent);
335 p=strrchr(tag,'/');
336 if (p != (char *) NULL)
337 *p='\0';
338 (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
339 locale_message=GetLocaleMessage(message);
340 if (locale_message == message)
341 locale_message=tag;
342 if (p == (char *) NULL)
cristyb32b90a2009-09-07 21:45:48 +0000343 (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
cristyf2faecf2010-05-28 19:19:36 +0000344 (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
cristy3ed852e2009-09-05 21:47:34 +0000345 else
cristyb32b90a2009-09-07 21:45:48 +0000346 (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
cristyf2faecf2010-05-28 19:19:36 +0000347 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
cristyb32b90a2009-09-07 21:45:48 +0000348 (100L*offset/(extent-1)));
349 if (offset == (MagickOffsetType) (extent-1))
cristy3ed852e2009-09-05 21:47:34 +0000350 (void) fprintf(stderr,"\n");
351 (void) fflush(stderr);
352 return(MagickTrue);
353}
354
355static Image *SparseColorOption(const Image *image,const ChannelType channel,
356 const SparseColorMethod method,const char *arguments,
357 const MagickBooleanType color_from_image,ExceptionInfo *exception)
358{
359 ChannelType
360 channels;
361
362 char
363 token[MaxTextExtent];
364
365 const char
366 *p;
367
368 double
369 *sparse_arguments;
370
cristybb503372010-05-27 20:51:26 +0000371 register size_t
cristy3ed852e2009-09-05 21:47:34 +0000372 x;
373
cristybb503372010-05-27 20:51:26 +0000374 size_t
cristy3ed852e2009-09-05 21:47:34 +0000375 number_arguments;
376
cristybb503372010-05-27 20:51:26 +0000377 size_t
cristy3ed852e2009-09-05 21:47:34 +0000378 number_colors;
379
380 Image
381 *sparse_image;
382
383 MagickPixelPacket
384 color;
385
386 MagickBooleanType
387 error;
388
389 assert(image != (Image *) NULL);
390 assert(image->signature == MagickSignature);
391 if (image->debug != MagickFalse)
392 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
393 assert(exception != (ExceptionInfo *) NULL);
394 assert(exception->signature == MagickSignature);
395 /*
396 Limit channels according to image - and add up number of color channel.
397 */
398 channels=channel;
399 if (image->colorspace != CMYKColorspace)
400 channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */
401 if (image->matte == MagickFalse)
402 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
403 number_colors=0;
404 if ((channels & RedChannel) != 0)
405 number_colors++;
406 if ((channels & GreenChannel) != 0)
407 number_colors++;
408 if ((channels & BlueChannel) != 0)
409 number_colors++;
410 if ((channels & IndexChannel) != 0)
411 number_colors++;
412 if ((channels & OpacityChannel) != 0)
413 number_colors++;
anthony1e4df872011-03-19 14:10:59 +0000414
cristy3ed852e2009-09-05 21:47:34 +0000415 /*
416 Read string, to determine number of arguments needed,
417 */
418 p=arguments;
419 x=0;
420 while( *p != '\0' )
421 {
422 GetMagickToken(p,&p,token);
423 if ( token[0] == ',' ) continue;
424 if ( isalpha((int) token[0]) || token[0] == '#' ) {
425 if ( color_from_image ) {
426 (void) ThrowMagickException(exception,GetMagickModule(),
427 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
428 "Color arg given, when colors are coming from image");
429 return( (Image *)NULL);
430 }
431 x += number_colors; /* color argument */
432 }
433 else {
434 x++; /* floating point argument */
435 }
436 }
437 error=MagickTrue;
438 if ( color_from_image ) {
439 /* just the control points are being given */
440 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
441 number_arguments=(x/2)*(2+number_colors);
442 }
443 else {
444 /* control points and color values */
445 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
446 number_arguments=x;
447 }
448 if ( error ) {
449 (void) ThrowMagickException(exception,GetMagickModule(),
450 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
451 "Invalid number of Arguments");
452 return( (Image *)NULL);
453 }
454
455 /* Allocate and fill in the floating point arguments */
456 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
457 sizeof(*sparse_arguments));
458 if (sparse_arguments == (double *) NULL) {
459 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
460 "MemoryAllocationFailed","%s","SparseColorOption");
461 return( (Image *)NULL);
462 }
463 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
464 sizeof(*sparse_arguments));
465 p=arguments;
466 x=0;
467 while( *p != '\0' && x < number_arguments ) {
468 /* X coordinate */
469 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
470 if ( token[0] == '\0' ) break;
471 if ( isalpha((int) token[0]) || token[0] == '#' ) {
472 (void) ThrowMagickException(exception,GetMagickModule(),
473 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
474 "Color found, instead of X-coord");
475 error = MagickTrue;
476 break;
477 }
cristyf2f27272009-12-17 14:48:46 +0000478 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000479 /* Y coordinate */
480 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
481 if ( token[0] == '\0' ) break;
482 if ( isalpha((int) token[0]) || token[0] == '#' ) {
483 (void) ThrowMagickException(exception,GetMagickModule(),
484 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
485 "Color found, instead of Y-coord");
486 error = MagickTrue;
487 break;
488 }
cristyf2f27272009-12-17 14:48:46 +0000489 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000490 /* color values for this control point */
491#if 0
492 if ( (color_from_image ) {
493 /* get color from image */
494 /* HOW??? */
495 }
496 else
497#endif
498 {
499 /* color name or function given in string argument */
500 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
501 if ( token[0] == '\0' ) break;
502 if ( isalpha((int) token[0]) || token[0] == '#' ) {
503 /* Color string given */
504 (void) QueryMagickColor(token,&color,exception);
505 if ( channels & RedChannel )
506 sparse_arguments[x++] = QuantumScale*color.red;
507 if ( channels & GreenChannel )
508 sparse_arguments[x++] = QuantumScale*color.green;
509 if ( channels & BlueChannel )
510 sparse_arguments[x++] = QuantumScale*color.blue;
511 if ( channels & IndexChannel )
512 sparse_arguments[x++] = QuantumScale*color.index;
513 if ( channels & OpacityChannel )
514 sparse_arguments[x++] = QuantumScale*color.opacity;
515 }
516 else {
517#if 0
518 /* the color name/function/value was not found - error */
519 break;
520#else
521 /* Colors given as a set of floating point values - experimental */
522 /* NB: token contains the first floating point value to use! */
523 if ( channels & RedChannel ) {
524 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
525 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
526 break;
cristy0f19e682009-12-17 14:55:51 +0000527 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000528 token[0] = ','; /* used this token - get another */
529 }
530 if ( channels & GreenChannel ) {
531 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
532 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
533 break;
cristy0f19e682009-12-17 14:55:51 +0000534 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000535 token[0] = ','; /* used this token - get another */
536 }
537 if ( channels & BlueChannel ) {
538 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
539 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
540 break;
cristy0f19e682009-12-17 14:55:51 +0000541 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000542 token[0] = ','; /* used this token - get another */
543 }
544 if ( channels & IndexChannel ) {
545 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
546 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
547 break;
cristy0f19e682009-12-17 14:55:51 +0000548 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000549 token[0] = ','; /* used this token - get another */
550 }
551 if ( channels & OpacityChannel ) {
552 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
553 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
554 break;
cristy0f19e682009-12-17 14:55:51 +0000555 sparse_arguments[x++]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +0000556 token[0] = ','; /* used this token - get another */
557 }
558#endif
559 }
560 }
561 }
562 if ( number_arguments != x && !error ) {
563 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
564 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
565 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
566 return( (Image *)NULL);
567 }
568 if ( error )
569 return( (Image *)NULL);
570
571 /* Call the Interpolation function with the parsed arguments */
572 sparse_image=SparseColorImage(image,channels,method,number_arguments,
573 sparse_arguments,exception);
574 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
575 return( sparse_image );
576}
577
578WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
579 const char **argv,Image **image,ExceptionInfo *exception)
580{
581 ChannelType
582 channel;
583
584 const char
585 *format,
586 *option;
587
588 DrawInfo
589 *draw_info;
590
591 GeometryInfo
592 geometry_info;
593
594 Image
595 *region_image;
596
cristy6b3da3a2010-06-20 02:21:46 +0000597 ImageInfo
598 *mogrify_info;
599
cristyebbcfea2011-02-25 02:43:54 +0000600 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000601 status;
602
603 MagickPixelPacket
604 fill;
605
606 MagickStatusType
607 flags;
608
609 QuantizeInfo
610 *quantize_info;
611
612 RectangleInfo
613 geometry,
614 region_geometry;
615
cristybb503372010-05-27 20:51:26 +0000616 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000617 i;
618
cristyebbcfea2011-02-25 02:43:54 +0000619 ssize_t
620 count;
621
cristy3ed852e2009-09-05 21:47:34 +0000622 /*
623 Initialize method variables.
624 */
625 assert(image_info != (const ImageInfo *) NULL);
626 assert(image_info->signature == MagickSignature);
627 assert(image != (Image **) NULL);
628 assert((*image)->signature == MagickSignature);
629 if ((*image)->debug != MagickFalse)
630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
631 if (argc < 0)
632 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +0000633 mogrify_info=CloneImageInfo(image_info);
634 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
635 quantize_info=AcquireQuantizeInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +0000636 SetGeometryInfo(&geometry_info);
637 GetMagickPixelPacket(*image,&fill);
638 SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
639 &fill);
cristy6b3da3a2010-06-20 02:21:46 +0000640 channel=mogrify_info->channel;
641 format=GetImageOption(mogrify_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000642 SetGeometry(*image,&region_geometry);
643 region_image=NewImageList();
644 /*
645 Transmogrify the image.
646 */
cristybb503372010-05-27 20:51:26 +0000647 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000648 {
649 option=argv[i];
650 if (IsMagickOption(option) == MagickFalse)
651 continue;
652 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
653 0L);
cristycee97112010-05-28 00:44:52 +0000654 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000655 break;
cristy6b3da3a2010-06-20 02:21:46 +0000656 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +0000657 switch (*(option+1))
658 {
659 case 'a':
660 {
661 if (LocaleCompare("adaptive-blur",option+1) == 0)
662 {
663 Image
664 *blur_image;
665
666 /*
667 Adaptive blur image.
668 */
cristy6b3da3a2010-06-20 02:21:46 +0000669 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000670 flags=ParseGeometry(argv[i+1],&geometry_info);
671 if ((flags & SigmaValue) == 0)
672 geometry_info.sigma=1.0;
673 blur_image=AdaptiveBlurImageChannel(*image,channel,
674 geometry_info.rho,geometry_info.sigma,exception);
675 if (blur_image == (Image *) NULL)
676 break;
677 *image=DestroyImage(*image);
678 *image=blur_image;
679 break;
680 }
681 if (LocaleCompare("adaptive-resize",option+1) == 0)
682 {
683 Image
684 *resize_image;
685
686 /*
687 Adaptive resize image.
688 */
cristy6b3da3a2010-06-20 02:21:46 +0000689 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000690 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
691 resize_image=AdaptiveResizeImage(*image,geometry.width,
692 geometry.height,exception);
693 if (resize_image == (Image *) NULL)
694 break;
695 *image=DestroyImage(*image);
696 *image=resize_image;
697 break;
698 }
699 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
700 {
701 Image
702 *sharp_image;
703
704 /*
705 Adaptive sharpen image.
706 */
cristy6b3da3a2010-06-20 02:21:46 +0000707 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000708 flags=ParseGeometry(argv[i+1],&geometry_info);
709 if ((flags & SigmaValue) == 0)
710 geometry_info.sigma=1.0;
711 sharp_image=AdaptiveSharpenImageChannel(*image,channel,
712 geometry_info.rho,geometry_info.sigma,exception);
713 if (sharp_image == (Image *) NULL)
714 break;
715 *image=DestroyImage(*image);
716 *image=sharp_image;
717 break;
718 }
719 if (LocaleCompare("affine",option+1) == 0)
720 {
721 /*
722 Affine matrix.
723 */
724 if (*option == '+')
725 {
726 GetAffineMatrix(&draw_info->affine);
727 break;
728 }
729 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
730 break;
731 }
732 if (LocaleCompare("alpha",option+1) == 0)
733 {
734 AlphaChannelType
735 alpha_type;
736
cristy6b3da3a2010-06-20 02:21:46 +0000737 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000738 alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions,
739 MagickFalse,argv[i+1]);
740 (void) SetImageAlphaChannel(*image,alpha_type);
741 InheritException(exception,&(*image)->exception);
742 break;
743 }
744 if (LocaleCompare("annotate",option+1) == 0)
745 {
746 char
747 *text,
748 geometry[MaxTextExtent];
749
750 /*
751 Annotate image.
752 */
cristy6b3da3a2010-06-20 02:21:46 +0000753 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000754 SetGeometryInfo(&geometry_info);
755 flags=ParseGeometry(argv[i+1],&geometry_info);
756 if ((flags & SigmaValue) == 0)
757 geometry_info.sigma=geometry_info.rho;
cristy6b3da3a2010-06-20 02:21:46 +0000758 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
cristy3ed852e2009-09-05 21:47:34 +0000759 InheritException(exception,&(*image)->exception);
760 if (text == (char *) NULL)
761 break;
762 (void) CloneString(&draw_info->text,text);
763 text=DestroyString(text);
764 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
765 geometry_info.xi,geometry_info.psi);
766 (void) CloneString(&draw_info->geometry,geometry);
767 draw_info->affine.sx=cos(DegreesToRadians(
768 fmod(geometry_info.rho,360.0)));
769 draw_info->affine.rx=sin(DegreesToRadians(
770 fmod(geometry_info.rho,360.0)));
771 draw_info->affine.ry=(-sin(DegreesToRadians(
772 fmod(geometry_info.sigma,360.0))));
773 draw_info->affine.sy=cos(DegreesToRadians(
774 fmod(geometry_info.sigma,360.0)));
775 (void) AnnotateImage(*image,draw_info);
776 InheritException(exception,&(*image)->exception);
777 break;
778 }
779 if (LocaleCompare("antialias",option+1) == 0)
780 {
781 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
782 MagickFalse;
783 draw_info->text_antialias=(*option == '-') ? MagickTrue :
784 MagickFalse;
785 break;
786 }
787 if (LocaleCompare("auto-gamma",option+1) == 0)
788 {
789 /*
790 Auto Adjust Gamma of image based on its mean
791 */
cristy6b3da3a2010-06-20 02:21:46 +0000792 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000793 (void) AutoGammaImageChannel(*image,channel);
794 break;
795 }
796 if (LocaleCompare("auto-level",option+1) == 0)
797 {
798 /*
799 Perfectly Normalize (max/min stretch) the image
800 */
cristy6b3da3a2010-06-20 02:21:46 +0000801 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000802 (void) AutoLevelImageChannel(*image,channel);
803 break;
804 }
805 if (LocaleCompare("auto-orient",option+1) == 0)
806 {
807 Image
808 *orient_image;
809
cristy6b3da3a2010-06-20 02:21:46 +0000810 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000811 orient_image=NewImageList();
812 switch ((*image)->orientation)
813 {
814 case TopRightOrientation:
815 {
816 orient_image=FlopImage(*image,exception);
817 break;
818 }
819 case BottomRightOrientation:
820 {
821 orient_image=RotateImage(*image,180.0,exception);
822 break;
823 }
824 case BottomLeftOrientation:
825 {
826 orient_image=FlipImage(*image,exception);
827 break;
828 }
829 case LeftTopOrientation:
830 {
831 orient_image=TransposeImage(*image,exception);
832 break;
833 }
834 case RightTopOrientation:
835 {
836 orient_image=RotateImage(*image,90.0,exception);
837 break;
838 }
839 case RightBottomOrientation:
840 {
841 orient_image=TransverseImage(*image,exception);
842 break;
843 }
844 case LeftBottomOrientation:
845 {
846 orient_image=RotateImage(*image,270.0,exception);
847 break;
848 }
849 default:
850 break;
851 }
852 if (orient_image == (Image *) NULL)
853 break;
854 orient_image->orientation=TopLeftOrientation;
855 *image=DestroyImage(*image);
856 *image=orient_image;
857 break;
858 }
859 break;
860 }
861 case 'b':
862 {
863 if (LocaleCompare("black-threshold",option+1) == 0)
864 {
865 /*
866 Black threshold image.
867 */
cristy6b3da3a2010-06-20 02:21:46 +0000868 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000869 (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
870 exception);
871 InheritException(exception,&(*image)->exception);
872 break;
873 }
874 if (LocaleCompare("blue-shift",option+1) == 0)
875 {
876 Image
877 *shift_image;
878
879 /*
880 Blue shift image.
881 */
cristy6b3da3a2010-06-20 02:21:46 +0000882 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000883 geometry_info.rho=1.5;
884 if (*option == '-')
885 flags=ParseGeometry(argv[i+1],&geometry_info);
886 shift_image=BlueShiftImage(*image,geometry_info.rho,exception);
887 if (shift_image == (Image *) NULL)
888 break;
889 *image=DestroyImage(*image);
890 *image=shift_image;
891 break;
892 }
893 if (LocaleCompare("blur",option+1) == 0)
894 {
895 Image
896 *blur_image;
897
898 /*
899 Gaussian blur image.
900 */
cristy6b3da3a2010-06-20 02:21:46 +0000901 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000902 flags=ParseGeometry(argv[i+1],&geometry_info);
903 if ((flags & SigmaValue) == 0)
904 geometry_info.sigma=1.0;
905 blur_image=BlurImageChannel(*image,channel,geometry_info.rho,
906 geometry_info.sigma,exception);
907 if (blur_image == (Image *) NULL)
908 break;
909 *image=DestroyImage(*image);
910 *image=blur_image;
911 break;
912 }
913 if (LocaleCompare("border",option+1) == 0)
914 {
915 Image
916 *border_image;
917
918 /*
919 Surround image with a border of solid color.
920 */
cristy6b3da3a2010-06-20 02:21:46 +0000921 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000922 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
923 if ((flags & SigmaValue) == 0)
924 geometry.height=geometry.width;
925 border_image=BorderImage(*image,&geometry,exception);
926 if (border_image == (Image *) NULL)
927 break;
928 *image=DestroyImage(*image);
929 *image=border_image;
930 break;
931 }
932 if (LocaleCompare("bordercolor",option+1) == 0)
933 {
934 if (*option == '+')
935 {
936 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
937 exception);
938 break;
939 }
940 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
941 exception);
942 break;
943 }
944 if (LocaleCompare("box",option+1) == 0)
945 {
946 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
947 exception);
948 break;
949 }
cristya28d6b82010-01-11 20:03:47 +0000950 if (LocaleCompare("brightness-contrast",option+1) == 0)
951 {
952 double
953 brightness,
954 contrast;
955
956 GeometryInfo
957 geometry_info;
958
959 MagickStatusType
960 flags;
961
962 /*
963 Brightness / contrast image.
964 */
cristy6b3da3a2010-06-20 02:21:46 +0000965 (void) SyncImageSettings(mogrify_info,*image);
cristya28d6b82010-01-11 20:03:47 +0000966 flags=ParseGeometry(argv[i+1],&geometry_info);
967 brightness=geometry_info.rho;
cristy81fbc8b2010-01-11 20:04:07 +0000968 contrast=0.0;
cristya28d6b82010-01-11 20:03:47 +0000969 if ((flags & SigmaValue) != 0)
970 contrast=geometry_info.sigma;
cristy02cc0f22010-01-12 00:02:32 +0000971 (void) BrightnessContrastImageChannel(*image,channel,brightness,
972 contrast);
cristya28d6b82010-01-11 20:03:47 +0000973 InheritException(exception,&(*image)->exception);
974 break;
975 }
cristy3ed852e2009-09-05 21:47:34 +0000976 break;
977 }
978 case 'c':
979 {
980 if (LocaleCompare("cdl",option+1) == 0)
981 {
982 char
983 *color_correction_collection;
984
985 /*
986 Color correct with a color decision list.
987 */
cristy6b3da3a2010-06-20 02:21:46 +0000988 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +0000989 color_correction_collection=FileToString(argv[i+1],~0,exception);
990 if (color_correction_collection == (char *) NULL)
991 break;
992 (void) ColorDecisionListImage(*image,color_correction_collection);
993 InheritException(exception,&(*image)->exception);
994 break;
995 }
996 if (LocaleCompare("channel",option+1) == 0)
997 {
998 if (*option == '+')
999 {
1000 channel=DefaultChannels;
1001 break;
1002 }
1003 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1004 break;
1005 }
1006 if (LocaleCompare("charcoal",option+1) == 0)
1007 {
1008 Image
1009 *charcoal_image;
1010
1011 /*
1012 Charcoal image.
1013 */
cristy6b3da3a2010-06-20 02:21:46 +00001014 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001015 flags=ParseGeometry(argv[i+1],&geometry_info);
1016 if ((flags & SigmaValue) == 0)
1017 geometry_info.sigma=1.0;
1018 charcoal_image=CharcoalImage(*image,geometry_info.rho,
1019 geometry_info.sigma,exception);
1020 if (charcoal_image == (Image *) NULL)
1021 break;
1022 *image=DestroyImage(*image);
1023 *image=charcoal_image;
1024 break;
1025 }
1026 if (LocaleCompare("chop",option+1) == 0)
1027 {
1028 Image
1029 *chop_image;
1030
1031 /*
1032 Chop the image.
1033 */
cristy6b3da3a2010-06-20 02:21:46 +00001034 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001035 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1036 chop_image=ChopImage(*image,&geometry,exception);
1037 if (chop_image == (Image *) NULL)
1038 break;
1039 *image=DestroyImage(*image);
1040 *image=chop_image;
1041 break;
1042 }
cristy1eb45dd2009-09-25 16:38:06 +00001043 if (LocaleCompare("clamp",option+1) == 0)
1044 {
1045 /*
1046 Clamp image.
1047 */
cristy6b3da3a2010-06-20 02:21:46 +00001048 (void) SyncImageSettings(mogrify_info,*image);
cristy1eb45dd2009-09-25 16:38:06 +00001049 (void) ClampImageChannel(*image,channel);
1050 InheritException(exception,&(*image)->exception);
1051 break;
1052 }
cristy3ed852e2009-09-05 21:47:34 +00001053 if (LocaleCompare("clip",option+1) == 0)
1054 {
cristy6b3da3a2010-06-20 02:21:46 +00001055 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001056 if (*option == '+')
1057 {
1058 (void) SetImageClipMask(*image,(Image *) NULL);
1059 InheritException(exception,&(*image)->exception);
1060 break;
1061 }
1062 (void) ClipImage(*image);
1063 InheritException(exception,&(*image)->exception);
1064 break;
1065 }
1066 if (LocaleCompare("clip-mask",option+1) == 0)
1067 {
cristyb0d3bb92010-09-22 14:37:58 +00001068 CacheView
1069 *mask_view;
cristya01cbea2010-11-03 16:33:33 +00001070
cristy3ed852e2009-09-05 21:47:34 +00001071 Image
cristyb0d3bb92010-09-22 14:37:58 +00001072 *mask_image;
cristy3ed852e2009-09-05 21:47:34 +00001073
cristy9d314ff2011-03-09 01:30:28 +00001074 register PixelPacket
1075 *restrict q;
cristy3ed852e2009-09-05 21:47:34 +00001076
cristybb503372010-05-27 20:51:26 +00001077 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001078 x;
1079
cristy9d314ff2011-03-09 01:30:28 +00001080 ssize_t
1081 y;
cristy3ed852e2009-09-05 21:47:34 +00001082
cristy6b3da3a2010-06-20 02:21:46 +00001083 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001084 if (*option == '+')
1085 {
1086 /*
1087 Remove a mask.
1088 */
1089 (void) SetImageMask(*image,(Image *) NULL);
1090 InheritException(exception,&(*image)->exception);
1091 break;
1092 }
1093 /*
1094 Set the image mask.
1095 */
cristyb0d3bb92010-09-22 14:37:58 +00001096 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1097 if (mask_image == (Image *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001098 break;
cristyb0d3bb92010-09-22 14:37:58 +00001099 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1100 return(MagickFalse);
1101 mask_view=AcquireCacheView(mask_image);
1102 for (y=0; y < (ssize_t) mask_image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001103 {
cristyb0d3bb92010-09-22 14:37:58 +00001104 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1105 exception);
cristy3ed852e2009-09-05 21:47:34 +00001106 if (q == (PixelPacket *) NULL)
1107 break;
cristyb0d3bb92010-09-22 14:37:58 +00001108 for (x=0; x < (ssize_t) mask_image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +00001109 {
cristyb0d3bb92010-09-22 14:37:58 +00001110 if (mask_image->matte == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00001111 q->opacity=PixelIntensityToQuantum(q);
1112 q->red=q->opacity;
1113 q->green=q->opacity;
1114 q->blue=q->opacity;
1115 q++;
1116 }
cristyb0d3bb92010-09-22 14:37:58 +00001117 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00001118 break;
1119 }
cristyb0d3bb92010-09-22 14:37:58 +00001120 mask_view=DestroyCacheView(mask_view);
1121 mask_image->matte=MagickTrue;
1122 (void) SetImageClipMask(*image,mask_image);
1123 mask_image=DestroyImage(mask_image);
cristy3ed852e2009-09-05 21:47:34 +00001124 InheritException(exception,&(*image)->exception);
1125 break;
1126 }
1127 if (LocaleCompare("clip-path",option+1) == 0)
1128 {
cristy6b3da3a2010-06-20 02:21:46 +00001129 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001130 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1131 MagickFalse);
1132 InheritException(exception,&(*image)->exception);
1133 break;
1134 }
1135 if (LocaleCompare("colorize",option+1) == 0)
1136 {
1137 Image
1138 *colorize_image;
1139
1140 /*
1141 Colorize the image.
1142 */
cristy6b3da3a2010-06-20 02:21:46 +00001143 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001144 colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1145 exception);
1146 if (colorize_image == (Image *) NULL)
1147 break;
1148 *image=DestroyImage(*image);
1149 *image=colorize_image;
1150 break;
1151 }
cristye6365592010-04-02 17:31:23 +00001152 if (LocaleCompare("color-matrix",option+1) == 0)
1153 {
1154 Image
1155 *color_image;
1156
1157 KernelInfo
1158 *kernel;
1159
cristy6b3da3a2010-06-20 02:21:46 +00001160 (void) SyncImageSettings(mogrify_info,*image);
cristye6365592010-04-02 17:31:23 +00001161 kernel=AcquireKernelInfo(argv[i+1]);
1162 if (kernel == (KernelInfo *) NULL)
1163 break;
1164 color_image=ColorMatrixImage(*image,kernel,exception);
1165 kernel=DestroyKernelInfo(kernel);
1166 if (color_image == (Image *) NULL)
1167 break;
1168 *image=DestroyImage(*image);
1169 *image=color_image;
1170 break;
1171 }
cristy3ed852e2009-09-05 21:47:34 +00001172 if (LocaleCompare("colors",option+1) == 0)
1173 {
1174 /*
1175 Reduce the number of colors in the image.
1176 */
cristy6b3da3a2010-06-20 02:21:46 +00001177 (void) SyncImageSettings(mogrify_info,*image);
cristye27293e2009-12-18 02:53:20 +00001178 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00001179 if (quantize_info->number_colors == 0)
1180 break;
1181 if (((*image)->storage_class == DirectClass) ||
1182 (*image)->colors > quantize_info->number_colors)
1183 (void) QuantizeImage(quantize_info,*image);
1184 else
1185 (void) CompressImageColormap(*image);
1186 InheritException(exception,&(*image)->exception);
1187 break;
1188 }
1189 if (LocaleCompare("colorspace",option+1) == 0)
1190 {
1191 ColorspaceType
1192 colorspace;
1193
cristy6b3da3a2010-06-20 02:21:46 +00001194 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001195 if (*option == '+')
1196 {
1197 (void) TransformImageColorspace(*image,RGBColorspace);
1198 InheritException(exception,&(*image)->exception);
1199 break;
1200 }
1201 colorspace=(ColorspaceType) ParseMagickOption(
1202 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1203 (void) TransformImageColorspace(*image,colorspace);
1204 InheritException(exception,&(*image)->exception);
1205 break;
1206 }
1207 if (LocaleCompare("contrast",option+1) == 0)
1208 {
cristy6b3da3a2010-06-20 02:21:46 +00001209 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001210 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1211 MagickFalse);
1212 InheritException(exception,&(*image)->exception);
1213 break;
1214 }
1215 if (LocaleCompare("contrast-stretch",option+1) == 0)
1216 {
1217 double
1218 black_point,
1219 white_point;
1220
cristy3ed852e2009-09-05 21:47:34 +00001221 MagickStatusType
1222 flags;
1223
1224 /*
1225 Contrast stretch image.
1226 */
cristy6b3da3a2010-06-20 02:21:46 +00001227 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001228 flags=ParseGeometry(argv[i+1],&geometry_info);
1229 black_point=geometry_info.rho;
1230 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1231 black_point;
1232 if ((flags & PercentValue) != 0)
1233 {
1234 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1235 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1236 }
1237 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1238 white_point;
1239 (void) ContrastStretchImageChannel(*image,channel,black_point,
1240 white_point);
1241 InheritException(exception,&(*image)->exception);
1242 break;
1243 }
1244 if (LocaleCompare("convolve",option+1) == 0)
1245 {
cristy36826ab2010-03-06 01:29:30 +00001246 double
1247 gamma;
1248
cristy3ed852e2009-09-05 21:47:34 +00001249 Image
1250 *convolve_image;
1251
cristy2be15382010-01-21 02:38:03 +00001252 KernelInfo
cristy56a9e512010-01-06 18:18:55 +00001253 *kernel;
cristy3ed852e2009-09-05 21:47:34 +00001254
cristybb503372010-05-27 20:51:26 +00001255 register ssize_t
cristy36826ab2010-03-06 01:29:30 +00001256 j;
1257
cristy6b3da3a2010-06-20 02:21:46 +00001258 (void) SyncImageSettings(mogrify_info,*image);
cristy2be15382010-01-21 02:38:03 +00001259 kernel=AcquireKernelInfo(argv[i+1]);
1260 if (kernel == (KernelInfo *) NULL)
cristy56a9e512010-01-06 18:18:55 +00001261 break;
cristy36826ab2010-03-06 01:29:30 +00001262 gamma=0.0;
cristybb503372010-05-27 20:51:26 +00001263 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
cristy36826ab2010-03-06 01:29:30 +00001264 gamma+=kernel->values[j];
1265 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
cristybb503372010-05-27 20:51:26 +00001266 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
cristy36826ab2010-03-06 01:29:30 +00001267 kernel->values[j]*=gamma;
cristy6771f1e2010-03-05 19:43:39 +00001268 convolve_image=FilterImageChannel(*image,channel,kernel,exception);
anthony83ba99b2010-01-24 08:48:15 +00001269 kernel=DestroyKernelInfo(kernel);
cristy3ed852e2009-09-05 21:47:34 +00001270 if (convolve_image == (Image *) NULL)
1271 break;
1272 *image=DestroyImage(*image);
1273 *image=convolve_image;
1274 break;
1275 }
1276 if (LocaleCompare("crop",option+1) == 0)
1277 {
cristy6b3da3a2010-06-20 02:21:46 +00001278 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001279 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1280 if (((geometry.width != 0) || (geometry.height != 0)) &&
1281 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1282 break;
1283 (void) TransformImage(image,argv[i+1],(char *) NULL);
1284 InheritException(exception,&(*image)->exception);
1285 break;
1286 }
1287 if (LocaleCompare("cycle",option+1) == 0)
1288 {
1289 /*
1290 Cycle an image colormap.
1291 */
cristy6b3da3a2010-06-20 02:21:46 +00001292 (void) SyncImageSettings(mogrify_info,*image);
cristy32c2aea2010-12-01 01:00:50 +00001293 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
cristy3ed852e2009-09-05 21:47:34 +00001294 InheritException(exception,&(*image)->exception);
1295 break;
1296 }
1297 break;
1298 }
1299 case 'd':
1300 {
1301 if (LocaleCompare("decipher",option+1) == 0)
1302 {
1303 StringInfo
1304 *passkey;
1305
1306 /*
1307 Decipher pixels.
1308 */
cristy6b3da3a2010-06-20 02:21:46 +00001309 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001310 passkey=FileToStringInfo(argv[i+1],~0,exception);
1311 if (passkey != (StringInfo *) NULL)
1312 {
1313 (void) PasskeyDecipherImage(*image,passkey,exception);
1314 passkey=DestroyStringInfo(passkey);
1315 }
1316 break;
1317 }
1318 if (LocaleCompare("density",option+1) == 0)
1319 {
1320 /*
1321 Set image density.
1322 */
1323 (void) CloneString(&draw_info->density,argv[i+1]);
1324 break;
1325 }
1326 if (LocaleCompare("depth",option+1) == 0)
1327 {
cristy6b3da3a2010-06-20 02:21:46 +00001328 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001329 if (*option == '+')
1330 {
1331 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1332 break;
1333 }
cristye27293e2009-12-18 02:53:20 +00001334 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
cristy3ed852e2009-09-05 21:47:34 +00001335 break;
1336 }
1337 if (LocaleCompare("deskew",option+1) == 0)
1338 {
1339 double
1340 threshold;
1341
1342 Image
1343 *deskew_image;
1344
1345 /*
1346 Straighten the image.
1347 */
cristy6b3da3a2010-06-20 02:21:46 +00001348 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001349 if (*option == '+')
1350 threshold=40.0*QuantumRange/100.0;
1351 else
cristyf2f27272009-12-17 14:48:46 +00001352 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy3ed852e2009-09-05 21:47:34 +00001353 deskew_image=DeskewImage(*image,threshold,exception);
1354 if (deskew_image == (Image *) NULL)
1355 break;
1356 *image=DestroyImage(*image);
1357 *image=deskew_image;
1358 break;
1359 }
1360 if (LocaleCompare("despeckle",option+1) == 0)
1361 {
1362 Image
1363 *despeckle_image;
1364
1365 /*
1366 Reduce the speckles within an image.
1367 */
cristy6b3da3a2010-06-20 02:21:46 +00001368 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001369 despeckle_image=DespeckleImage(*image,exception);
1370 if (despeckle_image == (Image *) NULL)
1371 break;
1372 *image=DestroyImage(*image);
1373 *image=despeckle_image;
1374 break;
1375 }
1376 if (LocaleCompare("display",option+1) == 0)
1377 {
1378 (void) CloneString(&draw_info->server_name,argv[i+1]);
1379 break;
1380 }
cristy3ed852e2009-09-05 21:47:34 +00001381 if (LocaleCompare("distort",option+1) == 0)
1382 {
1383 char
1384 *args,
1385 token[MaxTextExtent];
1386
1387 const char
1388 *p;
1389
1390 DistortImageMethod
1391 method;
1392
1393 double
1394 *arguments;
1395
1396 Image
1397 *distort_image;
1398
cristybb503372010-05-27 20:51:26 +00001399 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001400 x;
1401
cristybb503372010-05-27 20:51:26 +00001402 size_t
cristy3ed852e2009-09-05 21:47:34 +00001403 number_arguments;
1404
1405 /*
1406 Distort image.
1407 */
cristy6b3da3a2010-06-20 02:21:46 +00001408 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001409 method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
1410 MagickFalse,argv[i+1]);
cristy6b3da3a2010-06-20 02:21:46 +00001411 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
cristy3ed852e2009-09-05 21:47:34 +00001412 InheritException(exception,&(*image)->exception);
1413 if (args == (char *) NULL)
1414 break;
1415 p=(char *) args;
1416 for (x=0; *p != '\0'; x++)
1417 {
1418 GetMagickToken(p,&p,token);
1419 if (*token == ',')
1420 GetMagickToken(p,&p,token);
1421 }
cristybb503372010-05-27 20:51:26 +00001422 number_arguments=(size_t) x;
cristy3ed852e2009-09-05 21:47:34 +00001423 arguments=(double *) AcquireQuantumMemory(number_arguments,
1424 sizeof(*arguments));
1425 if (arguments == (double *) NULL)
1426 ThrowWandFatalException(ResourceLimitFatalError,
1427 "MemoryAllocationFailed",(*image)->filename);
1428 (void) ResetMagickMemory(arguments,0,number_arguments*
1429 sizeof(*arguments));
1430 p=(char *) args;
cristybb503372010-05-27 20:51:26 +00001431 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
cristy3ed852e2009-09-05 21:47:34 +00001432 {
1433 GetMagickToken(p,&p,token);
1434 if (*token == ',')
1435 GetMagickToken(p,&p,token);
cristyf2f27272009-12-17 14:48:46 +00001436 arguments[x]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +00001437 }
1438 args=DestroyString(args);
1439 distort_image=DistortImage(*image,method,number_arguments,arguments,
1440 (*option == '+') ? MagickTrue : MagickFalse,exception);
1441 arguments=(double *) RelinquishMagickMemory(arguments);
1442 if (distort_image == (Image *) NULL)
1443 break;
1444 *image=DestroyImage(*image);
1445 *image=distort_image;
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) ParseMagickOption(
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 */
cristy6b3da3a2010-06-20 02:21:46 +00001467 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001468 (void) CloneString(&draw_info->primitive,argv[i+1]);
1469 (void) DrawImage(*image,draw_info);
1470 InheritException(exception,&(*image)->exception);
1471 break;
1472 }
1473 break;
1474 }
1475 case 'e':
1476 {
1477 if (LocaleCompare("edge",option+1) == 0)
1478 {
1479 Image
1480 *edge_image;
1481
1482 /*
1483 Enhance edges in the image.
1484 */
cristy6b3da3a2010-06-20 02:21:46 +00001485 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001486 flags=ParseGeometry(argv[i+1],&geometry_info);
1487 if ((flags & SigmaValue) == 0)
1488 geometry_info.sigma=1.0;
1489 edge_image=EdgeImage(*image,geometry_info.rho,exception);
1490 if (edge_image == (Image *) NULL)
1491 break;
1492 *image=DestroyImage(*image);
1493 *image=edge_image;
1494 break;
1495 }
1496 if (LocaleCompare("emboss",option+1) == 0)
1497 {
1498 Image
1499 *emboss_image;
1500
1501 /*
1502 Gaussian embossen image.
1503 */
cristy6b3da3a2010-06-20 02:21:46 +00001504 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001505 flags=ParseGeometry(argv[i+1],&geometry_info);
1506 if ((flags & SigmaValue) == 0)
1507 geometry_info.sigma=1.0;
1508 emboss_image=EmbossImage(*image,geometry_info.rho,
1509 geometry_info.sigma,exception);
1510 if (emboss_image == (Image *) NULL)
1511 break;
1512 *image=DestroyImage(*image);
1513 *image=emboss_image;
1514 break;
1515 }
1516 if (LocaleCompare("encipher",option+1) == 0)
1517 {
1518 StringInfo
1519 *passkey;
1520
1521 /*
1522 Encipher pixels.
1523 */
cristy6b3da3a2010-06-20 02:21:46 +00001524 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001525 passkey=FileToStringInfo(argv[i+1],~0,exception);
1526 if (passkey != (StringInfo *) NULL)
1527 {
1528 (void) PasskeyEncipherImage(*image,passkey,exception);
1529 passkey=DestroyStringInfo(passkey);
1530 }
1531 break;
1532 }
1533 if (LocaleCompare("encoding",option+1) == 0)
1534 {
1535 (void) CloneString(&draw_info->encoding,argv[i+1]);
1536 break;
1537 }
1538 if (LocaleCompare("enhance",option+1) == 0)
1539 {
1540 Image
1541 *enhance_image;
1542
1543 /*
1544 Enhance image.
1545 */
cristy6b3da3a2010-06-20 02:21:46 +00001546 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001547 enhance_image=EnhanceImage(*image,exception);
1548 if (enhance_image == (Image *) NULL)
1549 break;
1550 *image=DestroyImage(*image);
1551 *image=enhance_image;
1552 break;
1553 }
1554 if (LocaleCompare("equalize",option+1) == 0)
1555 {
1556 /*
1557 Equalize image.
1558 */
cristy6b3da3a2010-06-20 02:21:46 +00001559 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001560 (void) EqualizeImageChannel(*image,channel);
1561 InheritException(exception,&(*image)->exception);
1562 break;
1563 }
1564 if (LocaleCompare("evaluate",option+1) == 0)
1565 {
1566 double
1567 constant;
1568
1569 MagickEvaluateOperator
1570 op;
1571
cristy6b3da3a2010-06-20 02:21:46 +00001572 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001573 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
1574 MagickFalse,argv[i+1]);
cristyf2f27272009-12-17 14:48:46 +00001575 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
cristy3ed852e2009-09-05 21:47:34 +00001576 (void) EvaluateImageChannel(*image,channel,op,constant,exception);
1577 break;
1578 }
1579 if (LocaleCompare("extent",option+1) == 0)
1580 {
1581 Image
1582 *extent_image;
1583
1584 /*
1585 Set the image extent.
1586 */
cristy6b3da3a2010-06-20 02:21:46 +00001587 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001588 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
cristyf0bbfd92009-11-25 14:12:31 +00001589 if (geometry.width == 0)
cristy2ea9a4e2009-11-25 14:30:22 +00001590 geometry.width=(*image)->columns;
cristyf0bbfd92009-11-25 14:12:31 +00001591 if (geometry.height == 0)
cristy2ea9a4e2009-11-25 14:30:22 +00001592 geometry.height=(*image)->rows;
cristy3ed852e2009-09-05 21:47:34 +00001593 extent_image=ExtentImage(*image,&geometry,exception);
1594 if (extent_image == (Image *) NULL)
1595 break;
1596 *image=DestroyImage(*image);
1597 *image=extent_image;
1598 break;
1599 }
1600 break;
1601 }
1602 case 'f':
1603 {
1604 if (LocaleCompare("family",option+1) == 0)
1605 {
1606 if (*option == '+')
1607 {
1608 if (draw_info->family != (char *) NULL)
1609 draw_info->family=DestroyString(draw_info->family);
1610 break;
1611 }
1612 (void) CloneString(&draw_info->family,argv[i+1]);
1613 break;
1614 }
cristy0fe961c2010-01-30 03:09:54 +00001615 if (LocaleCompare("features",option+1) == 0)
1616 {
1617 if (*option == '+')
1618 {
1619 (void) DeleteImageArtifact(*image,"identify:features");
1620 break;
1621 }
1622 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1623 break;
1624 }
cristy3ed852e2009-09-05 21:47:34 +00001625 if (LocaleCompare("fill",option+1) == 0)
1626 {
1627 ExceptionInfo
1628 *sans;
1629
1630 GetMagickPixelPacket(*image,&fill);
1631 if (*option == '+')
1632 {
1633 (void) QueryMagickColor("none",&fill,exception);
1634 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1635 if (draw_info->fill_pattern != (Image *) NULL)
1636 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1637 break;
1638 }
1639 sans=AcquireExceptionInfo();
1640 (void) QueryMagickColor(argv[i+1],&fill,sans);
1641 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1642 sans=DestroyExceptionInfo(sans);
1643 if (status == MagickFalse)
cristy6b3da3a2010-06-20 02:21:46 +00001644 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
cristy3ed852e2009-09-05 21:47:34 +00001645 exception);
1646 break;
1647 }
1648 if (LocaleCompare("flip",option+1) == 0)
1649 {
1650 Image
1651 *flip_image;
1652
1653 /*
1654 Flip image scanlines.
1655 */
cristy6b3da3a2010-06-20 02:21:46 +00001656 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001657 flip_image=FlipImage(*image,exception);
1658 if (flip_image == (Image *) NULL)
1659 break;
1660 *image=DestroyImage(*image);
1661 *image=flip_image;
1662 break;
1663 }
1664 if (LocaleCompare("flop",option+1) == 0)
1665 {
1666 Image
1667 *flop_image;
1668
1669 /*
1670 Flop image scanlines.
1671 */
cristy6b3da3a2010-06-20 02:21:46 +00001672 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001673 flop_image=FlopImage(*image,exception);
1674 if (flop_image == (Image *) NULL)
1675 break;
1676 *image=DestroyImage(*image);
1677 *image=flop_image;
1678 break;
1679 }
1680 if (LocaleCompare("floodfill",option+1) == 0)
1681 {
1682 MagickPixelPacket
1683 target;
1684
1685 /*
1686 Floodfill image.
1687 */
cristy6b3da3a2010-06-20 02:21:46 +00001688 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001689 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1690 (void) QueryMagickColor(argv[i+2],&target,exception);
1691 (void) FloodfillPaintImage(*image,channel,draw_info,&target,
1692 geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1693 InheritException(exception,&(*image)->exception);
1694 break;
1695 }
1696 if (LocaleCompare("font",option+1) == 0)
1697 {
1698 if (*option == '+')
1699 {
1700 if (draw_info->font != (char *) NULL)
1701 draw_info->font=DestroyString(draw_info->font);
1702 break;
1703 }
1704 (void) CloneString(&draw_info->font,argv[i+1]);
1705 break;
1706 }
1707 if (LocaleCompare("format",option+1) == 0)
1708 {
1709 format=argv[i+1];
1710 break;
1711 }
1712 if (LocaleCompare("frame",option+1) == 0)
1713 {
1714 FrameInfo
1715 frame_info;
1716
1717 Image
1718 *frame_image;
1719
1720 /*
1721 Surround image with an ornamental border.
1722 */
cristy6b3da3a2010-06-20 02:21:46 +00001723 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001724 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1725 frame_info.width=geometry.width;
1726 frame_info.height=geometry.height;
1727 if ((flags & HeightValue) == 0)
1728 frame_info.height=geometry.width;
1729 frame_info.outer_bevel=geometry.x;
1730 frame_info.inner_bevel=geometry.y;
cristybb503372010-05-27 20:51:26 +00001731 frame_info.x=(ssize_t) frame_info.width;
1732 frame_info.y=(ssize_t) frame_info.height;
cristy3ed852e2009-09-05 21:47:34 +00001733 frame_info.width=(*image)->columns+2*frame_info.width;
1734 frame_info.height=(*image)->rows+2*frame_info.height;
1735 frame_image=FrameImage(*image,&frame_info,exception);
1736 if (frame_image == (Image *) NULL)
1737 break;
1738 *image=DestroyImage(*image);
1739 *image=frame_image;
1740 break;
1741 }
1742 if (LocaleCompare("function",option+1) == 0)
1743 {
1744 char
1745 *arguments,
1746 token[MaxTextExtent];
1747
1748 const char
1749 *p;
1750
1751 double
1752 *parameters;
1753
1754 MagickFunction
1755 function;
1756
cristybb503372010-05-27 20:51:26 +00001757 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001758 x;
1759
cristybb503372010-05-27 20:51:26 +00001760 size_t
cristy3ed852e2009-09-05 21:47:34 +00001761 number_parameters;
1762
1763 /*
1764 Function Modify Image Values
1765 */
cristy6b3da3a2010-06-20 02:21:46 +00001766 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001767 function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
1768 MagickFalse,argv[i+1]);
cristy6b3da3a2010-06-20 02:21:46 +00001769 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
cristy3ed852e2009-09-05 21:47:34 +00001770 InheritException(exception,&(*image)->exception);
1771 if (arguments == (char *) NULL)
1772 break;
1773 p=(char *) arguments;
1774 for (x=0; *p != '\0'; x++)
1775 {
1776 GetMagickToken(p,&p,token);
1777 if (*token == ',')
1778 GetMagickToken(p,&p,token);
1779 }
cristybb503372010-05-27 20:51:26 +00001780 number_parameters=(size_t) x;
cristy3ed852e2009-09-05 21:47:34 +00001781 parameters=(double *) AcquireQuantumMemory(number_parameters,
1782 sizeof(*parameters));
1783 if (parameters == (double *) NULL)
1784 ThrowWandFatalException(ResourceLimitFatalError,
1785 "MemoryAllocationFailed",(*image)->filename);
1786 (void) ResetMagickMemory(parameters,0,number_parameters*
1787 sizeof(*parameters));
1788 p=(char *) arguments;
cristybb503372010-05-27 20:51:26 +00001789 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
cristy3ed852e2009-09-05 21:47:34 +00001790 {
1791 GetMagickToken(p,&p,token);
1792 if (*token == ',')
1793 GetMagickToken(p,&p,token);
cristyf2f27272009-12-17 14:48:46 +00001794 parameters[x]=StringToDouble(token);
cristy3ed852e2009-09-05 21:47:34 +00001795 }
1796 arguments=DestroyString(arguments);
1797 (void) FunctionImageChannel(*image,channel,function,
1798 number_parameters,parameters,exception);
1799 parameters=(double *) RelinquishMagickMemory(parameters);
1800 break;
1801 }
1802 break;
1803 }
1804 case 'g':
1805 {
1806 if (LocaleCompare("gamma",option+1) == 0)
1807 {
1808 /*
1809 Gamma image.
1810 */
cristy6b3da3a2010-06-20 02:21:46 +00001811 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001812 if (*option == '+')
cristyf2f27272009-12-17 14:48:46 +00001813 (*image)->gamma=StringToDouble(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00001814 else
1815 {
1816 if (strchr(argv[i+1],',') != (char *) NULL)
1817 (void) GammaImage(*image,argv[i+1]);
1818 else
cristya5447be2010-01-11 00:20:51 +00001819 (void) GammaImageChannel(*image,channel,
1820 StringToDouble(argv[i+1]));
cristy3ed852e2009-09-05 21:47:34 +00001821 InheritException(exception,&(*image)->exception);
1822 }
1823 break;
1824 }
1825 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1826 (LocaleCompare("gaussian",option+1) == 0))
1827 {
1828 Image
1829 *gaussian_image;
1830
1831 /*
1832 Gaussian blur image.
1833 */
cristy6b3da3a2010-06-20 02:21:46 +00001834 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001835 flags=ParseGeometry(argv[i+1],&geometry_info);
1836 if ((flags & SigmaValue) == 0)
1837 geometry_info.sigma=1.0;
1838 gaussian_image=GaussianBlurImageChannel(*image,channel,
1839 geometry_info.rho,geometry_info.sigma,exception);
1840 if (gaussian_image == (Image *) NULL)
1841 break;
1842 *image=DestroyImage(*image);
1843 *image=gaussian_image;
1844 break;
1845 }
1846 if (LocaleCompare("geometry",option+1) == 0)
1847 {
cristy6b3da3a2010-06-20 02:21:46 +00001848 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001849 if (*option == '+')
1850 {
1851 if ((*image)->geometry != (char *) NULL)
1852 (*image)->geometry=DestroyString((*image)->geometry);
1853 break;
1854 }
1855 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1856 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1857 (void) CloneString(&(*image)->geometry,argv[i+1]);
1858 else
1859 {
1860 Image
cristy15b98cd2010-09-12 19:42:50 +00001861 *resize_image;
cristy3ed852e2009-09-05 21:47:34 +00001862
1863 /*
1864 Resize image.
1865 */
cristy15b98cd2010-09-12 19:42:50 +00001866 resize_image=ResizeImage(*image,geometry.width,geometry.height,
1867 (*image)->filter,(*image)->blur,exception);
1868 if (resize_image == (Image *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001869 break;
1870 *image=DestroyImage(*image);
cristy15b98cd2010-09-12 19:42:50 +00001871 *image=resize_image;
cristy3ed852e2009-09-05 21:47:34 +00001872 }
1873 break;
1874 }
1875 if (LocaleCompare("gravity",option+1) == 0)
1876 {
1877 if (*option == '+')
1878 {
1879 draw_info->gravity=UndefinedGravity;
1880 break;
1881 }
1882 draw_info->gravity=(GravityType) ParseMagickOption(
1883 MagickGravityOptions,MagickFalse,argv[i+1]);
1884 break;
1885 }
1886 break;
1887 }
1888 case 'h':
1889 {
1890 if (LocaleCompare("highlight-color",option+1) == 0)
1891 {
1892 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1893 break;
1894 }
1895 break;
1896 }
1897 case 'i':
1898 {
1899 if (LocaleCompare("identify",option+1) == 0)
1900 {
1901 char
1902 *text;
1903
cristy6b3da3a2010-06-20 02:21:46 +00001904 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001905 if (format == (char *) NULL)
1906 {
cristy6b3da3a2010-06-20 02:21:46 +00001907 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
cristy3ed852e2009-09-05 21:47:34 +00001908 InheritException(exception,&(*image)->exception);
1909 break;
1910 }
cristy6b3da3a2010-06-20 02:21:46 +00001911 text=InterpretImageProperties(mogrify_info,*image,format);
cristy3ed852e2009-09-05 21:47:34 +00001912 InheritException(exception,&(*image)->exception);
1913 if (text == (char *) NULL)
1914 break;
1915 (void) fputs(text,stdout);
1916 (void) fputc('\n',stdout);
1917 text=DestroyString(text);
1918 break;
1919 }
1920 if (LocaleCompare("implode",option+1) == 0)
1921 {
1922 Image
1923 *implode_image;
1924
1925 /*
1926 Implode image.
1927 */
cristy6b3da3a2010-06-20 02:21:46 +00001928 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001929 (void) ParseGeometry(argv[i+1],&geometry_info);
1930 implode_image=ImplodeImage(*image,geometry_info.rho,exception);
1931 if (implode_image == (Image *) NULL)
1932 break;
1933 *image=DestroyImage(*image);
1934 *image=implode_image;
1935 break;
1936 }
cristyb32b90a2009-09-07 21:45:48 +00001937 if (LocaleCompare("interline-spacing",option+1) == 0)
1938 {
1939 if (*option == '+')
1940 (void) ParseGeometry("0",&geometry_info);
1941 else
1942 (void) ParseGeometry(argv[i+1],&geometry_info);
1943 draw_info->interline_spacing=geometry_info.rho;
1944 break;
1945 }
cristy3ed852e2009-09-05 21:47:34 +00001946 if (LocaleCompare("interword-spacing",option+1) == 0)
1947 {
1948 if (*option == '+')
1949 (void) ParseGeometry("0",&geometry_info);
1950 else
1951 (void) ParseGeometry(argv[i+1],&geometry_info);
1952 draw_info->interword_spacing=geometry_info.rho;
1953 break;
1954 }
1955 break;
1956 }
1957 case 'k':
1958 {
1959 if (LocaleCompare("kerning",option+1) == 0)
1960 {
1961 if (*option == '+')
1962 (void) ParseGeometry("0",&geometry_info);
1963 else
1964 (void) ParseGeometry(argv[i+1],&geometry_info);
1965 draw_info->kerning=geometry_info.rho;
1966 break;
1967 }
1968 break;
1969 }
1970 case 'l':
1971 {
1972 if (LocaleCompare("lat",option+1) == 0)
1973 {
1974 Image
1975 *threshold_image;
1976
1977 /*
1978 Local adaptive threshold image.
1979 */
cristy6b3da3a2010-06-20 02:21:46 +00001980 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00001981 flags=ParseGeometry(argv[i+1],&geometry_info);
1982 if ((flags & PercentValue) != 0)
1983 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
cristybb503372010-05-27 20:51:26 +00001984 threshold_image=AdaptiveThresholdImage(*image,(size_t)
1985 geometry_info.rho,(size_t) geometry_info.sigma,
1986 (ssize_t) geometry_info.xi,exception);
cristy3ed852e2009-09-05 21:47:34 +00001987 if (threshold_image == (Image *) NULL)
1988 break;
1989 *image=DestroyImage(*image);
1990 *image=threshold_image;
1991 break;
1992 }
1993 if (LocaleCompare("level",option+1) == 0)
1994 {
cristy3ed852e2009-09-05 21:47:34 +00001995 MagickRealType
1996 black_point,
1997 gamma,
1998 white_point;
1999
2000 MagickStatusType
2001 flags;
2002
2003 /*
2004 Parse levels.
2005 */
cristy6b3da3a2010-06-20 02:21:46 +00002006 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002007 flags=ParseGeometry(argv[i+1],&geometry_info);
2008 black_point=geometry_info.rho;
2009 white_point=(MagickRealType) QuantumRange;
2010 if ((flags & SigmaValue) != 0)
2011 white_point=geometry_info.sigma;
2012 gamma=1.0;
2013 if ((flags & XiValue) != 0)
2014 gamma=geometry_info.xi;
2015 if ((flags & PercentValue) != 0)
2016 {
2017 black_point*=(MagickRealType) (QuantumRange/100.0);
2018 white_point*=(MagickRealType) (QuantumRange/100.0);
2019 }
2020 if ((flags & SigmaValue) == 0)
2021 white_point=(MagickRealType) QuantumRange-black_point;
2022 if ((*option == '+') || ((flags & AspectValue) != 0))
2023 (void) LevelizeImageChannel(*image,channel,black_point,
2024 white_point,gamma);
2025 else
2026 (void) LevelImageChannel(*image,channel,black_point,white_point,
2027 gamma);
2028 InheritException(exception,&(*image)->exception);
2029 break;
2030 }
2031 if (LocaleCompare("level-colors",option+1) == 0)
2032 {
2033 char
2034 token[MaxTextExtent];
2035
2036 const char
2037 *p;
2038
2039 MagickPixelPacket
2040 black_point,
2041 white_point;
2042
2043 p=(const char *) argv[i+1];
2044 GetMagickToken(p,&p,token); /* get black point color */
cristyee0f8d72009-09-19 00:58:29 +00002045 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy3ed852e2009-09-05 21:47:34 +00002046 (void) QueryMagickColor(token,&black_point,exception);
2047 else
cristyee0f8d72009-09-19 00:58:29 +00002048 (void) QueryMagickColor("#000000",&black_point,exception);
cristy3ed852e2009-09-05 21:47:34 +00002049 if (isalpha((int) token[0]) || (token[0] == '#'))
2050 GetMagickToken(p,&p,token);
cristyee0f8d72009-09-19 00:58:29 +00002051 if (*token == '\0')
cristy3ed852e2009-09-05 21:47:34 +00002052 white_point=black_point; /* set everything to that color */
2053 else
2054 {
2055 /*
2056 Get white point color.
2057 */
cristyee0f8d72009-09-19 00:58:29 +00002058 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
cristy3ed852e2009-09-05 21:47:34 +00002059 GetMagickToken(p,&p,token);
cristyee0f8d72009-09-19 00:58:29 +00002060 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
cristy3ed852e2009-09-05 21:47:34 +00002061 (void) QueryMagickColor(token,&white_point,exception);
2062 else
cristyee0f8d72009-09-19 00:58:29 +00002063 (void) QueryMagickColor("#ffffff",&white_point,exception);
cristy3ed852e2009-09-05 21:47:34 +00002064 }
cristy74fe8f12009-10-03 19:09:01 +00002065 (void) LevelColorsImageChannel(*image,channel,&black_point,
2066 &white_point,*option == '+' ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +00002067 break;
2068 }
2069 if (LocaleCompare("linear-stretch",option+1) == 0)
2070 {
2071 double
2072 black_point,
2073 white_point;
2074
cristy3ed852e2009-09-05 21:47:34 +00002075 MagickStatusType
2076 flags;
2077
cristy6b3da3a2010-06-20 02:21:46 +00002078 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002079 flags=ParseGeometry(argv[i+1],&geometry_info);
2080 black_point=geometry_info.rho;
2081 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2082 if ((flags & SigmaValue) != 0)
2083 white_point=geometry_info.sigma;
2084 if ((flags & PercentValue) != 0)
2085 {
2086 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2087 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2088 }
2089 if ((flags & SigmaValue) == 0)
2090 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2091 black_point;
2092 (void) LinearStretchImage(*image,black_point,white_point);
2093 InheritException(exception,&(*image)->exception);
2094 break;
2095 }
2096 if (LocaleCompare("linewidth",option+1) == 0)
2097 {
cristyf2f27272009-12-17 14:48:46 +00002098 draw_info->stroke_width=StringToDouble(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00002099 break;
2100 }
2101 if (LocaleCompare("liquid-rescale",option+1) == 0)
2102 {
2103 Image
2104 *resize_image;
2105
2106 /*
2107 Liquid rescale image.
2108 */
cristy6b3da3a2010-06-20 02:21:46 +00002109 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002110 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2111 if ((flags & XValue) == 0)
2112 geometry.x=1;
2113 if ((flags & YValue) == 0)
2114 geometry.y=0;
2115 resize_image=LiquidRescaleImage(*image,geometry.width,
2116 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2117 if (resize_image == (Image *) NULL)
2118 break;
2119 *image=DestroyImage(*image);
2120 *image=resize_image;
2121 break;
2122 }
2123 if (LocaleCompare("lowlight-color",option+1) == 0)
2124 {
2125 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2126 break;
2127 }
2128 break;
2129 }
2130 case 'm':
2131 {
2132 if (LocaleCompare("map",option+1) == 0)
2133 {
2134 Image
2135 *remap_image;
2136
2137 /*
2138 Transform image colors to match this set of colors.
2139 */
cristy6b3da3a2010-06-20 02:21:46 +00002140 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002141 if (*option == '+')
2142 break;
cristy6b3da3a2010-06-20 02:21:46 +00002143 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00002144 if (remap_image == (Image *) NULL)
2145 break;
2146 (void) RemapImage(quantize_info,*image,remap_image);
2147 InheritException(exception,&(*image)->exception);
2148 remap_image=DestroyImage(remap_image);
2149 break;
2150 }
2151 if (LocaleCompare("mask",option+1) == 0)
2152 {
2153 Image
2154 *mask;
2155
cristy6b3da3a2010-06-20 02:21:46 +00002156 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002157 if (*option == '+')
2158 {
2159 /*
2160 Remove a mask.
2161 */
2162 (void) SetImageMask(*image,(Image *) NULL);
2163 InheritException(exception,&(*image)->exception);
2164 break;
2165 }
2166 /*
2167 Set the image mask.
2168 */
cristy6b3da3a2010-06-20 02:21:46 +00002169 mask=GetImageCache(mogrify_info,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00002170 if (mask == (Image *) NULL)
2171 break;
2172 (void) SetImageMask(*image,mask);
2173 mask=DestroyImage(mask);
2174 InheritException(exception,&(*image)->exception);
2175 break;
2176 }
2177 if (LocaleCompare("matte",option+1) == 0)
2178 {
2179 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2180 SetAlphaChannel : DeactivateAlphaChannel );
2181 InheritException(exception,&(*image)->exception);
2182 break;
2183 }
2184 if (LocaleCompare("median",option+1) == 0)
2185 {
2186 Image
2187 *median_image;
2188
2189 /*
2190 Median filter image.
2191 */
cristy6b3da3a2010-06-20 02:21:46 +00002192 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002193 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy733678d2011-03-18 21:29:28 +00002194 median_image=StatisticImageChannel(*image,channel,MedianStatistic,
cristy95c38342011-03-18 22:39:51 +00002195 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
cristy3ed852e2009-09-05 21:47:34 +00002196 if (median_image == (Image *) NULL)
2197 break;
2198 *image=DestroyImage(*image);
2199 *image=median_image;
2200 break;
2201 }
cristy69ec32d2011-02-27 23:57:09 +00002202 if (LocaleCompare("mode",option+1) == 0)
2203 {
2204 Image
2205 *mode_image;
2206
2207 /*
2208 Mode image.
2209 */
2210 (void) SyncImageSettings(mogrify_info,*image);
2211 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy733678d2011-03-18 21:29:28 +00002212 mode_image=StatisticImageChannel(*image,channel,ModeStatistic,
cristy95c38342011-03-18 22:39:51 +00002213 (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception);
cristy69ec32d2011-02-27 23:57:09 +00002214 if (mode_image == (Image *) NULL)
2215 break;
2216 *image=DestroyImage(*image);
2217 *image=mode_image;
2218 break;
2219 }
cristy3ed852e2009-09-05 21:47:34 +00002220 if (LocaleCompare("modulate",option+1) == 0)
2221 {
cristy6b3da3a2010-06-20 02:21:46 +00002222 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002223 (void) ModulateImage(*image,argv[i+1]);
2224 InheritException(exception,&(*image)->exception);
2225 break;
2226 }
2227 if (LocaleCompare("monitor",option+1) == 0)
2228 {
cristy7d34ef22010-03-25 01:11:22 +00002229 if (*option == '+')
2230 {
2231 (void) SetImageProgressMonitor(*image,
2232 (MagickProgressMonitor) NULL,(void *) NULL);
2233 break;
2234 }
cristy3ed852e2009-09-05 21:47:34 +00002235 (void) SetImageProgressMonitor(*image,MonitorProgress,
2236 (void *) NULL);
2237 break;
2238 }
2239 if (LocaleCompare("monochrome",option+1) == 0)
2240 {
cristy6b3da3a2010-06-20 02:21:46 +00002241 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002242 (void) SetImageType(*image,BilevelType);
2243 InheritException(exception,&(*image)->exception);
2244 break;
2245 }
anthony29188a82010-01-22 10:12:34 +00002246 if (LocaleCompare("morphology",option+1) == 0)
2247 {
anthony29188a82010-01-22 10:12:34 +00002248 char
2249 token[MaxTextExtent];
2250
2251 const char
2252 *p;
2253
cristye96405a2010-05-19 02:24:31 +00002254 Image
2255 *morphology_image;
2256
2257 KernelInfo
2258 *kernel;
2259
cristye96405a2010-05-19 02:24:31 +00002260 MorphologyMethod
2261 method;
2262
cristy9d314ff2011-03-09 01:30:28 +00002263 ssize_t
2264 iterations;
2265
anthony29188a82010-01-22 10:12:34 +00002266 /*
2267 Morphological Image Operation
2268 */
cristy6b3da3a2010-06-20 02:21:46 +00002269 (void) SyncImageSettings(mogrify_info,*image);
anthony29188a82010-01-22 10:12:34 +00002270 p=argv[i+1];
2271 GetMagickToken(p,&p,token);
2272 method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions,
cristyd2c1e1e2010-05-08 01:05:44 +00002273 MagickFalse,token);
cristyef656912010-03-05 19:54:59 +00002274 iterations=1L;
anthony29188a82010-01-22 10:12:34 +00002275 GetMagickToken(p,&p,token);
cristyef656912010-03-05 19:54:59 +00002276 if ((*p == ':') || (*p == ','))
anthony29188a82010-01-22 10:12:34 +00002277 GetMagickToken(p,&p,token);
cristyef656912010-03-05 19:54:59 +00002278 if ((*p != '\0'))
cristy32c2aea2010-12-01 01:00:50 +00002279 iterations=(ssize_t) StringToLong(p);
anthony29188a82010-01-22 10:12:34 +00002280 kernel=AcquireKernelInfo(argv[i+2]);
2281 if (kernel == (KernelInfo *) NULL)
cristye96405a2010-05-19 02:24:31 +00002282 {
2283 (void) ThrowMagickException(exception,GetMagickModule(),
2284 OptionError,"UnabletoParseKernel","morphology");
2285 status=MagickFalse;
2286 break;
2287 }
anthony29188a82010-01-22 10:12:34 +00002288 morphology_image=MorphologyImageChannel(*image,channel,method,
cristy02d5b4f2010-02-01 01:08:27 +00002289 iterations,kernel,exception);
anthony83ba99b2010-01-24 08:48:15 +00002290 kernel=DestroyKernelInfo(kernel);
anthony29188a82010-01-22 10:12:34 +00002291 if (morphology_image == (Image *) NULL)
2292 break;
2293 *image=DestroyImage(*image);
2294 *image=morphology_image;
2295 break;
2296 }
cristy3ed852e2009-09-05 21:47:34 +00002297 if (LocaleCompare("motion-blur",option+1) == 0)
2298 {
2299 Image
2300 *blur_image;
2301
2302 /*
2303 Motion blur image.
2304 */
cristy6b3da3a2010-06-20 02:21:46 +00002305 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002306 flags=ParseGeometry(argv[i+1],&geometry_info);
2307 if ((flags & SigmaValue) == 0)
2308 geometry_info.sigma=1.0;
2309 blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
2310 geometry_info.sigma,geometry_info.xi,exception);
2311 if (blur_image == (Image *) NULL)
2312 break;
2313 *image=DestroyImage(*image);
2314 *image=blur_image;
2315 break;
2316 }
2317 break;
2318 }
2319 case 'n':
2320 {
2321 if (LocaleCompare("negate",option+1) == 0)
2322 {
cristy6b3da3a2010-06-20 02:21:46 +00002323 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002324 (void) NegateImageChannel(*image,channel,*option == '+' ?
2325 MagickTrue : MagickFalse);
2326 InheritException(exception,&(*image)->exception);
2327 break;
2328 }
2329 if (LocaleCompare("noise",option+1) == 0)
2330 {
2331 Image
2332 *noisy_image;
2333
cristy6b3da3a2010-06-20 02:21:46 +00002334 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002335 if (*option == '-')
2336 {
2337 (void) ParseGeometry(argv[i+1],&geometry_info);
cristy733678d2011-03-18 21:29:28 +00002338 noisy_image=StatisticImageChannel(*image,channel,
cristy95c38342011-03-18 22:39:51 +00002339 NonpeakStatistic,(size_t) geometry_info.rho,(size_t)
2340 geometry_info.rho,exception);
cristy3ed852e2009-09-05 21:47:34 +00002341 }
2342 else
2343 {
2344 NoiseType
2345 noise;
2346
2347 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
2348 MagickFalse,argv[i+1]);
2349 noisy_image=AddNoiseImageChannel(*image,channel,noise,
2350 exception);
2351 }
2352 if (noisy_image == (Image *) NULL)
2353 break;
2354 *image=DestroyImage(*image);
2355 *image=noisy_image;
2356 break;
2357 }
2358 if (LocaleCompare("normalize",option+1) == 0)
2359 {
cristy6b3da3a2010-06-20 02:21:46 +00002360 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002361 (void) NormalizeImageChannel(*image,channel);
2362 InheritException(exception,&(*image)->exception);
2363 break;
2364 }
2365 break;
2366 }
2367 case 'o':
2368 {
2369 if (LocaleCompare("opaque",option+1) == 0)
2370 {
2371 MagickPixelPacket
2372 target;
2373
cristy6b3da3a2010-06-20 02:21:46 +00002374 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002375 (void) QueryMagickColor(argv[i+1],&target,exception);
2376 (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
2377 *option == '-' ? MagickFalse : MagickTrue);
2378 break;
2379 }
2380 if (LocaleCompare("ordered-dither",option+1) == 0)
2381 {
cristy6b3da3a2010-06-20 02:21:46 +00002382 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002383 (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
2384 exception);
2385 break;
2386 }
2387 break;
2388 }
2389 case 'p':
2390 {
2391 if (LocaleCompare("paint",option+1) == 0)
2392 {
2393 Image
2394 *paint_image;
2395
2396 /*
2397 Oil paint image.
2398 */
cristy6b3da3a2010-06-20 02:21:46 +00002399 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002400 (void) ParseGeometry(argv[i+1],&geometry_info);
2401 paint_image=OilPaintImage(*image,geometry_info.rho,exception);
2402 if (paint_image == (Image *) NULL)
2403 break;
2404 *image=DestroyImage(*image);
2405 *image=paint_image;
2406 break;
2407 }
2408 if (LocaleCompare("pen",option+1) == 0)
2409 {
2410 if (*option == '+')
2411 {
2412 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2413 break;
2414 }
2415 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2416 break;
2417 }
2418 if (LocaleCompare("pointsize",option+1) == 0)
2419 {
2420 if (*option == '+')
2421 (void) ParseGeometry("12",&geometry_info);
2422 else
2423 (void) ParseGeometry(argv[i+1],&geometry_info);
2424 draw_info->pointsize=geometry_info.rho;
2425 break;
2426 }
2427 if (LocaleCompare("polaroid",option+1) == 0)
2428 {
2429 double
2430 angle;
2431
2432 Image
2433 *polaroid_image;
2434
2435 RandomInfo
2436 *random_info;
2437
2438 /*
2439 Simulate a Polaroid picture.
2440 */
cristy6b3da3a2010-06-20 02:21:46 +00002441 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002442 random_info=AcquireRandomInfo();
2443 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2444 random_info=DestroyRandomInfo(random_info);
2445 if (*option == '-')
2446 {
2447 SetGeometryInfo(&geometry_info);
2448 flags=ParseGeometry(argv[i+1],&geometry_info);
2449 angle=geometry_info.rho;
2450 }
2451 polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
2452 if (polaroid_image == (Image *) NULL)
2453 break;
2454 *image=DestroyImage(*image);
2455 *image=polaroid_image;
2456 break;
2457 }
2458 if (LocaleCompare("posterize",option+1) == 0)
2459 {
2460 /*
2461 Posterize image.
2462 */
cristy6b3da3a2010-06-20 02:21:46 +00002463 (void) SyncImageSettings(mogrify_info,*image);
cristye27293e2009-12-18 02:53:20 +00002464 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00002465 quantize_info->dither);
2466 InheritException(exception,&(*image)->exception);
2467 break;
2468 }
2469 if (LocaleCompare("preview",option+1) == 0)
2470 {
2471 Image
2472 *preview_image;
2473
2474 PreviewType
2475 preview_type;
2476
2477 /*
2478 Preview image.
2479 */
cristy6b3da3a2010-06-20 02:21:46 +00002480 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002481 if (*option == '+')
2482 preview_type=UndefinedPreview;
2483 else
2484 preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
2485 MagickFalse,argv[i+1]);
2486 preview_image=PreviewImage(*image,preview_type,exception);
2487 if (preview_image == (Image *) NULL)
2488 break;
2489 *image=DestroyImage(*image);
2490 *image=preview_image;
2491 break;
2492 }
2493 if (LocaleCompare("profile",option+1) == 0)
2494 {
2495 const char
2496 *name;
2497
2498 const StringInfo
2499 *profile;
2500
2501 Image
2502 *profile_image;
2503
2504 ImageInfo
2505 *profile_info;
2506
cristy6b3da3a2010-06-20 02:21:46 +00002507 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002508 if (*option == '+')
2509 {
2510 /*
2511 Remove a profile from the image.
2512 */
2513 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2514 NULL,0,MagickTrue);
2515 InheritException(exception,&(*image)->exception);
2516 break;
2517 }
2518 /*
2519 Associate a profile with the image.
2520 */
cristy6b3da3a2010-06-20 02:21:46 +00002521 profile_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00002522 profile=GetImageProfile(*image,"iptc");
2523 if (profile != (StringInfo *) NULL)
2524 profile_info->profile=(void *) CloneStringInfo(profile);
2525 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2526 profile_info=DestroyImageInfo(profile_info);
2527 if (profile_image == (Image *) NULL)
2528 {
cristy3ed852e2009-09-05 21:47:34 +00002529 StringInfo
2530 *profile;
2531
cristy6b3da3a2010-06-20 02:21:46 +00002532 profile_info=CloneImageInfo(mogrify_info);
cristy071dd7b2010-04-09 13:04:54 +00002533 (void) CopyMagickString(profile_info->filename,argv[i+1],
2534 MaxTextExtent);
2535 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
cristy3ed852e2009-09-05 21:47:34 +00002536 if (profile != (StringInfo *) NULL)
2537 {
cristy071dd7b2010-04-09 13:04:54 +00002538 (void) ProfileImage(*image,profile_info->magick,
cristybb503372010-05-27 20:51:26 +00002539 GetStringInfoDatum(profile),(size_t)
cristy071dd7b2010-04-09 13:04:54 +00002540 GetStringInfoLength(profile),MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +00002541 profile=DestroyStringInfo(profile);
2542 }
cristy071dd7b2010-04-09 13:04:54 +00002543 profile_info=DestroyImageInfo(profile_info);
cristy3ed852e2009-09-05 21:47:34 +00002544 break;
2545 }
2546 ResetImageProfileIterator(profile_image);
2547 name=GetNextImageProfile(profile_image);
2548 while (name != (const char *) NULL)
2549 {
2550 profile=GetImageProfile(profile_image,name);
2551 if (profile != (StringInfo *) NULL)
2552 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
cristybb503372010-05-27 20:51:26 +00002553 (size_t) GetStringInfoLength(profile),MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +00002554 name=GetNextImageProfile(profile_image);
2555 }
2556 profile_image=DestroyImage(profile_image);
2557 break;
2558 }
2559 break;
2560 }
2561 case 'q':
2562 {
2563 if (LocaleCompare("quantize",option+1) == 0)
2564 {
2565 if (*option == '+')
2566 {
2567 quantize_info->colorspace=UndefinedColorspace;
2568 break;
2569 }
2570 quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
2571 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2572 break;
2573 }
2574 break;
2575 }
2576 case 'r':
2577 {
2578 if (LocaleCompare("radial-blur",option+1) == 0)
2579 {
2580 Image
2581 *blur_image;
2582
2583 /*
2584 Radial blur image.
2585 */
cristy6b3da3a2010-06-20 02:21:46 +00002586 (void) SyncImageSettings(mogrify_info,*image);
cristya5447be2010-01-11 00:20:51 +00002587 blur_image=RadialBlurImageChannel(*image,channel,
2588 StringToDouble(argv[i+1]),exception);
cristy3ed852e2009-09-05 21:47:34 +00002589 if (blur_image == (Image *) NULL)
2590 break;
2591 *image=DestroyImage(*image);
2592 *image=blur_image;
2593 break;
2594 }
2595 if (LocaleCompare("raise",option+1) == 0)
2596 {
2597 /*
2598 Surround image with a raise of solid color.
2599 */
2600 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2601 if ((flags & SigmaValue) == 0)
2602 geometry.height=geometry.width;
2603 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2604 MagickFalse);
2605 InheritException(exception,&(*image)->exception);
2606 break;
2607 }
2608 if (LocaleCompare("random-threshold",option+1) == 0)
2609 {
2610 /*
2611 Threshold image.
2612 */
cristy6b3da3a2010-06-20 02:21:46 +00002613 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002614 (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
2615 exception);
2616 break;
2617 }
2618 if (LocaleCompare("recolor",option+1) == 0)
2619 {
cristy3ed852e2009-09-05 21:47:34 +00002620 Image
cristyf055ae42010-04-02 23:01:38 +00002621 *color_image;
cristy3ed852e2009-09-05 21:47:34 +00002622
cristyf055ae42010-04-02 23:01:38 +00002623 KernelInfo
2624 *kernel;
cristy3ed852e2009-09-05 21:47:34 +00002625
cristy6b3da3a2010-06-20 02:21:46 +00002626 (void) SyncImageSettings(mogrify_info,*image);
cristyf055ae42010-04-02 23:01:38 +00002627 kernel=AcquireKernelInfo(argv[i+1]);
2628 if (kernel == (KernelInfo *) NULL)
2629 break;
2630 color_image=ColorMatrixImage(*image,kernel,exception);
2631 kernel=DestroyKernelInfo(kernel);
2632 if (color_image == (Image *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00002633 break;
2634 *image=DestroyImage(*image);
cristyf055ae42010-04-02 23:01:38 +00002635 *image=color_image;
cristy3ed852e2009-09-05 21:47:34 +00002636 break;
2637 }
2638 if (LocaleCompare("region",option+1) == 0)
2639 {
2640 Image
2641 *crop_image;
2642
cristy6b3da3a2010-06-20 02:21:46 +00002643 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002644 if (region_image != (Image *) NULL)
2645 {
2646 /*
2647 Composite region.
2648 */
2649 (void) CompositeImage(region_image,(*image)->matte !=
2650 MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
2651 region_geometry.x,region_geometry.y);
2652 InheritException(exception,&region_image->exception);
2653 *image=DestroyImage(*image);
2654 *image=region_image;
2655 }
2656 if (*option == '+')
2657 {
2658 if (region_image != (Image *) NULL)
cristyb0a6e432010-10-09 13:26:15 +00002659 region_image=(Image *) NULL;
cristy3ed852e2009-09-05 21:47:34 +00002660 break;
2661 }
2662 /*
2663 Apply transformations to a selected region of the image.
2664 */
2665 (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
2666 exception);
2667 crop_image=CropImage(*image,&region_geometry,exception);
2668 if (crop_image == (Image *) NULL)
2669 break;
2670 region_image=(*image);
2671 *image=crop_image;
2672 break;
2673 }
2674 if (LocaleCompare("render",option+1) == 0)
2675 {
cristy6b3da3a2010-06-20 02:21:46 +00002676 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002677 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2678 break;
2679 }
2680 if (LocaleCompare("remap",option+1) == 0)
2681 {
2682 Image
2683 *remap_image;
2684
2685 /*
2686 Transform image colors to match this set of colors.
2687 */
cristy6b3da3a2010-06-20 02:21:46 +00002688 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002689 if (*option == '+')
2690 break;
cristy6b3da3a2010-06-20 02:21:46 +00002691 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
cristy3ed852e2009-09-05 21:47:34 +00002692 if (remap_image == (Image *) NULL)
2693 break;
2694 (void) RemapImage(quantize_info,*image,remap_image);
2695 InheritException(exception,&(*image)->exception);
2696 remap_image=DestroyImage(remap_image);
2697 break;
2698 }
2699 if (LocaleCompare("repage",option+1) == 0)
2700 {
2701 if (*option == '+')
2702 {
2703 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2704 break;
2705 }
2706 (void) ResetImagePage(*image,argv[i+1]);
2707 InheritException(exception,&(*image)->exception);
2708 break;
2709 }
2710 if (LocaleCompare("resample",option+1) == 0)
2711 {
2712 Image
2713 *resample_image;
2714
2715 /*
2716 Resample image.
2717 */
cristy6b3da3a2010-06-20 02:21:46 +00002718 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002719 flags=ParseGeometry(argv[i+1],&geometry_info);
2720 if ((flags & SigmaValue) == 0)
2721 geometry_info.sigma=geometry_info.rho;
2722 resample_image=ResampleImage(*image,geometry_info.rho,
2723 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2724 if (resample_image == (Image *) NULL)
2725 break;
2726 *image=DestroyImage(*image);
2727 *image=resample_image;
2728 break;
2729 }
2730 if (LocaleCompare("resize",option+1) == 0)
2731 {
2732 Image
2733 *resize_image;
2734
2735 /*
2736 Resize image.
2737 */
cristy6b3da3a2010-06-20 02:21:46 +00002738 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002739 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2740 resize_image=ResizeImage(*image,geometry.width,geometry.height,
2741 (*image)->filter,(*image)->blur,exception);
2742 if (resize_image == (Image *) NULL)
2743 break;
2744 *image=DestroyImage(*image);
2745 *image=resize_image;
2746 break;
2747 }
cristy3ed852e2009-09-05 21:47:34 +00002748 if (LocaleCompare("roll",option+1) == 0)
2749 {
2750 Image
2751 *roll_image;
2752
2753 /*
2754 Roll image.
2755 */
cristy6b3da3a2010-06-20 02:21:46 +00002756 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002757 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2758 roll_image=RollImage(*image,geometry.x,geometry.y,exception);
2759 if (roll_image == (Image *) NULL)
2760 break;
2761 *image=DestroyImage(*image);
2762 *image=roll_image;
2763 break;
2764 }
2765 if (LocaleCompare("rotate",option+1) == 0)
2766 {
2767 char
2768 *geometry;
2769
2770 Image
2771 *rotate_image;
2772
2773 /*
2774 Check for conditional image rotation.
2775 */
cristy6b3da3a2010-06-20 02:21:46 +00002776 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002777 if (strchr(argv[i+1],'>') != (char *) NULL)
2778 if ((*image)->columns <= (*image)->rows)
2779 break;
2780 if (strchr(argv[i+1],'<') != (char *) NULL)
2781 if ((*image)->columns >= (*image)->rows)
2782 break;
2783 /*
2784 Rotate image.
2785 */
2786 geometry=ConstantString(argv[i+1]);
2787 (void) SubstituteString(&geometry,">","");
2788 (void) SubstituteString(&geometry,"<","");
2789 (void) ParseGeometry(geometry,&geometry_info);
2790 geometry=DestroyString(geometry);
2791 rotate_image=RotateImage(*image,geometry_info.rho,exception);
2792 if (rotate_image == (Image *) NULL)
2793 break;
2794 *image=DestroyImage(*image);
2795 *image=rotate_image;
2796 break;
2797 }
2798 break;
2799 }
2800 case 's':
2801 {
2802 if (LocaleCompare("sample",option+1) == 0)
2803 {
2804 Image
2805 *sample_image;
2806
2807 /*
2808 Sample image with pixel replication.
2809 */
cristy6b3da3a2010-06-20 02:21:46 +00002810 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002811 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2812 sample_image=SampleImage(*image,geometry.width,geometry.height,
2813 exception);
2814 if (sample_image == (Image *) NULL)
2815 break;
2816 *image=DestroyImage(*image);
2817 *image=sample_image;
2818 break;
2819 }
2820 if (LocaleCompare("scale",option+1) == 0)
2821 {
2822 Image
2823 *scale_image;
2824
2825 /*
2826 Resize image.
2827 */
cristy6b3da3a2010-06-20 02:21:46 +00002828 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002829 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2830 scale_image=ScaleImage(*image,geometry.width,geometry.height,
2831 exception);
2832 if (scale_image == (Image *) NULL)
2833 break;
2834 *image=DestroyImage(*image);
2835 *image=scale_image;
2836 break;
2837 }
2838 if (LocaleCompare("selective-blur",option+1) == 0)
2839 {
2840 Image
2841 *blur_image;
2842
2843 /*
2844 Selectively blur pixels within a contrast threshold.
2845 */
cristy6b3da3a2010-06-20 02:21:46 +00002846 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002847 flags=ParseGeometry(argv[i+1],&geometry_info);
2848 if ((flags & PercentValue) != 0)
2849 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2850 blur_image=SelectiveBlurImageChannel(*image,channel,
2851 geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
2852 if (blur_image == (Image *) NULL)
2853 break;
2854 *image=DestroyImage(*image);
2855 *image=blur_image;
2856 break;
2857 }
2858 if (LocaleCompare("separate",option+1) == 0)
2859 {
2860 Image
2861 *separate_images;
2862
2863 /*
2864 Break channels into separate images.
2865 */
cristy6b3da3a2010-06-20 02:21:46 +00002866 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002867 separate_images=SeparateImages(*image,channel,exception);
2868 if (separate_images == (Image *) NULL)
2869 break;
2870 *image=DestroyImage(*image);
2871 *image=separate_images;
2872 break;
2873 }
2874 if (LocaleCompare("sepia-tone",option+1) == 0)
2875 {
2876 double
2877 threshold;
2878
2879 Image
2880 *sepia_image;
2881
2882 /*
2883 Sepia-tone image.
2884 */
cristy6b3da3a2010-06-20 02:21:46 +00002885 (void) SyncImageSettings(mogrify_info,*image);
cristyf2f27272009-12-17 14:48:46 +00002886 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy3ed852e2009-09-05 21:47:34 +00002887 sepia_image=SepiaToneImage(*image,threshold,exception);
2888 if (sepia_image == (Image *) NULL)
2889 break;
2890 *image=DestroyImage(*image);
2891 *image=sepia_image;
2892 break;
2893 }
2894 if (LocaleCompare("segment",option+1) == 0)
2895 {
2896 /*
2897 Segment image.
2898 */
cristy6b3da3a2010-06-20 02:21:46 +00002899 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002900 flags=ParseGeometry(argv[i+1],&geometry_info);
2901 if ((flags & SigmaValue) == 0)
2902 geometry_info.sigma=1.0;
cristy7e6164a2010-07-22 20:43:57 +00002903 (void) SegmentImage(*image,(*image)->colorspace,
2904 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
cristy3ed852e2009-09-05 21:47:34 +00002905 InheritException(exception,&(*image)->exception);
2906 break;
2907 }
2908 if (LocaleCompare("set",option+1) == 0)
2909 {
cristy6d9a1292010-05-31 14:17:06 +00002910 char
2911 *value;
2912
cristy3ed852e2009-09-05 21:47:34 +00002913 /*
2914 Set image option.
2915 */
cristy6d9a1292010-05-31 14:17:06 +00002916 if (*option == '+')
2917 {
2918 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2919 (void) DeleteImageRegistry(argv[i+1]+9);
2920 else
2921 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
cristy7e109582010-06-01 12:56:44 +00002922 {
cristy6b3da3a2010-06-20 02:21:46 +00002923 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
cristy7e109582010-06-01 12:56:44 +00002924 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2925 }
cristy6d9a1292010-05-31 14:17:06 +00002926 else
2927 (void) DeleteImageProperty(*image,argv[i+1]);
2928 break;
2929 }
cristy6b3da3a2010-06-20 02:21:46 +00002930 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
cristy6d9a1292010-05-31 14:17:06 +00002931 if (value == (char *) NULL)
2932 break;
cristy3ed852e2009-09-05 21:47:34 +00002933 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
cristy6d9a1292010-05-31 14:17:06 +00002934 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2935 exception);
cristy3ed852e2009-09-05 21:47:34 +00002936 else
2937 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
cristy6d9a1292010-05-31 14:17:06 +00002938 {
cristy7f02ba12010-09-21 12:39:28 +00002939 (void) SetImageOption(image_info,argv[i+1]+7,value);
cristy6b3da3a2010-06-20 02:21:46 +00002940 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
cristy6d9a1292010-05-31 14:17:06 +00002941 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2942 }
cristy3ed852e2009-09-05 21:47:34 +00002943 else
cristy6d9a1292010-05-31 14:17:06 +00002944 (void) SetImageProperty(*image,argv[i+1],value);
2945 value=DestroyString(value);
cristy3ed852e2009-09-05 21:47:34 +00002946 break;
2947 }
2948 if (LocaleCompare("shade",option+1) == 0)
2949 {
2950 Image
2951 *shade_image;
2952
2953 /*
2954 Shade image.
2955 */
cristy6b3da3a2010-06-20 02:21:46 +00002956 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002957 flags=ParseGeometry(argv[i+1],&geometry_info);
2958 if ((flags & SigmaValue) == 0)
2959 geometry_info.sigma=1.0;
2960 shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2961 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2962 if (shade_image == (Image *) NULL)
2963 break;
2964 *image=DestroyImage(*image);
2965 *image=shade_image;
2966 break;
2967 }
2968 if (LocaleCompare("shadow",option+1) == 0)
2969 {
2970 Image
2971 *shadow_image;
2972
2973 /*
2974 Shadow image.
2975 */
cristy6b3da3a2010-06-20 02:21:46 +00002976 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00002977 flags=ParseGeometry(argv[i+1],&geometry_info);
2978 if ((flags & SigmaValue) == 0)
2979 geometry_info.sigma=1.0;
2980 if ((flags & XiValue) == 0)
2981 geometry_info.xi=4.0;
2982 if ((flags & PsiValue) == 0)
2983 geometry_info.psi=4.0;
2984 shadow_image=ShadowImage(*image,geometry_info.rho,
cristybb503372010-05-27 20:51:26 +00002985 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
cristy0534a6b2010-03-18 01:19:38 +00002986 ceil(geometry_info.psi-0.5),exception);
cristy3ed852e2009-09-05 21:47:34 +00002987 if (shadow_image == (Image *) NULL)
2988 break;
2989 *image=DestroyImage(*image);
2990 *image=shadow_image;
2991 break;
2992 }
2993 if (LocaleCompare("sharpen",option+1) == 0)
2994 {
2995 Image
2996 *sharp_image;
2997
2998 /*
2999 Sharpen image.
3000 */
cristy6b3da3a2010-06-20 02:21:46 +00003001 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003002 flags=ParseGeometry(argv[i+1],&geometry_info);
3003 if ((flags & SigmaValue) == 0)
3004 geometry_info.sigma=1.0;
3005 sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
3006 geometry_info.sigma,exception);
3007 if (sharp_image == (Image *) NULL)
3008 break;
3009 *image=DestroyImage(*image);
3010 *image=sharp_image;
3011 break;
3012 }
3013 if (LocaleCompare("shave",option+1) == 0)
3014 {
3015 Image
3016 *shave_image;
3017
3018 /*
3019 Shave the image edges.
3020 */
cristy6b3da3a2010-06-20 02:21:46 +00003021 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003022 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
3023 shave_image=ShaveImage(*image,&geometry,exception);
3024 if (shave_image == (Image *) NULL)
3025 break;
3026 *image=DestroyImage(*image);
3027 *image=shave_image;
3028 break;
3029 }
3030 if (LocaleCompare("shear",option+1) == 0)
3031 {
3032 Image
3033 *shear_image;
3034
3035 /*
3036 Shear image.
3037 */
cristy6b3da3a2010-06-20 02:21:46 +00003038 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003039 flags=ParseGeometry(argv[i+1],&geometry_info);
3040 if ((flags & SigmaValue) == 0)
3041 geometry_info.sigma=geometry_info.rho;
3042 shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
3043 exception);
3044 if (shear_image == (Image *) NULL)
3045 break;
3046 *image=DestroyImage(*image);
3047 *image=shear_image;
3048 break;
3049 }
3050 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
3051 {
3052 /*
3053 Sigmoidal non-linearity contrast control.
3054 */
cristy6b3da3a2010-06-20 02:21:46 +00003055 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003056 flags=ParseGeometry(argv[i+1],&geometry_info);
3057 if ((flags & SigmaValue) == 0)
3058 geometry_info.sigma=(double) QuantumRange/2.0;
3059 if ((flags & PercentValue) != 0)
3060 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3061 100.0;
3062 (void) SigmoidalContrastImageChannel(*image,channel,
3063 (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
3064 geometry_info.sigma);
3065 InheritException(exception,&(*image)->exception);
3066 break;
3067 }
3068 if (LocaleCompare("sketch",option+1) == 0)
3069 {
3070 Image
3071 *sketch_image;
3072
3073 /*
3074 Sketch image.
3075 */
cristy6b3da3a2010-06-20 02:21:46 +00003076 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003077 flags=ParseGeometry(argv[i+1],&geometry_info);
3078 if ((flags & SigmaValue) == 0)
3079 geometry_info.sigma=1.0;
3080 sketch_image=SketchImage(*image,geometry_info.rho,
3081 geometry_info.sigma,geometry_info.xi,exception);
3082 if (sketch_image == (Image *) NULL)
3083 break;
3084 *image=DestroyImage(*image);
3085 *image=sketch_image;
3086 break;
3087 }
3088 if (LocaleCompare("solarize",option+1) == 0)
3089 {
3090 double
3091 threshold;
3092
cristy6b3da3a2010-06-20 02:21:46 +00003093 (void) SyncImageSettings(mogrify_info,*image);
cristyf2f27272009-12-17 14:48:46 +00003094 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy3ed852e2009-09-05 21:47:34 +00003095 (void) SolarizeImage(*image,threshold);
3096 InheritException(exception,&(*image)->exception);
3097 break;
3098 }
3099 if (LocaleCompare("sparse-color",option+1) == 0)
3100 {
3101 Image
3102 *sparse_image;
3103
3104 SparseColorMethod
3105 method;
3106
3107 char
3108 *arguments;
3109
3110 /*
3111 Sparse Color Interpolated Gradient
3112 */
cristy6b3da3a2010-06-20 02:21:46 +00003113 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003114 method=(SparseColorMethod) ParseMagickOption(
3115 MagickSparseColorOptions,MagickFalse,argv[i+1]);
cristy6b3da3a2010-06-20 02:21:46 +00003116 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
cristy3ed852e2009-09-05 21:47:34 +00003117 InheritException(exception,&(*image)->exception);
3118 if (arguments == (char *) NULL)
3119 break;
3120 sparse_image=SparseColorOption(*image,channel,method,arguments,
3121 option[0] == '+' ? MagickTrue : MagickFalse,exception);
3122 arguments=DestroyString(arguments);
3123 if (sparse_image == (Image *) NULL)
3124 break;
3125 *image=DestroyImage(*image);
3126 *image=sparse_image;
3127 break;
3128 }
3129 if (LocaleCompare("splice",option+1) == 0)
3130 {
3131 Image
3132 *splice_image;
3133
3134 /*
3135 Splice a solid color into the image.
3136 */
cristy6b3da3a2010-06-20 02:21:46 +00003137 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003138 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
3139 splice_image=SpliceImage(*image,&geometry,exception);
3140 if (splice_image == (Image *) NULL)
3141 break;
3142 *image=DestroyImage(*image);
3143 *image=splice_image;
3144 break;
3145 }
3146 if (LocaleCompare("spread",option+1) == 0)
3147 {
3148 Image
3149 *spread_image;
3150
3151 /*
3152 Spread an image.
3153 */
cristy6b3da3a2010-06-20 02:21:46 +00003154 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003155 (void) ParseGeometry(argv[i+1],&geometry_info);
3156 spread_image=SpreadImage(*image,geometry_info.rho,exception);
3157 if (spread_image == (Image *) NULL)
3158 break;
3159 *image=DestroyImage(*image);
3160 *image=spread_image;
3161 break;
3162 }
cristy0834d642011-03-18 18:26:08 +00003163 if (LocaleCompare("statistic",option+1) == 0)
3164 {
3165 Image
3166 *statistic_image;
3167
3168 StatisticType
3169 type;
3170
3171 (void) SyncImageSettings(mogrify_info,*image);
3172 type=(StatisticType) ParseMagickOption(MagickStatisticOptions,
3173 MagickFalse,argv[i+1]);
3174 (void) ParseGeometry(argv[i+2],&geometry_info);
3175 statistic_image=StatisticImageChannel(*image,channel,type,
cristy95c38342011-03-18 22:39:51 +00003176 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3177 exception);
cristy0834d642011-03-18 18:26:08 +00003178 if (statistic_image == (Image *) NULL)
3179 break;
3180 *image=DestroyImage(*image);
3181 *image=statistic_image;
3182 break;
3183 }
cristy3ed852e2009-09-05 21:47:34 +00003184 if (LocaleCompare("stretch",option+1) == 0)
3185 {
3186 if (*option == '+')
3187 {
3188 draw_info->stretch=UndefinedStretch;
3189 break;
3190 }
3191 draw_info->stretch=(StretchType) ParseMagickOption(
3192 MagickStretchOptions,MagickFalse,argv[i+1]);
3193 break;
3194 }
3195 if (LocaleCompare("strip",option+1) == 0)
3196 {
3197 /*
3198 Strip image of profiles and comments.
3199 */
cristy6b3da3a2010-06-20 02:21:46 +00003200 (void) SyncImageSettings(mogrify_info,*image);
glennrp3dae5ae2010-12-23 22:42:52 +00003201 (void) StripImage(*image);
cristy3ed852e2009-09-05 21:47:34 +00003202 InheritException(exception,&(*image)->exception);
3203 break;
3204 }
3205 if (LocaleCompare("stroke",option+1) == 0)
3206 {
3207 ExceptionInfo
3208 *sans;
3209
3210 if (*option == '+')
3211 {
3212 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
3213 if (draw_info->stroke_pattern != (Image *) NULL)
3214 draw_info->stroke_pattern=DestroyImage(
3215 draw_info->stroke_pattern);
3216 break;
3217 }
3218 sans=AcquireExceptionInfo();
3219 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
3220 sans=DestroyExceptionInfo(sans);
3221 if (status == MagickFalse)
cristy6b3da3a2010-06-20 02:21:46 +00003222 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
cristy3ed852e2009-09-05 21:47:34 +00003223 exception);
3224 break;
3225 }
3226 if (LocaleCompare("strokewidth",option+1) == 0)
3227 {
cristyf2f27272009-12-17 14:48:46 +00003228 draw_info->stroke_width=StringToDouble(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00003229 break;
3230 }
3231 if (LocaleCompare("style",option+1) == 0)
3232 {
3233 if (*option == '+')
3234 {
3235 draw_info->style=UndefinedStyle;
3236 break;
3237 }
3238 draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
3239 MagickFalse,argv[i+1]);
3240 break;
3241 }
3242 if (LocaleCompare("swirl",option+1) == 0)
3243 {
3244 Image
3245 *swirl_image;
3246
3247 /*
3248 Swirl image.
3249 */
cristy6b3da3a2010-06-20 02:21:46 +00003250 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003251 (void) ParseGeometry(argv[i+1],&geometry_info);
3252 swirl_image=SwirlImage(*image,geometry_info.rho,exception);
3253 if (swirl_image == (Image *) NULL)
3254 break;
3255 *image=DestroyImage(*image);
3256 *image=swirl_image;
3257 break;
3258 }
3259 break;
3260 }
3261 case 't':
3262 {
3263 if (LocaleCompare("threshold",option+1) == 0)
3264 {
3265 double
3266 threshold;
3267
3268 /*
3269 Threshold image.
3270 */
cristy6b3da3a2010-06-20 02:21:46 +00003271 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003272 if (*option == '+')
3273 threshold=(double) QuantumRange/2.5;
3274 else
cristyf2f27272009-12-17 14:48:46 +00003275 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
cristy3ed852e2009-09-05 21:47:34 +00003276 (void) BilevelImageChannel(*image,channel,threshold);
3277 InheritException(exception,&(*image)->exception);
3278 break;
3279 }
3280 if (LocaleCompare("thumbnail",option+1) == 0)
3281 {
3282 Image
3283 *thumbnail_image;
3284
3285 /*
3286 Thumbnail image.
3287 */
cristy6b3da3a2010-06-20 02:21:46 +00003288 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003289 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3290 thumbnail_image=ThumbnailImage(*image,geometry.width,
3291 geometry.height,exception);
3292 if (thumbnail_image == (Image *) NULL)
3293 break;
3294 *image=DestroyImage(*image);
3295 *image=thumbnail_image;
3296 break;
3297 }
3298 if (LocaleCompare("tile",option+1) == 0)
3299 {
3300 if (*option == '+')
3301 {
3302 if (draw_info->fill_pattern != (Image *) NULL)
3303 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3304 break;
3305 }
cristy6b3da3a2010-06-20 02:21:46 +00003306 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
cristy3ed852e2009-09-05 21:47:34 +00003307 exception);
3308 break;
3309 }
3310 if (LocaleCompare("tint",option+1) == 0)
3311 {
3312 Image
3313 *tint_image;
3314
3315 /*
3316 Tint the image.
3317 */
cristy6b3da3a2010-06-20 02:21:46 +00003318 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003319 tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
3320 if (tint_image == (Image *) NULL)
3321 break;
3322 *image=DestroyImage(*image);
3323 *image=tint_image;
3324 break;
3325 }
3326 if (LocaleCompare("transform",option+1) == 0)
3327 {
3328 Image
3329 *transform_image;
3330
3331 /*
3332 Affine transform image.
3333 */
cristy6b3da3a2010-06-20 02:21:46 +00003334 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003335 transform_image=AffineTransformImage(*image,&draw_info->affine,
3336 exception);
3337 if (transform_image == (Image *) NULL)
3338 break;
3339 *image=DestroyImage(*image);
3340 *image=transform_image;
3341 break;
3342 }
3343 if (LocaleCompare("transparent",option+1) == 0)
3344 {
3345 MagickPixelPacket
3346 target;
3347
cristy6b3da3a2010-06-20 02:21:46 +00003348 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003349 (void) QueryMagickColor(argv[i+1],&target,exception);
3350 (void) TransparentPaintImage(*image,&target,(Quantum)
3351 TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
3352 InheritException(exception,&(*image)->exception);
3353 break;
3354 }
3355 if (LocaleCompare("transpose",option+1) == 0)
3356 {
3357 Image
3358 *transpose_image;
3359
3360 /*
3361 Transpose image scanlines.
3362 */
cristy6b3da3a2010-06-20 02:21:46 +00003363 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003364 transpose_image=TransposeImage(*image,exception);
3365 if (transpose_image == (Image *) NULL)
3366 break;
3367 *image=DestroyImage(*image);
3368 *image=transpose_image;
3369 break;
3370 }
3371 if (LocaleCompare("transverse",option+1) == 0)
3372 {
3373 Image
3374 *transverse_image;
3375
3376 /*
3377 Transverse image scanlines.
3378 */
cristy6b3da3a2010-06-20 02:21:46 +00003379 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003380 transverse_image=TransverseImage(*image,exception);
3381 if (transverse_image == (Image *) NULL)
3382 break;
3383 *image=DestroyImage(*image);
3384 *image=transverse_image;
3385 break;
3386 }
3387 if (LocaleCompare("treedepth",option+1) == 0)
3388 {
cristye27293e2009-12-18 02:53:20 +00003389 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00003390 break;
3391 }
3392 if (LocaleCompare("trim",option+1) == 0)
3393 {
3394 Image
3395 *trim_image;
3396
3397 /*
3398 Trim image.
3399 */
cristy6b3da3a2010-06-20 02:21:46 +00003400 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003401 trim_image=TrimImage(*image,exception);
3402 if (trim_image == (Image *) NULL)
3403 break;
3404 *image=DestroyImage(*image);
3405 *image=trim_image;
3406 break;
3407 }
3408 if (LocaleCompare("type",option+1) == 0)
3409 {
3410 ImageType
3411 type;
3412
cristy6b3da3a2010-06-20 02:21:46 +00003413 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003414 if (*option == '+')
cristy5f1c1ff2010-12-23 21:38:06 +00003415 type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00003416 else
3417 type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
3418 argv[i+1]);
cristy5f1c1ff2010-12-23 21:38:06 +00003419 (*image)->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00003420 (void) SetImageType(*image,type);
3421 InheritException(exception,&(*image)->exception);
3422 break;
3423 }
3424 break;
3425 }
3426 case 'u':
3427 {
3428 if (LocaleCompare("undercolor",option+1) == 0)
3429 {
3430 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3431 exception);
3432 break;
3433 }
cristy045bd902010-01-30 18:56:24 +00003434 if (LocaleCompare("unique",option+1) == 0)
3435 {
3436 if (*option == '+')
3437 {
cristy83fae872010-04-22 15:04:16 +00003438 (void) DeleteImageArtifact(*image,"identify:unique-colors");
cristy045bd902010-01-30 18:56:24 +00003439 break;
3440 }
cristy83fae872010-04-22 15:04:16 +00003441 (void) SetImageArtifact(*image,"identify:unique-colors","true");
cristya01cbea2010-11-03 16:33:33 +00003442 (void) SetImageArtifact(*image,"verbose","true");
cristy045bd902010-01-30 18:56:24 +00003443 break;
3444 }
cristy3ed852e2009-09-05 21:47:34 +00003445 if (LocaleCompare("unique-colors",option+1) == 0)
3446 {
3447 Image
3448 *unique_image;
3449
3450 /*
3451 Unique image colors.
3452 */
cristy6b3da3a2010-06-20 02:21:46 +00003453 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003454 unique_image=UniqueImageColors(*image,exception);
3455 if (unique_image == (Image *) NULL)
3456 break;
3457 *image=DestroyImage(*image);
3458 *image=unique_image;
3459 break;
3460 }
3461 if (LocaleCompare("unsharp",option+1) == 0)
3462 {
3463 Image
3464 *unsharp_image;
3465
3466 /*
3467 Unsharp mask image.
3468 */
cristy6b3da3a2010-06-20 02:21:46 +00003469 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003470 flags=ParseGeometry(argv[i+1],&geometry_info);
3471 if ((flags & SigmaValue) == 0)
3472 geometry_info.sigma=1.0;
3473 if ((flags & XiValue) == 0)
3474 geometry_info.xi=1.0;
3475 if ((flags & PsiValue) == 0)
3476 geometry_info.psi=0.05;
3477 unsharp_image=UnsharpMaskImageChannel(*image,channel,
3478 geometry_info.rho,geometry_info.sigma,geometry_info.xi,
3479 geometry_info.psi,exception);
3480 if (unsharp_image == (Image *) NULL)
3481 break;
3482 *image=DestroyImage(*image);
3483 *image=unsharp_image;
3484 break;
3485 }
3486 break;
3487 }
3488 case 'v':
3489 {
3490 if (LocaleCompare("verbose",option+1) == 0)
3491 {
3492 (void) SetImageArtifact(*image,option+1,
3493 *option == '+' ? "false" : "true");
3494 break;
3495 }
3496 if (LocaleCompare("vignette",option+1) == 0)
3497 {
3498 Image
3499 *vignette_image;
3500
3501 /*
3502 Vignette image.
3503 */
cristy6b3da3a2010-06-20 02:21:46 +00003504 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003505 flags=ParseGeometry(argv[i+1],&geometry_info);
3506 if ((flags & SigmaValue) == 0)
3507 geometry_info.sigma=1.0;
3508 if ((flags & XiValue) == 0)
3509 geometry_info.xi=0.1*(*image)->columns;
3510 if ((flags & PsiValue) == 0)
3511 geometry_info.psi=0.1*(*image)->rows;
3512 vignette_image=VignetteImage(*image,geometry_info.rho,
cristybb503372010-05-27 20:51:26 +00003513 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
cristy0534a6b2010-03-18 01:19:38 +00003514 ceil(geometry_info.psi-0.5),exception);
cristy3ed852e2009-09-05 21:47:34 +00003515 if (vignette_image == (Image *) NULL)
3516 break;
3517 *image=DestroyImage(*image);
3518 *image=vignette_image;
3519 break;
3520 }
3521 if (LocaleCompare("virtual-pixel",option+1) == 0)
3522 {
3523 if (*option == '+')
3524 {
3525 (void) SetImageVirtualPixelMethod(*image,
3526 UndefinedVirtualPixelMethod);
3527 break;
3528 }
3529 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3530 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
3531 argv[i+1]));
3532 break;
3533 }
3534 break;
3535 }
3536 case 'w':
3537 {
3538 if (LocaleCompare("wave",option+1) == 0)
3539 {
3540 Image
3541 *wave_image;
3542
3543 /*
3544 Wave image.
3545 */
cristy6b3da3a2010-06-20 02:21:46 +00003546 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003547 flags=ParseGeometry(argv[i+1],&geometry_info);
3548 if ((flags & SigmaValue) == 0)
3549 geometry_info.sigma=1.0;
3550 wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
3551 exception);
3552 if (wave_image == (Image *) NULL)
3553 break;
3554 *image=DestroyImage(*image);
3555 *image=wave_image;
3556 break;
3557 }
3558 if (LocaleCompare("weight",option+1) == 0)
3559 {
cristye27293e2009-12-18 02:53:20 +00003560 draw_info->weight=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00003561 if (LocaleCompare(argv[i+1],"all") == 0)
3562 draw_info->weight=0;
3563 if (LocaleCompare(argv[i+1],"bold") == 0)
3564 draw_info->weight=700;
3565 if (LocaleCompare(argv[i+1],"bolder") == 0)
3566 if (draw_info->weight <= 800)
3567 draw_info->weight+=100;
3568 if (LocaleCompare(argv[i+1],"lighter") == 0)
3569 if (draw_info->weight >= 100)
3570 draw_info->weight-=100;
3571 if (LocaleCompare(argv[i+1],"normal") == 0)
3572 draw_info->weight=400;
3573 break;
3574 }
3575 if (LocaleCompare("white-threshold",option+1) == 0)
3576 {
3577 /*
3578 White threshold image.
3579 */
cristy6b3da3a2010-06-20 02:21:46 +00003580 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003581 (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
3582 exception);
3583 InheritException(exception,&(*image)->exception);
3584 break;
3585 }
3586 break;
3587 }
3588 default:
3589 break;
3590 }
3591 i+=count;
3592 }
3593 if (region_image != (Image *) NULL)
3594 {
3595 /*
3596 Composite transformed region onto image.
3597 */
cristy6b3da3a2010-06-20 02:21:46 +00003598 (void) SyncImageSettings(mogrify_info,*image);
cristy3ed852e2009-09-05 21:47:34 +00003599 (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
3600 OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
3601 region_geometry.y);
3602 InheritException(exception,&region_image->exception);
3603 *image=DestroyImage(*image);
3604 *image=region_image;
3605 }
3606 /*
3607 Free resources.
3608 */
3609 quantize_info=DestroyQuantizeInfo(quantize_info);
3610 draw_info=DestroyDrawInfo(draw_info);
cristy6b3da3a2010-06-20 02:21:46 +00003611 mogrify_info=DestroyImageInfo(mogrify_info);
3612 status=(*image)->exception.severity == UndefinedException ? MagickTrue :
3613 MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00003614 return(status);
3615}
3616
3617/*
3618%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3619% %
3620% %
3621% %
cristy5063d812010-10-19 16:28:10 +00003622+ 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 +00003623% %
3624% %
3625% %
3626%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3627%
3628% MogrifyImageCommand() transforms an image or a sequence of images. These
3629% transforms include image scaling, image rotation, color reduction, and
3630% others. The transmogrified image overwrites the original image.
3631%
3632% The format of the MogrifyImageCommand method is:
3633%
3634% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3635% const char **argv,char **metadata,ExceptionInfo *exception)
3636%
3637% A description of each parameter follows:
3638%
3639% o image_info: the image info.
3640%
3641% o argc: the number of elements in the argument vector.
3642%
3643% o argv: A text array containing the command line arguments.
3644%
3645% o metadata: any metadata is returned here.
3646%
3647% o exception: return any errors or warnings in this structure.
3648%
3649*/
3650
3651static MagickBooleanType MogrifyUsage(void)
3652{
3653 static const char
3654 *miscellaneous[]=
3655 {
3656 "-debug events display copious debugging information",
3657 "-help print program options",
3658 "-list type print a list of supported option arguments",
3659 "-log format format of debugging information",
3660 "-version print version information",
3661 (char *) NULL
3662 },
3663 *operators[]=
3664 {
3665 "-adaptive-blur geometry",
3666 " adaptively blur pixels; decrease effect near edges",
3667 "-adaptive-resize geometry",
3668 " adaptively resize image using 'mesh' interpolation",
3669 "-adaptive-sharpen geometry",
3670 " adaptively sharpen pixels; increase effect near edges",
3671 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3672 " transparent, extract, background, or shape",
3673 "-annotate geometry text",
3674 " annotate the image with text",
3675 "-auto-gamma automagically adjust gamma level of image",
3676 "-auto-level automagically adjust color levels of image",
3677 "-auto-orient automagically orient (rotate) image",
3678 "-bench iterations measure performance",
3679 "-black-threshold value",
3680 " force all pixels below the threshold into black",
3681 "-blue-shift simulate a scene at nighttime in the moonlight",
3682 "-blur geometry reduce image noise and reduce detail levels",
3683 "-border geometry surround image with a border of color",
3684 "-bordercolor color border color",
cristya28d6b82010-01-11 20:03:47 +00003685 "-brightness-contrast geometry",
3686 " improve brightness / contrast of the image",
cristy3ed852e2009-09-05 21:47:34 +00003687 "-cdl filename color correct with a color decision list",
3688 "-charcoal radius simulate a charcoal drawing",
3689 "-chop geometry remove pixels from the image interior",
cristyecb0c6d2009-09-25 16:50:09 +00003690 "-clamp restrict pixel range from 0 to the quantum depth",
cristycee97112010-05-28 00:44:52 +00003691 "-clip clip along the first path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003692 "-clip-mask filename associate a clip mask with the image",
cristycee97112010-05-28 00:44:52 +00003693 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +00003694 "-colorize value colorize the image with the fill color",
cristye6365592010-04-02 17:31:23 +00003695 "-color-matrix matrix apply color correction to the image",
cristy3ed852e2009-09-05 21:47:34 +00003696 "-contrast enhance or reduce the image contrast",
3697 "-contrast-stretch geometry",
3698 " improve contrast by `stretching' the intensity range",
3699 "-convolve coefficients",
3700 " apply a convolution kernel to the image",
3701 "-cycle amount cycle the image colormap",
3702 "-decipher filename convert cipher pixels to plain pixels",
3703 "-deskew threshold straighten an image",
3704 "-despeckle reduce the speckles within an image",
3705 "-distort method args",
3706 " distort images according to given method ad args",
3707 "-draw string annotate the image with a graphic primitive",
3708 "-edge radius apply a filter to detect edges in the image",
3709 "-encipher filename convert plain pixels to cipher pixels",
3710 "-emboss radius emboss an image",
3711 "-enhance apply a digital filter to enhance a noisy image",
3712 "-equalize perform histogram equalization to an image",
3713 "-evaluate operator value",
cristyd18ae7c2010-03-07 17:39:52 +00003714 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003715 "-extent geometry set the image size",
3716 "-extract geometry extract area from image",
3717 "-fft implements the discrete Fourier transform (DFT)",
3718 "-flip flip image vertically",
3719 "-floodfill geometry color",
3720 " floodfill the image with color",
3721 "-flop flop image horizontally",
3722 "-frame geometry surround image with an ornamental border",
cristyc2b730e2009-11-24 14:32:09 +00003723 "-function name parameters",
cristy3ed852e2009-09-05 21:47:34 +00003724 " apply function over image values",
3725 "-gamma value level of gamma correction",
3726 "-gaussian-blur geometry",
3727 " reduce image noise and reduce detail levels",
cristy901f09d2009-10-16 22:56:10 +00003728 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +00003729 "-identify identify the format and characteristics of the image",
3730 "-ift implements the inverse discrete Fourier transform (DFT)",
3731 "-implode amount implode image pixels about the center",
3732 "-lat geometry local adaptive thresholding",
3733 "-layers method optimize, merge, or compare image layers",
3734 "-level value adjust the level of image contrast",
3735 "-level-colors color,color",
cristyee0f8d72009-09-19 00:58:29 +00003736 " level image with the given colors",
cristy3ed852e2009-09-05 21:47:34 +00003737 "-linear-stretch geometry",
3738 " improve contrast by `stretching with saturation'",
3739 "-liquid-rescale geometry",
3740 " rescale image with seam-carving",
3741 "-median radius apply a median filter to the image",
cristy2ecd9be2011-02-28 01:17:26 +00003742 "-mode radius make each pixel the 'predominate color' of the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003743 "-modulate value vary the brightness, saturation, and hue",
3744 "-monochrome transform image to black and white",
cristy7c1b9fd2010-02-02 14:36:00 +00003745 "-morphology method kernel",
anthony29188a82010-01-22 10:12:34 +00003746 " apply a morphology method to the image",
cristy3ed852e2009-09-05 21:47:34 +00003747 "-motion-blur geometry",
3748 " simulate motion blur",
3749 "-negate replace every pixel with its complementary color ",
3750 "-noise radius add or reduce noise in an image",
3751 "-normalize transform image to span the full range of colors",
3752 "-opaque color change this color to the fill color",
3753 "-ordered-dither NxN",
3754 " add a noise pattern to the image with specific",
3755 " amplitudes",
3756 "-paint radius simulate an oil painting",
3757 "-polaroid angle simulate a Polaroid picture",
3758 "-posterize levels reduce the image to a limited number of color levels",
cristy3ed852e2009-09-05 21:47:34 +00003759 "-profile filename add, delete, or apply an image profile",
3760 "-quantize colorspace reduce colors in this colorspace",
3761 "-radial-blur angle radial blur the image",
3762 "-raise value lighten/darken image edges to create a 3-D effect",
3763 "-random-threshold low,high",
3764 " random threshold the image",
cristy3ed852e2009-09-05 21:47:34 +00003765 "-region geometry apply options to a portion of the image",
3766 "-render render vector graphics",
3767 "-repage geometry size and location of an image canvas",
3768 "-resample geometry change the resolution of an image",
3769 "-resize geometry resize the image",
3770 "-roll geometry roll an image vertically or horizontally",
3771 "-rotate degrees apply Paeth rotation to the image",
3772 "-sample geometry scale image with pixel sampling",
3773 "-scale geometry scale the image",
3774 "-segment values segment an image",
3775 "-selective-blur geometry",
3776 " selectively blur pixels within a contrast threshold",
3777 "-sepia-tone threshold",
3778 " simulate a sepia-toned photo",
3779 "-set property value set an image property",
3780 "-shade degrees shade the image using a distant light source",
3781 "-shadow geometry simulate an image shadow",
3782 "-sharpen geometry sharpen the image",
3783 "-shave geometry shave pixels from the image edges",
cristycee97112010-05-28 00:44:52 +00003784 "-shear geometry slide one edge of the image along the X or Y axis",
cristy3ed852e2009-09-05 21:47:34 +00003785 "-sigmoidal-contrast geometry",
3786 " increase the contrast without saturating highlights or shadows",
3787 "-sketch geometry simulate a pencil sketch",
3788 "-solarize threshold negate all pixels above the threshold level",
3789 "-sparse-color method args",
3790 " fill in a image based on a few color points",
3791 "-splice geometry splice the background color into the image",
3792 "-spread radius displace image pixels by a random amount",
cristy0834d642011-03-18 18:26:08 +00003793 "-statistic type radius",
3794 " replace each pixel with corresponding statistic from the neighborhood",
cristy3ed852e2009-09-05 21:47:34 +00003795 "-strip strip image of all profiles and comments",
3796 "-swirl degrees swirl image pixels about the center",
3797 "-threshold value threshold the image",
3798 "-thumbnail geometry create a thumbnail of the image",
3799 "-tile filename tile image when filling a graphic primitive",
3800 "-tint value tint the image with the fill color",
3801 "-transform affine transform image",
3802 "-transparent color make this color transparent within the image",
3803 "-transpose flip image vertically and rotate 90 degrees",
3804 "-transverse flop image horizontally and rotate 270 degrees",
3805 "-trim trim image edges",
3806 "-type type image type",
3807 "-unique-colors discard all but one of any pixel color",
3808 "-unsharp geometry sharpen the image",
3809 "-vignette geometry soften the edges of the image in vignette style",
cristycee97112010-05-28 00:44:52 +00003810 "-wave geometry alter an image along a sine wave",
cristy3ed852e2009-09-05 21:47:34 +00003811 "-white-threshold value",
3812 " force all pixels above the threshold into white",
3813 (char *) NULL
3814 },
3815 *sequence_operators[]=
3816 {
cristy4285d782011-02-09 20:12:28 +00003817 "-append append an image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003818 "-clut apply a color lookup table to the image",
3819 "-coalesce merge a sequence of images",
3820 "-combine combine a sequence of images",
3821 "-composite composite image",
3822 "-crop geometry cut out a rectangular region of the image",
3823 "-deconstruct break down an image sequence into constituent parts",
cristyd18ae7c2010-03-07 17:39:52 +00003824 "-evaluate-sequence operator",
3825 " evaluate an arithmetic, relational, or logical expression",
cristy3ed852e2009-09-05 21:47:34 +00003826 "-flatten flatten a sequence of images",
3827 "-fx expression apply mathematical expression to an image channel(s)",
3828 "-hald-clut apply a Hald color lookup table to the image",
3829 "-morph value morph an image sequence",
3830 "-mosaic create a mosaic from an image sequence",
cristy36b94822010-05-20 12:48:16 +00003831 "-print string interpret string and print to console",
cristy3ed852e2009-09-05 21:47:34 +00003832 "-process arguments process the image with a custom image filter",
cristy3ed852e2009-09-05 21:47:34 +00003833 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003834 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003835 "-write filename write images to this file",
3836 (char *) NULL
3837 },
3838 *settings[]=
3839 {
3840 "-adjoin join images into a single multi-image file",
3841 "-affine matrix affine transform matrix",
3842 "-alpha option activate, deactivate, reset, or set the alpha channel",
3843 "-antialias remove pixel-aliasing",
3844 "-authenticate password",
3845 " decipher image with this password",
3846 "-attenuate value lessen (or intensify) when adding noise to an image",
3847 "-background color background color",
3848 "-bias value add bias when convolving an image",
3849 "-black-point-compensation",
3850 " use black point compensation",
3851 "-blue-primary point chromaticity blue primary point",
3852 "-bordercolor color border color",
3853 "-caption string assign a caption to an image",
3854 "-channel type apply option to select image channels",
3855 "-colors value preferred number of colors in the image",
3856 "-colorspace type alternate image colorspace",
3857 "-comment string annotate image with comment",
3858 "-compose operator set image composite operator",
3859 "-compress type type of pixel compression when writing the image",
3860 "-define format:option",
3861 " define one or more image format options",
3862 "-delay value display the next image after pausing",
3863 "-density geometry horizontal and vertical density of the image",
3864 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003865 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003866 "-display server get image or font from this X server",
3867 "-dispose method layer disposal method",
3868 "-dither method apply error diffusion to image",
3869 "-encoding type text encoding type",
3870 "-endian type endianness (MSB or LSB) of the image",
3871 "-family name render text with this font family",
3872 "-fill color color to use when filling a graphic primitive",
3873 "-filter type use this filter when resizing an image",
3874 "-font name render text with this font",
3875 "-format \"string\" output formatted image characteristics",
3876 "-fuzz distance colors within this distance are considered equal",
3877 "-gravity type horizontal and vertical text placement",
3878 "-green-primary point chromaticity green primary point",
3879 "-intent type type of rendering intent when managing the image color",
3880 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003881 "-interline-spacing value",
3882 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003883 "-interpolate method pixel color interpolation method",
3884 "-interword-spacing value",
3885 " set the space between two words",
3886 "-kerning value set the space between two letters",
3887 "-label string assign a label to an image",
3888 "-limit type value pixel cache resource limit",
3889 "-loop iterations add Netscape loop extension to your GIF animation",
3890 "-mask filename associate a mask with the image",
3891 "-mattecolor color frame color",
3892 "-monitor monitor progress",
3893 "-orient type image orientation",
3894 "-page geometry size and location of an image canvas (setting)",
3895 "-ping efficiently determine image attributes",
3896 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003897 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003898 "-preview type image preview type",
3899 "-quality value JPEG/MIFF/PNG compression level",
3900 "-quiet suppress all warning messages",
3901 "-red-primary point chromaticity red primary point",
3902 "-regard-warnings pay attention to warning messages",
3903 "-remap filename transform image colors to match this set of colors",
3904 "-respect-parentheses settings remain in effect until parenthesis boundary",
3905 "-sampling-factor geometry",
3906 " horizontal and vertical sampling factor",
3907 "-scene value image scene number",
3908 "-seed value seed a new sequence of pseudo-random numbers",
3909 "-size geometry width and height of image",
3910 "-stretch type render text with this font stretch",
3911 "-stroke color graphic primitive stroke color",
3912 "-strokewidth value graphic primitive stroke width",
3913 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003914 "-synchronize synchronize image to storage device",
3915 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003916 "-texture filename name of texture to tile onto the image background",
3917 "-tile-offset geometry",
3918 " tile offset",
3919 "-treedepth value color tree depth",
3920 "-transparent-color color",
3921 " transparent color",
3922 "-undercolor color annotation bounding box color",
3923 "-units type the units of image resolution",
3924 "-verbose print detailed information about the image",
3925 "-view FlashPix viewing transforms",
3926 "-virtual-pixel method",
3927 " virtual pixel access method",
3928 "-weight type render text with this font weight",
3929 "-white-point point chromaticity white point",
3930 (char *) NULL
3931 },
3932 *stack_operators[]=
3933 {
anthonyb69c4b32011-03-23 04:37:44 +00003934 "-delete indexes delete the image from the image sequence",
3935 "-duplicate count,indexes",
cristyecb10ff2011-03-22 13:14:03 +00003936 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003937 "-insert index insert last image into the image sequence",
anthony9bd15492011-03-23 02:11:13 +00003938 "-reverse reverse image sequence",
cristy3ed852e2009-09-05 21:47:34 +00003939 "-swap indexes swap two images in the image sequence",
3940 (char *) NULL
3941 };
3942
3943 const char
3944 **p;
3945
cristybb503372010-05-27 20:51:26 +00003946 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00003947 (void) printf("Copyright: %s\n",GetMagickCopyright());
3948 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00003949 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3950 GetClientName());
3951 (void) printf("\nImage Settings:\n");
3952 for (p=settings; *p != (char *) NULL; p++)
3953 (void) printf(" %s\n",*p);
3954 (void) printf("\nImage Operators:\n");
3955 for (p=operators; *p != (char *) NULL; p++)
3956 (void) printf(" %s\n",*p);
3957 (void) printf("\nImage Sequence Operators:\n");
3958 for (p=sequence_operators; *p != (char *) NULL; p++)
3959 (void) printf(" %s\n",*p);
3960 (void) printf("\nImage Stack Operators:\n");
3961 for (p=stack_operators; *p != (char *) NULL; p++)
3962 (void) printf(" %s\n",*p);
3963 (void) printf("\nMiscellaneous Options:\n");
3964 for (p=miscellaneous; *p != (char *) NULL; p++)
3965 (void) printf(" %s\n",*p);
3966 (void) printf(
3967 "\nBy default, the image format of `file' is determined by its magic\n");
3968 (void) printf(
3969 "number. To specify a particular image format, precede the filename\n");
3970 (void) printf(
3971 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3972 (void) printf(
3973 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3974 (void) printf("'-' for standard input or output.\n");
3975 return(MagickFalse);
3976}
3977
3978WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3979 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3980{
3981#define DestroyMogrify() \
3982{ \
3983 if (format != (char *) NULL) \
3984 format=DestroyString(format); \
3985 if (path != (char *) NULL) \
3986 path=DestroyString(path); \
3987 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +00003988 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +00003989 argv[i]=DestroyString(argv[i]); \
3990 argv=(char **) RelinquishMagickMemory(argv); \
3991}
3992#define ThrowMogrifyException(asperity,tag,option) \
3993{ \
3994 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3995 option); \
3996 DestroyMogrify(); \
3997 return(MagickFalse); \
3998}
3999#define ThrowMogrifyInvalidArgumentException(option,argument) \
4000{ \
4001 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
4002 "InvalidArgument","`%s': %s",argument,option); \
4003 DestroyMogrify(); \
4004 return(MagickFalse); \
4005}
4006
4007 char
4008 *format,
4009 *option,
4010 *path;
4011
4012 Image
4013 *image;
4014
4015 ImageStack
4016 image_stack[MaxImageStackDepth+1];
4017
cristy3ed852e2009-09-05 21:47:34 +00004018 MagickBooleanType
4019 global_colormap;
4020
4021 MagickBooleanType
4022 fire,
cristyebbcfea2011-02-25 02:43:54 +00004023 pend,
4024 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +00004025
4026 MagickStatusType
4027 status;
4028
cristyebbcfea2011-02-25 02:43:54 +00004029 register ssize_t
4030 i;
4031
4032 ssize_t
4033 j,
4034 k;
4035
cristy3ed852e2009-09-05 21:47:34 +00004036 /*
4037 Set defaults.
4038 */
4039 assert(image_info != (ImageInfo *) NULL);
4040 assert(image_info->signature == MagickSignature);
4041 if (image_info->debug != MagickFalse)
4042 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
4043 assert(exception != (ExceptionInfo *) NULL);
4044 if (argc == 2)
4045 {
4046 option=argv[1];
4047 if ((LocaleCompare("version",option+1) == 0) ||
4048 (LocaleCompare("-version",option+1) == 0))
4049 {
4050 (void) fprintf(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00004051 GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00004052 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
4053 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00004054 return(MagickFalse);
4055 }
4056 }
4057 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +00004058 return(MogrifyUsage());
cristy3ed852e2009-09-05 21:47:34 +00004059 format=(char *) NULL;
4060 path=(char *) NULL;
4061 global_colormap=MagickFalse;
4062 k=0;
4063 j=1;
4064 NewImageStack();
4065 option=(char *) NULL;
4066 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +00004067 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00004068 status=MagickTrue;
4069 /*
4070 Parse command line.
4071 */
4072 ReadCommandlLine(argc,&argv);
4073 status=ExpandFilenames(&argc,&argv);
4074 if (status == MagickFalse)
4075 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
4076 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +00004077 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00004078 {
4079 option=argv[i];
4080 if (LocaleCompare(option,"(") == 0)
4081 {
4082 FireImageStack(MagickFalse,MagickTrue,pend);
4083 if (k == MaxImageStackDepth)
4084 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
4085 option);
4086 PushImageStack();
4087 continue;
4088 }
4089 if (LocaleCompare(option,")") == 0)
4090 {
4091 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
4092 if (k == 0)
4093 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
4094 PopImageStack();
4095 continue;
4096 }
4097 if (IsMagickOption(option) == MagickFalse)
4098 {
4099 char
4100 backup_filename[MaxTextExtent],
4101 *filename;
4102
4103 Image
4104 *images;
4105
4106 /*
4107 Option is a file name: begin by reading image from specified file.
4108 */
4109 FireImageStack(MagickFalse,MagickFalse,pend);
4110 filename=argv[i];
cristycee97112010-05-28 00:44:52 +00004111 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +00004112 filename=argv[++i];
4113 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
4114 images=ReadImages(image_info,exception);
4115 status&=(images != (Image *) NULL) &&
4116 (exception->severity < ErrorException);
4117 if (images == (Image *) NULL)
4118 continue;
cristydaa76602010-06-30 13:05:11 +00004119 if (format != (char *) NULL)
4120 (void) CopyMagickString(images->filename,images->magick_filename,
4121 MaxTextExtent);
cristy3ed852e2009-09-05 21:47:34 +00004122 if (path != (char *) NULL)
4123 {
4124 GetPathComponent(option,TailPath,filename);
4125 (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
4126 path,*DirectorySeparator,filename);
4127 }
4128 if (format != (char *) NULL)
cristydaa76602010-06-30 13:05:11 +00004129 AppendImageFormat(format,images->filename);
cristy3ed852e2009-09-05 21:47:34 +00004130 AppendImageStack(images);
4131 FinalizeImageSettings(image_info,image,MagickFalse);
4132 if (global_colormap != MagickFalse)
4133 {
4134 QuantizeInfo
4135 *quantize_info;
4136
4137 quantize_info=AcquireQuantizeInfo(image_info);
4138 (void) RemapImages(quantize_info,images,(Image *) NULL);
4139 quantize_info=DestroyQuantizeInfo(quantize_info);
4140 }
4141 *backup_filename='\0';
4142 if ((LocaleCompare(image->filename,"-") != 0) &&
4143 (IsPathWritable(image->filename) != MagickFalse))
4144 {
cristybb503372010-05-27 20:51:26 +00004145 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004146 i;
4147
4148 /*
4149 Rename image file as backup.
4150 */
4151 (void) CopyMagickString(backup_filename,image->filename,
4152 MaxTextExtent);
4153 for (i=0; i < 6; i++)
4154 {
4155 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
4156 if (IsPathAccessible(backup_filename) == MagickFalse)
4157 break;
4158 }
4159 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
4160 (rename(image->filename,backup_filename) != 0))
4161 *backup_filename='\0';
4162 }
4163 /*
4164 Write transmogrified image to disk.
4165 */
4166 image_info->synchronize=MagickTrue;
4167 status&=WriteImages(image_info,image,image->filename,exception);
4168 if ((status == MagickFalse) && (*backup_filename != '\0'))
4169 (void) remove(backup_filename);
4170 RemoveAllImageStack();
4171 continue;
4172 }
4173 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4174 switch (*(option+1))
4175 {
4176 case 'a':
4177 {
4178 if (LocaleCompare("adaptive-blur",option+1) == 0)
4179 {
4180 i++;
cristybb503372010-05-27 20:51:26 +00004181 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004182 ThrowMogrifyException(OptionError,"MissingArgument",option);
4183 if (IsGeometry(argv[i]) == MagickFalse)
4184 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4185 break;
4186 }
4187 if (LocaleCompare("adaptive-resize",option+1) == 0)
4188 {
4189 i++;
cristybb503372010-05-27 20:51:26 +00004190 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004191 ThrowMogrifyException(OptionError,"MissingArgument",option);
4192 if (IsGeometry(argv[i]) == MagickFalse)
4193 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4194 break;
4195 }
4196 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4197 {
4198 i++;
cristybb503372010-05-27 20:51:26 +00004199 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004200 ThrowMogrifyException(OptionError,"MissingArgument",option);
4201 if (IsGeometry(argv[i]) == MagickFalse)
4202 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4203 break;
4204 }
4205 if (LocaleCompare("affine",option+1) == 0)
4206 {
4207 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);
cristy3ed852e2009-09-05 21:47:34 +00004212 break;
4213 }
4214 if (LocaleCompare("alpha",option+1) == 0)
4215 {
cristybb503372010-05-27 20:51:26 +00004216 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004217 type;
4218
4219 if (*option == '+')
4220 break;
4221 i++;
cristybb503372010-05-27 20:51:26 +00004222 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004223 ThrowMogrifyException(OptionError,"MissingArgument",option);
4224 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
4225 if (type < 0)
4226 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
4227 argv[i]);
4228 break;
4229 }
4230 if (LocaleCompare("annotate",option+1) == 0)
4231 {
4232 if (*option == '+')
4233 break;
4234 i++;
cristybb503372010-05-27 20:51:26 +00004235 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004236 ThrowMogrifyException(OptionError,"MissingArgument",option);
4237 if (IsGeometry(argv[i]) == MagickFalse)
4238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristybb503372010-05-27 20:51:26 +00004239 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004240 ThrowMogrifyException(OptionError,"MissingArgument",option);
4241 i++;
4242 break;
4243 }
4244 if (LocaleCompare("antialias",option+1) == 0)
4245 break;
4246 if (LocaleCompare("append",option+1) == 0)
4247 break;
4248 if (LocaleCompare("attenuate",option+1) == 0)
4249 {
4250 if (*option == '+')
4251 break;
4252 i++;
cristybb503372010-05-27 20:51:26 +00004253 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004254 ThrowMogrifyException(OptionError,"MissingArgument",option);
4255 if (IsGeometry(argv[i]) == MagickFalse)
4256 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4257 break;
4258 }
4259 if (LocaleCompare("authenticate",option+1) == 0)
4260 {
4261 if (*option == '+')
4262 break;
4263 i++;
cristybb503372010-05-27 20:51:26 +00004264 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004265 ThrowMogrifyException(OptionError,"MissingArgument",option);
4266 break;
4267 }
4268 if (LocaleCompare("auto-gamma",option+1) == 0)
4269 break;
4270 if (LocaleCompare("auto-level",option+1) == 0)
4271 break;
4272 if (LocaleCompare("auto-orient",option+1) == 0)
4273 break;
4274 if (LocaleCompare("average",option+1) == 0)
4275 break;
4276 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4277 }
4278 case 'b':
4279 {
4280 if (LocaleCompare("background",option+1) == 0)
4281 {
4282 if (*option == '+')
4283 break;
4284 i++;
cristybb503372010-05-27 20:51:26 +00004285 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004286 ThrowMogrifyException(OptionError,"MissingArgument",option);
4287 break;
4288 }
4289 if (LocaleCompare("bias",option+1) == 0)
4290 {
4291 if (*option == '+')
4292 break;
4293 i++;
cristybb503372010-05-27 20:51:26 +00004294 if (i == (ssize_t) (argc-1))
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 }
4300 if (LocaleCompare("black-point-compensation",option+1) == 0)
4301 break;
4302 if (LocaleCompare("black-threshold",option+1) == 0)
4303 {
4304 if (*option == '+')
4305 break;
4306 i++;
cristybb503372010-05-27 20:51:26 +00004307 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004308 ThrowMogrifyException(OptionError,"MissingArgument",option);
4309 if (IsGeometry(argv[i]) == MagickFalse)
4310 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4311 break;
4312 }
4313 if (LocaleCompare("blue-primary",option+1) == 0)
4314 {
4315 if (*option == '+')
4316 break;
4317 i++;
cristybb503372010-05-27 20:51:26 +00004318 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004319 ThrowMogrifyException(OptionError,"MissingArgument",option);
4320 if (IsGeometry(argv[i]) == MagickFalse)
4321 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4322 break;
4323 }
4324 if (LocaleCompare("blue-shift",option+1) == 0)
4325 {
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("blur",option+1) == 0)
4334 {
4335 i++;
cristybb503372010-05-27 20:51:26 +00004336 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004337 ThrowMogrifyException(OptionError,"MissingArgument",option);
4338 if (IsGeometry(argv[i]) == MagickFalse)
4339 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4340 break;
4341 }
4342 if (LocaleCompare("border",option+1) == 0)
4343 {
4344 if (*option == '+')
4345 break;
4346 i++;
cristybb503372010-05-27 20:51:26 +00004347 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004348 ThrowMogrifyException(OptionError,"MissingArgument",option);
4349 if (IsGeometry(argv[i]) == MagickFalse)
4350 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4351 break;
4352 }
4353 if (LocaleCompare("bordercolor",option+1) == 0)
4354 {
4355 if (*option == '+')
4356 break;
4357 i++;
cristybb503372010-05-27 20:51:26 +00004358 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004359 ThrowMogrifyException(OptionError,"MissingArgument",option);
4360 break;
4361 }
4362 if (LocaleCompare("box",option+1) == 0)
4363 {
4364 if (*option == '+')
4365 break;
4366 i++;
cristybb503372010-05-27 20:51:26 +00004367 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004368 ThrowMogrifyException(OptionError,"MissingArgument",option);
4369 break;
4370 }
cristya28d6b82010-01-11 20:03:47 +00004371 if (LocaleCompare("brightness-contrast",option+1) == 0)
4372 {
4373 i++;
cristybb503372010-05-27 20:51:26 +00004374 if (i == (ssize_t) argc)
cristya28d6b82010-01-11 20:03:47 +00004375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4376 if (IsGeometry(argv[i]) == MagickFalse)
4377 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4378 break;
4379 }
cristy3ed852e2009-09-05 21:47:34 +00004380 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4381 }
4382 case 'c':
4383 {
4384 if (LocaleCompare("cache",option+1) == 0)
4385 {
4386 if (*option == '+')
4387 break;
4388 i++;
cristybb503372010-05-27 20:51:26 +00004389 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004390 ThrowMogrifyException(OptionError,"MissingArgument",option);
4391 if (IsGeometry(argv[i]) == MagickFalse)
4392 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4393 break;
4394 }
4395 if (LocaleCompare("caption",option+1) == 0)
4396 {
4397 if (*option == '+')
4398 break;
4399 i++;
cristybb503372010-05-27 20:51:26 +00004400 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004401 ThrowMogrifyException(OptionError,"MissingArgument",option);
4402 break;
4403 }
4404 if (LocaleCompare("channel",option+1) == 0)
4405 {
cristybb503372010-05-27 20:51:26 +00004406 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004407 channel;
4408
4409 if (*option == '+')
4410 break;
4411 i++;
cristybb503372010-05-27 20:51:26 +00004412 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004413 ThrowMogrifyException(OptionError,"MissingArgument",option);
4414 channel=ParseChannelOption(argv[i]);
4415 if (channel < 0)
4416 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4417 argv[i]);
4418 break;
4419 }
4420 if (LocaleCompare("cdl",option+1) == 0)
4421 {
4422 if (*option == '+')
4423 break;
4424 i++;
cristybb503372010-05-27 20:51:26 +00004425 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004426 ThrowMogrifyException(OptionError,"MissingArgument",option);
4427 break;
4428 }
4429 if (LocaleCompare("charcoal",option+1) == 0)
4430 {
4431 if (*option == '+')
4432 break;
4433 i++;
cristybb503372010-05-27 20:51:26 +00004434 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004435 ThrowMogrifyException(OptionError,"MissingArgument",option);
4436 if (IsGeometry(argv[i]) == MagickFalse)
4437 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4438 break;
4439 }
4440 if (LocaleCompare("chop",option+1) == 0)
4441 {
4442 if (*option == '+')
4443 break;
4444 i++;
cristybb503372010-05-27 20:51:26 +00004445 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004446 ThrowMogrifyException(OptionError,"MissingArgument",option);
4447 if (IsGeometry(argv[i]) == MagickFalse)
4448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4449 break;
4450 }
cristy1eb45dd2009-09-25 16:38:06 +00004451 if (LocaleCompare("clamp",option+1) == 0)
4452 break;
4453 if (LocaleCompare("clip",option+1) == 0)
4454 break;
cristy3ed852e2009-09-05 21:47:34 +00004455 if (LocaleCompare("clip-mask",option+1) == 0)
4456 {
4457 if (*option == '+')
4458 break;
4459 i++;
cristybb503372010-05-27 20:51:26 +00004460 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004461 ThrowMogrifyException(OptionError,"MissingArgument",option);
4462 break;
4463 }
4464 if (LocaleCompare("clut",option+1) == 0)
4465 break;
4466 if (LocaleCompare("coalesce",option+1) == 0)
4467 break;
4468 if (LocaleCompare("colorize",option+1) == 0)
4469 {
4470 if (*option == '+')
4471 break;
4472 i++;
cristybb503372010-05-27 20:51:26 +00004473 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004474 ThrowMogrifyException(OptionError,"MissingArgument",option);
4475 if (IsGeometry(argv[i]) == MagickFalse)
4476 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4477 break;
4478 }
cristye6365592010-04-02 17:31:23 +00004479 if (LocaleCompare("color-matrix",option+1) == 0)
4480 {
cristyb6bd4ad2010-08-08 01:12:27 +00004481 KernelInfo
4482 *kernel_info;
4483
cristye6365592010-04-02 17:31:23 +00004484 if (*option == '+')
4485 break;
4486 i++;
cristybb503372010-05-27 20:51:26 +00004487 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00004488 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004489 kernel_info=AcquireKernelInfo(argv[i]);
4490 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004491 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004492 kernel_info=DestroyKernelInfo(kernel_info);
cristye6365592010-04-02 17:31:23 +00004493 break;
4494 }
cristy3ed852e2009-09-05 21:47:34 +00004495 if (LocaleCompare("colors",option+1) == 0)
4496 {
4497 if (*option == '+')
4498 break;
4499 i++;
cristybb503372010-05-27 20:51:26 +00004500 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004501 ThrowMogrifyException(OptionError,"MissingArgument",option);
4502 if (IsGeometry(argv[i]) == MagickFalse)
4503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4504 break;
4505 }
4506 if (LocaleCompare("colorspace",option+1) == 0)
4507 {
cristybb503372010-05-27 20:51:26 +00004508 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004509 colorspace;
4510
4511 if (*option == '+')
4512 break;
4513 i++;
cristybb503372010-05-27 20:51:26 +00004514 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004515 ThrowMogrifyException(OptionError,"MissingArgument",option);
4516 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
4517 argv[i]);
4518 if (colorspace < 0)
4519 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4520 argv[i]);
4521 break;
4522 }
4523 if (LocaleCompare("combine",option+1) == 0)
4524 break;
4525 if (LocaleCompare("comment",option+1) == 0)
4526 {
4527 if (*option == '+')
4528 break;
4529 i++;
cristybb503372010-05-27 20:51:26 +00004530 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004531 ThrowMogrifyException(OptionError,"MissingArgument",option);
4532 break;
4533 }
4534 if (LocaleCompare("composite",option+1) == 0)
4535 break;
4536 if (LocaleCompare("compress",option+1) == 0)
4537 {
cristybb503372010-05-27 20:51:26 +00004538 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004539 compress;
4540
4541 if (*option == '+')
4542 break;
4543 i++;
cristybb503372010-05-27 20:51:26 +00004544 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004545 ThrowMogrifyException(OptionError,"MissingArgument",option);
4546 compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
4547 argv[i]);
4548 if (compress < 0)
4549 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4550 argv[i]);
4551 break;
4552 }
cristy22879752009-10-25 23:55:40 +00004553 if (LocaleCompare("concurrent",option+1) == 0)
4554 break;
cristy3ed852e2009-09-05 21:47:34 +00004555 if (LocaleCompare("contrast",option+1) == 0)
4556 break;
4557 if (LocaleCompare("contrast-stretch",option+1) == 0)
4558 {
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("convolve",option+1) == 0)
4567 {
cristyb6bd4ad2010-08-08 01:12:27 +00004568 KernelInfo
4569 *kernel_info;
4570
cristy3ed852e2009-09-05 21:47:34 +00004571 if (*option == '+')
4572 break;
4573 i++;
cristybb503372010-05-27 20:51:26 +00004574 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004575 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00004576 kernel_info=AcquireKernelInfo(argv[i]);
4577 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00004578 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00004579 kernel_info=DestroyKernelInfo(kernel_info);
cristy3ed852e2009-09-05 21:47:34 +00004580 break;
4581 }
4582 if (LocaleCompare("crop",option+1) == 0)
4583 {
4584 if (*option == '+')
4585 break;
4586 i++;
cristybb503372010-05-27 20:51:26 +00004587 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004588 ThrowMogrifyException(OptionError,"MissingArgument",option);
4589 if (IsGeometry(argv[i]) == MagickFalse)
4590 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4591 break;
4592 }
4593 if (LocaleCompare("cycle",option+1) == 0)
4594 {
4595 if (*option == '+')
4596 break;
4597 i++;
cristybb503372010-05-27 20:51:26 +00004598 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 if (IsGeometry(argv[i]) == MagickFalse)
4601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4602 break;
4603 }
4604 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4605 }
4606 case 'd':
4607 {
4608 if (LocaleCompare("decipher",option+1) == 0)
4609 {
4610 if (*option == '+')
4611 break;
4612 i++;
cristybb503372010-05-27 20:51:26 +00004613 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004614 ThrowMogrifyException(OptionError,"MissingArgument",option);
4615 break;
4616 }
4617 if (LocaleCompare("deconstruct",option+1) == 0)
4618 break;
4619 if (LocaleCompare("debug",option+1) == 0)
4620 {
cristybb503372010-05-27 20:51:26 +00004621 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004622 event;
4623
4624 if (*option == '+')
4625 break;
4626 i++;
cristybb503372010-05-27 20:51:26 +00004627 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004628 ThrowMogrifyException(OptionError,"MissingArgument",option);
4629 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
4630 if (event < 0)
4631 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4632 argv[i]);
4633 (void) SetLogEventMask(argv[i]);
4634 break;
4635 }
4636 if (LocaleCompare("define",option+1) == 0)
4637 {
4638 i++;
cristybb503372010-05-27 20:51:26 +00004639 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004640 ThrowMogrifyException(OptionError,"MissingArgument",option);
4641 if (*option == '+')
4642 {
4643 const char
4644 *define;
4645
4646 define=GetImageOption(image_info,argv[i]);
4647 if (define == (const char *) NULL)
4648 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4649 break;
4650 }
4651 break;
4652 }
4653 if (LocaleCompare("delay",option+1) == 0)
4654 {
4655 if (*option == '+')
4656 break;
4657 i++;
cristybb503372010-05-27 20:51:26 +00004658 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004659 ThrowMogrifyException(OptionError,"MissingArgument",option);
4660 if (IsGeometry(argv[i]) == MagickFalse)
4661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4662 break;
4663 }
cristyecb10ff2011-03-22 13:14:03 +00004664 if (LocaleCompare("delete",option+1) == 0)
4665 {
4666 if (*option == '+')
4667 break;
4668 i++;
4669 if (i == (ssize_t) (argc-1))
4670 ThrowMogrifyException(OptionError,"MissingArgument",option);
4671 if (IsGeometry(argv[i]) == MagickFalse)
4672 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4673 break;
4674 }
cristy3ed852e2009-09-05 21:47:34 +00004675 if (LocaleCompare("density",option+1) == 0)
4676 {
4677 if (*option == '+')
4678 break;
4679 i++;
cristybb503372010-05-27 20:51:26 +00004680 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004681 ThrowMogrifyException(OptionError,"MissingArgument",option);
4682 if (IsGeometry(argv[i]) == MagickFalse)
4683 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4684 break;
4685 }
4686 if (LocaleCompare("depth",option+1) == 0)
4687 {
4688 if (*option == '+')
4689 break;
4690 i++;
cristybb503372010-05-27 20:51:26 +00004691 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004692 ThrowMogrifyException(OptionError,"MissingArgument",option);
4693 if (IsGeometry(argv[i]) == MagickFalse)
4694 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4695 break;
4696 }
4697 if (LocaleCompare("deskew",option+1) == 0)
4698 {
4699 if (*option == '+')
4700 break;
4701 i++;
cristybb503372010-05-27 20:51:26 +00004702 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004703 ThrowMogrifyException(OptionError,"MissingArgument",option);
4704 if (IsGeometry(argv[i]) == MagickFalse)
4705 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4706 break;
4707 }
4708 if (LocaleCompare("despeckle",option+1) == 0)
4709 break;
4710 if (LocaleCompare("dft",option+1) == 0)
4711 break;
cristyc9b12952010-03-28 01:12:28 +00004712 if (LocaleCompare("direction",option+1) == 0)
4713 {
cristybb503372010-05-27 20:51:26 +00004714 ssize_t
cristyc9b12952010-03-28 01:12:28 +00004715 direction;
4716
4717 if (*option == '+')
4718 break;
4719 i++;
cristybb503372010-05-27 20:51:26 +00004720 if (i == (ssize_t) argc)
cristyc9b12952010-03-28 01:12:28 +00004721 ThrowMogrifyException(OptionError,"MissingArgument",option);
4722 direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
4723 argv[i]);
4724 if (direction < 0)
4725 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4726 argv[i]);
4727 break;
4728 }
cristy3ed852e2009-09-05 21:47:34 +00004729 if (LocaleCompare("display",option+1) == 0)
4730 {
4731 if (*option == '+')
4732 break;
4733 i++;
cristybb503372010-05-27 20:51:26 +00004734 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004735 ThrowMogrifyException(OptionError,"MissingArgument",option);
4736 break;
4737 }
4738 if (LocaleCompare("dispose",option+1) == 0)
4739 {
cristybb503372010-05-27 20:51:26 +00004740 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004741 dispose;
4742
4743 if (*option == '+')
4744 break;
4745 i++;
cristybb503372010-05-27 20:51:26 +00004746 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004747 ThrowMogrifyException(OptionError,"MissingArgument",option);
4748 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
4749 if (dispose < 0)
4750 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4751 argv[i]);
4752 break;
4753 }
4754 if (LocaleCompare("distort",option+1) == 0)
4755 {
cristybb503372010-05-27 20:51:26 +00004756 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004757 op;
4758
4759 i++;
cristybb503372010-05-27 20:51:26 +00004760 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004761 ThrowMogrifyException(OptionError,"MissingArgument",option);
4762 op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
4763 if (op < 0)
4764 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4765 argv[i]);
4766 i++;
cristybb503372010-05-27 20:51:26 +00004767 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004768 ThrowMogrifyException(OptionError,"MissingArgument",option);
4769 break;
4770 }
4771 if (LocaleCompare("dither",option+1) == 0)
4772 {
cristybb503372010-05-27 20:51:26 +00004773 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004774 method;
4775
4776 if (*option == '+')
4777 break;
4778 i++;
cristybb503372010-05-27 20:51:26 +00004779 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004780 ThrowMogrifyException(OptionError,"MissingArgument",option);
4781 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
4782 if (method < 0)
4783 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4784 argv[i]);
4785 break;
4786 }
4787 if (LocaleCompare("draw",option+1) == 0)
4788 {
4789 if (*option == '+')
4790 break;
4791 i++;
cristybb503372010-05-27 20:51:26 +00004792 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004793 ThrowMogrifyException(OptionError,"MissingArgument",option);
4794 break;
4795 }
cristyecb10ff2011-03-22 13:14:03 +00004796 if (LocaleCompare("duplicate",option+1) == 0)
4797 {
4798 if (*option == '+')
4799 break;
4800 i++;
4801 if (i == (ssize_t) (argc-1))
4802 ThrowMogrifyException(OptionError,"MissingArgument",option);
4803 if (IsGeometry(argv[i]) == MagickFalse)
4804 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4805 break;
4806 }
cristy22879752009-10-25 23:55:40 +00004807 if (LocaleCompare("duration",option+1) == 0)
4808 {
4809 if (*option == '+')
4810 break;
4811 i++;
cristybb503372010-05-27 20:51:26 +00004812 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004813 ThrowMogrifyException(OptionError,"MissingArgument",option);
4814 if (IsGeometry(argv[i]) == MagickFalse)
4815 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4816 break;
4817 }
cristy3ed852e2009-09-05 21:47:34 +00004818 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4819 }
4820 case 'e':
4821 {
4822 if (LocaleCompare("edge",option+1) == 0)
4823 {
4824 if (*option == '+')
4825 break;
4826 i++;
cristybb503372010-05-27 20:51:26 +00004827 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004828 ThrowMogrifyException(OptionError,"MissingArgument",option);
4829 if (IsGeometry(argv[i]) == MagickFalse)
4830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4831 break;
4832 }
4833 if (LocaleCompare("emboss",option+1) == 0)
4834 {
4835 if (*option == '+')
4836 break;
4837 i++;
cristybb503372010-05-27 20:51:26 +00004838 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004839 ThrowMogrifyException(OptionError,"MissingArgument",option);
4840 if (IsGeometry(argv[i]) == MagickFalse)
4841 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4842 break;
4843 }
4844 if (LocaleCompare("encipher",option+1) == 0)
4845 {
4846 if (*option == '+')
4847 break;
4848 i++;
cristybb503372010-05-27 20:51:26 +00004849 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004850 ThrowMogrifyException(OptionError,"MissingArgument",option);
4851 break;
4852 }
4853 if (LocaleCompare("encoding",option+1) == 0)
4854 {
4855 if (*option == '+')
4856 break;
4857 i++;
cristybb503372010-05-27 20:51:26 +00004858 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004859 ThrowMogrifyException(OptionError,"MissingArgument",option);
4860 break;
4861 }
4862 if (LocaleCompare("endian",option+1) == 0)
4863 {
cristybb503372010-05-27 20:51:26 +00004864 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004865 endian;
4866
4867 if (*option == '+')
4868 break;
4869 i++;
cristybb503372010-05-27 20:51:26 +00004870 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004871 ThrowMogrifyException(OptionError,"MissingArgument",option);
4872 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4873 if (endian < 0)
4874 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4875 argv[i]);
4876 break;
4877 }
4878 if (LocaleCompare("enhance",option+1) == 0)
4879 break;
4880 if (LocaleCompare("equalize",option+1) == 0)
4881 break;
4882 if (LocaleCompare("evaluate",option+1) == 0)
4883 {
cristybb503372010-05-27 20:51:26 +00004884 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004885 op;
4886
4887 if (*option == '+')
4888 break;
4889 i++;
cristybb503372010-05-27 20:51:26 +00004890 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004891 ThrowMogrifyException(OptionError,"MissingArgument",option);
4892 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4893 if (op < 0)
4894 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4895 argv[i]);
4896 i++;
cristybb503372010-05-27 20:51:26 +00004897 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004898 ThrowMogrifyException(OptionError,"MissingArgument",option);
4899 if (IsGeometry(argv[i]) == MagickFalse)
4900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4901 break;
4902 }
cristyd18ae7c2010-03-07 17:39:52 +00004903 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4904 {
cristybb503372010-05-27 20:51:26 +00004905 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004906 op;
4907
4908 if (*option == '+')
4909 break;
4910 i++;
cristybb503372010-05-27 20:51:26 +00004911 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004912 ThrowMogrifyException(OptionError,"MissingArgument",option);
4913 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4914 if (op < 0)
4915 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4916 argv[i]);
4917 break;
4918 }
cristy3ed852e2009-09-05 21:47:34 +00004919 if (LocaleCompare("extent",option+1) == 0)
4920 {
4921 if (*option == '+')
4922 break;
4923 i++;
cristybb503372010-05-27 20:51:26 +00004924 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004925 ThrowMogrifyException(OptionError,"MissingArgument",option);
4926 if (IsGeometry(argv[i]) == MagickFalse)
4927 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4928 break;
4929 }
4930 if (LocaleCompare("extract",option+1) == 0)
4931 {
4932 if (*option == '+')
4933 break;
4934 i++;
cristybb503372010-05-27 20:51:26 +00004935 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004936 ThrowMogrifyException(OptionError,"MissingArgument",option);
4937 if (IsGeometry(argv[i]) == MagickFalse)
4938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4939 break;
4940 }
4941 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4942 }
4943 case 'f':
4944 {
4945 if (LocaleCompare("family",option+1) == 0)
4946 {
4947 if (*option == '+')
4948 break;
4949 i++;
cristybb503372010-05-27 20:51:26 +00004950 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004951 ThrowMogrifyException(OptionError,"MissingArgument",option);
4952 break;
4953 }
4954 if (LocaleCompare("fill",option+1) == 0)
4955 {
4956 if (*option == '+')
4957 break;
4958 i++;
cristybb503372010-05-27 20:51:26 +00004959 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004960 ThrowMogrifyException(OptionError,"MissingArgument",option);
4961 break;
4962 }
4963 if (LocaleCompare("filter",option+1) == 0)
4964 {
cristybb503372010-05-27 20:51:26 +00004965 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004966 filter;
4967
4968 if (*option == '+')
4969 break;
4970 i++;
cristybb503372010-05-27 20:51:26 +00004971 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004972 ThrowMogrifyException(OptionError,"MissingArgument",option);
4973 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4974 if (filter < 0)
4975 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4976 argv[i]);
4977 break;
4978 }
4979 if (LocaleCompare("flatten",option+1) == 0)
4980 break;
4981 if (LocaleCompare("flip",option+1) == 0)
4982 break;
4983 if (LocaleCompare("flop",option+1) == 0)
4984 break;
4985 if (LocaleCompare("floodfill",option+1) == 0)
4986 {
4987 if (*option == '+')
4988 break;
4989 i++;
cristybb503372010-05-27 20:51:26 +00004990 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004991 ThrowMogrifyException(OptionError,"MissingArgument",option);
4992 if (IsGeometry(argv[i]) == MagickFalse)
4993 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4994 i++;
cristybb503372010-05-27 20:51:26 +00004995 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004996 ThrowMogrifyException(OptionError,"MissingArgument",option);
4997 break;
4998 }
4999 if (LocaleCompare("font",option+1) == 0)
5000 {
5001 if (*option == '+')
5002 break;
5003 i++;
cristybb503372010-05-27 20:51:26 +00005004 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005005 ThrowMogrifyException(OptionError,"MissingArgument",option);
5006 break;
5007 }
5008 if (LocaleCompare("format",option+1) == 0)
5009 {
5010 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
5011 (void) CloneString(&format,(char *) NULL);
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 ThrowMogrifyException(OptionError,"MissingArgument",option);
5017 (void) CloneString(&format,argv[i]);
5018 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
5019 (void) ConcatenateMagickString(image_info->filename,":",
5020 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00005021 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00005022 if (*image_info->magick == '\0')
5023 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
5024 format);
5025 break;
5026 }
5027 if (LocaleCompare("frame",option+1) == 0)
5028 {
5029 if (*option == '+')
5030 break;
5031 i++;
cristybb503372010-05-27 20:51:26 +00005032 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005033 ThrowMogrifyException(OptionError,"MissingArgument",option);
5034 if (IsGeometry(argv[i]) == MagickFalse)
5035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5036 break;
5037 }
5038 if (LocaleCompare("function",option+1) == 0)
5039 {
cristybb503372010-05-27 20:51:26 +00005040 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005041 op;
5042
5043 if (*option == '+')
5044 break;
5045 i++;
cristybb503372010-05-27 20:51:26 +00005046 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005047 ThrowMogrifyException(OptionError,"MissingArgument",option);
5048 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
5049 if (op < 0)
5050 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
5051 i++;
cristybb503372010-05-27 20:51:26 +00005052 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005053 ThrowMogrifyException(OptionError,"MissingArgument",option);
5054 break;
5055 }
5056 if (LocaleCompare("fuzz",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 if (IsGeometry(argv[i]) == MagickFalse)
5064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5065 break;
5066 }
5067 if (LocaleCompare("fx",option+1) == 0)
5068 {
5069 if (*option == '+')
5070 break;
5071 i++;
cristybb503372010-05-27 20:51:26 +00005072 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005073 ThrowMogrifyException(OptionError,"MissingArgument",option);
5074 break;
5075 }
5076 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5077 }
5078 case 'g':
5079 {
5080 if (LocaleCompare("gamma",option+1) == 0)
5081 {
5082 i++;
cristybb503372010-05-27 20:51:26 +00005083 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005084 ThrowMogrifyException(OptionError,"MissingArgument",option);
5085 if (IsGeometry(argv[i]) == MagickFalse)
5086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5087 break;
5088 }
5089 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5090 (LocaleCompare("gaussian",option+1) == 0))
5091 {
5092 i++;
cristybb503372010-05-27 20:51:26 +00005093 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005094 ThrowMogrifyException(OptionError,"MissingArgument",option);
5095 if (IsGeometry(argv[i]) == MagickFalse)
5096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5097 break;
5098 }
5099 if (LocaleCompare("geometry",option+1) == 0)
5100 {
5101 if (*option == '+')
5102 break;
5103 i++;
cristybb503372010-05-27 20:51:26 +00005104 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005105 ThrowMogrifyException(OptionError,"MissingArgument",option);
5106 if (IsGeometry(argv[i]) == MagickFalse)
5107 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5108 break;
5109 }
5110 if (LocaleCompare("gravity",option+1) == 0)
5111 {
cristybb503372010-05-27 20:51:26 +00005112 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005113 gravity;
5114
5115 if (*option == '+')
5116 break;
5117 i++;
cristybb503372010-05-27 20:51:26 +00005118 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005119 ThrowMogrifyException(OptionError,"MissingArgument",option);
5120 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5121 if (gravity < 0)
5122 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5123 argv[i]);
5124 break;
5125 }
5126 if (LocaleCompare("green-primary",option+1) == 0)
5127 {
5128 if (*option == '+')
5129 break;
5130 i++;
cristybb503372010-05-27 20:51:26 +00005131 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005132 ThrowMogrifyException(OptionError,"MissingArgument",option);
5133 if (IsGeometry(argv[i]) == MagickFalse)
5134 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5135 break;
5136 }
5137 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5138 }
5139 case 'h':
5140 {
5141 if (LocaleCompare("hald-clut",option+1) == 0)
5142 break;
5143 if ((LocaleCompare("help",option+1) == 0) ||
5144 (LocaleCompare("-help",option+1) == 0))
5145 return(MogrifyUsage());
5146 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5147 }
5148 case 'i':
5149 {
5150 if (LocaleCompare("identify",option+1) == 0)
5151 break;
5152 if (LocaleCompare("idft",option+1) == 0)
5153 break;
5154 if (LocaleCompare("implode",option+1) == 0)
5155 {
5156 if (*option == '+')
5157 break;
5158 i++;
cristybb503372010-05-27 20:51:26 +00005159 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005160 ThrowMogrifyException(OptionError,"MissingArgument",option);
5161 if (IsGeometry(argv[i]) == MagickFalse)
5162 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5163 break;
5164 }
5165 if (LocaleCompare("intent",option+1) == 0)
5166 {
cristybb503372010-05-27 20:51:26 +00005167 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005168 intent;
5169
5170 if (*option == '+')
5171 break;
5172 i++;
cristybb503372010-05-27 20:51:26 +00005173 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005174 ThrowMogrifyException(OptionError,"MissingArgument",option);
5175 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5176 if (intent < 0)
5177 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5178 argv[i]);
5179 break;
5180 }
5181 if (LocaleCompare("interlace",option+1) == 0)
5182 {
cristybb503372010-05-27 20:51:26 +00005183 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005184 interlace;
5185
5186 if (*option == '+')
5187 break;
5188 i++;
cristybb503372010-05-27 20:51:26 +00005189 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005190 ThrowMogrifyException(OptionError,"MissingArgument",option);
5191 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5192 argv[i]);
5193 if (interlace < 0)
5194 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5195 argv[i]);
5196 break;
5197 }
cristyb32b90a2009-09-07 21:45:48 +00005198 if (LocaleCompare("interline-spacing",option+1) == 0)
5199 {
5200 if (*option == '+')
5201 break;
5202 i++;
cristybb503372010-05-27 20:51:26 +00005203 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00005204 ThrowMogrifyException(OptionError,"MissingArgument",option);
5205 if (IsGeometry(argv[i]) == MagickFalse)
5206 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5207 break;
5208 }
cristy3ed852e2009-09-05 21:47:34 +00005209 if (LocaleCompare("interpolate",option+1) == 0)
5210 {
cristybb503372010-05-27 20:51:26 +00005211 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005212 interpolate;
5213
5214 if (*option == '+')
5215 break;
5216 i++;
cristybb503372010-05-27 20:51:26 +00005217 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005218 ThrowMogrifyException(OptionError,"MissingArgument",option);
5219 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5220 argv[i]);
5221 if (interpolate < 0)
5222 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5223 argv[i]);
5224 break;
5225 }
5226 if (LocaleCompare("interword-spacing",option+1) == 0)
5227 {
5228 if (*option == '+')
5229 break;
5230 i++;
cristybb503372010-05-27 20:51:26 +00005231 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005232 ThrowMogrifyException(OptionError,"MissingArgument",option);
5233 if (IsGeometry(argv[i]) == MagickFalse)
5234 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5235 break;
5236 }
5237 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5238 }
5239 case 'k':
5240 {
5241 if (LocaleCompare("kerning",option+1) == 0)
5242 {
5243 if (*option == '+')
5244 break;
5245 i++;
cristybb503372010-05-27 20:51:26 +00005246 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005247 ThrowMogrifyException(OptionError,"MissingArgument",option);
5248 if (IsGeometry(argv[i]) == MagickFalse)
5249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5250 break;
5251 }
5252 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5253 }
5254 case 'l':
5255 {
5256 if (LocaleCompare("label",option+1) == 0)
5257 {
5258 if (*option == '+')
5259 break;
5260 i++;
cristybb503372010-05-27 20:51:26 +00005261 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005262 ThrowMogrifyException(OptionError,"MissingArgument",option);
5263 break;
5264 }
5265 if (LocaleCompare("lat",option+1) == 0)
5266 {
5267 if (*option == '+')
5268 break;
5269 i++;
cristybb503372010-05-27 20:51:26 +00005270 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005271 ThrowMogrifyException(OptionError,"MissingArgument",option);
5272 if (IsGeometry(argv[i]) == MagickFalse)
5273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5274 }
5275 if (LocaleCompare("layers",option+1) == 0)
5276 {
cristybb503372010-05-27 20:51:26 +00005277 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005278 type;
5279
5280 if (*option == '+')
5281 break;
5282 i++;
cristybb503372010-05-27 20:51:26 +00005283 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005284 ThrowMogrifyException(OptionError,"MissingArgument",option);
5285 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5286 if (type < 0)
5287 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5288 argv[i]);
5289 break;
5290 }
5291 if (LocaleCompare("level",option+1) == 0)
5292 {
5293 i++;
cristybb503372010-05-27 20:51:26 +00005294 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005295 ThrowMogrifyException(OptionError,"MissingArgument",option);
5296 if (IsGeometry(argv[i]) == MagickFalse)
5297 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5298 break;
5299 }
5300 if (LocaleCompare("level-colors",option+1) == 0)
5301 {
5302 i++;
cristybb503372010-05-27 20:51:26 +00005303 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005304 ThrowMogrifyException(OptionError,"MissingArgument",option);
5305 break;
5306 }
5307 if (LocaleCompare("linewidth",option+1) == 0)
5308 {
5309 if (*option == '+')
5310 break;
5311 i++;
cristybb503372010-05-27 20:51:26 +00005312 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005313 ThrowMogrifyException(OptionError,"MissingArgument",option);
5314 if (IsGeometry(argv[i]) == MagickFalse)
5315 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5316 break;
5317 }
5318 if (LocaleCompare("limit",option+1) == 0)
5319 {
5320 char
5321 *p;
5322
5323 double
5324 value;
5325
cristybb503372010-05-27 20:51:26 +00005326 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005327 resource;
5328
5329 if (*option == '+')
5330 break;
5331 i++;
cristybb503372010-05-27 20:51:26 +00005332 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005333 ThrowMogrifyException(OptionError,"MissingArgument",option);
5334 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5335 argv[i]);
5336 if (resource < 0)
5337 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5338 argv[i]);
5339 i++;
cristybb503372010-05-27 20:51:26 +00005340 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005341 ThrowMogrifyException(OptionError,"MissingArgument",option);
5342 value=strtod(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00005343 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00005344 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5346 break;
5347 }
5348 if (LocaleCompare("liquid-rescale",option+1) == 0)
5349 {
5350 i++;
cristybb503372010-05-27 20:51:26 +00005351 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005352 ThrowMogrifyException(OptionError,"MissingArgument",option);
5353 if (IsGeometry(argv[i]) == MagickFalse)
5354 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5355 break;
5356 }
5357 if (LocaleCompare("list",option+1) == 0)
5358 {
cristybb503372010-05-27 20:51:26 +00005359 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005360 list;
5361
5362 if (*option == '+')
5363 break;
5364 i++;
cristybb503372010-05-27 20:51:26 +00005365 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005366 ThrowMogrifyException(OptionError,"MissingArgument",option);
5367 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5368 if (list < 0)
5369 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00005370 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00005371 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00005372 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00005373 }
5374 if (LocaleCompare("log",option+1) == 0)
5375 {
5376 if (*option == '+')
5377 break;
5378 i++;
cristybb503372010-05-27 20:51:26 +00005379 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00005380 (strchr(argv[i],'%') == (char *) NULL))
5381 ThrowMogrifyException(OptionError,"MissingArgument",option);
5382 break;
5383 }
5384 if (LocaleCompare("loop",option+1) == 0)
5385 {
5386 if (*option == '+')
5387 break;
5388 i++;
cristybb503372010-05-27 20:51:26 +00005389 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005390 ThrowMogrifyException(OptionError,"MissingArgument",option);
5391 if (IsGeometry(argv[i]) == MagickFalse)
5392 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5393 break;
5394 }
5395 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5396 }
5397 case 'm':
5398 {
5399 if (LocaleCompare("map",option+1) == 0)
5400 {
5401 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5402 if (*option == '+')
5403 break;
5404 i++;
cristybb503372010-05-27 20:51:26 +00005405 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005406 ThrowMogrifyException(OptionError,"MissingArgument",option);
5407 break;
5408 }
5409 if (LocaleCompare("mask",option+1) == 0)
5410 {
5411 if (*option == '+')
5412 break;
5413 i++;
cristybb503372010-05-27 20:51:26 +00005414 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005415 ThrowMogrifyException(OptionError,"MissingArgument",option);
5416 break;
5417 }
5418 if (LocaleCompare("matte",option+1) == 0)
5419 break;
5420 if (LocaleCompare("mattecolor",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 break;
5428 }
cristyf40785b2010-03-06 02:27:27 +00005429 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005430 break;
cristyf40785b2010-03-06 02:27:27 +00005431 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005432 break;
cristy3ed852e2009-09-05 21:47:34 +00005433 if (LocaleCompare("modulate",option+1) == 0)
5434 {
5435 if (*option == '+')
5436 break;
5437 i++;
cristybb503372010-05-27 20:51:26 +00005438 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005439 ThrowMogrifyException(OptionError,"MissingArgument",option);
5440 if (IsGeometry(argv[i]) == MagickFalse)
5441 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5442 break;
5443 }
5444 if (LocaleCompare("median",option+1) == 0)
5445 {
5446 if (*option == '+')
5447 break;
5448 i++;
cristybb503372010-05-27 20:51:26 +00005449 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005450 ThrowMogrifyException(OptionError,"MissingArgument",option);
5451 if (IsGeometry(argv[i]) == MagickFalse)
5452 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5453 break;
5454 }
cristy69ec32d2011-02-27 23:57:09 +00005455 if (LocaleCompare("mode",option+1) == 0)
5456 {
5457 if (*option == '+')
5458 break;
5459 i++;
5460 if (i == (ssize_t) argc)
5461 ThrowMogrifyException(OptionError,"MissingArgument",option);
5462 if (IsGeometry(argv[i]) == MagickFalse)
5463 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5464 break;
5465 }
cristy3ed852e2009-09-05 21:47:34 +00005466 if (LocaleCompare("monitor",option+1) == 0)
5467 break;
5468 if (LocaleCompare("monochrome",option+1) == 0)
5469 break;
5470 if (LocaleCompare("morph",option+1) == 0)
5471 {
5472 if (*option == '+')
5473 break;
5474 i++;
cristybb503372010-05-27 20:51:26 +00005475 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005476 ThrowMogrifyException(OptionError,"MissingArgument",option);
5477 if (IsGeometry(argv[i]) == MagickFalse)
5478 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5479 break;
5480 }
anthony29188a82010-01-22 10:12:34 +00005481 if (LocaleCompare("morphology",option+1) == 0)
5482 {
anthony29188a82010-01-22 10:12:34 +00005483 char
5484 token[MaxTextExtent];
5485
cristyb6bd4ad2010-08-08 01:12:27 +00005486 KernelInfo
5487 *kernel_info;
5488
5489 ssize_t
5490 op;
5491
anthony29188a82010-01-22 10:12:34 +00005492 i++;
cristybb503372010-05-27 20:51:26 +00005493 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005494 ThrowMogrifyException(OptionError,"MissingArgument",option);
5495 GetMagickToken(argv[i],NULL,token);
5496 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5497 if (op < 0)
5498 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005499 token);
anthony29188a82010-01-22 10:12:34 +00005500 i++;
cristybb503372010-05-27 20:51:26 +00005501 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005502 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005503 kernel_info=AcquireKernelInfo(argv[i]);
5504 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005505 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005506 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005507 break;
5508 }
cristy3ed852e2009-09-05 21:47:34 +00005509 if (LocaleCompare("mosaic",option+1) == 0)
5510 break;
5511 if (LocaleCompare("motion-blur",option+1) == 0)
5512 {
5513 if (*option == '+')
5514 break;
5515 i++;
cristybb503372010-05-27 20:51:26 +00005516 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005517 ThrowMogrifyException(OptionError,"MissingArgument",option);
5518 if (IsGeometry(argv[i]) == MagickFalse)
5519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5520 break;
5521 }
5522 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5523 }
5524 case 'n':
5525 {
5526 if (LocaleCompare("negate",option+1) == 0)
5527 break;
5528 if (LocaleCompare("noise",option+1) == 0)
5529 {
5530 i++;
cristybb503372010-05-27 20:51:26 +00005531 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005532 ThrowMogrifyException(OptionError,"MissingArgument",option);
5533 if (*option == '+')
5534 {
cristybb503372010-05-27 20:51:26 +00005535 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005536 noise;
5537
5538 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5539 if (noise < 0)
5540 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5541 argv[i]);
5542 break;
5543 }
5544 if (IsGeometry(argv[i]) == MagickFalse)
5545 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5546 break;
5547 }
5548 if (LocaleCompare("noop",option+1) == 0)
5549 break;
5550 if (LocaleCompare("normalize",option+1) == 0)
5551 break;
5552 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5553 }
5554 case 'o':
5555 {
5556 if (LocaleCompare("opaque",option+1) == 0)
5557 {
cristy3ed852e2009-09-05 21:47:34 +00005558 i++;
cristybb503372010-05-27 20:51:26 +00005559 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005560 ThrowMogrifyException(OptionError,"MissingArgument",option);
5561 break;
5562 }
5563 if (LocaleCompare("ordered-dither",option+1) == 0)
5564 {
5565 if (*option == '+')
5566 break;
5567 i++;
cristybb503372010-05-27 20:51:26 +00005568 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005569 ThrowMogrifyException(OptionError,"MissingArgument",option);
5570 break;
5571 }
5572 if (LocaleCompare("orient",option+1) == 0)
5573 {
cristybb503372010-05-27 20:51:26 +00005574 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005575 orientation;
5576
5577 orientation=UndefinedOrientation;
5578 if (*option == '+')
5579 break;
5580 i++;
cristybb503372010-05-27 20:51:26 +00005581 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005582 ThrowMogrifyException(OptionError,"MissingArgument",option);
5583 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5584 argv[i]);
5585 if (orientation < 0)
5586 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5587 argv[i]);
5588 break;
5589 }
5590 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5591 }
5592 case 'p':
5593 {
5594 if (LocaleCompare("page",option+1) == 0)
5595 {
5596 if (*option == '+')
5597 break;
5598 i++;
cristybb503372010-05-27 20:51:26 +00005599 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005600 ThrowMogrifyException(OptionError,"MissingArgument",option);
5601 break;
5602 }
5603 if (LocaleCompare("paint",option+1) == 0)
5604 {
5605 if (*option == '+')
5606 break;
5607 i++;
cristybb503372010-05-27 20:51:26 +00005608 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005609 ThrowMogrifyException(OptionError,"MissingArgument",option);
5610 if (IsGeometry(argv[i]) == MagickFalse)
5611 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5612 break;
5613 }
5614 if (LocaleCompare("path",option+1) == 0)
5615 {
5616 (void) CloneString(&path,(char *) NULL);
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 (void) CloneString(&path,argv[i]);
5623 break;
5624 }
5625 if (LocaleCompare("pointsize",option+1) == 0)
5626 {
5627 if (*option == '+')
5628 break;
5629 i++;
cristybb503372010-05-27 20:51:26 +00005630 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005631 ThrowMogrifyException(OptionError,"MissingArgument",option);
5632 if (IsGeometry(argv[i]) == MagickFalse)
5633 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5634 break;
5635 }
5636 if (LocaleCompare("polaroid",option+1) == 0)
5637 {
5638 if (*option == '+')
5639 break;
5640 i++;
cristybb503372010-05-27 20:51:26 +00005641 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005642 ThrowMogrifyException(OptionError,"MissingArgument",option);
5643 if (IsGeometry(argv[i]) == MagickFalse)
5644 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5645 break;
5646 }
5647 if (LocaleCompare("posterize",option+1) == 0)
5648 {
5649 if (*option == '+')
5650 break;
5651 i++;
cristybb503372010-05-27 20:51:26 +00005652 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005653 ThrowMogrifyException(OptionError,"MissingArgument",option);
5654 if (IsGeometry(argv[i]) == MagickFalse)
5655 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5656 break;
5657 }
cristye7f51092010-01-17 00:39:37 +00005658 if (LocaleCompare("precision",option+1) == 0)
5659 {
5660 if (*option == '+')
5661 break;
5662 i++;
cristybb503372010-05-27 20:51:26 +00005663 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005664 ThrowMogrifyException(OptionError,"MissingArgument",option);
5665 if (IsGeometry(argv[i]) == MagickFalse)
5666 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5667 break;
5668 }
cristy3ed852e2009-09-05 21:47:34 +00005669 if (LocaleCompare("print",option+1) == 0)
5670 {
5671 if (*option == '+')
5672 break;
5673 i++;
cristybb503372010-05-27 20:51:26 +00005674 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005675 ThrowMogrifyException(OptionError,"MissingArgument",option);
5676 break;
5677 }
5678 if (LocaleCompare("process",option+1) == 0)
5679 {
5680 if (*option == '+')
5681 break;
5682 i++;
cristybb503372010-05-27 20:51:26 +00005683 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005684 ThrowMogrifyException(OptionError,"MissingArgument",option);
5685 break;
5686 }
5687 if (LocaleCompare("profile",option+1) == 0)
5688 {
5689 i++;
cristybb503372010-05-27 20:51:26 +00005690 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005691 ThrowMogrifyException(OptionError,"MissingArgument",option);
5692 break;
5693 }
5694 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5695 }
5696 case 'q':
5697 {
5698 if (LocaleCompare("quality",option+1) == 0)
5699 {
5700 if (*option == '+')
5701 break;
5702 i++;
cristybb503372010-05-27 20:51:26 +00005703 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005704 ThrowMogrifyException(OptionError,"MissingArgument",option);
5705 if (IsGeometry(argv[i]) == MagickFalse)
5706 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5707 break;
5708 }
5709 if (LocaleCompare("quantize",option+1) == 0)
5710 {
cristybb503372010-05-27 20:51:26 +00005711 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005712 colorspace;
5713
5714 if (*option == '+')
5715 break;
5716 i++;
cristybb503372010-05-27 20:51:26 +00005717 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005718 ThrowMogrifyException(OptionError,"MissingArgument",option);
5719 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5720 argv[i]);
5721 if (colorspace < 0)
5722 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5723 argv[i]);
5724 break;
5725 }
5726 if (LocaleCompare("quiet",option+1) == 0)
5727 break;
5728 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5729 }
5730 case 'r':
5731 {
5732 if (LocaleCompare("radial-blur",option+1) == 0)
5733 {
5734 i++;
cristybb503372010-05-27 20:51:26 +00005735 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005736 ThrowMogrifyException(OptionError,"MissingArgument",option);
5737 if (IsGeometry(argv[i]) == MagickFalse)
5738 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5739 break;
5740 }
5741 if (LocaleCompare("raise",option+1) == 0)
5742 {
5743 i++;
cristybb503372010-05-27 20:51:26 +00005744 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005745 ThrowMogrifyException(OptionError,"MissingArgument",option);
5746 if (IsGeometry(argv[i]) == MagickFalse)
5747 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5748 break;
5749 }
5750 if (LocaleCompare("random-threshold",option+1) == 0)
5751 {
5752 if (*option == '+')
5753 break;
5754 i++;
cristybb503372010-05-27 20:51:26 +00005755 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005756 ThrowMogrifyException(OptionError,"MissingArgument",option);
5757 if (IsGeometry(argv[i]) == MagickFalse)
5758 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5759 break;
5760 }
cristye6365592010-04-02 17:31:23 +00005761 if (LocaleCompare("recolor",option+1) == 0)
5762 {
5763 if (*option == '+')
5764 break;
5765 i++;
cristybb503372010-05-27 20:51:26 +00005766 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005767 ThrowMogrifyException(OptionError,"MissingArgument",option);
5768 if (IsGeometry(argv[i]) == MagickFalse)
5769 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5770 break;
5771 }
cristy3ed852e2009-09-05 21:47:34 +00005772 if (LocaleCompare("red-primary",option+1) == 0)
5773 {
5774 if (*option == '+')
5775 break;
5776 i++;
cristybb503372010-05-27 20:51:26 +00005777 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005778 ThrowMogrifyException(OptionError,"MissingArgument",option);
5779 if (IsGeometry(argv[i]) == MagickFalse)
5780 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5781 }
cristy9f2083a2010-04-22 19:48:05 +00005782 if (LocaleCompare("regard-warnings",option+1) == 0)
5783 break;
cristy3ed852e2009-09-05 21:47:34 +00005784 if (LocaleCompare("region",option+1) == 0)
5785 {
5786 if (*option == '+')
5787 break;
5788 i++;
cristybb503372010-05-27 20:51:26 +00005789 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005790 ThrowMogrifyException(OptionError,"MissingArgument",option);
5791 if (IsGeometry(argv[i]) == MagickFalse)
5792 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5793 break;
5794 }
cristyf0c78232010-03-15 12:53:40 +00005795 if (LocaleCompare("remap",option+1) == 0)
5796 {
5797 if (*option == '+')
5798 break;
5799 i++;
cristybb503372010-05-27 20:51:26 +00005800 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005801 ThrowMogrifyException(OptionError,"MissingArgument",option);
5802 break;
5803 }
cristy3ed852e2009-09-05 21:47:34 +00005804 if (LocaleCompare("render",option+1) == 0)
5805 break;
5806 if (LocaleCompare("repage",option+1) == 0)
5807 {
5808 if (*option == '+')
5809 break;
5810 i++;
cristybb503372010-05-27 20:51:26 +00005811 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005812 ThrowMogrifyException(OptionError,"MissingArgument",option);
5813 if (IsGeometry(argv[i]) == MagickFalse)
5814 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5815 break;
5816 }
5817 if (LocaleCompare("resample",option+1) == 0)
5818 {
5819 if (*option == '+')
5820 break;
5821 i++;
cristybb503372010-05-27 20:51:26 +00005822 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005823 ThrowMogrifyException(OptionError,"MissingArgument",option);
5824 if (IsGeometry(argv[i]) == MagickFalse)
5825 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5826 break;
5827 }
5828 if (LocaleCompare("resize",option+1) == 0)
5829 {
5830 if (*option == '+')
5831 break;
5832 i++;
cristybb503372010-05-27 20:51:26 +00005833 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005834 ThrowMogrifyException(OptionError,"MissingArgument",option);
5835 if (IsGeometry(argv[i]) == MagickFalse)
5836 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5837 break;
5838 }
cristyebbcfea2011-02-25 02:43:54 +00005839 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5840 {
5841 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5842 break;
5843 }
cristy3ed852e2009-09-05 21:47:34 +00005844 if (LocaleCompare("reverse",option+1) == 0)
5845 break;
5846 if (LocaleCompare("roll",option+1) == 0)
5847 {
5848 if (*option == '+')
5849 break;
5850 i++;
cristybb503372010-05-27 20:51:26 +00005851 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005852 ThrowMogrifyException(OptionError,"MissingArgument",option);
5853 if (IsGeometry(argv[i]) == MagickFalse)
5854 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5855 break;
5856 }
5857 if (LocaleCompare("rotate",option+1) == 0)
5858 {
5859 i++;
cristybb503372010-05-27 20:51:26 +00005860 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005861 ThrowMogrifyException(OptionError,"MissingArgument",option);
5862 if (IsGeometry(argv[i]) == MagickFalse)
5863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5864 break;
5865 }
5866 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5867 }
5868 case 's':
5869 {
5870 if (LocaleCompare("sample",option+1) == 0)
5871 {
5872 if (*option == '+')
5873 break;
5874 i++;
cristybb503372010-05-27 20:51:26 +00005875 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005876 ThrowMogrifyException(OptionError,"MissingArgument",option);
5877 if (IsGeometry(argv[i]) == MagickFalse)
5878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5879 break;
5880 }
5881 if (LocaleCompare("sampling-factor",option+1) == 0)
5882 {
5883 if (*option == '+')
5884 break;
5885 i++;
cristybb503372010-05-27 20:51:26 +00005886 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005887 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 if (IsGeometry(argv[i]) == MagickFalse)
5889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5890 break;
5891 }
5892 if (LocaleCompare("scale",option+1) == 0)
5893 {
5894 if (*option == '+')
5895 break;
5896 i++;
cristybb503372010-05-27 20:51:26 +00005897 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005898 ThrowMogrifyException(OptionError,"MissingArgument",option);
5899 if (IsGeometry(argv[i]) == MagickFalse)
5900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5901 break;
5902 }
5903 if (LocaleCompare("scene",option+1) == 0)
5904 {
5905 if (*option == '+')
5906 break;
5907 i++;
cristybb503372010-05-27 20:51:26 +00005908 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005909 ThrowMogrifyException(OptionError,"MissingArgument",option);
5910 if (IsGeometry(argv[i]) == MagickFalse)
5911 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5912 break;
5913 }
5914 if (LocaleCompare("seed",option+1) == 0)
5915 {
5916 if (*option == '+')
5917 break;
5918 i++;
cristybb503372010-05-27 20:51:26 +00005919 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005920 ThrowMogrifyException(OptionError,"MissingArgument",option);
5921 if (IsGeometry(argv[i]) == MagickFalse)
5922 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5923 break;
5924 }
5925 if (LocaleCompare("segment",option+1) == 0)
5926 {
5927 if (*option == '+')
5928 break;
5929 i++;
cristybb503372010-05-27 20:51:26 +00005930 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005931 ThrowMogrifyException(OptionError,"MissingArgument",option);
5932 if (IsGeometry(argv[i]) == MagickFalse)
5933 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5934 break;
5935 }
5936 if (LocaleCompare("selective-blur",option+1) == 0)
5937 {
5938 i++;
cristybb503372010-05-27 20:51:26 +00005939 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005940 ThrowMogrifyException(OptionError,"MissingArgument",option);
5941 if (IsGeometry(argv[i]) == MagickFalse)
5942 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5943 break;
5944 }
5945 if (LocaleCompare("separate",option+1) == 0)
5946 break;
5947 if (LocaleCompare("sepia-tone",option+1) == 0)
5948 {
5949 if (*option == '+')
5950 break;
5951 i++;
cristybb503372010-05-27 20:51:26 +00005952 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005953 ThrowMogrifyException(OptionError,"MissingArgument",option);
5954 if (IsGeometry(argv[i]) == MagickFalse)
5955 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5956 break;
5957 }
5958 if (LocaleCompare("set",option+1) == 0)
5959 {
5960 i++;
cristybb503372010-05-27 20:51:26 +00005961 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005962 ThrowMogrifyException(OptionError,"MissingArgument",option);
5963 if (*option == '+')
5964 break;
5965 i++;
cristybb503372010-05-27 20:51:26 +00005966 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005967 ThrowMogrifyException(OptionError,"MissingArgument",option);
5968 break;
5969 }
5970 if (LocaleCompare("shade",option+1) == 0)
5971 {
5972 i++;
cristybb503372010-05-27 20:51:26 +00005973 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005974 ThrowMogrifyException(OptionError,"MissingArgument",option);
5975 if (IsGeometry(argv[i]) == MagickFalse)
5976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5977 break;
5978 }
5979 if (LocaleCompare("shadow",option+1) == 0)
5980 {
5981 if (*option == '+')
5982 break;
5983 i++;
cristybb503372010-05-27 20:51:26 +00005984 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005985 ThrowMogrifyException(OptionError,"MissingArgument",option);
5986 if (IsGeometry(argv[i]) == MagickFalse)
5987 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5988 break;
5989 }
5990 if (LocaleCompare("sharpen",option+1) == 0)
5991 {
5992 i++;
cristybb503372010-05-27 20:51:26 +00005993 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005994 ThrowMogrifyException(OptionError,"MissingArgument",option);
5995 if (IsGeometry(argv[i]) == MagickFalse)
5996 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5997 break;
5998 }
5999 if (LocaleCompare("shave",option+1) == 0)
6000 {
6001 if (*option == '+')
6002 break;
6003 i++;
cristybb503372010-05-27 20:51:26 +00006004 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006005 ThrowMogrifyException(OptionError,"MissingArgument",option);
6006 if (IsGeometry(argv[i]) == MagickFalse)
6007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6008 break;
6009 }
6010 if (LocaleCompare("shear",option+1) == 0)
6011 {
6012 i++;
cristybb503372010-05-27 20:51:26 +00006013 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006014 ThrowMogrifyException(OptionError,"MissingArgument",option);
6015 if (IsGeometry(argv[i]) == MagickFalse)
6016 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6017 break;
6018 }
6019 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
6020 {
6021 i++;
cristybb503372010-05-27 20:51:26 +00006022 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006023 ThrowMogrifyException(OptionError,"MissingArgument",option);
6024 if (IsGeometry(argv[i]) == MagickFalse)
6025 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6026 break;
6027 }
6028 if (LocaleCompare("size",option+1) == 0)
6029 {
6030 if (*option == '+')
6031 break;
6032 i++;
cristybb503372010-05-27 20:51:26 +00006033 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006034 ThrowMogrifyException(OptionError,"MissingArgument",option);
6035 if (IsGeometry(argv[i]) == MagickFalse)
6036 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6037 break;
6038 }
6039 if (LocaleCompare("sketch",option+1) == 0)
6040 {
6041 if (*option == '+')
6042 break;
6043 i++;
cristybb503372010-05-27 20:51:26 +00006044 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006045 ThrowMogrifyException(OptionError,"MissingArgument",option);
6046 if (IsGeometry(argv[i]) == MagickFalse)
6047 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6048 break;
6049 }
cristy4285d782011-02-09 20:12:28 +00006050 if (LocaleCompare("smush",option+1) == 0)
6051 {
cristy4285d782011-02-09 20:12:28 +00006052 i++;
6053 if (i == (ssize_t) argc)
6054 ThrowMogrifyException(OptionError,"MissingArgument",option);
6055 if (IsGeometry(argv[i]) == MagickFalse)
6056 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00006057 i++;
6058 break;
6059 }
cristy3ed852e2009-09-05 21:47:34 +00006060 if (LocaleCompare("solarize",option+1) == 0)
6061 {
6062 if (*option == '+')
6063 break;
6064 i++;
cristybb503372010-05-27 20:51:26 +00006065 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006066 ThrowMogrifyException(OptionError,"MissingArgument",option);
6067 if (IsGeometry(argv[i]) == MagickFalse)
6068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6069 break;
6070 }
6071 if (LocaleCompare("sparse-color",option+1) == 0)
6072 {
cristybb503372010-05-27 20:51:26 +00006073 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006074 op;
6075
6076 i++;
cristybb503372010-05-27 20:51:26 +00006077 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006078 ThrowMogrifyException(OptionError,"MissingArgument",option);
6079 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6080 if (op < 0)
6081 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6082 argv[i]);
6083 i++;
cristybb503372010-05-27 20:51:26 +00006084 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006085 ThrowMogrifyException(OptionError,"MissingArgument",option);
6086 break;
6087 }
6088 if (LocaleCompare("spread",option+1) == 0)
6089 {
6090 if (*option == '+')
6091 break;
6092 i++;
cristybb503372010-05-27 20:51:26 +00006093 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006094 ThrowMogrifyException(OptionError,"MissingArgument",option);
6095 if (IsGeometry(argv[i]) == MagickFalse)
6096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6097 break;
6098 }
cristy0834d642011-03-18 18:26:08 +00006099 if (LocaleCompare("statistic",option+1) == 0)
6100 {
6101 ssize_t
6102 op;
6103
6104 if (*option == '+')
6105 break;
6106 i++;
6107 if (i == (ssize_t) argc)
6108 ThrowMogrifyException(OptionError,"MissingArgument",option);
6109 op=ParseMagickOption(MagickStatisticOptions,MagickFalse,argv[i]);
6110 if (op < 0)
6111 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6112 argv[i]);
6113 i++;
6114 if (i == (ssize_t) (argc-1))
6115 ThrowMogrifyException(OptionError,"MissingArgument",option);
6116 if (IsGeometry(argv[i]) == MagickFalse)
6117 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6118 break;
6119 }
cristy3ed852e2009-09-05 21:47:34 +00006120 if (LocaleCompare("stretch",option+1) == 0)
6121 {
cristybb503372010-05-27 20:51:26 +00006122 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006123 stretch;
6124
6125 if (*option == '+')
6126 break;
6127 i++;
cristybb503372010-05-27 20:51:26 +00006128 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006129 ThrowMogrifyException(OptionError,"MissingArgument",option);
6130 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
6131 if (stretch < 0)
6132 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6133 argv[i]);
6134 break;
6135 }
6136 if (LocaleCompare("strip",option+1) == 0)
6137 break;
6138 if (LocaleCompare("stroke",option+1) == 0)
6139 {
6140 if (*option == '+')
6141 break;
6142 i++;
cristybb503372010-05-27 20:51:26 +00006143 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006144 ThrowMogrifyException(OptionError,"MissingArgument",option);
6145 break;
6146 }
6147 if (LocaleCompare("strokewidth",option+1) == 0)
6148 {
6149 if (*option == '+')
6150 break;
6151 i++;
cristybb503372010-05-27 20:51:26 +00006152 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006153 ThrowMogrifyException(OptionError,"MissingArgument",option);
6154 if (IsGeometry(argv[i]) == MagickFalse)
6155 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6156 break;
6157 }
6158 if (LocaleCompare("style",option+1) == 0)
6159 {
cristybb503372010-05-27 20:51:26 +00006160 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006161 style;
6162
6163 if (*option == '+')
6164 break;
6165 i++;
cristybb503372010-05-27 20:51:26 +00006166 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006167 ThrowMogrifyException(OptionError,"MissingArgument",option);
6168 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6169 if (style < 0)
6170 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6171 argv[i]);
6172 break;
6173 }
cristyecb10ff2011-03-22 13:14:03 +00006174 if (LocaleCompare("swap",option+1) == 0)
6175 {
6176 if (*option == '+')
6177 break;
6178 i++;
6179 if (i == (ssize_t) (argc-1))
6180 ThrowMogrifyException(OptionError,"MissingArgument",option);
6181 if (IsGeometry(argv[i]) == MagickFalse)
6182 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6183 break;
6184 }
cristy3ed852e2009-09-05 21:47:34 +00006185 if (LocaleCompare("swirl",option+1) == 0)
6186 {
6187 if (*option == '+')
6188 break;
6189 i++;
cristybb503372010-05-27 20:51:26 +00006190 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006191 ThrowMogrifyException(OptionError,"MissingArgument",option);
6192 if (IsGeometry(argv[i]) == MagickFalse)
6193 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6194 break;
6195 }
cristyd9a29192010-10-16 16:49:53 +00006196 if (LocaleCompare("synchronize",option+1) == 0)
6197 break;
cristy3ed852e2009-09-05 21:47:34 +00006198 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6199 }
6200 case 't':
6201 {
6202 if (LocaleCompare("taint",option+1) == 0)
6203 break;
6204 if (LocaleCompare("texture",option+1) == 0)
6205 {
6206 if (*option == '+')
6207 break;
6208 i++;
cristybb503372010-05-27 20:51:26 +00006209 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006210 ThrowMogrifyException(OptionError,"MissingArgument",option);
6211 break;
6212 }
6213 if (LocaleCompare("tile",option+1) == 0)
6214 {
6215 if (*option == '+')
6216 break;
6217 i++;
cristybb503372010-05-27 20:51:26 +00006218 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006219 ThrowMogrifyException(OptionError,"MissingArgument",option);
6220 break;
6221 }
6222 if (LocaleCompare("tile-offset",option+1) == 0)
6223 {
6224 if (*option == '+')
6225 break;
6226 i++;
cristybb503372010-05-27 20:51:26 +00006227 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006228 ThrowMogrifyException(OptionError,"MissingArgument",option);
6229 if (IsGeometry(argv[i]) == MagickFalse)
6230 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6231 break;
6232 }
6233 if (LocaleCompare("tint",option+1) == 0)
6234 {
6235 if (*option == '+')
6236 break;
6237 i++;
cristybb503372010-05-27 20:51:26 +00006238 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006239 ThrowMogrifyException(OptionError,"MissingArgument",option);
6240 if (IsGeometry(argv[i]) == MagickFalse)
6241 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6242 break;
6243 }
6244 if (LocaleCompare("transform",option+1) == 0)
6245 break;
6246 if (LocaleCompare("transpose",option+1) == 0)
6247 break;
6248 if (LocaleCompare("transverse",option+1) == 0)
6249 break;
6250 if (LocaleCompare("threshold",option+1) == 0)
6251 {
6252 if (*option == '+')
6253 break;
6254 i++;
cristybb503372010-05-27 20:51:26 +00006255 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006256 ThrowMogrifyException(OptionError,"MissingArgument",option);
6257 if (IsGeometry(argv[i]) == MagickFalse)
6258 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6259 break;
6260 }
6261 if (LocaleCompare("thumbnail",option+1) == 0)
6262 {
6263 if (*option == '+')
6264 break;
6265 i++;
cristybb503372010-05-27 20:51:26 +00006266 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006267 ThrowMogrifyException(OptionError,"MissingArgument",option);
6268 if (IsGeometry(argv[i]) == MagickFalse)
6269 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6270 break;
6271 }
6272 if (LocaleCompare("transparent",option+1) == 0)
6273 {
6274 i++;
cristybb503372010-05-27 20:51:26 +00006275 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006276 ThrowMogrifyException(OptionError,"MissingArgument",option);
6277 break;
6278 }
6279 if (LocaleCompare("transparent-color",option+1) == 0)
6280 {
6281 if (*option == '+')
6282 break;
6283 i++;
cristybb503372010-05-27 20:51:26 +00006284 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006285 ThrowMogrifyException(OptionError,"MissingArgument",option);
6286 break;
6287 }
6288 if (LocaleCompare("treedepth",option+1) == 0)
6289 {
6290 if (*option == '+')
6291 break;
6292 i++;
cristybb503372010-05-27 20:51:26 +00006293 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006294 ThrowMogrifyException(OptionError,"MissingArgument",option);
6295 if (IsGeometry(argv[i]) == MagickFalse)
6296 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6297 break;
6298 }
6299 if (LocaleCompare("trim",option+1) == 0)
6300 break;
6301 if (LocaleCompare("type",option+1) == 0)
6302 {
cristybb503372010-05-27 20:51:26 +00006303 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006304 type;
6305
6306 if (*option == '+')
6307 break;
6308 i++;
cristybb503372010-05-27 20:51:26 +00006309 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006310 ThrowMogrifyException(OptionError,"MissingArgument",option);
6311 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6312 if (type < 0)
6313 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6314 argv[i]);
6315 break;
6316 }
6317 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6318 }
6319 case 'u':
6320 {
6321 if (LocaleCompare("undercolor",option+1) == 0)
6322 {
6323 if (*option == '+')
6324 break;
6325 i++;
cristybb503372010-05-27 20:51:26 +00006326 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006327 ThrowMogrifyException(OptionError,"MissingArgument",option);
6328 break;
6329 }
6330 if (LocaleCompare("unique-colors",option+1) == 0)
6331 break;
6332 if (LocaleCompare("units",option+1) == 0)
6333 {
cristybb503372010-05-27 20:51:26 +00006334 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006335 units;
6336
6337 if (*option == '+')
6338 break;
6339 i++;
cristybb503372010-05-27 20:51:26 +00006340 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006341 ThrowMogrifyException(OptionError,"MissingArgument",option);
6342 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6343 argv[i]);
6344 if (units < 0)
6345 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6346 argv[i]);
6347 break;
6348 }
6349 if (LocaleCompare("unsharp",option+1) == 0)
6350 {
6351 i++;
cristybb503372010-05-27 20:51:26 +00006352 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006353 ThrowMogrifyException(OptionError,"MissingArgument",option);
6354 if (IsGeometry(argv[i]) == MagickFalse)
6355 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6356 break;
6357 }
6358 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6359 }
6360 case 'v':
6361 {
6362 if (LocaleCompare("verbose",option+1) == 0)
6363 {
6364 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6365 break;
6366 }
6367 if ((LocaleCompare("version",option+1) == 0) ||
6368 (LocaleCompare("-version",option+1) == 0))
6369 {
6370 (void) fprintf(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00006371 GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00006372 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6373 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00006374 break;
6375 }
6376 if (LocaleCompare("view",option+1) == 0)
6377 {
6378 if (*option == '+')
6379 break;
6380 i++;
cristybb503372010-05-27 20:51:26 +00006381 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006382 ThrowMogrifyException(OptionError,"MissingArgument",option);
6383 break;
6384 }
6385 if (LocaleCompare("vignette",option+1) == 0)
6386 {
6387 if (*option == '+')
6388 break;
6389 i++;
cristybb503372010-05-27 20:51:26 +00006390 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006391 ThrowMogrifyException(OptionError,"MissingArgument",option);
6392 if (IsGeometry(argv[i]) == MagickFalse)
6393 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6394 break;
6395 }
6396 if (LocaleCompare("virtual-pixel",option+1) == 0)
6397 {
cristybb503372010-05-27 20:51:26 +00006398 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006399 method;
6400
6401 if (*option == '+')
6402 break;
6403 i++;
cristybb503372010-05-27 20:51:26 +00006404 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006405 ThrowMogrifyException(OptionError,"MissingArgument",option);
6406 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6407 argv[i]);
6408 if (method < 0)
6409 ThrowMogrifyException(OptionError,
6410 "UnrecognizedVirtualPixelMethod",argv[i]);
6411 break;
6412 }
6413 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6414 }
6415 case 'w':
6416 {
6417 if (LocaleCompare("wave",option+1) == 0)
6418 {
6419 i++;
cristybb503372010-05-27 20:51:26 +00006420 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006421 ThrowMogrifyException(OptionError,"MissingArgument",option);
6422 if (IsGeometry(argv[i]) == MagickFalse)
6423 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6424 break;
6425 }
6426 if (LocaleCompare("weight",option+1) == 0)
6427 {
6428 if (*option == '+')
6429 break;
6430 i++;
cristybb503372010-05-27 20:51:26 +00006431 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006432 ThrowMogrifyException(OptionError,"MissingArgument",option);
6433 break;
6434 }
6435 if (LocaleCompare("white-point",option+1) == 0)
6436 {
6437 if (*option == '+')
6438 break;
6439 i++;
cristybb503372010-05-27 20:51:26 +00006440 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006441 ThrowMogrifyException(OptionError,"MissingArgument",option);
6442 if (IsGeometry(argv[i]) == MagickFalse)
6443 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6444 break;
6445 }
6446 if (LocaleCompare("white-threshold",option+1) == 0)
6447 {
6448 if (*option == '+')
6449 break;
6450 i++;
cristybb503372010-05-27 20:51:26 +00006451 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006452 ThrowMogrifyException(OptionError,"MissingArgument",option);
6453 if (IsGeometry(argv[i]) == MagickFalse)
6454 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6455 break;
6456 }
6457 if (LocaleCompare("write",option+1) == 0)
6458 {
6459 i++;
cristybb503372010-05-27 20:51:26 +00006460 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006461 ThrowMogrifyException(OptionError,"MissingArgument",option);
6462 break;
6463 }
6464 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6465 }
6466 case '?':
6467 break;
6468 default:
6469 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6470 }
6471 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6472 MagickFalse : MagickTrue;
6473 if (fire != MagickFalse)
6474 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6475 }
6476 if (k != 0)
6477 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006478 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006479 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6480 DestroyMogrify();
6481 return(status != 0 ? MagickTrue : MagickFalse);
6482}
6483
6484/*
6485%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6486% %
6487% %
6488% %
6489+ M o g r i f y I m a g e I n f o %
6490% %
6491% %
6492% %
6493%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6494%
6495% MogrifyImageInfo() applies image processing settings to the image as
6496% prescribed by command line options.
6497%
6498% The format of the MogrifyImageInfo method is:
6499%
6500% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6501% const char **argv,ExceptionInfo *exception)
6502%
6503% A description of each parameter follows:
6504%
6505% o image_info: the image info..
6506%
6507% o argc: Specifies a pointer to an integer describing the number of
6508% elements in the argument vector.
6509%
6510% o argv: Specifies a pointer to a text array containing the command line
6511% arguments.
6512%
6513% o exception: return any errors or warnings in this structure.
6514%
6515*/
6516WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6517 const int argc,const char **argv,ExceptionInfo *exception)
6518{
6519 const char
6520 *option;
6521
6522 GeometryInfo
6523 geometry_info;
6524
cristybb503372010-05-27 20:51:26 +00006525 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006526 count;
6527
cristybb503372010-05-27 20:51:26 +00006528 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006529 i;
6530
6531 /*
6532 Initialize method variables.
6533 */
6534 assert(image_info != (ImageInfo *) NULL);
6535 assert(image_info->signature == MagickSignature);
6536 if (image_info->debug != MagickFalse)
6537 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6538 image_info->filename);
6539 if (argc < 0)
6540 return(MagickTrue);
6541 /*
6542 Set the image settings.
6543 */
cristybb503372010-05-27 20:51:26 +00006544 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006545 {
6546 option=argv[i];
6547 if (IsMagickOption(option) == MagickFalse)
6548 continue;
6549 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6550 0L);
cristycee97112010-05-28 00:44:52 +00006551 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006552 break;
6553 switch (*(option+1))
6554 {
6555 case 'a':
6556 {
6557 if (LocaleCompare("adjoin",option+1) == 0)
6558 {
6559 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6560 break;
6561 }
6562 if (LocaleCompare("antialias",option+1) == 0)
6563 {
6564 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6565 break;
6566 }
6567 if (LocaleCompare("attenuate",option+1) == 0)
6568 {
6569 if (*option == '+')
6570 {
6571 (void) DeleteImageOption(image_info,option+1);
6572 break;
6573 }
6574 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 break;
6576 }
6577 if (LocaleCompare("authenticate",option+1) == 0)
6578 {
6579 if (*option == '+')
6580 (void) CloneString(&image_info->authenticate,(char *) NULL);
6581 else
6582 (void) CloneString(&image_info->authenticate,argv[i+1]);
6583 break;
6584 }
6585 break;
6586 }
6587 case 'b':
6588 {
6589 if (LocaleCompare("background",option+1) == 0)
6590 {
6591 if (*option == '+')
6592 {
6593 (void) DeleteImageOption(image_info,option+1);
6594 (void) QueryColorDatabase(BackgroundColor,
6595 &image_info->background_color,exception);
6596 break;
6597 }
6598 (void) SetImageOption(image_info,option+1,argv[i+1]);
6599 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6600 exception);
6601 break;
6602 }
6603 if (LocaleCompare("bias",option+1) == 0)
6604 {
6605 if (*option == '+')
6606 {
6607 (void) SetImageOption(image_info,option+1,"0.0");
6608 break;
6609 }
6610 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 break;
6612 }
6613 if (LocaleCompare("black-point-compensation",option+1) == 0)
6614 {
6615 if (*option == '+')
6616 {
6617 (void) SetImageOption(image_info,option+1,"false");
6618 break;
6619 }
6620 (void) SetImageOption(image_info,option+1,"true");
6621 break;
6622 }
6623 if (LocaleCompare("blue-primary",option+1) == 0)
6624 {
6625 if (*option == '+')
6626 {
6627 (void) SetImageOption(image_info,option+1,"0.0");
6628 break;
6629 }
6630 (void) SetImageOption(image_info,option+1,argv[i+1]);
6631 break;
6632 }
6633 if (LocaleCompare("bordercolor",option+1) == 0)
6634 {
6635 if (*option == '+')
6636 {
6637 (void) DeleteImageOption(image_info,option+1);
6638 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6639 exception);
6640 break;
6641 }
6642 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6643 exception);
6644 (void) SetImageOption(image_info,option+1,argv[i+1]);
6645 break;
6646 }
6647 if (LocaleCompare("box",option+1) == 0)
6648 {
6649 if (*option == '+')
6650 {
6651 (void) SetImageOption(image_info,"undercolor","none");
6652 break;
6653 }
6654 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6655 break;
6656 }
6657 break;
6658 }
6659 case 'c':
6660 {
6661 if (LocaleCompare("cache",option+1) == 0)
6662 {
6663 MagickSizeType
6664 limit;
6665
6666 limit=MagickResourceInfinity;
6667 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006668 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006669 (void) SetMagickResourceLimit(MemoryResource,limit);
6670 (void) SetMagickResourceLimit(MapResource,2*limit);
6671 break;
6672 }
6673 if (LocaleCompare("caption",option+1) == 0)
6674 {
6675 if (*option == '+')
6676 {
6677 (void) DeleteImageOption(image_info,option+1);
6678 break;
6679 }
6680 (void) SetImageOption(image_info,option+1,argv[i+1]);
6681 break;
6682 }
6683 if (LocaleCompare("channel",option+1) == 0)
6684 {
6685 if (*option == '+')
6686 {
6687 image_info->channel=DefaultChannels;
6688 break;
6689 }
6690 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6691 break;
6692 }
6693 if (LocaleCompare("colors",option+1) == 0)
6694 {
cristye27293e2009-12-18 02:53:20 +00006695 image_info->colors=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006696 break;
6697 }
6698 if (LocaleCompare("colorspace",option+1) == 0)
6699 {
6700 if (*option == '+')
6701 {
6702 image_info->colorspace=UndefinedColorspace;
6703 (void) SetImageOption(image_info,option+1,"undefined");
6704 break;
6705 }
6706 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6707 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6708 (void) SetImageOption(image_info,option+1,argv[i+1]);
6709 break;
6710 }
6711 if (LocaleCompare("compress",option+1) == 0)
6712 {
6713 if (*option == '+')
6714 {
6715 image_info->compression=UndefinedCompression;
6716 (void) SetImageOption(image_info,option+1,"undefined");
6717 break;
6718 }
6719 image_info->compression=(CompressionType) ParseMagickOption(
6720 MagickCompressOptions,MagickFalse,argv[i+1]);
6721 (void) SetImageOption(image_info,option+1,argv[i+1]);
6722 break;
6723 }
6724 if (LocaleCompare("comment",option+1) == 0)
6725 {
6726 if (*option == '+')
6727 {
6728 (void) DeleteImageOption(image_info,option+1);
6729 break;
6730 }
6731 (void) SetImageOption(image_info,option+1,argv[i+1]);
6732 break;
6733 }
6734 if (LocaleCompare("compose",option+1) == 0)
6735 {
6736 if (*option == '+')
6737 {
6738 (void) SetImageOption(image_info,option+1,"undefined");
6739 break;
6740 }
6741 (void) SetImageOption(image_info,option+1,argv[i+1]);
6742 break;
6743 }
6744 if (LocaleCompare("compress",option+1) == 0)
6745 {
6746 if (*option == '+')
6747 {
6748 image_info->compression=UndefinedCompression;
6749 (void) SetImageOption(image_info,option+1,"undefined");
6750 break;
6751 }
6752 image_info->compression=(CompressionType) ParseMagickOption(
6753 MagickCompressOptions,MagickFalse,argv[i+1]);
6754 (void) SetImageOption(image_info,option+1,argv[i+1]);
6755 break;
6756 }
6757 break;
6758 }
6759 case 'd':
6760 {
6761 if (LocaleCompare("debug",option+1) == 0)
6762 {
6763 if (*option == '+')
6764 (void) SetLogEventMask("none");
6765 else
6766 (void) SetLogEventMask(argv[i+1]);
6767 image_info->debug=IsEventLogging();
6768 break;
6769 }
6770 if (LocaleCompare("define",option+1) == 0)
6771 {
6772 if (*option == '+')
6773 {
6774 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6775 (void) DeleteImageRegistry(argv[i+1]+9);
6776 else
6777 (void) DeleteImageOption(image_info,argv[i+1]);
6778 break;
6779 }
6780 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6781 {
6782 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6783 exception);
6784 break;
6785 }
6786 (void) DefineImageOption(image_info,argv[i+1]);
6787 break;
6788 }
6789 if (LocaleCompare("delay",option+1) == 0)
6790 {
6791 if (*option == '+')
6792 {
6793 (void) SetImageOption(image_info,option+1,"0");
6794 break;
6795 }
6796 (void) SetImageOption(image_info,option+1,argv[i+1]);
6797 break;
6798 }
6799 if (LocaleCompare("density",option+1) == 0)
6800 {
6801 /*
6802 Set image density.
6803 */
6804 if (*option == '+')
6805 {
6806 if (image_info->density != (char *) NULL)
6807 image_info->density=DestroyString(image_info->density);
6808 (void) SetImageOption(image_info,option+1,"72");
6809 break;
6810 }
6811 (void) CloneString(&image_info->density,argv[i+1]);
6812 (void) SetImageOption(image_info,option+1,argv[i+1]);
6813 break;
6814 }
6815 if (LocaleCompare("depth",option+1) == 0)
6816 {
6817 if (*option == '+')
6818 {
6819 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6820 break;
6821 }
cristye27293e2009-12-18 02:53:20 +00006822 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006823 break;
6824 }
cristyc9b12952010-03-28 01:12:28 +00006825 if (LocaleCompare("direction",option+1) == 0)
6826 {
6827 if (*option == '+')
6828 {
6829 (void) SetImageOption(image_info,option+1,"undefined");
6830 break;
6831 }
6832 (void) SetImageOption(image_info,option+1,argv[i+1]);
6833 break;
6834 }
cristy3ed852e2009-09-05 21:47:34 +00006835 if (LocaleCompare("display",option+1) == 0)
6836 {
6837 if (*option == '+')
6838 {
6839 if (image_info->server_name != (char *) NULL)
6840 image_info->server_name=DestroyString(
6841 image_info->server_name);
6842 break;
6843 }
6844 (void) CloneString(&image_info->server_name,argv[i+1]);
6845 break;
6846 }
6847 if (LocaleCompare("dispose",option+1) == 0)
6848 {
6849 if (*option == '+')
6850 {
6851 (void) SetImageOption(image_info,option+1,"undefined");
6852 break;
6853 }
6854 (void) SetImageOption(image_info,option+1,argv[i+1]);
6855 break;
6856 }
6857 if (LocaleCompare("dither",option+1) == 0)
6858 {
6859 if (*option == '+')
6860 {
6861 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006862 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006863 break;
6864 }
6865 (void) SetImageOption(image_info,option+1,argv[i+1]);
6866 image_info->dither=MagickTrue;
6867 break;
6868 }
6869 break;
6870 }
6871 case 'e':
6872 {
6873 if (LocaleCompare("encoding",option+1) == 0)
6874 {
6875 if (*option == '+')
6876 {
6877 (void) SetImageOption(image_info,option+1,"undefined");
6878 break;
6879 }
6880 (void) SetImageOption(image_info,option+1,argv[i+1]);
6881 break;
6882 }
6883 if (LocaleCompare("endian",option+1) == 0)
6884 {
6885 if (*option == '+')
6886 {
6887 image_info->endian=UndefinedEndian;
6888 (void) SetImageOption(image_info,option+1,"undefined");
6889 break;
6890 }
6891 image_info->endian=(EndianType) ParseMagickOption(
6892 MagickEndianOptions,MagickFalse,argv[i+1]);
6893 (void) SetImageOption(image_info,option+1,argv[i+1]);
6894 break;
6895 }
6896 if (LocaleCompare("extract",option+1) == 0)
6897 {
6898 /*
6899 Set image extract geometry.
6900 */
6901 if (*option == '+')
6902 {
6903 if (image_info->extract != (char *) NULL)
6904 image_info->extract=DestroyString(image_info->extract);
6905 break;
6906 }
6907 (void) CloneString(&image_info->extract,argv[i+1]);
6908 break;
6909 }
6910 break;
6911 }
6912 case 'f':
6913 {
6914 if (LocaleCompare("fill",option+1) == 0)
6915 {
6916 if (*option == '+')
6917 {
6918 (void) SetImageOption(image_info,option+1,"none");
6919 break;
6920 }
6921 (void) SetImageOption(image_info,option+1,argv[i+1]);
6922 break;
6923 }
6924 if (LocaleCompare("filter",option+1) == 0)
6925 {
6926 if (*option == '+')
6927 {
6928 (void) SetImageOption(image_info,option+1,"undefined");
6929 break;
6930 }
6931 (void) SetImageOption(image_info,option+1,argv[i+1]);
6932 break;
6933 }
6934 if (LocaleCompare("font",option+1) == 0)
6935 {
6936 if (*option == '+')
6937 {
6938 if (image_info->font != (char *) NULL)
6939 image_info->font=DestroyString(image_info->font);
6940 break;
6941 }
6942 (void) CloneString(&image_info->font,argv[i+1]);
6943 break;
6944 }
6945 if (LocaleCompare("format",option+1) == 0)
6946 {
6947 register const char
6948 *q;
6949
6950 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006951 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006952 image_info->ping=MagickFalse;
6953 (void) SetImageOption(image_info,option+1,argv[i+1]);
6954 break;
6955 }
6956 if (LocaleCompare("fuzz",option+1) == 0)
6957 {
6958 if (*option == '+')
6959 {
6960 image_info->fuzz=0.0;
6961 (void) SetImageOption(image_info,option+1,"0");
6962 break;
6963 }
cristyf2f27272009-12-17 14:48:46 +00006964 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006965 1.0);
6966 (void) SetImageOption(image_info,option+1,argv[i+1]);
6967 break;
6968 }
6969 break;
6970 }
6971 case 'g':
6972 {
6973 if (LocaleCompare("gravity",option+1) == 0)
6974 {
6975 if (*option == '+')
6976 {
6977 (void) SetImageOption(image_info,option+1,"undefined");
6978 break;
6979 }
6980 (void) SetImageOption(image_info,option+1,argv[i+1]);
6981 break;
6982 }
6983 if (LocaleCompare("green-primary",option+1) == 0)
6984 {
6985 if (*option == '+')
6986 {
6987 (void) SetImageOption(image_info,option+1,"0.0");
6988 break;
6989 }
6990 (void) SetImageOption(image_info,option+1,argv[i+1]);
6991 break;
6992 }
6993 break;
6994 }
6995 case 'i':
6996 {
6997 if (LocaleCompare("intent",option+1) == 0)
6998 {
6999 if (*option == '+')
7000 {
7001 (void) SetImageOption(image_info,option+1,"undefined");
7002 break;
7003 }
7004 (void) SetImageOption(image_info,option+1,argv[i+1]);
7005 break;
7006 }
7007 if (LocaleCompare("interlace",option+1) == 0)
7008 {
7009 if (*option == '+')
7010 {
7011 image_info->interlace=UndefinedInterlace;
7012 (void) SetImageOption(image_info,option+1,"undefined");
7013 break;
7014 }
7015 image_info->interlace=(InterlaceType) ParseMagickOption(
7016 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7017 (void) SetImageOption(image_info,option+1,argv[i+1]);
7018 break;
7019 }
cristyb32b90a2009-09-07 21:45:48 +00007020 if (LocaleCompare("interline-spacing",option+1) == 0)
7021 {
7022 if (*option == '+')
7023 {
7024 (void) SetImageOption(image_info,option+1,"undefined");
7025 break;
7026 }
7027 (void) SetImageOption(image_info,option+1,argv[i+1]);
7028 break;
7029 }
cristy3ed852e2009-09-05 21:47:34 +00007030 if (LocaleCompare("interpolate",option+1) == 0)
7031 {
7032 if (*option == '+')
7033 {
7034 (void) SetImageOption(image_info,option+1,"undefined");
7035 break;
7036 }
7037 (void) SetImageOption(image_info,option+1,argv[i+1]);
7038 break;
7039 }
7040 if (LocaleCompare("interword-spacing",option+1) == 0)
7041 {
7042 if (*option == '+')
7043 {
7044 (void) SetImageOption(image_info,option+1,"undefined");
7045 break;
7046 }
7047 (void) SetImageOption(image_info,option+1,argv[i+1]);
7048 break;
7049 }
7050 break;
7051 }
7052 case 'k':
7053 {
7054 if (LocaleCompare("kerning",option+1) == 0)
7055 {
7056 if (*option == '+')
7057 {
7058 (void) SetImageOption(image_info,option+1,"undefined");
7059 break;
7060 }
7061 (void) SetImageOption(image_info,option+1,argv[i+1]);
7062 break;
7063 }
7064 break;
7065 }
7066 case 'l':
7067 {
7068 if (LocaleCompare("label",option+1) == 0)
7069 {
7070 if (*option == '+')
7071 {
7072 (void) DeleteImageOption(image_info,option+1);
7073 break;
7074 }
7075 (void) SetImageOption(image_info,option+1,argv[i+1]);
7076 break;
7077 }
7078 if (LocaleCompare("limit",option+1) == 0)
7079 {
7080 MagickSizeType
7081 limit;
7082
7083 ResourceType
7084 type;
7085
7086 if (*option == '+')
7087 break;
7088 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
7089 MagickFalse,argv[i+1]);
7090 limit=MagickResourceInfinity;
7091 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00007092 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00007093 (void) SetMagickResourceLimit(type,limit);
7094 break;
7095 }
7096 if (LocaleCompare("list",option+1) == 0)
7097 {
cristybb503372010-05-27 20:51:26 +00007098 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007099 list;
7100
7101 /*
7102 Display configuration list.
7103 */
7104 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
7105 switch (list)
7106 {
7107 case MagickCoderOptions:
7108 {
7109 (void) ListCoderInfo((FILE *) NULL,exception);
7110 break;
7111 }
7112 case MagickColorOptions:
7113 {
7114 (void) ListColorInfo((FILE *) NULL,exception);
7115 break;
7116 }
7117 case MagickConfigureOptions:
7118 {
7119 (void) ListConfigureInfo((FILE *) NULL,exception);
7120 break;
7121 }
7122 case MagickDelegateOptions:
7123 {
7124 (void) ListDelegateInfo((FILE *) NULL,exception);
7125 break;
7126 }
7127 case MagickFontOptions:
7128 {
7129 (void) ListTypeInfo((FILE *) NULL,exception);
7130 break;
7131 }
7132 case MagickFormatOptions:
7133 {
7134 (void) ListMagickInfo((FILE *) NULL,exception);
7135 break;
7136 }
7137 case MagickLocaleOptions:
7138 {
7139 (void) ListLocaleInfo((FILE *) NULL,exception);
7140 break;
7141 }
7142 case MagickLogOptions:
7143 {
7144 (void) ListLogInfo((FILE *) NULL,exception);
7145 break;
7146 }
7147 case MagickMagicOptions:
7148 {
7149 (void) ListMagicInfo((FILE *) NULL,exception);
7150 break;
7151 }
7152 case MagickMimeOptions:
7153 {
7154 (void) ListMimeInfo((FILE *) NULL,exception);
7155 break;
7156 }
7157 case MagickModuleOptions:
7158 {
7159 (void) ListModuleInfo((FILE *) NULL,exception);
7160 break;
7161 }
7162 case MagickPolicyOptions:
7163 {
7164 (void) ListPolicyInfo((FILE *) NULL,exception);
7165 break;
7166 }
7167 case MagickResourceOptions:
7168 {
7169 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7170 break;
7171 }
7172 case MagickThresholdOptions:
7173 {
7174 (void) ListThresholdMaps((FILE *) NULL,exception);
7175 break;
7176 }
7177 default:
7178 {
7179 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7180 exception);
7181 break;
7182 }
7183 }
cristyaeb2cbc2010-05-07 13:28:58 +00007184 break;
cristy3ed852e2009-09-05 21:47:34 +00007185 }
7186 if (LocaleCompare("log",option+1) == 0)
7187 {
7188 if (*option == '+')
7189 break;
7190 (void) SetLogFormat(argv[i+1]);
7191 break;
7192 }
7193 if (LocaleCompare("loop",option+1) == 0)
7194 {
7195 if (*option == '+')
7196 {
7197 (void) SetImageOption(image_info,option+1,"0");
7198 break;
7199 }
7200 (void) SetImageOption(image_info,option+1,argv[i+1]);
7201 break;
7202 }
7203 break;
7204 }
7205 case 'm':
7206 {
7207 if (LocaleCompare("matte",option+1) == 0)
7208 {
7209 if (*option == '+')
7210 {
7211 (void) SetImageOption(image_info,option+1,"false");
7212 break;
7213 }
7214 (void) SetImageOption(image_info,option+1,"true");
7215 break;
7216 }
7217 if (LocaleCompare("mattecolor",option+1) == 0)
7218 {
7219 if (*option == '+')
7220 {
7221 (void) SetImageOption(image_info,option+1,argv[i+1]);
7222 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7223 exception);
7224 break;
7225 }
7226 (void) SetImageOption(image_info,option+1,argv[i+1]);
7227 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7228 exception);
7229 break;
7230 }
7231 if (LocaleCompare("monitor",option+1) == 0)
7232 {
7233 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7234 (void *) NULL);
7235 break;
7236 }
7237 if (LocaleCompare("monochrome",option+1) == 0)
7238 {
7239 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7240 break;
7241 }
7242 break;
7243 }
7244 case 'o':
7245 {
7246 if (LocaleCompare("orient",option+1) == 0)
7247 {
7248 if (*option == '+')
7249 {
7250 image_info->orientation=UndefinedOrientation;
7251 (void) SetImageOption(image_info,option+1,"undefined");
7252 break;
7253 }
7254 image_info->orientation=(OrientationType) ParseMagickOption(
7255 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00007256 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007257 break;
7258 }
7259 }
7260 case 'p':
7261 {
7262 if (LocaleCompare("page",option+1) == 0)
7263 {
7264 char
7265 *canonical_page,
7266 page[MaxTextExtent];
7267
7268 const char
7269 *image_option;
7270
7271 MagickStatusType
7272 flags;
7273
7274 RectangleInfo
7275 geometry;
7276
7277 if (*option == '+')
7278 {
7279 (void) DeleteImageOption(image_info,option+1);
7280 (void) CloneString(&image_info->page,(char *) NULL);
7281 break;
7282 }
7283 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7284 image_option=GetImageOption(image_info,"page");
7285 if (image_option != (const char *) NULL)
7286 flags=ParseAbsoluteGeometry(image_option,&geometry);
7287 canonical_page=GetPageGeometry(argv[i+1]);
7288 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7289 canonical_page=DestroyString(canonical_page);
7290 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00007291 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00007292 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7293 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00007294 (unsigned long) geometry.width,(unsigned long) geometry.height,
7295 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00007296 (void) SetImageOption(image_info,option+1,page);
7297 (void) CloneString(&image_info->page,page);
7298 break;
7299 }
7300 if (LocaleCompare("pen",option+1) == 0)
7301 {
7302 if (*option == '+')
7303 {
7304 (void) SetImageOption(image_info,option+1,"none");
7305 break;
7306 }
7307 (void) SetImageOption(image_info,option+1,argv[i+1]);
7308 break;
7309 }
7310 if (LocaleCompare("ping",option+1) == 0)
7311 {
7312 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7313 break;
7314 }
7315 if (LocaleCompare("pointsize",option+1) == 0)
7316 {
7317 if (*option == '+')
7318 geometry_info.rho=0.0;
7319 else
7320 (void) ParseGeometry(argv[i+1],&geometry_info);
7321 image_info->pointsize=geometry_info.rho;
7322 break;
7323 }
cristye7f51092010-01-17 00:39:37 +00007324 if (LocaleCompare("precision",option+1) == 0)
7325 {
cristybf2766a2010-01-17 03:33:23 +00007326 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00007327 break;
7328 }
cristy3ed852e2009-09-05 21:47:34 +00007329 if (LocaleCompare("preview",option+1) == 0)
7330 {
7331 /*
7332 Preview image.
7333 */
7334 if (*option == '+')
7335 {
7336 image_info->preview_type=UndefinedPreview;
7337 break;
7338 }
7339 image_info->preview_type=(PreviewType) ParseMagickOption(
7340 MagickPreviewOptions,MagickFalse,argv[i+1]);
7341 break;
7342 }
7343 break;
7344 }
7345 case 'q':
7346 {
7347 if (LocaleCompare("quality",option+1) == 0)
7348 {
7349 /*
7350 Set image compression quality.
7351 */
7352 if (*option == '+')
7353 {
7354 image_info->quality=UndefinedCompressionQuality;
7355 (void) SetImageOption(image_info,option+1,"0");
7356 break;
7357 }
cristye27293e2009-12-18 02:53:20 +00007358 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007359 (void) SetImageOption(image_info,option+1,argv[i+1]);
7360 break;
7361 }
7362 if (LocaleCompare("quiet",option+1) == 0)
7363 {
7364 static WarningHandler
7365 warning_handler = (WarningHandler) NULL;
7366
7367 if (*option == '+')
7368 {
7369 /*
7370 Restore error or warning messages.
7371 */
7372 warning_handler=SetWarningHandler(warning_handler);
7373 break;
7374 }
7375 /*
7376 Suppress error or warning messages.
7377 */
7378 warning_handler=SetWarningHandler((WarningHandler) NULL);
7379 break;
7380 }
7381 break;
7382 }
7383 case 'r':
7384 {
7385 if (LocaleCompare("red-primary",option+1) == 0)
7386 {
7387 if (*option == '+')
7388 {
7389 (void) SetImageOption(image_info,option+1,"0.0");
7390 break;
7391 }
7392 (void) SetImageOption(image_info,option+1,argv[i+1]);
7393 break;
7394 }
7395 break;
7396 }
7397 case 's':
7398 {
7399 if (LocaleCompare("sampling-factor",option+1) == 0)
7400 {
7401 /*
7402 Set image sampling factor.
7403 */
7404 if (*option == '+')
7405 {
7406 if (image_info->sampling_factor != (char *) NULL)
7407 image_info->sampling_factor=DestroyString(
7408 image_info->sampling_factor);
7409 break;
7410 }
7411 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7412 break;
7413 }
7414 if (LocaleCompare("scene",option+1) == 0)
7415 {
7416 /*
7417 Set image scene.
7418 */
7419 if (*option == '+')
7420 {
7421 image_info->scene=0;
7422 (void) SetImageOption(image_info,option+1,"0");
7423 break;
7424 }
cristye27293e2009-12-18 02:53:20 +00007425 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007426 (void) SetImageOption(image_info,option+1,argv[i+1]);
7427 break;
7428 }
7429 if (LocaleCompare("seed",option+1) == 0)
7430 {
cristybb503372010-05-27 20:51:26 +00007431 size_t
cristy3ed852e2009-09-05 21:47:34 +00007432 seed;
7433
7434 if (*option == '+')
7435 {
cristybb503372010-05-27 20:51:26 +00007436 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007437 SeedPseudoRandomGenerator(seed);
7438 break;
7439 }
cristye27293e2009-12-18 02:53:20 +00007440 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007441 SeedPseudoRandomGenerator(seed);
7442 break;
7443 }
7444 if (LocaleCompare("size",option+1) == 0)
7445 {
7446 if (*option == '+')
7447 {
7448 if (image_info->size != (char *) NULL)
7449 image_info->size=DestroyString(image_info->size);
7450 break;
7451 }
7452 (void) CloneString(&image_info->size,argv[i+1]);
7453 break;
7454 }
7455 if (LocaleCompare("stroke",option+1) == 0)
7456 {
7457 if (*option == '+')
7458 {
7459 (void) SetImageOption(image_info,option+1,"none");
7460 break;
7461 }
7462 (void) SetImageOption(image_info,option+1,argv[i+1]);
7463 break;
7464 }
7465 if (LocaleCompare("strokewidth",option+1) == 0)
7466 {
7467 if (*option == '+')
7468 {
7469 (void) SetImageOption(image_info,option+1,"0");
7470 break;
7471 }
7472 (void) SetImageOption(image_info,option+1,argv[i+1]);
7473 break;
7474 }
cristyd9a29192010-10-16 16:49:53 +00007475 if (LocaleCompare("synchronize",option+1) == 0)
7476 {
7477 if (*option == '+')
7478 {
7479 image_info->synchronize=MagickFalse;
7480 break;
7481 }
7482 image_info->synchronize=MagickTrue;
7483 break;
7484 }
cristy3ed852e2009-09-05 21:47:34 +00007485 break;
7486 }
7487 case 't':
7488 {
7489 if (LocaleCompare("taint",option+1) == 0)
7490 {
7491 if (*option == '+')
7492 {
7493 (void) SetImageOption(image_info,option+1,"false");
7494 break;
7495 }
7496 (void) SetImageOption(image_info,option+1,"true");
7497 break;
7498 }
7499 if (LocaleCompare("texture",option+1) == 0)
7500 {
7501 if (*option == '+')
7502 {
7503 if (image_info->texture != (char *) NULL)
7504 image_info->texture=DestroyString(image_info->texture);
7505 break;
7506 }
7507 (void) CloneString(&image_info->texture,argv[i+1]);
7508 break;
7509 }
7510 if (LocaleCompare("tile-offset",option+1) == 0)
7511 {
7512 if (*option == '+')
7513 {
7514 (void) SetImageOption(image_info,option+1,"0");
7515 break;
7516 }
7517 (void) SetImageOption(image_info,option+1,argv[i+1]);
7518 break;
7519 }
7520 if (LocaleCompare("transparent-color",option+1) == 0)
7521 {
7522 if (*option == '+')
7523 {
7524 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7525 (void) SetImageOption(image_info,option+1,"none");
7526 break;
7527 }
7528 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7529 exception);
7530 (void) SetImageOption(image_info,option+1,argv[i+1]);
7531 break;
7532 }
7533 if (LocaleCompare("type",option+1) == 0)
7534 {
7535 if (*option == '+')
7536 {
cristy5f1c1ff2010-12-23 21:38:06 +00007537 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007538 (void) SetImageOption(image_info,option+1,"undefined");
7539 break;
7540 }
7541 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7542 MagickFalse,argv[i+1]);
7543 (void) SetImageOption(image_info,option+1,argv[i+1]);
7544 break;
7545 }
7546 break;
7547 }
7548 case 'u':
7549 {
7550 if (LocaleCompare("undercolor",option+1) == 0)
7551 {
7552 if (*option == '+')
7553 {
7554 (void) DeleteImageOption(image_info,option+1);
7555 break;
7556 }
7557 (void) SetImageOption(image_info,option+1,argv[i+1]);
7558 break;
7559 }
7560 if (LocaleCompare("units",option+1) == 0)
7561 {
7562 if (*option == '+')
7563 {
7564 image_info->units=UndefinedResolution;
7565 (void) SetImageOption(image_info,option+1,"undefined");
7566 break;
7567 }
7568 image_info->units=(ResolutionType) ParseMagickOption(
7569 MagickResolutionOptions,MagickFalse,argv[i+1]);
7570 (void) SetImageOption(image_info,option+1,argv[i+1]);
7571 break;
7572 }
7573 break;
7574 }
7575 case 'v':
7576 {
7577 if (LocaleCompare("verbose",option+1) == 0)
7578 {
7579 if (*option == '+')
7580 {
7581 image_info->verbose=MagickFalse;
7582 break;
7583 }
7584 image_info->verbose=MagickTrue;
7585 image_info->ping=MagickFalse;
7586 break;
7587 }
7588 if (LocaleCompare("view",option+1) == 0)
7589 {
7590 if (*option == '+')
7591 {
7592 if (image_info->view != (char *) NULL)
7593 image_info->view=DestroyString(image_info->view);
7594 break;
7595 }
7596 (void) CloneString(&image_info->view,argv[i+1]);
7597 break;
7598 }
7599 if (LocaleCompare("virtual-pixel",option+1) == 0)
7600 {
7601 if (*option == '+')
7602 {
7603 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7604 (void) SetImageOption(image_info,option+1,"undefined");
7605 break;
7606 }
7607 image_info->virtual_pixel_method=(VirtualPixelMethod)
7608 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7609 argv[i+1]);
7610 (void) SetImageOption(image_info,option+1,argv[i+1]);
7611 break;
7612 }
7613 break;
7614 }
7615 case 'w':
7616 {
7617 if (LocaleCompare("white-point",option+1) == 0)
7618 {
7619 if (*option == '+')
7620 {
7621 (void) SetImageOption(image_info,option+1,"0.0");
7622 break;
7623 }
7624 (void) SetImageOption(image_info,option+1,argv[i+1]);
7625 break;
7626 }
7627 break;
7628 }
7629 default:
7630 break;
7631 }
7632 i+=count;
7633 }
7634 return(MagickTrue);
7635}
7636
7637/*
7638%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7639% %
7640% %
7641% %
7642+ M o g r i f y I m a g e L i s t %
7643% %
7644% %
7645% %
7646%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7647%
7648% MogrifyImageList() applies any command line options that might affect the
7649% entire image list (e.g. -append, -coalesce, etc.).
7650%
7651% The format of the MogrifyImage method is:
7652%
7653% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7654% const char **argv,Image **images,ExceptionInfo *exception)
7655%
7656% A description of each parameter follows:
7657%
7658% o image_info: the image info..
7659%
7660% o argc: Specifies a pointer to an integer describing the number of
7661% elements in the argument vector.
7662%
7663% o argv: Specifies a pointer to a text array containing the command line
7664% arguments.
7665%
7666% o images: the images.
7667%
7668% o exception: return any errors or warnings in this structure.
7669%
7670*/
7671WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7672 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7673{
7674 ChannelType
7675 channel;
7676
7677 const char
7678 *option;
7679
cristy6b3da3a2010-06-20 02:21:46 +00007680 ImageInfo
7681 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007682
7683 MagickStatusType
7684 status;
7685
7686 QuantizeInfo
7687 *quantize_info;
7688
cristybb503372010-05-27 20:51:26 +00007689 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007690 i;
7691
cristy6b3da3a2010-06-20 02:21:46 +00007692 ssize_t
7693 count,
7694 index;
7695
cristy3ed852e2009-09-05 21:47:34 +00007696 /*
7697 Apply options to the image list.
7698 */
7699 assert(image_info != (ImageInfo *) NULL);
7700 assert(image_info->signature == MagickSignature);
7701 assert(images != (Image **) NULL);
7702 assert((*images)->signature == MagickSignature);
7703 if ((*images)->debug != MagickFalse)
7704 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7705 (*images)->filename);
7706 if ((argc <= 0) || (*argv == (char *) NULL))
7707 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +00007708 mogrify_info=CloneImageInfo(image_info);
7709 quantize_info=AcquireQuantizeInfo(mogrify_info);
7710 channel=mogrify_info->channel;
cristy3ed852e2009-09-05 21:47:34 +00007711 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007712 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007713 {
cristy74fe8f12009-10-03 19:09:01 +00007714 if (*images == (Image *) NULL)
7715 break;
cristy3ed852e2009-09-05 21:47:34 +00007716 option=argv[i];
7717 if (IsMagickOption(option) == MagickFalse)
7718 continue;
7719 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7720 0L);
cristycee97112010-05-28 00:44:52 +00007721 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007722 break;
cristy6b3da3a2010-06-20 02:21:46 +00007723 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007724 switch (*(option+1))
7725 {
7726 case 'a':
7727 {
7728 if (LocaleCompare("affinity",option+1) == 0)
7729 {
cristy6b3da3a2010-06-20 02:21:46 +00007730 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007731 if (*option == '+')
7732 {
7733 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7734 InheritException(exception,&(*images)->exception);
7735 break;
7736 }
7737 i++;
7738 break;
7739 }
7740 if (LocaleCompare("append",option+1) == 0)
7741 {
7742 Image
7743 *append_image;
7744
cristy6b3da3a2010-06-20 02:21:46 +00007745 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007746 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7747 MagickFalse,exception);
7748 if (append_image == (Image *) NULL)
7749 {
7750 status=MagickFalse;
7751 break;
7752 }
7753 *images=DestroyImageList(*images);
7754 *images=append_image;
7755 break;
7756 }
7757 if (LocaleCompare("average",option+1) == 0)
7758 {
7759 Image
7760 *average_image;
7761
cristyd18ae7c2010-03-07 17:39:52 +00007762 /*
7763 Average an image sequence (deprecated).
7764 */
cristy6b3da3a2010-06-20 02:21:46 +00007765 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007766 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7767 exception);
cristy3ed852e2009-09-05 21:47:34 +00007768 if (average_image == (Image *) NULL)
7769 {
7770 status=MagickFalse;
7771 break;
7772 }
7773 *images=DestroyImageList(*images);
7774 *images=average_image;
7775 break;
7776 }
7777 break;
7778 }
7779 case 'c':
7780 {
7781 if (LocaleCompare("channel",option+1) == 0)
7782 {
7783 if (*option == '+')
7784 {
7785 channel=DefaultChannels;
7786 break;
7787 }
7788 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7789 break;
7790 }
7791 if (LocaleCompare("clut",option+1) == 0)
7792 {
7793 Image
7794 *clut_image,
7795 *image;
7796
cristy6b3da3a2010-06-20 02:21:46 +00007797 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007798 image=RemoveFirstImageFromList(images);
7799 clut_image=RemoveFirstImageFromList(images);
7800 if (clut_image == (Image *) NULL)
7801 {
7802 status=MagickFalse;
7803 break;
7804 }
7805 (void) ClutImageChannel(image,channel,clut_image);
7806 clut_image=DestroyImage(clut_image);
7807 InheritException(exception,&image->exception);
7808 *images=DestroyImageList(*images);
7809 *images=image;
7810 break;
7811 }
7812 if (LocaleCompare("coalesce",option+1) == 0)
7813 {
7814 Image
7815 *coalesce_image;
7816
cristy6b3da3a2010-06-20 02:21:46 +00007817 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007818 coalesce_image=CoalesceImages(*images,exception);
7819 if (coalesce_image == (Image *) NULL)
7820 {
7821 status=MagickFalse;
7822 break;
7823 }
7824 *images=DestroyImageList(*images);
7825 *images=coalesce_image;
7826 break;
7827 }
7828 if (LocaleCompare("combine",option+1) == 0)
7829 {
7830 Image
7831 *combine_image;
7832
cristy6b3da3a2010-06-20 02:21:46 +00007833 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007834 combine_image=CombineImages(*images,channel,exception);
7835 if (combine_image == (Image *) NULL)
7836 {
7837 status=MagickFalse;
7838 break;
7839 }
7840 *images=DestroyImageList(*images);
7841 *images=combine_image;
7842 break;
7843 }
7844 if (LocaleCompare("composite",option+1) == 0)
7845 {
7846 Image
7847 *mask_image,
7848 *composite_image,
7849 *image;
7850
7851 RectangleInfo
7852 geometry;
7853
cristy6b3da3a2010-06-20 02:21:46 +00007854 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007855 image=RemoveFirstImageFromList(images);
7856 composite_image=RemoveFirstImageFromList(images);
7857 if (composite_image == (Image *) NULL)
7858 {
7859 status=MagickFalse;
7860 break;
7861 }
7862 (void) TransformImage(&composite_image,(char *) NULL,
7863 composite_image->geometry);
7864 SetGeometry(composite_image,&geometry);
7865 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7866 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7867 &geometry);
7868 mask_image=RemoveFirstImageFromList(images);
7869 if (mask_image != (Image *) NULL)
7870 {
7871 if ((image->compose == DisplaceCompositeOp) ||
7872 (image->compose == DistortCompositeOp))
7873 {
7874 /*
7875 Merge Y displacement into X displacement image.
7876 */
7877 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7878 mask_image,0,0);
7879 mask_image=DestroyImage(mask_image);
7880 }
7881 else
7882 {
7883 /*
7884 Set a blending mask for the composition.
7885 */
7886 image->mask=mask_image;
7887 (void) NegateImage(image->mask,MagickFalse);
7888 }
7889 }
7890 (void) CompositeImageChannel(image,channel,image->compose,
7891 composite_image,geometry.x,geometry.y);
7892 if (image->mask != (Image *) NULL)
7893 image->mask=DestroyImage(image->mask);
7894 composite_image=DestroyImage(composite_image);
7895 InheritException(exception,&image->exception);
7896 *images=DestroyImageList(*images);
7897 *images=image;
7898 break;
7899 }
7900 if (LocaleCompare("crop",option+1) == 0)
7901 {
7902 MagickStatusType
7903 flags;
7904
7905 RectangleInfo
7906 geometry;
7907
cristy6b3da3a2010-06-20 02:21:46 +00007908 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007909 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7910 if (((geometry.width == 0) && (geometry.height == 0)) ||
7911 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7912 break;
7913 (void) TransformImages(images,argv[i+1],(char *) NULL);
7914 InheritException(exception,&(*images)->exception);
7915 break;
7916 }
7917 break;
7918 }
7919 case 'd':
7920 {
7921 if (LocaleCompare("deconstruct",option+1) == 0)
7922 {
7923 Image
7924 *deconstruct_image;
7925
cristy6b3da3a2010-06-20 02:21:46 +00007926 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007927 deconstruct_image=DeconstructImages(*images,exception);
7928 if (deconstruct_image == (Image *) NULL)
7929 {
7930 status=MagickFalse;
7931 break;
7932 }
7933 *images=DestroyImageList(*images);
7934 *images=deconstruct_image;
7935 break;
7936 }
7937 if (LocaleCompare("delete",option+1) == 0)
7938 {
7939 if (*option == '+')
7940 DeleteImages(images,"-1",exception);
7941 else
7942 DeleteImages(images,argv[i+1],exception);
7943 break;
7944 }
7945 if (LocaleCompare("dither",option+1) == 0)
7946 {
7947 if (*option == '+')
7948 {
7949 quantize_info->dither=MagickFalse;
7950 break;
7951 }
7952 quantize_info->dither=MagickTrue;
7953 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7954 MagickDitherOptions,MagickFalse,argv[i+1]);
7955 break;
7956 }
cristyecb10ff2011-03-22 13:14:03 +00007957 if (LocaleCompare("duplicate",option+1) == 0)
7958 {
cristybf95deb2011-03-23 00:25:36 +00007959 size_t
7960 number_duplicates;
7961
anthony9bd15492011-03-23 02:11:13 +00007962 char
7963 *p;
7964
7965 if (*option == '+') {
7966 AppendImageToList(images,DuplicateImages(*images,1,"-1",
7967 exception));
7968 break;
7969 }
7970 number_duplicates=(size_t) StringToLong(argv[i+1]);
7971 if ( (p=strchr(argv[i+1],',')) != (char *)NULL )
7972 AppendImageToList(images,DuplicateImages(*images,
7973 number_duplicates,p,exception));
cristybf95deb2011-03-23 00:25:36 +00007974 else
anthony9bd15492011-03-23 02:11:13 +00007975 AppendImageToList(images,DuplicateImages(*images,
7976 number_duplicates,"-1",exception));
cristyecb10ff2011-03-22 13:14:03 +00007977 break;
7978 }
cristy3ed852e2009-09-05 21:47:34 +00007979 break;
7980 }
cristyd18ae7c2010-03-07 17:39:52 +00007981 case 'e':
7982 {
7983 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7984 {
7985 Image
7986 *evaluate_image;
7987
7988 MagickEvaluateOperator
7989 op;
7990
cristy6b3da3a2010-06-20 02:21:46 +00007991 (void) SyncImageSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007992 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
7993 MagickFalse,argv[i+1]);
7994 evaluate_image=EvaluateImages(*images,op,exception);
7995 if (evaluate_image == (Image *) NULL)
7996 {
7997 status=MagickFalse;
7998 break;
7999 }
8000 *images=DestroyImageList(*images);
8001 *images=evaluate_image;
8002 break;
8003 }
8004 break;
8005 }
cristy3ed852e2009-09-05 21:47:34 +00008006 case 'f':
8007 {
cristyf0a247f2009-10-04 00:20:03 +00008008 if (LocaleCompare("fft",option+1) == 0)
8009 {
8010 Image
8011 *fourier_image;
8012
8013 /*
8014 Implements the discrete Fourier transform (DFT).
8015 */
cristy6b3da3a2010-06-20 02:21:46 +00008016 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00008017 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8018 MagickTrue : MagickFalse,exception);
8019 if (fourier_image == (Image *) NULL)
8020 break;
8021 *images=DestroyImage(*images);
8022 *images=fourier_image;
8023 break;
8024 }
cristy3ed852e2009-09-05 21:47:34 +00008025 if (LocaleCompare("flatten",option+1) == 0)
8026 {
8027 Image
8028 *flatten_image;
8029
cristy6b3da3a2010-06-20 02:21:46 +00008030 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008031 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8032 if (flatten_image == (Image *) NULL)
8033 break;
8034 *images=DestroyImageList(*images);
8035 *images=flatten_image;
8036 break;
8037 }
8038 if (LocaleCompare("fx",option+1) == 0)
8039 {
8040 Image
8041 *fx_image;
8042
cristy6b3da3a2010-06-20 02:21:46 +00008043 (void) SyncImagesSettings(mogrify_info,*images);
anthony1e4df872011-03-19 14:10:59 +00008044 PageIndexImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008045 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8046 if (fx_image == (Image *) NULL)
8047 {
8048 status=MagickFalse;
8049 break;
8050 }
8051 *images=DestroyImageList(*images);
8052 *images=fx_image;
8053 break;
8054 }
8055 break;
8056 }
8057 case 'h':
8058 {
8059 if (LocaleCompare("hald-clut",option+1) == 0)
8060 {
8061 Image
8062 *hald_image,
8063 *image;
8064
cristy6b3da3a2010-06-20 02:21:46 +00008065 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008066 image=RemoveFirstImageFromList(images);
8067 hald_image=RemoveFirstImageFromList(images);
8068 if (hald_image == (Image *) NULL)
8069 {
8070 status=MagickFalse;
8071 break;
8072 }
8073 (void) HaldClutImageChannel(image,channel,hald_image);
8074 hald_image=DestroyImage(hald_image);
8075 InheritException(exception,&image->exception);
cristy0aff6ea2009-11-14 01:40:53 +00008076 if (*images != (Image *) NULL)
8077 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008078 *images=image;
8079 break;
8080 }
8081 break;
8082 }
8083 case 'i':
8084 {
8085 if (LocaleCompare("ift",option+1) == 0)
8086 {
8087 Image
cristy8587f882009-11-13 20:28:49 +00008088 *fourier_image,
8089 *magnitude_image,
8090 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00008091
8092 /*
8093 Implements the inverse fourier discrete Fourier transform (DFT).
8094 */
cristy6b3da3a2010-06-20 02:21:46 +00008095 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00008096 magnitude_image=RemoveFirstImageFromList(images);
8097 phase_image=RemoveFirstImageFromList(images);
8098 if (phase_image == (Image *) NULL)
8099 {
8100 status=MagickFalse;
8101 break;
8102 }
8103 fourier_image=InverseFourierTransformImage(magnitude_image,
8104 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00008105 if (fourier_image == (Image *) NULL)
8106 break;
cristy0aff6ea2009-11-14 01:40:53 +00008107 if (*images != (Image *) NULL)
8108 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00008109 *images=fourier_image;
8110 break;
8111 }
8112 if (LocaleCompare("insert",option+1) == 0)
8113 {
8114 Image
8115 *p,
8116 *q;
8117
8118 index=0;
8119 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00008120 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00008121 p=RemoveLastImageFromList(images);
8122 if (p == (Image *) NULL)
8123 {
8124 (void) ThrowMagickException(exception,GetMagickModule(),
8125 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8126 status=MagickFalse;
8127 break;
8128 }
8129 q=p;
8130 if (index == 0)
8131 PrependImageToList(images,q);
8132 else
cristybb503372010-05-27 20:51:26 +00008133 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00008134 AppendImageToList(images,q);
8135 else
8136 {
8137 q=GetImageFromList(*images,index-1);
8138 if (q == (Image *) NULL)
8139 {
8140 (void) ThrowMagickException(exception,GetMagickModule(),
8141 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8142 status=MagickFalse;
8143 break;
8144 }
8145 InsertImageInList(&q,p);
8146 }
8147 *images=GetFirstImageInList(q);
8148 break;
8149 }
8150 break;
8151 }
8152 case 'l':
8153 {
8154 if (LocaleCompare("layers",option+1) == 0)
8155 {
8156 Image
8157 *layers;
8158
8159 ImageLayerMethod
8160 method;
8161
cristy6b3da3a2010-06-20 02:21:46 +00008162 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008163 layers=(Image *) NULL;
8164 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
8165 MagickFalse,argv[i+1]);
8166 switch (method)
8167 {
8168 case CoalesceLayer:
8169 {
8170 layers=CoalesceImages(*images,exception);
8171 break;
8172 }
8173 case CompareAnyLayer:
8174 case CompareClearLayer:
8175 case CompareOverlayLayer:
8176 default:
8177 {
8178 layers=CompareImageLayers(*images,method,exception);
8179 break;
8180 }
8181 case MergeLayer:
8182 case FlattenLayer:
8183 case MosaicLayer:
8184 case TrimBoundsLayer:
8185 {
8186 layers=MergeImageLayers(*images,method,exception);
8187 break;
8188 }
8189 case DisposeLayer:
8190 {
8191 layers=DisposeImages(*images,exception);
8192 break;
8193 }
8194 case OptimizeImageLayer:
8195 {
8196 layers=OptimizeImageLayers(*images,exception);
8197 break;
8198 }
8199 case OptimizePlusLayer:
8200 {
8201 layers=OptimizePlusImageLayers(*images,exception);
8202 break;
8203 }
8204 case OptimizeTransLayer:
8205 {
8206 OptimizeImageTransparency(*images,exception);
8207 break;
8208 }
8209 case RemoveDupsLayer:
8210 {
8211 RemoveDuplicateLayers(images,exception);
8212 break;
8213 }
8214 case RemoveZeroLayer:
8215 {
8216 RemoveZeroDelayLayers(images,exception);
8217 break;
8218 }
8219 case OptimizeLayer:
8220 {
8221 /*
8222 General Purpose, GIF Animation Optimizer.
8223 */
8224 layers=CoalesceImages(*images,exception);
8225 if (layers == (Image *) NULL)
8226 {
8227 status=MagickFalse;
8228 break;
8229 }
8230 InheritException(exception,&layers->exception);
8231 *images=DestroyImageList(*images);
8232 *images=layers;
8233 layers=OptimizeImageLayers(*images,exception);
8234 if (layers == (Image *) NULL)
8235 {
8236 status=MagickFalse;
8237 break;
8238 }
8239 InheritException(exception,&layers->exception);
8240 *images=DestroyImageList(*images);
8241 *images=layers;
8242 layers=(Image *) NULL;
8243 OptimizeImageTransparency(*images,exception);
8244 InheritException(exception,&(*images)->exception);
8245 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8246 break;
8247 }
8248 case CompositeLayer:
8249 {
8250 CompositeOperator
8251 compose;
8252
8253 Image
8254 *source;
8255
8256 RectangleInfo
8257 geometry;
8258
8259 /*
8260 Split image sequence at the first 'NULL:' image.
8261 */
8262 source=(*images);
8263 while (source != (Image *) NULL)
8264 {
8265 source=GetNextImageInList(source);
8266 if ((source != (Image *) NULL) &&
8267 (LocaleCompare(source->magick,"NULL") == 0))
8268 break;
8269 }
8270 if (source != (Image *) NULL)
8271 {
8272 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8273 (GetNextImageInList(source) == (Image *) NULL))
8274 source=(Image *) NULL;
8275 else
8276 {
8277 /*
8278 Separate the two lists, junk the null: image.
8279 */
8280 source=SplitImageList(source->previous);
8281 DeleteImageFromList(&source);
8282 }
8283 }
8284 if (source == (Image *) NULL)
8285 {
8286 (void) ThrowMagickException(exception,GetMagickModule(),
8287 OptionError,"MissingNullSeparator","layers Composite");
8288 status=MagickFalse;
8289 break;
8290 }
8291 /*
8292 Adjust offset with gravity and virtual canvas.
8293 */
8294 SetGeometry(*images,&geometry);
8295 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8296 geometry.width=source->page.width != 0 ?
8297 source->page.width : source->columns;
8298 geometry.height=source->page.height != 0 ?
8299 source->page.height : source->rows;
8300 GravityAdjustGeometry((*images)->page.width != 0 ?
8301 (*images)->page.width : (*images)->columns,
8302 (*images)->page.height != 0 ? (*images)->page.height :
8303 (*images)->rows,(*images)->gravity,&geometry);
8304 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00008305 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00008306 if (option != (const char *) NULL)
8307 compose=(CompositeOperator) ParseMagickOption(
8308 MagickComposeOptions,MagickFalse,option);
8309 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8310 exception);
8311 source=DestroyImageList(source);
8312 break;
8313 }
8314 }
8315 if (layers == (Image *) NULL)
8316 break;
8317 InheritException(exception,&layers->exception);
8318 *images=DestroyImageList(*images);
8319 *images=layers;
8320 break;
8321 }
8322 break;
8323 }
8324 case 'm':
8325 {
8326 if (LocaleCompare("map",option+1) == 0)
8327 {
cristy6b3da3a2010-06-20 02:21:46 +00008328 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008329 if (*option == '+')
8330 {
8331 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8332 InheritException(exception,&(*images)->exception);
8333 break;
8334 }
8335 i++;
8336 break;
8337 }
cristyf40785b2010-03-06 02:27:27 +00008338 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00008339 {
8340 Image
cristyf40785b2010-03-06 02:27:27 +00008341 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00008342
cristyd18ae7c2010-03-07 17:39:52 +00008343 /*
8344 Maximum image sequence (deprecated).
8345 */
cristy6b3da3a2010-06-20 02:21:46 +00008346 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00008347 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00008348 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00008349 {
8350 status=MagickFalse;
8351 break;
8352 }
8353 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00008354 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00008355 break;
8356 }
cristyf40785b2010-03-06 02:27:27 +00008357 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00008358 {
8359 Image
cristyf40785b2010-03-06 02:27:27 +00008360 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00008361
cristyd18ae7c2010-03-07 17:39:52 +00008362 /*
8363 Minimum image sequence (deprecated).
8364 */
cristy6b3da3a2010-06-20 02:21:46 +00008365 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00008366 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00008367 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00008368 {
8369 status=MagickFalse;
8370 break;
8371 }
8372 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00008373 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00008374 break;
8375 }
cristy3ed852e2009-09-05 21:47:34 +00008376 if (LocaleCompare("morph",option+1) == 0)
8377 {
8378 Image
8379 *morph_image;
8380
cristy6b3da3a2010-06-20 02:21:46 +00008381 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00008382 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00008383 exception);
8384 if (morph_image == (Image *) NULL)
8385 {
8386 status=MagickFalse;
8387 break;
8388 }
8389 *images=DestroyImageList(*images);
8390 *images=morph_image;
8391 break;
8392 }
8393 if (LocaleCompare("mosaic",option+1) == 0)
8394 {
8395 Image
8396 *mosaic_image;
8397
cristy6b3da3a2010-06-20 02:21:46 +00008398 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008399 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8400 if (mosaic_image == (Image *) NULL)
8401 {
8402 status=MagickFalse;
8403 break;
8404 }
8405 *images=DestroyImageList(*images);
8406 *images=mosaic_image;
8407 break;
8408 }
8409 break;
8410 }
8411 case 'p':
8412 {
8413 if (LocaleCompare("print",option+1) == 0)
8414 {
8415 char
8416 *string;
8417
cristy6b3da3a2010-06-20 02:21:46 +00008418 (void) SyncImagesSettings(mogrify_info,*images);
8419 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00008420 if (string == (char *) NULL)
8421 break;
8422 InheritException(exception,&(*images)->exception);
8423 (void) fprintf(stdout,"%s",string);
8424 string=DestroyString(string);
8425 }
8426 if (LocaleCompare("process",option+1) == 0)
8427 {
8428 char
8429 **arguments;
8430
8431 int
8432 j,
8433 number_arguments;
8434
cristy6b3da3a2010-06-20 02:21:46 +00008435 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008436 arguments=StringToArgv(argv[i+1],&number_arguments);
8437 if (arguments == (char **) NULL)
8438 break;
8439 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8440 {
8441 char
8442 breaker,
8443 quote,
8444 *token;
8445
8446 const char
8447 *arguments;
8448
8449 int
8450 next,
8451 status;
8452
8453 size_t
8454 length;
8455
8456 TokenInfo
8457 *token_info;
8458
8459 /*
8460 Support old style syntax, filter="-option arg".
8461 */
8462 length=strlen(argv[i+1]);
8463 token=(char *) NULL;
8464 if (~length >= MaxTextExtent)
8465 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8466 sizeof(*token));
8467 if (token == (char *) NULL)
8468 break;
8469 next=0;
8470 arguments=argv[i+1];
8471 token_info=AcquireTokenInfo();
8472 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8473 "\"",'\0',&breaker,&next,&quote);
8474 token_info=DestroyTokenInfo(token_info);
8475 if (status == 0)
8476 {
8477 const char
8478 *argv;
8479
8480 argv=(&(arguments[next]));
8481 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8482 exception);
8483 }
8484 token=DestroyString(token);
8485 break;
8486 }
cristy91c0da22010-05-02 01:44:07 +00008487 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008488 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8489 number_arguments-2,(const char **) arguments+2,exception);
8490 for (j=0; j < number_arguments; j++)
8491 arguments[j]=DestroyString(arguments[j]);
8492 arguments=(char **) RelinquishMagickMemory(arguments);
8493 break;
8494 }
8495 break;
8496 }
8497 case 'r':
8498 {
8499 if (LocaleCompare("reverse",option+1) == 0)
8500 {
8501 ReverseImageList(images);
8502 InheritException(exception,&(*images)->exception);
8503 break;
8504 }
8505 break;
8506 }
8507 case 's':
8508 {
cristy4285d782011-02-09 20:12:28 +00008509 if (LocaleCompare("smush",option+1) == 0)
8510 {
8511 Image
8512 *smush_image;
8513
8514 ssize_t
8515 offset;
8516
8517 (void) SyncImagesSettings(mogrify_info,*images);
8518 offset=(ssize_t) StringToLong(argv[i+1]);
8519 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8520 MagickFalse,offset,exception);
8521 if (smush_image == (Image *) NULL)
8522 {
8523 status=MagickFalse;
8524 break;
8525 }
8526 *images=DestroyImageList(*images);
8527 *images=smush_image;
8528 break;
8529 }
cristy3ed852e2009-09-05 21:47:34 +00008530 if (LocaleCompare("swap",option+1) == 0)
8531 {
8532 Image
8533 *p,
8534 *q,
8535 *swap;
8536
cristybb503372010-05-27 20:51:26 +00008537 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008538 swap_index;
8539
8540 index=(-1);
8541 swap_index=(-2);
8542 if (*option != '+')
8543 {
8544 GeometryInfo
8545 geometry_info;
8546
8547 MagickStatusType
8548 flags;
8549
8550 swap_index=(-1);
8551 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008552 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008553 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008554 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008555 }
8556 p=GetImageFromList(*images,index);
8557 q=GetImageFromList(*images,swap_index);
8558 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8559 {
8560 (void) ThrowMagickException(exception,GetMagickModule(),
8561 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8562 status=MagickFalse;
8563 break;
8564 }
8565 if (p == q)
8566 break;
8567 swap=CloneImage(p,0,0,MagickTrue,exception);
8568 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8569 ReplaceImageInList(&q,swap);
8570 *images=GetFirstImageInList(q);
8571 break;
8572 }
8573 break;
8574 }
8575 case 'w':
8576 {
8577 if (LocaleCompare("write",option+1) == 0)
8578 {
cristy071dd7b2010-04-09 13:04:54 +00008579 char
cristy06609ee2010-03-17 20:21:27 +00008580 key[MaxTextExtent];
8581
cristy3ed852e2009-09-05 21:47:34 +00008582 Image
8583 *write_images;
8584
8585 ImageInfo
8586 *write_info;
8587
cristy6b3da3a2010-06-20 02:21:46 +00008588 (void) SyncImagesSettings(mogrify_info,*images);
cristy06609ee2010-03-17 20:21:27 +00008589 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8590 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008591 write_images=(*images);
8592 if (*option == '+')
8593 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008594 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008595 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8596 write_info=DestroyImageInfo(write_info);
8597 if (*option == '+')
8598 write_images=DestroyImageList(write_images);
8599 break;
8600 }
8601 break;
8602 }
8603 default:
8604 break;
8605 }
8606 i+=count;
8607 }
8608 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008609 mogrify_info=DestroyImageInfo(mogrify_info);
8610 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008611 return(status != 0 ? MagickTrue : MagickFalse);
8612}
8613
8614/*
8615%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8616% %
8617% %
8618% %
8619+ M o g r i f y I m a g e s %
8620% %
8621% %
8622% %
8623%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8624%
8625% MogrifyImages() applies image processing options to a sequence of images as
8626% prescribed by command line options.
8627%
8628% The format of the MogrifyImage method is:
8629%
8630% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8631% const MagickBooleanType post,const int argc,const char **argv,
8632% Image **images,Exceptioninfo *exception)
8633%
8634% A description of each parameter follows:
8635%
8636% o image_info: the image info..
8637%
8638% o post: If true, post process image list operators otherwise pre-process.
8639%
8640% o argc: Specifies a pointer to an integer describing the number of
8641% elements in the argument vector.
8642%
8643% o argv: Specifies a pointer to a text array containing the command line
8644% arguments.
8645%
8646% o images: the images.
8647%
8648% o exception: return any errors or warnings in this structure.
8649%
8650*/
8651WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8652 const MagickBooleanType post,const int argc,const char **argv,
8653 Image **images,ExceptionInfo *exception)
8654{
8655#define MogrifyImageTag "Mogrify/Image"
8656
8657 Image
8658 *image,
8659 *mogrify_images;
8660
cristy0e9f9c12010-02-11 03:00:47 +00008661 MagickBooleanType
8662 proceed;
8663
8664 MagickSizeType
8665 number_images;
8666
cristy3ed852e2009-09-05 21:47:34 +00008667 MagickStatusType
8668 status;
8669
cristybb503372010-05-27 20:51:26 +00008670 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008671 i;
8672
cristy3ed852e2009-09-05 21:47:34 +00008673 /*
8674 Apply options to individual images in the list.
8675 */
8676 assert(image_info != (ImageInfo *) NULL);
8677 assert(image_info->signature == MagickSignature);
8678 if (images == (Image **) NULL)
8679 return(MogrifyImage(image_info,argc,argv,images,exception));
8680 assert((*images)->signature == MagickSignature);
8681 if ((*images)->debug != MagickFalse)
8682 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8683 (*images)->filename);
8684 if ((argc <= 0) || (*argv == (char *) NULL))
8685 return(MagickTrue);
8686 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8687 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008688 status=0;
8689 if (post == MagickFalse)
8690 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthony1e4df872011-03-19 14:10:59 +00008691 PageIndexImageList(*images);
8692 number_images=(*images)->page_total;
8693 mogrify_images=NewImageList();
cristybb503372010-05-27 20:51:26 +00008694 for (i=0; i < (ssize_t) number_images; i++)
cristy3ed852e2009-09-05 21:47:34 +00008695 {
8696 image=RemoveFirstImageFromList(images);
8697 if (image == (Image *) NULL)
8698 continue;
8699 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8700 AppendImageToList(&mogrify_images,image);
cristy0e9f9c12010-02-11 03:00:47 +00008701 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8702 number_images);
8703 if (proceed == MagickFalse)
8704 break;
cristy3ed852e2009-09-05 21:47:34 +00008705 }
8706 if (post != MagickFalse)
8707 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8708 *images=mogrify_images;
8709 return(status != 0 ? MagickTrue : MagickFalse);
8710}