blob: 405ec9bbcc74f048ca2611aa713ac2f4d3c675c1 [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",
3833 "-reverse reverse image sequence",
3834 "-separate separate an image channel into a grayscale image",
cristy4285d782011-02-09 20:12:28 +00003835 "-smush geometry smush an image sequence together",
cristy3ed852e2009-09-05 21:47:34 +00003836 "-write filename write images to this file",
3837 (char *) NULL
3838 },
3839 *settings[]=
3840 {
3841 "-adjoin join images into a single multi-image file",
3842 "-affine matrix affine transform matrix",
3843 "-alpha option activate, deactivate, reset, or set the alpha channel",
3844 "-antialias remove pixel-aliasing",
3845 "-authenticate password",
3846 " decipher image with this password",
3847 "-attenuate value lessen (or intensify) when adding noise to an image",
3848 "-background color background color",
3849 "-bias value add bias when convolving an image",
3850 "-black-point-compensation",
3851 " use black point compensation",
3852 "-blue-primary point chromaticity blue primary point",
3853 "-bordercolor color border color",
3854 "-caption string assign a caption to an image",
3855 "-channel type apply option to select image channels",
3856 "-colors value preferred number of colors in the image",
3857 "-colorspace type alternate image colorspace",
3858 "-comment string annotate image with comment",
3859 "-compose operator set image composite operator",
3860 "-compress type type of pixel compression when writing the image",
3861 "-define format:option",
3862 " define one or more image format options",
3863 "-delay value display the next image after pausing",
3864 "-density geometry horizontal and vertical density of the image",
3865 "-depth value image depth",
cristyc9b12952010-03-28 01:12:28 +00003866 "-direction type render text right-to-left or left-to-right",
cristy3ed852e2009-09-05 21:47:34 +00003867 "-display server get image or font from this X server",
3868 "-dispose method layer disposal method",
3869 "-dither method apply error diffusion to image",
3870 "-encoding type text encoding type",
3871 "-endian type endianness (MSB or LSB) of the image",
3872 "-family name render text with this font family",
3873 "-fill color color to use when filling a graphic primitive",
3874 "-filter type use this filter when resizing an image",
3875 "-font name render text with this font",
3876 "-format \"string\" output formatted image characteristics",
3877 "-fuzz distance colors within this distance are considered equal",
3878 "-gravity type horizontal and vertical text placement",
3879 "-green-primary point chromaticity green primary point",
3880 "-intent type type of rendering intent when managing the image color",
3881 "-interlace type type of image interlacing scheme",
cristyb32b90a2009-09-07 21:45:48 +00003882 "-interline-spacing value",
3883 " set the space between two text lines",
cristy3ed852e2009-09-05 21:47:34 +00003884 "-interpolate method pixel color interpolation method",
3885 "-interword-spacing value",
3886 " set the space between two words",
3887 "-kerning value set the space between two letters",
3888 "-label string assign a label to an image",
3889 "-limit type value pixel cache resource limit",
3890 "-loop iterations add Netscape loop extension to your GIF animation",
3891 "-mask filename associate a mask with the image",
3892 "-mattecolor color frame color",
3893 "-monitor monitor progress",
3894 "-orient type image orientation",
3895 "-page geometry size and location of an image canvas (setting)",
3896 "-ping efficiently determine image attributes",
3897 "-pointsize value font point size",
cristy7c1b9fd2010-02-02 14:36:00 +00003898 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +00003899 "-preview type image preview type",
3900 "-quality value JPEG/MIFF/PNG compression level",
3901 "-quiet suppress all warning messages",
3902 "-red-primary point chromaticity red primary point",
3903 "-regard-warnings pay attention to warning messages",
3904 "-remap filename transform image colors to match this set of colors",
3905 "-respect-parentheses settings remain in effect until parenthesis boundary",
3906 "-sampling-factor geometry",
3907 " horizontal and vertical sampling factor",
3908 "-scene value image scene number",
3909 "-seed value seed a new sequence of pseudo-random numbers",
3910 "-size geometry width and height of image",
3911 "-stretch type render text with this font stretch",
3912 "-stroke color graphic primitive stroke color",
3913 "-strokewidth value graphic primitive stroke width",
3914 "-style type render text with this font style",
cristyd9a29192010-10-16 16:49:53 +00003915 "-synchronize synchronize image to storage device",
3916 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +00003917 "-texture filename name of texture to tile onto the image background",
3918 "-tile-offset geometry",
3919 " tile offset",
3920 "-treedepth value color tree depth",
3921 "-transparent-color color",
3922 " transparent color",
3923 "-undercolor color annotation bounding box color",
3924 "-units type the units of image resolution",
3925 "-verbose print detailed information about the image",
3926 "-view FlashPix viewing transforms",
3927 "-virtual-pixel method",
3928 " virtual pixel access method",
3929 "-weight type render text with this font weight",
3930 "-white-point point chromaticity white point",
3931 (char *) NULL
3932 },
3933 *stack_operators[]=
3934 {
cristy3ed852e2009-09-05 21:47:34 +00003935 "-delete index delete the image from the image sequence",
cristyecb10ff2011-03-22 13:14:03 +00003936 "-duplicate count[,index]",
3937 " duplicate an image one or more times",
cristy3ed852e2009-09-05 21:47:34 +00003938 "-insert index insert last image into the image sequence",
3939 "-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 {
cristybf95deb2011-03-23 00:25:36 +00004798 i++;
4799 if (i == (ssize_t) (argc-1))
4800 ThrowMogrifyException(OptionError,"MissingArgument",option);
4801 if (IsGeometry(argv[i]) == MagickFalse)
4802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyecb10ff2011-03-22 13:14:03 +00004803 if (*option == '+')
4804 break;
4805 i++;
4806 if (i == (ssize_t) (argc-1))
4807 ThrowMogrifyException(OptionError,"MissingArgument",option);
4808 if (IsGeometry(argv[i]) == MagickFalse)
4809 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4810 break;
4811 }
cristy22879752009-10-25 23:55:40 +00004812 if (LocaleCompare("duration",option+1) == 0)
4813 {
4814 if (*option == '+')
4815 break;
4816 i++;
cristybb503372010-05-27 20:51:26 +00004817 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00004818 ThrowMogrifyException(OptionError,"MissingArgument",option);
4819 if (IsGeometry(argv[i]) == MagickFalse)
4820 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4821 break;
4822 }
cristy3ed852e2009-09-05 21:47:34 +00004823 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4824 }
4825 case 'e':
4826 {
4827 if (LocaleCompare("edge",option+1) == 0)
4828 {
4829 if (*option == '+')
4830 break;
4831 i++;
cristybb503372010-05-27 20:51:26 +00004832 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004833 ThrowMogrifyException(OptionError,"MissingArgument",option);
4834 if (IsGeometry(argv[i]) == MagickFalse)
4835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4836 break;
4837 }
4838 if (LocaleCompare("emboss",option+1) == 0)
4839 {
4840 if (*option == '+')
4841 break;
4842 i++;
cristybb503372010-05-27 20:51:26 +00004843 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004844 ThrowMogrifyException(OptionError,"MissingArgument",option);
4845 if (IsGeometry(argv[i]) == MagickFalse)
4846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4847 break;
4848 }
4849 if (LocaleCompare("encipher",option+1) == 0)
4850 {
4851 if (*option == '+')
4852 break;
4853 i++;
cristybb503372010-05-27 20:51:26 +00004854 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004855 ThrowMogrifyException(OptionError,"MissingArgument",option);
4856 break;
4857 }
4858 if (LocaleCompare("encoding",option+1) == 0)
4859 {
4860 if (*option == '+')
4861 break;
4862 i++;
cristybb503372010-05-27 20:51:26 +00004863 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004864 ThrowMogrifyException(OptionError,"MissingArgument",option);
4865 break;
4866 }
4867 if (LocaleCompare("endian",option+1) == 0)
4868 {
cristybb503372010-05-27 20:51:26 +00004869 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004870 endian;
4871
4872 if (*option == '+')
4873 break;
4874 i++;
cristybb503372010-05-27 20:51:26 +00004875 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004876 ThrowMogrifyException(OptionError,"MissingArgument",option);
4877 endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
4878 if (endian < 0)
4879 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4880 argv[i]);
4881 break;
4882 }
4883 if (LocaleCompare("enhance",option+1) == 0)
4884 break;
4885 if (LocaleCompare("equalize",option+1) == 0)
4886 break;
4887 if (LocaleCompare("evaluate",option+1) == 0)
4888 {
cristybb503372010-05-27 20:51:26 +00004889 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004890 op;
4891
4892 if (*option == '+')
4893 break;
4894 i++;
cristybb503372010-05-27 20:51:26 +00004895 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004896 ThrowMogrifyException(OptionError,"MissingArgument",option);
4897 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4898 if (op < 0)
4899 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4900 argv[i]);
4901 i++;
cristybb503372010-05-27 20:51:26 +00004902 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004903 ThrowMogrifyException(OptionError,"MissingArgument",option);
4904 if (IsGeometry(argv[i]) == MagickFalse)
4905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4906 break;
4907 }
cristyd18ae7c2010-03-07 17:39:52 +00004908 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4909 {
cristybb503372010-05-27 20:51:26 +00004910 ssize_t
cristyd18ae7c2010-03-07 17:39:52 +00004911 op;
4912
4913 if (*option == '+')
4914 break;
4915 i++;
cristybb503372010-05-27 20:51:26 +00004916 if (i == (ssize_t) argc)
cristyd18ae7c2010-03-07 17:39:52 +00004917 ThrowMogrifyException(OptionError,"MissingArgument",option);
4918 op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4919 if (op < 0)
4920 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4921 argv[i]);
4922 break;
4923 }
cristy3ed852e2009-09-05 21:47:34 +00004924 if (LocaleCompare("extent",option+1) == 0)
4925 {
4926 if (*option == '+')
4927 break;
4928 i++;
cristybb503372010-05-27 20:51:26 +00004929 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004930 ThrowMogrifyException(OptionError,"MissingArgument",option);
4931 if (IsGeometry(argv[i]) == MagickFalse)
4932 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4933 break;
4934 }
4935 if (LocaleCompare("extract",option+1) == 0)
4936 {
4937 if (*option == '+')
4938 break;
4939 i++;
cristybb503372010-05-27 20:51:26 +00004940 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004941 ThrowMogrifyException(OptionError,"MissingArgument",option);
4942 if (IsGeometry(argv[i]) == MagickFalse)
4943 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4944 break;
4945 }
4946 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4947 }
4948 case 'f':
4949 {
4950 if (LocaleCompare("family",option+1) == 0)
4951 {
4952 if (*option == '+')
4953 break;
4954 i++;
cristybb503372010-05-27 20:51:26 +00004955 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00004956 ThrowMogrifyException(OptionError,"MissingArgument",option);
4957 break;
4958 }
4959 if (LocaleCompare("fill",option+1) == 0)
4960 {
4961 if (*option == '+')
4962 break;
4963 i++;
cristybb503372010-05-27 20:51:26 +00004964 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004965 ThrowMogrifyException(OptionError,"MissingArgument",option);
4966 break;
4967 }
4968 if (LocaleCompare("filter",option+1) == 0)
4969 {
cristybb503372010-05-27 20:51:26 +00004970 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00004971 filter;
4972
4973 if (*option == '+')
4974 break;
4975 i++;
cristybb503372010-05-27 20:51:26 +00004976 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00004977 ThrowMogrifyException(OptionError,"MissingArgument",option);
4978 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
4979 if (filter < 0)
4980 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4981 argv[i]);
4982 break;
4983 }
4984 if (LocaleCompare("flatten",option+1) == 0)
4985 break;
4986 if (LocaleCompare("flip",option+1) == 0)
4987 break;
4988 if (LocaleCompare("flop",option+1) == 0)
4989 break;
4990 if (LocaleCompare("floodfill",option+1) == 0)
4991 {
4992 if (*option == '+')
4993 break;
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 if (IsGeometry(argv[i]) == MagickFalse)
4998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4999 i++;
cristybb503372010-05-27 20:51:26 +00005000 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005001 ThrowMogrifyException(OptionError,"MissingArgument",option);
5002 break;
5003 }
5004 if (LocaleCompare("font",option+1) == 0)
5005 {
5006 if (*option == '+')
5007 break;
5008 i++;
cristybb503372010-05-27 20:51:26 +00005009 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005010 ThrowMogrifyException(OptionError,"MissingArgument",option);
5011 break;
5012 }
5013 if (LocaleCompare("format",option+1) == 0)
5014 {
5015 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
5016 (void) CloneString(&format,(char *) NULL);
5017 if (*option == '+')
5018 break;
5019 i++;
cristybb503372010-05-27 20:51:26 +00005020 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005021 ThrowMogrifyException(OptionError,"MissingArgument",option);
5022 (void) CloneString(&format,argv[i]);
5023 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
5024 (void) ConcatenateMagickString(image_info->filename,":",
5025 MaxTextExtent);
cristyd965a422010-03-03 17:47:35 +00005026 (void) SetImageInfo(image_info,0,exception);
cristy3ed852e2009-09-05 21:47:34 +00005027 if (*image_info->magick == '\0')
5028 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
5029 format);
5030 break;
5031 }
5032 if (LocaleCompare("frame",option+1) == 0)
5033 {
5034 if (*option == '+')
5035 break;
5036 i++;
cristybb503372010-05-27 20:51:26 +00005037 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005038 ThrowMogrifyException(OptionError,"MissingArgument",option);
5039 if (IsGeometry(argv[i]) == MagickFalse)
5040 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5041 break;
5042 }
5043 if (LocaleCompare("function",option+1) == 0)
5044 {
cristybb503372010-05-27 20:51:26 +00005045 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005046 op;
5047
5048 if (*option == '+')
5049 break;
5050 i++;
cristybb503372010-05-27 20:51:26 +00005051 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005052 ThrowMogrifyException(OptionError,"MissingArgument",option);
5053 op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
5054 if (op < 0)
5055 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
5056 i++;
cristybb503372010-05-27 20:51:26 +00005057 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005058 ThrowMogrifyException(OptionError,"MissingArgument",option);
5059 break;
5060 }
5061 if (LocaleCompare("fuzz",option+1) == 0)
5062 {
5063 if (*option == '+')
5064 break;
5065 i++;
cristybb503372010-05-27 20:51:26 +00005066 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005067 ThrowMogrifyException(OptionError,"MissingArgument",option);
5068 if (IsGeometry(argv[i]) == MagickFalse)
5069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5070 break;
5071 }
5072 if (LocaleCompare("fx",option+1) == 0)
5073 {
5074 if (*option == '+')
5075 break;
5076 i++;
cristybb503372010-05-27 20:51:26 +00005077 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005078 ThrowMogrifyException(OptionError,"MissingArgument",option);
5079 break;
5080 }
5081 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5082 }
5083 case 'g':
5084 {
5085 if (LocaleCompare("gamma",option+1) == 0)
5086 {
5087 i++;
cristybb503372010-05-27 20:51:26 +00005088 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005089 ThrowMogrifyException(OptionError,"MissingArgument",option);
5090 if (IsGeometry(argv[i]) == MagickFalse)
5091 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5092 break;
5093 }
5094 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5095 (LocaleCompare("gaussian",option+1) == 0))
5096 {
5097 i++;
cristybb503372010-05-27 20:51:26 +00005098 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005099 ThrowMogrifyException(OptionError,"MissingArgument",option);
5100 if (IsGeometry(argv[i]) == MagickFalse)
5101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5102 break;
5103 }
5104 if (LocaleCompare("geometry",option+1) == 0)
5105 {
5106 if (*option == '+')
5107 break;
5108 i++;
cristybb503372010-05-27 20:51:26 +00005109 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005110 ThrowMogrifyException(OptionError,"MissingArgument",option);
5111 if (IsGeometry(argv[i]) == MagickFalse)
5112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5113 break;
5114 }
5115 if (LocaleCompare("gravity",option+1) == 0)
5116 {
cristybb503372010-05-27 20:51:26 +00005117 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005118 gravity;
5119
5120 if (*option == '+')
5121 break;
5122 i++;
cristybb503372010-05-27 20:51:26 +00005123 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005124 ThrowMogrifyException(OptionError,"MissingArgument",option);
5125 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
5126 if (gravity < 0)
5127 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5128 argv[i]);
5129 break;
5130 }
5131 if (LocaleCompare("green-primary",option+1) == 0)
5132 {
5133 if (*option == '+')
5134 break;
5135 i++;
cristybb503372010-05-27 20:51:26 +00005136 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005137 ThrowMogrifyException(OptionError,"MissingArgument",option);
5138 if (IsGeometry(argv[i]) == MagickFalse)
5139 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5140 break;
5141 }
5142 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5143 }
5144 case 'h':
5145 {
5146 if (LocaleCompare("hald-clut",option+1) == 0)
5147 break;
5148 if ((LocaleCompare("help",option+1) == 0) ||
5149 (LocaleCompare("-help",option+1) == 0))
5150 return(MogrifyUsage());
5151 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5152 }
5153 case 'i':
5154 {
5155 if (LocaleCompare("identify",option+1) == 0)
5156 break;
5157 if (LocaleCompare("idft",option+1) == 0)
5158 break;
5159 if (LocaleCompare("implode",option+1) == 0)
5160 {
5161 if (*option == '+')
5162 break;
5163 i++;
cristybb503372010-05-27 20:51:26 +00005164 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005165 ThrowMogrifyException(OptionError,"MissingArgument",option);
5166 if (IsGeometry(argv[i]) == MagickFalse)
5167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5168 break;
5169 }
5170 if (LocaleCompare("intent",option+1) == 0)
5171 {
cristybb503372010-05-27 20:51:26 +00005172 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005173 intent;
5174
5175 if (*option == '+')
5176 break;
5177 i++;
cristybb503372010-05-27 20:51:26 +00005178 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005179 ThrowMogrifyException(OptionError,"MissingArgument",option);
5180 intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
5181 if (intent < 0)
5182 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5183 argv[i]);
5184 break;
5185 }
5186 if (LocaleCompare("interlace",option+1) == 0)
5187 {
cristybb503372010-05-27 20:51:26 +00005188 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005189 interlace;
5190
5191 if (*option == '+')
5192 break;
5193 i++;
cristybb503372010-05-27 20:51:26 +00005194 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005195 ThrowMogrifyException(OptionError,"MissingArgument",option);
5196 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
5197 argv[i]);
5198 if (interlace < 0)
5199 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5200 argv[i]);
5201 break;
5202 }
cristyb32b90a2009-09-07 21:45:48 +00005203 if (LocaleCompare("interline-spacing",option+1) == 0)
5204 {
5205 if (*option == '+')
5206 break;
5207 i++;
cristybb503372010-05-27 20:51:26 +00005208 if (i == (ssize_t) (argc-1))
cristyb32b90a2009-09-07 21:45:48 +00005209 ThrowMogrifyException(OptionError,"MissingArgument",option);
5210 if (IsGeometry(argv[i]) == MagickFalse)
5211 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5212 break;
5213 }
cristy3ed852e2009-09-05 21:47:34 +00005214 if (LocaleCompare("interpolate",option+1) == 0)
5215 {
cristybb503372010-05-27 20:51:26 +00005216 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005217 interpolate;
5218
5219 if (*option == '+')
5220 break;
5221 i++;
cristybb503372010-05-27 20:51:26 +00005222 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005223 ThrowMogrifyException(OptionError,"MissingArgument",option);
5224 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
5225 argv[i]);
5226 if (interpolate < 0)
5227 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5228 argv[i]);
5229 break;
5230 }
5231 if (LocaleCompare("interword-spacing",option+1) == 0)
5232 {
5233 if (*option == '+')
5234 break;
5235 i++;
cristybb503372010-05-27 20:51:26 +00005236 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005237 ThrowMogrifyException(OptionError,"MissingArgument",option);
5238 if (IsGeometry(argv[i]) == MagickFalse)
5239 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5240 break;
5241 }
5242 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5243 }
5244 case 'k':
5245 {
5246 if (LocaleCompare("kerning",option+1) == 0)
5247 {
5248 if (*option == '+')
5249 break;
5250 i++;
cristybb503372010-05-27 20:51:26 +00005251 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005252 ThrowMogrifyException(OptionError,"MissingArgument",option);
5253 if (IsGeometry(argv[i]) == MagickFalse)
5254 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5255 break;
5256 }
5257 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5258 }
5259 case 'l':
5260 {
5261 if (LocaleCompare("label",option+1) == 0)
5262 {
5263 if (*option == '+')
5264 break;
5265 i++;
cristybb503372010-05-27 20:51:26 +00005266 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005267 ThrowMogrifyException(OptionError,"MissingArgument",option);
5268 break;
5269 }
5270 if (LocaleCompare("lat",option+1) == 0)
5271 {
5272 if (*option == '+')
5273 break;
5274 i++;
cristybb503372010-05-27 20:51:26 +00005275 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005276 ThrowMogrifyException(OptionError,"MissingArgument",option);
5277 if (IsGeometry(argv[i]) == MagickFalse)
5278 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5279 }
5280 if (LocaleCompare("layers",option+1) == 0)
5281 {
cristybb503372010-05-27 20:51:26 +00005282 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005283 type;
5284
5285 if (*option == '+')
5286 break;
5287 i++;
cristybb503372010-05-27 20:51:26 +00005288 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005289 ThrowMogrifyException(OptionError,"MissingArgument",option);
5290 type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
5291 if (type < 0)
5292 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5293 argv[i]);
5294 break;
5295 }
5296 if (LocaleCompare("level",option+1) == 0)
5297 {
5298 i++;
cristybb503372010-05-27 20:51:26 +00005299 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005300 ThrowMogrifyException(OptionError,"MissingArgument",option);
5301 if (IsGeometry(argv[i]) == MagickFalse)
5302 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5303 break;
5304 }
5305 if (LocaleCompare("level-colors",option+1) == 0)
5306 {
5307 i++;
cristybb503372010-05-27 20:51:26 +00005308 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005309 ThrowMogrifyException(OptionError,"MissingArgument",option);
5310 break;
5311 }
5312 if (LocaleCompare("linewidth",option+1) == 0)
5313 {
5314 if (*option == '+')
5315 break;
5316 i++;
cristybb503372010-05-27 20:51:26 +00005317 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005318 ThrowMogrifyException(OptionError,"MissingArgument",option);
5319 if (IsGeometry(argv[i]) == MagickFalse)
5320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5321 break;
5322 }
5323 if (LocaleCompare("limit",option+1) == 0)
5324 {
5325 char
5326 *p;
5327
5328 double
5329 value;
5330
cristybb503372010-05-27 20:51:26 +00005331 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005332 resource;
5333
5334 if (*option == '+')
5335 break;
5336 i++;
cristybb503372010-05-27 20:51:26 +00005337 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005338 ThrowMogrifyException(OptionError,"MissingArgument",option);
5339 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
5340 argv[i]);
5341 if (resource < 0)
5342 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5343 argv[i]);
5344 i++;
cristybb503372010-05-27 20:51:26 +00005345 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005346 ThrowMogrifyException(OptionError,"MissingArgument",option);
5347 value=strtod(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00005348 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00005349 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5350 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5351 break;
5352 }
5353 if (LocaleCompare("liquid-rescale",option+1) == 0)
5354 {
5355 i++;
cristybb503372010-05-27 20:51:26 +00005356 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005357 ThrowMogrifyException(OptionError,"MissingArgument",option);
5358 if (IsGeometry(argv[i]) == MagickFalse)
5359 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5360 break;
5361 }
5362 if (LocaleCompare("list",option+1) == 0)
5363 {
cristybb503372010-05-27 20:51:26 +00005364 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005365 list;
5366
5367 if (*option == '+')
5368 break;
5369 i++;
cristybb503372010-05-27 20:51:26 +00005370 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005371 ThrowMogrifyException(OptionError,"MissingArgument",option);
5372 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
5373 if (list < 0)
5374 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00005375 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00005376 argv+j,exception);
cristyaeb2cbc2010-05-07 13:28:58 +00005377 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00005378 }
5379 if (LocaleCompare("log",option+1) == 0)
5380 {
5381 if (*option == '+')
5382 break;
5383 i++;
cristybb503372010-05-27 20:51:26 +00005384 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00005385 (strchr(argv[i],'%') == (char *) NULL))
5386 ThrowMogrifyException(OptionError,"MissingArgument",option);
5387 break;
5388 }
5389 if (LocaleCompare("loop",option+1) == 0)
5390 {
5391 if (*option == '+')
5392 break;
5393 i++;
cristybb503372010-05-27 20:51:26 +00005394 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5396 if (IsGeometry(argv[i]) == MagickFalse)
5397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5398 break;
5399 }
5400 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5401 }
5402 case 'm':
5403 {
5404 if (LocaleCompare("map",option+1) == 0)
5405 {
5406 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5407 if (*option == '+')
5408 break;
5409 i++;
cristybb503372010-05-27 20:51:26 +00005410 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005411 ThrowMogrifyException(OptionError,"MissingArgument",option);
5412 break;
5413 }
5414 if (LocaleCompare("mask",option+1) == 0)
5415 {
5416 if (*option == '+')
5417 break;
5418 i++;
cristybb503372010-05-27 20:51:26 +00005419 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005420 ThrowMogrifyException(OptionError,"MissingArgument",option);
5421 break;
5422 }
5423 if (LocaleCompare("matte",option+1) == 0)
5424 break;
5425 if (LocaleCompare("mattecolor",option+1) == 0)
5426 {
5427 if (*option == '+')
5428 break;
5429 i++;
cristybb503372010-05-27 20:51:26 +00005430 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005431 ThrowMogrifyException(OptionError,"MissingArgument",option);
5432 break;
5433 }
cristyf40785b2010-03-06 02:27:27 +00005434 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005435 break;
cristyf40785b2010-03-06 02:27:27 +00005436 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00005437 break;
cristy3ed852e2009-09-05 21:47:34 +00005438 if (LocaleCompare("modulate",option+1) == 0)
5439 {
5440 if (*option == '+')
5441 break;
5442 i++;
cristybb503372010-05-27 20:51:26 +00005443 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005444 ThrowMogrifyException(OptionError,"MissingArgument",option);
5445 if (IsGeometry(argv[i]) == MagickFalse)
5446 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5447 break;
5448 }
5449 if (LocaleCompare("median",option+1) == 0)
5450 {
5451 if (*option == '+')
5452 break;
5453 i++;
cristybb503372010-05-27 20:51:26 +00005454 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005455 ThrowMogrifyException(OptionError,"MissingArgument",option);
5456 if (IsGeometry(argv[i]) == MagickFalse)
5457 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5458 break;
5459 }
cristy69ec32d2011-02-27 23:57:09 +00005460 if (LocaleCompare("mode",option+1) == 0)
5461 {
5462 if (*option == '+')
5463 break;
5464 i++;
5465 if (i == (ssize_t) argc)
5466 ThrowMogrifyException(OptionError,"MissingArgument",option);
5467 if (IsGeometry(argv[i]) == MagickFalse)
5468 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5469 break;
5470 }
cristy3ed852e2009-09-05 21:47:34 +00005471 if (LocaleCompare("monitor",option+1) == 0)
5472 break;
5473 if (LocaleCompare("monochrome",option+1) == 0)
5474 break;
5475 if (LocaleCompare("morph",option+1) == 0)
5476 {
5477 if (*option == '+')
5478 break;
5479 i++;
cristybb503372010-05-27 20:51:26 +00005480 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005481 ThrowMogrifyException(OptionError,"MissingArgument",option);
5482 if (IsGeometry(argv[i]) == MagickFalse)
5483 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5484 break;
5485 }
anthony29188a82010-01-22 10:12:34 +00005486 if (LocaleCompare("morphology",option+1) == 0)
5487 {
anthony29188a82010-01-22 10:12:34 +00005488 char
5489 token[MaxTextExtent];
5490
cristyb6bd4ad2010-08-08 01:12:27 +00005491 KernelInfo
5492 *kernel_info;
5493
5494 ssize_t
5495 op;
5496
anthony29188a82010-01-22 10:12:34 +00005497 i++;
cristybb503372010-05-27 20:51:26 +00005498 if (i == (ssize_t) argc)
anthony29188a82010-01-22 10:12:34 +00005499 ThrowMogrifyException(OptionError,"MissingArgument",option);
5500 GetMagickToken(argv[i],NULL,token);
5501 op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
5502 if (op < 0)
5503 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
cristyf0c78232010-03-15 12:53:40 +00005504 token);
anthony29188a82010-01-22 10:12:34 +00005505 i++;
cristybb503372010-05-27 20:51:26 +00005506 if (i == (ssize_t) (argc-1))
anthony29188a82010-01-22 10:12:34 +00005507 ThrowMogrifyException(OptionError,"MissingArgument",option);
cristyb6bd4ad2010-08-08 01:12:27 +00005508 kernel_info=AcquireKernelInfo(argv[i]);
5509 if (kernel_info == (KernelInfo *) NULL)
cristyf4e8c912010-08-08 01:51:19 +00005510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristyb6bd4ad2010-08-08 01:12:27 +00005511 kernel_info=DestroyKernelInfo(kernel_info);
anthony29188a82010-01-22 10:12:34 +00005512 break;
5513 }
cristy3ed852e2009-09-05 21:47:34 +00005514 if (LocaleCompare("mosaic",option+1) == 0)
5515 break;
5516 if (LocaleCompare("motion-blur",option+1) == 0)
5517 {
5518 if (*option == '+')
5519 break;
5520 i++;
cristybb503372010-05-27 20:51:26 +00005521 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005522 ThrowMogrifyException(OptionError,"MissingArgument",option);
5523 if (IsGeometry(argv[i]) == MagickFalse)
5524 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5525 break;
5526 }
5527 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5528 }
5529 case 'n':
5530 {
5531 if (LocaleCompare("negate",option+1) == 0)
5532 break;
5533 if (LocaleCompare("noise",option+1) == 0)
5534 {
5535 i++;
cristybb503372010-05-27 20:51:26 +00005536 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005537 ThrowMogrifyException(OptionError,"MissingArgument",option);
5538 if (*option == '+')
5539 {
cristybb503372010-05-27 20:51:26 +00005540 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005541 noise;
5542
5543 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
5544 if (noise < 0)
5545 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5546 argv[i]);
5547 break;
5548 }
5549 if (IsGeometry(argv[i]) == MagickFalse)
5550 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5551 break;
5552 }
5553 if (LocaleCompare("noop",option+1) == 0)
5554 break;
5555 if (LocaleCompare("normalize",option+1) == 0)
5556 break;
5557 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5558 }
5559 case 'o':
5560 {
5561 if (LocaleCompare("opaque",option+1) == 0)
5562 {
cristy3ed852e2009-09-05 21:47:34 +00005563 i++;
cristybb503372010-05-27 20:51:26 +00005564 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005565 ThrowMogrifyException(OptionError,"MissingArgument",option);
5566 break;
5567 }
5568 if (LocaleCompare("ordered-dither",option+1) == 0)
5569 {
5570 if (*option == '+')
5571 break;
5572 i++;
cristybb503372010-05-27 20:51:26 +00005573 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005574 ThrowMogrifyException(OptionError,"MissingArgument",option);
5575 break;
5576 }
5577 if (LocaleCompare("orient",option+1) == 0)
5578 {
cristybb503372010-05-27 20:51:26 +00005579 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005580 orientation;
5581
5582 orientation=UndefinedOrientation;
5583 if (*option == '+')
5584 break;
5585 i++;
cristybb503372010-05-27 20:51:26 +00005586 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005587 ThrowMogrifyException(OptionError,"MissingArgument",option);
5588 orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
5589 argv[i]);
5590 if (orientation < 0)
5591 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5592 argv[i]);
5593 break;
5594 }
5595 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5596 }
5597 case 'p':
5598 {
5599 if (LocaleCompare("page",option+1) == 0)
5600 {
5601 if (*option == '+')
5602 break;
5603 i++;
cristybb503372010-05-27 20:51:26 +00005604 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005605 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 break;
5607 }
5608 if (LocaleCompare("paint",option+1) == 0)
5609 {
5610 if (*option == '+')
5611 break;
5612 i++;
cristybb503372010-05-27 20:51:26 +00005613 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005614 ThrowMogrifyException(OptionError,"MissingArgument",option);
5615 if (IsGeometry(argv[i]) == MagickFalse)
5616 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5617 break;
5618 }
5619 if (LocaleCompare("path",option+1) == 0)
5620 {
5621 (void) CloneString(&path,(char *) NULL);
5622 if (*option == '+')
5623 break;
5624 i++;
cristybb503372010-05-27 20:51:26 +00005625 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005626 ThrowMogrifyException(OptionError,"MissingArgument",option);
5627 (void) CloneString(&path,argv[i]);
5628 break;
5629 }
5630 if (LocaleCompare("pointsize",option+1) == 0)
5631 {
5632 if (*option == '+')
5633 break;
5634 i++;
cristybb503372010-05-27 20:51:26 +00005635 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005636 ThrowMogrifyException(OptionError,"MissingArgument",option);
5637 if (IsGeometry(argv[i]) == MagickFalse)
5638 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5639 break;
5640 }
5641 if (LocaleCompare("polaroid",option+1) == 0)
5642 {
5643 if (*option == '+')
5644 break;
5645 i++;
cristybb503372010-05-27 20:51:26 +00005646 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005647 ThrowMogrifyException(OptionError,"MissingArgument",option);
5648 if (IsGeometry(argv[i]) == MagickFalse)
5649 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 break;
5651 }
5652 if (LocaleCompare("posterize",option+1) == 0)
5653 {
5654 if (*option == '+')
5655 break;
5656 i++;
cristybb503372010-05-27 20:51:26 +00005657 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005658 ThrowMogrifyException(OptionError,"MissingArgument",option);
5659 if (IsGeometry(argv[i]) == MagickFalse)
5660 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5661 break;
5662 }
cristye7f51092010-01-17 00:39:37 +00005663 if (LocaleCompare("precision",option+1) == 0)
5664 {
5665 if (*option == '+')
5666 break;
5667 i++;
cristybb503372010-05-27 20:51:26 +00005668 if (i == (ssize_t) argc)
cristye7f51092010-01-17 00:39:37 +00005669 ThrowMogrifyException(OptionError,"MissingArgument",option);
5670 if (IsGeometry(argv[i]) == MagickFalse)
5671 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5672 break;
5673 }
cristy3ed852e2009-09-05 21:47:34 +00005674 if (LocaleCompare("print",option+1) == 0)
5675 {
5676 if (*option == '+')
5677 break;
5678 i++;
cristybb503372010-05-27 20:51:26 +00005679 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005680 ThrowMogrifyException(OptionError,"MissingArgument",option);
5681 break;
5682 }
5683 if (LocaleCompare("process",option+1) == 0)
5684 {
5685 if (*option == '+')
5686 break;
5687 i++;
cristybb503372010-05-27 20:51:26 +00005688 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005689 ThrowMogrifyException(OptionError,"MissingArgument",option);
5690 break;
5691 }
5692 if (LocaleCompare("profile",option+1) == 0)
5693 {
5694 i++;
cristybb503372010-05-27 20:51:26 +00005695 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005696 ThrowMogrifyException(OptionError,"MissingArgument",option);
5697 break;
5698 }
5699 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5700 }
5701 case 'q':
5702 {
5703 if (LocaleCompare("quality",option+1) == 0)
5704 {
5705 if (*option == '+')
5706 break;
5707 i++;
cristybb503372010-05-27 20:51:26 +00005708 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005709 ThrowMogrifyException(OptionError,"MissingArgument",option);
5710 if (IsGeometry(argv[i]) == MagickFalse)
5711 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5712 break;
5713 }
5714 if (LocaleCompare("quantize",option+1) == 0)
5715 {
cristybb503372010-05-27 20:51:26 +00005716 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00005717 colorspace;
5718
5719 if (*option == '+')
5720 break;
5721 i++;
cristybb503372010-05-27 20:51:26 +00005722 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00005723 ThrowMogrifyException(OptionError,"MissingArgument",option);
5724 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
5725 argv[i]);
5726 if (colorspace < 0)
5727 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5728 argv[i]);
5729 break;
5730 }
5731 if (LocaleCompare("quiet",option+1) == 0)
5732 break;
5733 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5734 }
5735 case 'r':
5736 {
5737 if (LocaleCompare("radial-blur",option+1) == 0)
5738 {
5739 i++;
cristybb503372010-05-27 20:51:26 +00005740 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005741 ThrowMogrifyException(OptionError,"MissingArgument",option);
5742 if (IsGeometry(argv[i]) == MagickFalse)
5743 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5744 break;
5745 }
5746 if (LocaleCompare("raise",option+1) == 0)
5747 {
5748 i++;
cristybb503372010-05-27 20:51:26 +00005749 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005750 ThrowMogrifyException(OptionError,"MissingArgument",option);
5751 if (IsGeometry(argv[i]) == MagickFalse)
5752 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5753 break;
5754 }
5755 if (LocaleCompare("random-threshold",option+1) == 0)
5756 {
5757 if (*option == '+')
5758 break;
5759 i++;
cristybb503372010-05-27 20:51:26 +00005760 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005761 ThrowMogrifyException(OptionError,"MissingArgument",option);
5762 if (IsGeometry(argv[i]) == MagickFalse)
5763 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5764 break;
5765 }
cristye6365592010-04-02 17:31:23 +00005766 if (LocaleCompare("recolor",option+1) == 0)
5767 {
5768 if (*option == '+')
5769 break;
5770 i++;
cristybb503372010-05-27 20:51:26 +00005771 if (i == (ssize_t) (argc-1))
cristye6365592010-04-02 17:31:23 +00005772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5775 break;
5776 }
cristy3ed852e2009-09-05 21:47:34 +00005777 if (LocaleCompare("red-primary",option+1) == 0)
5778 {
5779 if (*option == '+')
5780 break;
5781 i++;
cristybb503372010-05-27 20:51:26 +00005782 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005783 ThrowMogrifyException(OptionError,"MissingArgument",option);
5784 if (IsGeometry(argv[i]) == MagickFalse)
5785 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5786 }
cristy9f2083a2010-04-22 19:48:05 +00005787 if (LocaleCompare("regard-warnings",option+1) == 0)
5788 break;
cristy3ed852e2009-09-05 21:47:34 +00005789 if (LocaleCompare("region",option+1) == 0)
5790 {
5791 if (*option == '+')
5792 break;
5793 i++;
cristybb503372010-05-27 20:51:26 +00005794 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005795 ThrowMogrifyException(OptionError,"MissingArgument",option);
5796 if (IsGeometry(argv[i]) == MagickFalse)
5797 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5798 break;
5799 }
cristyf0c78232010-03-15 12:53:40 +00005800 if (LocaleCompare("remap",option+1) == 0)
5801 {
5802 if (*option == '+')
5803 break;
5804 i++;
cristybb503372010-05-27 20:51:26 +00005805 if (i == (ssize_t) (argc-1))
cristyf0c78232010-03-15 12:53:40 +00005806 ThrowMogrifyException(OptionError,"MissingArgument",option);
5807 break;
5808 }
cristy3ed852e2009-09-05 21:47:34 +00005809 if (LocaleCompare("render",option+1) == 0)
5810 break;
5811 if (LocaleCompare("repage",option+1) == 0)
5812 {
5813 if (*option == '+')
5814 break;
5815 i++;
cristybb503372010-05-27 20:51:26 +00005816 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005817 ThrowMogrifyException(OptionError,"MissingArgument",option);
5818 if (IsGeometry(argv[i]) == MagickFalse)
5819 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5820 break;
5821 }
5822 if (LocaleCompare("resample",option+1) == 0)
5823 {
5824 if (*option == '+')
5825 break;
5826 i++;
cristybb503372010-05-27 20:51:26 +00005827 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005828 ThrowMogrifyException(OptionError,"MissingArgument",option);
5829 if (IsGeometry(argv[i]) == MagickFalse)
5830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5831 break;
5832 }
5833 if (LocaleCompare("resize",option+1) == 0)
5834 {
5835 if (*option == '+')
5836 break;
5837 i++;
cristybb503372010-05-27 20:51:26 +00005838 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005839 ThrowMogrifyException(OptionError,"MissingArgument",option);
5840 if (IsGeometry(argv[i]) == MagickFalse)
5841 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5842 break;
5843 }
cristyebbcfea2011-02-25 02:43:54 +00005844 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5845 {
5846 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5847 break;
5848 }
cristy3ed852e2009-09-05 21:47:34 +00005849 if (LocaleCompare("reverse",option+1) == 0)
5850 break;
5851 if (LocaleCompare("roll",option+1) == 0)
5852 {
5853 if (*option == '+')
5854 break;
5855 i++;
cristybb503372010-05-27 20:51:26 +00005856 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005857 ThrowMogrifyException(OptionError,"MissingArgument",option);
5858 if (IsGeometry(argv[i]) == MagickFalse)
5859 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5860 break;
5861 }
5862 if (LocaleCompare("rotate",option+1) == 0)
5863 {
5864 i++;
cristybb503372010-05-27 20:51:26 +00005865 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005866 ThrowMogrifyException(OptionError,"MissingArgument",option);
5867 if (IsGeometry(argv[i]) == MagickFalse)
5868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5869 break;
5870 }
5871 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5872 }
5873 case 's':
5874 {
5875 if (LocaleCompare("sample",option+1) == 0)
5876 {
5877 if (*option == '+')
5878 break;
5879 i++;
cristybb503372010-05-27 20:51:26 +00005880 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005881 ThrowMogrifyException(OptionError,"MissingArgument",option);
5882 if (IsGeometry(argv[i]) == MagickFalse)
5883 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5884 break;
5885 }
5886 if (LocaleCompare("sampling-factor",option+1) == 0)
5887 {
5888 if (*option == '+')
5889 break;
5890 i++;
cristybb503372010-05-27 20:51:26 +00005891 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005892 ThrowMogrifyException(OptionError,"MissingArgument",option);
5893 if (IsGeometry(argv[i]) == MagickFalse)
5894 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5895 break;
5896 }
5897 if (LocaleCompare("scale",option+1) == 0)
5898 {
5899 if (*option == '+')
5900 break;
5901 i++;
cristybb503372010-05-27 20:51:26 +00005902 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005903 ThrowMogrifyException(OptionError,"MissingArgument",option);
5904 if (IsGeometry(argv[i]) == MagickFalse)
5905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5906 break;
5907 }
5908 if (LocaleCompare("scene",option+1) == 0)
5909 {
5910 if (*option == '+')
5911 break;
5912 i++;
cristybb503372010-05-27 20:51:26 +00005913 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005914 ThrowMogrifyException(OptionError,"MissingArgument",option);
5915 if (IsGeometry(argv[i]) == MagickFalse)
5916 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5917 break;
5918 }
5919 if (LocaleCompare("seed",option+1) == 0)
5920 {
5921 if (*option == '+')
5922 break;
5923 i++;
cristybb503372010-05-27 20:51:26 +00005924 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005925 ThrowMogrifyException(OptionError,"MissingArgument",option);
5926 if (IsGeometry(argv[i]) == MagickFalse)
5927 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5928 break;
5929 }
5930 if (LocaleCompare("segment",option+1) == 0)
5931 {
5932 if (*option == '+')
5933 break;
5934 i++;
cristybb503372010-05-27 20:51:26 +00005935 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005936 ThrowMogrifyException(OptionError,"MissingArgument",option);
5937 if (IsGeometry(argv[i]) == MagickFalse)
5938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5939 break;
5940 }
5941 if (LocaleCompare("selective-blur",option+1) == 0)
5942 {
5943 i++;
cristybb503372010-05-27 20:51:26 +00005944 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005945 ThrowMogrifyException(OptionError,"MissingArgument",option);
5946 if (IsGeometry(argv[i]) == MagickFalse)
5947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5948 break;
5949 }
5950 if (LocaleCompare("separate",option+1) == 0)
5951 break;
5952 if (LocaleCompare("sepia-tone",option+1) == 0)
5953 {
5954 if (*option == '+')
5955 break;
5956 i++;
cristybb503372010-05-27 20:51:26 +00005957 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005958 ThrowMogrifyException(OptionError,"MissingArgument",option);
5959 if (IsGeometry(argv[i]) == MagickFalse)
5960 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5961 break;
5962 }
5963 if (LocaleCompare("set",option+1) == 0)
5964 {
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 if (*option == '+')
5969 break;
5970 i++;
cristybb503372010-05-27 20:51:26 +00005971 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005972 ThrowMogrifyException(OptionError,"MissingArgument",option);
5973 break;
5974 }
5975 if (LocaleCompare("shade",option+1) == 0)
5976 {
5977 i++;
cristybb503372010-05-27 20:51:26 +00005978 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005979 ThrowMogrifyException(OptionError,"MissingArgument",option);
5980 if (IsGeometry(argv[i]) == MagickFalse)
5981 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5982 break;
5983 }
5984 if (LocaleCompare("shadow",option+1) == 0)
5985 {
5986 if (*option == '+')
5987 break;
5988 i++;
cristybb503372010-05-27 20:51:26 +00005989 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005990 ThrowMogrifyException(OptionError,"MissingArgument",option);
5991 if (IsGeometry(argv[i]) == MagickFalse)
5992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5993 break;
5994 }
5995 if (LocaleCompare("sharpen",option+1) == 0)
5996 {
5997 i++;
cristybb503372010-05-27 20:51:26 +00005998 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00005999 ThrowMogrifyException(OptionError,"MissingArgument",option);
6000 if (IsGeometry(argv[i]) == MagickFalse)
6001 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6002 break;
6003 }
6004 if (LocaleCompare("shave",option+1) == 0)
6005 {
6006 if (*option == '+')
6007 break;
6008 i++;
cristybb503372010-05-27 20:51:26 +00006009 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006010 ThrowMogrifyException(OptionError,"MissingArgument",option);
6011 if (IsGeometry(argv[i]) == MagickFalse)
6012 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6013 break;
6014 }
6015 if (LocaleCompare("shear",option+1) == 0)
6016 {
6017 i++;
cristybb503372010-05-27 20:51:26 +00006018 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006019 ThrowMogrifyException(OptionError,"MissingArgument",option);
6020 if (IsGeometry(argv[i]) == MagickFalse)
6021 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6022 break;
6023 }
6024 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
6025 {
6026 i++;
cristybb503372010-05-27 20:51:26 +00006027 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006028 ThrowMogrifyException(OptionError,"MissingArgument",option);
6029 if (IsGeometry(argv[i]) == MagickFalse)
6030 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6031 break;
6032 }
6033 if (LocaleCompare("size",option+1) == 0)
6034 {
6035 if (*option == '+')
6036 break;
6037 i++;
cristybb503372010-05-27 20:51:26 +00006038 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006039 ThrowMogrifyException(OptionError,"MissingArgument",option);
6040 if (IsGeometry(argv[i]) == MagickFalse)
6041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6042 break;
6043 }
6044 if (LocaleCompare("sketch",option+1) == 0)
6045 {
6046 if (*option == '+')
6047 break;
6048 i++;
cristybb503372010-05-27 20:51:26 +00006049 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006050 ThrowMogrifyException(OptionError,"MissingArgument",option);
6051 if (IsGeometry(argv[i]) == MagickFalse)
6052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6053 break;
6054 }
cristy4285d782011-02-09 20:12:28 +00006055 if (LocaleCompare("smush",option+1) == 0)
6056 {
cristy4285d782011-02-09 20:12:28 +00006057 i++;
6058 if (i == (ssize_t) argc)
6059 ThrowMogrifyException(OptionError,"MissingArgument",option);
6060 if (IsGeometry(argv[i]) == MagickFalse)
6061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
cristy4285d782011-02-09 20:12:28 +00006062 i++;
6063 break;
6064 }
cristy3ed852e2009-09-05 21:47:34 +00006065 if (LocaleCompare("solarize",option+1) == 0)
6066 {
6067 if (*option == '+')
6068 break;
6069 i++;
cristybb503372010-05-27 20:51:26 +00006070 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006071 ThrowMogrifyException(OptionError,"MissingArgument",option);
6072 if (IsGeometry(argv[i]) == MagickFalse)
6073 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6074 break;
6075 }
6076 if (LocaleCompare("sparse-color",option+1) == 0)
6077 {
cristybb503372010-05-27 20:51:26 +00006078 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006079 op;
6080
6081 i++;
cristybb503372010-05-27 20:51:26 +00006082 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006083 ThrowMogrifyException(OptionError,"MissingArgument",option);
6084 op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6085 if (op < 0)
6086 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6087 argv[i]);
6088 i++;
cristybb503372010-05-27 20:51:26 +00006089 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6091 break;
6092 }
6093 if (LocaleCompare("spread",option+1) == 0)
6094 {
6095 if (*option == '+')
6096 break;
6097 i++;
cristybb503372010-05-27 20:51:26 +00006098 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6100 if (IsGeometry(argv[i]) == MagickFalse)
6101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6102 break;
6103 }
cristy0834d642011-03-18 18:26:08 +00006104 if (LocaleCompare("statistic",option+1) == 0)
6105 {
6106 ssize_t
6107 op;
6108
6109 if (*option == '+')
6110 break;
6111 i++;
6112 if (i == (ssize_t) argc)
6113 ThrowMogrifyException(OptionError,"MissingArgument",option);
6114 op=ParseMagickOption(MagickStatisticOptions,MagickFalse,argv[i]);
6115 if (op < 0)
6116 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6117 argv[i]);
6118 i++;
6119 if (i == (ssize_t) (argc-1))
6120 ThrowMogrifyException(OptionError,"MissingArgument",option);
6121 if (IsGeometry(argv[i]) == MagickFalse)
6122 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6123 break;
6124 }
cristy3ed852e2009-09-05 21:47:34 +00006125 if (LocaleCompare("stretch",option+1) == 0)
6126 {
cristybb503372010-05-27 20:51:26 +00006127 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006128 stretch;
6129
6130 if (*option == '+')
6131 break;
6132 i++;
cristybb503372010-05-27 20:51:26 +00006133 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006134 ThrowMogrifyException(OptionError,"MissingArgument",option);
6135 stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
6136 if (stretch < 0)
6137 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6138 argv[i]);
6139 break;
6140 }
6141 if (LocaleCompare("strip",option+1) == 0)
6142 break;
6143 if (LocaleCompare("stroke",option+1) == 0)
6144 {
6145 if (*option == '+')
6146 break;
6147 i++;
cristybb503372010-05-27 20:51:26 +00006148 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006149 ThrowMogrifyException(OptionError,"MissingArgument",option);
6150 break;
6151 }
6152 if (LocaleCompare("strokewidth",option+1) == 0)
6153 {
6154 if (*option == '+')
6155 break;
6156 i++;
cristybb503372010-05-27 20:51:26 +00006157 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006158 ThrowMogrifyException(OptionError,"MissingArgument",option);
6159 if (IsGeometry(argv[i]) == MagickFalse)
6160 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6161 break;
6162 }
6163 if (LocaleCompare("style",option+1) == 0)
6164 {
cristybb503372010-05-27 20:51:26 +00006165 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006166 style;
6167
6168 if (*option == '+')
6169 break;
6170 i++;
cristybb503372010-05-27 20:51:26 +00006171 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006172 ThrowMogrifyException(OptionError,"MissingArgument",option);
6173 style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
6174 if (style < 0)
6175 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6176 argv[i]);
6177 break;
6178 }
cristyecb10ff2011-03-22 13:14:03 +00006179 if (LocaleCompare("swap",option+1) == 0)
6180 {
6181 if (*option == '+')
6182 break;
6183 i++;
6184 if (i == (ssize_t) (argc-1))
6185 ThrowMogrifyException(OptionError,"MissingArgument",option);
6186 if (IsGeometry(argv[i]) == MagickFalse)
6187 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6188 break;
6189 }
cristy3ed852e2009-09-05 21:47:34 +00006190 if (LocaleCompare("swirl",option+1) == 0)
6191 {
6192 if (*option == '+')
6193 break;
6194 i++;
cristybb503372010-05-27 20:51:26 +00006195 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006196 ThrowMogrifyException(OptionError,"MissingArgument",option);
6197 if (IsGeometry(argv[i]) == MagickFalse)
6198 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6199 break;
6200 }
cristyd9a29192010-10-16 16:49:53 +00006201 if (LocaleCompare("synchronize",option+1) == 0)
6202 break;
cristy3ed852e2009-09-05 21:47:34 +00006203 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6204 }
6205 case 't':
6206 {
6207 if (LocaleCompare("taint",option+1) == 0)
6208 break;
6209 if (LocaleCompare("texture",option+1) == 0)
6210 {
6211 if (*option == '+')
6212 break;
6213 i++;
cristybb503372010-05-27 20:51:26 +00006214 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006215 ThrowMogrifyException(OptionError,"MissingArgument",option);
6216 break;
6217 }
6218 if (LocaleCompare("tile",option+1) == 0)
6219 {
6220 if (*option == '+')
6221 break;
6222 i++;
cristybb503372010-05-27 20:51:26 +00006223 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006224 ThrowMogrifyException(OptionError,"MissingArgument",option);
6225 break;
6226 }
6227 if (LocaleCompare("tile-offset",option+1) == 0)
6228 {
6229 if (*option == '+')
6230 break;
6231 i++;
cristybb503372010-05-27 20:51:26 +00006232 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006233 ThrowMogrifyException(OptionError,"MissingArgument",option);
6234 if (IsGeometry(argv[i]) == MagickFalse)
6235 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6236 break;
6237 }
6238 if (LocaleCompare("tint",option+1) == 0)
6239 {
6240 if (*option == '+')
6241 break;
6242 i++;
cristybb503372010-05-27 20:51:26 +00006243 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006244 ThrowMogrifyException(OptionError,"MissingArgument",option);
6245 if (IsGeometry(argv[i]) == MagickFalse)
6246 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6247 break;
6248 }
6249 if (LocaleCompare("transform",option+1) == 0)
6250 break;
6251 if (LocaleCompare("transpose",option+1) == 0)
6252 break;
6253 if (LocaleCompare("transverse",option+1) == 0)
6254 break;
6255 if (LocaleCompare("threshold",option+1) == 0)
6256 {
6257 if (*option == '+')
6258 break;
6259 i++;
cristybb503372010-05-27 20:51:26 +00006260 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006261 ThrowMogrifyException(OptionError,"MissingArgument",option);
6262 if (IsGeometry(argv[i]) == MagickFalse)
6263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6264 break;
6265 }
6266 if (LocaleCompare("thumbnail",option+1) == 0)
6267 {
6268 if (*option == '+')
6269 break;
6270 i++;
cristybb503372010-05-27 20:51:26 +00006271 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006272 ThrowMogrifyException(OptionError,"MissingArgument",option);
6273 if (IsGeometry(argv[i]) == MagickFalse)
6274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6275 break;
6276 }
6277 if (LocaleCompare("transparent",option+1) == 0)
6278 {
6279 i++;
cristybb503372010-05-27 20:51:26 +00006280 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006281 ThrowMogrifyException(OptionError,"MissingArgument",option);
6282 break;
6283 }
6284 if (LocaleCompare("transparent-color",option+1) == 0)
6285 {
6286 if (*option == '+')
6287 break;
6288 i++;
cristybb503372010-05-27 20:51:26 +00006289 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006290 ThrowMogrifyException(OptionError,"MissingArgument",option);
6291 break;
6292 }
6293 if (LocaleCompare("treedepth",option+1) == 0)
6294 {
6295 if (*option == '+')
6296 break;
6297 i++;
cristybb503372010-05-27 20:51:26 +00006298 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006299 ThrowMogrifyException(OptionError,"MissingArgument",option);
6300 if (IsGeometry(argv[i]) == MagickFalse)
6301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6302 break;
6303 }
6304 if (LocaleCompare("trim",option+1) == 0)
6305 break;
6306 if (LocaleCompare("type",option+1) == 0)
6307 {
cristybb503372010-05-27 20:51:26 +00006308 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006309 type;
6310
6311 if (*option == '+')
6312 break;
6313 i++;
cristybb503372010-05-27 20:51:26 +00006314 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006315 ThrowMogrifyException(OptionError,"MissingArgument",option);
6316 type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
6317 if (type < 0)
6318 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6319 argv[i]);
6320 break;
6321 }
6322 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6323 }
6324 case 'u':
6325 {
6326 if (LocaleCompare("undercolor",option+1) == 0)
6327 {
6328 if (*option == '+')
6329 break;
6330 i++;
cristybb503372010-05-27 20:51:26 +00006331 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006332 ThrowMogrifyException(OptionError,"MissingArgument",option);
6333 break;
6334 }
6335 if (LocaleCompare("unique-colors",option+1) == 0)
6336 break;
6337 if (LocaleCompare("units",option+1) == 0)
6338 {
cristybb503372010-05-27 20:51:26 +00006339 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006340 units;
6341
6342 if (*option == '+')
6343 break;
6344 i++;
cristybb503372010-05-27 20:51:26 +00006345 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006346 ThrowMogrifyException(OptionError,"MissingArgument",option);
6347 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
6348 argv[i]);
6349 if (units < 0)
6350 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6351 argv[i]);
6352 break;
6353 }
6354 if (LocaleCompare("unsharp",option+1) == 0)
6355 {
6356 i++;
cristybb503372010-05-27 20:51:26 +00006357 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006358 ThrowMogrifyException(OptionError,"MissingArgument",option);
6359 if (IsGeometry(argv[i]) == MagickFalse)
6360 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6361 break;
6362 }
6363 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6364 }
6365 case 'v':
6366 {
6367 if (LocaleCompare("verbose",option+1) == 0)
6368 {
6369 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6370 break;
6371 }
6372 if ((LocaleCompare("version",option+1) == 0) ||
6373 (LocaleCompare("-version",option+1) == 0))
6374 {
6375 (void) fprintf(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00006376 GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +00006377 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
6378 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00006379 break;
6380 }
6381 if (LocaleCompare("view",option+1) == 0)
6382 {
6383 if (*option == '+')
6384 break;
6385 i++;
cristybb503372010-05-27 20:51:26 +00006386 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006387 ThrowMogrifyException(OptionError,"MissingArgument",option);
6388 break;
6389 }
6390 if (LocaleCompare("vignette",option+1) == 0)
6391 {
6392 if (*option == '+')
6393 break;
6394 i++;
cristybb503372010-05-27 20:51:26 +00006395 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006396 ThrowMogrifyException(OptionError,"MissingArgument",option);
6397 if (IsGeometry(argv[i]) == MagickFalse)
6398 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6399 break;
6400 }
6401 if (LocaleCompare("virtual-pixel",option+1) == 0)
6402 {
cristybb503372010-05-27 20:51:26 +00006403 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006404 method;
6405
6406 if (*option == '+')
6407 break;
6408 i++;
cristybb503372010-05-27 20:51:26 +00006409 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006410 ThrowMogrifyException(OptionError,"MissingArgument",option);
6411 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
6412 argv[i]);
6413 if (method < 0)
6414 ThrowMogrifyException(OptionError,
6415 "UnrecognizedVirtualPixelMethod",argv[i]);
6416 break;
6417 }
6418 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6419 }
6420 case 'w':
6421 {
6422 if (LocaleCompare("wave",option+1) == 0)
6423 {
6424 i++;
cristybb503372010-05-27 20:51:26 +00006425 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006426 ThrowMogrifyException(OptionError,"MissingArgument",option);
6427 if (IsGeometry(argv[i]) == MagickFalse)
6428 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6429 break;
6430 }
6431 if (LocaleCompare("weight",option+1) == 0)
6432 {
6433 if (*option == '+')
6434 break;
6435 i++;
cristybb503372010-05-27 20:51:26 +00006436 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006437 ThrowMogrifyException(OptionError,"MissingArgument",option);
6438 break;
6439 }
6440 if (LocaleCompare("white-point",option+1) == 0)
6441 {
6442 if (*option == '+')
6443 break;
6444 i++;
cristybb503372010-05-27 20:51:26 +00006445 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006446 ThrowMogrifyException(OptionError,"MissingArgument",option);
6447 if (IsGeometry(argv[i]) == MagickFalse)
6448 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6449 break;
6450 }
6451 if (LocaleCompare("white-threshold",option+1) == 0)
6452 {
6453 if (*option == '+')
6454 break;
6455 i++;
cristybb503372010-05-27 20:51:26 +00006456 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006457 ThrowMogrifyException(OptionError,"MissingArgument",option);
6458 if (IsGeometry(argv[i]) == MagickFalse)
6459 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6460 break;
6461 }
6462 if (LocaleCompare("write",option+1) == 0)
6463 {
6464 i++;
cristybb503372010-05-27 20:51:26 +00006465 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00006466 ThrowMogrifyException(OptionError,"MissingArgument",option);
6467 break;
6468 }
6469 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6470 }
6471 case '?':
6472 break;
6473 default:
6474 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6475 }
6476 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
6477 MagickFalse : MagickTrue;
6478 if (fire != MagickFalse)
6479 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6480 }
6481 if (k != 0)
6482 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00006483 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006484 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6485 DestroyMogrify();
6486 return(status != 0 ? MagickTrue : MagickFalse);
6487}
6488
6489/*
6490%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6491% %
6492% %
6493% %
6494+ M o g r i f y I m a g e I n f o %
6495% %
6496% %
6497% %
6498%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6499%
6500% MogrifyImageInfo() applies image processing settings to the image as
6501% prescribed by command line options.
6502%
6503% The format of the MogrifyImageInfo method is:
6504%
6505% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6506% const char **argv,ExceptionInfo *exception)
6507%
6508% A description of each parameter follows:
6509%
6510% o image_info: the image info..
6511%
6512% o argc: Specifies a pointer to an integer describing the number of
6513% elements in the argument vector.
6514%
6515% o argv: Specifies a pointer to a text array containing the command line
6516% arguments.
6517%
6518% o exception: return any errors or warnings in this structure.
6519%
6520*/
6521WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6522 const int argc,const char **argv,ExceptionInfo *exception)
6523{
6524 const char
6525 *option;
6526
6527 GeometryInfo
6528 geometry_info;
6529
cristybb503372010-05-27 20:51:26 +00006530 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006531 count;
6532
cristybb503372010-05-27 20:51:26 +00006533 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00006534 i;
6535
6536 /*
6537 Initialize method variables.
6538 */
6539 assert(image_info != (ImageInfo *) NULL);
6540 assert(image_info->signature == MagickSignature);
6541 if (image_info->debug != MagickFalse)
6542 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6543 image_info->filename);
6544 if (argc < 0)
6545 return(MagickTrue);
6546 /*
6547 Set the image settings.
6548 */
cristybb503372010-05-27 20:51:26 +00006549 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00006550 {
6551 option=argv[i];
6552 if (IsMagickOption(option) == MagickFalse)
6553 continue;
6554 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
6555 0L);
cristycee97112010-05-28 00:44:52 +00006556 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00006557 break;
6558 switch (*(option+1))
6559 {
6560 case 'a':
6561 {
6562 if (LocaleCompare("adjoin",option+1) == 0)
6563 {
6564 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6565 break;
6566 }
6567 if (LocaleCompare("antialias",option+1) == 0)
6568 {
6569 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6570 break;
6571 }
6572 if (LocaleCompare("attenuate",option+1) == 0)
6573 {
6574 if (*option == '+')
6575 {
6576 (void) DeleteImageOption(image_info,option+1);
6577 break;
6578 }
6579 (void) SetImageOption(image_info,option+1,argv[i+1]);
6580 break;
6581 }
6582 if (LocaleCompare("authenticate",option+1) == 0)
6583 {
6584 if (*option == '+')
6585 (void) CloneString(&image_info->authenticate,(char *) NULL);
6586 else
6587 (void) CloneString(&image_info->authenticate,argv[i+1]);
6588 break;
6589 }
6590 break;
6591 }
6592 case 'b':
6593 {
6594 if (LocaleCompare("background",option+1) == 0)
6595 {
6596 if (*option == '+')
6597 {
6598 (void) DeleteImageOption(image_info,option+1);
6599 (void) QueryColorDatabase(BackgroundColor,
6600 &image_info->background_color,exception);
6601 break;
6602 }
6603 (void) SetImageOption(image_info,option+1,argv[i+1]);
6604 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6605 exception);
6606 break;
6607 }
6608 if (LocaleCompare("bias",option+1) == 0)
6609 {
6610 if (*option == '+')
6611 {
6612 (void) SetImageOption(image_info,option+1,"0.0");
6613 break;
6614 }
6615 (void) SetImageOption(image_info,option+1,argv[i+1]);
6616 break;
6617 }
6618 if (LocaleCompare("black-point-compensation",option+1) == 0)
6619 {
6620 if (*option == '+')
6621 {
6622 (void) SetImageOption(image_info,option+1,"false");
6623 break;
6624 }
6625 (void) SetImageOption(image_info,option+1,"true");
6626 break;
6627 }
6628 if (LocaleCompare("blue-primary",option+1) == 0)
6629 {
6630 if (*option == '+')
6631 {
6632 (void) SetImageOption(image_info,option+1,"0.0");
6633 break;
6634 }
6635 (void) SetImageOption(image_info,option+1,argv[i+1]);
6636 break;
6637 }
6638 if (LocaleCompare("bordercolor",option+1) == 0)
6639 {
6640 if (*option == '+')
6641 {
6642 (void) DeleteImageOption(image_info,option+1);
6643 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6644 exception);
6645 break;
6646 }
6647 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6648 exception);
6649 (void) SetImageOption(image_info,option+1,argv[i+1]);
6650 break;
6651 }
6652 if (LocaleCompare("box",option+1) == 0)
6653 {
6654 if (*option == '+')
6655 {
6656 (void) SetImageOption(image_info,"undercolor","none");
6657 break;
6658 }
6659 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6660 break;
6661 }
6662 break;
6663 }
6664 case 'c':
6665 {
6666 if (LocaleCompare("cache",option+1) == 0)
6667 {
6668 MagickSizeType
6669 limit;
6670
6671 limit=MagickResourceInfinity;
6672 if (LocaleCompare("unlimited",argv[i+1]) != 0)
cristyf2f27272009-12-17 14:48:46 +00006673 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
cristy3ed852e2009-09-05 21:47:34 +00006674 (void) SetMagickResourceLimit(MemoryResource,limit);
6675 (void) SetMagickResourceLimit(MapResource,2*limit);
6676 break;
6677 }
6678 if (LocaleCompare("caption",option+1) == 0)
6679 {
6680 if (*option == '+')
6681 {
6682 (void) DeleteImageOption(image_info,option+1);
6683 break;
6684 }
6685 (void) SetImageOption(image_info,option+1,argv[i+1]);
6686 break;
6687 }
6688 if (LocaleCompare("channel",option+1) == 0)
6689 {
6690 if (*option == '+')
6691 {
6692 image_info->channel=DefaultChannels;
6693 break;
6694 }
6695 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6696 break;
6697 }
6698 if (LocaleCompare("colors",option+1) == 0)
6699 {
cristye27293e2009-12-18 02:53:20 +00006700 image_info->colors=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006701 break;
6702 }
6703 if (LocaleCompare("colorspace",option+1) == 0)
6704 {
6705 if (*option == '+')
6706 {
6707 image_info->colorspace=UndefinedColorspace;
6708 (void) SetImageOption(image_info,option+1,"undefined");
6709 break;
6710 }
6711 image_info->colorspace=(ColorspaceType) ParseMagickOption(
6712 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6713 (void) SetImageOption(image_info,option+1,argv[i+1]);
6714 break;
6715 }
6716 if (LocaleCompare("compress",option+1) == 0)
6717 {
6718 if (*option == '+')
6719 {
6720 image_info->compression=UndefinedCompression;
6721 (void) SetImageOption(image_info,option+1,"undefined");
6722 break;
6723 }
6724 image_info->compression=(CompressionType) ParseMagickOption(
6725 MagickCompressOptions,MagickFalse,argv[i+1]);
6726 (void) SetImageOption(image_info,option+1,argv[i+1]);
6727 break;
6728 }
6729 if (LocaleCompare("comment",option+1) == 0)
6730 {
6731 if (*option == '+')
6732 {
6733 (void) DeleteImageOption(image_info,option+1);
6734 break;
6735 }
6736 (void) SetImageOption(image_info,option+1,argv[i+1]);
6737 break;
6738 }
6739 if (LocaleCompare("compose",option+1) == 0)
6740 {
6741 if (*option == '+')
6742 {
6743 (void) SetImageOption(image_info,option+1,"undefined");
6744 break;
6745 }
6746 (void) SetImageOption(image_info,option+1,argv[i+1]);
6747 break;
6748 }
6749 if (LocaleCompare("compress",option+1) == 0)
6750 {
6751 if (*option == '+')
6752 {
6753 image_info->compression=UndefinedCompression;
6754 (void) SetImageOption(image_info,option+1,"undefined");
6755 break;
6756 }
6757 image_info->compression=(CompressionType) ParseMagickOption(
6758 MagickCompressOptions,MagickFalse,argv[i+1]);
6759 (void) SetImageOption(image_info,option+1,argv[i+1]);
6760 break;
6761 }
6762 break;
6763 }
6764 case 'd':
6765 {
6766 if (LocaleCompare("debug",option+1) == 0)
6767 {
6768 if (*option == '+')
6769 (void) SetLogEventMask("none");
6770 else
6771 (void) SetLogEventMask(argv[i+1]);
6772 image_info->debug=IsEventLogging();
6773 break;
6774 }
6775 if (LocaleCompare("define",option+1) == 0)
6776 {
6777 if (*option == '+')
6778 {
6779 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6780 (void) DeleteImageRegistry(argv[i+1]+9);
6781 else
6782 (void) DeleteImageOption(image_info,argv[i+1]);
6783 break;
6784 }
6785 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6786 {
6787 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6788 exception);
6789 break;
6790 }
6791 (void) DefineImageOption(image_info,argv[i+1]);
6792 break;
6793 }
6794 if (LocaleCompare("delay",option+1) == 0)
6795 {
6796 if (*option == '+')
6797 {
6798 (void) SetImageOption(image_info,option+1,"0");
6799 break;
6800 }
6801 (void) SetImageOption(image_info,option+1,argv[i+1]);
6802 break;
6803 }
6804 if (LocaleCompare("density",option+1) == 0)
6805 {
6806 /*
6807 Set image density.
6808 */
6809 if (*option == '+')
6810 {
6811 if (image_info->density != (char *) NULL)
6812 image_info->density=DestroyString(image_info->density);
6813 (void) SetImageOption(image_info,option+1,"72");
6814 break;
6815 }
6816 (void) CloneString(&image_info->density,argv[i+1]);
6817 (void) SetImageOption(image_info,option+1,argv[i+1]);
6818 break;
6819 }
6820 if (LocaleCompare("depth",option+1) == 0)
6821 {
6822 if (*option == '+')
6823 {
6824 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6825 break;
6826 }
cristye27293e2009-12-18 02:53:20 +00006827 image_info->depth=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00006828 break;
6829 }
cristyc9b12952010-03-28 01:12:28 +00006830 if (LocaleCompare("direction",option+1) == 0)
6831 {
6832 if (*option == '+')
6833 {
6834 (void) SetImageOption(image_info,option+1,"undefined");
6835 break;
6836 }
6837 (void) SetImageOption(image_info,option+1,argv[i+1]);
6838 break;
6839 }
cristy3ed852e2009-09-05 21:47:34 +00006840 if (LocaleCompare("display",option+1) == 0)
6841 {
6842 if (*option == '+')
6843 {
6844 if (image_info->server_name != (char *) NULL)
6845 image_info->server_name=DestroyString(
6846 image_info->server_name);
6847 break;
6848 }
6849 (void) CloneString(&image_info->server_name,argv[i+1]);
6850 break;
6851 }
6852 if (LocaleCompare("dispose",option+1) == 0)
6853 {
6854 if (*option == '+')
6855 {
6856 (void) SetImageOption(image_info,option+1,"undefined");
6857 break;
6858 }
6859 (void) SetImageOption(image_info,option+1,argv[i+1]);
6860 break;
6861 }
6862 if (LocaleCompare("dither",option+1) == 0)
6863 {
6864 if (*option == '+')
6865 {
6866 image_info->dither=MagickFalse;
cristyd5acfd12010-06-15 00:11:38 +00006867 (void) SetImageOption(image_info,option+1,"none");
cristy3ed852e2009-09-05 21:47:34 +00006868 break;
6869 }
6870 (void) SetImageOption(image_info,option+1,argv[i+1]);
6871 image_info->dither=MagickTrue;
6872 break;
6873 }
6874 break;
6875 }
6876 case 'e':
6877 {
6878 if (LocaleCompare("encoding",option+1) == 0)
6879 {
6880 if (*option == '+')
6881 {
6882 (void) SetImageOption(image_info,option+1,"undefined");
6883 break;
6884 }
6885 (void) SetImageOption(image_info,option+1,argv[i+1]);
6886 break;
6887 }
6888 if (LocaleCompare("endian",option+1) == 0)
6889 {
6890 if (*option == '+')
6891 {
6892 image_info->endian=UndefinedEndian;
6893 (void) SetImageOption(image_info,option+1,"undefined");
6894 break;
6895 }
6896 image_info->endian=(EndianType) ParseMagickOption(
6897 MagickEndianOptions,MagickFalse,argv[i+1]);
6898 (void) SetImageOption(image_info,option+1,argv[i+1]);
6899 break;
6900 }
6901 if (LocaleCompare("extract",option+1) == 0)
6902 {
6903 /*
6904 Set image extract geometry.
6905 */
6906 if (*option == '+')
6907 {
6908 if (image_info->extract != (char *) NULL)
6909 image_info->extract=DestroyString(image_info->extract);
6910 break;
6911 }
6912 (void) CloneString(&image_info->extract,argv[i+1]);
6913 break;
6914 }
6915 break;
6916 }
6917 case 'f':
6918 {
6919 if (LocaleCompare("fill",option+1) == 0)
6920 {
6921 if (*option == '+')
6922 {
6923 (void) SetImageOption(image_info,option+1,"none");
6924 break;
6925 }
6926 (void) SetImageOption(image_info,option+1,argv[i+1]);
6927 break;
6928 }
6929 if (LocaleCompare("filter",option+1) == 0)
6930 {
6931 if (*option == '+')
6932 {
6933 (void) SetImageOption(image_info,option+1,"undefined");
6934 break;
6935 }
6936 (void) SetImageOption(image_info,option+1,argv[i+1]);
6937 break;
6938 }
6939 if (LocaleCompare("font",option+1) == 0)
6940 {
6941 if (*option == '+')
6942 {
6943 if (image_info->font != (char *) NULL)
6944 image_info->font=DestroyString(image_info->font);
6945 break;
6946 }
6947 (void) CloneString(&image_info->font,argv[i+1]);
6948 break;
6949 }
6950 if (LocaleCompare("format",option+1) == 0)
6951 {
6952 register const char
6953 *q;
6954
6955 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
cristy9ed85672011-03-02 00:19:13 +00006956 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00006957 image_info->ping=MagickFalse;
6958 (void) SetImageOption(image_info,option+1,argv[i+1]);
6959 break;
6960 }
6961 if (LocaleCompare("fuzz",option+1) == 0)
6962 {
6963 if (*option == '+')
6964 {
6965 image_info->fuzz=0.0;
6966 (void) SetImageOption(image_info,option+1,"0");
6967 break;
6968 }
cristyf2f27272009-12-17 14:48:46 +00006969 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
cristy3ed852e2009-09-05 21:47:34 +00006970 1.0);
6971 (void) SetImageOption(image_info,option+1,argv[i+1]);
6972 break;
6973 }
6974 break;
6975 }
6976 case 'g':
6977 {
6978 if (LocaleCompare("gravity",option+1) == 0)
6979 {
6980 if (*option == '+')
6981 {
6982 (void) SetImageOption(image_info,option+1,"undefined");
6983 break;
6984 }
6985 (void) SetImageOption(image_info,option+1,argv[i+1]);
6986 break;
6987 }
6988 if (LocaleCompare("green-primary",option+1) == 0)
6989 {
6990 if (*option == '+')
6991 {
6992 (void) SetImageOption(image_info,option+1,"0.0");
6993 break;
6994 }
6995 (void) SetImageOption(image_info,option+1,argv[i+1]);
6996 break;
6997 }
6998 break;
6999 }
7000 case 'i':
7001 {
7002 if (LocaleCompare("intent",option+1) == 0)
7003 {
7004 if (*option == '+')
7005 {
7006 (void) SetImageOption(image_info,option+1,"undefined");
7007 break;
7008 }
7009 (void) SetImageOption(image_info,option+1,argv[i+1]);
7010 break;
7011 }
7012 if (LocaleCompare("interlace",option+1) == 0)
7013 {
7014 if (*option == '+')
7015 {
7016 image_info->interlace=UndefinedInterlace;
7017 (void) SetImageOption(image_info,option+1,"undefined");
7018 break;
7019 }
7020 image_info->interlace=(InterlaceType) ParseMagickOption(
7021 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7022 (void) SetImageOption(image_info,option+1,argv[i+1]);
7023 break;
7024 }
cristyb32b90a2009-09-07 21:45:48 +00007025 if (LocaleCompare("interline-spacing",option+1) == 0)
7026 {
7027 if (*option == '+')
7028 {
7029 (void) SetImageOption(image_info,option+1,"undefined");
7030 break;
7031 }
7032 (void) SetImageOption(image_info,option+1,argv[i+1]);
7033 break;
7034 }
cristy3ed852e2009-09-05 21:47:34 +00007035 if (LocaleCompare("interpolate",option+1) == 0)
7036 {
7037 if (*option == '+')
7038 {
7039 (void) SetImageOption(image_info,option+1,"undefined");
7040 break;
7041 }
7042 (void) SetImageOption(image_info,option+1,argv[i+1]);
7043 break;
7044 }
7045 if (LocaleCompare("interword-spacing",option+1) == 0)
7046 {
7047 if (*option == '+')
7048 {
7049 (void) SetImageOption(image_info,option+1,"undefined");
7050 break;
7051 }
7052 (void) SetImageOption(image_info,option+1,argv[i+1]);
7053 break;
7054 }
7055 break;
7056 }
7057 case 'k':
7058 {
7059 if (LocaleCompare("kerning",option+1) == 0)
7060 {
7061 if (*option == '+')
7062 {
7063 (void) SetImageOption(image_info,option+1,"undefined");
7064 break;
7065 }
7066 (void) SetImageOption(image_info,option+1,argv[i+1]);
7067 break;
7068 }
7069 break;
7070 }
7071 case 'l':
7072 {
7073 if (LocaleCompare("label",option+1) == 0)
7074 {
7075 if (*option == '+')
7076 {
7077 (void) DeleteImageOption(image_info,option+1);
7078 break;
7079 }
7080 (void) SetImageOption(image_info,option+1,argv[i+1]);
7081 break;
7082 }
7083 if (LocaleCompare("limit",option+1) == 0)
7084 {
7085 MagickSizeType
7086 limit;
7087
7088 ResourceType
7089 type;
7090
7091 if (*option == '+')
7092 break;
7093 type=(ResourceType) ParseMagickOption(MagickResourceOptions,
7094 MagickFalse,argv[i+1]);
7095 limit=MagickResourceInfinity;
7096 if (LocaleCompare("unlimited",argv[i+2]) != 0)
cristyf2f27272009-12-17 14:48:46 +00007097 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
cristy3ed852e2009-09-05 21:47:34 +00007098 (void) SetMagickResourceLimit(type,limit);
7099 break;
7100 }
7101 if (LocaleCompare("list",option+1) == 0)
7102 {
cristybb503372010-05-27 20:51:26 +00007103 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007104 list;
7105
7106 /*
7107 Display configuration list.
7108 */
7109 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]);
7110 switch (list)
7111 {
7112 case MagickCoderOptions:
7113 {
7114 (void) ListCoderInfo((FILE *) NULL,exception);
7115 break;
7116 }
7117 case MagickColorOptions:
7118 {
7119 (void) ListColorInfo((FILE *) NULL,exception);
7120 break;
7121 }
7122 case MagickConfigureOptions:
7123 {
7124 (void) ListConfigureInfo((FILE *) NULL,exception);
7125 break;
7126 }
7127 case MagickDelegateOptions:
7128 {
7129 (void) ListDelegateInfo((FILE *) NULL,exception);
7130 break;
7131 }
7132 case MagickFontOptions:
7133 {
7134 (void) ListTypeInfo((FILE *) NULL,exception);
7135 break;
7136 }
7137 case MagickFormatOptions:
7138 {
7139 (void) ListMagickInfo((FILE *) NULL,exception);
7140 break;
7141 }
7142 case MagickLocaleOptions:
7143 {
7144 (void) ListLocaleInfo((FILE *) NULL,exception);
7145 break;
7146 }
7147 case MagickLogOptions:
7148 {
7149 (void) ListLogInfo((FILE *) NULL,exception);
7150 break;
7151 }
7152 case MagickMagicOptions:
7153 {
7154 (void) ListMagicInfo((FILE *) NULL,exception);
7155 break;
7156 }
7157 case MagickMimeOptions:
7158 {
7159 (void) ListMimeInfo((FILE *) NULL,exception);
7160 break;
7161 }
7162 case MagickModuleOptions:
7163 {
7164 (void) ListModuleInfo((FILE *) NULL,exception);
7165 break;
7166 }
7167 case MagickPolicyOptions:
7168 {
7169 (void) ListPolicyInfo((FILE *) NULL,exception);
7170 break;
7171 }
7172 case MagickResourceOptions:
7173 {
7174 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7175 break;
7176 }
7177 case MagickThresholdOptions:
7178 {
7179 (void) ListThresholdMaps((FILE *) NULL,exception);
7180 break;
7181 }
7182 default:
7183 {
7184 (void) ListMagickOptions((FILE *) NULL,(MagickOption) list,
7185 exception);
7186 break;
7187 }
7188 }
cristyaeb2cbc2010-05-07 13:28:58 +00007189 break;
cristy3ed852e2009-09-05 21:47:34 +00007190 }
7191 if (LocaleCompare("log",option+1) == 0)
7192 {
7193 if (*option == '+')
7194 break;
7195 (void) SetLogFormat(argv[i+1]);
7196 break;
7197 }
7198 if (LocaleCompare("loop",option+1) == 0)
7199 {
7200 if (*option == '+')
7201 {
7202 (void) SetImageOption(image_info,option+1,"0");
7203 break;
7204 }
7205 (void) SetImageOption(image_info,option+1,argv[i+1]);
7206 break;
7207 }
7208 break;
7209 }
7210 case 'm':
7211 {
7212 if (LocaleCompare("matte",option+1) == 0)
7213 {
7214 if (*option == '+')
7215 {
7216 (void) SetImageOption(image_info,option+1,"false");
7217 break;
7218 }
7219 (void) SetImageOption(image_info,option+1,"true");
7220 break;
7221 }
7222 if (LocaleCompare("mattecolor",option+1) == 0)
7223 {
7224 if (*option == '+')
7225 {
7226 (void) SetImageOption(image_info,option+1,argv[i+1]);
7227 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
7228 exception);
7229 break;
7230 }
7231 (void) SetImageOption(image_info,option+1,argv[i+1]);
7232 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
7233 exception);
7234 break;
7235 }
7236 if (LocaleCompare("monitor",option+1) == 0)
7237 {
7238 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7239 (void *) NULL);
7240 break;
7241 }
7242 if (LocaleCompare("monochrome",option+1) == 0)
7243 {
7244 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7245 break;
7246 }
7247 break;
7248 }
7249 case 'o':
7250 {
7251 if (LocaleCompare("orient",option+1) == 0)
7252 {
7253 if (*option == '+')
7254 {
7255 image_info->orientation=UndefinedOrientation;
7256 (void) SetImageOption(image_info,option+1,"undefined");
7257 break;
7258 }
7259 image_info->orientation=(OrientationType) ParseMagickOption(
7260 MagickOrientationOptions,MagickFalse,argv[i+1]);
cristyc6e214d2010-08-08 00:31:08 +00007261 (void) SetImageOption(image_info,option+1,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007262 break;
7263 }
7264 }
7265 case 'p':
7266 {
7267 if (LocaleCompare("page",option+1) == 0)
7268 {
7269 char
7270 *canonical_page,
7271 page[MaxTextExtent];
7272
7273 const char
7274 *image_option;
7275
7276 MagickStatusType
7277 flags;
7278
7279 RectangleInfo
7280 geometry;
7281
7282 if (*option == '+')
7283 {
7284 (void) DeleteImageOption(image_info,option+1);
7285 (void) CloneString(&image_info->page,(char *) NULL);
7286 break;
7287 }
7288 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7289 image_option=GetImageOption(image_info,"page");
7290 if (image_option != (const char *) NULL)
7291 flags=ParseAbsoluteGeometry(image_option,&geometry);
7292 canonical_page=GetPageGeometry(argv[i+1]);
7293 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7294 canonical_page=DestroyString(canonical_page);
7295 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
cristyf2faecf2010-05-28 19:19:36 +00007296 (unsigned long) geometry.width,(unsigned long) geometry.height);
cristy3ed852e2009-09-05 21:47:34 +00007297 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7298 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
cristyf2faecf2010-05-28 19:19:36 +00007299 (unsigned long) geometry.width,(unsigned long) geometry.height,
7300 (long) geometry.x,(long) geometry.y);
cristy3ed852e2009-09-05 21:47:34 +00007301 (void) SetImageOption(image_info,option+1,page);
7302 (void) CloneString(&image_info->page,page);
7303 break;
7304 }
7305 if (LocaleCompare("pen",option+1) == 0)
7306 {
7307 if (*option == '+')
7308 {
7309 (void) SetImageOption(image_info,option+1,"none");
7310 break;
7311 }
7312 (void) SetImageOption(image_info,option+1,argv[i+1]);
7313 break;
7314 }
7315 if (LocaleCompare("ping",option+1) == 0)
7316 {
7317 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7318 break;
7319 }
7320 if (LocaleCompare("pointsize",option+1) == 0)
7321 {
7322 if (*option == '+')
7323 geometry_info.rho=0.0;
7324 else
7325 (void) ParseGeometry(argv[i+1],&geometry_info);
7326 image_info->pointsize=geometry_info.rho;
7327 break;
7328 }
cristye7f51092010-01-17 00:39:37 +00007329 if (LocaleCompare("precision",option+1) == 0)
7330 {
cristybf2766a2010-01-17 03:33:23 +00007331 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
cristye7f51092010-01-17 00:39:37 +00007332 break;
7333 }
cristy3ed852e2009-09-05 21:47:34 +00007334 if (LocaleCompare("preview",option+1) == 0)
7335 {
7336 /*
7337 Preview image.
7338 */
7339 if (*option == '+')
7340 {
7341 image_info->preview_type=UndefinedPreview;
7342 break;
7343 }
7344 image_info->preview_type=(PreviewType) ParseMagickOption(
7345 MagickPreviewOptions,MagickFalse,argv[i+1]);
7346 break;
7347 }
7348 break;
7349 }
7350 case 'q':
7351 {
7352 if (LocaleCompare("quality",option+1) == 0)
7353 {
7354 /*
7355 Set image compression quality.
7356 */
7357 if (*option == '+')
7358 {
7359 image_info->quality=UndefinedCompressionQuality;
7360 (void) SetImageOption(image_info,option+1,"0");
7361 break;
7362 }
cristye27293e2009-12-18 02:53:20 +00007363 image_info->quality=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007364 (void) SetImageOption(image_info,option+1,argv[i+1]);
7365 break;
7366 }
7367 if (LocaleCompare("quiet",option+1) == 0)
7368 {
7369 static WarningHandler
7370 warning_handler = (WarningHandler) NULL;
7371
7372 if (*option == '+')
7373 {
7374 /*
7375 Restore error or warning messages.
7376 */
7377 warning_handler=SetWarningHandler(warning_handler);
7378 break;
7379 }
7380 /*
7381 Suppress error or warning messages.
7382 */
7383 warning_handler=SetWarningHandler((WarningHandler) NULL);
7384 break;
7385 }
7386 break;
7387 }
7388 case 'r':
7389 {
7390 if (LocaleCompare("red-primary",option+1) == 0)
7391 {
7392 if (*option == '+')
7393 {
7394 (void) SetImageOption(image_info,option+1,"0.0");
7395 break;
7396 }
7397 (void) SetImageOption(image_info,option+1,argv[i+1]);
7398 break;
7399 }
7400 break;
7401 }
7402 case 's':
7403 {
7404 if (LocaleCompare("sampling-factor",option+1) == 0)
7405 {
7406 /*
7407 Set image sampling factor.
7408 */
7409 if (*option == '+')
7410 {
7411 if (image_info->sampling_factor != (char *) NULL)
7412 image_info->sampling_factor=DestroyString(
7413 image_info->sampling_factor);
7414 break;
7415 }
7416 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7417 break;
7418 }
7419 if (LocaleCompare("scene",option+1) == 0)
7420 {
7421 /*
7422 Set image scene.
7423 */
7424 if (*option == '+')
7425 {
7426 image_info->scene=0;
7427 (void) SetImageOption(image_info,option+1,"0");
7428 break;
7429 }
cristye27293e2009-12-18 02:53:20 +00007430 image_info->scene=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007431 (void) SetImageOption(image_info,option+1,argv[i+1]);
7432 break;
7433 }
7434 if (LocaleCompare("seed",option+1) == 0)
7435 {
cristybb503372010-05-27 20:51:26 +00007436 size_t
cristy3ed852e2009-09-05 21:47:34 +00007437 seed;
7438
7439 if (*option == '+')
7440 {
cristybb503372010-05-27 20:51:26 +00007441 seed=(size_t) time((time_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00007442 SeedPseudoRandomGenerator(seed);
7443 break;
7444 }
cristye27293e2009-12-18 02:53:20 +00007445 seed=StringToUnsignedLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00007446 SeedPseudoRandomGenerator(seed);
7447 break;
7448 }
7449 if (LocaleCompare("size",option+1) == 0)
7450 {
7451 if (*option == '+')
7452 {
7453 if (image_info->size != (char *) NULL)
7454 image_info->size=DestroyString(image_info->size);
7455 break;
7456 }
7457 (void) CloneString(&image_info->size,argv[i+1]);
7458 break;
7459 }
7460 if (LocaleCompare("stroke",option+1) == 0)
7461 {
7462 if (*option == '+')
7463 {
7464 (void) SetImageOption(image_info,option+1,"none");
7465 break;
7466 }
7467 (void) SetImageOption(image_info,option+1,argv[i+1]);
7468 break;
7469 }
7470 if (LocaleCompare("strokewidth",option+1) == 0)
7471 {
7472 if (*option == '+')
7473 {
7474 (void) SetImageOption(image_info,option+1,"0");
7475 break;
7476 }
7477 (void) SetImageOption(image_info,option+1,argv[i+1]);
7478 break;
7479 }
cristyd9a29192010-10-16 16:49:53 +00007480 if (LocaleCompare("synchronize",option+1) == 0)
7481 {
7482 if (*option == '+')
7483 {
7484 image_info->synchronize=MagickFalse;
7485 break;
7486 }
7487 image_info->synchronize=MagickTrue;
7488 break;
7489 }
cristy3ed852e2009-09-05 21:47:34 +00007490 break;
7491 }
7492 case 't':
7493 {
7494 if (LocaleCompare("taint",option+1) == 0)
7495 {
7496 if (*option == '+')
7497 {
7498 (void) SetImageOption(image_info,option+1,"false");
7499 break;
7500 }
7501 (void) SetImageOption(image_info,option+1,"true");
7502 break;
7503 }
7504 if (LocaleCompare("texture",option+1) == 0)
7505 {
7506 if (*option == '+')
7507 {
7508 if (image_info->texture != (char *) NULL)
7509 image_info->texture=DestroyString(image_info->texture);
7510 break;
7511 }
7512 (void) CloneString(&image_info->texture,argv[i+1]);
7513 break;
7514 }
7515 if (LocaleCompare("tile-offset",option+1) == 0)
7516 {
7517 if (*option == '+')
7518 {
7519 (void) SetImageOption(image_info,option+1,"0");
7520 break;
7521 }
7522 (void) SetImageOption(image_info,option+1,argv[i+1]);
7523 break;
7524 }
7525 if (LocaleCompare("transparent-color",option+1) == 0)
7526 {
7527 if (*option == '+')
7528 {
7529 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7530 (void) SetImageOption(image_info,option+1,"none");
7531 break;
7532 }
7533 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7534 exception);
7535 (void) SetImageOption(image_info,option+1,argv[i+1]);
7536 break;
7537 }
7538 if (LocaleCompare("type",option+1) == 0)
7539 {
7540 if (*option == '+')
7541 {
cristy5f1c1ff2010-12-23 21:38:06 +00007542 image_info->type=UndefinedType;
cristy3ed852e2009-09-05 21:47:34 +00007543 (void) SetImageOption(image_info,option+1,"undefined");
7544 break;
7545 }
7546 image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions,
7547 MagickFalse,argv[i+1]);
7548 (void) SetImageOption(image_info,option+1,argv[i+1]);
7549 break;
7550 }
7551 break;
7552 }
7553 case 'u':
7554 {
7555 if (LocaleCompare("undercolor",option+1) == 0)
7556 {
7557 if (*option == '+')
7558 {
7559 (void) DeleteImageOption(image_info,option+1);
7560 break;
7561 }
7562 (void) SetImageOption(image_info,option+1,argv[i+1]);
7563 break;
7564 }
7565 if (LocaleCompare("units",option+1) == 0)
7566 {
7567 if (*option == '+')
7568 {
7569 image_info->units=UndefinedResolution;
7570 (void) SetImageOption(image_info,option+1,"undefined");
7571 break;
7572 }
7573 image_info->units=(ResolutionType) ParseMagickOption(
7574 MagickResolutionOptions,MagickFalse,argv[i+1]);
7575 (void) SetImageOption(image_info,option+1,argv[i+1]);
7576 break;
7577 }
7578 break;
7579 }
7580 case 'v':
7581 {
7582 if (LocaleCompare("verbose",option+1) == 0)
7583 {
7584 if (*option == '+')
7585 {
7586 image_info->verbose=MagickFalse;
7587 break;
7588 }
7589 image_info->verbose=MagickTrue;
7590 image_info->ping=MagickFalse;
7591 break;
7592 }
7593 if (LocaleCompare("view",option+1) == 0)
7594 {
7595 if (*option == '+')
7596 {
7597 if (image_info->view != (char *) NULL)
7598 image_info->view=DestroyString(image_info->view);
7599 break;
7600 }
7601 (void) CloneString(&image_info->view,argv[i+1]);
7602 break;
7603 }
7604 if (LocaleCompare("virtual-pixel",option+1) == 0)
7605 {
7606 if (*option == '+')
7607 {
7608 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7609 (void) SetImageOption(image_info,option+1,"undefined");
7610 break;
7611 }
7612 image_info->virtual_pixel_method=(VirtualPixelMethod)
7613 ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
7614 argv[i+1]);
7615 (void) SetImageOption(image_info,option+1,argv[i+1]);
7616 break;
7617 }
7618 break;
7619 }
7620 case 'w':
7621 {
7622 if (LocaleCompare("white-point",option+1) == 0)
7623 {
7624 if (*option == '+')
7625 {
7626 (void) SetImageOption(image_info,option+1,"0.0");
7627 break;
7628 }
7629 (void) SetImageOption(image_info,option+1,argv[i+1]);
7630 break;
7631 }
7632 break;
7633 }
7634 default:
7635 break;
7636 }
7637 i+=count;
7638 }
7639 return(MagickTrue);
7640}
7641
7642/*
7643%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7644% %
7645% %
7646% %
7647+ M o g r i f y I m a g e L i s t %
7648% %
7649% %
7650% %
7651%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7652%
7653% MogrifyImageList() applies any command line options that might affect the
7654% entire image list (e.g. -append, -coalesce, etc.).
7655%
7656% The format of the MogrifyImage method is:
7657%
7658% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7659% const char **argv,Image **images,ExceptionInfo *exception)
7660%
7661% A description of each parameter follows:
7662%
7663% o image_info: the image info..
7664%
7665% o argc: Specifies a pointer to an integer describing the number of
7666% elements in the argument vector.
7667%
7668% o argv: Specifies a pointer to a text array containing the command line
7669% arguments.
7670%
7671% o images: the images.
7672%
7673% o exception: return any errors or warnings in this structure.
7674%
7675*/
7676WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7677 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7678{
7679 ChannelType
7680 channel;
7681
7682 const char
7683 *option;
7684
cristy6b3da3a2010-06-20 02:21:46 +00007685 ImageInfo
7686 *mogrify_info;
cristy3ed852e2009-09-05 21:47:34 +00007687
7688 MagickStatusType
7689 status;
7690
7691 QuantizeInfo
7692 *quantize_info;
7693
cristybb503372010-05-27 20:51:26 +00007694 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00007695 i;
7696
cristy6b3da3a2010-06-20 02:21:46 +00007697 ssize_t
7698 count,
7699 index;
7700
cristy3ed852e2009-09-05 21:47:34 +00007701 /*
7702 Apply options to the image list.
7703 */
7704 assert(image_info != (ImageInfo *) NULL);
7705 assert(image_info->signature == MagickSignature);
7706 assert(images != (Image **) NULL);
7707 assert((*images)->signature == MagickSignature);
7708 if ((*images)->debug != MagickFalse)
7709 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7710 (*images)->filename);
7711 if ((argc <= 0) || (*argv == (char *) NULL))
7712 return(MagickTrue);
cristy6b3da3a2010-06-20 02:21:46 +00007713 mogrify_info=CloneImageInfo(image_info);
7714 quantize_info=AcquireQuantizeInfo(mogrify_info);
7715 channel=mogrify_info->channel;
cristy3ed852e2009-09-05 21:47:34 +00007716 status=MagickTrue;
cristybb503372010-05-27 20:51:26 +00007717 for (i=0; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +00007718 {
cristy74fe8f12009-10-03 19:09:01 +00007719 if (*images == (Image *) NULL)
7720 break;
cristy3ed852e2009-09-05 21:47:34 +00007721 option=argv[i];
7722 if (IsMagickOption(option) == MagickFalse)
7723 continue;
7724 count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
7725 0L);
cristycee97112010-05-28 00:44:52 +00007726 if ((i+count) >= (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00007727 break;
cristy6b3da3a2010-06-20 02:21:46 +00007728 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
cristy3ed852e2009-09-05 21:47:34 +00007729 switch (*(option+1))
7730 {
7731 case 'a':
7732 {
7733 if (LocaleCompare("affinity",option+1) == 0)
7734 {
cristy6b3da3a2010-06-20 02:21:46 +00007735 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007736 if (*option == '+')
7737 {
7738 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7739 InheritException(exception,&(*images)->exception);
7740 break;
7741 }
7742 i++;
7743 break;
7744 }
7745 if (LocaleCompare("append",option+1) == 0)
7746 {
7747 Image
7748 *append_image;
7749
cristy6b3da3a2010-06-20 02:21:46 +00007750 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007751 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7752 MagickFalse,exception);
7753 if (append_image == (Image *) NULL)
7754 {
7755 status=MagickFalse;
7756 break;
7757 }
7758 *images=DestroyImageList(*images);
7759 *images=append_image;
7760 break;
7761 }
7762 if (LocaleCompare("average",option+1) == 0)
7763 {
7764 Image
7765 *average_image;
7766
cristyd18ae7c2010-03-07 17:39:52 +00007767 /*
7768 Average an image sequence (deprecated).
7769 */
cristy6b3da3a2010-06-20 02:21:46 +00007770 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007771 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7772 exception);
cristy3ed852e2009-09-05 21:47:34 +00007773 if (average_image == (Image *) NULL)
7774 {
7775 status=MagickFalse;
7776 break;
7777 }
7778 *images=DestroyImageList(*images);
7779 *images=average_image;
7780 break;
7781 }
7782 break;
7783 }
7784 case 'c':
7785 {
7786 if (LocaleCompare("channel",option+1) == 0)
7787 {
7788 if (*option == '+')
7789 {
7790 channel=DefaultChannels;
7791 break;
7792 }
7793 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7794 break;
7795 }
7796 if (LocaleCompare("clut",option+1) == 0)
7797 {
7798 Image
7799 *clut_image,
7800 *image;
7801
cristy6b3da3a2010-06-20 02:21:46 +00007802 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007803 image=RemoveFirstImageFromList(images);
7804 clut_image=RemoveFirstImageFromList(images);
7805 if (clut_image == (Image *) NULL)
7806 {
7807 status=MagickFalse;
7808 break;
7809 }
7810 (void) ClutImageChannel(image,channel,clut_image);
7811 clut_image=DestroyImage(clut_image);
7812 InheritException(exception,&image->exception);
7813 *images=DestroyImageList(*images);
7814 *images=image;
7815 break;
7816 }
7817 if (LocaleCompare("coalesce",option+1) == 0)
7818 {
7819 Image
7820 *coalesce_image;
7821
cristy6b3da3a2010-06-20 02:21:46 +00007822 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007823 coalesce_image=CoalesceImages(*images,exception);
7824 if (coalesce_image == (Image *) NULL)
7825 {
7826 status=MagickFalse;
7827 break;
7828 }
7829 *images=DestroyImageList(*images);
7830 *images=coalesce_image;
7831 break;
7832 }
7833 if (LocaleCompare("combine",option+1) == 0)
7834 {
7835 Image
7836 *combine_image;
7837
cristy6b3da3a2010-06-20 02:21:46 +00007838 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007839 combine_image=CombineImages(*images,channel,exception);
7840 if (combine_image == (Image *) NULL)
7841 {
7842 status=MagickFalse;
7843 break;
7844 }
7845 *images=DestroyImageList(*images);
7846 *images=combine_image;
7847 break;
7848 }
7849 if (LocaleCompare("composite",option+1) == 0)
7850 {
7851 Image
7852 *mask_image,
7853 *composite_image,
7854 *image;
7855
7856 RectangleInfo
7857 geometry;
7858
cristy6b3da3a2010-06-20 02:21:46 +00007859 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007860 image=RemoveFirstImageFromList(images);
7861 composite_image=RemoveFirstImageFromList(images);
7862 if (composite_image == (Image *) NULL)
7863 {
7864 status=MagickFalse;
7865 break;
7866 }
7867 (void) TransformImage(&composite_image,(char *) NULL,
7868 composite_image->geometry);
7869 SetGeometry(composite_image,&geometry);
7870 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7871 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7872 &geometry);
7873 mask_image=RemoveFirstImageFromList(images);
7874 if (mask_image != (Image *) NULL)
7875 {
7876 if ((image->compose == DisplaceCompositeOp) ||
7877 (image->compose == DistortCompositeOp))
7878 {
7879 /*
7880 Merge Y displacement into X displacement image.
7881 */
7882 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7883 mask_image,0,0);
7884 mask_image=DestroyImage(mask_image);
7885 }
7886 else
7887 {
7888 /*
7889 Set a blending mask for the composition.
7890 */
7891 image->mask=mask_image;
7892 (void) NegateImage(image->mask,MagickFalse);
7893 }
7894 }
7895 (void) CompositeImageChannel(image,channel,image->compose,
7896 composite_image,geometry.x,geometry.y);
7897 if (image->mask != (Image *) NULL)
7898 image->mask=DestroyImage(image->mask);
7899 composite_image=DestroyImage(composite_image);
7900 InheritException(exception,&image->exception);
7901 *images=DestroyImageList(*images);
7902 *images=image;
7903 break;
7904 }
7905 if (LocaleCompare("crop",option+1) == 0)
7906 {
7907 MagickStatusType
7908 flags;
7909
7910 RectangleInfo
7911 geometry;
7912
cristy6b3da3a2010-06-20 02:21:46 +00007913 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007914 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7915 if (((geometry.width == 0) && (geometry.height == 0)) ||
7916 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7917 break;
7918 (void) TransformImages(images,argv[i+1],(char *) NULL);
7919 InheritException(exception,&(*images)->exception);
7920 break;
7921 }
7922 break;
7923 }
7924 case 'd':
7925 {
7926 if (LocaleCompare("deconstruct",option+1) == 0)
7927 {
7928 Image
7929 *deconstruct_image;
7930
cristy6b3da3a2010-06-20 02:21:46 +00007931 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00007932 deconstruct_image=DeconstructImages(*images,exception);
7933 if (deconstruct_image == (Image *) NULL)
7934 {
7935 status=MagickFalse;
7936 break;
7937 }
7938 *images=DestroyImageList(*images);
7939 *images=deconstruct_image;
7940 break;
7941 }
7942 if (LocaleCompare("delete",option+1) == 0)
7943 {
7944 if (*option == '+')
7945 DeleteImages(images,"-1",exception);
7946 else
7947 DeleteImages(images,argv[i+1],exception);
7948 break;
7949 }
7950 if (LocaleCompare("dither",option+1) == 0)
7951 {
7952 if (*option == '+')
7953 {
7954 quantize_info->dither=MagickFalse;
7955 break;
7956 }
7957 quantize_info->dither=MagickTrue;
7958 quantize_info->dither_method=(DitherMethod) ParseMagickOption(
7959 MagickDitherOptions,MagickFalse,argv[i+1]);
7960 break;
7961 }
cristyecb10ff2011-03-22 13:14:03 +00007962 if (LocaleCompare("duplicate",option+1) == 0)
7963 {
7964 Image
7965 *duplicate_images;
7966
cristybf95deb2011-03-23 00:25:36 +00007967 size_t
7968 number_duplicates;
7969
7970 number_duplicates=(ssize_t) StringToLong(argv[i+1]);
7971 if (*option == '+')
7972 duplicate_images=DuplicateImages(*images,number_duplicates,"-1",
7973 exception);
7974 else
7975 duplicate_images=DuplicateImages(*images,number_duplicates,
7976 argv[i+2],exception);
cristyecb10ff2011-03-22 13:14:03 +00007977 if (*images != (Image *) NULL)
7978 *images=DestroyImage(*images);
7979 *images=duplicate_images;
7980 break;
7981 }
cristy3ed852e2009-09-05 21:47:34 +00007982 break;
7983 }
cristyd18ae7c2010-03-07 17:39:52 +00007984 case 'e':
7985 {
7986 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7987 {
7988 Image
7989 *evaluate_image;
7990
7991 MagickEvaluateOperator
7992 op;
7993
cristy6b3da3a2010-06-20 02:21:46 +00007994 (void) SyncImageSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00007995 op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
7996 MagickFalse,argv[i+1]);
7997 evaluate_image=EvaluateImages(*images,op,exception);
7998 if (evaluate_image == (Image *) NULL)
7999 {
8000 status=MagickFalse;
8001 break;
8002 }
8003 *images=DestroyImageList(*images);
8004 *images=evaluate_image;
8005 break;
8006 }
8007 break;
8008 }
cristy3ed852e2009-09-05 21:47:34 +00008009 case 'f':
8010 {
cristyf0a247f2009-10-04 00:20:03 +00008011 if (LocaleCompare("fft",option+1) == 0)
8012 {
8013 Image
8014 *fourier_image;
8015
8016 /*
8017 Implements the discrete Fourier transform (DFT).
8018 */
cristy6b3da3a2010-06-20 02:21:46 +00008019 (void) SyncImageSettings(mogrify_info,*images);
cristyf0a247f2009-10-04 00:20:03 +00008020 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8021 MagickTrue : MagickFalse,exception);
8022 if (fourier_image == (Image *) NULL)
8023 break;
8024 *images=DestroyImage(*images);
8025 *images=fourier_image;
8026 break;
8027 }
cristy3ed852e2009-09-05 21:47:34 +00008028 if (LocaleCompare("flatten",option+1) == 0)
8029 {
8030 Image
8031 *flatten_image;
8032
cristy6b3da3a2010-06-20 02:21:46 +00008033 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008034 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8035 if (flatten_image == (Image *) NULL)
8036 break;
8037 *images=DestroyImageList(*images);
8038 *images=flatten_image;
8039 break;
8040 }
8041 if (LocaleCompare("fx",option+1) == 0)
8042 {
8043 Image
8044 *fx_image;
8045
cristy6b3da3a2010-06-20 02:21:46 +00008046 (void) SyncImagesSettings(mogrify_info,*images);
anthony1e4df872011-03-19 14:10:59 +00008047 PageIndexImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008048 fx_image=FxImageChannel(*images,channel,argv[i+1],exception);
8049 if (fx_image == (Image *) NULL)
8050 {
8051 status=MagickFalse;
8052 break;
8053 }
8054 *images=DestroyImageList(*images);
8055 *images=fx_image;
8056 break;
8057 }
8058 break;
8059 }
8060 case 'h':
8061 {
8062 if (LocaleCompare("hald-clut",option+1) == 0)
8063 {
8064 Image
8065 *hald_image,
8066 *image;
8067
cristy6b3da3a2010-06-20 02:21:46 +00008068 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008069 image=RemoveFirstImageFromList(images);
8070 hald_image=RemoveFirstImageFromList(images);
8071 if (hald_image == (Image *) NULL)
8072 {
8073 status=MagickFalse;
8074 break;
8075 }
8076 (void) HaldClutImageChannel(image,channel,hald_image);
8077 hald_image=DestroyImage(hald_image);
8078 InheritException(exception,&image->exception);
cristy0aff6ea2009-11-14 01:40:53 +00008079 if (*images != (Image *) NULL)
8080 *images=DestroyImageList(*images);
cristy3ed852e2009-09-05 21:47:34 +00008081 *images=image;
8082 break;
8083 }
8084 break;
8085 }
8086 case 'i':
8087 {
8088 if (LocaleCompare("ift",option+1) == 0)
8089 {
8090 Image
cristy8587f882009-11-13 20:28:49 +00008091 *fourier_image,
8092 *magnitude_image,
8093 *phase_image;
cristy3ed852e2009-09-05 21:47:34 +00008094
8095 /*
8096 Implements the inverse fourier discrete Fourier transform (DFT).
8097 */
cristy6b3da3a2010-06-20 02:21:46 +00008098 (void) SyncImagesSettings(mogrify_info,*images);
cristy8587f882009-11-13 20:28:49 +00008099 magnitude_image=RemoveFirstImageFromList(images);
8100 phase_image=RemoveFirstImageFromList(images);
8101 if (phase_image == (Image *) NULL)
8102 {
8103 status=MagickFalse;
8104 break;
8105 }
8106 fourier_image=InverseFourierTransformImage(magnitude_image,
8107 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
cristy3ed852e2009-09-05 21:47:34 +00008108 if (fourier_image == (Image *) NULL)
8109 break;
cristy0aff6ea2009-11-14 01:40:53 +00008110 if (*images != (Image *) NULL)
8111 *images=DestroyImage(*images);
cristy3ed852e2009-09-05 21:47:34 +00008112 *images=fourier_image;
8113 break;
8114 }
8115 if (LocaleCompare("insert",option+1) == 0)
8116 {
8117 Image
8118 *p,
8119 *q;
8120
8121 index=0;
8122 if (*option != '+')
cristy32c2aea2010-12-01 01:00:50 +00008123 index=(ssize_t) StringToLong(argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00008124 p=RemoveLastImageFromList(images);
8125 if (p == (Image *) NULL)
8126 {
8127 (void) ThrowMagickException(exception,GetMagickModule(),
8128 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8129 status=MagickFalse;
8130 break;
8131 }
8132 q=p;
8133 if (index == 0)
8134 PrependImageToList(images,q);
8135 else
cristybb503372010-05-27 20:51:26 +00008136 if (index == (ssize_t) GetImageListLength(*images))
cristy3ed852e2009-09-05 21:47:34 +00008137 AppendImageToList(images,q);
8138 else
8139 {
8140 q=GetImageFromList(*images,index-1);
8141 if (q == (Image *) NULL)
8142 {
8143 (void) ThrowMagickException(exception,GetMagickModule(),
8144 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8145 status=MagickFalse;
8146 break;
8147 }
8148 InsertImageInList(&q,p);
8149 }
8150 *images=GetFirstImageInList(q);
8151 break;
8152 }
8153 break;
8154 }
8155 case 'l':
8156 {
8157 if (LocaleCompare("layers",option+1) == 0)
8158 {
8159 Image
8160 *layers;
8161
8162 ImageLayerMethod
8163 method;
8164
cristy6b3da3a2010-06-20 02:21:46 +00008165 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008166 layers=(Image *) NULL;
8167 method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions,
8168 MagickFalse,argv[i+1]);
8169 switch (method)
8170 {
8171 case CoalesceLayer:
8172 {
8173 layers=CoalesceImages(*images,exception);
8174 break;
8175 }
8176 case CompareAnyLayer:
8177 case CompareClearLayer:
8178 case CompareOverlayLayer:
8179 default:
8180 {
8181 layers=CompareImageLayers(*images,method,exception);
8182 break;
8183 }
8184 case MergeLayer:
8185 case FlattenLayer:
8186 case MosaicLayer:
8187 case TrimBoundsLayer:
8188 {
8189 layers=MergeImageLayers(*images,method,exception);
8190 break;
8191 }
8192 case DisposeLayer:
8193 {
8194 layers=DisposeImages(*images,exception);
8195 break;
8196 }
8197 case OptimizeImageLayer:
8198 {
8199 layers=OptimizeImageLayers(*images,exception);
8200 break;
8201 }
8202 case OptimizePlusLayer:
8203 {
8204 layers=OptimizePlusImageLayers(*images,exception);
8205 break;
8206 }
8207 case OptimizeTransLayer:
8208 {
8209 OptimizeImageTransparency(*images,exception);
8210 break;
8211 }
8212 case RemoveDupsLayer:
8213 {
8214 RemoveDuplicateLayers(images,exception);
8215 break;
8216 }
8217 case RemoveZeroLayer:
8218 {
8219 RemoveZeroDelayLayers(images,exception);
8220 break;
8221 }
8222 case OptimizeLayer:
8223 {
8224 /*
8225 General Purpose, GIF Animation Optimizer.
8226 */
8227 layers=CoalesceImages(*images,exception);
8228 if (layers == (Image *) NULL)
8229 {
8230 status=MagickFalse;
8231 break;
8232 }
8233 InheritException(exception,&layers->exception);
8234 *images=DestroyImageList(*images);
8235 *images=layers;
8236 layers=OptimizeImageLayers(*images,exception);
8237 if (layers == (Image *) NULL)
8238 {
8239 status=MagickFalse;
8240 break;
8241 }
8242 InheritException(exception,&layers->exception);
8243 *images=DestroyImageList(*images);
8244 *images=layers;
8245 layers=(Image *) NULL;
8246 OptimizeImageTransparency(*images,exception);
8247 InheritException(exception,&(*images)->exception);
8248 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8249 break;
8250 }
8251 case CompositeLayer:
8252 {
8253 CompositeOperator
8254 compose;
8255
8256 Image
8257 *source;
8258
8259 RectangleInfo
8260 geometry;
8261
8262 /*
8263 Split image sequence at the first 'NULL:' image.
8264 */
8265 source=(*images);
8266 while (source != (Image *) NULL)
8267 {
8268 source=GetNextImageInList(source);
8269 if ((source != (Image *) NULL) &&
8270 (LocaleCompare(source->magick,"NULL") == 0))
8271 break;
8272 }
8273 if (source != (Image *) NULL)
8274 {
8275 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8276 (GetNextImageInList(source) == (Image *) NULL))
8277 source=(Image *) NULL;
8278 else
8279 {
8280 /*
8281 Separate the two lists, junk the null: image.
8282 */
8283 source=SplitImageList(source->previous);
8284 DeleteImageFromList(&source);
8285 }
8286 }
8287 if (source == (Image *) NULL)
8288 {
8289 (void) ThrowMagickException(exception,GetMagickModule(),
8290 OptionError,"MissingNullSeparator","layers Composite");
8291 status=MagickFalse;
8292 break;
8293 }
8294 /*
8295 Adjust offset with gravity and virtual canvas.
8296 */
8297 SetGeometry(*images,&geometry);
8298 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8299 geometry.width=source->page.width != 0 ?
8300 source->page.width : source->columns;
8301 geometry.height=source->page.height != 0 ?
8302 source->page.height : source->rows;
8303 GravityAdjustGeometry((*images)->page.width != 0 ?
8304 (*images)->page.width : (*images)->columns,
8305 (*images)->page.height != 0 ? (*images)->page.height :
8306 (*images)->rows,(*images)->gravity,&geometry);
8307 compose=OverCompositeOp;
cristy6b3da3a2010-06-20 02:21:46 +00008308 option=GetImageOption(mogrify_info,"compose");
cristy3ed852e2009-09-05 21:47:34 +00008309 if (option != (const char *) NULL)
8310 compose=(CompositeOperator) ParseMagickOption(
8311 MagickComposeOptions,MagickFalse,option);
8312 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8313 exception);
8314 source=DestroyImageList(source);
8315 break;
8316 }
8317 }
8318 if (layers == (Image *) NULL)
8319 break;
8320 InheritException(exception,&layers->exception);
8321 *images=DestroyImageList(*images);
8322 *images=layers;
8323 break;
8324 }
8325 break;
8326 }
8327 case 'm':
8328 {
8329 if (LocaleCompare("map",option+1) == 0)
8330 {
cristy6b3da3a2010-06-20 02:21:46 +00008331 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008332 if (*option == '+')
8333 {
8334 (void) RemapImages(quantize_info,*images,(Image *) NULL);
8335 InheritException(exception,&(*images)->exception);
8336 break;
8337 }
8338 i++;
8339 break;
8340 }
cristyf40785b2010-03-06 02:27:27 +00008341 if (LocaleCompare("maximum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00008342 {
8343 Image
cristyf40785b2010-03-06 02:27:27 +00008344 *maximum_image;
cristy1c274c92010-03-06 02:06:45 +00008345
cristyd18ae7c2010-03-07 17:39:52 +00008346 /*
8347 Maximum image sequence (deprecated).
8348 */
cristy6b3da3a2010-06-20 02:21:46 +00008349 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00008350 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00008351 if (maximum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00008352 {
8353 status=MagickFalse;
8354 break;
8355 }
8356 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00008357 *images=maximum_image;
cristy1c274c92010-03-06 02:06:45 +00008358 break;
8359 }
cristyf40785b2010-03-06 02:27:27 +00008360 if (LocaleCompare("minimum",option+1) == 0)
cristy1c274c92010-03-06 02:06:45 +00008361 {
8362 Image
cristyf40785b2010-03-06 02:27:27 +00008363 *minimum_image;
cristy1c274c92010-03-06 02:06:45 +00008364
cristyd18ae7c2010-03-07 17:39:52 +00008365 /*
8366 Minimum image sequence (deprecated).
8367 */
cristy6b3da3a2010-06-20 02:21:46 +00008368 (void) SyncImagesSettings(mogrify_info,*images);
cristyd18ae7c2010-03-07 17:39:52 +00008369 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
cristyf40785b2010-03-06 02:27:27 +00008370 if (minimum_image == (Image *) NULL)
cristy1c274c92010-03-06 02:06:45 +00008371 {
8372 status=MagickFalse;
8373 break;
8374 }
8375 *images=DestroyImageList(*images);
cristyf40785b2010-03-06 02:27:27 +00008376 *images=minimum_image;
cristy1c274c92010-03-06 02:06:45 +00008377 break;
8378 }
cristy3ed852e2009-09-05 21:47:34 +00008379 if (LocaleCompare("morph",option+1) == 0)
8380 {
8381 Image
8382 *morph_image;
8383
cristy6b3da3a2010-06-20 02:21:46 +00008384 (void) SyncImagesSettings(mogrify_info,*images);
cristye27293e2009-12-18 02:53:20 +00008385 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
cristy3ed852e2009-09-05 21:47:34 +00008386 exception);
8387 if (morph_image == (Image *) NULL)
8388 {
8389 status=MagickFalse;
8390 break;
8391 }
8392 *images=DestroyImageList(*images);
8393 *images=morph_image;
8394 break;
8395 }
8396 if (LocaleCompare("mosaic",option+1) == 0)
8397 {
8398 Image
8399 *mosaic_image;
8400
cristy6b3da3a2010-06-20 02:21:46 +00008401 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008402 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8403 if (mosaic_image == (Image *) NULL)
8404 {
8405 status=MagickFalse;
8406 break;
8407 }
8408 *images=DestroyImageList(*images);
8409 *images=mosaic_image;
8410 break;
8411 }
8412 break;
8413 }
8414 case 'p':
8415 {
8416 if (LocaleCompare("print",option+1) == 0)
8417 {
8418 char
8419 *string;
8420
cristy6b3da3a2010-06-20 02:21:46 +00008421 (void) SyncImagesSettings(mogrify_info,*images);
8422 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
cristy3ed852e2009-09-05 21:47:34 +00008423 if (string == (char *) NULL)
8424 break;
8425 InheritException(exception,&(*images)->exception);
8426 (void) fprintf(stdout,"%s",string);
8427 string=DestroyString(string);
8428 }
8429 if (LocaleCompare("process",option+1) == 0)
8430 {
8431 char
8432 **arguments;
8433
8434 int
8435 j,
8436 number_arguments;
8437
cristy6b3da3a2010-06-20 02:21:46 +00008438 (void) SyncImagesSettings(mogrify_info,*images);
cristy3ed852e2009-09-05 21:47:34 +00008439 arguments=StringToArgv(argv[i+1],&number_arguments);
8440 if (arguments == (char **) NULL)
8441 break;
8442 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8443 {
8444 char
8445 breaker,
8446 quote,
8447 *token;
8448
8449 const char
8450 *arguments;
8451
8452 int
8453 next,
8454 status;
8455
8456 size_t
8457 length;
8458
8459 TokenInfo
8460 *token_info;
8461
8462 /*
8463 Support old style syntax, filter="-option arg".
8464 */
8465 length=strlen(argv[i+1]);
8466 token=(char *) NULL;
8467 if (~length >= MaxTextExtent)
8468 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8469 sizeof(*token));
8470 if (token == (char *) NULL)
8471 break;
8472 next=0;
8473 arguments=argv[i+1];
8474 token_info=AcquireTokenInfo();
8475 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8476 "\"",'\0',&breaker,&next,&quote);
8477 token_info=DestroyTokenInfo(token_info);
8478 if (status == 0)
8479 {
8480 const char
8481 *argv;
8482
8483 argv=(&(arguments[next]));
8484 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8485 exception);
8486 }
8487 token=DestroyString(token);
8488 break;
8489 }
cristy91c0da22010-05-02 01:44:07 +00008490 (void) SubstituteString(&arguments[1],"-","");
cristy3ed852e2009-09-05 21:47:34 +00008491 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8492 number_arguments-2,(const char **) arguments+2,exception);
8493 for (j=0; j < number_arguments; j++)
8494 arguments[j]=DestroyString(arguments[j]);
8495 arguments=(char **) RelinquishMagickMemory(arguments);
8496 break;
8497 }
8498 break;
8499 }
8500 case 'r':
8501 {
8502 if (LocaleCompare("reverse",option+1) == 0)
8503 {
8504 ReverseImageList(images);
8505 InheritException(exception,&(*images)->exception);
8506 break;
8507 }
8508 break;
8509 }
8510 case 's':
8511 {
cristy4285d782011-02-09 20:12:28 +00008512 if (LocaleCompare("smush",option+1) == 0)
8513 {
8514 Image
8515 *smush_image;
8516
8517 ssize_t
8518 offset;
8519
8520 (void) SyncImagesSettings(mogrify_info,*images);
8521 offset=(ssize_t) StringToLong(argv[i+1]);
8522 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8523 MagickFalse,offset,exception);
8524 if (smush_image == (Image *) NULL)
8525 {
8526 status=MagickFalse;
8527 break;
8528 }
8529 *images=DestroyImageList(*images);
8530 *images=smush_image;
8531 break;
8532 }
cristy3ed852e2009-09-05 21:47:34 +00008533 if (LocaleCompare("swap",option+1) == 0)
8534 {
8535 Image
8536 *p,
8537 *q,
8538 *swap;
8539
cristybb503372010-05-27 20:51:26 +00008540 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008541 swap_index;
8542
8543 index=(-1);
8544 swap_index=(-2);
8545 if (*option != '+')
8546 {
8547 GeometryInfo
8548 geometry_info;
8549
8550 MagickStatusType
8551 flags;
8552
8553 swap_index=(-1);
8554 flags=ParseGeometry(argv[i+1],&geometry_info);
cristybb503372010-05-27 20:51:26 +00008555 index=(ssize_t) geometry_info.rho;
cristy3ed852e2009-09-05 21:47:34 +00008556 if ((flags & SigmaValue) != 0)
cristybb503372010-05-27 20:51:26 +00008557 swap_index=(ssize_t) geometry_info.sigma;
cristy3ed852e2009-09-05 21:47:34 +00008558 }
8559 p=GetImageFromList(*images,index);
8560 q=GetImageFromList(*images,swap_index);
8561 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8562 {
8563 (void) ThrowMagickException(exception,GetMagickModule(),
8564 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8565 status=MagickFalse;
8566 break;
8567 }
8568 if (p == q)
8569 break;
8570 swap=CloneImage(p,0,0,MagickTrue,exception);
8571 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8572 ReplaceImageInList(&q,swap);
8573 *images=GetFirstImageInList(q);
8574 break;
8575 }
8576 break;
8577 }
8578 case 'w':
8579 {
8580 if (LocaleCompare("write",option+1) == 0)
8581 {
cristy071dd7b2010-04-09 13:04:54 +00008582 char
cristy06609ee2010-03-17 20:21:27 +00008583 key[MaxTextExtent];
8584
cristy3ed852e2009-09-05 21:47:34 +00008585 Image
8586 *write_images;
8587
8588 ImageInfo
8589 *write_info;
8590
cristy6b3da3a2010-06-20 02:21:46 +00008591 (void) SyncImagesSettings(mogrify_info,*images);
cristy06609ee2010-03-17 20:21:27 +00008592 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8593 (void) DeleteImageRegistry(key);
cristy3ed852e2009-09-05 21:47:34 +00008594 write_images=(*images);
8595 if (*option == '+')
8596 write_images=CloneImageList(*images,exception);
cristy6b3da3a2010-06-20 02:21:46 +00008597 write_info=CloneImageInfo(mogrify_info);
cristy3ed852e2009-09-05 21:47:34 +00008598 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8599 write_info=DestroyImageInfo(write_info);
8600 if (*option == '+')
8601 write_images=DestroyImageList(write_images);
8602 break;
8603 }
8604 break;
8605 }
8606 default:
8607 break;
8608 }
8609 i+=count;
8610 }
8611 quantize_info=DestroyQuantizeInfo(quantize_info);
cristy6b3da3a2010-06-20 02:21:46 +00008612 mogrify_info=DestroyImageInfo(mogrify_info);
8613 status&=MogrifyImageInfo(image_info,argc,argv,exception);
cristy3ed852e2009-09-05 21:47:34 +00008614 return(status != 0 ? MagickTrue : MagickFalse);
8615}
8616
8617/*
8618%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8619% %
8620% %
8621% %
8622+ M o g r i f y I m a g e s %
8623% %
8624% %
8625% %
8626%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8627%
8628% MogrifyImages() applies image processing options to a sequence of images as
8629% prescribed by command line options.
8630%
8631% The format of the MogrifyImage method is:
8632%
8633% MagickBooleanType MogrifyImages(ImageInfo *image_info,
8634% const MagickBooleanType post,const int argc,const char **argv,
8635% Image **images,Exceptioninfo *exception)
8636%
8637% A description of each parameter follows:
8638%
8639% o image_info: the image info..
8640%
8641% o post: If true, post process image list operators otherwise pre-process.
8642%
8643% o argc: Specifies a pointer to an integer describing the number of
8644% elements in the argument vector.
8645%
8646% o argv: Specifies a pointer to a text array containing the command line
8647% arguments.
8648%
8649% o images: the images.
8650%
8651% o exception: return any errors or warnings in this structure.
8652%
8653*/
8654WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8655 const MagickBooleanType post,const int argc,const char **argv,
8656 Image **images,ExceptionInfo *exception)
8657{
8658#define MogrifyImageTag "Mogrify/Image"
8659
8660 Image
8661 *image,
8662 *mogrify_images;
8663
cristy0e9f9c12010-02-11 03:00:47 +00008664 MagickBooleanType
8665 proceed;
8666
8667 MagickSizeType
8668 number_images;
8669
cristy3ed852e2009-09-05 21:47:34 +00008670 MagickStatusType
8671 status;
8672
cristybb503372010-05-27 20:51:26 +00008673 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +00008674 i;
8675
cristy3ed852e2009-09-05 21:47:34 +00008676 /*
8677 Apply options to individual images in the list.
8678 */
8679 assert(image_info != (ImageInfo *) NULL);
8680 assert(image_info->signature == MagickSignature);
8681 if (images == (Image **) NULL)
8682 return(MogrifyImage(image_info,argc,argv,images,exception));
8683 assert((*images)->signature == MagickSignature);
8684 if ((*images)->debug != MagickFalse)
8685 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8686 (*images)->filename);
8687 if ((argc <= 0) || (*argv == (char *) NULL))
8688 return(MagickTrue);
8689 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8690 (void *) NULL);
cristy3ed852e2009-09-05 21:47:34 +00008691 status=0;
8692 if (post == MagickFalse)
8693 status&=MogrifyImageList(image_info,argc,argv,images,exception);
anthony1e4df872011-03-19 14:10:59 +00008694 PageIndexImageList(*images);
8695 number_images=(*images)->page_total;
8696 mogrify_images=NewImageList();
cristybb503372010-05-27 20:51:26 +00008697 for (i=0; i < (ssize_t) number_images; i++)
cristy3ed852e2009-09-05 21:47:34 +00008698 {
8699 image=RemoveFirstImageFromList(images);
8700 if (image == (Image *) NULL)
8701 continue;
8702 status&=MogrifyImage(image_info,argc,argv,&image,exception);
8703 AppendImageToList(&mogrify_images,image);
cristy0e9f9c12010-02-11 03:00:47 +00008704 proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i,
8705 number_images);
8706 if (proceed == MagickFalse)
8707 break;
cristy3ed852e2009-09-05 21:47:34 +00008708 }
8709 if (post != MagickFalse)
8710 status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception);
8711 *images=mogrify_images;
8712 return(status != 0 ? MagickTrue : MagickFalse);
8713}