MagickWand 7.1.1-43
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
mogrify.c
1/*
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% Cristy %
17% March 2000 %
18% %
19% %
20% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization %
21% 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% https://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 similar 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
40% request.
41%
42% This embeds the legacy command-line parser as opposed to operation.c which
43% embeds the modern parser designed for the execution in a strict one option
44% at a time manner that is needed for 'pipelining and file scripting' of
45% options in IMv7.
46%
47*/
48␌
49/*
50 Include declarations.
51*/
52#include "MagickWand/studio.h"
53#include "MagickWand/MagickWand.h"
54#include "MagickWand/magick-wand-private.h"
55#include "MagickWand/mogrify-private.h"
56#include "MagickCore/blob-private.h"
57#include "MagickCore/color-private.h"
58#include "MagickCore/composite-private.h"
59#include "MagickCore/geometry-private.h"
60#include "MagickCore/image-private.h"
61#include "MagickCore/monitor-private.h"
62#include "MagickCore/profile-private.h"
63#include "MagickCore/string-private.h"
64#include "MagickCore/thread-private.h"
65#include "MagickCore/timer-private.h"
66#include "MagickCore/utility-private.h"
67␌
68/*
69 Constant declaration.
70*/
71static const char
72 MogrifyAlphaColor[] = "#bdbdbd", /* gray */
73 MogrifyBackgroundColor[] = "#ffffff", /* white */
74 MogrifyBorderColor[] = "#dfdfdf"; /* gray */
75␌
76/*
77 Define declarations.
78*/
79#define UndefinedCompressionQuality 0UL
80␌
81/*
82%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83% %
84% %
85% %
86+ M o g r i f y I m a g e %
87% %
88% %
89% %
90%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91%
92% MogrifyImage() applies simple single image processing options to a single
93% image that may be part of a large list, but also handles any 'region'
94% image handling.
95%
96% The image in the list may be modified in three different ways...
97%
98% * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
99% * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
100% * replace by a list of images (only the -separate option!)
101%
102% In each case the result is returned into the list, and a pointer to the
103% modified image (last image added if replaced by a list of images) is
104% returned.
105%
106% ASIDE: The -crop is present but restricted to non-tile single image crops
107%
108% This means if all the images are being processed (such as by
109% MogrifyImages(), next image to be processed will be as per the pointer
110% (*image)->next. Also the image list may grow as a result of some specific
111% operations but as images are never merged or deleted, it will never shrink
112% in length. Typically the list will remain the same length.
113%
114% WARNING: As the image pointed to may be replaced, the first image in the
115% list may also change. GetFirstImageInList() should be used by caller if
116% they wish return the Image pointer to the first image in list.
117%
118%
119% The format of the MogrifyImage method is:
120%
121% MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
122% const char **argv,Image **image)
123%
124% A description of each parameter follows:
125%
126% o image_info: the image info..
127%
128% o argc: Specifies a pointer to an integer describing the number of
129% elements in the argument vector.
130%
131% o argv: Specifies a pointer to a text array containing the command line
132% arguments.
133%
134% o image: the image.
135%
136% o exception: return any errors or warnings in this structure.
137%
138*/
139
140static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
141 ExceptionInfo *exception)
142{
143 char
144 key[MagickPathExtent];
145
146 ExceptionInfo
147 *sans_exception;
148
149 Image
150 *image;
151
152 ImageInfo
153 *read_info;
154
155 /*
156 Read an image into a image cache (for repeated usage) if not already in
157 cache. Then return the image that is in the cache.
158 */
159 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",path);
160 sans_exception=AcquireExceptionInfo();
161 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
162 sans_exception=DestroyExceptionInfo(sans_exception);
163 if (image != (Image *) NULL)
164 return(image);
165 read_info=CloneImageInfo(image_info);
166 (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
167 image=ReadImage(read_info,exception);
168 read_info=DestroyImageInfo(read_info);
169 if (image != (Image *) NULL)
170 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
171 return(image);
172}
173
174static inline MagickBooleanType IsPathWritable(const char *path)
175{
176 if (IsPathAccessible(path) == MagickFalse)
177 return(MagickFalse);
178 if (access_utf8(path,W_OK) != 0)
179 return(MagickFalse);
180 return(MagickTrue);
181}
182
183static MagickBooleanType MonitorProgress(const char *text,
184 const MagickOffsetType offset,const MagickSizeType extent,
185 void *wand_unused(client_data))
186{
187 char
188 message[MagickPathExtent],
189 tag[MagickPathExtent];
190
191 const char
192 *locale_message;
193
194 char
195 *p;
196
197 magick_unreferenced(client_data);
198
199 if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
200 return(MagickTrue);
201 if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
202 return(MagickTrue);
203 (void) CopyMagickString(tag,text == (const char *) NULL ? "null" : text,
204 MagickPathExtent);
205 p=strrchr(tag,'/');
206 if (p != (char *) NULL)
207 *p='\0';
208 (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag);
209 locale_message=GetLocaleMessage(message);
210 if (locale_message == message)
211 locale_message=tag;
212 if (p == (char *) NULL)
213 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
214 locale_message,(long) offset,(unsigned long) extent,(long)
215 (100.0*offset*PerceptibleReciprocal(extent-1.0)));
216 else
217 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
218 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
219 (100.0*offset*PerceptibleReciprocal(extent-1.0)));
220 if (offset == (MagickOffsetType) (extent-1))
221 (void) FormatLocaleFile(stderr,"\n");
222 (void) fflush(stderr);
223 return(MagickTrue);
224}
225
226static Image *SparseColorOption(const Image *image,
227 const SparseColorMethod method,const char *arguments,
228 const MagickBooleanType color_from_image,ExceptionInfo *exception)
229{
230 char
231 token[MagickPathExtent];
232
233 const char
234 *p;
235
236 double
237 *sparse_arguments;
238
239 Image
240 *sparse_image;
241
242 MagickBooleanType
243 error;
244
245 PixelInfo
246 color;
247
248 size_t
249 x;
250
251 size_t
252 number_arguments,
253 number_colors;
254
255 /*
256 SparseColorOption() parses the complex -sparse-color argument into an an
257 array of floating point values then calls SparseColorImage(). Argument is
258 a complex mix of floating-point pixel coordinates, and color specifications
259 (or direct floating point numbers). The number of floats needed to
260 represent a color varies depending on the current channel setting.
261 */
262 assert(image != (Image *) NULL);
263 assert(image->signature == MagickCoreSignature);
264 assert(exception != (ExceptionInfo *) NULL);
265 assert(exception->signature == MagickCoreSignature);
266 if (IsEventLogging() != MagickFalse)
267 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
268 /*
269 Limit channels according to image - and add up number of color channel.
270 */
271 number_colors=0;
272 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
273 number_colors++;
274 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
275 number_colors++;
276 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
277 number_colors++;
278 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
279 (image->colorspace == CMYKColorspace))
280 number_colors++;
281 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
282 (image->alpha_trait != UndefinedPixelTrait))
283 number_colors++;
284
285 /*
286 Read string, to determine number of arguments needed,
287 */
288 p=arguments;
289 x=0;
290 while( *p != '\0' )
291 {
292 (void) GetNextToken(p,&p,MagickPathExtent,token);
293 if (*token == ',') continue;
294 if ( isalpha((int) ((unsigned char) *token)) || (*token == '#')) {
295 if ( color_from_image ) {
296 (void) ThrowMagickException(exception,GetMagickModule(),
297 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
298 "Color arg given, when colors are coming from image");
299 return( (Image *) NULL);
300 }
301 x += number_colors; /* color argument */
302 }
303 else {
304 x++; /* floating point argument */
305 }
306 }
307 error=MagickTrue;
308 if ( color_from_image ) {
309 /* just the control points are being given */
310 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
311 number_arguments=(x/2)*(2+number_colors);
312 }
313 else {
314 /* control points and color values */
315 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
316 number_arguments=x;
317 }
318 if ( error ) {
319 (void) ThrowMagickException(exception,GetMagickModule(),
320 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
321 "Invalid number of Arguments");
322 return( (Image *) NULL);
323 }
324
325 /* Allocate and fill in the floating point arguments */
326 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
327 sizeof(*sparse_arguments));
328 if (sparse_arguments == (double *) NULL) {
329 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
330 " MemoryAllocationFailed\n""%s","SparseColorOption");
331 return( (Image *) NULL);
332 }
333 (void) memset(sparse_arguments,0,number_arguments*
334 sizeof(*sparse_arguments));
335 p=arguments;
336 x=0;
337 while ((*p != '\0') && (x < number_arguments))
338 {
339 /* X coordinate */
340 *token=',';
341 while (*token == ',')
342 (void) GetNextToken(p,&p,MagickPathExtent,token);
343 if (*token == '\0') break;
344 if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
345 {
346 (void) ThrowMagickException(exception,GetMagickModule(),
347 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
348 "Color found, instead of X-coord");
349 error=MagickTrue;
350 break;
351 }
352 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
353 /* Y coordinate */
354 *token=',';
355 while (*token == ',')
356 (void) GetNextToken(p,&p,MagickPathExtent,token);
357 if (*token == '\0')
358 break;
359 if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
360 {
361 (void) ThrowMagickException(exception,GetMagickModule(),
362 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
363 "Color found, instead of Y-coord");
364 error = MagickTrue;
365 break;
366 }
367 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
368 /* color values for this control point */
369#if 0
370 if ( (color_from_image ) {
371 /* get color from image */
372 /* HOW??? */
373 }
374 else
375#endif
376 {
377 /* color name or function given in string argument */
378 *token=',';
379 while (*token == ',')
380 (void) GetNextToken(p,&p,MagickPathExtent,token);
381 if (*token == '\0')
382 break;
383 if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
384 {
385 /* Color string given */
386 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
387 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
388 sparse_arguments[x++] = QuantumScale*color.red;
389 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
390 sparse_arguments[x++] = QuantumScale*color.green;
391 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
392 sparse_arguments[x++] = QuantumScale*color.blue;
393 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
394 (image->colorspace == CMYKColorspace))
395 sparse_arguments[x++] = QuantumScale*color.black;
396 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
397 (image->alpha_trait != UndefinedPixelTrait))
398 sparse_arguments[x++] = QuantumScale*color.alpha;
399 }
400 else {
401 /* Colors given as a set of floating point values - experimental */
402 /* NB: token contains the first floating point value to use! */
403 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
404 {
405 while (*token == ',')
406 (void) GetNextToken(p,&p,MagickPathExtent,token);
407 if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
408 (*token == '#'))
409 break;
410 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
411 *token = ','; /* used this token - get another */
412 }
413 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
414 {
415 while (*token == ',')
416 (void) GetNextToken(p,&p,MagickPathExtent,token);
417 if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
418 (*token == '#'))
419 break;
420 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
421 *token = ','; /* used this token - get another */
422 }
423 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
424 {
425 while (*token == ',')
426 (void) GetNextToken(p,&p,MagickPathExtent,token);
427 if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
428 (*token == '#'))
429 break;
430 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
431 *token = ','; /* used this token - get another */
432 }
433 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
434 (image->colorspace == CMYKColorspace))
435 {
436 while (*token == ',')
437 (void) GetNextToken(p,&p,MagickPathExtent,token);
438 if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
439 (*token == '#'))
440 break;
441 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
442 *token=','; /* used this token - get another */
443 }
444 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
445 (image->alpha_trait != UndefinedPixelTrait))
446 {
447 while (*token == ',')
448 (void) GetNextToken(p,&p,MagickPathExtent,token);
449 if ((*token == '\0') || isalpha((int) ((unsigned char) *token)) ||
450 (*token == '#'))
451 break;
452 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
453 *token = ','; /* used this token - get another */
454 }
455 }
456 }
457 }
458 if ((number_arguments != x) && (!error))
459 {
460 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
461 " InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
462 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
463 return((Image *) NULL);
464 }
465 if (error)
466 return((Image *) NULL);
467 /*
468 Call the Interpolation function with the parsed arguments.
469 */
470 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
471 exception);
472 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
473 return( sparse_image );
474}
475
476WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
477 const char **argv,Image **image,ExceptionInfo *exception)
478{
479 CompositeOperator
480 compose;
481
482 const char
483 *format,
484 *option;
485
486 double
487 attenuate;
488
489 DrawInfo
490 *draw_info;
491
492 GeometryInfo
493 geometry_info;
494
495 ImageInfo
496 *mogrify_info;
497
498 MagickStatusType
499 status;
500
501 PixelInfo
502 fill;
503
504 MagickStatusType
505 flags;
506
507 PixelInterpolateMethod
508 interpolate_method;
509
510 QuantizeInfo
511 *quantize_info;
512
513 RectangleInfo
514 geometry,
515 region_geometry;
516
517 ssize_t
518 i;
519
520 /*
521 Initialize method variables.
522 */
523 assert(image_info != (const ImageInfo *) NULL);
524 assert(image_info->signature == MagickCoreSignature);
525 assert(image != (Image **) NULL);
526 assert((*image)->signature == MagickCoreSignature);
527 if (IsEventLogging() != MagickFalse)
528 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
529 if (argc < 0)
530 return(MagickTrue);
531 mogrify_info=CloneImageInfo(image_info);
532 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
533 quantize_info=AcquireQuantizeInfo(mogrify_info);
534 SetGeometryInfo(&geometry_info);
535 GetPixelInfo(*image,&fill);
536 fill=(*image)->background_color;
537 attenuate=1.0;
538 compose=(*image)->compose;
539 interpolate_method=UndefinedInterpolatePixel;
540 format=GetImageOption(mogrify_info,"format");
541 SetGeometry(*image,&region_geometry);
542 /*
543 Transmogrify the image.
544 */
545 for (i=0; i < (ssize_t) argc; i++)
546 {
547 Image
548 *mogrify_image;
549
550 ssize_t
551 count;
552
553 option=argv[i];
554 if (IsCommandOption(option) == MagickFalse)
555 continue;
556 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
557 0L);
558 if ((i+count) >= (ssize_t) argc)
559 break;
560 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
561 mogrify_image=(Image *) NULL;
562 switch (*(option+1))
563 {
564 case 'a':
565 {
566 if (LocaleCompare("adaptive-blur",option+1) == 0)
567 {
568 /*
569 Adaptive blur image.
570 */
571 (void) SyncImageSettings(mogrify_info,*image,exception);
572 flags=ParseGeometry(argv[i+1],&geometry_info);
573 if ((flags & SigmaValue) == 0)
574 geometry_info.sigma=1.0;
575 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
576 geometry_info.sigma,exception);
577 break;
578 }
579 if (LocaleCompare("adaptive-resize",option+1) == 0)
580 {
581 /*
582 Adaptive resize image.
583 */
584 (void) SyncImageSettings(mogrify_info,*image,exception);
585 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
586 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
587 geometry.height,exception);
588 break;
589 }
590 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
591 {
592 /*
593 Adaptive sharpen image.
594 */
595 (void) SyncImageSettings(mogrify_info,*image,exception);
596 flags=ParseGeometry(argv[i+1],&geometry_info);
597 if ((flags & SigmaValue) == 0)
598 geometry_info.sigma=1.0;
599 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
600 geometry_info.sigma,exception);
601 break;
602 }
603 if (LocaleCompare("affine",option+1) == 0)
604 {
605 /*
606 Affine matrix.
607 */
608 if (*option == '+')
609 {
610 GetAffineMatrix(&draw_info->affine);
611 break;
612 }
613 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
614 break;
615 }
616 if (LocaleCompare("alpha",option+1) == 0)
617 {
618 AlphaChannelOption
619 alpha_type;
620
621 (void) SyncImageSettings(mogrify_info,*image,exception);
622 alpha_type=(AlphaChannelOption) ParseCommandOption(
623 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
624 (void) SetImageAlphaChannel(*image,alpha_type,exception);
625 break;
626 }
627 if (LocaleCompare("annotate",option+1) == 0)
628 {
629 char
630 *text,
631 geometry_str[MagickPathExtent];
632
633 /*
634 Annotate image.
635 */
636 (void) SyncImageSettings(mogrify_info,*image,exception);
637 SetGeometryInfo(&geometry_info);
638 flags=ParseGeometry(argv[i+1],&geometry_info);
639 if ((flags & SigmaValue) == 0)
640 geometry_info.sigma=geometry_info.rho;
641 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
642 exception);
643 if (text == (char *) NULL)
644 break;
645 (void) CloneString(&draw_info->text,text);
646 text=DestroyString(text);
647 (void) FormatLocaleString(geometry_str,MagickPathExtent,"%+f%+f",
648 geometry_info.xi,geometry_info.psi);
649 (void) CloneString(&draw_info->geometry,geometry_str);
650 draw_info->affine.sx=cos(DegreesToRadians(
651 fmod(geometry_info.rho,360.0)));
652 draw_info->affine.rx=sin(DegreesToRadians(
653 fmod(geometry_info.rho,360.0)));
654 draw_info->affine.ry=(-sin(DegreesToRadians(
655 fmod(geometry_info.sigma,360.0))));
656 draw_info->affine.sy=cos(DegreesToRadians(
657 fmod(geometry_info.sigma,360.0)));
658 (void) AnnotateImage(*image,draw_info,exception);
659 break;
660 }
661 if (LocaleCompare("antialias",option+1) == 0)
662 {
663 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
664 MagickFalse;
665 draw_info->text_antialias=(*option == '-') ? MagickTrue :
666 MagickFalse;
667 break;
668 }
669 if (LocaleCompare("attenuate",option+1) == 0)
670 {
671 if (*option == '+')
672 {
673 attenuate=1.0;
674 break;
675 }
676 attenuate=StringToDouble(argv[i+1],(char **) NULL);
677 break;
678 }
679 if (LocaleCompare("auto-gamma",option+1) == 0)
680 {
681 /*
682 Auto Adjust Gamma of image based on its mean.
683 */
684 (void) SyncImageSettings(mogrify_info,*image,exception);
685 (void) AutoGammaImage(*image,exception);
686 break;
687 }
688 if (LocaleCompare("auto-level",option+1) == 0)
689 {
690 /*
691 Perfectly Normalize (max/min stretch) the image.
692 */
693 (void) SyncImageSettings(mogrify_info,*image,exception);
694 (void) AutoLevelImage(*image,exception);
695 break;
696 }
697 if (LocaleCompare("auto-orient",option+1) == 0)
698 {
699 (void) SyncImageSettings(mogrify_info,*image,exception);
700 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
701 exception);
702 break;
703 }
704 if (LocaleCompare("auto-threshold",option+1) == 0)
705 {
706 AutoThresholdMethod
707 method;
708
709 (void) SyncImageSettings(mogrify_info,*image,exception);
710 method=(AutoThresholdMethod) ParseCommandOption(
711 MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
712 (void) AutoThresholdImage(*image,method,exception);
713 break;
714 }
715 break;
716 }
717 case 'b':
718 {
719 if (LocaleCompare("bilateral-blur",option+1) == 0)
720 {
721 /*
722 Bilateral filter image.
723 */
724 (void) SyncImageSettings(mogrify_info,*image,exception);
725 flags=ParseGeometry(argv[i+1],&geometry_info);
726 if ((flags & SigmaValue) == 0)
727 geometry_info.sigma=geometry_info.rho;
728 if ((flags & XiValue) == 0)
729 geometry_info.xi=1.0*sqrt(geometry_info.rho*geometry_info.rho+
730 geometry_info.sigma*geometry_info.sigma);
731 if ((flags & PsiValue) == 0)
732 geometry_info.psi=0.25*sqrt(geometry_info.rho*geometry_info.rho+
733 geometry_info.sigma*geometry_info.sigma);
734 mogrify_image=BilateralBlurImage(*image,(size_t) geometry_info.rho,
735 (size_t) geometry_info.sigma,geometry_info.xi,geometry_info.psi,
736 exception);
737 break;
738 }
739 if (LocaleCompare("black-threshold",option+1) == 0)
740 {
741 /*
742 Black threshold image.
743 */
744 (void) SyncImageSettings(mogrify_info,*image,exception);
745 (void) BlackThresholdImage(*image,argv[i+1],exception);
746 break;
747 }
748 if (LocaleCompare("blue-shift",option+1) == 0)
749 {
750 /*
751 Blue shift image.
752 */
753 (void) SyncImageSettings(mogrify_info,*image,exception);
754 geometry_info.rho=1.5;
755 if (*option == '-')
756 flags=ParseGeometry(argv[i+1],&geometry_info);
757 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
758 break;
759 }
760 if (LocaleCompare("blur",option+1) == 0)
761 {
762 /*
763 Gaussian blur image.
764 */
765 (void) SyncImageSettings(mogrify_info,*image,exception);
766 flags=ParseGeometry(argv[i+1],&geometry_info);
767 if ((flags & SigmaValue) == 0)
768 geometry_info.sigma=1.0;
769 if ((flags & XiValue) == 0)
770 geometry_info.xi=0.0;
771 mogrify_image=BlurImage(*image,geometry_info.rho,
772 geometry_info.sigma,exception);
773 break;
774 }
775 if (LocaleCompare("border",option+1) == 0)
776 {
777 /*
778 Surround image with a border of solid color.
779 */
780 (void) SyncImageSettings(mogrify_info,*image,exception);
781 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
782 mogrify_image=BorderImage(*image,&geometry,compose,exception);
783 break;
784 }
785 if (LocaleCompare("bordercolor",option+1) == 0)
786 {
787 if (*option == '+')
788 {
789 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
790 &draw_info->border_color,exception);
791 break;
792 }
793 (void) QueryColorCompliance(argv[i+1],AllCompliance,
794 &draw_info->border_color,exception);
795 break;
796 }
797 if (LocaleCompare("box",option+1) == 0)
798 {
799 (void) QueryColorCompliance(argv[i+1],AllCompliance,
800 &draw_info->undercolor,exception);
801 break;
802 }
803 if (LocaleCompare("brightness-contrast",option+1) == 0)
804 {
805 double
806 brightness,
807 contrast;
808
809 /*
810 Brightness / contrast image.
811 */
812 (void) SyncImageSettings(mogrify_info,*image,exception);
813 flags=ParseGeometry(argv[i+1],&geometry_info);
814 brightness=geometry_info.rho;
815 contrast=0.0;
816 if ((flags & SigmaValue) != 0)
817 contrast=geometry_info.sigma;
818 (void) BrightnessContrastImage(*image,brightness,contrast,
819 exception);
820 break;
821 }
822 break;
823 }
824 case 'c':
825 {
826 if (LocaleCompare("canny",option+1) == 0)
827 {
828 /*
829 Detect edges in the image.
830 */
831 (void) SyncImageSettings(mogrify_info,*image,exception);
832 flags=ParseGeometry(argv[i+1],&geometry_info);
833 if ((flags & SigmaValue) == 0)
834 geometry_info.sigma=1.0;
835 if ((flags & XiValue) == 0)
836 geometry_info.xi=0.10;
837 if ((flags & PsiValue) == 0)
838 geometry_info.psi=0.30;
839 if ((flags & PercentValue) != 0)
840 {
841 geometry_info.xi/=100.0;
842 geometry_info.psi/=100.0;
843 }
844 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
845 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
846 break;
847 }
848 if (LocaleCompare("cdl",option+1) == 0)
849 {
850 char
851 *color_correction_collection;
852
853 /*
854 Color correct with a color decision list.
855 */
856 (void) SyncImageSettings(mogrify_info,*image,exception);
857 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
858 if (color_correction_collection == (char *) NULL)
859 break;
860 (void) ColorDecisionListImage(*image,color_correction_collection,
861 exception);
862 color_correction_collection=DestroyString(color_correction_collection);
863 break;
864 }
865 if (LocaleCompare("channel",option+1) == 0)
866 {
867 ChannelType
868 channel;
869
870 (void) SyncImageSettings(mogrify_info,*image,exception);
871 if (*option == '+')
872 {
873 (void) SetPixelChannelMask(*image,DefaultChannels);
874 break;
875 }
876 channel=(ChannelType) ParseChannelOption(argv[i+1]);
877 (void) SetPixelChannelMask(*image,channel);
878 break;
879 }
880 if (LocaleCompare("charcoal",option+1) == 0)
881 {
882 /*
883 Charcoal image.
884 */
885 (void) SyncImageSettings(mogrify_info,*image,exception);
886 flags=ParseGeometry(argv[i+1],&geometry_info);
887 if ((flags & SigmaValue) == 0)
888 geometry_info.sigma=1.0;
889 if ((flags & XiValue) == 0)
890 geometry_info.xi=1.0;
891 mogrify_image=CharcoalImage(*image,geometry_info.rho,
892 geometry_info.sigma,exception);
893 break;
894 }
895 if (LocaleCompare("chop",option+1) == 0)
896 {
897 /*
898 Chop the image.
899 */
900 (void) SyncImageSettings(mogrify_info,*image,exception);
901 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
902 mogrify_image=ChopImage(*image,&geometry,exception);
903 break;
904 }
905 if (LocaleCompare("clahe",option+1) == 0)
906 {
907 /*
908 Contrast limited adaptive histogram equalization.
909 */
910 (void) SyncImageSettings(mogrify_info,*image,exception);
911 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
912 flags=ParseGeometry(argv[i+1],&geometry_info);
913 (void) CLAHEImage(*image,geometry.width,geometry.height,
914 (size_t) geometry.x,geometry_info.psi,exception);
915 break;
916 }
917 if (LocaleCompare("clip",option+1) == 0)
918 {
919 (void) SyncImageSettings(mogrify_info,*image,exception);
920 if (*option == '+')
921 {
922 (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
923 exception);
924 break;
925 }
926 (void) ClipImage(*image,exception);
927 break;
928 }
929 if (LocaleCompare("clip-mask",option+1) == 0)
930 {
931 Image
932 *clip_mask;
933
934 (void) SyncImageSettings(mogrify_info,*image,exception);
935 if (*option == '+')
936 {
937 /*
938 Remove a mask.
939 */
940 (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
941 exception);
942 break;
943 }
944 /*
945 Set the image mask.
946 */
947 clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
948 if (clip_mask == (Image *) NULL)
949 break;
950 (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
951 clip_mask=DestroyImage(clip_mask);
952 break;
953 }
954 if (LocaleCompare("clip-path",option+1) == 0)
955 {
956 (void) SyncImageSettings(mogrify_info,*image,exception);
957 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
958 MagickFalse,exception);
959 break;
960 }
961 if (LocaleCompare("colorize",option+1) == 0)
962 {
963 /*
964 Colorize the image.
965 */
966 (void) SyncImageSettings(mogrify_info,*image,exception);
967 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
968 break;
969 }
970 if (LocaleCompare("color-matrix",option+1) == 0)
971 {
972 KernelInfo
973 *kernel;
974
975 (void) SyncImageSettings(mogrify_info,*image,exception);
976 kernel=AcquireKernelInfo(argv[i+1],exception);
977 if (kernel == (KernelInfo *) NULL)
978 break;
979 /* FUTURE: check on size of the matrix */
980 mogrify_image=ColorMatrixImage(*image,kernel,exception);
981 kernel=DestroyKernelInfo(kernel);
982 break;
983 }
984 if (LocaleCompare("colors",option+1) == 0)
985 {
986 /*
987 Reduce the number of colors in the image.
988 */
989 (void) SyncImageSettings(mogrify_info,*image,exception);
990 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
991 if (quantize_info->number_colors == 0)
992 break;
993 if (((*image)->storage_class == DirectClass) ||
994 (*image)->colors > quantize_info->number_colors)
995 (void) QuantizeImage(quantize_info,*image,exception);
996 else
997 (void) CompressImageColormap(*image,exception);
998 break;
999 }
1000 if (LocaleCompare("colorspace",option+1) == 0)
1001 {
1002 ColorspaceType
1003 colorspace;
1004
1005 (void) SyncImageSettings(mogrify_info,*image,exception);
1006 if (*option == '+')
1007 {
1008 (void) TransformImageColorspace(*image,sRGBColorspace,
1009 exception);
1010 break;
1011 }
1012 colorspace=(ColorspaceType) ParseCommandOption(
1013 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1014 (void) TransformImageColorspace(*image,colorspace,exception);
1015 break;
1016 }
1017 if (LocaleCompare("color-threshold",option+1) == 0)
1018 {
1019 PixelInfo
1020 start,
1021 stop;
1022
1023 /*
1024 Color threshold image.
1025 */
1026 (void) SyncImageSettings(mogrify_info,*image,exception);
1027 if (*option == '+')
1028 (void) GetColorRange("white-black",&start,&stop,exception);
1029 else
1030 (void) GetColorRange(argv[i+1],&start,&stop,exception);
1031 (void) ColorThresholdImage(*image,&start,&stop,exception);
1032 break;
1033 }
1034 if (LocaleCompare("compose",option+1) == 0)
1035 {
1036 (void) SyncImageSettings(mogrify_info,*image,exception);
1037 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1038 MagickFalse,argv[i+1]);
1039 break;
1040 }
1041 if (LocaleCompare("connected-components",option+1) == 0)
1042 {
1043 (void) SyncImageSettings(mogrify_info,*image,exception);
1044 mogrify_image=ConnectedComponentsImage(*image,(size_t)
1045 StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1046 break;
1047 }
1048 if (LocaleCompare("contrast",option+1) == 0)
1049 {
1050 (void) SyncImageSettings(mogrify_info,*image,exception);
1051 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1052 MagickFalse,exception);
1053 break;
1054 }
1055 if (LocaleCompare("contrast-stretch",option+1) == 0)
1056 {
1057 double
1058 black_point,
1059 white_point;
1060
1061 /*
1062 Contrast stretch image.
1063 */
1064 (void) SyncImageSettings(mogrify_info,*image,exception);
1065 flags=ParseGeometry(argv[i+1],&geometry_info);
1066 black_point=geometry_info.rho;
1067 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1068 black_point;
1069 if ((flags & PercentValue) != 0)
1070 {
1071 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1072 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1073 }
1074 white_point=(double) (*image)->columns*(*image)->rows-
1075 white_point;
1076 (void) ContrastStretchImage(*image,black_point,white_point,
1077 exception);
1078 break;
1079 }
1080 if (LocaleCompare("convolve",option+1) == 0)
1081 {
1082 double
1083 gamma;
1084
1085 KernelInfo
1086 *kernel_info;
1087
1088 ssize_t
1089 j;
1090
1091 size_t
1092 extent;
1093
1094 (void) SyncImageSettings(mogrify_info,*image,exception);
1095 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1096 if (kernel_info == (KernelInfo *) NULL)
1097 break;
1098 extent=kernel_info->width*kernel_info->height;
1099 gamma=0.0;
1100 for (j=0; j < (ssize_t) extent; j++)
1101 gamma+=kernel_info->values[j];
1102 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1103 for (j=0; j < (ssize_t) extent; j++)
1104 kernel_info->values[j]*=gamma;
1105 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1106 kernel_info,exception);
1107 kernel_info=DestroyKernelInfo(kernel_info);
1108 break;
1109 }
1110 if (LocaleCompare("crop",option+1) == 0)
1111 {
1112 /*
1113 Crop a image to a smaller size
1114 */
1115 (void) SyncImageSettings(mogrify_info,*image,exception);
1116 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1117 break;
1118 }
1119 if (LocaleCompare("cycle",option+1) == 0)
1120 {
1121 /*
1122 Cycle an image colormap.
1123 */
1124 (void) SyncImageSettings(mogrify_info,*image,exception);
1125 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1126 exception);
1127 break;
1128 }
1129 break;
1130 }
1131 case 'd':
1132 {
1133 if (LocaleCompare("decipher",option+1) == 0)
1134 {
1135 StringInfo
1136 *passkey;
1137
1138 /*
1139 Decipher pixels.
1140 */
1141 (void) SyncImageSettings(mogrify_info,*image,exception);
1142 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1143 if (passkey != (StringInfo *) NULL)
1144 {
1145 (void) PasskeyDecipherImage(*image,passkey,exception);
1146 passkey=DestroyStringInfo(passkey);
1147 }
1148 break;
1149 }
1150 if (LocaleCompare("density",option+1) == 0)
1151 {
1152 /*
1153 Set image density.
1154 */
1155 (void) CloneString(&draw_info->density,argv[i+1]);
1156 break;
1157 }
1158 if (LocaleCompare("depth",option+1) == 0)
1159 {
1160 (void) SyncImageSettings(mogrify_info,*image,exception);
1161 if (*option == '+')
1162 {
1163 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1164 break;
1165 }
1166 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1167 exception);
1168 break;
1169 }
1170 if (LocaleCompare("deskew",option+1) == 0)
1171 {
1172 double
1173 threshold;
1174
1175 /*
1176 Straighten the image.
1177 */
1178 (void) SyncImageSettings(mogrify_info,*image,exception);
1179 if (*option == '+')
1180 threshold=40.0*(double) QuantumRange/100.0;
1181 else
1182 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1183 1.0);
1184 mogrify_image=DeskewImage(*image,threshold,exception);
1185 break;
1186 }
1187 if (LocaleCompare("despeckle",option+1) == 0)
1188 {
1189 /*
1190 Reduce the speckles within an image.
1191 */
1192 (void) SyncImageSettings(mogrify_info,*image,exception);
1193 mogrify_image=DespeckleImage(*image,exception);
1194 break;
1195 }
1196 if (LocaleCompare("display",option+1) == 0)
1197 {
1198 (void) CloneString(&draw_info->server_name,argv[i+1]);
1199 break;
1200 }
1201 if (LocaleCompare("distort",option+1) == 0)
1202 {
1203 char
1204 *args,
1205 token[MagickPathExtent];
1206
1207 const char
1208 *p;
1209
1210 DistortMethod
1211 method;
1212
1213 double
1214 *arguments;
1215
1216 ssize_t
1217 x;
1218
1219 size_t
1220 number_arguments;
1221
1222 /*
1223 Distort image.
1224 */
1225 (void) SyncImageSettings(mogrify_info,*image,exception);
1226 method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1227 MagickFalse,argv[i+1]);
1228 if (method == ResizeDistortion)
1229 {
1230 double
1231 resize_args[2];
1232
1233 /*
1234 Special Case - Argument is actually a resize geometry!
1235 Convert that to an appropriate distortion argument array.
1236 */
1237 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1238 exception);
1239 resize_args[0]=(double) geometry.width;
1240 resize_args[1]=(double) geometry.height;
1241 mogrify_image=DistortImage(*image,method,(size_t)2,
1242 resize_args,MagickTrue,exception);
1243 break;
1244 }
1245 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1246 exception);
1247 if (args == (char *) NULL)
1248 break;
1249 p=(char *) args;
1250 for (x=0; *p != '\0'; x++)
1251 {
1252 (void) GetNextToken(p,&p,MagickPathExtent,token);
1253 if (*token == ',')
1254 (void) GetNextToken(p,&p,MagickPathExtent,token);
1255 }
1256 number_arguments=(size_t) x;
1257 arguments=(double *) AcquireQuantumMemory(number_arguments,
1258 sizeof(*arguments));
1259 if (arguments == (double *) NULL)
1260 ThrowWandFatalException(ResourceLimitFatalError,
1261 "MemoryAllocationFailed",(*image)->filename);
1262 (void) memset(arguments,0,number_arguments*
1263 sizeof(*arguments));
1264 p=(char *) args;
1265 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1266 {
1267 (void) GetNextToken(p,&p,MagickPathExtent,token);
1268 if (*token == ',')
1269 (void) GetNextToken(p,&p,MagickPathExtent,token);
1270 arguments[x]=StringToDouble(token,(char **) NULL);
1271 }
1272 args=DestroyString(args);
1273 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1274 (*option == '+') ? MagickTrue : MagickFalse,exception);
1275 arguments=(double *) RelinquishMagickMemory(arguments);
1276 break;
1277 }
1278 if (LocaleCompare("dither",option+1) == 0)
1279 {
1280 if (*option == '+')
1281 {
1282 quantize_info->dither_method=NoDitherMethod;
1283 break;
1284 }
1285 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1286 MagickDitherOptions,MagickFalse,argv[i+1]);
1287 break;
1288 }
1289 if (LocaleCompare("draw",option+1) == 0)
1290 {
1291 /*
1292 Draw image.
1293 */
1294 (void) SyncImageSettings(mogrify_info,*image,exception);
1295 (void) CloneString(&draw_info->primitive,argv[i+1]);
1296 (void) DrawImage(*image,draw_info,exception);
1297 break;
1298 }
1299 break;
1300 }
1301 case 'e':
1302 {
1303 if (LocaleCompare("edge",option+1) == 0)
1304 {
1305 /*
1306 Enhance edges in the image.
1307 */
1308 (void) SyncImageSettings(mogrify_info,*image,exception);
1309 flags=ParseGeometry(argv[i+1],&geometry_info);
1310 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1311 break;
1312 }
1313 if (LocaleCompare("emboss",option+1) == 0)
1314 {
1315 /*
1316 Emboss image.
1317 */
1318 (void) SyncImageSettings(mogrify_info,*image,exception);
1319 flags=ParseGeometry(argv[i+1],&geometry_info);
1320 if ((flags & SigmaValue) == 0)
1321 geometry_info.sigma=1.0;
1322 mogrify_image=EmbossImage(*image,geometry_info.rho,
1323 geometry_info.sigma,exception);
1324 break;
1325 }
1326 if (LocaleCompare("encipher",option+1) == 0)
1327 {
1328 StringInfo
1329 *passkey;
1330
1331 /*
1332 Encipher pixels.
1333 */
1334 (void) SyncImageSettings(mogrify_info,*image,exception);
1335 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1336 if (passkey != (StringInfo *) NULL)
1337 {
1338 (void) PasskeyEncipherImage(*image,passkey,exception);
1339 passkey=DestroyStringInfo(passkey);
1340 }
1341 break;
1342 }
1343 if (LocaleCompare("encoding",option+1) == 0)
1344 {
1345 (void) CloneString(&draw_info->encoding,argv[i+1]);
1346 break;
1347 }
1348 if (LocaleCompare("enhance",option+1) == 0)
1349 {
1350 /*
1351 Enhance image.
1352 */
1353 (void) SyncImageSettings(mogrify_info,*image,exception);
1354 mogrify_image=EnhanceImage(*image,exception);
1355 break;
1356 }
1357 if (LocaleCompare("equalize",option+1) == 0)
1358 {
1359 /*
1360 Equalize image.
1361 */
1362 (void) SyncImageSettings(mogrify_info,*image,exception);
1363 (void) EqualizeImage(*image,exception);
1364 break;
1365 }
1366 if (LocaleCompare("evaluate",option+1) == 0)
1367 {
1368 double
1369 constant;
1370
1371 MagickEvaluateOperator
1372 op;
1373
1374 (void) SyncImageSettings(mogrify_info,*image,exception);
1375 op=(MagickEvaluateOperator) ParseCommandOption(
1376 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1377 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1378 1.0);
1379 (void) EvaluateImage(*image,op,constant,exception);
1380 break;
1381 }
1382 if (LocaleCompare("extent",option+1) == 0)
1383 {
1384 /*
1385 Set the image extent.
1386 */
1387 (void) SyncImageSettings(mogrify_info,*image,exception);
1388 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1389 if (geometry.width == 0)
1390 geometry.width=(*image)->columns;
1391 if (geometry.height == 0)
1392 geometry.height=(*image)->rows;
1393 mogrify_image=ExtentImage(*image,&geometry,exception);
1394 break;
1395 }
1396 break;
1397 }
1398 case 'f':
1399 {
1400 if (LocaleCompare("family",option+1) == 0)
1401 {
1402 if (*option == '+')
1403 {
1404 if (draw_info->family != (char *) NULL)
1405 draw_info->family=DestroyString(draw_info->family);
1406 break;
1407 }
1408 (void) SetImageOption(image_info,option+1,argv[i+1]);
1409 (void) CloneString(&draw_info->family,argv[i+1]);
1410 break;
1411 }
1412 if (LocaleCompare("features",option+1) == 0)
1413 {
1414 if (*option == '+')
1415 {
1416 (void) DeleteImageArtifact(*image,"identify:features");
1417 break;
1418 }
1419 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1420 (void) SetImageArtifact(*image,"verbose","true");
1421 break;
1422 }
1423 if (LocaleCompare("fill",option+1) == 0)
1424 {
1425 ExceptionInfo
1426 *sans;
1427
1428 PixelInfo
1429 color;
1430
1431 GetPixelInfo(*image,&fill);
1432 if (*option == '+')
1433 {
1434 (void) QueryColorCompliance("none",AllCompliance,&fill,
1435 exception);
1436 draw_info->fill=fill;
1437 if (draw_info->fill_pattern != (Image *) NULL)
1438 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1439 break;
1440 }
1441 sans=AcquireExceptionInfo();
1442 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1443 sans=DestroyExceptionInfo(sans);
1444 if (status == MagickFalse)
1445 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1446 exception);
1447 else
1448 draw_info->fill=fill=color;
1449 break;
1450 }
1451 if (LocaleCompare("flip",option+1) == 0)
1452 {
1453 /*
1454 Flip image scanlines.
1455 */
1456 (void) SyncImageSettings(mogrify_info,*image,exception);
1457 mogrify_image=FlipImage(*image,exception);
1458 break;
1459 }
1460 if (LocaleCompare("floodfill",option+1) == 0)
1461 {
1462 PixelInfo
1463 target;
1464
1465 /*
1466 Floodfill image.
1467 */
1468 (void) SyncImageSettings(mogrify_info,*image,exception);
1469 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1470 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1471 exception);
1472 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1473 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1474 break;
1475 }
1476 if (LocaleCompare("flop",option+1) == 0)
1477 {
1478 /*
1479 Flop image scanlines.
1480 */
1481 (void) SyncImageSettings(mogrify_info,*image,exception);
1482 mogrify_image=FlopImage(*image,exception);
1483 break;
1484 }
1485 if (LocaleCompare("font",option+1) == 0)
1486 {
1487 if (*option == '+')
1488 {
1489 if (draw_info->font != (char *) NULL)
1490 draw_info->font=DestroyString(draw_info->font);
1491 break;
1492 }
1493 (void) CloneString(&draw_info->font,argv[i+1]);
1494 break;
1495 }
1496 if (LocaleCompare("format",option+1) == 0)
1497 {
1498 format=argv[i+1];
1499 break;
1500 }
1501 if (LocaleCompare("frame",option+1) == 0)
1502 {
1503 FrameInfo
1504 frame_info;
1505
1506 /*
1507 Surround image with an ornamental border.
1508 */
1509 (void) SyncImageSettings(mogrify_info,*image,exception);
1510 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1511 frame_info.width=geometry.width;
1512 frame_info.height=geometry.height;
1513 frame_info.outer_bevel=geometry.x;
1514 frame_info.inner_bevel=geometry.y;
1515 frame_info.x=(ssize_t) frame_info.width;
1516 frame_info.y=(ssize_t) frame_info.height;
1517 frame_info.width=(*image)->columns+2*frame_info.width;
1518 frame_info.height=(*image)->rows+2*frame_info.height;
1519 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1520 break;
1521 }
1522 if (LocaleCompare("function",option+1) == 0)
1523 {
1524 char
1525 *arguments,
1526 token[MagickPathExtent];
1527
1528 const char
1529 *p;
1530
1531 double
1532 *parameters;
1533
1534 MagickFunction
1535 function;
1536
1537 ssize_t
1538 x;
1539
1540 size_t
1541 number_parameters;
1542
1543 /*
1544 Function Modify Image Values
1545 */
1546 (void) SyncImageSettings(mogrify_info,*image,exception);
1547 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1548 MagickFalse,argv[i+1]);
1549 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1550 exception);
1551 if (arguments == (char *) NULL)
1552 break;
1553 p=(char *) arguments;
1554 for (x=0; *p != '\0'; x++)
1555 {
1556 (void) GetNextToken(p,&p,MagickPathExtent,token);
1557 if (*token == ',')
1558 (void) GetNextToken(p,&p,MagickPathExtent,token);
1559 }
1560 number_parameters=(size_t) x;
1561 parameters=(double *) AcquireQuantumMemory(number_parameters,
1562 sizeof(*parameters));
1563 if (parameters == (double *) NULL)
1564 ThrowWandFatalException(ResourceLimitFatalError,
1565 "MemoryAllocationFailed",(*image)->filename);
1566 (void) memset(parameters,0,number_parameters*
1567 sizeof(*parameters));
1568 p=(char *) arguments;
1569 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1570 {
1571 (void) GetNextToken(p,&p,MagickPathExtent,token);
1572 if (*token == ',')
1573 (void) GetNextToken(p,&p,MagickPathExtent,token);
1574 parameters[x]=StringToDouble(token,(char **) NULL);
1575 }
1576 arguments=DestroyString(arguments);
1577 (void) FunctionImage(*image,function,number_parameters,parameters,
1578 exception);
1579 parameters=(double *) RelinquishMagickMemory(parameters);
1580 break;
1581 }
1582 break;
1583 }
1584 case 'g':
1585 {
1586 if (LocaleCompare("gamma",option+1) == 0)
1587 {
1588 /*
1589 Gamma image.
1590 */
1591 (void) SyncImageSettings(mogrify_info,*image,exception);
1592 if (*option == '+')
1593 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1594 else
1595 (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),
1596 exception);
1597 break;
1598 }
1599 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1600 (LocaleCompare("gaussian",option+1) == 0))
1601 {
1602 /*
1603 Gaussian blur image.
1604 */
1605 (void) SyncImageSettings(mogrify_info,*image,exception);
1606 flags=ParseGeometry(argv[i+1],&geometry_info);
1607 if ((flags & SigmaValue) == 0)
1608 geometry_info.sigma=1.0;
1609 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1610 geometry_info.sigma,exception);
1611 break;
1612 }
1613 if (LocaleCompare("geometry",option+1) == 0)
1614 {
1615 /*
1616 Record Image offset, Resize last image.
1617 */
1618 (void) SyncImageSettings(mogrify_info,*image,exception);
1619 if (*option == '+')
1620 {
1621 if ((*image)->geometry != (char *) NULL)
1622 (*image)->geometry=DestroyString((*image)->geometry);
1623 break;
1624 }
1625 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1626 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1627 (void) CloneString(&(*image)->geometry,argv[i+1]);
1628 else
1629 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1630 (*image)->filter,exception);
1631 break;
1632 }
1633 if (LocaleCompare("gravity",option+1) == 0)
1634 {
1635 if (*option == '+')
1636 {
1637 draw_info->gravity=UndefinedGravity;
1638 break;
1639 }
1640 draw_info->gravity=(GravityType) ParseCommandOption(
1641 MagickGravityOptions,MagickFalse,argv[i+1]);
1642 break;
1643 }
1644 if (LocaleCompare("grayscale",option+1) == 0)
1645 {
1646 PixelIntensityMethod
1647 method;
1648
1649 (void) SyncImageSettings(mogrify_info,*image,exception);
1650 method=(PixelIntensityMethod) ParseCommandOption(
1651 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1652 (void) GrayscaleImage(*image,method,exception);
1653 break;
1654 }
1655 break;
1656 }
1657 case 'h':
1658 {
1659 if (LocaleCompare("highlight-color",option+1) == 0)
1660 {
1661 (void) SetImageArtifact(*image,"compare:highlight-color",argv[i+1]);
1662 break;
1663 }
1664 if (LocaleCompare("hough-lines",option+1) == 0)
1665 {
1666 /*
1667 Detect edges in the image.
1668 */
1669 (void) SyncImageSettings(mogrify_info,*image,exception);
1670 flags=ParseGeometry(argv[i+1],&geometry_info);
1671 if ((flags & SigmaValue) == 0)
1672 geometry_info.sigma=geometry_info.rho;
1673 if ((flags & XiValue) == 0)
1674 geometry_info.xi=40;
1675 mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1676 (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1677 break;
1678 }
1679 break;
1680 }
1681 case 'i':
1682 {
1683 if (LocaleCompare("identify",option+1) == 0)
1684 {
1685 char
1686 *text;
1687
1688 (void) SyncImageSettings(mogrify_info,*image,exception);
1689 if (format == (char *) NULL)
1690 {
1691 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1692 exception);
1693 break;
1694 }
1695 text=InterpretImageProperties(mogrify_info,*image,format,exception);
1696 if (text == (char *) NULL)
1697 break;
1698 (void) fputs(text,stdout);
1699 text=DestroyString(text);
1700 break;
1701 }
1702 if (LocaleCompare("illuminant",option+1) == 0)
1703 {
1704 (void) SetImageArtifact(*image,"color:illuminant",argv[i+1]);
1705 break;
1706 }
1707 if (LocaleCompare("implode",option+1) == 0)
1708 {
1709 /*
1710 Implode image.
1711 */
1712 (void) SyncImageSettings(mogrify_info,*image,exception);
1713 (void) ParseGeometry(argv[i+1],&geometry_info);
1714 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1715 interpolate_method,exception);
1716 break;
1717 }
1718 if (LocaleCompare("integral",option+1) == 0)
1719 {
1720 (void) SyncImageSettings(mogrify_info,*image,exception);
1721 mogrify_image=IntegralImage(*image,exception);
1722 break;
1723 }
1724 if (LocaleCompare("interline-spacing",option+1) == 0)
1725 {
1726 if (*option == '+')
1727 (void) ParseGeometry("0",&geometry_info);
1728 else
1729 (void) ParseGeometry(argv[i+1],&geometry_info);
1730 draw_info->interline_spacing=geometry_info.rho;
1731 break;
1732 }
1733 if (LocaleCompare("interpolate",option+1) == 0)
1734 {
1735 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1736 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1737 break;
1738 }
1739 if (LocaleCompare("interword-spacing",option+1) == 0)
1740 {
1741 if (*option == '+')
1742 (void) ParseGeometry("0",&geometry_info);
1743 else
1744 (void) ParseGeometry(argv[i+1],&geometry_info);
1745 draw_info->interword_spacing=geometry_info.rho;
1746 break;
1747 }
1748 if (LocaleCompare("interpolative-resize",option+1) == 0)
1749 {
1750 /*
1751 Interpolative resize image.
1752 */
1753 (void) SyncImageSettings(mogrify_info,*image,exception);
1754 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1755 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1756 geometry.height,interpolate_method,exception);
1757 break;
1758 }
1759 break;
1760 }
1761 case 'k':
1762 {
1763 if (LocaleCompare("kerning",option+1) == 0)
1764 {
1765 if (*option == '+')
1766 (void) ParseGeometry("0",&geometry_info);
1767 else
1768 (void) ParseGeometry(argv[i+1],&geometry_info);
1769 draw_info->kerning=geometry_info.rho;
1770 break;
1771 }
1772 if (LocaleCompare("kmeans",option+1) == 0)
1773 {
1774 /*
1775 K-means clustering.
1776 */
1777 (void) SyncImageSettings(mogrify_info,*image,exception);
1778 flags=ParseGeometry(argv[i+1],&geometry_info);
1779 if ((flags & SigmaValue) == 0)
1780 geometry_info.sigma=300.0;
1781 if ((flags & XiValue) == 0)
1782 geometry_info.xi=0.0001;
1783 (void) KmeansImage(*image,(size_t) geometry_info.rho,
1784 (size_t) geometry_info.sigma,geometry_info.xi,exception);
1785 break;
1786 }
1787 if (LocaleCompare("kuwahara",option+1) == 0)
1788 {
1789 /*
1790 Edge preserving blur.
1791 */
1792 (void) SyncImageSettings(mogrify_info,*image,exception);
1793 flags=ParseGeometry(argv[i+1],&geometry_info);
1794 if ((flags & SigmaValue) == 0)
1795 geometry_info.sigma=geometry_info.rho-0.5;
1796 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1797 geometry_info.sigma,exception);
1798 break;
1799 }
1800 break;
1801 }
1802 case 'l':
1803 {
1804 if (LocaleCompare("lat",option+1) == 0)
1805 {
1806 /*
1807 Local adaptive threshold image.
1808 */
1809 (void) SyncImageSettings(mogrify_info,*image,exception);
1810 flags=ParseGeometry(argv[i+1],&geometry_info);
1811 if ((flags & PercentValue) != 0)
1812 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1813 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1814 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1815 geometry_info.xi,exception);
1816 break;
1817 }
1818 if (LocaleCompare("level",option+1) == 0)
1819 {
1820 double
1821 black_point,
1822 gamma,
1823 white_point;
1824
1825 /*
1826 Parse levels.
1827 */
1828 (void) SyncImageSettings(mogrify_info,*image,exception);
1829 flags=ParseGeometry(argv[i+1],&geometry_info);
1830 black_point=geometry_info.rho;
1831 white_point=(double) QuantumRange;
1832 if ((flags & SigmaValue) != 0)
1833 white_point=geometry_info.sigma;
1834 gamma=1.0;
1835 if ((flags & XiValue) != 0)
1836 gamma=geometry_info.xi;
1837 if ((flags & PercentValue) != 0)
1838 {
1839 black_point*=(double) QuantumRange/100.0;
1840 white_point*=(double) QuantumRange/100.0;
1841 }
1842 if ((flags & SigmaValue) == 0)
1843 white_point=(double) QuantumRange-black_point;
1844 if ((*option == '+') || ((flags & AspectValue) != 0))
1845 (void) LevelizeImage(*image,black_point,white_point,gamma,
1846 exception);
1847 else
1848 (void) LevelImage(*image,black_point,white_point,gamma,exception);
1849 break;
1850 }
1851 if (LocaleCompare("level-colors",option+1) == 0)
1852 {
1853 char
1854 token[MagickPathExtent];
1855
1856 const char
1857 *p;
1858
1859 PixelInfo
1860 black_point,
1861 white_point;
1862
1863 p=(const char *) argv[i+1];
1864 (void) GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */
1865 if ((isalpha((int) ((unsigned char) *token)) != 0) || ((*token == '#') != 0))
1866 (void) QueryColorCompliance(token,AllCompliance,&black_point,
1867 exception);
1868 else
1869 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
1870 exception);
1871 if (isalpha((int) ((unsigned char) *token)) || (*token == '#'))
1872 (void) GetNextToken(p,&p,MagickPathExtent,token);
1873 if (*token == '\0')
1874 white_point=black_point; /* set everything to that color */
1875 else
1876 {
1877 if ((isalpha((int) ((unsigned char) *token)) == 0) && ((*token == '#') == 0))
1878 (void) GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */
1879 if ((isalpha((int) ((unsigned char) *token)) != 0) || ((*token == '#') != 0))
1880 (void) QueryColorCompliance(token,AllCompliance,&white_point,
1881 exception);
1882 else
1883 (void) QueryColorCompliance("#ffffff",AllCompliance,
1884 &white_point,exception);
1885 }
1886 (void) LevelImageColors(*image,&black_point,&white_point,
1887 *option == '+' ? MagickTrue : MagickFalse,exception);
1888 break;
1889 }
1890 if (LocaleCompare("linear-stretch",option+1) == 0)
1891 {
1892 double
1893 black_point,
1894 white_point;
1895
1896 (void) SyncImageSettings(mogrify_info,*image,exception);
1897 flags=ParseGeometry(argv[i+1],&geometry_info);
1898 black_point=geometry_info.rho;
1899 white_point=(double) (*image)->columns*(*image)->rows;
1900 if ((flags & SigmaValue) != 0)
1901 white_point=geometry_info.sigma;
1902 if ((flags & PercentValue) != 0)
1903 {
1904 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1905 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1906 }
1907 if ((flags & SigmaValue) == 0)
1908 white_point=(double) (*image)->columns*(*image)->rows-
1909 black_point;
1910 (void) LinearStretchImage(*image,black_point,white_point,exception);
1911 break;
1912 }
1913 if (LocaleCompare("liquid-rescale",option+1) == 0)
1914 {
1915 /*
1916 Liquid rescale image.
1917 */
1918 (void) SyncImageSettings(mogrify_info,*image,exception);
1919 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1920 if ((flags & XValue) == 0)
1921 geometry.x=1;
1922 if ((flags & YValue) == 0)
1923 geometry.y=0;
1924 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1925 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1926 break;
1927 }
1928 if (LocaleCompare("local-contrast",option+1) == 0)
1929 {
1930 (void) SyncImageSettings(mogrify_info,*image,exception);
1931 flags=ParseGeometry(argv[i+1],&geometry_info);
1932 if ((flags & RhoValue) == 0)
1933 geometry_info.rho=10;
1934 if ((flags & SigmaValue) == 0)
1935 geometry_info.sigma=12.5;
1936 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
1937 geometry_info.sigma,exception);
1938 break;
1939 }
1940 if (LocaleCompare("lowlight-color",option+1) == 0)
1941 {
1942 (void) SetImageArtifact(*image,"compare:lowlight-color",argv[i+1]);
1943 break;
1944 }
1945 break;
1946 }
1947 case 'm':
1948 {
1949 if (LocaleCompare("magnify",option+1) == 0)
1950 {
1951 /*
1952 Double image size.
1953 */
1954 (void) SyncImageSettings(mogrify_info,*image,exception);
1955 mogrify_image=MagnifyImage(*image,exception);
1956 break;
1957 }
1958 if (LocaleCompare("map",option+1) == 0)
1959 {
1960 Image
1961 *remap_image;
1962
1963 /*
1964 Transform image colors to match this set of colors.
1965 */
1966 (void) SyncImageSettings(mogrify_info,*image,exception);
1967 if (*option == '+')
1968 break;
1969 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
1970 if (remap_image == (Image *) NULL)
1971 break;
1972 (void) RemapImage(quantize_info,*image,remap_image,exception);
1973 remap_image=DestroyImage(remap_image);
1974 break;
1975 }
1976 if (LocaleCompare("mask",option+1) == 0)
1977 {
1978 Image
1979 *mask;
1980
1981 (void) SyncImageSettings(mogrify_info,*image,exception);
1982 if (*option == '+')
1983 {
1984 /*
1985 Remove a mask.
1986 */
1987 (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
1988 exception);
1989 break;
1990 }
1991 /*
1992 Set the image mask.
1993 */
1994 mask=GetImageCache(mogrify_info,argv[i+1],exception);
1995 if (mask == (Image *) NULL)
1996 break;
1997 (void) SetImageMask(*image,WritePixelMask,mask,exception);
1998 mask=DestroyImage(mask);
1999 break;
2000 }
2001 if (LocaleCompare("matte",option+1) == 0)
2002 {
2003 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2004 SetAlphaChannel : DeactivateAlphaChannel,exception);
2005 break;
2006 }
2007 if (LocaleCompare("mean-shift",option+1) == 0)
2008 {
2009 /*
2010 Detect edges in the image.
2011 */
2012 (void) SyncImageSettings(mogrify_info,*image,exception);
2013 flags=ParseGeometry(argv[i+1],&geometry_info);
2014 if ((flags & SigmaValue) == 0)
2015 geometry_info.sigma=geometry_info.rho;
2016 if ((flags & XiValue) == 0)
2017 geometry_info.xi=0.10*(double) QuantumRange;
2018 if ((flags & PercentValue) != 0)
2019 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2020 mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2021 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2022 break;
2023 }
2024 if (LocaleCompare("median",option+1) == 0)
2025 {
2026 /*
2027 Median filter image.
2028 */
2029 (void) SyncImageSettings(mogrify_info,*image,exception);
2030 flags=ParseGeometry(argv[i+1],&geometry_info);
2031 if ((flags & SigmaValue) == 0)
2032 geometry_info.sigma=geometry_info.rho;
2033 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2034 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2035 break;
2036 }
2037 if (LocaleCompare("mode",option+1) == 0)
2038 {
2039 /*
2040 Mode image.
2041 */
2042 (void) SyncImageSettings(mogrify_info,*image,exception);
2043 flags=ParseGeometry(argv[i+1],&geometry_info);
2044 if ((flags & SigmaValue) == 0)
2045 geometry_info.sigma=geometry_info.rho;
2046 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2047 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2048 break;
2049 }
2050 if (LocaleCompare("modulate",option+1) == 0)
2051 {
2052 (void) SyncImageSettings(mogrify_info,*image,exception);
2053 (void) ModulateImage(*image,argv[i+1],exception);
2054 break;
2055 }
2056 if (LocaleCompare("moments",option+1) == 0)
2057 {
2058 if (*option == '+')
2059 {
2060 (void) DeleteImageArtifact(*image,"identify:moments");
2061 break;
2062 }
2063 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2064 (void) SetImageArtifact(*image,"verbose","true");
2065 break;
2066 }
2067 if (LocaleCompare("monitor",option+1) == 0)
2068 {
2069 if (*option == '+')
2070 {
2071 (void) SetImageProgressMonitor(*image,
2072 (MagickProgressMonitor) NULL,(void *) NULL);
2073 break;
2074 }
2075 (void) SetImageProgressMonitor(*image,MonitorProgress,
2076 (void *) NULL);
2077 break;
2078 }
2079 if (LocaleCompare("monochrome",option+1) == 0)
2080 {
2081 (void) SyncImageSettings(mogrify_info,*image,exception);
2082 (void) SetImageType(*image,BilevelType,exception);
2083 break;
2084 }
2085 if (LocaleCompare("morphology",option+1) == 0)
2086 {
2087 char
2088 token[MagickPathExtent];
2089
2090 const char
2091 *p;
2092
2093 KernelInfo
2094 *kernel;
2095
2096 MorphologyMethod
2097 method;
2098
2099 ssize_t
2100 iterations;
2101
2102 /*
2103 Morphological Image Operation
2104 */
2105 (void) SyncImageSettings(mogrify_info,*image,exception);
2106 p=argv[i+1];
2107 (void) GetNextToken(p,&p,MagickPathExtent,token);
2108 method=(MorphologyMethod) ParseCommandOption(
2109 MagickMorphologyOptions,MagickFalse,token);
2110 iterations=1L;
2111 (void) GetNextToken(p,&p,MagickPathExtent,token);
2112 if ((*p == ':') || (*p == ','))
2113 (void) GetNextToken(p,&p,MagickPathExtent,token);
2114 if ((*p != '\0'))
2115 iterations=(ssize_t) StringToLong(p);
2116 kernel=AcquireKernelInfo(argv[i+2],exception);
2117 if (kernel == (KernelInfo *) NULL)
2118 {
2119 (void) ThrowMagickException(exception,GetMagickModule(),
2120 OptionError,"UnabletoParseKernel","morphology");
2121 status=MagickFalse;
2122 break;
2123 }
2124 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2125 exception);
2126 kernel=DestroyKernelInfo(kernel);
2127 break;
2128 }
2129 if (LocaleCompare("motion-blur",option+1) == 0)
2130 {
2131 /*
2132 Motion blur image.
2133 */
2134 (void) SyncImageSettings(mogrify_info,*image,exception);
2135 flags=ParseGeometry(argv[i+1],&geometry_info);
2136 if ((flags & SigmaValue) == 0)
2137 geometry_info.sigma=1.0;
2138 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2139 geometry_info.sigma,geometry_info.xi,exception);
2140 break;
2141 }
2142 break;
2143 }
2144 case 'n':
2145 {
2146 if (LocaleCompare("negate",option+1) == 0)
2147 {
2148 (void) SyncImageSettings(mogrify_info,*image,exception);
2149 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2150 MagickFalse,exception);
2151 break;
2152 }
2153 if (LocaleCompare("noise",option+1) == 0)
2154 {
2155 (void) SyncImageSettings(mogrify_info,*image,exception);
2156 if (*option == '-')
2157 {
2158 flags=ParseGeometry(argv[i+1],&geometry_info);
2159 if ((flags & SigmaValue) == 0)
2160 geometry_info.sigma=geometry_info.rho;
2161 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2162 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2163 }
2164 else
2165 {
2166 NoiseType
2167 noise;
2168
2169 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2170 MagickFalse,argv[i+1]);
2171 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2172 }
2173 break;
2174 }
2175 if (LocaleCompare("normalize",option+1) == 0)
2176 {
2177 (void) SyncImageSettings(mogrify_info,*image,exception);
2178 (void) NormalizeImage(*image,exception);
2179 break;
2180 }
2181 break;
2182 }
2183 case 'o':
2184 {
2185 if (LocaleCompare("opaque",option+1) == 0)
2186 {
2187 PixelInfo
2188 target;
2189
2190 (void) SyncImageSettings(mogrify_info,*image,exception);
2191 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2192 exception);
2193 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2194 MagickFalse : MagickTrue,exception);
2195 break;
2196 }
2197 if (LocaleCompare("ordered-dither",option+1) == 0)
2198 {
2199 (void) SyncImageSettings(mogrify_info,*image,exception);
2200 (void) OrderedDitherImage(*image,argv[i+1],exception);
2201 break;
2202 }
2203 break;
2204 }
2205 case 'p':
2206 {
2207 if (LocaleCompare("paint",option+1) == 0)
2208 {
2209 (void) SyncImageSettings(mogrify_info,*image,exception);
2210 (void) ParseGeometry(argv[i+1],&geometry_info);
2211 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2212 geometry_info.sigma,exception);
2213 break;
2214 }
2215 if (LocaleCompare("perceptible",option+1) == 0)
2216 {
2217 /*
2218 Perceptible image.
2219 */
2220 (void) SyncImageSettings(mogrify_info,*image,exception);
2221 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2222 (char **) NULL),exception);
2223 break;
2224 }
2225 if (LocaleCompare("pointsize",option+1) == 0)
2226 {
2227 if (*option == '+')
2228 (void) ParseGeometry("12",&geometry_info);
2229 else
2230 (void) ParseGeometry(argv[i+1],&geometry_info);
2231 draw_info->pointsize=geometry_info.rho;
2232 break;
2233 }
2234 if (LocaleCompare("polaroid",option+1) == 0)
2235 {
2236 const char
2237 *caption;
2238
2239 double
2240 angle;
2241
2242 RandomInfo
2243 *random_info;
2244
2245 /*
2246 Simulate a Polaroid picture.
2247 */
2248 (void) SyncImageSettings(mogrify_info,*image,exception);
2249 random_info=AcquireRandomInfo();
2250 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2251 random_info=DestroyRandomInfo(random_info);
2252 if (*option == '-')
2253 {
2254 SetGeometryInfo(&geometry_info);
2255 flags=ParseGeometry(argv[i+1],&geometry_info);
2256 angle=geometry_info.rho;
2257 }
2258 caption=GetImageProperty(*image,"caption",exception);
2259 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2260 interpolate_method,exception);
2261 break;
2262 }
2263 if (LocaleCompare("posterize",option+1) == 0)
2264 {
2265 /*
2266 Posterize image.
2267 */
2268 (void) SyncImageSettings(mogrify_info,*image,exception);
2269 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2270 quantize_info->dither_method,exception);
2271 break;
2272 }
2273 if (LocaleCompare("preview",option+1) == 0)
2274 {
2275 PreviewType
2276 preview_type;
2277
2278 /*
2279 Preview image.
2280 */
2281 (void) SyncImageSettings(mogrify_info,*image,exception);
2282 if (*option == '+')
2283 preview_type=UndefinedPreview;
2284 else
2285 preview_type=(PreviewType) ParseCommandOption(
2286 MagickPreviewOptions,MagickFalse,argv[i+1]);
2287 mogrify_image=PreviewImage(*image,preview_type,exception);
2288 break;
2289 }
2290 if (LocaleCompare("profile",option+1) == 0)
2291 {
2292 const char
2293 *name;
2294
2295 const StringInfo
2296 *profile;
2297
2298 ExceptionInfo
2299 *sans_exception;
2300
2301 Image
2302 *profile_image;
2303
2304 ImageInfo
2305 *profile_info;
2306
2307 (void) SyncImageSettings(mogrify_info,*image,exception);
2308 if (*option == '+')
2309 {
2310 /*
2311 Remove a profile from the image.
2312 */
2313 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2314 NULL,0,exception);
2315 break;
2316 }
2317 /*
2318 Associate a profile with the image.
2319 */
2320 profile_info=CloneImageInfo(mogrify_info);
2321 profile=GetImageProfile(*image,"iptc");
2322 if (profile != (StringInfo *) NULL)
2323 profile_info->profile=(void *) CloneStringInfo(profile);
2324 sans_exception=AcquireExceptionInfo();
2325 profile_image=GetImageCache(profile_info,argv[i+1],sans_exception);
2326 sans_exception=DestroyExceptionInfo(sans_exception);
2327 profile_info=DestroyImageInfo(profile_info);
2328 if (profile_image == (Image *) NULL)
2329 {
2330 StringInfo
2331 *file_data;
2332
2333 profile_info=CloneImageInfo(mogrify_info);
2334 (void) CopyMagickString(profile_info->filename,argv[i+1],
2335 MagickPathExtent);
2336 file_data=FileToStringInfo(profile_info->filename,~0UL,
2337 exception);
2338 if (file_data != (StringInfo *) NULL)
2339 {
2340 (void) SetImageInfo(profile_info,0,exception);
2341 (void) ProfileImage(*image,profile_info->magick,
2342 GetStringInfoDatum(file_data),
2343 GetStringInfoLength(file_data),exception);
2344 file_data=DestroyStringInfo(file_data);
2345 }
2346 profile_info=DestroyImageInfo(profile_info);
2347 break;
2348 }
2349 ResetImageProfileIterator(profile_image);
2350 name=GetNextImageProfile(profile_image);
2351 while (name != (const char *) NULL)
2352 {
2353 profile=GetImageProfile(profile_image,name);
2354 if (profile != (StringInfo *) NULL)
2355 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2356 (size_t) GetStringInfoLength(profile),exception);
2357 name=GetNextImageProfile(profile_image);
2358 }
2359 profile_image=DestroyImage(profile_image);
2360 break;
2361 }
2362 break;
2363 }
2364 case 'q':
2365 {
2366 if (LocaleCompare("quantize",option+1) == 0)
2367 {
2368 if (*option == '+')
2369 {
2370 quantize_info->colorspace=UndefinedColorspace;
2371 break;
2372 }
2373 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2374 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2375 break;
2376 }
2377 break;
2378 }
2379 case 'r':
2380 {
2381 if (LocaleCompare("rotational-blur",option+1) == 0)
2382 {
2383 /*
2384 Rotational blur image.
2385 */
2386 (void) SyncImageSettings(mogrify_info,*image,exception);
2387 flags=ParseGeometry(argv[i+1],&geometry_info);
2388 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,
2389 exception);
2390 break;
2391 }
2392 if (LocaleCompare("raise",option+1) == 0)
2393 {
2394 /*
2395 Surround image with a raise of solid color.
2396 */
2397 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2398 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2399 MagickFalse,exception);
2400 break;
2401 }
2402 if (LocaleCompare("random-threshold",option+1) == 0)
2403 {
2404 /*
2405 Random threshold image.
2406 */
2407 double
2408 min_threshold,
2409 max_threshold;
2410
2411 (void) SyncImageSettings(mogrify_info,*image,exception);
2412 min_threshold=0.0;
2413 max_threshold=(double) QuantumRange;
2414 flags=ParseGeometry(argv[i+1],&geometry_info);
2415 min_threshold=geometry_info.rho;
2416 max_threshold=geometry_info.sigma;
2417 if ((flags & SigmaValue) == 0)
2418 max_threshold=min_threshold;
2419 if (strchr(argv[i+1],'%') != (char *) NULL)
2420 {
2421 max_threshold*=0.01*(double) QuantumRange;
2422 min_threshold*=0.01*(double) QuantumRange;
2423 }
2424 (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2425 exception);
2426 break;
2427 }
2428 if (LocaleCompare("range-threshold",option+1) == 0)
2429 {
2430 /*
2431 Range threshold image.
2432 */
2433 (void) SyncImageSettings(mogrify_info,*image,exception);
2434 flags=ParseGeometry(argv[i+1],&geometry_info);
2435 if ((flags & SigmaValue) == 0)
2436 geometry_info.sigma=geometry_info.rho;
2437 if ((flags & XiValue) == 0)
2438 geometry_info.xi=geometry_info.sigma;
2439 if ((flags & PsiValue) == 0)
2440 geometry_info.psi=geometry_info.xi;
2441 if (strchr(argv[i+1],'%') != (char *) NULL)
2442 {
2443 geometry_info.rho*=0.01*(double) QuantumRange;
2444 geometry_info.sigma*=0.01*(double) QuantumRange;
2445 geometry_info.xi*=0.01*(double) QuantumRange;
2446 geometry_info.psi*=0.01*(double) QuantumRange;
2447 }
2448 (void) RangeThresholdImage(*image,geometry_info.rho,
2449 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2450 break;
2451 }
2452 if (LocaleCompare("read-mask",option+1) == 0)
2453 {
2454 Image
2455 *mask;
2456
2457 (void) SyncImageSettings(mogrify_info,*image,exception);
2458 if (*option == '+')
2459 {
2460 /*
2461 Remove a mask.
2462 */
2463 (void) SetImageMask(*image,ReadPixelMask,(const Image *) NULL,
2464 exception);
2465 break;
2466 }
2467 /*
2468 Set the image mask.
2469 */
2470 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2471 if (mask == (Image *) NULL)
2472 break;
2473 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2474 mask=DestroyImage(mask);
2475 break;
2476 }
2477 if (LocaleCompare("region",option+1) == 0)
2478 {
2479 /*
2480 Apply read mask as defined by a region geometry.
2481 */
2482 (void) SyncImageSettings(mogrify_info,*image,exception);
2483 if (*option == '+')
2484 {
2485 (void) SetImageRegionMask(*image,WritePixelMask,
2486 (const RectangleInfo *) NULL,exception);
2487 break;
2488 }
2489 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2490 (void) SetImageRegionMask(*image,WritePixelMask,&geometry,
2491 exception);
2492 break;
2493 }
2494 if (LocaleCompare("render",option+1) == 0)
2495 {
2496 (void) SyncImageSettings(mogrify_info,*image,exception);
2497 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2498 break;
2499 }
2500 if (LocaleCompare("remap",option+1) == 0)
2501 {
2502 Image
2503 *remap_image;
2504
2505 /*
2506 Transform image colors to match this set of colors.
2507 */
2508 (void) SyncImageSettings(mogrify_info,*image,exception);
2509 if (*option == '+')
2510 break;
2511 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2512 if (remap_image == (Image *) NULL)
2513 break;
2514 (void) RemapImage(quantize_info,*image,remap_image,exception);
2515 remap_image=DestroyImage(remap_image);
2516 break;
2517 }
2518 if (LocaleCompare("repage",option+1) == 0)
2519 {
2520 if (*option == '+')
2521 {
2522 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2523 break;
2524 }
2525 (void) ResetImagePage(*image,argv[i+1]);
2526 break;
2527 }
2528 if (LocaleCompare("resample",option+1) == 0)
2529 {
2530 /*
2531 Resample image.
2532 */
2533 (void) SyncImageSettings(mogrify_info,*image,exception);
2534 flags=ParseGeometry(argv[i+1],&geometry_info);
2535 if ((flags & SigmaValue) == 0)
2536 geometry_info.sigma=geometry_info.rho;
2537 mogrify_image=ResampleImage(*image,geometry_info.rho,
2538 geometry_info.sigma,(*image)->filter,exception);
2539 break;
2540 }
2541 if (LocaleCompare("reshape",option+1) == 0)
2542 {
2543 /*
2544 Reshape image.
2545 */
2546 (void) SyncImageSettings(mogrify_info,*image,exception);
2547 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2548 (void) ReshapePixelCache(*image,geometry.width,geometry.height,
2549 exception);
2550 break;
2551 }
2552 if (LocaleCompare("resize",option+1) == 0)
2553 {
2554 /*
2555 Resize image.
2556 */
2557 (void) SyncImageSettings(mogrify_info,*image,exception);
2558 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2559 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2560 (*image)->filter,exception);
2561 break;
2562 }
2563 if (LocaleCompare("roll",option+1) == 0)
2564 {
2565 /*
2566 Roll image.
2567 */
2568 (void) SyncImageSettings(mogrify_info,*image,exception);
2569 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2570 if ((flags & PercentValue) != 0)
2571 {
2572 geometry.x*=(double) (*image)->columns/100.0;
2573 geometry.y*=(double) (*image)->rows/100.0;
2574 }
2575 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2576 break;
2577 }
2578 if (LocaleCompare("rotate",option+1) == 0)
2579 {
2580 char
2581 *rotation;
2582
2583 /*
2584 Check for conditional image rotation.
2585 */
2586 (void) SyncImageSettings(mogrify_info,*image,exception);
2587 if (strchr(argv[i+1],'>') != (char *) NULL)
2588 if ((*image)->columns <= (*image)->rows)
2589 break;
2590 if (strchr(argv[i+1],'<') != (char *) NULL)
2591 if ((*image)->columns >= (*image)->rows)
2592 break;
2593 /*
2594 Rotate image.
2595 */
2596 rotation=ConstantString(argv[i+1]);
2597 (void) SubstituteString(&rotation,">","");
2598 (void) SubstituteString(&rotation,"<","");
2599 (void) ParseGeometry(rotation,&geometry_info);
2600 rotation=DestroyString(rotation);
2601 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2602 break;
2603 }
2604 break;
2605 }
2606 case 's':
2607 {
2608 if (LocaleCompare("sample",option+1) == 0)
2609 {
2610 /*
2611 Sample image with pixel replication.
2612 */
2613 (void) SyncImageSettings(mogrify_info,*image,exception);
2614 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2615 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2616 exception);
2617 break;
2618 }
2619 if (LocaleCompare("scale",option+1) == 0)
2620 {
2621 /*
2622 Resize image.
2623 */
2624 (void) SyncImageSettings(mogrify_info,*image,exception);
2625 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2626 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2627 exception);
2628 break;
2629 }
2630 if (LocaleCompare("selective-blur",option+1) == 0)
2631 {
2632 /*
2633 Selectively blur pixels within a contrast threshold.
2634 */
2635 (void) SyncImageSettings(mogrify_info,*image,exception);
2636 flags=ParseGeometry(argv[i+1],&geometry_info);
2637 if ((flags & PercentValue) != 0)
2638 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2639 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2640 geometry_info.sigma,geometry_info.xi,exception);
2641 break;
2642 }
2643 if (LocaleCompare("separate",option+1) == 0)
2644 {
2645 /*
2646 Break channels into separate images.
2647 */
2648 (void) SyncImageSettings(mogrify_info,*image,exception);
2649 mogrify_image=SeparateImages(*image,exception);
2650 break;
2651 }
2652 if (LocaleCompare("sepia-tone",option+1) == 0)
2653 {
2654 double
2655 threshold;
2656
2657 /*
2658 Sepia-tone image.
2659 */
2660 (void) SyncImageSettings(mogrify_info,*image,exception);
2661 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2662 1.0);
2663 mogrify_image=SepiaToneImage(*image,threshold,exception);
2664 break;
2665 }
2666 if (LocaleCompare("segment",option+1) == 0)
2667 {
2668 /*
2669 Segment image.
2670 */
2671 (void) SyncImageSettings(mogrify_info,*image,exception);
2672 flags=ParseGeometry(argv[i+1],&geometry_info);
2673 if ((flags & SigmaValue) == 0)
2674 geometry_info.sigma=1.0;
2675 (void) SegmentImage(*image,(*image)->colorspace,
2676 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2677 exception);
2678 break;
2679 }
2680 if (LocaleCompare("set",option+1) == 0)
2681 {
2682 char
2683 *value;
2684
2685 /*
2686 Set image option.
2687 */
2688 if (*option == '+')
2689 {
2690 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2691 (void) DeleteImageRegistry(argv[i+1]+9);
2692 else
2693 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2694 {
2695 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2696 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2697 }
2698 else
2699 (void) DeleteImageProperty(*image,argv[i+1]);
2700 break;
2701 }
2702 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2703 exception);
2704 if (value == (char *) NULL)
2705 break;
2706 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2707 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2708 exception);
2709 else
2710 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2711 {
2712 (void) SetImageOption(image_info,argv[i+1]+7,value);
2713 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2714 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2715 }
2716 else
2717 if (LocaleCompare(argv[i+1],"profile") == 0)
2718 {
2719 StringInfo
2720 *profile = (StringInfo *) NULL;
2721
2722 (void) CopyMagickString(image_info->filename,value,
2723 MagickPathExtent);
2724 (void) SetImageInfo(image_info,1,exception);
2725 if (LocaleCompare(image_info->filename,"-") != 0)
2726 profile=FileToStringInfo(image_info->filename,~0UL,
2727 exception);
2728 if (profile != (StringInfo *) NULL)
2729 {
2730 SetStringInfoName(profile,image_info->magick);
2731 status=SetImageProfilePrivate(*image,profile,exception);
2732 }
2733 }
2734 else
2735 (void) SetImageProperty(*image,argv[i+1],value,exception);
2736 value=DestroyString(value);
2737 break;
2738 }
2739 if (LocaleCompare("shade",option+1) == 0)
2740 {
2741 /*
2742 Shade image.
2743 */
2744 (void) SyncImageSettings(mogrify_info,*image,exception);
2745 flags=ParseGeometry(argv[i+1],&geometry_info);
2746 if ((flags & SigmaValue) == 0)
2747 geometry_info.sigma=1.0;
2748 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2749 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2750 break;
2751 }
2752 if (LocaleCompare("shadow",option+1) == 0)
2753 {
2754 /*
2755 Shadow image.
2756 */
2757 (void) SyncImageSettings(mogrify_info,*image,exception);
2758 flags=ParseGeometry(argv[i+1],&geometry_info);
2759 if ((flags & SigmaValue) == 0)
2760 geometry_info.sigma=1.0;
2761 if ((flags & XiValue) == 0)
2762 geometry_info.xi=4.0;
2763 if ((flags & PsiValue) == 0)
2764 geometry_info.psi=4.0;
2765 mogrify_image=ShadowImage(*image,geometry_info.rho,
2766 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2767 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2768 break;
2769 }
2770 if (LocaleCompare("sharpen",option+1) == 0)
2771 {
2772 /*
2773 Sharpen image.
2774 */
2775 (void) SyncImageSettings(mogrify_info,*image,exception);
2776 flags=ParseGeometry(argv[i+1],&geometry_info);
2777 if ((flags & SigmaValue) == 0)
2778 geometry_info.sigma=1.0;
2779 if ((flags & XiValue) == 0)
2780 geometry_info.xi=0.0;
2781 mogrify_image=SharpenImage(*image,geometry_info.rho,
2782 geometry_info.sigma,exception);
2783 break;
2784 }
2785 if (LocaleCompare("shave",option+1) == 0)
2786 {
2787 /*
2788 Shave the image edges.
2789 */
2790 (void) SyncImageSettings(mogrify_info,*image,exception);
2791 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2792 mogrify_image=ShaveImage(*image,&geometry,exception);
2793 break;
2794 }
2795 if (LocaleCompare("shear",option+1) == 0)
2796 {
2797 /*
2798 Shear image.
2799 */
2800 (void) SyncImageSettings(mogrify_info,*image,exception);
2801 flags=ParseGeometry(argv[i+1],&geometry_info);
2802 if ((flags & SigmaValue) == 0)
2803 geometry_info.sigma=geometry_info.rho;
2804 mogrify_image=ShearImage(*image,geometry_info.rho,
2805 geometry_info.sigma,exception);
2806 break;
2807 }
2808 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2809 {
2810 /*
2811 Sigmoidal non-linearity contrast control.
2812 */
2813 (void) SyncImageSettings(mogrify_info,*image,exception);
2814 flags=ParseGeometry(argv[i+1],&geometry_info);
2815 if ((flags & SigmaValue) == 0)
2816 geometry_info.sigma=(double) QuantumRange/2.0;
2817 if ((flags & PercentValue) != 0)
2818 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2819 100.0;
2820 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2821 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2822 exception);
2823 break;
2824 }
2825 if (LocaleCompare("sketch",option+1) == 0)
2826 {
2827 /*
2828 Sketch image.
2829 */
2830 (void) SyncImageSettings(mogrify_info,*image,exception);
2831 flags=ParseGeometry(argv[i+1],&geometry_info);
2832 if ((flags & SigmaValue) == 0)
2833 geometry_info.sigma=1.0;
2834 mogrify_image=SketchImage(*image,geometry_info.rho,
2835 geometry_info.sigma,geometry_info.xi,exception);
2836 break;
2837 }
2838 if (LocaleCompare("solarize",option+1) == 0)
2839 {
2840 double
2841 threshold;
2842
2843 (void) SyncImageSettings(mogrify_info,*image,exception);
2844 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2845 1.0);
2846 (void) SolarizeImage(*image,threshold,exception);
2847 break;
2848 }
2849 if (LocaleCompare("sort-pixels",option+1) == 0)
2850 {
2851 /*
2852 Sort each scanline in scending order of intensity.
2853 */
2854 (void) SyncImageSettings(mogrify_info,*image,exception);
2855 (void) SortImagePixels(*image,exception);
2856 break;
2857 }
2858 if (LocaleCompare("sparse-color",option+1) == 0)
2859 {
2860 SparseColorMethod
2861 method;
2862
2863 char
2864 *arguments;
2865
2866 /*
2867 Sparse Color Interpolated Gradient
2868 */
2869 (void) SyncImageSettings(mogrify_info,*image,exception);
2870 method=(SparseColorMethod) ParseCommandOption(
2871 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2872 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2873 exception);
2874 if (arguments == (char *) NULL)
2875 break;
2876 mogrify_image=SparseColorOption(*image,method,arguments,
2877 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2878 arguments=DestroyString(arguments);
2879 break;
2880 }
2881 if (LocaleCompare("splice",option+1) == 0)
2882 {
2883 /*
2884 Splice a solid color into the image.
2885 */
2886 (void) SyncImageSettings(mogrify_info,*image,exception);
2887 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2888 mogrify_image=SpliceImage(*image,&geometry,exception);
2889 break;
2890 }
2891 if (LocaleCompare("spread",option+1) == 0)
2892 {
2893 /*
2894 Spread an image.
2895 */
2896 (void) SyncImageSettings(mogrify_info,*image,exception);
2897 (void) ParseGeometry(argv[i+1],&geometry_info);
2898 mogrify_image=SpreadImage(*image,interpolate_method,
2899 geometry_info.rho,exception);
2900 break;
2901 }
2902 if (LocaleCompare("statistic",option+1) == 0)
2903 {
2904 StatisticType
2905 type;
2906
2907 (void) SyncImageSettings(mogrify_info,*image,exception);
2908 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2909 MagickFalse,argv[i+1]);
2910 (void) ParseGeometry(argv[i+2],&geometry_info);
2911 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2912 (size_t) geometry_info.sigma,exception);
2913 break;
2914 }
2915 if (LocaleCompare("stretch",option+1) == 0)
2916 {
2917 if (*option == '+')
2918 {
2919 draw_info->stretch=UndefinedStretch;
2920 break;
2921 }
2922 draw_info->stretch=(StretchType) ParseCommandOption(
2923 MagickStretchOptions,MagickFalse,argv[i+1]);
2924 break;
2925 }
2926 if (LocaleCompare("strip",option+1) == 0)
2927 {
2928 /*
2929 Strip image of profiles and comments.
2930 */
2931 (void) SyncImageSettings(mogrify_info,*image,exception);
2932 (void) StripImage(*image,exception);
2933 break;
2934 }
2935 if (LocaleCompare("stroke",option+1) == 0)
2936 {
2937 ExceptionInfo
2938 *sans;
2939
2940 PixelInfo
2941 color;
2942
2943 if (*option == '+')
2944 {
2945 (void) QueryColorCompliance("none",AllCompliance,
2946 &draw_info->stroke,exception);
2947 if (draw_info->stroke_pattern != (Image *) NULL)
2948 draw_info->stroke_pattern=DestroyImage(
2949 draw_info->stroke_pattern);
2950 break;
2951 }
2952 sans=AcquireExceptionInfo();
2953 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
2954 sans=DestroyExceptionInfo(sans);
2955 if (status == MagickFalse)
2956 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2957 exception);
2958 else
2959 draw_info->stroke=color;
2960 break;
2961 }
2962 if (LocaleCompare("strokewidth",option+1) == 0)
2963 {
2964 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2965 break;
2966 }
2967 if (LocaleCompare("style",option+1) == 0)
2968 {
2969 if (*option == '+')
2970 {
2971 draw_info->style=UndefinedStyle;
2972 break;
2973 }
2974 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2975 MagickFalse,argv[i+1]);
2976 break;
2977 }
2978 if (LocaleCompare("swirl",option+1) == 0)
2979 {
2980 /*
2981 Swirl image.
2982 */
2983 (void) SyncImageSettings(mogrify_info,*image,exception);
2984 (void) ParseGeometry(argv[i+1],&geometry_info);
2985 mogrify_image=SwirlImage(*image,geometry_info.rho,
2986 interpolate_method,exception);
2987 break;
2988 }
2989 break;
2990 }
2991 case 't':
2992 {
2993 if (LocaleCompare("threshold",option+1) == 0)
2994 {
2995 double
2996 threshold;
2997
2998 /*
2999 Threshold image.
3000 */
3001 (void) SyncImageSettings(mogrify_info,*image,exception);
3002 if (*option == '+')
3003 threshold=(double) QuantumRange/2;
3004 else
3005 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3006 1.0);
3007 (void) BilevelImage(*image,threshold,exception);
3008 break;
3009 }
3010 if (LocaleCompare("thumbnail",option+1) == 0)
3011 {
3012 /*
3013 Thumbnail image.
3014 */
3015 (void) SyncImageSettings(mogrify_info,*image,exception);
3016 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3017 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3018 exception);
3019 break;
3020 }
3021 if (LocaleCompare("tile",option+1) == 0)
3022 {
3023 if (*option == '+')
3024 {
3025 if (draw_info->fill_pattern != (Image *) NULL)
3026 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3027 break;
3028 }
3029 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3030 exception);
3031 break;
3032 }
3033 if (LocaleCompare("tint",option+1) == 0)
3034 {
3035 /*
3036 Tint the image.
3037 */
3038 (void) SyncImageSettings(mogrify_info,*image,exception);
3039 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3040 break;
3041 }
3042 if (LocaleCompare("transform",option+1) == 0)
3043 {
3044 /*
3045 Affine transform image.
3046 */
3047 (void) SyncImageSettings(mogrify_info,*image,exception);
3048 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3049 exception);
3050 break;
3051 }
3052 if (LocaleCompare("transparent",option+1) == 0)
3053 {
3054 PixelInfo
3055 target;
3056
3057 (void) SyncImageSettings(mogrify_info,*image,exception);
3058 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3059 exception);
3060 (void) TransparentPaintImage(*image,&target,(Quantum)
3061 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3062 exception);
3063 break;
3064 }
3065 if (LocaleCompare("transpose",option+1) == 0)
3066 {
3067 /*
3068 Transpose image scanlines.
3069 */
3070 (void) SyncImageSettings(mogrify_info,*image,exception);
3071 mogrify_image=TransposeImage(*image,exception);
3072 break;
3073 }
3074 if (LocaleCompare("transverse",option+1) == 0)
3075 {
3076 /*
3077 Transverse image scanlines.
3078 */
3079 (void) SyncImageSettings(mogrify_info,*image,exception);
3080 mogrify_image=TransverseImage(*image,exception);
3081 break;
3082 }
3083 if (LocaleCompare("treedepth",option+1) == 0)
3084 {
3085 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3086 break;
3087 }
3088 if (LocaleCompare("trim",option+1) == 0)
3089 {
3090 /*
3091 Trim image.
3092 */
3093 (void) SyncImageSettings(mogrify_info,*image,exception);
3094 mogrify_image=TrimImage(*image,exception);
3095 break;
3096 }
3097 if (LocaleCompare("type",option+1) == 0)
3098 {
3099 ImageType
3100 type;
3101
3102 (void) SyncImageSettings(mogrify_info,*image,exception);
3103 if (*option == '+')
3104 type=UndefinedType;
3105 else
3106 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3107 argv[i+1]);
3108 (*image)->type=UndefinedType;
3109 (void) SetImageType(*image,type,exception);
3110 break;
3111 }
3112 break;
3113 }
3114 case 'u':
3115 {
3116 if (LocaleCompare("undercolor",option+1) == 0)
3117 {
3118 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3119 &draw_info->undercolor,exception);
3120 break;
3121 }
3122 if (LocaleCompare("unique",option+1) == 0)
3123 {
3124 if (*option == '+')
3125 {
3126 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3127 break;
3128 }
3129 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3130 (void) SetImageArtifact(*image,"verbose","true");
3131 break;
3132 }
3133 if (LocaleCompare("unique-colors",option+1) == 0)
3134 {
3135 /*
3136 Unique image colors.
3137 */
3138 (void) SyncImageSettings(mogrify_info,*image,exception);
3139 mogrify_image=UniqueImageColors(*image,exception);
3140 break;
3141 }
3142 if (LocaleCompare("unsharp",option+1) == 0)
3143 {
3144 /*
3145 Unsharp mask image.
3146 */
3147 (void) SyncImageSettings(mogrify_info,*image,exception);
3148 flags=ParseGeometry(argv[i+1],&geometry_info);
3149 if ((flags & SigmaValue) == 0)
3150 geometry_info.sigma=1.0;
3151 if ((flags & XiValue) == 0)
3152 geometry_info.xi=1.0;
3153 if ((flags & PsiValue) == 0)
3154 geometry_info.psi=0.05;
3155 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3156 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3157 exception);
3158 break;
3159 }
3160 break;
3161 }
3162 case 'v':
3163 {
3164 if (LocaleCompare("verbose",option+1) == 0)
3165 {
3166 (void) SetImageArtifact(*image,option+1,
3167 *option == '+' ? "false" : "true");
3168 break;
3169 }
3170 if (LocaleCompare("vignette",option+1) == 0)
3171 {
3172 /*
3173 Vignette image.
3174 */
3175 (void) SyncImageSettings(mogrify_info,*image,exception);
3176 flags=ParseGeometry(argv[i+1],&geometry_info);
3177 if ((flags & SigmaValue) == 0)
3178 geometry_info.sigma=1.0;
3179 if ((flags & XiValue) == 0)
3180 geometry_info.xi=0.1*(*image)->columns;
3181 if ((flags & PsiValue) == 0)
3182 geometry_info.psi=0.1*(*image)->rows;
3183 if ((flags & PercentValue) != 0)
3184 {
3185 geometry_info.xi*=(double) (*image)->columns/100.0;
3186 geometry_info.psi*=(double) (*image)->rows/100.0;
3187 }
3188 mogrify_image=VignetteImage(*image,geometry_info.rho,
3189 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3190 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3191 break;
3192 }
3193 if (LocaleCompare("virtual-pixel",option+1) == 0)
3194 {
3195 if (*option == '+')
3196 {
3197 (void) SetImageVirtualPixelMethod(*image,
3198 UndefinedVirtualPixelMethod,exception);
3199 break;
3200 }
3201 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3202 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3203 argv[i+1]),exception);
3204 break;
3205 }
3206 break;
3207 }
3208 case 'w':
3209 {
3210 if (LocaleCompare("wave",option+1) == 0)
3211 {
3212 /*
3213 Wave image.
3214 */
3215 (void) SyncImageSettings(mogrify_info,*image,exception);
3216 flags=ParseGeometry(argv[i+1],&geometry_info);
3217 if ((flags & SigmaValue) == 0)
3218 geometry_info.sigma=1.0;
3219 mogrify_image=WaveImage(*image,geometry_info.rho,
3220 geometry_info.sigma,interpolate_method,exception);
3221 break;
3222 }
3223 if (LocaleCompare("wavelet-denoise",option+1) == 0)
3224 {
3225 /*
3226 Wavelet denoise image.
3227 */
3228 (void) SyncImageSettings(mogrify_info,*image,exception);
3229 flags=ParseGeometry(argv[i+1],&geometry_info);
3230 if ((flags & PercentValue) != 0)
3231 {
3232 geometry_info.rho=(double) QuantumRange*geometry_info.rho/100.0;
3233 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
3234 100.0;
3235 }
3236 if ((flags & SigmaValue) == 0)
3237 geometry_info.sigma=0.0;
3238 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3239 geometry_info.sigma,exception);
3240 break;
3241 }
3242 if (LocaleCompare("weight",option+1) == 0)
3243 {
3244 ssize_t
3245 weight;
3246
3247 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3248 argv[i+1]);
3249 if (weight == -1)
3250 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3251 draw_info->weight=(size_t) weight;
3252 break;
3253 }
3254 if (LocaleCompare("white-balance",option+1) == 0)
3255 {
3256 /*
3257 White balance image.
3258 */
3259 (void) SyncImageSettings(mogrify_info,*image,exception);
3260 (void) WhiteBalanceImage(*image,exception);
3261 break;
3262 }
3263 if (LocaleCompare("white-threshold",option+1) == 0)
3264 {
3265 /*
3266 White threshold image.
3267 */
3268 (void) SyncImageSettings(mogrify_info,*image,exception);
3269 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3270 break;
3271 }
3272 if (LocaleCompare("write-mask",option+1) == 0)
3273 {
3274 Image
3275 *mask;
3276
3277 (void) SyncImageSettings(mogrify_info,*image,exception);
3278 if (*option == '+')
3279 {
3280 /*
3281 Remove a mask.
3282 */
3283 (void) SetImageMask(*image,WritePixelMask,(const Image *) NULL,
3284 exception);
3285 break;
3286 }
3287 /*
3288 Set the image mask.
3289 */
3290 mask=GetImageCache(mogrify_info,argv[i+1],exception);
3291 if (mask == (Image *) NULL)
3292 break;
3293 (void) SetImageMask(*image,WritePixelMask,mask,exception);
3294 mask=DestroyImage(mask);
3295 break;
3296 }
3297 if (LocaleCompare("word-break",option+1) == 0)
3298 {
3299 (void) SetImageOption(image_info,option+1,argv[i+1]);
3300 break;
3301 }
3302 break;
3303 }
3304 default:
3305 break;
3306 }
3307 /*
3308 Replace current image with any image that was generated
3309 */
3310 if (mogrify_image != (Image *) NULL)
3311 ReplaceImageInListReturnLast(image,mogrify_image);
3312 i+=count;
3313 }
3314 /*
3315 Free resources.
3316 */
3317 quantize_info=DestroyQuantizeInfo(quantize_info);
3318 draw_info=DestroyDrawInfo(draw_info);
3319 mogrify_info=DestroyImageInfo(mogrify_info);
3320 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3321 return(status == 0 ? MagickFalse : MagickTrue);
3322}
3323␌
3324/*
3325%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3326% %
3327% %
3328% %
3329+ M o g r i f y I m a g e C o m m a n d %
3330% %
3331% %
3332% %
3333%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3334%
3335% MogrifyImageCommand() transforms an image or a sequence of images. These
3336% transforms include image scaling, image rotation, color reduction, and
3337% others. The transmogrified image overwrites the original image.
3338%
3339% The format of the MogrifyImageCommand method is:
3340%
3341% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3342% const char **argv,char **metadata,ExceptionInfo *exception)
3343%
3344% A description of each parameter follows:
3345%
3346% o image_info: the image info.
3347%
3348% o argc: the number of elements in the argument vector.
3349%
3350% o argv: A text array containing the command line arguments.
3351%
3352% o metadata: any metadata is returned here.
3353%
3354% o exception: return any errors or warnings in this structure.
3355%
3356*/
3357
3358static MagickBooleanType MogrifyUsage(void)
3359{
3360 static const char
3361 channel_operators[] =
3362 " -channel-fx expression\n"
3363 " exchange, extract, or transfer one or more image channels\n"
3364 " -separate separate an image channel into a grayscale image",
3365 miscellaneous[] =
3366 " -debug events display copious debugging information\n"
3367 " -distribute-cache port\n"
3368 " distributed pixel cache spanning one or more servers\n"
3369 " -help print program options\n"
3370 " -list type print a list of supported option arguments\n"
3371 " -log format format of debugging information\n"
3372 " -version print version information",
3373 operators[] =
3374 " -adaptive-blur geometry\n"
3375 " adaptively blur pixels; decrease effect near edges\n"
3376 " -adaptive-resize geometry\n"
3377 " adaptively resize image using 'mesh' interpolation\n"
3378 " -adaptive-sharpen geometry\n"
3379 " adaptively sharpen pixels; increase effect near edges\n"
3380 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
3381 " transparent, extract, background, or shape\n"
3382 " -annotate geometry text\n"
3383 " annotate the image with text\n"
3384 " -auto-gamma automagically adjust gamma level of image\n"
3385 " -auto-level automagically adjust color levels of image\n"
3386 " -auto-orient automagically orient (rotate) image\n"
3387 " -auto-threshold method\n"
3388 " automatically perform image thresholding\n"
3389 " -bench iterations measure performance\n"
3390 " -bilateral-blur geometry\n"
3391 " non-linear, edge-preserving, and noise-reducing smoothing filter\n"
3392 " -black-threshold value\n"
3393 " force all pixels below the threshold into black\n"
3394 " -blue-shift simulate a scene at nighttime in the moonlight\n"
3395 " -blur geometry reduce image noise and reduce detail levels\n"
3396 " -border geometry surround image with a border of color\n"
3397 " -bordercolor color border color\n"
3398 " -brightness-contrast geometry\n"
3399 " improve brightness / contrast of the image\n"
3400 " -canny geometry detect edges in the image\n"
3401 " -cdl filename color correct with a color decision list\n"
3402 " -channel mask set the image channel mask\n"
3403 " -charcoal geometry simulate a charcoal drawing\n"
3404 " -chop geometry remove pixels from the image interior\n"
3405 " -clahe geometry contrast limited adaptive histogram equalization\n"
3406 " -clamp keep pixel values in range (0-QuantumRange)\n"
3407 " -clip clip along the first path from the 8BIM profile\n"
3408 " -clip-mask filename associate a clip mask with the image\n"
3409 " -clip-path id clip along a named path from the 8BIM profile\n"
3410 " -colorize value colorize the image with the fill color\n"
3411 " -color-matrix matrix apply color correction to the image\n"
3412 " -colors value preferred number of colors in the image\n"
3413 " -color-threshold start_color-stop_color\n"
3414 " force all pixels in the color range to white otherwise black\n"
3415 " -connected-components connectivity\n"
3416 " connected-components uniquely labeled\n"
3417 " -contrast enhance or reduce the image contrast\n"
3418 " -contrast-stretch geometry\n"
3419 " improve contrast by 'stretching' the intensity range\n"
3420 " -convolve coefficients\n"
3421 " apply a convolution kernel to the image\n"
3422 " -cycle amount cycle the image colormap\n"
3423 " -decipher filename convert cipher pixels to plain pixels\n"
3424 " -deskew threshold straighten an image\n"
3425 " -despeckle reduce the speckles within an image\n"
3426 " -distort method args\n"
3427 " distort images according to given method ad args\n"
3428 " -draw string annotate the image with a graphic primitive\n"
3429 " -edge radius apply a filter to detect edges in the image\n"
3430 " -encipher filename convert plain pixels to cipher pixels\n"
3431 " -emboss radius emboss an image\n"
3432 " -enhance apply a digital filter to enhance a noisy image\n"
3433 " -equalize perform histogram equalization to an image\n"
3434 " -evaluate operator value\n"
3435 " evaluate an arithmetic, relational, or logical expression\n"
3436 " -extent geometry set the image size\n"
3437 " -extract geometry extract area from image\n"
3438 " -fft implements the discrete Fourier transform (DFT)\n"
3439 " -flip flip image vertically\n"
3440 " -floodfill geometry color\n"
3441 " floodfill the image with color\n"
3442 " -flop flop image horizontally\n"
3443 " -frame geometry surround image with an ornamental border\n"
3444 " -function name parameters\n"
3445 " apply function over image values\n"
3446 " -gamma value level of gamma correction\n"
3447 " -gaussian-blur geometry\n"
3448 " reduce image noise and reduce detail levels\n"
3449 " -geometry geometry preferred size or location of the image\n"
3450 " -grayscale method convert image to grayscale\n"
3451 " -hough-lines geometry\n"
3452 " identify lines in the image\n"
3453 " -identify identify the format and characteristics of the image\n"
3454 " -ift implements the inverse discrete Fourier transform (DFT)\n"
3455 " -implode amount implode image pixels about the center\n"
3456 " -integral calculate the sum of values (pixel values) in the image\n"
3457 " -interpolative-resize geometry\n"
3458 " resize image using interpolation\n"
3459 " -kmeans geometry K means color reduction\n"
3460 " -kuwahara geometry edge preserving noise reduction filter\n"
3461 " -lat geometry local adaptive thresholding\n"
3462 " -level value adjust the level of image contrast\n"
3463 " -level-colors color,color\n"
3464 " level image with the given colors\n"
3465 " -linear-stretch geometry\n"
3466 " improve contrast by 'stretching with saturation'\n"
3467 " -liquid-rescale geometry\n"
3468 " rescale image with seam-carving\n"
3469 " -local-contrast geometry\n"
3470 " enhance local contrast\n"
3471 " -magnify double the size of the image with pixel art scaling\n"
3472 " -mean-shift geometry delineate arbitrarily shaped clusters in the image\n"
3473 " -median geometry apply a median filter to the image\n"
3474 " -mode geometry make each pixel the 'predominant color' of the\n"
3475 " neighborhood\n"
3476 " -modulate value vary the brightness, saturation, and hue\n"
3477 " -monochrome transform image to black and white\n"
3478 " -morphology method kernel\n"
3479 " apply a morphology method to the image\n"
3480 " -motion-blur geometry\n"
3481 " simulate motion blur\n"
3482 " -negate replace every pixel with its complementary color \n"
3483 " -noise geometry add or reduce noise in an image\n"
3484 " -normalize transform image to span the full range of colors\n"
3485 " -opaque color change this color to the fill color\n"
3486 " -ordered-dither NxN\n"
3487 " add a noise pattern to the image with specific\n"
3488 " amplitudes\n"
3489 " -paint radius simulate an oil painting\n"
3490 " -perceptible epsilon\n"
3491 " pixel value less than |epsilon| become epsilon or\n"
3492 " -epsilon\n"
3493 " -polaroid angle simulate a Polaroid picture\n"
3494 " -posterize levels reduce the image to a limited number of color levels\n"
3495 " -profile filename add, delete, or apply an image profile\n"
3496 " -quantize colorspace reduce colors in this colorspace\n"
3497 " -raise value lighten/darken image edges to create a 3-D effect\n"
3498 " -random-threshold low,high\n"
3499 " random threshold the image\n"
3500 " -range-threshold values\n"
3501 " perform either hard or soft thresholding within some range of values in an image\n"
3502 " -region geometry apply options to a portion of the image\n"
3503 " -render render vector graphics\n"
3504 " -repage geometry size and location of an image canvas\n"
3505 " -resample geometry change the resolution of an image\n"
3506 " -reshape geometry reshape the image\n"
3507 " -resize geometry resize the image\n"
3508 " -roll geometry roll an image vertically or horizontally\n"
3509 " -rotate degrees apply Paeth rotation to the image\n"
3510 " -rotational-blur angle\n"
3511 " rotational blur the image\n"
3512 " -sample geometry scale image with pixel sampling\n"
3513 " -scale geometry scale the image\n"
3514 " -segment values segment an image\n"
3515 " -selective-blur geometry\n"
3516 " selectively blur pixels within a contrast threshold\n"
3517 " -sepia-tone threshold\n"
3518 " simulate a sepia-toned photo\n"
3519 " -set property value set an image property\n"
3520 " -shade degrees shade the image using a distant light source\n"
3521 " -shadow geometry simulate an image shadow\n"
3522 " -sharpen geometry sharpen the image\n"
3523 " -shave geometry shave pixels from the image edges\n"
3524 " -shear geometry slide one edge of the image along the X or Y axis\n"
3525 " -sigmoidal-contrast geometry\n"
3526 " increase the contrast without saturating highlights or\n"
3527 " shadows\n"
3528 " -sketch geometry simulate a pencil sketch\n"
3529 " -solarize threshold negate all pixels above the threshold level\n"
3530 " -sort-pixels sort each scanline in ascending order of intensity\n"
3531 " -sparse-color method args\n"
3532 " fill in a image based on a few color points\n"
3533 " -splice geometry splice the background color into the image\n"
3534 " -spread radius displace image pixels by a random amount\n"
3535 " -statistic type radius\n"
3536 " replace each pixel with corresponding statistic from the neighborhood\n"
3537 " -strip strip image of all profiles and comments\n"
3538 " -swirl degrees swirl image pixels about the center\n"
3539 " -threshold value threshold the image\n"
3540 " -thumbnail geometry create a thumbnail of the image\n"
3541 " -tile filename tile image when filling a graphic primitive\n"
3542 " -tint value tint the image with the fill color\n"
3543 " -transform affine transform image\n"
3544 " -transparent color make this color transparent within the image\n"
3545 " -transpose flip image vertically and rotate 90 degrees\n"
3546 " -transverse flop image horizontally and rotate 270 degrees\n"
3547 " -trim trim image edges\n"
3548 " -type type image type\n"
3549 " -unique-colors discard all but one of any pixel color\n"
3550 " -unsharp geometry sharpen the image\n"
3551 " -vignette geometry soften the edges of the image in vignette style\n"
3552 " -wave geometry alter an image along a sine wave\n"
3553 " -wavelet-denoise threshold\n"
3554 " removes noise from the image using a wavelet transform\n"
3555 " -white-balance automagically adjust white balance of image\n"
3556 " -white-threshold value\n"
3557 " force all pixels above the threshold into white",
3558 sequence_operators[] =
3559 " -affinity filename transform image colors to match this set of colors\n"
3560 " -append append an image sequence\n"
3561 " -clut apply a color lookup table to the image\n"
3562 " -coalesce merge a sequence of images\n"
3563 " -combine combine a sequence of images\n"
3564 " -compare mathematically and visually annotate the difference between an image and its reconstruction\n"
3565 " -complex operator perform complex mathematics on an image sequence\n"
3566 " -composite composite image\n"
3567 " -copy geometry offset\n"
3568 " copy pixels from one area of an image to another\n"
3569 " -crop geometry cut out a rectangular region of the image\n"
3570 " -deconstruct break down an image sequence into constituent parts\n"
3571 " -evaluate-sequence operator\n"
3572 " evaluate an arithmetic, relational, or logical expression\n"
3573 " -flatten flatten a sequence of images\n"
3574 " -fx expression apply mathematical expression to an image channel(s)\n"
3575 " -hald-clut apply a Hald color lookup table to the image\n"
3576 " -layers method optimize, merge, or compare image layers\n"
3577 " -morph value morph an image sequence\n"
3578 " -mosaic create a mosaic from an image sequence\n"
3579 " -poly terms build a polynomial from the image sequence and the corresponding\n"
3580 " terms (coefficients and degree pairs).\n"
3581 " -print string interpret string and print to console\n"
3582 " -process arguments process the image with a custom image filter\n"
3583 " -smush geometry smush an image sequence together\n"
3584 " -write filename write images to this file",
3585 settings[] =
3586 " -adjoin join images into a single multi-image file\n"
3587 " -affine matrix affine transform matrix\n"
3588 " -alpha option activate, deactivate, reset, or set the alpha channel\n"
3589 " -antialias remove pixel-aliasing\n"
3590 " -authenticate password\n"
3591 " decipher image with this password\n"
3592 " -attenuate value lessen (or intensify) when adding noise to an image\n"
3593 " -background color background color\n"
3594 " -bias value add bias when convolving an image\n"
3595 " -black-point-compensation\n"
3596 " use black point compensation\n"
3597 " -blue-primary point chromaticity blue primary point\n"
3598 " -bordercolor color border color\n"
3599 " -caption string assign a caption to an image\n"
3600 " -colorspace type alternate image colorspace\n"
3601 " -comment string annotate image with comment\n"
3602 " -compose operator set image composite operator\n"
3603 " -compress type type of pixel compression when writing the image\n"
3604 " -define format:option=value\n"
3605 " define one or more image format options\n"
3606 " -delay value display the next image after pausing\n"
3607 " -density geometry horizontal and vertical density of the image\n"
3608 " -depth value image depth\n"
3609 " -direction type render text right-to-left or left-to-right\n"
3610 " -display server get image or font from this X server\n"
3611 " -dispose method layer disposal method\n"
3612 " -dither method apply error diffusion to image\n"
3613 " -encoding type text encoding type\n"
3614 " -endian type endianness (MSB or LSB) of the image\n"
3615 " -family name render text with this font family\n"
3616 " -features distance analyze image features (e.g. contrast, correlation)\n"
3617 " -fill color color to use when filling a graphic primitive\n"
3618 " -filter type use this filter when resizing an image\n"
3619 " -font name render text with this font\n"
3620 " -format \"string\" output formatted image characteristics\n"
3621 " -fuzz distance colors within this distance are considered equal\n"
3622 " -gravity type horizontal and vertical text placement\n"
3623 " -green-primary point chromaticity green primary point\n"
3624 " -illuminant type reference illuminant\n"
3625 " -intensity method method to generate an intensity value from a pixel\n"
3626 " -intent type type of rendering intent when managing the image color\n"
3627 " -interlace type type of image interlacing scheme\n"
3628 " -interline-spacing value\n"
3629 " set the space between two text lines\n"
3630 " -interpolate method pixel color interpolation method\n"
3631 " -interword-spacing value\n"
3632 " set the space between two words\n"
3633 " -kerning value set the space between two letters\n"
3634 " -label string assign a label to an image\n"
3635 " -limit type value pixel cache resource limit\n"
3636 " -loop iterations add Netscape loop extension to your GIF animation\n"
3637 " -matte store matte channel if the image has one\n"
3638 " -mattecolor color frame color\n"
3639 " -monitor monitor progress\n"
3640 " -orient type image orientation\n"
3641 " -page geometry size and location of an image canvas (setting)\n"
3642 " -path path write images to this path on disk\n"
3643 " -ping efficiently determine image attributes\n"
3644 " -pointsize value font point size\n"
3645 " -precision value maximum number of significant digits to print\n"
3646 " -preview type image preview type\n"
3647 " -quality value JPEG/MIFF/PNG compression level\n"
3648 " -quiet suppress all warning messages\n"
3649 " -read-mask filename associate a read mask with the image\n"
3650 " -red-primary point chromaticity red primary point\n"
3651 " -regard-warnings pay attention to warning messages\n"
3652 " -remap filename transform image colors to match this set of colors\n"
3653 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
3654 " -sampling-factor geometry\n"
3655 " horizontal and vertical sampling factor\n"
3656 " -scene value image scene number\n"
3657 " -seed value seed a new sequence of pseudo-random numbers\n"
3658 " -size geometry width and height of image\n"
3659 " -stretch type render text with this font stretch\n"
3660 " -stroke color graphic primitive stroke color\n"
3661 " -strokewidth value graphic primitive stroke width\n"
3662 " -style type render text with this font style\n"
3663 " -synchronize synchronize image to storage device\n"
3664 " -taint declare the image as modified\n"
3665 " -texture filename name of texture to tile onto the image background\n"
3666 " -tile-offset geometry\n"
3667 " tile offset\n"
3668 " -treedepth value color tree depth\n"
3669 " -transparent-color color\n"
3670 " transparent color\n"
3671 " -undercolor color annotation bounding box color\n"
3672 " -units type the units of image resolution\n"
3673 " -verbose print detailed information about the image\n"
3674 " -view FlashPix viewing transforms\n"
3675 " -virtual-pixel method\n"
3676 " virtual pixel access method\n"
3677 " -weight type render text with this font weight\n"
3678 " -white-point point chromaticity white point\n"
3679 " -word-break type sets whether line breaks appear wherever the text would otherwise overflow"
3680 " -write-mask filename associate a write mask with the image",
3681 stack_operators[] =
3682 " -delete indexes delete the image from the image sequence\n"
3683 " -duplicate count,indexes\n"
3684 " duplicate an image one or more times\n"
3685 " -insert index insert last image into the image sequence\n"
3686 " -reverse reverse image sequence\n"
3687 " -swap indexes swap two images in the image sequence";
3688
3689 ListMagickVersion(stdout);
3690 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3691 GetClientName());
3692 (void) fprintf(stdout,"\nImage Settings:\n");
3693 (void) fputs(settings,stdout);
3694 (void) fprintf(stdout,"\nImage Operators:\n");
3695 (void) fputs(operators,stdout);
3696 (void) fprintf(stdout,"\nImage Channel Operators:\n");
3697 (void) fputs(channel_operators,stdout);
3698 (void) fprintf(stdout,"\nImage Sequence Operators:\n");
3699 (void) fputs(sequence_operators,stdout);
3700 (void) fprintf(stdout,"\nImage Stack Operators:\n");
3701 (void) fputs(stack_operators,stdout);
3702 (void) fprintf(stdout,"\nMiscellaneous Options:\n");
3703 (void) fputs(miscellaneous,stdout);
3704 (void) fprintf(stdout,
3705 "\nBy default, the image format of 'file' is determined by its magic\n");
3706 (void) fprintf(stdout,
3707 "number. To specify a particular image format, precede the filename\n");
3708 (void) fprintf(stdout,
3709 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3710 (void) fprintf(stdout,
3711 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3712 (void) fprintf(stdout,"'-' for standard input or output.\n");
3713 return(MagickTrue);
3714}
3715
3716WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3717 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3718{
3719#define DestroyMogrify() \
3720{ \
3721 if (format != (char *) NULL) \
3722 format=DestroyString(format); \
3723 if (path != (char *) NULL) \
3724 path=DestroyString(path); \
3725 DestroyImageStack(); \
3726 for (i=0; i < (ssize_t) argc; i++) \
3727 argv[i]=DestroyString(argv[i]); \
3728 argv=(char **) RelinquishMagickMemory(argv); \
3729}
3730#define ThrowMogrifyException(asperity,tag,option) \
3731{ \
3732 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3733 option); \
3734 DestroyMogrify(); \
3735 return(MagickFalse); \
3736}
3737#define ThrowMogrifyInvalidArgumentException(option,argument) \
3738{ \
3739 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3740 "InvalidArgument","'%s': %s",argument,option); \
3741 DestroyMogrify(); \
3742 return(MagickFalse); \
3743}
3744
3745 char
3746 *format,
3747 *option,
3748 *path;
3749
3750 Image
3751 *image;
3752
3754 image_stack[MaxImageStackDepth+1];
3755
3756 MagickBooleanType
3757 global_colormap;
3758
3759 MagickBooleanType
3760 fire,
3761 pend,
3762 respect_parentheses;
3763
3764 MagickStatusType
3765 status;
3766
3767 ssize_t
3768 i;
3769
3770 ssize_t
3771 j,
3772 k;
3773
3774 wand_unreferenced(metadata);
3775
3776 /*
3777 Set defaults.
3778 */
3779 assert(image_info != (ImageInfo *) NULL);
3780 assert(image_info->signature == MagickCoreSignature);
3781 if (IsEventLogging() != MagickFalse)
3782 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3783 assert(exception != (ExceptionInfo *) NULL);
3784 if (argc == 2)
3785 {
3786 option=argv[1];
3787 if ((LocaleCompare("version",option+1) == 0) ||
3788 (LocaleCompare("-version",option+1) == 0))
3789 {
3790 ListMagickVersion(stdout);
3791 return(MagickTrue);
3792 }
3793 }
3794 if (argc < 2)
3795 {
3796 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3797 "MissingArgument","%s","");
3798 (void) MogrifyUsage();
3799 return(MagickFalse);
3800 }
3801 format=(char *) NULL;
3802 path=(char *) NULL;
3803 global_colormap=MagickFalse;
3804 k=0;
3805 j=1;
3806 NewImageStack();
3807 option=(char *) NULL;
3808 pend=MagickFalse;
3809 respect_parentheses=MagickFalse;
3810 status=MagickTrue;
3811 /*
3812 Parse command line.
3813 */
3814 ReadCommandlLine(argc,&argv);
3815 status=ExpandFilenames(&argc,&argv);
3816 if (status == MagickFalse)
3817 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3818 GetExceptionMessage(errno));
3819 for (i=1; i < (ssize_t) argc; i++)
3820 {
3821 option=argv[i];
3822 if (LocaleCompare(option,"(") == 0)
3823 {
3824 FireImageStack(MagickFalse,MagickTrue,pend);
3825 if (k == MaxImageStackDepth)
3826 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3827 option);
3828 PushImageStack();
3829 continue;
3830 }
3831 if (LocaleCompare(option,")") == 0)
3832 {
3833 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3834 if (k == 0)
3835 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3836 PopImageStack();
3837 continue;
3838 }
3839 if (IsCommandOption(option) == MagickFalse)
3840 {
3841 char
3842 backup_filename[MagickPathExtent],
3843 *filename,
3844 magic[MagickPathExtent];
3845
3846 Image
3847 *images;
3848
3849 struct stat
3850 properties;
3851
3852 /*
3853 Option is a file name: begin by reading image from specified file.
3854 */
3855 FireImageStack(MagickFalse,MagickFalse,pend);
3856 filename=argv[i];
3857 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3858 filename=argv[++i];
3859 images=ReadImages(image_info,filename,exception);
3860 status&=(MagickStatusType) (images != (Image *) NULL) &&
3861 (exception->severity < ErrorException);
3862 if (images == (Image *) NULL)
3863 continue;
3864 properties=(*GetBlobProperties(images));
3865 if (format != (char *) NULL)
3866 GetPathComponent(images->magick_filename,
3867 BasePathSansCompressExtension,images->filename);
3868 if (path != (char *) NULL)
3869 {
3870 GetPathComponent(option,TailPath,filename);
3871 (void) FormatLocaleString(images->filename,MagickPathExtent,
3872 "%s%c%s",path,*DirectorySeparator,filename);
3873 }
3874 if (format != (char *) NULL)
3875 AppendImageFormat(format,images->filename);
3876 AppendImageStack(images);
3877 FinalizeImageSettings(image_info,image,MagickFalse);
3878 if (image == (Image *) NULL)
3879 continue;
3880 if (global_colormap != MagickFalse)
3881 {
3882 QuantizeInfo
3883 *quantize_info;
3884
3885 quantize_info=AcquireQuantizeInfo(image_info);
3886 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3887 quantize_info=DestroyQuantizeInfo(quantize_info);
3888 }
3889 *backup_filename='\0';
3890 *magic='\0';
3891 GetPathComponent(filename,MagickPath,magic);
3892 if (*magic != '\0')
3893 {
3894 char
3895 name[MagickPathExtent];
3896
3897 if (format != (char *) NULL)
3898 (void) CopyMagickString(magic,format,MagickPathExtent);
3899 (void) FormatLocaleString(name,MagickPathExtent,"%s:%s",magic,
3900 image->filename);
3901 (void) CopyMagickString(image->filename,name,MagickPathExtent);
3902 }
3903 if ((LocaleCompare(image->filename,"-") != 0) &&
3904 (IsPathWritable(image->filename) != MagickFalse))
3905 {
3906 /*
3907 Rename image file as backup.
3908 */
3909 (void) CopyMagickString(backup_filename,image->filename,
3910 MagickPathExtent);
3911 for (j=0; j < 6; j++)
3912 {
3913 (void) ConcatenateMagickString(backup_filename,"~",
3914 MagickPathExtent);
3915 if (IsPathAccessible(backup_filename) == MagickFalse)
3916 break;
3917 }
3918 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3919 (rename_utf8(image->filename,backup_filename) != 0))
3920 *backup_filename='\0';
3921 }
3922 /*
3923 Write transmogrified image to disk.
3924 */
3925 image_info->synchronize=MagickTrue;
3926 status&=(MagickStatusType) WriteImages(image_info,image,image->filename,
3927 exception);
3928 if (status != MagickFalse)
3929 {
3930 {
3931 MagickBooleanType
3932 preserve_timestamp;
3933
3934 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3935 "preserve-timestamp"));
3936 if (preserve_timestamp != MagickFalse)
3937 (void) set_file_timestamp(image->filename,&properties);
3938 }
3939 if (*backup_filename != '\0')
3940 (void) remove_utf8(backup_filename);
3941 }
3942 else
3943 if (*backup_filename != '\0')
3944 (void) rename_utf8(backup_filename,image->filename);
3945 RemoveAllImageStack();
3946 continue;
3947 }
3948 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3949 switch (*(option+1))
3950 {
3951 case 'a':
3952 {
3953 if (LocaleCompare("adaptive-blur",option+1) == 0)
3954 {
3955 i++;
3956 if (i == (ssize_t) argc)
3957 ThrowMogrifyException(OptionError,"MissingArgument",option);
3958 if (IsGeometry(argv[i]) == MagickFalse)
3959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3960 break;
3961 }
3962 if (LocaleCompare("adaptive-resize",option+1) == 0)
3963 {
3964 i++;
3965 if (i == (ssize_t) argc)
3966 ThrowMogrifyException(OptionError,"MissingArgument",option);
3967 if (IsGeometry(argv[i]) == MagickFalse)
3968 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3969 break;
3970 }
3971 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3972 {
3973 i++;
3974 if (i == (ssize_t) argc)
3975 ThrowMogrifyException(OptionError,"MissingArgument",option);
3976 if (IsGeometry(argv[i]) == MagickFalse)
3977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3978 break;
3979 }
3980 if (LocaleCompare("affine",option+1) == 0)
3981 {
3982 if (*option == '+')
3983 break;
3984 i++;
3985 if (i == (ssize_t) argc)
3986 ThrowMogrifyException(OptionError,"MissingArgument",option);
3987 break;
3988 }
3989 if (LocaleCompare("alpha",option+1) == 0)
3990 {
3991 ssize_t
3992 type;
3993
3994 if (*option == '+')
3995 break;
3996 i++;
3997 if (i == (ssize_t) argc)
3998 ThrowMogrifyException(OptionError,"MissingArgument",option);
3999 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4000 argv[i]);
4001 if (type < 0)
4002 ThrowMogrifyException(OptionError,
4003 "UnrecognizedAlphaChannelOption",argv[i]);
4004 break;
4005 }
4006 if (LocaleCompare("annotate",option+1) == 0)
4007 {
4008 if (*option == '+')
4009 break;
4010 i++;
4011 if (i == (ssize_t) argc)
4012 ThrowMogrifyException(OptionError,"MissingArgument",option);
4013 if (IsGeometry(argv[i]) == MagickFalse)
4014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4015 if (i == (ssize_t) argc)
4016 ThrowMogrifyException(OptionError,"MissingArgument",option);
4017 i++;
4018 break;
4019 }
4020 if (LocaleCompare("antialias",option+1) == 0)
4021 break;
4022 if (LocaleCompare("append",option+1) == 0)
4023 break;
4024 if (LocaleCompare("attenuate",option+1) == 0)
4025 {
4026 if (*option == '+')
4027 break;
4028 i++;
4029 if (i == (ssize_t) argc)
4030 ThrowMogrifyException(OptionError,"MissingArgument",option);
4031 if (IsGeometry(argv[i]) == MagickFalse)
4032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4033 break;
4034 }
4035 if (LocaleCompare("authenticate",option+1) == 0)
4036 {
4037 if (*option == '+')
4038 break;
4039 i++;
4040 if (i == (ssize_t) argc)
4041 ThrowMogrifyException(OptionError,"MissingArgument",option);
4042 break;
4043 }
4044 if (LocaleCompare("auto-gamma",option+1) == 0)
4045 break;
4046 if (LocaleCompare("auto-level",option+1) == 0)
4047 break;
4048 if (LocaleCompare("auto-orient",option+1) == 0)
4049 break;
4050 if (LocaleCompare("auto-threshold",option+1) == 0)
4051 {
4052 ssize_t
4053 method;
4054
4055 if (*option == '+')
4056 break;
4057 i++;
4058 if (i == (ssize_t) argc)
4059 ThrowMogrifyException(OptionError,"MissingArgument",option);
4060 method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4061 argv[i]);
4062 if (method < 0)
4063 ThrowMogrifyException(OptionError,"UnrecognizedThresholdMethod",
4064 argv[i]);
4065 break;
4066 }
4067 if (LocaleCompare("average",option+1) == 0)
4068 break;
4069 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4070 }
4071 case 'b':
4072 {
4073 if (LocaleCompare("background",option+1) == 0)
4074 {
4075 if (*option == '+')
4076 break;
4077 i++;
4078 if (i == (ssize_t) argc)
4079 ThrowMogrifyException(OptionError,"MissingArgument",option);
4080 break;
4081 }
4082 if (LocaleCompare("bias",option+1) == 0)
4083 {
4084 if (*option == '+')
4085 break;
4086 i++;
4087 if (i == (ssize_t) argc)
4088 ThrowMogrifyException(OptionError,"MissingArgument",option);
4089 if (IsGeometry(argv[i]) == MagickFalse)
4090 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4091 break;
4092 }
4093 if (LocaleCompare("bilateral-blur",option+1) == 0)
4094 {
4095 if (*option == '+')
4096 break;
4097 i++;
4098 if (i == (ssize_t) argc)
4099 ThrowMogrifyException(OptionError,"MissingArgument",option);
4100 if (IsGeometry(argv[i]) == MagickFalse)
4101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4102 break;
4103 }
4104 if (LocaleCompare("black-point-compensation",option+1) == 0)
4105 break;
4106 if (LocaleCompare("black-threshold",option+1) == 0)
4107 {
4108 if (*option == '+')
4109 break;
4110 i++;
4111 if (i == (ssize_t) argc)
4112 ThrowMogrifyException(OptionError,"MissingArgument",option);
4113 if (IsGeometry(argv[i]) == MagickFalse)
4114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4115 break;
4116 }
4117 if (LocaleCompare("blue-primary",option+1) == 0)
4118 {
4119 if (*option == '+')
4120 break;
4121 i++;
4122 if (i == (ssize_t) argc)
4123 ThrowMogrifyException(OptionError,"MissingArgument",option);
4124 if (IsGeometry(argv[i]) == MagickFalse)
4125 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4126 break;
4127 }
4128 if (LocaleCompare("blue-shift",option+1) == 0)
4129 {
4130 i++;
4131 if (i == (ssize_t) argc)
4132 ThrowMogrifyException(OptionError,"MissingArgument",option);
4133 if (IsGeometry(argv[i]) == MagickFalse)
4134 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4135 break;
4136 }
4137 if (LocaleCompare("blur",option+1) == 0)
4138 {
4139 i++;
4140 if (i == (ssize_t) argc)
4141 ThrowMogrifyException(OptionError,"MissingArgument",option);
4142 if (IsGeometry(argv[i]) == MagickFalse)
4143 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4144 break;
4145 }
4146 if (LocaleCompare("border",option+1) == 0)
4147 {
4148 if (*option == '+')
4149 break;
4150 i++;
4151 if (i == (ssize_t) argc)
4152 ThrowMogrifyException(OptionError,"MissingArgument",option);
4153 if (IsGeometry(argv[i]) == MagickFalse)
4154 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4155 break;
4156 }
4157 if (LocaleCompare("bordercolor",option+1) == 0)
4158 {
4159 if (*option == '+')
4160 break;
4161 i++;
4162 if (i == (ssize_t) argc)
4163 ThrowMogrifyException(OptionError,"MissingArgument",option);
4164 break;
4165 }
4166 if (LocaleCompare("box",option+1) == 0)
4167 {
4168 if (*option == '+')
4169 break;
4170 i++;
4171 if (i == (ssize_t) argc)
4172 ThrowMogrifyException(OptionError,"MissingArgument",option);
4173 break;
4174 }
4175 if (LocaleCompare("brightness-contrast",option+1) == 0)
4176 {
4177 i++;
4178 if (i == (ssize_t) argc)
4179 ThrowMogrifyException(OptionError,"MissingArgument",option);
4180 if (IsGeometry(argv[i]) == MagickFalse)
4181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4182 break;
4183 }
4184 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4185 }
4186 case 'c':
4187 {
4188 if (LocaleCompare("cache",option+1) == 0)
4189 {
4190 if (*option == '+')
4191 break;
4192 i++;
4193 if (i == (ssize_t) argc)
4194 ThrowMogrifyException(OptionError,"MissingArgument",option);
4195 if (IsGeometry(argv[i]) == MagickFalse)
4196 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4197 break;
4198 }
4199 if (LocaleCompare("canny",option+1) == 0)
4200 {
4201 if (*option == '+')
4202 break;
4203 i++;
4204 if (i == (ssize_t) argc)
4205 ThrowMogrifyException(OptionError,"MissingArgument",option);
4206 if (IsGeometry(argv[i]) == MagickFalse)
4207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4208 break;
4209 }
4210 if (LocaleCompare("caption",option+1) == 0)
4211 {
4212 if (*option == '+')
4213 break;
4214 i++;
4215 if (i == (ssize_t) argc)
4216 ThrowMogrifyException(OptionError,"MissingArgument",option);
4217 break;
4218 }
4219 if (LocaleCompare("channel",option+1) == 0)
4220 {
4221 ssize_t
4222 channel;
4223
4224 if (*option == '+')
4225 break;
4226 i++;
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,"MissingArgument",option);
4229 channel=ParseChannelOption(argv[i]);
4230 if (channel < 0)
4231 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4232 argv[i]);
4233 break;
4234 }
4235 if (LocaleCompare("channel-fx",option+1) == 0)
4236 {
4237 ssize_t
4238 channel;
4239
4240 if (*option == '+')
4241 break;
4242 i++;
4243 if (i == (ssize_t) argc)
4244 ThrowMogrifyException(OptionError,"MissingArgument",option);
4245 channel=ParsePixelChannelOption(argv[i]);
4246 if (channel < 0)
4247 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4248 argv[i]);
4249 break;
4250 }
4251 if (LocaleCompare("cdl",option+1) == 0)
4252 {
4253 if (*option == '+')
4254 break;
4255 i++;
4256 if (i == (ssize_t) argc)
4257 ThrowMogrifyException(OptionError,"MissingArgument",option);
4258 break;
4259 }
4260 if (LocaleCompare("charcoal",option+1) == 0)
4261 {
4262 if (*option == '+')
4263 break;
4264 i++;
4265 if (i == (ssize_t) argc)
4266 ThrowMogrifyException(OptionError,"MissingArgument",option);
4267 if (IsGeometry(argv[i]) == MagickFalse)
4268 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4269 break;
4270 }
4271 if (LocaleCompare("chop",option+1) == 0)
4272 {
4273 if (*option == '+')
4274 break;
4275 i++;
4276 if (i == (ssize_t) argc)
4277 ThrowMogrifyException(OptionError,"MissingArgument",option);
4278 if (IsGeometry(argv[i]) == MagickFalse)
4279 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4280 break;
4281 }
4282 if (LocaleCompare("clahe",option+1) == 0)
4283 {
4284 if (*option == '+')
4285 break;
4286 i++;
4287 if (i == (ssize_t) argc)
4288 ThrowMogrifyException(OptionError,"MissingArgument",option);
4289 if (IsGeometry(argv[i]) == MagickFalse)
4290 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4291 break;
4292 }
4293 if (LocaleCompare("clamp",option+1) == 0)
4294 break;
4295 if (LocaleCompare("clip",option+1) == 0)
4296 break;
4297 if (LocaleCompare("clip-mask",option+1) == 0)
4298 {
4299 if (*option == '+')
4300 break;
4301 i++;
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 break;
4305 }
4306 if (LocaleCompare("clut",option+1) == 0)
4307 break;
4308 if (LocaleCompare("coalesce",option+1) == 0)
4309 break;
4310 if (LocaleCompare("colorize",option+1) == 0)
4311 {
4312 if (*option == '+')
4313 break;
4314 i++;
4315 if (i == (ssize_t) argc)
4316 ThrowMogrifyException(OptionError,"MissingArgument",option);
4317 if (IsGeometry(argv[i]) == MagickFalse)
4318 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4319 break;
4320 }
4321 if (LocaleCompare("color-matrix",option+1) == 0)
4322 {
4323 KernelInfo
4324 *kernel_info;
4325
4326 if (*option == '+')
4327 break;
4328 i++;
4329 if (i == (ssize_t) argc)
4330 ThrowMogrifyException(OptionError,"MissingArgument",option);
4331 kernel_info=AcquireKernelInfo(argv[i],exception);
4332 if (kernel_info == (KernelInfo *) NULL)
4333 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4334 kernel_info=DestroyKernelInfo(kernel_info);
4335 break;
4336 }
4337 if (LocaleCompare("colors",option+1) == 0)
4338 {
4339 if (*option == '+')
4340 break;
4341 i++;
4342 if (i == (ssize_t) argc)
4343 ThrowMogrifyException(OptionError,"MissingArgument",option);
4344 if (IsGeometry(argv[i]) == MagickFalse)
4345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4346 break;
4347 }
4348 if (LocaleCompare("colorspace",option+1) == 0)
4349 {
4350 ssize_t
4351 colorspace;
4352
4353 if (*option == '+')
4354 break;
4355 i++;
4356 if (i == (ssize_t) argc)
4357 ThrowMogrifyException(OptionError,"MissingArgument",option);
4358 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4359 argv[i]);
4360 if (colorspace < 0)
4361 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4362 argv[i]);
4363 break;
4364 }
4365 if (LocaleCompare("color-threshold",option+1) == 0)
4366 {
4367 if (*option == '+')
4368 break;
4369 i++;
4370 if (i == (ssize_t) argc)
4371 ThrowMogrifyException(OptionError,"MissingArgument",option);
4372 break;
4373 }
4374 if (LocaleCompare("combine",option+1) == 0)
4375 {
4376 ssize_t
4377 colorspace;
4378
4379 if (*option == '+')
4380 break;
4381 i++;
4382 if (i == (ssize_t) argc)
4383 ThrowMogrifyException(OptionError,"MissingArgument",option);
4384 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4385 argv[i]);
4386 if (colorspace < 0)
4387 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4388 argv[i]);
4389 break;
4390 }
4391 if (LocaleCompare("comment",option+1) == 0)
4392 {
4393 if (*option == '+')
4394 break;
4395 i++;
4396 if (i == (ssize_t) argc)
4397 ThrowMogrifyException(OptionError,"MissingArgument",option);
4398 break;
4399 }
4400 if (LocaleCompare("compare",option+1) == 0)
4401 break;
4402 if (LocaleCompare("compose",option+1) == 0)
4403 {
4404 ssize_t
4405 compose;
4406
4407 if (*option == '+')
4408 break;
4409 i++;
4410 if (i == (ssize_t) argc)
4411 ThrowMogrifyException(OptionError,"MissingArgument",option);
4412 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
4413 argv[i]);
4414 if (compose < 0)
4415 ThrowMogrifyException(OptionError,"UnrecognizedComposeOperator",
4416 argv[i]);
4417 break;
4418 }
4419 if (LocaleCompare("composite",option+1) == 0)
4420 break;
4421 if (LocaleCompare("compress",option+1) == 0)
4422 {
4423 ssize_t
4424 compress;
4425
4426 if (*option == '+')
4427 break;
4428 i++;
4429 if (i == (ssize_t) argc)
4430 ThrowMogrifyException(OptionError,"MissingArgument",option);
4431 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4432 argv[i]);
4433 if (compress < 0)
4434 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4435 argv[i]);
4436 break;
4437 }
4438 if (LocaleCompare("concurrent",option+1) == 0)
4439 break;
4440 if (LocaleCompare("connected-components",option+1) == 0)
4441 {
4442 i++;
4443 if (i == (ssize_t) argc)
4444 ThrowMogrifyException(OptionError,"MissingArgument",option);
4445 if (IsGeometry(argv[i]) == MagickFalse)
4446 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4447 break;
4448 }
4449 if (LocaleCompare("contrast",option+1) == 0)
4450 break;
4451 if (LocaleCompare("contrast-stretch",option+1) == 0)
4452 {
4453 i++;
4454 if (i == (ssize_t) argc)
4455 ThrowMogrifyException(OptionError,"MissingArgument",option);
4456 if (IsGeometry(argv[i]) == MagickFalse)
4457 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4458 break;
4459 }
4460 if (LocaleCompare("convolve",option+1) == 0)
4461 {
4462 KernelInfo
4463 *kernel_info;
4464
4465 if (*option == '+')
4466 break;
4467 i++;
4468 if (i == (ssize_t) argc)
4469 ThrowMogrifyException(OptionError,"MissingArgument",option);
4470 kernel_info=AcquireKernelInfo(argv[i],exception);
4471 if (kernel_info == (KernelInfo *) NULL)
4472 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4473 kernel_info=DestroyKernelInfo(kernel_info);
4474 break;
4475 }
4476 if (LocaleCompare("copy",option+1) == 0)
4477 {
4478 if (*option == '+')
4479 break;
4480 i++;
4481 if (i == (ssize_t) argc)
4482 ThrowMogrifyException(OptionError,"MissingArgument",option);
4483 if (IsGeometry(argv[i]) == MagickFalse)
4484 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4485 i++;
4486 if (i == (ssize_t) argc)
4487 ThrowMogrifyException(OptionError,"MissingArgument",option);
4488 if (IsGeometry(argv[i]) == MagickFalse)
4489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4490 break;
4491 }
4492 if (LocaleCompare("crop",option+1) == 0)
4493 {
4494 if (*option == '+')
4495 break;
4496 i++;
4497 if (i == (ssize_t) argc)
4498 ThrowMogrifyException(OptionError,"MissingArgument",option);
4499 if (IsGeometry(argv[i]) == MagickFalse)
4500 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4501 break;
4502 }
4503 if (LocaleCompare("cycle",option+1) == 0)
4504 {
4505 if (*option == '+')
4506 break;
4507 i++;
4508 if (i == (ssize_t) argc)
4509 ThrowMogrifyException(OptionError,"MissingArgument",option);
4510 if (IsGeometry(argv[i]) == MagickFalse)
4511 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4512 break;
4513 }
4514 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4515 }
4516 case 'd':
4517 {
4518 if (LocaleCompare("decipher",option+1) == 0)
4519 {
4520 if (*option == '+')
4521 break;
4522 i++;
4523 if (i == (ssize_t) argc)
4524 ThrowMogrifyException(OptionError,"MissingArgument",option);
4525 break;
4526 }
4527 if (LocaleCompare("deconstruct",option+1) == 0)
4528 break;
4529 if (LocaleCompare("debug",option+1) == 0)
4530 {
4531 ssize_t
4532 event;
4533
4534 if (*option == '+')
4535 break;
4536 i++;
4537 if (i == (ssize_t) argc)
4538 ThrowMogrifyException(OptionError,"MissingArgument",option);
4539 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4540 if (event < 0)
4541 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4542 argv[i]);
4543 (void) SetLogEventMask(argv[i]);
4544 break;
4545 }
4546 if (LocaleCompare("define",option+1) == 0)
4547 {
4548 i++;
4549 if (i == (ssize_t) argc)
4550 ThrowMogrifyException(OptionError,"MissingArgument",option);
4551 if (*option == '+')
4552 {
4553 const char
4554 *define;
4555
4556 define=GetImageOption(image_info,argv[i]);
4557 if (define == (const char *) NULL)
4558 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4559 break;
4560 }
4561 break;
4562 }
4563 if (LocaleCompare("delay",option+1) == 0)
4564 {
4565 if (*option == '+')
4566 break;
4567 i++;
4568 if (i == (ssize_t) argc)
4569 ThrowMogrifyException(OptionError,"MissingArgument",option);
4570 if (IsGeometry(argv[i]) == MagickFalse)
4571 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4572 break;
4573 }
4574 if (LocaleCompare("delete",option+1) == 0)
4575 {
4576 if (*option == '+')
4577 break;
4578 i++;
4579 if (i == (ssize_t) argc)
4580 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (LocaleNCompare(argv[i],"registry:",9) == 0)
4582 {
4583 (void) DeleteImageRegistry(argv[i]+9);
4584 break;
4585 }
4586 if (IsGeometry(argv[i]) == MagickFalse)
4587 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4588 break;
4589 }
4590 if (LocaleCompare("density",option+1) == 0)
4591 {
4592 if (*option == '+')
4593 break;
4594 i++;
4595 if (i == (ssize_t) argc)
4596 ThrowMogrifyException(OptionError,"MissingArgument",option);
4597 if (IsGeometry(argv[i]) == MagickFalse)
4598 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4599 break;
4600 }
4601 if (LocaleCompare("depth",option+1) == 0)
4602 {
4603 if (*option == '+')
4604 break;
4605 i++;
4606 if (i == (ssize_t) argc)
4607 ThrowMogrifyException(OptionError,"MissingArgument",option);
4608 if (IsGeometry(argv[i]) == MagickFalse)
4609 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4610 break;
4611 }
4612 if (LocaleCompare("deskew",option+1) == 0)
4613 {
4614 if (*option == '+')
4615 break;
4616 i++;
4617 if (i == (ssize_t) argc)
4618 ThrowMogrifyException(OptionError,"MissingArgument",option);
4619 if (IsGeometry(argv[i]) == MagickFalse)
4620 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4621 break;
4622 }
4623 if (LocaleCompare("despeckle",option+1) == 0)
4624 break;
4625 if (LocaleCompare("dft",option+1) == 0)
4626 break;
4627 if (LocaleCompare("direction",option+1) == 0)
4628 {
4629 ssize_t
4630 direction;
4631
4632 if (*option == '+')
4633 break;
4634 i++;
4635 if (i == (ssize_t) argc)
4636 ThrowMogrifyException(OptionError,"MissingArgument",option);
4637 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4638 argv[i]);
4639 if (direction < 0)
4640 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4641 argv[i]);
4642 break;
4643 }
4644 if (LocaleCompare("display",option+1) == 0)
4645 {
4646 if (*option == '+')
4647 break;
4648 i++;
4649 if (i == (ssize_t) argc)
4650 ThrowMogrifyException(OptionError,"MissingArgument",option);
4651 break;
4652 }
4653 if (LocaleCompare("dispose",option+1) == 0)
4654 {
4655 ssize_t
4656 dispose;
4657
4658 if (*option == '+')
4659 break;
4660 i++;
4661 if (i == (ssize_t) argc)
4662 ThrowMogrifyException(OptionError,"MissingArgument",option);
4663 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4664 argv[i]);
4665 if (dispose < 0)
4666 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4667 argv[i]);
4668 break;
4669 }
4670 if (LocaleCompare("distort",option+1) == 0)
4671 {
4672 ssize_t
4673 op;
4674
4675 i++;
4676 if (i == (ssize_t) argc)
4677 ThrowMogrifyException(OptionError,"MissingArgument",option);
4678 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4679 if (op < 0)
4680 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4681 argv[i]);
4682 i++;
4683 if (i == (ssize_t) argc)
4684 ThrowMogrifyException(OptionError,"MissingArgument",option);
4685 break;
4686 }
4687 if (LocaleCompare("dither",option+1) == 0)
4688 {
4689 ssize_t
4690 method;
4691
4692 if (*option == '+')
4693 break;
4694 i++;
4695 if (i == (ssize_t) argc)
4696 ThrowMogrifyException(OptionError,"MissingArgument",option);
4697 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4698 if (method < 0)
4699 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4700 argv[i]);
4701 break;
4702 }
4703 if (LocaleCompare("draw",option+1) == 0)
4704 {
4705 if (*option == '+')
4706 break;
4707 i++;
4708 if (i == (ssize_t) argc)
4709 ThrowMogrifyException(OptionError,"MissingArgument",option);
4710 break;
4711 }
4712 if (LocaleCompare("duplicate",option+1) == 0)
4713 {
4714 if (*option == '+')
4715 break;
4716 i++;
4717 if (i == (ssize_t) argc)
4718 ThrowMogrifyException(OptionError,"MissingArgument",option);
4719 if (IsGeometry(argv[i]) == MagickFalse)
4720 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4721 break;
4722 }
4723 if (LocaleCompare("duration",option+1) == 0)
4724 {
4725 if (*option == '+')
4726 break;
4727 i++;
4728 if (i == (ssize_t) argc)
4729 ThrowMogrifyException(OptionError,"MissingArgument",option);
4730 if (IsGeometry(argv[i]) == MagickFalse)
4731 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4732 break;
4733 }
4734 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4735 }
4736 case 'e':
4737 {
4738 if (LocaleCompare("edge",option+1) == 0)
4739 {
4740 if (*option == '+')
4741 break;
4742 i++;
4743 if (i == (ssize_t) argc)
4744 ThrowMogrifyException(OptionError,"MissingArgument",option);
4745 if (IsGeometry(argv[i]) == MagickFalse)
4746 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4747 break;
4748 }
4749 if (LocaleCompare("emboss",option+1) == 0)
4750 {
4751 if (*option == '+')
4752 break;
4753 i++;
4754 if (i == (ssize_t) argc)
4755 ThrowMogrifyException(OptionError,"MissingArgument",option);
4756 if (IsGeometry(argv[i]) == MagickFalse)
4757 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4758 break;
4759 }
4760 if (LocaleCompare("encipher",option+1) == 0)
4761 {
4762 if (*option == '+')
4763 break;
4764 i++;
4765 if (i == (ssize_t) argc)
4766 ThrowMogrifyException(OptionError,"MissingArgument",option);
4767 break;
4768 }
4769 if (LocaleCompare("encoding",option+1) == 0)
4770 {
4771 if (*option == '+')
4772 break;
4773 i++;
4774 if (i == (ssize_t) argc)
4775 ThrowMogrifyException(OptionError,"MissingArgument",option);
4776 break;
4777 }
4778 if (LocaleCompare("endian",option+1) == 0)
4779 {
4780 ssize_t
4781 endian;
4782
4783 if (*option == '+')
4784 break;
4785 i++;
4786 if (i == (ssize_t) argc)
4787 ThrowMogrifyException(OptionError,"MissingArgument",option);
4788 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4789 if (endian < 0)
4790 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4791 argv[i]);
4792 break;
4793 }
4794 if (LocaleCompare("enhance",option+1) == 0)
4795 break;
4796 if (LocaleCompare("equalize",option+1) == 0)
4797 break;
4798 if (LocaleCompare("evaluate",option+1) == 0)
4799 {
4800 ssize_t
4801 op;
4802
4803 if (*option == '+')
4804 break;
4805 i++;
4806 if (i == (ssize_t) argc)
4807 ThrowMogrifyException(OptionError,"MissingArgument",option);
4808 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4809 if (op < 0)
4810 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4811 argv[i]);
4812 i++;
4813 if (i == (ssize_t) argc)
4814 ThrowMogrifyException(OptionError,"MissingArgument",option);
4815 if (IsGeometry(argv[i]) == MagickFalse)
4816 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4817 break;
4818 }
4819 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4820 {
4821 ssize_t
4822 op;
4823
4824 if (*option == '+')
4825 break;
4826 i++;
4827 if (i == (ssize_t) argc)
4828 ThrowMogrifyException(OptionError,"MissingArgument",option);
4829 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4830 if (op < 0)
4831 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4832 argv[i]);
4833 break;
4834 }
4835 if (LocaleCompare("extent",option+1) == 0)
4836 {
4837 if (*option == '+')
4838 break;
4839 i++;
4840 if (i == (ssize_t) argc)
4841 ThrowMogrifyException(OptionError,"MissingArgument",option);
4842 if (IsGeometry(argv[i]) == MagickFalse)
4843 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4844 break;
4845 }
4846 if (LocaleCompare("extract",option+1) == 0)
4847 {
4848 if (*option == '+')
4849 break;
4850 i++;
4851 if (i == (ssize_t) argc)
4852 ThrowMogrifyException(OptionError,"MissingArgument",option);
4853 if (IsGeometry(argv[i]) == MagickFalse)
4854 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4855 break;
4856 }
4857 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4858 }
4859 case 'f':
4860 {
4861 if (LocaleCompare("family",option+1) == 0)
4862 {
4863 if (*option == '+')
4864 break;
4865 i++;
4866 if (i == (ssize_t) argc)
4867 ThrowMogrifyException(OptionError,"MissingArgument",option);
4868 break;
4869 }
4870 if (LocaleCompare("features",option+1) == 0)
4871 {
4872 if (*option == '+')
4873 break;
4874 i++;
4875 if (i == (ssize_t) argc)
4876 ThrowMogrifyException(OptionError,"MissingArgument",option);
4877 if (IsGeometry(argv[i]) == MagickFalse)
4878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4879 break;
4880 }
4881 if (LocaleCompare("fill",option+1) == 0)
4882 {
4883 if (*option == '+')
4884 break;
4885 i++;
4886 if (i == (ssize_t) argc)
4887 ThrowMogrifyException(OptionError,"MissingArgument",option);
4888 break;
4889 }
4890 if (LocaleCompare("filter",option+1) == 0)
4891 {
4892 ssize_t
4893 filter;
4894
4895 if (*option == '+')
4896 break;
4897 i++;
4898 if (i == (ssize_t) argc)
4899 ThrowMogrifyException(OptionError,"MissingArgument",option);
4900 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4901 if (filter < 0)
4902 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4903 argv[i]);
4904 break;
4905 }
4906 if (LocaleCompare("flatten",option+1) == 0)
4907 break;
4908 if (LocaleCompare("flip",option+1) == 0)
4909 break;
4910 if (LocaleCompare("flop",option+1) == 0)
4911 break;
4912 if (LocaleCompare("floodfill",option+1) == 0)
4913 {
4914 if (*option == '+')
4915 break;
4916 i++;
4917 if (i == (ssize_t) argc)
4918 ThrowMogrifyException(OptionError,"MissingArgument",option);
4919 if (IsGeometry(argv[i]) == MagickFalse)
4920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4921 i++;
4922 if (i == (ssize_t) argc)
4923 ThrowMogrifyException(OptionError,"MissingArgument",option);
4924 break;
4925 }
4926 if (LocaleCompare("font",option+1) == 0)
4927 {
4928 if (*option == '+')
4929 break;
4930 i++;
4931 if (i == (ssize_t) argc)
4932 ThrowMogrifyException(OptionError,"MissingArgument",option);
4933 break;
4934 }
4935 if (LocaleCompare("format",option+1) == 0)
4936 {
4937 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
4938 (void) CloneString(&format,(char *) NULL);
4939 if (*option == '+')
4940 break;
4941 i++;
4942 if (i == (ssize_t) argc)
4943 ThrowMogrifyException(OptionError,"MissingArgument",option);
4944 (void) CloneString(&format,argv[i]);
4945 (void) CopyMagickString(image_info->filename,format,
4946 MagickPathExtent);
4947 (void) ConcatenateMagickString(image_info->filename,":",
4948 MagickPathExtent);
4949 (void) SetImageInfo(image_info,0,exception);
4950 if (*image_info->magick == '\0')
4951 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4952 format);
4953 break;
4954 }
4955 if (LocaleCompare("frame",option+1) == 0)
4956 {
4957 if (*option == '+')
4958 break;
4959 i++;
4960 if (i == (ssize_t) argc)
4961 ThrowMogrifyException(OptionError,"MissingArgument",option);
4962 if (IsGeometry(argv[i]) == MagickFalse)
4963 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4964 break;
4965 }
4966 if (LocaleCompare("function",option+1) == 0)
4967 {
4968 ssize_t
4969 op;
4970
4971 if (*option == '+')
4972 break;
4973 i++;
4974 if (i == (ssize_t) argc)
4975 ThrowMogrifyException(OptionError,"MissingArgument",option);
4976 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4977 if (op < 0)
4978 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4979 i++;
4980 if (i == (ssize_t) argc)
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4982 break;
4983 }
4984 if (LocaleCompare("fuzz",option+1) == 0)
4985 {
4986 if (*option == '+')
4987 break;
4988 i++;
4989 if (i == (ssize_t) argc)
4990 ThrowMogrifyException(OptionError,"MissingArgument",option);
4991 if (IsGeometry(argv[i]) == MagickFalse)
4992 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4993 break;
4994 }
4995 if (LocaleCompare("fx",option+1) == 0)
4996 {
4997 i++;
4998 if (i == (ssize_t) argc)
4999 ThrowMogrifyException(OptionError,"MissingArgument",option);
5000 break;
5001 }
5002 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5003 }
5004 case 'g':
5005 {
5006 if (LocaleCompare("gamma",option+1) == 0)
5007 {
5008 i++;
5009 if (i == (ssize_t) argc)
5010 ThrowMogrifyException(OptionError,"MissingArgument",option);
5011 if (IsGeometry(argv[i]) == MagickFalse)
5012 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5013 break;
5014 }
5015 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5016 (LocaleCompare("gaussian",option+1) == 0))
5017 {
5018 i++;
5019 if (i == (ssize_t) argc)
5020 ThrowMogrifyException(OptionError,"MissingArgument",option);
5021 if (IsGeometry(argv[i]) == MagickFalse)
5022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5023 break;
5024 }
5025 if (LocaleCompare("geometry",option+1) == 0)
5026 {
5027 if (*option == '+')
5028 break;
5029 i++;
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,"MissingArgument",option);
5032 if (IsGeometry(argv[i]) == MagickFalse)
5033 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5034 break;
5035 }
5036 if (LocaleCompare("gravity",option+1) == 0)
5037 {
5038 ssize_t
5039 gravity;
5040
5041 if (*option == '+')
5042 break;
5043 i++;
5044 if (i == (ssize_t) argc)
5045 ThrowMogrifyException(OptionError,"MissingArgument",option);
5046 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5047 argv[i]);
5048 if (gravity < 0)
5049 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5050 argv[i]);
5051 break;
5052 }
5053 if (LocaleCompare("grayscale",option+1) == 0)
5054 {
5055 ssize_t
5056 method;
5057
5058 if (*option == '+')
5059 break;
5060 i++;
5061 if (i == (ssize_t) argc)
5062 ThrowMogrifyException(OptionError,"MissingArgument",option);
5063 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5064 argv[i]);
5065 if (method < 0)
5066 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
5067 argv[i]);
5068 break;
5069 }
5070 if (LocaleCompare("green-primary",option+1) == 0)
5071 {
5072 if (*option == '+')
5073 break;
5074 i++;
5075 if (i == (ssize_t) argc)
5076 ThrowMogrifyException(OptionError,"MissingArgument",option);
5077 if (IsGeometry(argv[i]) == MagickFalse)
5078 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5079 break;
5080 }
5081 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5082 }
5083 case 'h':
5084 {
5085 if (LocaleCompare("hald-clut",option+1) == 0)
5086 break;
5087 if ((LocaleCompare("help",option+1) == 0) ||
5088 (LocaleCompare("-help",option+1) == 0))
5089 {
5090 DestroyMogrify();
5091 return(MogrifyUsage());
5092 }
5093 if (LocaleCompare("hough-lines",option+1) == 0)
5094 {
5095 if (*option == '+')
5096 break;
5097 i++;
5098 if (i == (ssize_t) argc)
5099 ThrowMogrifyException(OptionError,"MissingArgument",option);
5100 if (IsGeometry(argv[i]) == MagickFalse)
5101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5102 break;
5103 }
5104 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5105 }
5106 case 'i':
5107 {
5108 if (LocaleCompare("identify",option+1) == 0)
5109 break;
5110 if (LocaleCompare("idft",option+1) == 0)
5111 break;
5112 if (LocaleCompare("illuminant",option+1) == 0)
5113 {
5114 ssize_t
5115 type;
5116
5117 if (*option == '+')
5118 break;
5119 i++;
5120 if (i == (ssize_t) argc)
5121 ThrowMogrifyException(OptionError,"MissingArgument",option);
5122 type=ParseCommandOption(MagickIlluminantOptions,MagickFalse,
5123 argv[i]);
5124 if (type < 0)
5125 ThrowMogrifyException(OptionError,"UnrecognizedIlluminantMethod",
5126 argv[i]);
5127 break;
5128 }
5129 if (LocaleCompare("implode",option+1) == 0)
5130 {
5131 if (*option == '+')
5132 break;
5133 i++;
5134 if (i == (ssize_t) argc)
5135 ThrowMogrifyException(OptionError,"MissingArgument",option);
5136 if (IsGeometry(argv[i]) == MagickFalse)
5137 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5138 break;
5139 }
5140 if (LocaleCompare("intensity",option+1) == 0)
5141 {
5142 ssize_t
5143 intensity;
5144
5145 if (*option == '+')
5146 break;
5147 i++;
5148 if (i == (ssize_t) argc)
5149 ThrowMogrifyException(OptionError,"MissingArgument",option);
5150 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5151 MagickFalse,argv[i]);
5152 if (intensity < 0)
5153 ThrowMogrifyException(OptionError,
5154 "UnrecognizedPixelIntensityMethod",argv[i]);
5155 break;
5156 }
5157 if (LocaleCompare("integral",option+1) == 0)
5158 break;
5159 if (LocaleCompare("intent",option+1) == 0)
5160 {
5161 ssize_t
5162 intent;
5163
5164 if (*option == '+')
5165 break;
5166 i++;
5167 if (i == (ssize_t) argc)
5168 ThrowMogrifyException(OptionError,"MissingArgument",option);
5169 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5170 if (intent < 0)
5171 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5172 argv[i]);
5173 break;
5174 }
5175 if (LocaleCompare("interlace",option+1) == 0)
5176 {
5177 ssize_t
5178 interlace;
5179
5180 if (*option == '+')
5181 break;
5182 i++;
5183 if (i == (ssize_t) argc)
5184 ThrowMogrifyException(OptionError,"MissingArgument",option);
5185 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5186 argv[i]);
5187 if (interlace < 0)
5188 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5189 argv[i]);
5190 break;
5191 }
5192 if (LocaleCompare("interline-spacing",option+1) == 0)
5193 {
5194 if (*option == '+')
5195 break;
5196 i++;
5197 if (i == (ssize_t) argc)
5198 ThrowMogrifyException(OptionError,"MissingArgument",option);
5199 if (IsGeometry(argv[i]) == MagickFalse)
5200 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5201 break;
5202 }
5203 if (LocaleCompare("interpolate",option+1) == 0)
5204 {
5205 ssize_t
5206 interpolate;
5207
5208 if (*option == '+')
5209 break;
5210 i++;
5211 if (i == (ssize_t) argc)
5212 ThrowMogrifyException(OptionError,"MissingArgument",option);
5213 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5214 argv[i]);
5215 if (interpolate < 0)
5216 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5217 argv[i]);
5218 break;
5219 }
5220 if (LocaleCompare("interword-spacing",option+1) == 0)
5221 {
5222 if (*option == '+')
5223 break;
5224 i++;
5225 if (i == (ssize_t) argc)
5226 ThrowMogrifyException(OptionError,"MissingArgument",option);
5227 if (IsGeometry(argv[i]) == MagickFalse)
5228 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5229 break;
5230 }
5231 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5232 }
5233 case 'k':
5234 {
5235 if (LocaleCompare("kerning",option+1) == 0)
5236 {
5237 if (*option == '+')
5238 break;
5239 i++;
5240 if (i == (ssize_t) argc)
5241 ThrowMogrifyException(OptionError,"MissingArgument",option);
5242 if (IsGeometry(argv[i]) == MagickFalse)
5243 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5244 break;
5245 }
5246 if (LocaleCompare("kmeans",option+1) == 0)
5247 {
5248 i++;
5249 if (i == (ssize_t) argc)
5250 ThrowMogrifyException(OptionError,"MissingArgument",option);
5251 if (IsGeometry(argv[i]) == MagickFalse)
5252 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5253 break;
5254 }
5255 if (LocaleCompare("kuwahara",option+1) == 0)
5256 {
5257 i++;
5258 if (i == (ssize_t) argc)
5259 ThrowMogrifyException(OptionError,"MissingArgument",option);
5260 if (IsGeometry(argv[i]) == MagickFalse)
5261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5262 break;
5263 }
5264 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5265 }
5266 case 'l':
5267 {
5268 if (LocaleCompare("label",option+1) == 0)
5269 {
5270 if (*option == '+')
5271 break;
5272 i++;
5273 if (i == (ssize_t) argc)
5274 ThrowMogrifyException(OptionError,"MissingArgument",option);
5275 break;
5276 }
5277 if (LocaleCompare("lat",option+1) == 0)
5278 {
5279 if (*option == '+')
5280 break;
5281 i++;
5282 if (i == (ssize_t) argc)
5283 ThrowMogrifyException(OptionError,"MissingArgument",option);
5284 if (IsGeometry(argv[i]) == MagickFalse)
5285 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5286 break;
5287 }
5288 if (LocaleCompare("layers",option+1) == 0)
5289 {
5290 ssize_t
5291 type;
5292
5293 if (*option == '+')
5294 break;
5295 i++;
5296 if (i == (ssize_t) argc)
5297 ThrowMogrifyException(OptionError,"MissingArgument",option);
5298 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5299 if (type < 0)
5300 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5301 argv[i]);
5302 break;
5303 }
5304 if (LocaleCompare("level",option+1) == 0)
5305 {
5306 i++;
5307 if (i == (ssize_t) argc)
5308 ThrowMogrifyException(OptionError,"MissingArgument",option);
5309 if (IsGeometry(argv[i]) == MagickFalse)
5310 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5311 break;
5312 }
5313 if (LocaleCompare("level-colors",option+1) == 0)
5314 {
5315 i++;
5316 if (i == (ssize_t) argc)
5317 ThrowMogrifyException(OptionError,"MissingArgument",option);
5318 break;
5319 }
5320 if (LocaleCompare("limit",option+1) == 0)
5321 {
5322 char
5323 *p;
5324
5325 double
5326 value;
5327
5328 ssize_t
5329 resource;
5330
5331 if (*option == '+')
5332 break;
5333 i++;
5334 if (i == (ssize_t) argc)
5335 ThrowMogrifyException(OptionError,"MissingArgument",option);
5336 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5337 argv[i]);
5338 if (resource < 0)
5339 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5340 argv[i]);
5341 i++;
5342 if (i == (ssize_t) argc)
5343 ThrowMogrifyException(OptionError,"MissingArgument",option);
5344 value=StringToDouble(argv[i],&p);
5345 (void) value;
5346 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5347 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5348 break;
5349 }
5350 if (LocaleCompare("liquid-rescale",option+1) == 0)
5351 {
5352 i++;
5353 if (i == (ssize_t) argc)
5354 ThrowMogrifyException(OptionError,"MissingArgument",option);
5355 if (IsGeometry(argv[i]) == MagickFalse)
5356 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5357 break;
5358 }
5359 if (LocaleCompare("list",option+1) == 0)
5360 {
5361 ssize_t
5362 list;
5363
5364 if (*option == '+')
5365 break;
5366 i++;
5367 if (i == (ssize_t) argc)
5368 ThrowMogrifyException(OptionError,"MissingArgument",option);
5369 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5370 if (list < 0)
5371 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5372 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5373 argv+j,exception);
5374 return(status == 0 ? MagickFalse : MagickTrue);
5375 }
5376 if (LocaleCompare("log",option+1) == 0)
5377 {
5378 if (*option == '+')
5379 break;
5380 i++;
5381 if ((i == (ssize_t) argc) ||
5382 (strchr(argv[i],'%') == (char *) NULL))
5383 ThrowMogrifyException(OptionError,"MissingArgument",option);
5384 break;
5385 }
5386 if (LocaleCompare("loop",option+1) == 0)
5387 {
5388 if (*option == '+')
5389 break;
5390 i++;
5391 if (i == (ssize_t) argc)
5392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5393 if (IsGeometry(argv[i]) == MagickFalse)
5394 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5395 break;
5396 }
5397 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5398 }
5399 case 'm':
5400 {
5401 if (LocaleCompare("magnify",option+1) == 0)
5402 break;
5403 if (LocaleCompare("map",option+1) == 0)
5404 {
5405 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5406 if (*option == '+')
5407 break;
5408 i++;
5409 if (i == (ssize_t) argc)
5410 ThrowMogrifyException(OptionError,"MissingArgument",option);
5411 break;
5412 }
5413 if (LocaleCompare("mask",option+1) == 0)
5414 {
5415 if (*option == '+')
5416 break;
5417 i++;
5418 if (i == (ssize_t) argc)
5419 ThrowMogrifyException(OptionError,"MissingArgument",option);
5420 break;
5421 }
5422 if (LocaleCompare("matte",option+1) == 0)
5423 break;
5424 if (LocaleCompare("mattecolor",option+1) == 0)
5425 {
5426 if (*option == '+')
5427 break;
5428 i++;
5429 if (i == (ssize_t) argc)
5430 ThrowMogrifyException(OptionError,"MissingArgument",option);
5431 break;
5432 }
5433 if (LocaleCompare("maximum",option+1) == 0)
5434 break;
5435 if (LocaleCompare("mean-shift",option+1) == 0)
5436 {
5437 if (*option == '+')
5438 break;
5439 i++;
5440 if (i == (ssize_t) argc)
5441 ThrowMogrifyException(OptionError,"MissingArgument",option);
5442 if (IsGeometry(argv[i]) == MagickFalse)
5443 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5444 break;
5445 }
5446 if (LocaleCompare("median",option+1) == 0)
5447 {
5448 if (*option == '+')
5449 break;
5450 i++;
5451 if (i == (ssize_t) argc)
5452 ThrowMogrifyException(OptionError,"MissingArgument",option);
5453 if (IsGeometry(argv[i]) == MagickFalse)
5454 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5455 break;
5456 }
5457 if (LocaleCompare("metric",option+1) == 0)
5458 {
5459 ssize_t
5460 type;
5461
5462 if (*option == '+')
5463 break;
5464 i++;
5465 if (i == (ssize_t) argc)
5466 ThrowMogrifyException(OptionError,"MissingArgument",option);
5467 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5468 if (type < 0)
5469 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5470 argv[i]);
5471 break;
5472 }
5473 if (LocaleCompare("minimum",option+1) == 0)
5474 break;
5475 if (LocaleCompare("modulate",option+1) == 0)
5476 {
5477 if (*option == '+')
5478 break;
5479 i++;
5480 if (i == (ssize_t) argc)
5481 ThrowMogrifyException(OptionError,"MissingArgument",option);
5482 if (IsGeometry(argv[i]) == MagickFalse)
5483 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5484 break;
5485 }
5486 if (LocaleCompare("mode",option+1) == 0)
5487 {
5488 if (*option == '+')
5489 break;
5490 i++;
5491 if (i == (ssize_t) argc)
5492 ThrowMogrifyException(OptionError,"MissingArgument",option);
5493 if (IsGeometry(argv[i]) == MagickFalse)
5494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5495 break;
5496 }
5497 if (LocaleCompare("monitor",option+1) == 0)
5498 break;
5499 if (LocaleCompare("monochrome",option+1) == 0)
5500 break;
5501 if (LocaleCompare("morph",option+1) == 0)
5502 {
5503 if (*option == '+')
5504 break;
5505 i++;
5506 if (i == (ssize_t) argc)
5507 ThrowMogrifyException(OptionError,"MissingArgument",option);
5508 if (IsGeometry(argv[i]) == MagickFalse)
5509 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5510 break;
5511 }
5512 if (LocaleCompare("morphology",option+1) == 0)
5513 {
5514 char
5515 token[MagickPathExtent];
5516
5517 KernelInfo
5518 *kernel_info;
5519
5520 ssize_t
5521 op;
5522
5523 i++;
5524 if (i == (ssize_t) argc)
5525 ThrowMogrifyException(OptionError,"MissingArgument",option);
5526 (void) GetNextToken(argv[i],(const char **) NULL,MagickPathExtent,
5527 token);
5528 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5529 if (op < 0)
5530 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5531 token);
5532 i++;
5533 if (i == (ssize_t) argc)
5534 ThrowMogrifyException(OptionError,"MissingArgument",option);
5535 kernel_info=AcquireKernelInfo(argv[i],exception);
5536 if (kernel_info == (KernelInfo *) NULL)
5537 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5538 kernel_info=DestroyKernelInfo(kernel_info);
5539 break;
5540 }
5541 if (LocaleCompare("mosaic",option+1) == 0)
5542 break;
5543 if (LocaleCompare("motion-blur",option+1) == 0)
5544 {
5545 if (*option == '+')
5546 break;
5547 i++;
5548 if (i == (ssize_t) argc)
5549 ThrowMogrifyException(OptionError,"MissingArgument",option);
5550 if (IsGeometry(argv[i]) == MagickFalse)
5551 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5552 break;
5553 }
5554 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5555 }
5556 case 'n':
5557 {
5558 if (LocaleCompare("negate",option+1) == 0)
5559 break;
5560 if (LocaleCompare("noise",option+1) == 0)
5561 {
5562 i++;
5563 if (i == (ssize_t) argc)
5564 ThrowMogrifyException(OptionError,"MissingArgument",option);
5565 if (*option == '+')
5566 {
5567 ssize_t
5568 noise;
5569
5570 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5571 argv[i]);
5572 if (noise < 0)
5573 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5574 argv[i]);
5575 break;
5576 }
5577 if (IsGeometry(argv[i]) == MagickFalse)
5578 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5579 break;
5580 }
5581 if (LocaleCompare("noop",option+1) == 0)
5582 break;
5583 if (LocaleCompare("normalize",option+1) == 0)
5584 break;
5585 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5586 }
5587 case 'o':
5588 {
5589 if (LocaleCompare("opaque",option+1) == 0)
5590 {
5591 i++;
5592 if (i == (ssize_t) argc)
5593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 break;
5595 }
5596 if (LocaleCompare("ordered-dither",option+1) == 0)
5597 {
5598 if (*option == '+')
5599 break;
5600 i++;
5601 if (i == (ssize_t) argc)
5602 ThrowMogrifyException(OptionError,"MissingArgument",option);
5603 break;
5604 }
5605 if (LocaleCompare("orient",option+1) == 0)
5606 {
5607 ssize_t
5608 orientation;
5609
5610 orientation=UndefinedOrientation;
5611 if (*option == '+')
5612 break;
5613 i++;
5614 if (i == (ssize_t) argc)
5615 ThrowMogrifyException(OptionError,"MissingArgument",option);
5616 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5617 argv[i]);
5618 if (orientation < 0)
5619 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5620 argv[i]);
5621 break;
5622 }
5623 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5624 }
5625 case 'p':
5626 {
5627 if (LocaleCompare("page",option+1) == 0)
5628 {
5629 if (*option == '+')
5630 break;
5631 i++;
5632 if (i == (ssize_t) argc)
5633 ThrowMogrifyException(OptionError,"MissingArgument",option);
5634 break;
5635 }
5636 if (LocaleCompare("paint",option+1) == 0)
5637 {
5638 if (*option == '+')
5639 break;
5640 i++;
5641 if (i == (ssize_t) argc)
5642 ThrowMogrifyException(OptionError,"MissingArgument",option);
5643 if (IsGeometry(argv[i]) == MagickFalse)
5644 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5645 break;
5646 }
5647 if (LocaleCompare("path",option+1) == 0)
5648 {
5649 (void) CloneString(&path,(char *) NULL);
5650 if (*option == '+')
5651 break;
5652 i++;
5653 if (i == (ssize_t) argc)
5654 ThrowMogrifyException(OptionError,"MissingArgument",option);
5655 (void) CloneString(&path,argv[i]);
5656 break;
5657 }
5658 if (LocaleCompare("perceptible",option+1) == 0)
5659 {
5660 if (*option == '+')
5661 break;
5662 i++;
5663 if (i == (ssize_t) argc)
5664 ThrowMogrifyException(OptionError,"MissingArgument",option);
5665 if (IsGeometry(argv[i]) == MagickFalse)
5666 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5667 break;
5668 }
5669 if (LocaleCompare("pointsize",option+1) == 0)
5670 {
5671 if (*option == '+')
5672 break;
5673 i++;
5674 if (i == (ssize_t) argc)
5675 ThrowMogrifyException(OptionError,"MissingArgument",option);
5676 if (IsGeometry(argv[i]) == MagickFalse)
5677 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5678 break;
5679 }
5680 if (LocaleCompare("polaroid",option+1) == 0)
5681 {
5682 if (*option == '+')
5683 break;
5684 i++;
5685 if (i == (ssize_t) argc)
5686 ThrowMogrifyException(OptionError,"MissingArgument",option);
5687 if (IsGeometry(argv[i]) == MagickFalse)
5688 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5689 break;
5690 }
5691 if (LocaleCompare("poly",option+1) == 0)
5692 {
5693 if (*option == '+')
5694 break;
5695 i++;
5696 if (i == (ssize_t) argc)
5697 ThrowMogrifyException(OptionError,"MissingArgument",option);
5698 if (IsGeometry(argv[i]) == MagickFalse)
5699 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5700 break;
5701 }
5702 if (LocaleCompare("posterize",option+1) == 0)
5703 {
5704 if (*option == '+')
5705 break;
5706 i++;
5707 if (i == (ssize_t) argc)
5708 ThrowMogrifyException(OptionError,"MissingArgument",option);
5709 if (IsGeometry(argv[i]) == MagickFalse)
5710 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5711 break;
5712 }
5713 if (LocaleCompare("precision",option+1) == 0)
5714 {
5715 if (*option == '+')
5716 break;
5717 i++;
5718 if (i == (ssize_t) argc)
5719 ThrowMogrifyException(OptionError,"MissingArgument",option);
5720 if (IsGeometry(argv[i]) == MagickFalse)
5721 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5722 break;
5723 }
5724 if (LocaleCompare("print",option+1) == 0)
5725 {
5726 if (*option == '+')
5727 break;
5728 i++;
5729 if (i == (ssize_t) argc)
5730 ThrowMogrifyException(OptionError,"MissingArgument",option);
5731 break;
5732 }
5733 if (LocaleCompare("process",option+1) == 0)
5734 {
5735 if (*option == '+')
5736 break;
5737 i++;
5738 if (i == (ssize_t) argc)
5739 ThrowMogrifyException(OptionError,"MissingArgument",option);
5740 break;
5741 }
5742 if (LocaleCompare("profile",option+1) == 0)
5743 {
5744 i++;
5745 if (i == (ssize_t) argc)
5746 ThrowMogrifyException(OptionError,"MissingArgument",option);
5747 break;
5748 }
5749 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5750 }
5751 case 'q':
5752 {
5753 if (LocaleCompare("quality",option+1) == 0)
5754 {
5755 if (*option == '+')
5756 break;
5757 i++;
5758 if (i == (ssize_t) argc)
5759 ThrowMogrifyException(OptionError,"MissingArgument",option);
5760 if (IsGeometry(argv[i]) == MagickFalse)
5761 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5762 break;
5763 }
5764 if (LocaleCompare("quantize",option+1) == 0)
5765 {
5766 ssize_t
5767 colorspace;
5768
5769 if (*option == '+')
5770 break;
5771 i++;
5772 if (i == (ssize_t) argc)
5773 ThrowMogrifyException(OptionError,"MissingArgument",option);
5774 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5775 argv[i]);
5776 if (colorspace < 0)
5777 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5778 argv[i]);
5779 break;
5780 }
5781 if (LocaleCompare("quiet",option+1) == 0)
5782 break;
5783 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5784 }
5785 case 'r':
5786 {
5787 if (LocaleCompare("rotational-blur",option+1) == 0)
5788 {
5789 i++;
5790 if (i == (ssize_t) argc)
5791 ThrowMogrifyException(OptionError,"MissingArgument",option);
5792 if (IsGeometry(argv[i]) == MagickFalse)
5793 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5794 break;
5795 }
5796 if (LocaleCompare("raise",option+1) == 0)
5797 {
5798 i++;
5799 if (i == (ssize_t) argc)
5800 ThrowMogrifyException(OptionError,"MissingArgument",option);
5801 if (IsGeometry(argv[i]) == MagickFalse)
5802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5803 break;
5804 }
5805 if (LocaleCompare("random-threshold",option+1) == 0)
5806 {
5807 if (*option == '+')
5808 break;
5809 i++;
5810 if (i == (ssize_t) argc)
5811 ThrowMogrifyException(OptionError,"MissingArgument",option);
5812 if (IsGeometry(argv[i]) == MagickFalse)
5813 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5814 break;
5815 }
5816 if (LocaleCompare("range-threshold",option+1) == 0)
5817 {
5818 if (*option == '+')
5819 break;
5820 i++;
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5825 break;
5826 }
5827 if (LocaleCompare("read-mask",option+1) == 0)
5828 {
5829 if (*option == '+')
5830 break;
5831 i++;
5832 if (i == (ssize_t) argc)
5833 ThrowMogrifyException(OptionError,"MissingArgument",option);
5834 break;
5835 }
5836 if (LocaleCompare("red-primary",option+1) == 0)
5837 {
5838 if (*option == '+')
5839 break;
5840 i++;
5841 if (i == (ssize_t) argc)
5842 ThrowMogrifyException(OptionError,"MissingArgument",option);
5843 if (IsGeometry(argv[i]) == MagickFalse)
5844 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5845 }
5846 if (LocaleCompare("regard-warnings",option+1) == 0)
5847 break;
5848 if (LocaleCompare("region",option+1) == 0)
5849 {
5850 if (*option == '+')
5851 break;
5852 i++;
5853 if (i == (ssize_t) argc)
5854 ThrowMogrifyException(OptionError,"MissingArgument",option);
5855 if (IsGeometry(argv[i]) == MagickFalse)
5856 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5857 break;
5858 }
5859 if (LocaleCompare("remap",option+1) == 0)
5860 {
5861 if (*option == '+')
5862 break;
5863 i++;
5864 if (i == (ssize_t) argc)
5865 ThrowMogrifyException(OptionError,"MissingArgument",option);
5866 break;
5867 }
5868 if (LocaleCompare("render",option+1) == 0)
5869 break;
5870 if (LocaleCompare("repage",option+1) == 0)
5871 {
5872 if (*option == '+')
5873 break;
5874 i++;
5875 if (i == (ssize_t) argc)
5876 ThrowMogrifyException(OptionError,"MissingArgument",option);
5877 if (IsGeometry(argv[i]) == MagickFalse)
5878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5879 break;
5880 }
5881 if (LocaleCompare("resample",option+1) == 0)
5882 {
5883 if (*option == '+')
5884 break;
5885 i++;
5886 if (i == (ssize_t) argc)
5887 ThrowMogrifyException(OptionError,"MissingArgument",option);
5888 if (IsGeometry(argv[i]) == MagickFalse)
5889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5890 break;
5891 }
5892 if (LocaleCompare("reshape",option+1) == 0)
5893 {
5894 if (*option == '+')
5895 break;
5896 i++;
5897 if (i == (ssize_t) argc)
5898 ThrowMogrifyException(OptionError,"MissingArgument",option);
5899 if (IsGeometry(argv[i]) == MagickFalse)
5900 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5901 break;
5902 }
5903 if (LocaleCompare("resize",option+1) == 0)
5904 {
5905 if (*option == '+')
5906 break;
5907 i++;
5908 if (i == (ssize_t) argc)
5909 ThrowMogrifyException(OptionError,"MissingArgument",option);
5910 if (IsGeometry(argv[i]) == MagickFalse)
5911 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5912 break;
5913 }
5914 if ((LocaleNCompare("respect-parentheses",option+1,17) == 0) ||
5915 (LocaleNCompare("respect-parenthesis",option+1,17) == 0))
5916 {
5917 respect_parentheses=(*option == '-') ? MagickTrue : MagickFalse;
5918 break;
5919 }
5920 if (LocaleCompare("reverse",option+1) == 0)
5921 break;
5922 if (LocaleCompare("roll",option+1) == 0)
5923 {
5924 if (*option == '+')
5925 break;
5926 i++;
5927 if (i == (ssize_t) argc)
5928 ThrowMogrifyException(OptionError,"MissingArgument",option);
5929 if (IsGeometry(argv[i]) == MagickFalse)
5930 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5931 break;
5932 }
5933 if (LocaleCompare("rotate",option+1) == 0)
5934 {
5935 i++;
5936 if (i == (ssize_t) argc)
5937 ThrowMogrifyException(OptionError,"MissingArgument",option);
5938 if (IsGeometry(argv[i]) == MagickFalse)
5939 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5940 break;
5941 }
5942 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5943 }
5944 case 's':
5945 {
5946 if (LocaleCompare("sample",option+1) == 0)
5947 {
5948 if (*option == '+')
5949 break;
5950 i++;
5951 if (i == (ssize_t) argc)
5952 ThrowMogrifyException(OptionError,"MissingArgument",option);
5953 if (IsGeometry(argv[i]) == MagickFalse)
5954 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5955 break;
5956 }
5957 if (LocaleCompare("sampling-factor",option+1) == 0)
5958 {
5959 if (*option == '+')
5960 break;
5961 i++;
5962 if (i == (ssize_t) argc)
5963 ThrowMogrifyException(OptionError,"MissingArgument",option);
5964 if (IsGeometry(argv[i]) == MagickFalse)
5965 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5966 break;
5967 }
5968 if (LocaleCompare("scale",option+1) == 0)
5969 {
5970 if (*option == '+')
5971 break;
5972 i++;
5973 if (i == (ssize_t) argc)
5974 ThrowMogrifyException(OptionError,"MissingArgument",option);
5975 if (IsGeometry(argv[i]) == MagickFalse)
5976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5977 break;
5978 }
5979 if (LocaleCompare("scene",option+1) == 0)
5980 {
5981 if (*option == '+')
5982 break;
5983 i++;
5984 if (i == (ssize_t) argc)
5985 ThrowMogrifyException(OptionError,"MissingArgument",option);
5986 if (IsGeometry(argv[i]) == MagickFalse)
5987 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5988 break;
5989 }
5990 if (LocaleCompare("seed",option+1) == 0)
5991 {
5992 if (*option == '+')
5993 break;
5994 i++;
5995 if (i == (ssize_t) argc)
5996 ThrowMogrifyException(OptionError,"MissingArgument",option);
5997 if (IsGeometry(argv[i]) == MagickFalse)
5998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5999 break;
6000 }
6001 if (LocaleCompare("segment",option+1) == 0)
6002 {
6003 if (*option == '+')
6004 break;
6005 i++;
6006 if (i == (ssize_t) argc)
6007 ThrowMogrifyException(OptionError,"MissingArgument",option);
6008 if (IsGeometry(argv[i]) == MagickFalse)
6009 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6010 break;
6011 }
6012 if (LocaleCompare("selective-blur",option+1) == 0)
6013 {
6014 i++;
6015 if (i == (ssize_t) argc)
6016 ThrowMogrifyException(OptionError,"MissingArgument",option);
6017 if (IsGeometry(argv[i]) == MagickFalse)
6018 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6019 break;
6020 }
6021 if (LocaleCompare("separate",option+1) == 0)
6022 break;
6023 if (LocaleCompare("sepia-tone",option+1) == 0)
6024 {
6025 if (*option == '+')
6026 break;
6027 i++;
6028 if (i == (ssize_t) argc)
6029 ThrowMogrifyException(OptionError,"MissingArgument",option);
6030 if (IsGeometry(argv[i]) == MagickFalse)
6031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6032 break;
6033 }
6034 if (LocaleCompare("set",option+1) == 0)
6035 {
6036 i++;
6037 if (i == (ssize_t) argc)
6038 ThrowMogrifyException(OptionError,"MissingArgument",option);
6039 if (*option == '+')
6040 break;
6041 i++;
6042 if (i == (ssize_t) argc)
6043 ThrowMogrifyException(OptionError,"MissingArgument",option);
6044 break;
6045 }
6046 if (LocaleCompare("shade",option+1) == 0)
6047 {
6048 i++;
6049 if (i == (ssize_t) argc)
6050 ThrowMogrifyException(OptionError,"MissingArgument",option);
6051 if (IsGeometry(argv[i]) == MagickFalse)
6052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6053 break;
6054 }
6055 if (LocaleCompare("shadow",option+1) == 0)
6056 {
6057 if (*option == '+')
6058 break;
6059 i++;
6060 if (i == (ssize_t) argc)
6061 ThrowMogrifyException(OptionError,"MissingArgument",option);
6062 if (IsGeometry(argv[i]) == MagickFalse)
6063 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6064 break;
6065 }
6066 if (LocaleCompare("sharpen",option+1) == 0)
6067 {
6068 i++;
6069 if (i == (ssize_t) argc)
6070 ThrowMogrifyException(OptionError,"MissingArgument",option);
6071 if (IsGeometry(argv[i]) == MagickFalse)
6072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6073 break;
6074 }
6075 if (LocaleCompare("shave",option+1) == 0)
6076 {
6077 if (*option == '+')
6078 break;
6079 i++;
6080 if (i == (ssize_t) argc)
6081 ThrowMogrifyException(OptionError,"MissingArgument",option);
6082 if (IsGeometry(argv[i]) == MagickFalse)
6083 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6084 break;
6085 }
6086 if (LocaleCompare("shear",option+1) == 0)
6087 {
6088 i++;
6089 if (i == (ssize_t) argc)
6090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6091 if (IsGeometry(argv[i]) == MagickFalse)
6092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6093 break;
6094 }
6095 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
6096 {
6097 i++;
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6100 if (IsGeometry(argv[i]) == MagickFalse)
6101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6102 break;
6103 }
6104 if (LocaleCompare("size",option+1) == 0)
6105 {
6106 if (*option == '+')
6107 break;
6108 i++;
6109 if (i == (ssize_t) argc)
6110 ThrowMogrifyException(OptionError,"MissingArgument",option);
6111 if (IsGeometry(argv[i]) == MagickFalse)
6112 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6113 break;
6114 }
6115 if (LocaleCompare("sketch",option+1) == 0)
6116 {
6117 if (*option == '+')
6118 break;
6119 i++;
6120 if (i == (ssize_t) argc)
6121 ThrowMogrifyException(OptionError,"MissingArgument",option);
6122 if (IsGeometry(argv[i]) == MagickFalse)
6123 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6124 break;
6125 }
6126 if (LocaleCompare("smush",option+1) == 0)
6127 {
6128 i++;
6129 if (i == (ssize_t) argc)
6130 ThrowMogrifyException(OptionError,"MissingArgument",option);
6131 if (IsGeometry(argv[i]) == MagickFalse)
6132 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6133 i++;
6134 break;
6135 }
6136 if (LocaleCompare("solarize",option+1) == 0)
6137 {
6138 if (*option == '+')
6139 break;
6140 i++;
6141 if (i == (ssize_t) argc)
6142 ThrowMogrifyException(OptionError,"MissingArgument",option);
6143 if (IsGeometry(argv[i]) == MagickFalse)
6144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6145 break;
6146 }
6147 if (LocaleCompare("sort",option+1) == 0)
6148 break;
6149 if (LocaleCompare("sparse-color",option+1) == 0)
6150 {
6151 ssize_t
6152 op;
6153
6154 i++;
6155 if (i == (ssize_t) argc)
6156 ThrowMogrifyException(OptionError,"MissingArgument",option);
6157 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6158 if (op < 0)
6159 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6160 argv[i]);
6161 i++;
6162 if (i == (ssize_t) argc)
6163 ThrowMogrifyException(OptionError,"MissingArgument",option);
6164 break;
6165 }
6166 if (LocaleCompare("splice",option+1) == 0)
6167 {
6168 if (*option == '+')
6169 break;
6170 i++;
6171 if (i == (ssize_t) argc)
6172 ThrowMogrifyException(OptionError,"MissingArgument",option);
6173 if (IsGeometry(argv[i]) == MagickFalse)
6174 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6175 break;
6176 }
6177 if (LocaleCompare("spread",option+1) == 0)
6178 {
6179 if (*option == '+')
6180 break;
6181 i++;
6182 if (i == (ssize_t) argc)
6183 ThrowMogrifyException(OptionError,"MissingArgument",option);
6184 if (IsGeometry(argv[i]) == MagickFalse)
6185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6186 break;
6187 }
6188 if (LocaleCompare("statistic",option+1) == 0)
6189 {
6190 ssize_t
6191 op;
6192
6193 if (*option == '+')
6194 break;
6195 i++;
6196 if (i == (ssize_t) argc)
6197 ThrowMogrifyException(OptionError,"MissingArgument",option);
6198 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6199 if (op < 0)
6200 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6201 argv[i]);
6202 i++;
6203 if (i == (ssize_t) argc)
6204 ThrowMogrifyException(OptionError,"MissingArgument",option);
6205 if (IsGeometry(argv[i]) == MagickFalse)
6206 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6207 break;
6208 }
6209 if (LocaleCompare("stretch",option+1) == 0)
6210 {
6211 ssize_t
6212 stretch;
6213
6214 if (*option == '+')
6215 break;
6216 i++;
6217 if (i == (ssize_t) argc)
6218 ThrowMogrifyException(OptionError,"MissingArgument",option);
6219 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6220 argv[i]);
6221 if (stretch < 0)
6222 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6223 argv[i]);
6224 break;
6225 }
6226 if (LocaleCompare("strip",option+1) == 0)
6227 break;
6228 if (LocaleCompare("stroke",option+1) == 0)
6229 {
6230 if (*option == '+')
6231 break;
6232 i++;
6233 if (i == (ssize_t) argc)
6234 ThrowMogrifyException(OptionError,"MissingArgument",option);
6235 break;
6236 }
6237 if (LocaleCompare("strokewidth",option+1) == 0)
6238 {
6239 if (*option == '+')
6240 break;
6241 i++;
6242 if (i == (ssize_t) argc)
6243 ThrowMogrifyException(OptionError,"MissingArgument",option);
6244 if (IsGeometry(argv[i]) == MagickFalse)
6245 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6246 break;
6247 }
6248 if (LocaleCompare("style",option+1) == 0)
6249 {
6250 ssize_t
6251 style;
6252
6253 if (*option == '+')
6254 break;
6255 i++;
6256 if (i == (ssize_t) argc)
6257 ThrowMogrifyException(OptionError,"MissingArgument",option);
6258 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6259 if (style < 0)
6260 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6261 argv[i]);
6262 break;
6263 }
6264 if (LocaleCompare("swap",option+1) == 0)
6265 {
6266 if (*option == '+')
6267 break;
6268 i++;
6269 if (i == (ssize_t) argc)
6270 ThrowMogrifyException(OptionError,"MissingArgument",option);
6271 if (IsGeometry(argv[i]) == MagickFalse)
6272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6273 break;
6274 }
6275 if (LocaleCompare("swirl",option+1) == 0)
6276 {
6277 if (*option == '+')
6278 break;
6279 i++;
6280 if (i == (ssize_t) argc)
6281 ThrowMogrifyException(OptionError,"MissingArgument",option);
6282 if (IsGeometry(argv[i]) == MagickFalse)
6283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6284 break;
6285 }
6286 if (LocaleCompare("synchronize",option+1) == 0)
6287 break;
6288 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6289 }
6290 case 't':
6291 {
6292 if (LocaleCompare("taint",option+1) == 0)
6293 break;
6294 if (LocaleCompare("texture",option+1) == 0)
6295 {
6296 if (*option == '+')
6297 break;
6298 i++;
6299 if (i == (ssize_t) argc)
6300 ThrowMogrifyException(OptionError,"MissingArgument",option);
6301 break;
6302 }
6303 if (LocaleCompare("tile",option+1) == 0)
6304 {
6305 if (*option == '+')
6306 break;
6307 i++;
6308 if (i == (ssize_t) argc)
6309 ThrowMogrifyException(OptionError,"MissingArgument",option);
6310 break;
6311 }
6312 if (LocaleCompare("tile-offset",option+1) == 0)
6313 {
6314 if (*option == '+')
6315 break;
6316 i++;
6317 if (i == (ssize_t) argc)
6318 ThrowMogrifyException(OptionError,"MissingArgument",option);
6319 if (IsGeometry(argv[i]) == MagickFalse)
6320 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6321 break;
6322 }
6323 if (LocaleCompare("tint",option+1) == 0)
6324 {
6325 if (*option == '+')
6326 break;
6327 i++;
6328 if (i == (ssize_t) argc)
6329 ThrowMogrifyException(OptionError,"MissingArgument",option);
6330 if (IsGeometry(argv[i]) == MagickFalse)
6331 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6332 break;
6333 }
6334 if (LocaleCompare("transform",option+1) == 0)
6335 break;
6336 if (LocaleCompare("transpose",option+1) == 0)
6337 break;
6338 if (LocaleCompare("transverse",option+1) == 0)
6339 break;
6340 if (LocaleCompare("threshold",option+1) == 0)
6341 {
6342 if (*option == '+')
6343 break;
6344 i++;
6345 if (i == (ssize_t) argc)
6346 ThrowMogrifyException(OptionError,"MissingArgument",option);
6347 if (IsGeometry(argv[i]) == MagickFalse)
6348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6349 break;
6350 }
6351 if (LocaleCompare("thumbnail",option+1) == 0)
6352 {
6353 if (*option == '+')
6354 break;
6355 i++;
6356 if (i == (ssize_t) argc)
6357 ThrowMogrifyException(OptionError,"MissingArgument",option);
6358 if (IsGeometry(argv[i]) == MagickFalse)
6359 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6360 break;
6361 }
6362 if (LocaleCompare("transparent",option+1) == 0)
6363 {
6364 i++;
6365 if (i == (ssize_t) argc)
6366 ThrowMogrifyException(OptionError,"MissingArgument",option);
6367 break;
6368 }
6369 if (LocaleCompare("transparent-color",option+1) == 0)
6370 {
6371 if (*option == '+')
6372 break;
6373 i++;
6374 if (i == (ssize_t) argc)
6375 ThrowMogrifyException(OptionError,"MissingArgument",option);
6376 break;
6377 }
6378 if (LocaleCompare("treedepth",option+1) == 0)
6379 {
6380 if (*option == '+')
6381 break;
6382 i++;
6383 if (i == (ssize_t) argc)
6384 ThrowMogrifyException(OptionError,"MissingArgument",option);
6385 if (IsGeometry(argv[i]) == MagickFalse)
6386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6387 break;
6388 }
6389 if (LocaleCompare("trim",option+1) == 0)
6390 break;
6391 if (LocaleCompare("type",option+1) == 0)
6392 {
6393 ssize_t
6394 type;
6395
6396 if (*option == '+')
6397 break;
6398 i++;
6399 if (i == (ssize_t) argc)
6400 ThrowMogrifyException(OptionError,"MissingArgument",option);
6401 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6402 if (type < 0)
6403 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6404 argv[i]);
6405 break;
6406 }
6407 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6408 }
6409 case 'u':
6410 {
6411 if (LocaleCompare("undercolor",option+1) == 0)
6412 {
6413 if (*option == '+')
6414 break;
6415 i++;
6416 if (i == (ssize_t) argc)
6417 ThrowMogrifyException(OptionError,"MissingArgument",option);
6418 break;
6419 }
6420 if (LocaleCompare("unique-colors",option+1) == 0)
6421 break;
6422 if (LocaleCompare("units",option+1) == 0)
6423 {
6424 ssize_t
6425 units;
6426
6427 if (*option == '+')
6428 break;
6429 i++;
6430 if (i == (ssize_t) argc)
6431 ThrowMogrifyException(OptionError,"MissingArgument",option);
6432 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6433 argv[i]);
6434 if (units < 0)
6435 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6436 argv[i]);
6437 break;
6438 }
6439 if (LocaleCompare("unsharp",option+1) == 0)
6440 {
6441 i++;
6442 if (i == (ssize_t) argc)
6443 ThrowMogrifyException(OptionError,"MissingArgument",option);
6444 if (IsGeometry(argv[i]) == MagickFalse)
6445 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6446 break;
6447 }
6448 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6449 }
6450 case 'v':
6451 {
6452 if (LocaleCompare("verbose",option+1) == 0)
6453 {
6454 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6455 break;
6456 }
6457 if ((LocaleCompare("version",option+1) == 0) ||
6458 (LocaleCompare("-version",option+1) == 0))
6459 {
6460 ListMagickVersion(stdout);
6461 break;
6462 }
6463 if (LocaleCompare("vignette",option+1) == 0)
6464 {
6465 if (*option == '+')
6466 break;
6467 i++;
6468 if (i == (ssize_t) argc)
6469 ThrowMogrifyException(OptionError,"MissingArgument",option);
6470 if (IsGeometry(argv[i]) == MagickFalse)
6471 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6472 break;
6473 }
6474 if (LocaleCompare("virtual-pixel",option+1) == 0)
6475 {
6476 ssize_t
6477 method;
6478
6479 if (*option == '+')
6480 break;
6481 i++;
6482 if (i == (ssize_t) argc)
6483 ThrowMogrifyException(OptionError,"MissingArgument",option);
6484 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6485 argv[i]);
6486 if (method < 0)
6487 ThrowMogrifyException(OptionError,
6488 "UnrecognizedVirtualPixelMethod",argv[i]);
6489 break;
6490 }
6491 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6492 }
6493 case 'w':
6494 {
6495 if (LocaleCompare("wave",option+1) == 0)
6496 {
6497 i++;
6498 if (i == (ssize_t) argc)
6499 ThrowMogrifyException(OptionError,"MissingArgument",option);
6500 if (IsGeometry(argv[i]) == MagickFalse)
6501 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6502 break;
6503 }
6504 if (LocaleCompare("wavelet-denoise",option+1) == 0)
6505 {
6506 i++;
6507 if (i == (ssize_t) argc)
6508 ThrowMogrifyException(OptionError,"MissingArgument",option);
6509 if (IsGeometry(argv[i]) == MagickFalse)
6510 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6511 break;
6512 }
6513 if (LocaleCompare("weight",option+1) == 0)
6514 {
6515 if (*option == '+')
6516 break;
6517 i++;
6518 if (i == (ssize_t) argc)
6519 ThrowMogrifyException(OptionError,"MissingArgument",option);
6520 break;
6521 }
6522 if (LocaleCompare("word-break",option+1) == 0)
6523 {
6524 ssize_t
6525 word_break;
6526
6527 if (*option == '+')
6528 break;
6529 i++;
6530 if (i == (ssize_t) argc)
6531 ThrowMogrifyException(OptionError,"MissingArgument",option);
6532 word_break=ParseCommandOption(MagickWordBreakOptions,MagickFalse,
6533 argv[i]);
6534 if (word_break < 0)
6535 ThrowMogrifyException(OptionError,"UnrecognizedArgument",argv[i]);
6536 break;
6537 }
6538 if (LocaleCompare("white-balance",option+1) == 0)
6539 break;
6540 if (LocaleCompare("white-point",option+1) == 0)
6541 {
6542 if (*option == '+')
6543 break;
6544 i++;
6545 if (i == (ssize_t) argc)
6546 ThrowMogrifyException(OptionError,"MissingArgument",option);
6547 if (IsGeometry(argv[i]) == MagickFalse)
6548 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6549 break;
6550 }
6551 if (LocaleCompare("white-threshold",option+1) == 0)
6552 {
6553 if (*option == '+')
6554 break;
6555 i++;
6556 if (i == (ssize_t) argc)
6557 ThrowMogrifyException(OptionError,"MissingArgument",option);
6558 if (IsGeometry(argv[i]) == MagickFalse)
6559 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6560 break;
6561 }
6562 if (LocaleCompare("write",option+1) == 0)
6563 {
6564 i++;
6565 if (i == (ssize_t) argc)
6566 ThrowMogrifyException(OptionError,"MissingArgument",option);
6567 break;
6568 }
6569 if (LocaleCompare("write-mask",option+1) == 0)
6570 {
6571 if (*option == '+')
6572 break;
6573 i++;
6574 if (i == (ssize_t) argc)
6575 ThrowMogrifyException(OptionError,"MissingArgument",option);
6576 break;
6577 }
6578 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6579 }
6580 case '?':
6581 break;
6582 default:
6583 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6584 }
6585 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6586 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6587 if (fire != MagickFalse)
6588 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6589 }
6590 if (k != 0)
6591 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6592 if (i != (ssize_t) argc)
6593 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6594 DestroyMogrify();
6595 return(status != 0 ? MagickTrue : MagickFalse);
6596}
6597␌
6598/*
6599%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6600% %
6601% %
6602% %
6603+ M o g r i f y I m a g e I n f o %
6604% %
6605% %
6606% %
6607%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6608%
6609% MogrifyImageInfo() applies image processing settings to the image as
6610% prescribed by command line options.
6611%
6612% The format of the MogrifyImageInfo method is:
6613%
6614% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6615% const char **argv,ExceptionInfo *exception)
6616%
6617% A description of each parameter follows:
6618%
6619% o image_info: the image info..
6620%
6621% o argc: Specifies a pointer to an integer describing the number of
6622% elements in the argument vector.
6623%
6624% o argv: Specifies a pointer to a text array containing the command line
6625% arguments.
6626%
6627% o exception: return any errors or warnings in this structure.
6628%
6629*/
6630WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6631 const int argc,const char **argv,ExceptionInfo *exception)
6632{
6633 const char
6634 *option;
6635
6636 GeometryInfo
6637 geometry_info;
6638
6639 ssize_t
6640 count;
6641
6642 ssize_t
6643 i;
6644
6645 /*
6646 Initialize method variables.
6647 */
6648 assert(image_info != (ImageInfo *) NULL);
6649 assert(image_info->signature == MagickCoreSignature);
6650 if (IsEventLogging() != MagickFalse)
6651 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6652 image_info->filename);
6653 if (argc < 0)
6654 return(MagickTrue);
6655 /*
6656 Set the image settings.
6657 */
6658 for (i=0; i < (ssize_t) argc; i++)
6659 {
6660 option=argv[i];
6661 if (IsCommandOption(option) == MagickFalse)
6662 continue;
6663 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6664 count=MagickMax(count,0L);
6665 if ((i+count) >= (ssize_t) argc)
6666 break;
6667 switch (*(option+1))
6668 {
6669 case 'a':
6670 {
6671 if (LocaleCompare("adjoin",option+1) == 0)
6672 {
6673 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6674 break;
6675 }
6676 if (LocaleCompare("antialias",option+1) == 0)
6677 {
6678 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6679 break;
6680 }
6681 if (LocaleCompare("authenticate",option+1) == 0)
6682 {
6683 if (*option == '+')
6684 (void) DeleteImageOption(image_info,option+1);
6685 else
6686 (void) SetImageOption(image_info,option+1,argv[i+1]);
6687 break;
6688 }
6689 break;
6690 }
6691 case 'b':
6692 {
6693 if (LocaleCompare("background",option+1) == 0)
6694 {
6695 if (*option == '+')
6696 {
6697 (void) DeleteImageOption(image_info,option+1);
6698 (void) QueryColorCompliance(MogrifyBackgroundColor,
6699 AllCompliance,&image_info->background_color,exception);
6700 break;
6701 }
6702 (void) SetImageOption(image_info,option+1,argv[i+1]);
6703 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6704 &image_info->background_color,exception);
6705 break;
6706 }
6707 if (LocaleCompare("bias",option+1) == 0)
6708 {
6709 if (*option == '+')
6710 {
6711 (void) SetImageOption(image_info,"convolve:bias","0.0");
6712 break;
6713 }
6714 (void) SetImageOption(image_info,"convolve:bias",argv[i+1]);
6715 break;
6716 }
6717 if (LocaleCompare("black-point-compensation",option+1) == 0)
6718 {
6719 if (*option == '+')
6720 {
6721 (void) SetImageOption(image_info,option+1,"false");
6722 break;
6723 }
6724 (void) SetImageOption(image_info,option+1,"true");
6725 break;
6726 }
6727 if (LocaleCompare("blue-primary",option+1) == 0)
6728 {
6729 if (*option == '+')
6730 {
6731 (void) SetImageOption(image_info,option+1,"0.0");
6732 break;
6733 }
6734 (void) SetImageOption(image_info,option+1,argv[i+1]);
6735 break;
6736 }
6737 if (LocaleCompare("bordercolor",option+1) == 0)
6738 {
6739 if (*option == '+')
6740 {
6741 (void) DeleteImageOption(image_info,option+1);
6742 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6743 &image_info->border_color,exception);
6744 break;
6745 }
6746 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6747 &image_info->border_color,exception);
6748 (void) SetImageOption(image_info,option+1,argv[i+1]);
6749 break;
6750 }
6751 if (LocaleCompare("box",option+1) == 0)
6752 {
6753 if (*option == '+')
6754 {
6755 (void) SetImageOption(image_info,"undercolor","none");
6756 break;
6757 }
6758 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6759 break;
6760 }
6761 break;
6762 }
6763 case 'c':
6764 {
6765 if (LocaleCompare("cache",option+1) == 0)
6766 {
6767 MagickSizeType
6768 limit;
6769
6770 limit=MagickResourceInfinity;
6771 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6772 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6773 100.0);
6774 (void) SetMagickResourceLimit(MemoryResource,limit);
6775 (void) SetMagickResourceLimit(MapResource,2*limit);
6776 break;
6777 }
6778 if (LocaleCompare("caption",option+1) == 0)
6779 {
6780 if (*option == '+')
6781 {
6782 (void) DeleteImageOption(image_info,option+1);
6783 break;
6784 }
6785 (void) SetImageOption(image_info,option+1,argv[i+1]);
6786 break;
6787 }
6788 if (LocaleCompare("colorspace",option+1) == 0)
6789 {
6790 if (*option == '+')
6791 {
6792 image_info->colorspace=UndefinedColorspace;
6793 (void) SetImageOption(image_info,option+1,"undefined");
6794 break;
6795 }
6796 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6797 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6798 (void) SetImageOption(image_info,option+1,argv[i+1]);
6799 break;
6800 }
6801 if (LocaleCompare("comment",option+1) == 0)
6802 {
6803 if (*option == '+')
6804 {
6805 (void) DeleteImageOption(image_info,option+1);
6806 break;
6807 }
6808 (void) SetImageOption(image_info,option+1,argv[i+1]);
6809 break;
6810 }
6811 if (LocaleCompare("compose",option+1) == 0)
6812 {
6813 if (*option == '+')
6814 {
6815 (void) SetImageOption(image_info,option+1,"undefined");
6816 break;
6817 }
6818 (void) SetImageOption(image_info,option+1,argv[i+1]);
6819 break;
6820 }
6821 if (LocaleCompare("compress",option+1) == 0)
6822 {
6823 if (*option == '+')
6824 {
6825 image_info->compression=UndefinedCompression;
6826 (void) SetImageOption(image_info,option+1,"undefined");
6827 break;
6828 }
6829 image_info->compression=(CompressionType) ParseCommandOption(
6830 MagickCompressOptions,MagickFalse,argv[i+1]);
6831 (void) SetImageOption(image_info,option+1,argv[i+1]);
6832 break;
6833 }
6834 break;
6835 }
6836 case 'd':
6837 {
6838 if (LocaleCompare("debug",option+1) == 0)
6839 {
6840 if (*option == '+')
6841 (void) SetLogEventMask("none");
6842 else
6843 (void) SetLogEventMask(argv[i+1]);
6844 image_info->debug=IsEventLogging();
6845 break;
6846 }
6847 if (LocaleCompare("define",option+1) == 0)
6848 {
6849 if (*option == '+')
6850 {
6851 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6852 (void) DeleteImageRegistry(argv[i+1]+9);
6853 else
6854 (void) DeleteImageOption(image_info,argv[i+1]);
6855 break;
6856 }
6857 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6858 {
6859 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6860 exception);
6861 break;
6862 }
6863 (void) DefineImageOption(image_info,argv[i+1]);
6864 break;
6865 }
6866 if (LocaleCompare("delay",option+1) == 0)
6867 {
6868 if (*option == '+')
6869 {
6870 (void) SetImageOption(image_info,option+1,"0");
6871 break;
6872 }
6873 (void) SetImageOption(image_info,option+1,argv[i+1]);
6874 break;
6875 }
6876 if (LocaleCompare("density",option+1) == 0)
6877 {
6878 /*
6879 Set image density.
6880 */
6881 if (*option == '+')
6882 {
6883 if (image_info->density != (char *) NULL)
6884 image_info->density=DestroyString(image_info->density);
6885 (void) SetImageOption(image_info,option+1,"72");
6886 break;
6887 }
6888 (void) CloneString(&image_info->density,argv[i+1]);
6889 (void) SetImageOption(image_info,option+1,argv[i+1]);
6890 break;
6891 }
6892 if (LocaleCompare("depth",option+1) == 0)
6893 {
6894 if (*option == '+')
6895 {
6896 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6897 break;
6898 }
6899 image_info->depth=StringToUnsignedLong(argv[i+1]);
6900 break;
6901 }
6902 if (LocaleCompare("direction",option+1) == 0)
6903 {
6904 if (*option == '+')
6905 {
6906 (void) SetImageOption(image_info,option+1,"undefined");
6907 break;
6908 }
6909 (void) SetImageOption(image_info,option+1,argv[i+1]);
6910 break;
6911 }
6912 if (LocaleCompare("display",option+1) == 0)
6913 {
6914 if (*option == '+')
6915 {
6916 if (image_info->server_name != (char *) NULL)
6917 image_info->server_name=DestroyString(
6918 image_info->server_name);
6919 break;
6920 }
6921 (void) CloneString(&image_info->server_name,argv[i+1]);
6922 break;
6923 }
6924 if (LocaleCompare("dispose",option+1) == 0)
6925 {
6926 if (*option == '+')
6927 {
6928 (void) SetImageOption(image_info,option+1,"undefined");
6929 break;
6930 }
6931 (void) SetImageOption(image_info,option+1,argv[i+1]);
6932 break;
6933 }
6934 if (LocaleCompare("dither",option+1) == 0)
6935 {
6936 if (*option == '+')
6937 {
6938 image_info->dither=MagickFalse;
6939 (void) SetImageOption(image_info,option+1,"none");
6940 break;
6941 }
6942 (void) SetImageOption(image_info,option+1,argv[i+1]);
6943 image_info->dither=MagickTrue;
6944 break;
6945 }
6946 break;
6947 }
6948 case 'e':
6949 {
6950 if (LocaleCompare("encoding",option+1) == 0)
6951 {
6952 if (*option == '+')
6953 {
6954 (void) SetImageOption(image_info,option+1,"undefined");
6955 break;
6956 }
6957 (void) SetImageOption(image_info,option+1,argv[i+1]);
6958 break;
6959 }
6960 if (LocaleCompare("endian",option+1) == 0)
6961 {
6962 if (*option == '+')
6963 {
6964 image_info->endian=UndefinedEndian;
6965 (void) SetImageOption(image_info,option+1,"undefined");
6966 break;
6967 }
6968 image_info->endian=(EndianType) ParseCommandOption(
6969 MagickEndianOptions,MagickFalse,argv[i+1]);
6970 (void) SetImageOption(image_info,option+1,argv[i+1]);
6971 break;
6972 }
6973 if (LocaleCompare("extract",option+1) == 0)
6974 {
6975 /*
6976 Set image extract geometry.
6977 */
6978 if (*option == '+')
6979 {
6980 if (image_info->extract != (char *) NULL)
6981 image_info->extract=DestroyString(image_info->extract);
6982 break;
6983 }
6984 (void) CloneString(&image_info->extract,argv[i+1]);
6985 break;
6986 }
6987 break;
6988 }
6989 case 'f':
6990 {
6991 if (LocaleCompare("family",option+1) == 0)
6992 {
6993 if (*option != '+')
6994 (void) SetImageOption(image_info,option+1,argv[i+1]);
6995 break;
6996 }
6997 if (LocaleCompare("fill",option+1) == 0)
6998 {
6999 if (*option == '+')
7000 {
7001 (void) SetImageOption(image_info,option+1,"none");
7002 break;
7003 }
7004 (void) SetImageOption(image_info,option+1,argv[i+1]);
7005 break;
7006 }
7007 if (LocaleCompare("filter",option+1) == 0)
7008 {
7009 if (*option == '+')
7010 {
7011 (void) SetImageOption(image_info,option+1,"undefined");
7012 break;
7013 }
7014 (void) SetImageOption(image_info,option+1,argv[i+1]);
7015 break;
7016 }
7017 if (LocaleCompare("font",option+1) == 0)
7018 {
7019 if (*option == '+')
7020 {
7021 if (image_info->font != (char *) NULL)
7022 image_info->font=DestroyString(image_info->font);
7023 break;
7024 }
7025 (void) CloneString(&image_info->font,argv[i+1]);
7026 break;
7027 }
7028 if (LocaleCompare("format",option+1) == 0)
7029 {
7030 (void) SetImageOption(image_info,option+1,argv[i+1]);
7031 break;
7032 }
7033 if (LocaleCompare("fuzz",option+1) == 0)
7034 {
7035 if (*option == '+')
7036 {
7037 image_info->fuzz=0.0;
7038 (void) SetImageOption(image_info,option+1,"0");
7039 break;
7040 }
7041 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
7042 QuantumRange+1.0);
7043 (void) SetImageOption(image_info,option+1,argv[i+1]);
7044 break;
7045 }
7046 break;
7047 }
7048 case 'g':
7049 {
7050 if (LocaleCompare("gravity",option+1) == 0)
7051 {
7052 if (*option == '+')
7053 {
7054 (void) SetImageOption(image_info,option+1,"undefined");
7055 break;
7056 }
7057 (void) SetImageOption(image_info,option+1,argv[i+1]);
7058 break;
7059 }
7060 if (LocaleCompare("green-primary",option+1) == 0)
7061 {
7062 if (*option == '+')
7063 {
7064 (void) SetImageOption(image_info,option+1,"0.0");
7065 break;
7066 }
7067 (void) SetImageOption(image_info,option+1,argv[i+1]);
7068 break;
7069 }
7070 break;
7071 }
7072 case 'i':
7073 {
7074 if (LocaleCompare("intensity",option+1) == 0)
7075 {
7076 if (*option == '+')
7077 {
7078 (void) SetImageOption(image_info,option+1,"undefined");
7079 break;
7080 }
7081 (void) SetImageOption(image_info,option+1,argv[i+1]);
7082 break;
7083 }
7084 if (LocaleCompare("intent",option+1) == 0)
7085 {
7086 if (*option == '+')
7087 {
7088 (void) SetImageOption(image_info,option+1,"undefined");
7089 break;
7090 }
7091 (void) SetImageOption(image_info,option+1,argv[i+1]);
7092 break;
7093 }
7094 if (LocaleCompare("interlace",option+1) == 0)
7095 {
7096 if (*option == '+')
7097 {
7098 image_info->interlace=UndefinedInterlace;
7099 (void) SetImageOption(image_info,option+1,"undefined");
7100 break;
7101 }
7102 image_info->interlace=(InterlaceType) ParseCommandOption(
7103 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7104 (void) SetImageOption(image_info,option+1,argv[i+1]);
7105 break;
7106 }
7107 if (LocaleCompare("interline-spacing",option+1) == 0)
7108 {
7109 if (*option == '+')
7110 {
7111 (void) SetImageOption(image_info,option+1,"undefined");
7112 break;
7113 }
7114 (void) SetImageOption(image_info,option+1,argv[i+1]);
7115 break;
7116 }
7117 if (LocaleCompare("interpolate",option+1) == 0)
7118 {
7119 if (*option == '+')
7120 {
7121 (void) SetImageOption(image_info,option+1,"undefined");
7122 break;
7123 }
7124 (void) SetImageOption(image_info,option+1,argv[i+1]);
7125 break;
7126 }
7127 if (LocaleCompare("interword-spacing",option+1) == 0)
7128 {
7129 if (*option == '+')
7130 {
7131 (void) SetImageOption(image_info,option+1,"undefined");
7132 break;
7133 }
7134 (void) SetImageOption(image_info,option+1,argv[i+1]);
7135 break;
7136 }
7137 break;
7138 }
7139 case 'k':
7140 {
7141 if (LocaleCompare("kerning",option+1) == 0)
7142 {
7143 if (*option == '+')
7144 {
7145 (void) SetImageOption(image_info,option+1,"undefined");
7146 break;
7147 }
7148 (void) SetImageOption(image_info,option+1,argv[i+1]);
7149 break;
7150 }
7151 break;
7152 }
7153 case 'l':
7154 {
7155 if (LocaleCompare("label",option+1) == 0)
7156 {
7157 if (*option == '+')
7158 {
7159 (void) DeleteImageOption(image_info,option+1);
7160 break;
7161 }
7162 (void) SetImageOption(image_info,option+1,argv[i+1]);
7163 break;
7164 }
7165 if (LocaleCompare("limit",option+1) == 0)
7166 {
7167 MagickSizeType
7168 limit;
7169
7170 ResourceType
7171 type;
7172
7173 if (*option == '+')
7174 break;
7175 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7176 MagickFalse,argv[i+1]);
7177 limit=MagickResourceInfinity;
7178 if (LocaleCompare("unlimited",argv[i+2]) != 0)
7179 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7180 if (type == TimeResource)
7181 limit=(MagickSizeType) ParseMagickTimeToLive(argv[i+2]);
7182 (void) SetMagickResourceLimit(type,limit);
7183 break;
7184 }
7185 if (LocaleCompare("list",option+1) == 0)
7186 {
7187 ssize_t
7188 list;
7189
7190 /*
7191 Display configuration list.
7192 */
7193 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7194 switch (list)
7195 {
7196 case MagickCoderOptions:
7197 {
7198 (void) ListCoderInfo((FILE *) NULL,exception);
7199 break;
7200 }
7201 case MagickColorOptions:
7202 {
7203 (void) ListColorInfo((FILE *) NULL,exception);
7204 break;
7205 }
7206 case MagickConfigureOptions:
7207 {
7208 (void) ListConfigureInfo((FILE *) NULL,exception);
7209 break;
7210 }
7211 case MagickDelegateOptions:
7212 {
7213 (void) ListDelegateInfo((FILE *) NULL,exception);
7214 break;
7215 }
7216 case MagickFontOptions:
7217 {
7218 (void) ListTypeInfo((FILE *) NULL,exception);
7219 break;
7220 }
7221 case MagickFormatOptions:
7222 {
7223 (void) ListMagickInfo((FILE *) NULL,exception);
7224 break;
7225 }
7226 case MagickLocaleOptions:
7227 {
7228 (void) ListLocaleInfo((FILE *) NULL,exception);
7229 break;
7230 }
7231 case MagickLogOptions:
7232 {
7233 (void) ListLogInfo((FILE *) NULL,exception);
7234 break;
7235 }
7236 case MagickMagicOptions:
7237 {
7238 (void) ListMagicInfo((FILE *) NULL,exception);
7239 break;
7240 }
7241 case MagickMimeOptions:
7242 {
7243 (void) ListMimeInfo((FILE *) NULL,exception);
7244 break;
7245 }
7246 case MagickModuleOptions:
7247 {
7248 (void) ListModuleInfo((FILE *) NULL,exception);
7249 break;
7250 }
7251 case MagickPagesizeOptions:
7252 {
7253 (void) ListPagesizes((FILE *) NULL,exception);
7254 break;
7255 }
7256 case MagickPolicyOptions:
7257 {
7258 (void) ListPolicyInfo((FILE *) NULL,exception);
7259 break;
7260 }
7261 case MagickResourceOptions:
7262 {
7263 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7264 break;
7265 }
7266 case MagickThresholdOptions:
7267 {
7268 (void) ListThresholdMaps((FILE *) NULL,exception);
7269 break;
7270 }
7271 default:
7272 {
7273 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7274 exception);
7275 break;
7276 }
7277 }
7278 break;
7279 }
7280 if (LocaleCompare("log",option+1) == 0)
7281 {
7282 if (*option == '+')
7283 break;
7284 (void) SetLogFormat(argv[i+1]);
7285 break;
7286 }
7287 if (LocaleCompare("loop",option+1) == 0)
7288 {
7289 if (*option == '+')
7290 {
7291 (void) SetImageOption(image_info,option+1,"0");
7292 break;
7293 }
7294 (void) SetImageOption(image_info,option+1,argv[i+1]);
7295 break;
7296 }
7297 break;
7298 }
7299 case 'm':
7300 {
7301 if (LocaleCompare("matte",option+1) == 0)
7302 {
7303 if (*option == '+')
7304 {
7305 (void) SetImageOption(image_info,option+1,"false");
7306 break;
7307 }
7308 (void) SetImageOption(image_info,option+1,"true");
7309 break;
7310 }
7311 if (LocaleCompare("mattecolor",option+1) == 0)
7312 {
7313 if (*option == '+')
7314 {
7315 (void) SetImageOption(image_info,option+1,argv[i+1]);
7316 (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7317 &image_info->matte_color,exception);
7318 break;
7319 }
7320 (void) SetImageOption(image_info,option+1,argv[i+1]);
7321 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7322 &image_info->matte_color,exception);
7323 break;
7324 }
7325 if (LocaleCompare("metric",option+1) == 0)
7326 {
7327 if (*option == '+')
7328 (void) DeleteImageOption(image_info,option+1);
7329 else
7330 (void) SetImageOption(image_info,option+1,argv[i+1]);
7331 break;
7332 }
7333 if (LocaleCompare("monitor",option+1) == 0)
7334 {
7335 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7336 (void *) NULL);
7337 break;
7338 }
7339 if (LocaleCompare("monochrome",option+1) == 0)
7340 {
7341 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7342 break;
7343 }
7344 break;
7345 }
7346 case 'o':
7347 {
7348 if (LocaleCompare("orient",option+1) == 0)
7349 {
7350 if (*option == '+')
7351 {
7352 image_info->orientation=UndefinedOrientation;
7353 (void) SetImageOption(image_info,option+1,"undefined");
7354 break;
7355 }
7356 image_info->orientation=(OrientationType) ParseCommandOption(
7357 MagickOrientationOptions,MagickFalse,argv[i+1]);
7358 (void) SetImageOption(image_info,option+1,argv[i+1]);
7359 break;
7360 }
7361 break;
7362 }
7363 case 'p':
7364 {
7365 if (LocaleCompare("page",option+1) == 0)
7366 {
7367 char
7368 *canonical_page,
7369 page[MagickPathExtent];
7370
7371 const char
7372 *image_option;
7373
7374 MagickStatusType
7375 flags;
7376
7377 RectangleInfo
7378 geometry;
7379
7380 if (*option == '+')
7381 {
7382 (void) DeleteImageOption(image_info,option+1);
7383 (void) CloneString(&image_info->page,(char *) NULL);
7384 break;
7385 }
7386 (void) memset(&geometry,0,sizeof(geometry));
7387 image_option=GetImageOption(image_info,"page");
7388 if (image_option != (const char *) NULL)
7389 flags=ParseAbsoluteGeometry(image_option,&geometry);
7390 canonical_page=GetPageGeometry(argv[i+1]);
7391 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7392 canonical_page=DestroyString(canonical_page);
7393 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu",
7394 (unsigned long) geometry.width,(unsigned long) geometry.height);
7395 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7396 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu%+ld%+ld",
7397 (unsigned long) geometry.width,(unsigned long) geometry.height,
7398 (long) geometry.x,(long) geometry.y);
7399 (void) SetImageOption(image_info,option+1,page);
7400 (void) CloneString(&image_info->page,page);
7401 break;
7402 }
7403 if (LocaleCompare("ping",option+1) == 0)
7404 {
7405 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7406 break;
7407 }
7408 if (LocaleCompare("pointsize",option+1) == 0)
7409 {
7410 if (*option == '+')
7411 geometry_info.rho=0.0;
7412 else
7413 (void) ParseGeometry(argv[i+1],&geometry_info);
7414 image_info->pointsize=geometry_info.rho;
7415 break;
7416 }
7417 if (LocaleCompare("precision",option+1) == 0)
7418 {
7419 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7420 break;
7421 }
7422 break;
7423 }
7424 case 'q':
7425 {
7426 if (LocaleCompare("quality",option+1) == 0)
7427 {
7428 /*
7429 Set image compression quality.
7430 */
7431 if (*option == '+')
7432 {
7433 image_info->quality=UndefinedCompressionQuality;
7434 (void) SetImageOption(image_info,option+1,"0");
7435 break;
7436 }
7437 image_info->quality=StringToUnsignedLong(argv[i+1]);
7438 (void) SetImageOption(image_info,option+1,argv[i+1]);
7439 break;
7440 }
7441 if (LocaleCompare("quiet",option+1) == 0)
7442 {
7443 static WarningHandler
7444 warning_handler = (WarningHandler) NULL;
7445
7446 if (*option == '+')
7447 {
7448 /*
7449 Restore error or warning messages.
7450 */
7451 warning_handler=SetWarningHandler(warning_handler);
7452 break;
7453 }
7454 /*
7455 Suppress error or warning messages.
7456 */
7457 warning_handler=SetWarningHandler((WarningHandler) NULL);
7458 break;
7459 }
7460 break;
7461 }
7462 case 'r':
7463 {
7464 if (LocaleCompare("red-primary",option+1) == 0)
7465 {
7466 if (*option == '+')
7467 {
7468 (void) SetImageOption(image_info,option+1,"0.0");
7469 break;
7470 }
7471 (void) SetImageOption(image_info,option+1,argv[i+1]);
7472 break;
7473 }
7474 break;
7475 }
7476 case 's':
7477 {
7478 if (LocaleCompare("sampling-factor",option+1) == 0)
7479 {
7480 /*
7481 Set image sampling factor.
7482 */
7483 if (*option == '+')
7484 {
7485 if (image_info->sampling_factor != (char *) NULL)
7486 image_info->sampling_factor=DestroyString(
7487 image_info->sampling_factor);
7488 break;
7489 }
7490 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7491 break;
7492 }
7493 if (LocaleCompare("scene",option+1) == 0)
7494 {
7495 /*
7496 Set image scene.
7497 */
7498 if (*option == '+')
7499 {
7500 image_info->scene=0;
7501 (void) SetImageOption(image_info,option+1,"0");
7502 break;
7503 }
7504 image_info->scene=StringToUnsignedLong(argv[i+1]);
7505 (void) SetImageOption(image_info,option+1,argv[i+1]);
7506 break;
7507 }
7508 if (LocaleCompare("seed",option+1) == 0)
7509 {
7510 unsigned long
7511 seed;
7512
7513 if (*option == '+')
7514 {
7515 seed=(unsigned long) time((time_t *) NULL);
7516 SetRandomSecretKey(seed);
7517 break;
7518 }
7519 seed=StringToUnsignedLong(argv[i+1]);
7520 SetRandomSecretKey(seed);
7521 break;
7522 }
7523 if (LocaleCompare("size",option+1) == 0)
7524 {
7525 if (*option == '+')
7526 {
7527 if (image_info->size != (char *) NULL)
7528 image_info->size=DestroyString(image_info->size);
7529 break;
7530 }
7531 (void) CloneString(&image_info->size,argv[i+1]);
7532 break;
7533 }
7534 if (LocaleCompare("stroke",option+1) == 0)
7535 {
7536 if (*option == '+')
7537 {
7538 (void) SetImageOption(image_info,option+1,"none");
7539 break;
7540 }
7541 (void) SetImageOption(image_info,option+1,argv[i+1]);
7542 break;
7543 }
7544 if (LocaleCompare("strokewidth",option+1) == 0)
7545 {
7546 if (*option == '+')
7547 (void) SetImageOption(image_info,option+1,"0");
7548 else
7549 (void) SetImageOption(image_info,option+1,argv[i+1]);
7550 break;
7551 }
7552 if (LocaleCompare("style",option+1) == 0)
7553 {
7554 if (*option == '+')
7555 {
7556 (void) SetImageOption(image_info,option+1,"none");
7557 break;
7558 }
7559 (void) SetImageOption(image_info,option+1,argv[i+1]);
7560 break;
7561 }
7562 if (LocaleCompare("synchronize",option+1) == 0)
7563 {
7564 if (*option == '+')
7565 {
7566 image_info->synchronize=MagickFalse;
7567 break;
7568 }
7569 image_info->synchronize=MagickTrue;
7570 break;
7571 }
7572 break;
7573 }
7574 case 't':
7575 {
7576 if (LocaleCompare("taint",option+1) == 0)
7577 {
7578 if (*option == '+')
7579 {
7580 (void) SetImageOption(image_info,option+1,"false");
7581 break;
7582 }
7583 (void) SetImageOption(image_info,option+1,"true");
7584 break;
7585 }
7586 if (LocaleCompare("texture",option+1) == 0)
7587 {
7588 if (*option == '+')
7589 {
7590 if (image_info->texture != (char *) NULL)
7591 image_info->texture=DestroyString(image_info->texture);
7592 break;
7593 }
7594 (void) CloneString(&image_info->texture,argv[i+1]);
7595 break;
7596 }
7597 if (LocaleCompare("tile-offset",option+1) == 0)
7598 {
7599 if (*option == '+')
7600 (void) SetImageOption(image_info,option+1,"0");
7601 else
7602 (void) SetImageOption(image_info,option+1,argv[i+1]);
7603 break;
7604 }
7605 if (LocaleCompare("transparent-color",option+1) == 0)
7606 {
7607 if (*option == '+')
7608 {
7609 (void) QueryColorCompliance("none",AllCompliance,
7610 &image_info->transparent_color,exception);
7611 (void) SetImageOption(image_info,option+1,"none");
7612 break;
7613 }
7614 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7615 &image_info->transparent_color,exception);
7616 (void) SetImageOption(image_info,option+1,argv[i+1]);
7617 break;
7618 }
7619 if (LocaleCompare("type",option+1) == 0)
7620 {
7621 if (*option == '+')
7622 {
7623 image_info->type=UndefinedType;
7624 (void) SetImageOption(image_info,option+1,"undefined");
7625 break;
7626 }
7627 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7628 MagickFalse,argv[i+1]);
7629 (void) SetImageOption(image_info,option+1,argv[i+1]);
7630 break;
7631 }
7632 break;
7633 }
7634 case 'u':
7635 {
7636 if (LocaleCompare("undercolor",option+1) == 0)
7637 {
7638 if (*option == '+')
7639 (void) DeleteImageOption(image_info,option+1);
7640 else
7641 (void) SetImageOption(image_info,option+1,argv[i+1]);
7642 break;
7643 }
7644 if (LocaleCompare("units",option+1) == 0)
7645 {
7646 if (*option == '+')
7647 {
7648 image_info->units=UndefinedResolution;
7649 (void) SetImageOption(image_info,option+1,"undefined");
7650 break;
7651 }
7652 image_info->units=(ResolutionType) ParseCommandOption(
7653 MagickResolutionOptions,MagickFalse,argv[i+1]);
7654 (void) SetImageOption(image_info,option+1,argv[i+1]);
7655 break;
7656 }
7657 break;
7658 }
7659 case 'v':
7660 {
7661 if (LocaleCompare("verbose",option+1) == 0)
7662 {
7663 if (*option == '+')
7664 {
7665 image_info->verbose=MagickFalse;
7666 break;
7667 }
7668 image_info->verbose=MagickTrue;
7669 image_info->ping=MagickFalse;
7670 break;
7671 }
7672 if (LocaleCompare("virtual-pixel",option+1) == 0)
7673 {
7674 if (*option == '+')
7675 (void) SetImageOption(image_info,option+1,"undefined");
7676 else
7677 (void) SetImageOption(image_info,option+1,argv[i+1]);
7678 break;
7679 }
7680 break;
7681 }
7682 case 'w':
7683 {
7684 if (LocaleCompare("weight",option+1) == 0)
7685 {
7686 if (*option == '+')
7687 (void) SetImageOption(image_info,option+1,"0");
7688 else
7689 (void) SetImageOption(image_info,option+1,argv[i+1]);
7690 break;
7691 }
7692 if (LocaleCompare("white-point",option+1) == 0)
7693 {
7694 if (*option == '+')
7695 (void) SetImageOption(image_info,option+1,"0.0");
7696 else
7697 (void) SetImageOption(image_info,option+1,argv[i+1]);
7698 break;
7699 }
7700 if (LocaleCompare("word-break",option+1) == 0)
7701 {
7702 if (*option == '+')
7703 {
7704 (void) SetImageOption(image_info,option+1,"undefined");
7705 break;
7706 }
7707 (void) SetImageOption(image_info,option+1,argv[i+1]);
7708 break;
7709 }
7710 break;
7711 }
7712 default:
7713 break;
7714 }
7715 i+=count;
7716 }
7717 return(MagickTrue);
7718}
7719␌
7720/*
7721%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7722% %
7723% %
7724% %
7725+ M o g r i f y I m a g e L i s t %
7726% %
7727% %
7728% %
7729%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7730%
7731% MogrifyImageList() applies any command line options that might affect the
7732% entire image list (e.g. -append, -coalesce, etc.).
7733%
7734% The format of the MogrifyImage method is:
7735%
7736% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7737% const char **argv,Image **images,ExceptionInfo *exception)
7738%
7739% A description of each parameter follows:
7740%
7741% o image_info: the image info..
7742%
7743% o argc: Specifies a pointer to an integer describing the number of
7744% elements in the argument vector.
7745%
7746% o argv: Specifies a pointer to a text array containing the command line
7747% arguments.
7748%
7749% o images: pointer to pointer of the first image in image list.
7750%
7751% o exception: return any errors or warnings in this structure.
7752%
7753*/
7754WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7755 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7756{
7757 const char
7758 *option;
7759
7760 ImageInfo
7761 *mogrify_info;
7762
7763 MagickStatusType
7764 status;
7765
7766 PixelInterpolateMethod
7767 interpolate_method;
7768
7769 QuantizeInfo
7770 *quantize_info;
7771
7772 ssize_t
7773 i;
7774
7775 ssize_t
7776 count,
7777 index;
7778
7779 /*
7780 Apply options to the image list.
7781 */
7782 assert(image_info != (ImageInfo *) NULL);
7783 assert(image_info->signature == MagickCoreSignature);
7784 assert(images != (Image **) NULL);
7785 assert((*images)->previous == (Image *) NULL);
7786 assert((*images)->signature == MagickCoreSignature);
7787 if (IsEventLogging() != MagickFalse)
7788 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7789 (*images)->filename);
7790 if ((argc <= 0) || (*argv == (char *) NULL))
7791 return(MagickTrue);
7792 interpolate_method=UndefinedInterpolatePixel;
7793 mogrify_info=CloneImageInfo(image_info);
7794 quantize_info=AcquireQuantizeInfo(mogrify_info);
7795 status=MagickTrue;
7796 for (i=0; i < (ssize_t) argc; i++)
7797 {
7798 if (*images == (Image *) NULL)
7799 break;
7800 option=argv[i];
7801 if (IsCommandOption(option) == MagickFalse)
7802 continue;
7803 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7804 count=MagickMax(count,0L);
7805 if ((i+count) >= (ssize_t) argc)
7806 break;
7807 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7808 switch (*(option+1))
7809 {
7810 case 'a':
7811 {
7812 if (LocaleCompare("affinity",option+1) == 0)
7813 {
7814 (void) SyncImagesSettings(mogrify_info,*images,exception);
7815 if (*option == '+')
7816 {
7817 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7818 exception);
7819 break;
7820 }
7821 i++;
7822 break;
7823 }
7824 if (LocaleCompare("append",option+1) == 0)
7825 {
7826 Image
7827 *append_image;
7828
7829 (void) SyncImagesSettings(mogrify_info,*images,exception);
7830 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7831 MagickFalse,exception);
7832 if (append_image == (Image *) NULL)
7833 {
7834 status=MagickFalse;
7835 break;
7836 }
7837 *images=DestroyImageList(*images);
7838 *images=append_image;
7839 break;
7840 }
7841 if (LocaleCompare("average",option+1) == 0)
7842 {
7843 Image
7844 *average_image;
7845
7846 /*
7847 Average an image sequence (deprecated).
7848 */
7849 (void) SyncImagesSettings(mogrify_info,*images,exception);
7850 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7851 exception);
7852 if (average_image == (Image *) NULL)
7853 {
7854 status=MagickFalse;
7855 break;
7856 }
7857 *images=DestroyImageList(*images);
7858 *images=average_image;
7859 break;
7860 }
7861 break;
7862 }
7863 case 'c':
7864 {
7865 if (LocaleCompare("channel-fx",option+1) == 0)
7866 {
7867 Image
7868 *channel_image;
7869
7870 (void) SyncImagesSettings(mogrify_info,*images,exception);
7871 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7872 if (channel_image == (Image *) NULL)
7873 {
7874 status=MagickFalse;
7875 break;
7876 }
7877 *images=DestroyImageList(*images);
7878 *images=channel_image;
7879 break;
7880 }
7881 if (LocaleCompare("clut",option+1) == 0)
7882 {
7883 Image
7884 *clut_image,
7885 *image;
7886
7887 (void) SyncImagesSettings(mogrify_info,*images,exception);
7888 image=RemoveFirstImageFromList(images);
7889 clut_image=RemoveFirstImageFromList(images);
7890 if (clut_image == (Image *) NULL)
7891 {
7892 (void) ThrowMagickException(exception,GetMagickModule(),
7893 OptionError,"ImageSequenceRequired","`%s'",option);
7894 image=DestroyImage(image);
7895 status=MagickFalse;
7896 break;
7897 }
7898 (void) ClutImage(image,clut_image,interpolate_method,exception);
7899 clut_image=DestroyImage(clut_image);
7900 *images=DestroyImageList(*images);
7901 *images=image;
7902 break;
7903 }
7904 if (LocaleCompare("coalesce",option+1) == 0)
7905 {
7906 Image
7907 *coalesce_image;
7908
7909 (void) SyncImagesSettings(mogrify_info,*images,exception);
7910 coalesce_image=CoalesceImages(*images,exception);
7911 if (coalesce_image == (Image *) NULL)
7912 {
7913 status=MagickFalse;
7914 break;
7915 }
7916 *images=DestroyImageList(*images);
7917 *images=coalesce_image;
7918 break;
7919 }
7920 if (LocaleCompare("combine",option+1) == 0)
7921 {
7922 ColorspaceType
7923 colorspace;
7924
7925 Image
7926 *combine_image;
7927
7928 (void) SyncImagesSettings(mogrify_info,*images,exception);
7929 colorspace=(*images)->colorspace;
7930 if ((*images)->number_channels < GetImageListLength(*images))
7931 colorspace=sRGBColorspace;
7932 if (*option == '+')
7933 colorspace=(ColorspaceType) ParseCommandOption(
7934 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7935 combine_image=CombineImages(*images,colorspace,exception);
7936 if (combine_image == (Image *) NULL)
7937 {
7938 status=MagickFalse;
7939 break;
7940 }
7941 *images=DestroyImageList(*images);
7942 *images=combine_image;
7943 break;
7944 }
7945 if (LocaleCompare("compare",option+1) == 0)
7946 {
7947 double
7948 distortion;
7949
7950 Image
7951 *difference_image,
7952 *image,
7953 *reconstruct_image;
7954
7955 MetricType
7956 metric;
7957
7958 /*
7959 Mathematically and visually annotate the difference between an
7960 image and its reconstruction.
7961 */
7962 (void) SyncImagesSettings(mogrify_info,*images,exception);
7963 image=RemoveFirstImageFromList(images);
7964 reconstruct_image=RemoveFirstImageFromList(images);
7965 if (reconstruct_image == (Image *) NULL)
7966 {
7967 (void) ThrowMagickException(exception,GetMagickModule(),
7968 OptionError,"ImageSequenceRequired","`%s'",option);
7969 image=DestroyImage(image);
7970 status=MagickFalse;
7971 break;
7972 }
7973 metric=UndefinedErrorMetric;
7974 option=GetImageOption(mogrify_info,"metric");
7975 if (option != (const char *) NULL)
7976 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7977 MagickFalse,option);
7978 difference_image=CompareImages(image,reconstruct_image,metric,
7979 &distortion,exception);
7980 if (difference_image == (Image *) NULL)
7981 break;
7982 reconstruct_image=DestroyImage(reconstruct_image);
7983 image=DestroyImage(image);
7984 if (*images != (Image *) NULL)
7985 *images=DestroyImageList(*images);
7986 *images=difference_image;
7987 break;
7988 }
7989 if (LocaleCompare("complex",option+1) == 0)
7990 {
7991 ComplexOperator
7992 op;
7993
7994 Image
7995 *complex_images;
7996
7997 (void) SyncImageSettings(mogrify_info,*images,exception);
7998 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7999 MagickFalse,argv[i+1]);
8000 complex_images=ComplexImages(*images,op,exception);
8001 if (complex_images == (Image *) NULL)
8002 {
8003 status=MagickFalse;
8004 break;
8005 }
8006 *images=DestroyImageList(*images);
8007 *images=complex_images;
8008 break;
8009 }
8010 if (LocaleCompare("composite",option+1) == 0)
8011 {
8012 CompositeOperator
8013 compose;
8014
8015 const char*
8016 value;
8017
8018 MagickBooleanType
8019 clip_to_self;
8020
8021 Image
8022 *mask_image,
8023 *new_images,
8024 *source_image;
8025
8026 RectangleInfo
8027 geometry;
8028
8029 /* Compose value from "-compose" option only */
8030 (void) SyncImageSettings(mogrify_info,*images,exception);
8031 value=GetImageOption(mogrify_info,"compose");
8032 if (value == (const char *) NULL)
8033 compose=OverCompositeOp; /* use Over not source_image->compose */
8034 else
8035 compose=(CompositeOperator) ParseCommandOption(
8036 MagickComposeOptions,MagickFalse,value);
8037
8038 /* Get "clip-to-self" expert setting (false is normal) */
8039 clip_to_self=GetCompositeClipToSelf(compose);
8040 value=GetImageOption(mogrify_info,"compose:clip-to-self");
8041 if (value != (const char *) NULL)
8042 clip_to_self=IsStringTrue(value);
8043 value=GetImageOption(mogrify_info,"compose:outside-overlay");
8044 if (value != (const char *) NULL)
8045 clip_to_self=IsStringFalse(value); /* deprecated */
8046
8047 new_images=RemoveFirstImageFromList(images);
8048 source_image=RemoveFirstImageFromList(images);
8049 if (source_image == (Image *) NULL)
8050 {
8051 (void) ThrowMagickException(exception,GetMagickModule(),
8052 OptionError,"ImageSequenceRequired","`%s'",option);
8053 new_images=DestroyImage(new_images);
8054 status=MagickFalse;
8055 break;
8056 }
8057
8058 /* FUTURE: this should not be here! - should be part of -geometry */
8059 if (source_image->geometry != (char *) NULL)
8060 {
8061 RectangleInfo
8062 resize_geometry;
8063
8064 (void) ParseRegionGeometry(source_image,source_image->geometry,
8065 &resize_geometry,exception);
8066 if ((source_image->columns != resize_geometry.width) ||
8067 (source_image->rows != resize_geometry.height))
8068 {
8069 Image
8070 *resize_image;
8071
8072 resize_image=ResizeImage(source_image,resize_geometry.width,
8073 resize_geometry.height,source_image->filter,exception);
8074 if (resize_image != (Image *) NULL)
8075 {
8076 source_image=DestroyImage(source_image);
8077 source_image=resize_image;
8078 }
8079 }
8080 }
8081 SetGeometry(source_image,&geometry);
8082 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
8083 GravityAdjustGeometry(new_images->columns,new_images->rows,
8084 new_images->gravity,&geometry);
8085 mask_image=RemoveFirstImageFromList(images);
8086 if (mask_image == (Image *) NULL)
8087 status&=(MagickStatusType) CompositeImage(new_images,source_image,
8088 compose,clip_to_self,geometry.x,geometry.y,exception);
8089 else
8090 {
8091 Image
8092 *canvas_image;
8093
8094 canvas_image=CloneImage(new_images,0,0,MagickTrue,exception);
8095 if (canvas_image == (Image *) NULL)
8096 break;
8097 switch (compose)
8098 {
8099 case BlendCompositeOp:
8100 {
8101 status&=(MagickStatusType) CompositeImage(new_images,
8102 source_image,compose,clip_to_self,geometry.x,geometry.y,
8103 exception);
8104 status&=(MagickStatusType) CompositeImage(new_images,
8105 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8106 break;
8107 }
8108 case DisplaceCompositeOp:
8109 case DistortCompositeOp:
8110 {
8111 status&=(MagickStatusType) CompositeImage(source_image,
8112 mask_image,CopyGreenCompositeOp,MagickTrue,0,0,exception);
8113 (void) SetImageColorspace(source_image,sRGBColorspace,
8114 exception);
8115 status&=(MagickStatusType) CompositeImage(new_images,
8116 source_image,compose,clip_to_self,geometry.x,geometry.y,
8117 exception);
8118 break;
8119 }
8120 case SaliencyBlendCompositeOp:
8121 case SeamlessBlendCompositeOp:
8122 {
8123 status&=(MagickStatusType) CompositeImage(source_image,
8124 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8125 status&=(MagickStatusType) CompositeImage(new_images,
8126 source_image,compose,clip_to_self,geometry.x,geometry.y,
8127 exception);
8128 break;
8129 }
8130 default:
8131 {
8132 Image
8133 *clone_image;
8134
8135 clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
8136 if (clone_image == (Image *) NULL)
8137 break;
8138 status&=(MagickStatusType) CompositeImage(new_images,
8139 source_image,compose,clip_to_self,geometry.x,geometry.y,
8140 exception);
8141 status&=(MagickStatusType) CompositeImage(new_images,
8142 mask_image,CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8143 status&=(MagickStatusType) CompositeImage(clone_image,
8144 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8145 new_images=DestroyImageList(new_images);
8146 new_images=clone_image;
8147 break;
8148 }
8149 }
8150 switch (compose)
8151 {
8152 case DisplaceCompositeOp:
8153 case DistortCompositeOp:
8154 {
8155 status&=(MagickStatusType) CompositeImage(canvas_image,
8156 new_images,CopyCompositeOp,clip_to_self,0,0,exception);
8157 break;
8158 }
8159 default:
8160 {
8161 status&=(MagickStatusType) CompositeImage(canvas_image,
8162 new_images,OverCompositeOp,clip_to_self,0,0,exception);
8163 break;
8164 }
8165 }
8166 new_images=DestroyImageList(new_images);
8167 new_images=canvas_image;
8168 mask_image=DestroyImage(mask_image);
8169 }
8170 source_image=DestroyImage(source_image);
8171 *images=DestroyImageList(*images);
8172 *images=new_images;
8173 break;
8174 }
8175 if (LocaleCompare("copy",option+1) == 0)
8176 {
8177 Image
8178 *source_image;
8179
8180 OffsetInfo
8181 offset;
8182
8183 RectangleInfo
8184 geometry;
8185
8186 /*
8187 Copy image pixels.
8188 */
8189 (void) SyncImageSettings(mogrify_info,*images,exception);
8190 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8191 offset.x=geometry.x;
8192 offset.y=geometry.y;
8193 source_image=(*images);
8194 if (source_image->next != (Image *) NULL)
8195 source_image=source_image->next;
8196 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8197 exception);
8198 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8199 exception);
8200 break;
8201 }
8202 break;
8203 }
8204 case 'd':
8205 {
8206 if (LocaleCompare("deconstruct",option+1) == 0)
8207 {
8208 Image
8209 *deconstruct_image;
8210
8211 (void) SyncImagesSettings(mogrify_info,*images,exception);
8212 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8213 exception);
8214 if (deconstruct_image == (Image *) NULL)
8215 {
8216 status=MagickFalse;
8217 break;
8218 }
8219 *images=DestroyImageList(*images);
8220 *images=deconstruct_image;
8221 break;
8222 }
8223 if (LocaleCompare("delete",option+1) == 0)
8224 {
8225 if (*option == '+')
8226 DeleteImages(images,"-1",exception);
8227 else
8228 DeleteImages(images,argv[i+1],exception);
8229 break;
8230 }
8231 if (LocaleCompare("dither",option+1) == 0)
8232 {
8233 if (*option == '+')
8234 {
8235 quantize_info->dither_method=NoDitherMethod;
8236 break;
8237 }
8238 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8239 MagickDitherOptions,MagickFalse,argv[i+1]);
8240 break;
8241 }
8242 if (LocaleCompare("duplicate",option+1) == 0)
8243 {
8244 Image
8245 *duplicate_images;
8246
8247 if (*option == '+')
8248 duplicate_images=DuplicateImages(*images,1,"-1",exception);
8249 else
8250 {
8251 const char
8252 *p;
8253
8254 size_t
8255 number_duplicates;
8256
8257 number_duplicates=(size_t) StringToLong(argv[i+1]);
8258 p=strchr(argv[i+1],',');
8259 if (p == (const char *) NULL)
8260 duplicate_images=DuplicateImages(*images,number_duplicates,
8261 "-1",exception);
8262 else
8263 duplicate_images=DuplicateImages(*images,number_duplicates,
8264 p+1,exception);
8265 }
8266 AppendImageToList(images, duplicate_images);
8267 (void) SyncImagesSettings(mogrify_info,*images,exception);
8268 break;
8269 }
8270 break;
8271 }
8272 case 'e':
8273 {
8274 if (LocaleCompare("evaluate-sequence",option+1) == 0)
8275 {
8276 Image
8277 *evaluate_image;
8278
8279 MagickEvaluateOperator
8280 op;
8281
8282 (void) SyncImageSettings(mogrify_info,*images,exception);
8283 op=(MagickEvaluateOperator) ParseCommandOption(
8284 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8285 evaluate_image=EvaluateImages(*images,op,exception);
8286 if (evaluate_image == (Image *) NULL)
8287 {
8288 status=MagickFalse;
8289 break;
8290 }
8291 *images=DestroyImageList(*images);
8292 *images=evaluate_image;
8293 break;
8294 }
8295 break;
8296 }
8297 case 'f':
8298 {
8299 if (LocaleCompare("fft",option+1) == 0)
8300 {
8301 Image
8302 *fourier_image;
8303
8304 /*
8305 Implements the discrete Fourier transform (DFT).
8306 */
8307 (void) SyncImageSettings(mogrify_info,*images,exception);
8308 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8309 MagickTrue : MagickFalse,exception);
8310 if (fourier_image == (Image *) NULL)
8311 break;
8312 *images=DestroyImageList(*images);
8313 *images=fourier_image;
8314 break;
8315 }
8316 if (LocaleCompare("flatten",option+1) == 0)
8317 {
8318 Image
8319 *flatten_image;
8320
8321 (void) SyncImagesSettings(mogrify_info,*images,exception);
8322 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8323 if (flatten_image == (Image *) NULL)
8324 break;
8325 *images=DestroyImageList(*images);
8326 *images=flatten_image;
8327 break;
8328 }
8329 if (LocaleCompare("fx",option+1) == 0)
8330 {
8331 Image
8332 *fx_image;
8333
8334puts("list");
8335 (void) SyncImagesSettings(mogrify_info,*images,exception);
8336 fx_image=FxImage(*images,argv[i+1],exception);
8337 if (fx_image == (Image *) NULL)
8338 {
8339 status=MagickFalse;
8340 break;
8341 }
8342 *images=DestroyImageList(*images);
8343 *images=fx_image;
8344 break;
8345 }
8346 break;
8347 }
8348 case 'h':
8349 {
8350 if (LocaleCompare("hald-clut",option+1) == 0)
8351 {
8352 Image
8353 *hald_image,
8354 *image;
8355
8356 (void) SyncImagesSettings(mogrify_info,*images,exception);
8357 image=RemoveFirstImageFromList(images);
8358 hald_image=RemoveFirstImageFromList(images);
8359 if (hald_image == (Image *) NULL)
8360 {
8361 (void) ThrowMagickException(exception,GetMagickModule(),
8362 OptionError,"ImageSequenceRequired","`%s'",option);
8363 image=DestroyImage(image);
8364 status=MagickFalse;
8365 break;
8366 }
8367 (void) HaldClutImage(image,hald_image,exception);
8368 hald_image=DestroyImage(hald_image);
8369 if (*images != (Image *) NULL)
8370 *images=DestroyImageList(*images);
8371 *images=image;
8372 break;
8373 }
8374 break;
8375 }
8376 case 'i':
8377 {
8378 if (LocaleCompare("ift",option+1) == 0)
8379 {
8380 Image
8381 *fourier_image,
8382 *magnitude_image,
8383 *phase_image;
8384
8385 /*
8386 Implements the inverse fourier discrete Fourier transform (DFT).
8387 */
8388 (void) SyncImagesSettings(mogrify_info,*images,exception);
8389 magnitude_image=RemoveFirstImageFromList(images);
8390 phase_image=RemoveFirstImageFromList(images);
8391 if (phase_image == (Image *) NULL)
8392 {
8393 (void) ThrowMagickException(exception,GetMagickModule(),
8394 OptionError,"ImageSequenceRequired","`%s'",option);
8395 magnitude_image=DestroyImage(magnitude_image);
8396 status=MagickFalse;
8397 break;
8398 }
8399 fourier_image=InverseFourierTransformImage(magnitude_image,
8400 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
8401 magnitude_image=DestroyImage(magnitude_image);
8402 phase_image=DestroyImage(phase_image);
8403 if (fourier_image == (Image *) NULL)
8404 break;
8405 if (*images != (Image *) NULL)
8406 *images=DestroyImageList(*images);
8407 *images=fourier_image;
8408 break;
8409 }
8410 if (LocaleCompare("insert",option+1) == 0)
8411 {
8412 Image
8413 *p,
8414 *q;
8415
8416 index=0;
8417 if (*option != '+')
8418 index=(ssize_t) StringToLong(argv[i+1]);
8419 p=RemoveLastImageFromList(images);
8420 if (p == (Image *) NULL)
8421 {
8422 (void) ThrowMagickException(exception,GetMagickModule(),
8423 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8424 status=MagickFalse;
8425 break;
8426 }
8427 q=p;
8428 if (index == 0)
8429 PrependImageToList(images,q);
8430 else
8431 if (index == (ssize_t) GetImageListLength(*images))
8432 AppendImageToList(images,q);
8433 else
8434 {
8435 q=GetImageFromList(*images,index-1);
8436 if (q == (Image *) NULL)
8437 {
8438 p=DestroyImage(p);
8439 (void) ThrowMagickException(exception,GetMagickModule(),
8440 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8441 status=MagickFalse;
8442 break;
8443 }
8444 InsertImageInList(&q,p);
8445 }
8446 *images=GetFirstImageInList(q);
8447 break;
8448 }
8449 if (LocaleCompare("interpolate",option+1) == 0)
8450 {
8451 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8452 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8453 break;
8454 }
8455 break;
8456 }
8457 case 'l':
8458 {
8459 if (LocaleCompare("layers",option+1) == 0)
8460 {
8461 Image
8462 *layers;
8463
8464 LayerMethod
8465 method;
8466
8467 (void) SyncImagesSettings(mogrify_info,*images,exception);
8468 layers=(Image *) NULL;
8469 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8470 MagickFalse,argv[i+1]);
8471 switch (method)
8472 {
8473 case CoalesceLayer:
8474 {
8475 layers=CoalesceImages(*images,exception);
8476 break;
8477 }
8478 case CompareAnyLayer:
8479 case CompareClearLayer:
8480 case CompareOverlayLayer:
8481 default:
8482 {
8483 layers=CompareImagesLayers(*images,method,exception);
8484 break;
8485 }
8486 case MergeLayer:
8487 case FlattenLayer:
8488 case MosaicLayer:
8489 case TrimBoundsLayer:
8490 {
8491 layers=MergeImageLayers(*images,method,exception);
8492 break;
8493 }
8494 case DisposeLayer:
8495 {
8496 layers=DisposeImages(*images,exception);
8497 break;
8498 }
8499 case OptimizeImageLayer:
8500 {
8501 layers=OptimizeImageLayers(*images,exception);
8502 break;
8503 }
8504 case OptimizePlusLayer:
8505 {
8506 layers=OptimizePlusImageLayers(*images,exception);
8507 break;
8508 }
8509 case OptimizeTransLayer:
8510 {
8511 OptimizeImageTransparency(*images,exception);
8512 break;
8513 }
8514 case RemoveDupsLayer:
8515 {
8516 RemoveDuplicateLayers(images,exception);
8517 break;
8518 }
8519 case RemoveZeroLayer:
8520 {
8521 RemoveZeroDelayLayers(images,exception);
8522 break;
8523 }
8524 case OptimizeLayer:
8525 {
8526 /*
8527 General Purpose, GIF Animation Optimizer.
8528 */
8529 layers=CoalesceImages(*images,exception);
8530 if (layers == (Image *) NULL)
8531 {
8532 status=MagickFalse;
8533 break;
8534 }
8535 *images=DestroyImageList(*images);
8536 *images=layers;
8537 layers=OptimizeImageLayers(*images,exception);
8538 if (layers == (Image *) NULL)
8539 {
8540 status=MagickFalse;
8541 break;
8542 }
8543 *images=DestroyImageList(*images);
8544 *images=layers;
8545 layers=(Image *) NULL;
8546 OptimizeImageTransparency(*images,exception);
8547 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8548 exception);
8549 break;
8550 }
8551 case CompositeLayer:
8552 {
8553 CompositeOperator
8554 compose;
8555
8556 Image
8557 *source;
8558
8559 RectangleInfo
8560 geometry;
8561
8562 /*
8563 Split image sequence at the first 'NULL:' image.
8564 */
8565 source=(*images);
8566 while (source != (Image *) NULL)
8567 {
8568 source=GetNextImageInList(source);
8569 if ((source != (Image *) NULL) &&
8570 (LocaleCompare(source->magick,"NULL") == 0))
8571 break;
8572 }
8573 if (source != (Image *) NULL)
8574 {
8575 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8576 (GetNextImageInList(source) == (Image *) NULL))
8577 source=(Image *) NULL;
8578 else
8579 {
8580 /*
8581 Separate the two lists, junk the null: image.
8582 */
8583 source=SplitImageList(source->previous);
8584 DeleteImageFromList(&source);
8585 }
8586 }
8587 if (source == (Image *) NULL)
8588 {
8589 (void) ThrowMagickException(exception,GetMagickModule(),
8590 OptionError,"MissingNullSeparator","layers Composite");
8591 status=MagickFalse;
8592 break;
8593 }
8594 /*
8595 Adjust offset with gravity and virtual canvas.
8596 */
8597 SetGeometry(*images,&geometry);
8598 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8599 geometry.width=source->page.width != 0 ?
8600 source->page.width : source->columns;
8601 geometry.height=source->page.height != 0 ?
8602 source->page.height : source->rows;
8603 GravityAdjustGeometry((*images)->page.width != 0 ?
8604 (*images)->page.width : (*images)->columns,
8605 (*images)->page.height != 0 ? (*images)->page.height :
8606 (*images)->rows,(*images)->gravity,&geometry);
8607 compose=OverCompositeOp;
8608 option=GetImageOption(mogrify_info,"compose");
8609 if (option != (const char *) NULL)
8610 compose=(CompositeOperator) ParseCommandOption(
8611 MagickComposeOptions,MagickFalse,option);
8612 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8613 exception);
8614 source=DestroyImageList(source);
8615 break;
8616 }
8617 }
8618 if (layers == (Image *) NULL)
8619 break;
8620 *images=DestroyImageList(*images);
8621 *images=layers;
8622 break;
8623 }
8624 break;
8625 }
8626 case 'm':
8627 {
8628 if (LocaleCompare("map",option+1) == 0)
8629 {
8630 (void) SyncImagesSettings(mogrify_info,*images,exception);
8631 if (*option == '+')
8632 {
8633 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8634 exception);
8635 break;
8636 }
8637 i++;
8638 break;
8639 }
8640 if (LocaleCompare("maximum",option+1) == 0)
8641 {
8642 Image
8643 *maximum_image;
8644
8645 /*
8646 Maximum image sequence (deprecated).
8647 */
8648 (void) SyncImagesSettings(mogrify_info,*images,exception);
8649 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8650 if (maximum_image == (Image *) NULL)
8651 {
8652 status=MagickFalse;
8653 break;
8654 }
8655 *images=DestroyImageList(*images);
8656 *images=maximum_image;
8657 break;
8658 }
8659 if (LocaleCompare("minimum",option+1) == 0)
8660 {
8661 Image
8662 *minimum_image;
8663
8664 /*
8665 Minimum image sequence (deprecated).
8666 */
8667 (void) SyncImagesSettings(mogrify_info,*images,exception);
8668 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8669 if (minimum_image == (Image *) NULL)
8670 {
8671 status=MagickFalse;
8672 break;
8673 }
8674 *images=DestroyImageList(*images);
8675 *images=minimum_image;
8676 break;
8677 }
8678 if (LocaleCompare("morph",option+1) == 0)
8679 {
8680 Image
8681 *morph_image;
8682
8683 (void) SyncImagesSettings(mogrify_info,*images,exception);
8684 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8685 exception);
8686 if (morph_image == (Image *) NULL)
8687 {
8688 status=MagickFalse;
8689 break;
8690 }
8691 *images=DestroyImageList(*images);
8692 *images=morph_image;
8693 break;
8694 }
8695 if (LocaleCompare("mosaic",option+1) == 0)
8696 {
8697 Image
8698 *mosaic_image;
8699
8700 (void) SyncImagesSettings(mogrify_info,*images,exception);
8701 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8702 if (mosaic_image == (Image *) NULL)
8703 {
8704 status=MagickFalse;
8705 break;
8706 }
8707 *images=DestroyImageList(*images);
8708 *images=mosaic_image;
8709 break;
8710 }
8711 break;
8712 }
8713 case 'p':
8714 {
8715 if (LocaleCompare("poly",option+1) == 0)
8716 {
8717 char
8718 *args,
8719 token[MagickPathExtent];
8720
8721 const char
8722 *p;
8723
8724 double
8725 *arguments;
8726
8727 Image
8728 *polynomial_image;
8729
8730 ssize_t
8731 x;
8732
8733 size_t
8734 number_arguments;
8735
8736 /*
8737 Polynomial image.
8738 */
8739 (void) SyncImageSettings(mogrify_info,*images,exception);
8740 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8741 exception);
8742 if (args == (char *) NULL)
8743 break;
8744 p=(char *) args;
8745 for (x=0; *p != '\0'; x++)
8746 {
8747 (void) GetNextToken(p,&p,MagickPathExtent,token);
8748 if (*token == ',')
8749 (void) GetNextToken(p,&p,MagickPathExtent,token);
8750 }
8751 number_arguments=(size_t) x;
8752 arguments=(double *) AcquireQuantumMemory(number_arguments,
8753 sizeof(*arguments));
8754 if (arguments == (double *) NULL)
8755 ThrowWandFatalException(ResourceLimitFatalError,
8756 "MemoryAllocationFailed",(*images)->filename);
8757 (void) memset(arguments,0,number_arguments*
8758 sizeof(*arguments));
8759 p=(char *) args;
8760 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8761 {
8762 (void) GetNextToken(p,&p,MagickPathExtent,token);
8763 if (*token == ',')
8764 (void) GetNextToken(p,&p,MagickPathExtent,token);
8765 arguments[x]=StringToDouble(token,(char **) NULL);
8766 }
8767 args=DestroyString(args);
8768 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8769 arguments,exception);
8770 arguments=(double *) RelinquishMagickMemory(arguments);
8771 if (polynomial_image == (Image *) NULL)
8772 {
8773 status=MagickFalse;
8774 break;
8775 }
8776 *images=DestroyImageList(*images);
8777 *images=polynomial_image;
8778 }
8779 if (LocaleCompare("print",option+1) == 0)
8780 {
8781 char
8782 *string;
8783
8784 (void) SyncImagesSettings(mogrify_info,*images,exception);
8785 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8786 exception);
8787 if (string == (char *) NULL)
8788 break;
8789 (void) FormatLocaleFile(stdout,"%s",string);
8790 string=DestroyString(string);
8791 }
8792 if (LocaleCompare("process",option+1) == 0)
8793 {
8794 char
8795 **arguments;
8796
8797 int
8798 j,
8799 number_arguments;
8800
8801 (void) SyncImagesSettings(mogrify_info,*images,exception);
8802 arguments=StringToArgv(argv[i+1],&number_arguments);
8803 if ((arguments == (char **) NULL) || (number_arguments == 1))
8804 break;
8805 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8806 {
8807 char
8808 breaker,
8809 quote,
8810 *token;
8811
8812 const char
8813 *argument;
8814
8815 int
8816 next,
8817 token_status;
8818
8819 size_t
8820 length;
8821
8822 TokenInfo
8823 *token_info;
8824
8825 /*
8826 Support old style syntax, filter="-option arg".
8827 */
8828 length=strlen(argv[i+1]);
8829 token=(char *) NULL;
8830 if (~length >= (MagickPathExtent-1))
8831 token=(char *) AcquireQuantumMemory(length+MagickPathExtent,
8832 sizeof(*token));
8833 if (token == (char *) NULL)
8834 break;
8835 next=0;
8836 argument=argv[i+1];
8837 token_info=AcquireTokenInfo();
8838 token_status=Tokenizer(token_info,0,token,length,argument,"",
8839 "=","\"",'\0',&breaker,&next,&quote);
8840 token_info=DestroyTokenInfo(token_info);
8841 if (token_status == 0)
8842 {
8843 const char
8844 *arg;
8845
8846 arg=(&(argument[next]));
8847 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8848 exception);
8849 }
8850 token=DestroyString(token);
8851 break;
8852 }
8853 (void) SubstituteString(&arguments[1],"-","");
8854 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8855 number_arguments-2,(const char **) arguments+2,exception);
8856 for (j=0; j < number_arguments; j++)
8857 arguments[j]=DestroyString(arguments[j]);
8858 arguments=(char **) RelinquishMagickMemory(arguments);
8859 break;
8860 }
8861 break;
8862 }
8863 case 'r':
8864 {
8865 if (LocaleCompare("reverse",option+1) == 0)
8866 {
8867 ReverseImageList(images);
8868 break;
8869 }
8870 break;
8871 }
8872 case 's':
8873 {
8874 if (LocaleCompare("smush",option+1) == 0)
8875 {
8876 Image
8877 *smush_image;
8878
8879 ssize_t
8880 offset;
8881
8882 (void) SyncImagesSettings(mogrify_info,*images,exception);
8883 offset=(ssize_t) StringToLong(argv[i+1]);
8884 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8885 MagickFalse,offset,exception);
8886 if (smush_image == (Image *) NULL)
8887 {
8888 status=MagickFalse;
8889 break;
8890 }
8891 *images=DestroyImageList(*images);
8892 *images=smush_image;
8893 break;
8894 }
8895 if (LocaleCompare("swap",option+1) == 0)
8896 {
8897 Image
8898 *p,
8899 *q,
8900 *u,
8901 *v;
8902
8903 ssize_t
8904 swap_index;
8905
8906 index=(-1);
8907 swap_index=(-2);
8908 if (*option != '+')
8909 {
8910 GeometryInfo
8911 geometry_info;
8912
8913 MagickStatusType
8914 flags;
8915
8916 swap_index=(-1);
8917 flags=ParseGeometry(argv[i+1],&geometry_info);
8918 index=(ssize_t) geometry_info.rho;
8919 if ((flags & SigmaValue) != 0)
8920 swap_index=(ssize_t) geometry_info.sigma;
8921 }
8922 p=GetImageFromList(*images,index);
8923 q=GetImageFromList(*images,swap_index);
8924 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8925 {
8926 (void) ThrowMagickException(exception,GetMagickModule(),
8927 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8928 status=MagickFalse;
8929 break;
8930 }
8931 if (p == q)
8932 break;
8933 u=CloneImage(p,0,0,MagickTrue,exception);
8934 if (u == (Image *) NULL)
8935 break;
8936 v=CloneImage(q,0,0,MagickTrue,exception);
8937 if (v == (Image *) NULL)
8938 {
8939 u=DestroyImage(u);
8940 break;
8941 }
8942 ReplaceImageInList(&p,v);
8943 ReplaceImageInList(&q,u);
8944 *images=GetFirstImageInList(q);
8945 break;
8946 }
8947 break;
8948 }
8949 case 'w':
8950 {
8951 if (LocaleCompare("write",option+1) == 0)
8952 {
8953 char
8954 key[MagickPathExtent];
8955
8956 Image
8957 *write_images;
8958
8959 ImageInfo
8960 *write_info;
8961
8962 (void) SyncImagesSettings(mogrify_info,*images,exception);
8963 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",
8964 argv[i+1]);
8965 (void) DeleteImageRegistry(key);
8966 write_images=CloneImageList(*images,exception);
8967 write_info=CloneImageInfo(mogrify_info);
8968 status&=(MagickStatusType) WriteImages(write_info,write_images,
8969 argv[i+1],exception);
8970 write_info=DestroyImageInfo(write_info);
8971 write_images=DestroyImageList(write_images);
8972 break;
8973 }
8974 break;
8975 }
8976 default:
8977 break;
8978 }
8979 i+=count;
8980 }
8981 quantize_info=DestroyQuantizeInfo(quantize_info);
8982 mogrify_info=DestroyImageInfo(mogrify_info);
8983 status&=(MagickStatusType) MogrifyImageInfo(image_info,argc,argv,exception);
8984 return(status != 0 ? MagickTrue : MagickFalse);
8985}
8986␌
8987/*
8988%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8989% %
8990% %
8991% %
8992+ M o g r i f y I m a g e s %
8993% %
8994% %
8995% %
8996%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8997%
8998% MogrifyImages() applies image processing options to a sequence of images as
8999% prescribed by command line options.
9000%
9001% The format of the MogrifyImage method is:
9002%
9003% MagickBooleanType MogrifyImages(ImageInfo *image_info,
9004% const MagickBooleanType post,const int argc,const char **argv,
9005% Image **images,Exceptioninfo *exception)
9006%
9007% A description of each parameter follows:
9008%
9009% o image_info: the image info..
9010%
9011% o post: If true, post process image list operators otherwise pre-process.
9012%
9013% o argc: Specifies a pointer to an integer describing the number of
9014% elements in the argument vector.
9015%
9016% o argv: Specifies a pointer to a text array containing the command line
9017% arguments.
9018%
9019% o images: pointer to a pointer of the first image in image list.
9020%
9021% o exception: return any errors or warnings in this structure.
9022%
9023*/
9024WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
9025 const MagickBooleanType post,const int argc,const char **argv,
9026 Image **images,ExceptionInfo *exception)
9027{
9028#define MogrifyImageTag "Mogrify/Image"
9029
9030 MagickStatusType
9031 status;
9032
9033 MagickBooleanType
9034 proceed;
9035
9036 size_t
9037 n;
9038
9039 ssize_t
9040 i;
9041
9042 assert(image_info != (ImageInfo *) NULL);
9043 assert(image_info->signature == MagickCoreSignature);
9044 if (images == (Image **) NULL)
9045 return(MogrifyImage(image_info,argc,argv,images,exception));
9046 assert((*images)->previous == (Image *) NULL);
9047 assert((*images)->signature == MagickCoreSignature);
9048 if (IsEventLogging() != MagickFalse)
9049 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
9050 (*images)->filename);
9051 if ((argc <= 0) || (*argv == (char *) NULL))
9052 return(MagickTrue);
9053 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
9054 (void *) NULL);
9055 status=MagickTrue;
9056#if 0
9057 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
9058 post?"post":"pre");
9059#endif
9060 /*
9061 Pre-process multi-image sequence operators
9062 */
9063 if (post == MagickFalse)
9064 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9065 exception);
9066 /*
9067 For each image, process simple single image operators
9068 */
9069 i=0;
9070 n=GetImageListLength(*images);
9071 for ( ; ; )
9072 {
9073#if 0
9074 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
9075 GetImageIndexInList(*images),(long)GetImageListLength(*images));
9076#endif
9077 status&=(MagickStatusType) MogrifyImage(image_info,argc,argv,images,
9078 exception);
9079 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
9080 if (proceed == MagickFalse)
9081 break;
9082 if ( (*images)->next == (Image *) NULL )
9083 break;
9084 *images=(*images)->next;
9085 i++;
9086 }
9087 assert( *images != (Image *) NULL );
9088#if 0
9089 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
9090 GetImageIndexInList(*images),(long)GetImageListLength(*images));
9091#endif
9092 /*
9093 Post-process, multi-image sequence operators
9094 */
9095 *images=GetFirstImageInList(*images);
9096 if (post != MagickFalse)
9097 status&=(MagickStatusType) MogrifyImageList(image_info,argc,argv,images,
9098 exception);
9099 return(status != 0 ? MagickTrue : MagickFalse);
9100}