2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
13 % MagickWand Module Methods %
20 % Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/magick-wand-private.h"
50 #include "MagickWand/mogrify-private.h"
51 #include "MagickCore/image-private.h"
52 #include "MagickCore/monitor-private.h"
53 #include "MagickCore/string-private.h"
54 #include "MagickCore/thread-private.h"
55 #include "MagickCore/utility-private.h"
56 #include "MagickCore/blob-private.h"
57 #if defined(MAGICKCORE_HAVE_UTIME_H)
65 MogrifyAlphaColor[] = "#bdbdbd", /* gray */
66 MogrifyBackgroundColor[] = "#ffffff", /* white */
67 MogrifyBorderColor[] = "#dfdfdf"; /* gray */
72 #define UndefinedCompressionQuality 0UL
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 % M a g i c k C o m m a n d G e n e s i s %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % MagickCommandGenesis() applies image processing options to an image as
86 % prescribed by command line options.
88 % It wiil look for special options like "-debug", "-bench", and
89 % "-distribute-cache" that needs to be applied even before the main
90 % processing begins, and may completely overrule normal command processing.
91 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
92 % and are typically ignored (as they have been handled) if seen later.
94 % The format of the MagickCommandGenesis method is:
96 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
97 % MagickCommand command,int argc,char **argv,char **metadata,
98 % ExceptionInfo *exception)
100 % A description of each parameter follows:
102 % o image_info: the image info.
104 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
105 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
106 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
107 % DisplayImageCommand, or AnimateImageCommand.
109 % o argc: Specifies a pointer to an integer describing the number of
110 % elements in the argument vector.
112 % o argv: Specifies a pointer to a text array containing the command line
115 % o metadata: any metadata is returned here.
117 % o exception: return any errors or warnings in this structure.
120 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
121 MagickCommand command,int argc,char **argv,char **metadata,
122 ExceptionInfo *exception)
125 client_name[MaxTextExtent],
147 (void) setlocale(LC_ALL,"");
148 (void) setlocale(LC_NUMERIC,"C");
149 GetPathComponent(argv[0],TailPath,client_name);
150 (void) SetClientName(client_name);
151 concurrent=MagickFalse;
155 regard_warnings=MagickFalse;
156 for (i=1; i < (ssize_t) (argc-1); i++)
159 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
161 if (LocaleCompare("-bench",option) == 0)
162 iterations=StringToUnsignedLong(argv[++i]);
163 if (LocaleCompare("-concurrent",option) == 0)
164 concurrent=MagickTrue;
165 if (LocaleCompare("-debug",option) == 0)
166 (void) SetLogEventMask(argv[++i]);
167 if (LocaleCompare("-distribute-cache",option) == 0)
169 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
172 if (LocaleCompare("-duration",option) == 0)
173 duration=StringToDouble(argv[++i],(char **) NULL);
174 if (LocaleCompare("-regard-warnings",option) == 0)
175 regard_warnings=MagickTrue;
183 status=command(image_info,argc,argv,&text,exception);
184 if (exception->severity != UndefinedException)
186 if ((exception->severity > ErrorException) ||
187 (regard_warnings != MagickFalse))
189 CatchException(exception);
191 if (text != (char *) NULL)
193 if (metadata != (char **) NULL)
194 (void) ConcatenateString(&(*metadata),text);
195 text=DestroyString(text);
199 number_threads=GetOpenMPMaximumThreads();
201 for (n=1; n <= (ssize_t) number_threads; n++)
211 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
212 timer=AcquireTimerInfo();
213 if (concurrent == MagickFalse)
215 for (i=0; i < (ssize_t) iterations; i++)
221 if (status == MagickFalse)
225 if (GetElapsedTime(timer) > duration)
227 (void) ContinueTimer(timer);
229 status=command(image_info,argc,argv,&text,exception);
230 if (exception->severity != UndefinedException)
232 if ((exception->severity > ErrorException) ||
233 (regard_warnings != MagickFalse))
235 CatchException(exception);
237 if (text != (char *) NULL)
239 if (metadata != (char **) NULL)
240 (void) ConcatenateString(&(*metadata),text);
241 text=DestroyString(text);
248 #if defined(MAGICKCORE_OPENMP_SUPPORT)
249 # pragma omp parallel for shared(status)
251 for (i=0; i < (ssize_t) iterations; i++)
257 if (status == MagickFalse)
261 if (GetElapsedTime(timer) > duration)
263 (void) ContinueTimer(timer);
265 status=command(image_info,argc,argv,&text,exception);
266 #if defined(MAGICKCORE_OPENMP_SUPPORT)
267 # pragma omp critical (MagickCore_MagickCommandGenesis)
270 if (exception->severity != UndefinedException)
272 if ((exception->severity > ErrorException) ||
273 (regard_warnings != MagickFalse))
275 CatchException(exception);
277 if (text != (char *) NULL)
279 if (metadata != (char **) NULL)
280 (void) ConcatenateString(&(*metadata),text);
281 text=DestroyString(text);
286 user_time=GetUserTime(timer);
287 parallel=GetElapsedTime(timer);
292 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
293 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
294 (void) FormatLocaleFile(stderr,
295 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
296 (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
297 (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
298 60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
299 timer=DestroyTimerInfo(timer);
305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309 + M o g r i f y I m a g e %
313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315 % MogrifyImage() applies simple single image processing options to a single
316 % image that may be part of a large list, but also handles any 'region'
319 % The image in the list may be modified in three different ways...
321 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
322 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
323 % * replace by a list of images (only the -separate option!)
325 % In each case the result is returned into the list, and a pointer to the
326 % modified image (last image added if replaced by a list of images) is
329 % ASIDE: The -crop is present but restricted to non-tile single image crops
331 % This means if all the images are being processed (such as by
332 % MogrifyImages(), next image to be processed will be as per the pointer
333 % (*image)->next. Also the image list may grow as a result of some specific
334 % operations but as images are never merged or deleted, it will never shrink
335 % in length. Typically the list will remain the same length.
337 % WARNING: As the image pointed to may be replaced, the first image in the
338 % list may also change. GetFirstImageInList() should be used by caller if
339 % they wish return the Image pointer to the first image in list.
342 % The format of the MogrifyImage method is:
344 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
345 % const char **argv,Image **image)
347 % A description of each parameter follows:
349 % o image_info: the image info..
351 % o argc: Specifies a pointer to an integer describing the number of
352 % elements in the argument vector.
354 % o argv: Specifies a pointer to a text array containing the command line
357 % o image: the image.
359 % o exception: return any errors or warnings in this structure.
363 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
364 ExceptionInfo *exception)
367 key[MagickPathExtent];
379 Read an image into a image cache (for repeated usage) if not already in
380 cache. Then return the image that is in the cache.
382 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",path);
383 sans_exception=AcquireExceptionInfo();
384 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
385 sans_exception=DestroyExceptionInfo(sans_exception);
386 if (image != (Image *) NULL)
388 read_info=CloneImageInfo(image_info);
389 (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
390 image=ReadImage(read_info,exception);
391 read_info=DestroyImageInfo(read_info);
392 if (image != (Image *) NULL)
393 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
397 static inline MagickBooleanType IsPathWritable(const char *path)
399 if (IsPathAccessible(path) == MagickFalse)
401 if (access_utf8(path,W_OK) != 0)
406 static MagickBooleanType MonitorProgress(const char *text,
407 const MagickOffsetType offset,const MagickSizeType extent,
408 void *wand_unused(client_data))
411 message[MagickPathExtent],
412 tag[MagickPathExtent];
420 magick_unreferenced(client_data);
422 if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
424 if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
426 (void) CopyMagickString(tag,text,MagickPathExtent);
428 if (p != (char *) NULL)
430 (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag);
431 locale_message=GetLocaleMessage(message);
432 if (locale_message == message)
434 if (p == (char *) NULL)
435 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
436 locale_message,(long) offset,(unsigned long) extent,(long)
437 (100L*offset/(extent-1)));
439 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
440 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
441 (100L*offset/(extent-1)));
442 if (offset == (MagickOffsetType) (extent-1))
443 (void) FormatLocaleFile(stderr,"\n");
444 (void) fflush(stderr);
448 static Image *SparseColorOption(const Image *image,
449 const SparseColorMethod method,const char *arguments,
450 const MagickBooleanType color_from_image,ExceptionInfo *exception)
453 token[MagickPathExtent];
478 SparseColorOption() parses the complex -sparse-color argument into an an
479 array of floating point values then calls SparseColorImage(). Argument is
480 a complex mix of floating-point pixel coodinates, and color specifications
481 (or direct floating point numbers). The number of floats needed to
482 represent a color varies depending on the current channel setting.
484 assert(image != (Image *) NULL);
485 assert(image->signature == MagickCoreSignature);
486 if (image->debug != MagickFalse)
487 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
488 assert(exception != (ExceptionInfo *) NULL);
489 assert(exception->signature == MagickCoreSignature);
491 Limit channels according to image - and add up number of color channel.
494 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
496 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
498 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
500 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
501 (image->colorspace == CMYKColorspace))
503 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
504 (image->alpha_trait != UndefinedPixelTrait))
508 Read string, to determine number of arguments needed,
514 GetNextToken(p,&p,MagickPathExtent,token);
515 if ( token[0] == ',' ) continue;
516 if ( isalpha((int) token[0]) || token[0] == '#' ) {
517 if ( color_from_image ) {
518 (void) ThrowMagickException(exception,GetMagickModule(),
519 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
520 "Color arg given, when colors are coming from image");
521 return( (Image *) NULL);
523 x += number_colors; /* color argument */
526 x++; /* floating point argument */
530 if ( color_from_image ) {
531 /* just the control points are being given */
532 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
533 number_arguments=(x/2)*(2+number_colors);
536 /* control points and color values */
537 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
541 (void) ThrowMagickException(exception,GetMagickModule(),
542 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
543 "Invalid number of Arguments");
544 return( (Image *) NULL);
547 /* Allocate and fill in the floating point arguments */
548 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
549 sizeof(*sparse_arguments));
550 if (sparse_arguments == (double *) NULL) {
551 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
552 "MemoryAllocationFailed","%s","SparseColorOption");
553 return( (Image *) NULL);
555 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
556 sizeof(*sparse_arguments));
559 while( *p != '\0' && x < number_arguments ) {
561 token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
562 if ( token[0] == '\0' ) break;
563 if ( isalpha((int) token[0]) || token[0] == '#' ) {
564 (void) ThrowMagickException(exception,GetMagickModule(),
565 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
566 "Color found, instead of X-coord");
570 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
572 token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
573 if ( token[0] == '\0' ) break;
574 if ( isalpha((int) token[0]) || token[0] == '#' ) {
575 (void) ThrowMagickException(exception,GetMagickModule(),
576 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
577 "Color found, instead of Y-coord");
581 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
582 /* color values for this control point */
584 if ( (color_from_image ) {
585 /* get color from image */
591 /* color name or function given in string argument */
592 token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
593 if ( token[0] == '\0' ) break;
594 if ( isalpha((int) token[0]) || token[0] == '#' ) {
595 /* Color string given */
596 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
597 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
598 sparse_arguments[x++] = QuantumScale*color.red;
599 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
600 sparse_arguments[x++] = QuantumScale*color.green;
601 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
602 sparse_arguments[x++] = QuantumScale*color.blue;
603 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
604 (image->colorspace == CMYKColorspace))
605 sparse_arguments[x++] = QuantumScale*color.black;
606 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
607 (image->alpha_trait != UndefinedPixelTrait))
608 sparse_arguments[x++] = QuantumScale*color.alpha;
611 /* Colors given as a set of floating point values - experimental */
612 /* NB: token contains the first floating point value to use! */
613 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
615 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
616 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
618 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
619 token[0] = ','; /* used this token - get another */
621 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
623 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
624 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
626 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
627 token[0] = ','; /* used this token - get another */
629 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
631 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
632 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
634 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
635 token[0] = ','; /* used this token - get another */
637 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
638 (image->colorspace == CMYKColorspace))
640 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
641 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
643 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
644 token[0] = ','; /* used this token - get another */
646 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
647 (image->alpha_trait != UndefinedPixelTrait))
649 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
650 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
652 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
653 token[0] = ','; /* used this token - get another */
658 if ( number_arguments != x && !error ) {
659 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
660 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
661 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
662 return( (Image *) NULL);
665 return( (Image *) NULL);
667 /* Call the Interpolation function with the parsed arguments */
668 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
670 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
671 return( sparse_image );
674 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
675 const char **argv,Image **image,ExceptionInfo *exception)
705 PixelInterpolateMethod
719 Initialize method variables.
721 assert(image_info != (const ImageInfo *) NULL);
722 assert(image_info->signature == MagickCoreSignature);
723 assert(image != (Image **) NULL);
724 assert((*image)->signature == MagickCoreSignature);
725 if ((*image)->debug != MagickFalse)
726 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
729 mogrify_info=CloneImageInfo(image_info);
730 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
731 quantize_info=AcquireQuantizeInfo(mogrify_info);
732 SetGeometryInfo(&geometry_info);
733 GetPixelInfo(*image,&fill);
734 fill=(*image)->background_color;
736 compose=(*image)->compose;
737 interpolate_method=UndefinedInterpolatePixel;
738 format=GetImageOption(mogrify_info,"format");
739 SetGeometry(*image,®ion_geometry);
741 Transmogrify the image.
743 for (i=0; i < (ssize_t) argc; i++)
752 if (IsCommandOption(option) == MagickFalse)
754 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
756 if ((i+count) >= (ssize_t) argc)
758 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
759 mogrify_image=(Image *) NULL;
764 if (LocaleCompare("adaptive-blur",option+1) == 0)
769 (void) SyncImageSettings(mogrify_info,*image,exception);
770 flags=ParseGeometry(argv[i+1],&geometry_info);
771 if ((flags & SigmaValue) == 0)
772 geometry_info.sigma=1.0;
773 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
774 geometry_info.sigma,exception);
777 if (LocaleCompare("adaptive-resize",option+1) == 0)
780 Adaptive resize image.
782 (void) SyncImageSettings(mogrify_info,*image,exception);
783 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
784 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
785 geometry.height,exception);
788 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
791 Adaptive sharpen image.
793 (void) SyncImageSettings(mogrify_info,*image,exception);
794 flags=ParseGeometry(argv[i+1],&geometry_info);
795 if ((flags & SigmaValue) == 0)
796 geometry_info.sigma=1.0;
797 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
798 geometry_info.sigma,exception);
801 if (LocaleCompare("affine",option+1) == 0)
808 GetAffineMatrix(&draw_info->affine);
811 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
814 if (LocaleCompare("alpha",option+1) == 0)
819 (void) SyncImageSettings(mogrify_info,*image,exception);
820 alpha_type=(AlphaChannelOption) ParseCommandOption(
821 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
822 (void) SetImageAlphaChannel(*image,alpha_type,exception);
825 if (LocaleCompare("annotate",option+1) == 0)
829 geometry_str[MagickPathExtent];
834 (void) SyncImageSettings(mogrify_info,*image,exception);
835 SetGeometryInfo(&geometry_info);
836 flags=ParseGeometry(argv[i+1],&geometry_info);
837 if ((flags & SigmaValue) == 0)
838 geometry_info.sigma=geometry_info.rho;
839 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
841 if (text == (char *) NULL)
843 (void) CloneString(&draw_info->text,text);
844 text=DestroyString(text);
845 (void) FormatLocaleString(geometry_str,MagickPathExtent,"%+f%+f",
846 geometry_info.xi,geometry_info.psi);
847 (void) CloneString(&draw_info->geometry,geometry_str);
848 draw_info->affine.sx=cos(DegreesToRadians(
849 fmod(geometry_info.rho,360.0)));
850 draw_info->affine.rx=sin(DegreesToRadians(
851 fmod(geometry_info.rho,360.0)));
852 draw_info->affine.ry=(-sin(DegreesToRadians(
853 fmod(geometry_info.sigma,360.0))));
854 draw_info->affine.sy=cos(DegreesToRadians(
855 fmod(geometry_info.sigma,360.0)));
856 (void) AnnotateImage(*image,draw_info,exception);
859 if (LocaleCompare("antialias",option+1) == 0)
861 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
863 draw_info->text_antialias=(*option == '-') ? MagickTrue :
867 if (LocaleCompare("attenuate",option+1) == 0)
874 attenuate=StringToDouble(argv[i+1],(char **) NULL);
877 if (LocaleCompare("auto-gamma",option+1) == 0)
880 Auto Adjust Gamma of image based on its mean
882 (void) SyncImageSettings(mogrify_info,*image,exception);
883 (void) AutoGammaImage(*image,exception);
886 if (LocaleCompare("auto-level",option+1) == 0)
889 Perfectly Normalize (max/min stretch) the image
891 (void) SyncImageSettings(mogrify_info,*image,exception);
892 (void) AutoLevelImage(*image,exception);
895 if (LocaleCompare("auto-orient",option+1) == 0)
897 (void) SyncImageSettings(mogrify_info,*image,exception);
898 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
906 if (LocaleCompare("black-threshold",option+1) == 0)
909 Black threshold image.
911 (void) SyncImageSettings(mogrify_info,*image,exception);
912 (void) BlackThresholdImage(*image,argv[i+1],exception);
915 if (LocaleCompare("blue-shift",option+1) == 0)
920 (void) SyncImageSettings(mogrify_info,*image,exception);
921 geometry_info.rho=1.5;
923 flags=ParseGeometry(argv[i+1],&geometry_info);
924 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
927 if (LocaleCompare("blur",option+1) == 0)
932 (void) SyncImageSettings(mogrify_info,*image,exception);
933 flags=ParseGeometry(argv[i+1],&geometry_info);
934 if ((flags & SigmaValue) == 0)
935 geometry_info.sigma=1.0;
936 if ((flags & XiValue) == 0)
937 geometry_info.xi=0.0;
938 mogrify_image=BlurImage(*image,geometry_info.rho,
939 geometry_info.sigma,exception);
942 if (LocaleCompare("border",option+1) == 0)
945 Surround image with a border of solid color.
947 (void) SyncImageSettings(mogrify_info,*image,exception);
948 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
949 mogrify_image=BorderImage(*image,&geometry,compose,exception);
952 if (LocaleCompare("bordercolor",option+1) == 0)
956 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
957 &draw_info->border_color,exception);
960 (void) QueryColorCompliance(argv[i+1],AllCompliance,
961 &draw_info->border_color,exception);
964 if (LocaleCompare("box",option+1) == 0)
966 (void) QueryColorCompliance(argv[i+1],AllCompliance,
967 &draw_info->undercolor,exception);
970 if (LocaleCompare("brightness-contrast",option+1) == 0)
977 Brightness / contrast image.
979 (void) SyncImageSettings(mogrify_info,*image,exception);
980 flags=ParseGeometry(argv[i+1],&geometry_info);
981 brightness=geometry_info.rho;
983 if ((flags & SigmaValue) != 0)
984 contrast=geometry_info.sigma;
985 (void) BrightnessContrastImage(*image,brightness,contrast,
993 if (LocaleCompare("canny",option+1) == 0)
996 Detect edges in the image.
998 (void) SyncImageSettings(mogrify_info,*image,exception);
999 flags=ParseGeometry(argv[i+1],&geometry_info);
1000 if ((flags & SigmaValue) == 0)
1001 geometry_info.sigma=1.0;
1002 if ((flags & XiValue) == 0)
1003 geometry_info.xi=0.10;
1004 if ((flags & PsiValue) == 0)
1005 geometry_info.psi=0.30;
1006 if ((flags & PercentValue) != 0)
1008 geometry_info.xi/=100.0;
1009 geometry_info.psi/=100.0;
1011 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
1012 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
1015 if (LocaleCompare("cdl",option+1) == 0)
1018 *color_correction_collection;
1021 Color correct with a color decision list.
1023 (void) SyncImageSettings(mogrify_info,*image,exception);
1024 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1025 if (color_correction_collection == (char *) NULL)
1027 (void) ColorDecisionListImage(*image,color_correction_collection,
1031 if (LocaleCompare("channel",option+1) == 0)
1036 (void) SyncImageSettings(mogrify_info,*image,exception);
1039 (void) SetPixelChannelMask(*image,DefaultChannels);
1042 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1043 (void) SetPixelChannelMask(*image,channel);
1046 if (LocaleCompare("charcoal",option+1) == 0)
1051 (void) SyncImageSettings(mogrify_info,*image,exception);
1052 flags=ParseGeometry(argv[i+1],&geometry_info);
1053 if ((flags & SigmaValue) == 0)
1054 geometry_info.sigma=1.0;
1055 if ((flags & XiValue) == 0)
1056 geometry_info.xi=1.0;
1057 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1058 geometry_info.sigma,exception);
1061 if (LocaleCompare("chop",option+1) == 0)
1066 (void) SyncImageSettings(mogrify_info,*image,exception);
1067 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1068 mogrify_image=ChopImage(*image,&geometry,exception);
1071 if (LocaleCompare("clip",option+1) == 0)
1073 (void) SyncImageSettings(mogrify_info,*image,exception);
1076 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
1080 (void) ClipImage(*image,exception);
1083 if (LocaleCompare("clip-mask",option+1) == 0)
1100 (void) SyncImageSettings(mogrify_info,*image,exception);
1106 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
1112 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1114 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1115 if (mask_image == (Image *) NULL)
1117 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1118 return(MagickFalse);
1119 mask_view=AcquireAuthenticCacheView(mask_image,exception);
1120 for (y=0; y < (ssize_t) mask_image->rows; y++)
1122 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1124 if (q == (Quantum *) NULL)
1126 for (x=0; x < (ssize_t) mask_image->columns; x++)
1128 if (mask_image->alpha_trait == UndefinedPixelTrait)
1129 SetPixelAlpha(mask_image,(Quantum)
1130 GetPixelIntensity(mask_image,q),q);
1131 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1132 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1133 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1134 q+=GetPixelChannels(mask_image);
1136 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1139 mask_view=DestroyCacheView(mask_view);
1140 mask_image->alpha_trait=BlendPixelTrait;
1141 (void) SetImageMask(*image,ReadPixelMask,mask_image,exception);
1144 if (LocaleCompare("clip-path",option+1) == 0)
1146 (void) SyncImageSettings(mogrify_info,*image,exception);
1147 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1148 MagickFalse,exception);
1151 if (LocaleCompare("colorize",option+1) == 0)
1156 (void) SyncImageSettings(mogrify_info,*image,exception);
1157 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1160 if (LocaleCompare("color-matrix",option+1) == 0)
1165 (void) SyncImageSettings(mogrify_info,*image,exception);
1166 kernel=AcquireKernelInfo(argv[i+1],exception);
1167 if (kernel == (KernelInfo *) NULL)
1169 /* FUTURE: check on size of the matrix */
1170 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1171 kernel=DestroyKernelInfo(kernel);
1174 if (LocaleCompare("colors",option+1) == 0)
1177 Reduce the number of colors in the image.
1179 (void) SyncImageSettings(mogrify_info,*image,exception);
1180 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1181 if (quantize_info->number_colors == 0)
1183 if (((*image)->storage_class == DirectClass) ||
1184 (*image)->colors > quantize_info->number_colors)
1185 (void) QuantizeImage(quantize_info,*image,exception);
1187 (void) CompressImageColormap(*image,exception);
1190 if (LocaleCompare("colorspace",option+1) == 0)
1195 (void) SyncImageSettings(mogrify_info,*image,exception);
1198 (void) TransformImageColorspace(*image,sRGBColorspace,
1202 colorspace=(ColorspaceType) ParseCommandOption(
1203 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1204 (void) TransformImageColorspace(*image,colorspace,exception);
1207 if (LocaleCompare("compose",option+1) == 0)
1209 (void) SyncImageSettings(mogrify_info,*image,exception);
1210 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1211 MagickFalse,argv[i+1]);
1214 if (LocaleCompare("connected-components",option+1) == 0)
1216 (void) SyncImageSettings(mogrify_info,*image,exception);
1217 mogrify_image=ConnectedComponentsImage(*image,(size_t)
1218 StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1221 if (LocaleCompare("contrast",option+1) == 0)
1223 (void) SyncImageSettings(mogrify_info,*image,exception);
1224 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1225 MagickFalse,exception);
1228 if (LocaleCompare("contrast-stretch",option+1) == 0)
1235 Contrast stretch image.
1237 (void) SyncImageSettings(mogrify_info,*image,exception);
1238 flags=ParseGeometry(argv[i+1],&geometry_info);
1239 black_point=geometry_info.rho;
1240 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1242 if ((flags & PercentValue) != 0)
1244 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1245 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1247 white_point=(double) (*image)->columns*(*image)->rows-
1249 (void) ContrastStretchImage(*image,black_point,white_point,
1253 if (LocaleCompare("convolve",option+1) == 0)
1267 (void) SyncImageSettings(mogrify_info,*image,exception);
1268 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1269 if (kernel_info == (KernelInfo *) NULL)
1271 extent=kernel_info->width*kernel_info->height;
1273 for (j=0; j < (ssize_t) extent; j++)
1274 gamma+=kernel_info->values[j];
1275 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1276 for (j=0; j < (ssize_t) extent; j++)
1277 kernel_info->values[j]*=gamma;
1278 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1279 kernel_info,exception);
1280 kernel_info=DestroyKernelInfo(kernel_info);
1283 if (LocaleCompare("crop",option+1) == 0)
1286 Crop a image to a smaller size
1288 (void) SyncImageSettings(mogrify_info,*image,exception);
1289 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1292 if (LocaleCompare("cycle",option+1) == 0)
1295 Cycle an image colormap.
1297 (void) SyncImageSettings(mogrify_info,*image,exception);
1298 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1306 if (LocaleCompare("decipher",option+1) == 0)
1314 (void) SyncImageSettings(mogrify_info,*image,exception);
1315 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1316 if (passkey != (StringInfo *) NULL)
1318 (void) PasskeyDecipherImage(*image,passkey,exception);
1319 passkey=DestroyStringInfo(passkey);
1323 if (LocaleCompare("density",option+1) == 0)
1328 (void) CloneString(&draw_info->density,argv[i+1]);
1331 if (LocaleCompare("depth",option+1) == 0)
1333 (void) SyncImageSettings(mogrify_info,*image,exception);
1336 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1339 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1343 if (LocaleCompare("deskew",option+1) == 0)
1349 Straighten the image.
1351 (void) SyncImageSettings(mogrify_info,*image,exception);
1353 threshold=40.0*QuantumRange/100.0;
1355 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1357 mogrify_image=DeskewImage(*image,threshold,exception);
1360 if (LocaleCompare("despeckle",option+1) == 0)
1363 Reduce the speckles within an image.
1365 (void) SyncImageSettings(mogrify_info,*image,exception);
1366 mogrify_image=DespeckleImage(*image,exception);
1369 if (LocaleCompare("display",option+1) == 0)
1371 (void) CloneString(&draw_info->server_name,argv[i+1]);
1374 if (LocaleCompare("distort",option+1) == 0)
1378 token[MagickPathExtent];
1398 (void) SyncImageSettings(mogrify_info,*image,exception);
1399 method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1400 MagickFalse,argv[i+1]);
1401 if (method == ResizeDistortion)
1407 Special Case - Argument is actually a resize geometry!
1408 Convert that to an appropriate distortion argument array.
1410 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1412 resize_args[0]=(double) geometry.width;
1413 resize_args[1]=(double) geometry.height;
1414 mogrify_image=DistortImage(*image,method,(size_t)2,
1415 resize_args,MagickTrue,exception);
1418 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1420 if (args == (char *) NULL)
1423 for (x=0; *p != '\0'; x++)
1425 GetNextToken(p,&p,MagickPathExtent,token);
1427 GetNextToken(p,&p,MagickPathExtent,token);
1429 number_arguments=(size_t) x;
1430 arguments=(double *) AcquireQuantumMemory(number_arguments,
1431 sizeof(*arguments));
1432 if (arguments == (double *) NULL)
1433 ThrowWandFatalException(ResourceLimitFatalError,
1434 "MemoryAllocationFailed",(*image)->filename);
1435 (void) ResetMagickMemory(arguments,0,number_arguments*
1436 sizeof(*arguments));
1438 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1440 GetNextToken(p,&p,MagickPathExtent,token);
1442 GetNextToken(p,&p,MagickPathExtent,token);
1443 arguments[x]=StringToDouble(token,(char **) NULL);
1445 args=DestroyString(args);
1446 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1447 (*option == '+') ? MagickTrue : MagickFalse,exception);
1448 arguments=(double *) RelinquishMagickMemory(arguments);
1451 if (LocaleCompare("dither",option+1) == 0)
1455 quantize_info->dither_method=NoDitherMethod;
1458 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1459 MagickDitherOptions,MagickFalse,argv[i+1]);
1462 if (LocaleCompare("draw",option+1) == 0)
1467 (void) SyncImageSettings(mogrify_info,*image,exception);
1468 (void) CloneString(&draw_info->primitive,argv[i+1]);
1469 (void) DrawImage(*image,draw_info,exception);
1476 if (LocaleCompare("edge",option+1) == 0)
1479 Enhance edges in the image.
1481 (void) SyncImageSettings(mogrify_info,*image,exception);
1482 flags=ParseGeometry(argv[i+1],&geometry_info);
1483 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1486 if (LocaleCompare("emboss",option+1) == 0)
1491 (void) SyncImageSettings(mogrify_info,*image,exception);
1492 flags=ParseGeometry(argv[i+1],&geometry_info);
1493 if ((flags & SigmaValue) == 0)
1494 geometry_info.sigma=1.0;
1495 mogrify_image=EmbossImage(*image,geometry_info.rho,
1496 geometry_info.sigma,exception);
1499 if (LocaleCompare("encipher",option+1) == 0)
1507 (void) SyncImageSettings(mogrify_info,*image,exception);
1508 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1509 if (passkey != (StringInfo *) NULL)
1511 (void) PasskeyEncipherImage(*image,passkey,exception);
1512 passkey=DestroyStringInfo(passkey);
1516 if (LocaleCompare("encoding",option+1) == 0)
1518 (void) CloneString(&draw_info->encoding,argv[i+1]);
1521 if (LocaleCompare("enhance",option+1) == 0)
1526 (void) SyncImageSettings(mogrify_info,*image,exception);
1527 mogrify_image=EnhanceImage(*image,exception);
1530 if (LocaleCompare("equalize",option+1) == 0)
1535 (void) SyncImageSettings(mogrify_info,*image,exception);
1536 (void) EqualizeImage(*image,exception);
1539 if (LocaleCompare("evaluate",option+1) == 0)
1544 MagickEvaluateOperator
1547 (void) SyncImageSettings(mogrify_info,*image,exception);
1548 op=(MagickEvaluateOperator) ParseCommandOption(
1549 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1550 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1552 (void) EvaluateImage(*image,op,constant,exception);
1555 if (LocaleCompare("extent",option+1) == 0)
1558 Set the image extent.
1560 (void) SyncImageSettings(mogrify_info,*image,exception);
1561 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1562 if (geometry.width == 0)
1563 geometry.width=(*image)->columns;
1564 if (geometry.height == 0)
1565 geometry.height=(*image)->rows;
1566 mogrify_image=ExtentImage(*image,&geometry,exception);
1573 if (LocaleCompare("family",option+1) == 0)
1577 if (draw_info->family != (char *) NULL)
1578 draw_info->family=DestroyString(draw_info->family);
1581 (void) CloneString(&draw_info->family,argv[i+1]);
1584 if (LocaleCompare("features",option+1) == 0)
1588 (void) DeleteImageArtifact(*image,"identify:features");
1591 (void) SetImageArtifact(*image,"vdentify:features",argv[i+1]);
1592 (void) SetImageArtifact(*image,"verbose","true");
1595 if (LocaleCompare("fill",option+1) == 0)
1603 GetPixelInfo(*image,&fill);
1606 (void) QueryColorCompliance("none",AllCompliance,&fill,
1608 draw_info->fill=fill;
1609 if (draw_info->fill_pattern != (Image *) NULL)
1610 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1613 sans=AcquireExceptionInfo();
1614 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1615 sans=DestroyExceptionInfo(sans);
1616 if (status == MagickFalse)
1617 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1620 draw_info->fill=fill=color;
1623 if (LocaleCompare("flip",option+1) == 0)
1626 Flip image scanlines.
1628 (void) SyncImageSettings(mogrify_info,*image,exception);
1629 mogrify_image=FlipImage(*image,exception);
1632 if (LocaleCompare("floodfill",option+1) == 0)
1640 (void) SyncImageSettings(mogrify_info,*image,exception);
1641 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1642 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1644 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1645 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1648 if (LocaleCompare("flop",option+1) == 0)
1651 Flop image scanlines.
1653 (void) SyncImageSettings(mogrify_info,*image,exception);
1654 mogrify_image=FlopImage(*image,exception);
1657 if (LocaleCompare("font",option+1) == 0)
1661 if (draw_info->font != (char *) NULL)
1662 draw_info->font=DestroyString(draw_info->font);
1665 (void) CloneString(&draw_info->font,argv[i+1]);
1668 if (LocaleCompare("format",option+1) == 0)
1673 if (LocaleCompare("frame",option+1) == 0)
1679 Surround image with an ornamental border.
1681 (void) SyncImageSettings(mogrify_info,*image,exception);
1682 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1683 frame_info.width=geometry.width;
1684 frame_info.height=geometry.height;
1685 frame_info.outer_bevel=geometry.x;
1686 frame_info.inner_bevel=geometry.y;
1687 frame_info.x=(ssize_t) frame_info.width;
1688 frame_info.y=(ssize_t) frame_info.height;
1689 frame_info.width=(*image)->columns+2*frame_info.width;
1690 frame_info.height=(*image)->rows+2*frame_info.height;
1691 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1694 if (LocaleCompare("function",option+1) == 0)
1698 token[MagickPathExtent];
1716 Function Modify Image Values
1718 (void) SyncImageSettings(mogrify_info,*image,exception);
1719 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1720 MagickFalse,argv[i+1]);
1721 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1723 if (arguments == (char *) NULL)
1725 p=(char *) arguments;
1726 for (x=0; *p != '\0'; x++)
1728 GetNextToken(p,&p,MagickPathExtent,token);
1730 GetNextToken(p,&p,MagickPathExtent,token);
1732 number_parameters=(size_t) x;
1733 parameters=(double *) AcquireQuantumMemory(number_parameters,
1734 sizeof(*parameters));
1735 if (parameters == (double *) NULL)
1736 ThrowWandFatalException(ResourceLimitFatalError,
1737 "MemoryAllocationFailed",(*image)->filename);
1738 (void) ResetMagickMemory(parameters,0,number_parameters*
1739 sizeof(*parameters));
1740 p=(char *) arguments;
1741 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1743 GetNextToken(p,&p,MagickPathExtent,token);
1745 GetNextToken(p,&p,MagickPathExtent,token);
1746 parameters[x]=StringToDouble(token,(char **) NULL);
1748 arguments=DestroyString(arguments);
1749 (void) FunctionImage(*image,function,number_parameters,parameters,
1751 parameters=(double *) RelinquishMagickMemory(parameters);
1758 if (LocaleCompare("gamma",option+1) == 0)
1763 (void) SyncImageSettings(mogrify_info,*image,exception);
1765 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1767 (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),
1771 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1772 (LocaleCompare("gaussian",option+1) == 0))
1775 Gaussian blur image.
1777 (void) SyncImageSettings(mogrify_info,*image,exception);
1778 flags=ParseGeometry(argv[i+1],&geometry_info);
1779 if ((flags & SigmaValue) == 0)
1780 geometry_info.sigma=1.0;
1781 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1782 geometry_info.sigma,exception);
1785 if (LocaleCompare("geometry",option+1) == 0)
1788 Record Image offset, Resize last image.
1790 (void) SyncImageSettings(mogrify_info,*image,exception);
1793 if ((*image)->geometry != (char *) NULL)
1794 (*image)->geometry=DestroyString((*image)->geometry);
1797 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1798 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1799 (void) CloneString(&(*image)->geometry,argv[i+1]);
1801 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1802 (*image)->filter,exception);
1805 if (LocaleCompare("gravity",option+1) == 0)
1809 draw_info->gravity=UndefinedGravity;
1812 draw_info->gravity=(GravityType) ParseCommandOption(
1813 MagickGravityOptions,MagickFalse,argv[i+1]);
1816 if (LocaleCompare("grayscale",option+1) == 0)
1818 PixelIntensityMethod
1821 (void) SyncImageSettings(mogrify_info,*image,exception);
1822 method=(PixelIntensityMethod) ParseCommandOption(
1823 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1824 (void) GrayscaleImage(*image,method,exception);
1831 if (LocaleCompare("highlight-color",option+1) == 0)
1833 (void) SetImageArtifact(*image,"compare:highlight-color",argv[i+1]);
1836 if (LocaleCompare("hough-lines",option+1) == 0)
1839 Detect edges in the image.
1841 (void) SyncImageSettings(mogrify_info,*image,exception);
1842 flags=ParseGeometry(argv[i+1],&geometry_info);
1843 if ((flags & SigmaValue) == 0)
1844 geometry_info.sigma=geometry_info.rho;
1845 if ((flags & XiValue) == 0)
1846 geometry_info.xi=40;
1847 mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1848 (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1855 if (LocaleCompare("identify",option+1) == 0)
1860 (void) SyncImageSettings(mogrify_info,*image,exception);
1861 if (format == (char *) NULL)
1863 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1867 text=InterpretImageProperties(mogrify_info,*image,format,
1869 if (text == (char *) NULL)
1871 (void) fputs(text,stdout);
1872 text=DestroyString(text);
1875 if (LocaleCompare("implode",option+1) == 0)
1880 (void) SyncImageSettings(mogrify_info,*image,exception);
1881 (void) ParseGeometry(argv[i+1],&geometry_info);
1882 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1883 interpolate_method,exception);
1886 if (LocaleCompare("interline-spacing",option+1) == 0)
1889 (void) ParseGeometry("0",&geometry_info);
1891 (void) ParseGeometry(argv[i+1],&geometry_info);
1892 draw_info->interline_spacing=geometry_info.rho;
1895 if (LocaleCompare("interpolate",option+1) == 0)
1897 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1898 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1901 if (LocaleCompare("interword-spacing",option+1) == 0)
1904 (void) ParseGeometry("0",&geometry_info);
1906 (void) ParseGeometry(argv[i+1],&geometry_info);
1907 draw_info->interword_spacing=geometry_info.rho;
1910 if (LocaleCompare("interpolative-resize",option+1) == 0)
1913 Interpolative resize image.
1915 (void) SyncImageSettings(mogrify_info,*image,exception);
1916 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1917 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1918 geometry.height,interpolate_method,exception);
1925 if (LocaleCompare("kerning",option+1) == 0)
1928 (void) ParseGeometry("0",&geometry_info);
1930 (void) ParseGeometry(argv[i+1],&geometry_info);
1931 draw_info->kerning=geometry_info.rho;
1934 if (LocaleCompare("kuwahara",option+1) == 0)
1937 Edge preserving blur.
1939 (void) SyncImageSettings(mogrify_info,*image,exception);
1940 flags=ParseGeometry(argv[i+1],&geometry_info);
1941 if ((flags & SigmaValue) == 0)
1942 geometry_info.sigma=geometry_info.rho-0.5;
1943 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1944 geometry_info.sigma,exception);
1951 if (LocaleCompare("lat",option+1) == 0)
1954 Local adaptive threshold image.
1956 (void) SyncImageSettings(mogrify_info,*image,exception);
1957 flags=ParseGeometry(argv[i+1],&geometry_info);
1958 if ((flags & PercentValue) != 0)
1959 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1960 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1961 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1962 geometry_info.xi,exception);
1965 if (LocaleCompare("level",option+1) == 0)
1975 (void) SyncImageSettings(mogrify_info,*image,exception);
1976 flags=ParseGeometry(argv[i+1],&geometry_info);
1977 black_point=geometry_info.rho;
1978 white_point=(double) QuantumRange;
1979 if ((flags & SigmaValue) != 0)
1980 white_point=geometry_info.sigma;
1982 if ((flags & XiValue) != 0)
1983 gamma=geometry_info.xi;
1984 if ((flags & PercentValue) != 0)
1986 black_point*=(double) (QuantumRange/100.0);
1987 white_point*=(double) (QuantumRange/100.0);
1989 if ((flags & SigmaValue) == 0)
1990 white_point=(double) QuantumRange-black_point;
1991 if ((*option == '+') || ((flags & AspectValue) != 0))
1992 (void) LevelizeImage(*image,black_point,white_point,gamma,
1995 (void) LevelImage(*image,black_point,white_point,gamma,
1999 if (LocaleCompare("level-colors",option+1) == 0)
2002 token[MagickPathExtent];
2011 p=(const char *) argv[i+1];
2012 GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */
2013 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2014 (void) QueryColorCompliance(token,AllCompliance,
2015 &black_point,exception);
2017 (void) QueryColorCompliance("#000000",AllCompliance,
2018 &black_point,exception);
2019 if (isalpha((int) token[0]) || (token[0] == '#'))
2020 GetNextToken(p,&p,MagickPathExtent,token);
2022 white_point=black_point; /* set everything to that color */
2025 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2026 GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */
2027 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2028 (void) QueryColorCompliance(token,AllCompliance,
2029 &white_point,exception);
2031 (void) QueryColorCompliance("#ffffff",AllCompliance,
2032 &white_point,exception);
2034 (void) LevelImageColors(*image,&black_point,&white_point,
2035 *option == '+' ? MagickTrue : MagickFalse,exception);
2038 if (LocaleCompare("linear-stretch",option+1) == 0)
2044 (void) SyncImageSettings(mogrify_info,*image,exception);
2045 flags=ParseGeometry(argv[i+1],&geometry_info);
2046 black_point=geometry_info.rho;
2047 white_point=(double) (*image)->columns*(*image)->rows;
2048 if ((flags & SigmaValue) != 0)
2049 white_point=geometry_info.sigma;
2050 if ((flags & PercentValue) != 0)
2052 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2053 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2055 if ((flags & SigmaValue) == 0)
2056 white_point=(double) (*image)->columns*(*image)->rows-
2058 (void) LinearStretchImage(*image,black_point,white_point,exception);
2061 if (LocaleCompare("liquid-rescale",option+1) == 0)
2064 Liquid rescale image.
2066 (void) SyncImageSettings(mogrify_info,*image,exception);
2067 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2068 if ((flags & XValue) == 0)
2070 if ((flags & YValue) == 0)
2072 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2073 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2076 if (LocaleCompare("local-contrast",option+1) == 0)
2078 (void) SyncImageSettings(mogrify_info,*image,exception);
2079 flags=ParseGeometry(argv[i+1],&geometry_info);
2080 if ((flags & RhoValue) == 0)
2081 geometry_info.rho=10;
2082 if ((flags & SigmaValue) == 0)
2083 geometry_info.sigma=12.5;
2084 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2085 geometry_info.sigma,exception);
2088 if (LocaleCompare("lowlight-color",option+1) == 0)
2090 (void) SetImageArtifact(*image,"compare:lowlight-color",argv[i+1]);
2097 if (LocaleCompare("magnify",option+1) == 0)
2102 (void) SyncImageSettings(mogrify_info,*image,exception);
2103 mogrify_image=MagnifyImage(*image,exception);
2106 if (LocaleCompare("map",option+1) == 0)
2112 Transform image colors to match this set of colors.
2114 (void) SyncImageSettings(mogrify_info,*image,exception);
2117 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2118 if (remap_image == (Image *) NULL)
2120 (void) RemapImage(quantize_info,*image,remap_image,exception);
2121 remap_image=DestroyImage(remap_image);
2124 if (LocaleCompare("mask",option+1) == 0)
2129 (void) SyncImageSettings(mogrify_info,*image,exception);
2135 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
2142 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2143 if (mask == (Image *) NULL)
2145 (void) NegateImage(mask,MagickFalse,exception);
2146 (void) SetImageMask(*image,WritePixelMask,mask,exception);
2147 mask=DestroyImage(mask);
2150 if (LocaleCompare("matte",option+1) == 0)
2152 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2153 SetAlphaChannel : DeactivateAlphaChannel,exception);
2156 if (LocaleCompare("mean-shift",option+1) == 0)
2159 Detect edges in the image.
2161 (void) SyncImageSettings(mogrify_info,*image,exception);
2162 flags=ParseGeometry(argv[i+1],&geometry_info);
2163 if ((flags & SigmaValue) == 0)
2164 geometry_info.sigma=geometry_info.rho;
2165 if ((flags & XiValue) == 0)
2166 geometry_info.xi=0.10*QuantumRange;
2167 if ((flags & PercentValue) != 0)
2168 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2169 mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2170 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2173 if (LocaleCompare("median",option+1) == 0)
2176 Median filter image.
2178 (void) SyncImageSettings(mogrify_info,*image,exception);
2179 flags=ParseGeometry(argv[i+1],&geometry_info);
2180 if ((flags & SigmaValue) == 0)
2181 geometry_info.sigma=geometry_info.rho;
2182 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2183 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2186 if (LocaleCompare("mode",option+1) == 0)
2191 (void) SyncImageSettings(mogrify_info,*image,exception);
2192 flags=ParseGeometry(argv[i+1],&geometry_info);
2193 if ((flags & SigmaValue) == 0)
2194 geometry_info.sigma=geometry_info.rho;
2195 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2196 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2199 if (LocaleCompare("modulate",option+1) == 0)
2201 (void) SyncImageSettings(mogrify_info,*image,exception);
2202 (void) ModulateImage(*image,argv[i+1],exception);
2205 if (LocaleCompare("moments",option+1) == 0)
2209 (void) DeleteImageArtifact(*image,"identify:moments");
2212 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2213 (void) SetImageArtifact(*image,"verbose","true");
2216 if (LocaleCompare("monitor",option+1) == 0)
2220 (void) SetImageProgressMonitor(*image,
2221 (MagickProgressMonitor) NULL,(void *) NULL);
2224 (void) SetImageProgressMonitor(*image,MonitorProgress,
2228 if (LocaleCompare("monochrome",option+1) == 0)
2230 (void) SyncImageSettings(mogrify_info,*image,exception);
2231 (void) SetImageType(*image,BilevelType,exception);
2234 if (LocaleCompare("morphology",option+1) == 0)
2237 token[MagickPathExtent];
2252 Morphological Image Operation
2254 (void) SyncImageSettings(mogrify_info,*image,exception);
2256 GetNextToken(p,&p,MagickPathExtent,token);
2257 method=(MorphologyMethod) ParseCommandOption(
2258 MagickMorphologyOptions,MagickFalse,token);
2260 GetNextToken(p,&p,MagickPathExtent,token);
2261 if ((*p == ':') || (*p == ','))
2262 GetNextToken(p,&p,MagickPathExtent,token);
2264 iterations=(ssize_t) StringToLong(p);
2265 kernel=AcquireKernelInfo(argv[i+2],exception);
2266 if (kernel == (KernelInfo *) NULL)
2268 (void) ThrowMagickException(exception,GetMagickModule(),
2269 OptionError,"UnabletoParseKernel","morphology");
2273 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2275 kernel=DestroyKernelInfo(kernel);
2278 if (LocaleCompare("motion-blur",option+1) == 0)
2283 (void) SyncImageSettings(mogrify_info,*image,exception);
2284 flags=ParseGeometry(argv[i+1],&geometry_info);
2285 if ((flags & SigmaValue) == 0)
2286 geometry_info.sigma=1.0;
2287 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2288 geometry_info.sigma,geometry_info.xi,exception);
2295 if (LocaleCompare("negate",option+1) == 0)
2297 (void) SyncImageSettings(mogrify_info,*image,exception);
2298 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2299 MagickFalse,exception);
2302 if (LocaleCompare("noise",option+1) == 0)
2304 (void) SyncImageSettings(mogrify_info,*image,exception);
2307 flags=ParseGeometry(argv[i+1],&geometry_info);
2308 if ((flags & SigmaValue) == 0)
2309 geometry_info.sigma=geometry_info.rho;
2310 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2311 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2318 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2319 MagickFalse,argv[i+1]);
2320 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2324 if (LocaleCompare("normalize",option+1) == 0)
2326 (void) SyncImageSettings(mogrify_info,*image,exception);
2327 (void) NormalizeImage(*image,exception);
2334 if (LocaleCompare("opaque",option+1) == 0)
2339 (void) SyncImageSettings(mogrify_info,*image,exception);
2340 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2342 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2343 MagickFalse : MagickTrue,exception);
2346 if (LocaleCompare("ordered-dither",option+1) == 0)
2348 (void) SyncImageSettings(mogrify_info,*image,exception);
2349 (void) OrderedDitherImage(*image,argv[i+1],exception);
2356 if (LocaleCompare("paint",option+1) == 0)
2358 (void) SyncImageSettings(mogrify_info,*image,exception);
2359 (void) ParseGeometry(argv[i+1],&geometry_info);
2360 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2361 geometry_info.sigma,exception);
2364 if (LocaleCompare("perceptible",option+1) == 0)
2369 (void) SyncImageSettings(mogrify_info,*image,exception);
2370 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2371 (char **) NULL),exception);
2374 if (LocaleCompare("pointsize",option+1) == 0)
2377 (void) ParseGeometry("12",&geometry_info);
2379 (void) ParseGeometry(argv[i+1],&geometry_info);
2380 draw_info->pointsize=geometry_info.rho;
2383 if (LocaleCompare("polaroid",option+1) == 0)
2395 Simulate a Polaroid picture.
2397 (void) SyncImageSettings(mogrify_info,*image,exception);
2398 random_info=AcquireRandomInfo();
2399 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2400 random_info=DestroyRandomInfo(random_info);
2403 SetGeometryInfo(&geometry_info);
2404 flags=ParseGeometry(argv[i+1],&geometry_info);
2405 angle=geometry_info.rho;
2407 caption=GetImageProperty(*image,"caption",exception);
2408 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2409 interpolate_method,exception);
2412 if (LocaleCompare("posterize",option+1) == 0)
2417 (void) SyncImageSettings(mogrify_info,*image,exception);
2418 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2419 quantize_info->dither_method,exception);
2422 if (LocaleCompare("preview",option+1) == 0)
2430 (void) SyncImageSettings(mogrify_info,*image,exception);
2432 preview_type=UndefinedPreview;
2434 preview_type=(PreviewType) ParseCommandOption(
2435 MagickPreviewOptions,MagickFalse,argv[i+1]);
2436 mogrify_image=PreviewImage(*image,preview_type,exception);
2439 if (LocaleCompare("profile",option+1) == 0)
2453 (void) SyncImageSettings(mogrify_info,*image,exception);
2457 Remove a profile from the image.
2459 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2464 Associate a profile with the image.
2466 profile_info=CloneImageInfo(mogrify_info);
2467 profile=GetImageProfile(*image,"iptc");
2468 if (profile != (StringInfo *) NULL)
2469 profile_info->profile=(void *) CloneStringInfo(profile);
2470 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2471 profile_info=DestroyImageInfo(profile_info);
2472 if (profile_image == (Image *) NULL)
2477 profile_info=CloneImageInfo(mogrify_info);
2478 (void) CopyMagickString(profile_info->filename,argv[i+1],
2480 file_data=FileToStringInfo(profile_info->filename,~0UL,
2482 if (file_data != (StringInfo *) NULL)
2484 (void) ProfileImage(*image,profile_info->magick,
2485 GetStringInfoDatum(file_data),
2486 GetStringInfoLength(file_data),exception);
2487 file_data=DestroyStringInfo(file_data);
2489 profile_info=DestroyImageInfo(profile_info);
2492 ResetImageProfileIterator(profile_image);
2493 name=GetNextImageProfile(profile_image);
2494 while (name != (const char *) NULL)
2496 profile=GetImageProfile(profile_image,name);
2497 if (profile != (StringInfo *) NULL)
2498 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2499 (size_t) GetStringInfoLength(profile),exception);
2500 name=GetNextImageProfile(profile_image);
2502 profile_image=DestroyImage(profile_image);
2509 if (LocaleCompare("quantize",option+1) == 0)
2513 quantize_info->colorspace=UndefinedColorspace;
2516 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2517 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2524 if (LocaleCompare("rotational-blur",option+1) == 0)
2527 Rotational blur image.
2529 (void) SyncImageSettings(mogrify_info,*image,exception);
2530 flags=ParseGeometry(argv[i+1],&geometry_info);
2531 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,exception);
2534 if (LocaleCompare("raise",option+1) == 0)
2537 Surround image with a raise of solid color.
2539 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2540 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2541 MagickFalse,exception);
2544 if (LocaleCompare("random-threshold",option+1) == 0)
2553 (void) SyncImageSettings(mogrify_info,*image,exception);
2555 max_threshold=(double) QuantumRange;
2556 flags=ParseGeometry(argv[i+1],&geometry_info);
2557 min_threshold=geometry_info.rho;
2558 max_threshold=geometry_info.sigma;
2559 if ((flags & SigmaValue) == 0)
2560 max_threshold=min_threshold;
2561 if (strchr(argv[i+1],'%') != (char *) NULL)
2563 max_threshold*=(double) (0.01*QuantumRange);
2564 min_threshold*=(double) (0.01*QuantumRange);
2566 (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2570 if (LocaleCompare("read-mask",option+1) == 0)
2575 (void) SyncImageSettings(mogrify_info,*image,exception);
2581 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
2588 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2589 if (mask == (Image *) NULL)
2591 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2592 mask=DestroyImage(mask);
2595 if (LocaleCompare("region",option+1) == 0)
2598 Apply read mask as defined by a region geometry.
2600 (void) SyncImageSettings(mogrify_info,*image,exception);
2603 (void) SetImageRegionMask(*image,ReadPixelMask,
2604 (const RectangleInfo *) NULL,exception);
2607 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2608 (void) SetImageRegionMask(*image,ReadPixelMask,&geometry,exception);
2611 if (LocaleCompare("render",option+1) == 0)
2613 (void) SyncImageSettings(mogrify_info,*image,exception);
2614 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2617 if (LocaleCompare("remap",option+1) == 0)
2623 Transform image colors to match this set of colors.
2625 (void) SyncImageSettings(mogrify_info,*image,exception);
2628 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2629 if (remap_image == (Image *) NULL)
2631 (void) RemapImage(quantize_info,*image,remap_image,exception);
2632 remap_image=DestroyImage(remap_image);
2635 if (LocaleCompare("repage",option+1) == 0)
2639 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2642 (void) ResetImagePage(*image,argv[i+1]);
2645 if (LocaleCompare("resample",option+1) == 0)
2650 (void) SyncImageSettings(mogrify_info,*image,exception);
2651 flags=ParseGeometry(argv[i+1],&geometry_info);
2652 if ((flags & SigmaValue) == 0)
2653 geometry_info.sigma=geometry_info.rho;
2654 mogrify_image=ResampleImage(*image,geometry_info.rho,
2655 geometry_info.sigma,(*image)->filter,exception);
2658 if (LocaleCompare("resize",option+1) == 0)
2663 (void) SyncImageSettings(mogrify_info,*image,exception);
2664 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2665 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2666 (*image)->filter,exception);
2669 if (LocaleCompare("roll",option+1) == 0)
2674 (void) SyncImageSettings(mogrify_info,*image,exception);
2675 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2676 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2679 if (LocaleCompare("rotate",option+1) == 0)
2685 Check for conditional image rotation.
2687 (void) SyncImageSettings(mogrify_info,*image,exception);
2688 if (strchr(argv[i+1],'>') != (char *) NULL)
2689 if ((*image)->columns <= (*image)->rows)
2691 if (strchr(argv[i+1],'<') != (char *) NULL)
2692 if ((*image)->columns >= (*image)->rows)
2697 rotation=ConstantString(argv[i+1]);
2698 (void) SubstituteString(&rotation,">","");
2699 (void) SubstituteString(&rotation,"<","");
2700 (void) ParseGeometry(rotation,&geometry_info);
2701 rotation=DestroyString(rotation);
2702 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2709 if (LocaleCompare("sample",option+1) == 0)
2712 Sample image with pixel replication.
2714 (void) SyncImageSettings(mogrify_info,*image,exception);
2715 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2716 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2720 if (LocaleCompare("scale",option+1) == 0)
2725 (void) SyncImageSettings(mogrify_info,*image,exception);
2726 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2727 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2731 if (LocaleCompare("selective-blur",option+1) == 0)
2734 Selectively blur pixels within a contrast threshold.
2736 (void) SyncImageSettings(mogrify_info,*image,exception);
2737 flags=ParseGeometry(argv[i+1],&geometry_info);
2738 if ((flags & PercentValue) != 0)
2739 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2740 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2741 geometry_info.sigma,geometry_info.xi,exception);
2744 if (LocaleCompare("separate",option+1) == 0)
2747 Break channels into separate images.
2749 (void) SyncImageSettings(mogrify_info,*image,exception);
2750 mogrify_image=SeparateImages(*image,exception);
2753 if (LocaleCompare("sepia-tone",option+1) == 0)
2761 (void) SyncImageSettings(mogrify_info,*image,exception);
2762 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2764 mogrify_image=SepiaToneImage(*image,threshold,exception);
2767 if (LocaleCompare("segment",option+1) == 0)
2772 (void) SyncImageSettings(mogrify_info,*image,exception);
2773 flags=ParseGeometry(argv[i+1],&geometry_info);
2774 if ((flags & SigmaValue) == 0)
2775 geometry_info.sigma=1.0;
2776 (void) SegmentImage(*image,(*image)->colorspace,
2777 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2781 if (LocaleCompare("set",option+1) == 0)
2791 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2792 (void) DeleteImageRegistry(argv[i+1]+9);
2794 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2796 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2797 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2800 (void) DeleteImageProperty(*image,argv[i+1]);
2803 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2805 if (value == (char *) NULL)
2807 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2808 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2811 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2813 (void) SetImageOption(image_info,argv[i+1]+7,value);
2814 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2815 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2818 (void) SetImageProperty(*image,argv[i+1],value,exception);
2819 value=DestroyString(value);
2822 if (LocaleCompare("shade",option+1) == 0)
2827 (void) SyncImageSettings(mogrify_info,*image,exception);
2828 flags=ParseGeometry(argv[i+1],&geometry_info);
2829 if ((flags & SigmaValue) == 0)
2830 geometry_info.sigma=1.0;
2831 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2832 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2835 if (LocaleCompare("shadow",option+1) == 0)
2840 (void) SyncImageSettings(mogrify_info,*image,exception);
2841 flags=ParseGeometry(argv[i+1],&geometry_info);
2842 if ((flags & SigmaValue) == 0)
2843 geometry_info.sigma=1.0;
2844 if ((flags & XiValue) == 0)
2845 geometry_info.xi=4.0;
2846 if ((flags & PsiValue) == 0)
2847 geometry_info.psi=4.0;
2848 mogrify_image=ShadowImage(*image,geometry_info.rho,
2849 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2850 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2853 if (LocaleCompare("sharpen",option+1) == 0)
2858 (void) SyncImageSettings(mogrify_info,*image,exception);
2859 flags=ParseGeometry(argv[i+1],&geometry_info);
2860 if ((flags & SigmaValue) == 0)
2861 geometry_info.sigma=1.0;
2862 if ((flags & XiValue) == 0)
2863 geometry_info.xi=0.0;
2864 mogrify_image=SharpenImage(*image,geometry_info.rho,
2865 geometry_info.sigma,exception);
2868 if (LocaleCompare("shave",option+1) == 0)
2871 Shave the image edges.
2873 (void) SyncImageSettings(mogrify_info,*image,exception);
2874 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2875 mogrify_image=ShaveImage(*image,&geometry,exception);
2878 if (LocaleCompare("shear",option+1) == 0)
2883 (void) SyncImageSettings(mogrify_info,*image,exception);
2884 flags=ParseGeometry(argv[i+1],&geometry_info);
2885 if ((flags & SigmaValue) == 0)
2886 geometry_info.sigma=geometry_info.rho;
2887 mogrify_image=ShearImage(*image,geometry_info.rho,
2888 geometry_info.sigma,exception);
2891 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2894 Sigmoidal non-linearity contrast control.
2896 (void) SyncImageSettings(mogrify_info,*image,exception);
2897 flags=ParseGeometry(argv[i+1],&geometry_info);
2898 if ((flags & SigmaValue) == 0)
2899 geometry_info.sigma=(double) QuantumRange/2.0;
2900 if ((flags & PercentValue) != 0)
2901 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2903 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2904 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2908 if (LocaleCompare("sketch",option+1) == 0)
2913 (void) SyncImageSettings(mogrify_info,*image,exception);
2914 flags=ParseGeometry(argv[i+1],&geometry_info);
2915 if ((flags & SigmaValue) == 0)
2916 geometry_info.sigma=1.0;
2917 mogrify_image=SketchImage(*image,geometry_info.rho,
2918 geometry_info.sigma,geometry_info.xi,exception);
2921 if (LocaleCompare("solarize",option+1) == 0)
2926 (void) SyncImageSettings(mogrify_info,*image,exception);
2927 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2929 (void) SolarizeImage(*image,threshold,exception);
2932 if (LocaleCompare("sparse-color",option+1) == 0)
2941 Sparse Color Interpolated Gradient
2943 (void) SyncImageSettings(mogrify_info,*image,exception);
2944 method=(SparseColorMethod) ParseCommandOption(
2945 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2946 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2948 if (arguments == (char *) NULL)
2950 mogrify_image=SparseColorOption(*image,method,arguments,
2951 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2952 arguments=DestroyString(arguments);
2955 if (LocaleCompare("splice",option+1) == 0)
2958 Splice a solid color into the image.
2960 (void) SyncImageSettings(mogrify_info,*image,exception);
2961 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2962 mogrify_image=SpliceImage(*image,&geometry,exception);
2965 if (LocaleCompare("spread",option+1) == 0)
2970 (void) SyncImageSettings(mogrify_info,*image,exception);
2971 (void) ParseGeometry(argv[i+1],&geometry_info);
2972 mogrify_image=SpreadImage(*image,interpolate_method,
2973 geometry_info.rho,exception);
2976 if (LocaleCompare("statistic",option+1) == 0)
2981 (void) SyncImageSettings(mogrify_info,*image,exception);
2982 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2983 MagickFalse,argv[i+1]);
2984 (void) ParseGeometry(argv[i+2],&geometry_info);
2985 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2986 (size_t) geometry_info.sigma,exception);
2989 if (LocaleCompare("stretch",option+1) == 0)
2993 draw_info->stretch=UndefinedStretch;
2996 draw_info->stretch=(StretchType) ParseCommandOption(
2997 MagickStretchOptions,MagickFalse,argv[i+1]);
3000 if (LocaleCompare("strip",option+1) == 0)
3003 Strip image of profiles and comments.
3005 (void) SyncImageSettings(mogrify_info,*image,exception);
3006 (void) StripImage(*image,exception);
3009 if (LocaleCompare("stroke",option+1) == 0)
3019 (void) QueryColorCompliance("none",AllCompliance,
3020 &draw_info->stroke,exception);
3021 if (draw_info->stroke_pattern != (Image *) NULL)
3022 draw_info->stroke_pattern=DestroyImage(
3023 draw_info->stroke_pattern);
3026 sans=AcquireExceptionInfo();
3027 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
3028 sans=DestroyExceptionInfo(sans);
3029 if (status == MagickFalse)
3030 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3033 draw_info->stroke=color;
3036 if (LocaleCompare("strokewidth",option+1) == 0)
3038 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
3041 if (LocaleCompare("style",option+1) == 0)
3045 draw_info->style=UndefinedStyle;
3048 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3049 MagickFalse,argv[i+1]);
3052 if (LocaleCompare("swirl",option+1) == 0)
3057 (void) SyncImageSettings(mogrify_info,*image,exception);
3058 (void) ParseGeometry(argv[i+1],&geometry_info);
3059 mogrify_image=SwirlImage(*image,geometry_info.rho,
3060 interpolate_method,exception);
3067 if (LocaleCompare("threshold",option+1) == 0)
3075 (void) SyncImageSettings(mogrify_info,*image,exception);
3077 threshold=(double) QuantumRange/2;
3079 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3081 (void) BilevelImage(*image,threshold,exception);
3084 if (LocaleCompare("thumbnail",option+1) == 0)
3089 (void) SyncImageSettings(mogrify_info,*image,exception);
3090 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3091 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3095 if (LocaleCompare("tile",option+1) == 0)
3099 if (draw_info->fill_pattern != (Image *) NULL)
3100 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3103 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3107 if (LocaleCompare("tint",option+1) == 0)
3112 (void) SyncImageSettings(mogrify_info,*image,exception);
3113 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3116 if (LocaleCompare("transform",option+1) == 0)
3119 Affine transform image.
3121 (void) SyncImageSettings(mogrify_info,*image,exception);
3122 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3126 if (LocaleCompare("transparent",option+1) == 0)
3131 (void) SyncImageSettings(mogrify_info,*image,exception);
3132 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3134 (void) TransparentPaintImage(*image,&target,(Quantum)
3135 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3139 if (LocaleCompare("transpose",option+1) == 0)
3142 Transpose image scanlines.
3144 (void) SyncImageSettings(mogrify_info,*image,exception);
3145 mogrify_image=TransposeImage(*image,exception);
3148 if (LocaleCompare("transverse",option+1) == 0)
3151 Transverse image scanlines.
3153 (void) SyncImageSettings(mogrify_info,*image,exception);
3154 mogrify_image=TransverseImage(*image,exception);
3157 if (LocaleCompare("treedepth",option+1) == 0)
3159 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3162 if (LocaleCompare("trim",option+1) == 0)
3167 (void) SyncImageSettings(mogrify_info,*image,exception);
3168 mogrify_image=TrimImage(*image,exception);
3171 if (LocaleCompare("type",option+1) == 0)
3176 (void) SyncImageSettings(mogrify_info,*image,exception);
3180 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3182 (*image)->type=UndefinedType;
3183 (void) SetImageType(*image,type,exception);
3190 if (LocaleCompare("undercolor",option+1) == 0)
3192 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3193 &draw_info->undercolor,exception);
3196 if (LocaleCompare("unique",option+1) == 0)
3200 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3203 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3204 (void) SetImageArtifact(*image,"verbose","true");
3207 if (LocaleCompare("unique-colors",option+1) == 0)
3210 Unique image colors.
3212 (void) SyncImageSettings(mogrify_info,*image,exception);
3213 mogrify_image=UniqueImageColors(*image,exception);
3216 if (LocaleCompare("unsharp",option+1) == 0)
3221 (void) SyncImageSettings(mogrify_info,*image,exception);
3222 flags=ParseGeometry(argv[i+1],&geometry_info);
3223 if ((flags & SigmaValue) == 0)
3224 geometry_info.sigma=1.0;
3225 if ((flags & XiValue) == 0)
3226 geometry_info.xi=1.0;
3227 if ((flags & PsiValue) == 0)
3228 geometry_info.psi=0.05;
3229 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3230 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3238 if (LocaleCompare("verbose",option+1) == 0)
3240 (void) SetImageArtifact(*image,option+1,
3241 *option == '+' ? "false" : "true");
3244 if (LocaleCompare("vignette",option+1) == 0)
3249 (void) SyncImageSettings(mogrify_info,*image,exception);
3250 flags=ParseGeometry(argv[i+1],&geometry_info);
3251 if ((flags & SigmaValue) == 0)
3252 geometry_info.sigma=1.0;
3253 if ((flags & XiValue) == 0)
3254 geometry_info.xi=0.1*(*image)->columns;
3255 if ((flags & PsiValue) == 0)
3256 geometry_info.psi=0.1*(*image)->rows;
3257 if ((flags & PercentValue) != 0)
3259 geometry_info.xi*=(double) (*image)->columns/100.0;
3260 geometry_info.psi*=(double) (*image)->rows/100.0;
3262 mogrify_image=VignetteImage(*image,geometry_info.rho,
3263 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3264 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3267 if (LocaleCompare("virtual-pixel",option+1) == 0)
3271 (void) SetImageVirtualPixelMethod(*image,
3272 UndefinedVirtualPixelMethod,exception);
3275 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3276 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3277 argv[i+1]),exception);
3284 if (LocaleCompare("wave",option+1) == 0)
3289 (void) SyncImageSettings(mogrify_info,*image,exception);
3290 flags=ParseGeometry(argv[i+1],&geometry_info);
3291 if ((flags & SigmaValue) == 0)
3292 geometry_info.sigma=1.0;
3293 mogrify_image=WaveImage(*image,geometry_info.rho,
3294 geometry_info.sigma,interpolate_method,exception);
3297 if (LocaleCompare("wavelet-denoise",option+1) == 0)
3300 Wavelet denoise image.
3302 (void) SyncImageSettings(mogrify_info,*image,exception);
3303 flags=ParseGeometry(argv[i+1],&geometry_info);
3304 if ((flags & PercentValue) != 0)
3306 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
3307 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3309 if ((flags & SigmaValue) == 0)
3310 geometry_info.sigma=0.0;
3311 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3312 geometry_info.sigma,exception);
3315 if (LocaleCompare("weight",option+1) == 0)
3320 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3323 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3324 draw_info->weight=(size_t) weight;
3327 if (LocaleCompare("white-threshold",option+1) == 0)
3330 White threshold image.
3332 (void) SyncImageSettings(mogrify_info,*image,exception);
3333 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3336 if (LocaleCompare("write-mask",option+1) == 0)
3341 (void) SyncImageSettings(mogrify_info,*image,exception);
3347 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
3354 mask=GetImageCache(mogrify_info,argv[i+1],exception);
3355 if (mask == (Image *) NULL)
3357 (void) SetImageMask(*image,WritePixelMask,mask,exception);
3358 mask=DestroyImage(mask);
3367 Replace current image with any image that was generated
3369 if (mogrify_image != (Image *) NULL)
3370 ReplaceImageInListReturnLast(image,mogrify_image);
3376 quantize_info=DestroyQuantizeInfo(quantize_info);
3377 draw_info=DestroyDrawInfo(draw_info);
3378 mogrify_info=DestroyImageInfo(mogrify_info);
3379 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3380 return(status == 0 ? MagickFalse : MagickTrue);
3384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3388 + M o g r i f y I m a g e C o m m a n d %
3392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3394 % MogrifyImageCommand() transforms an image or a sequence of images. These
3395 % transforms include image scaling, image rotation, color reduction, and
3396 % others. The transmogrified image overwrites the original image.
3398 % The format of the MogrifyImageCommand method is:
3400 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3401 % const char **argv,char **metadata,ExceptionInfo *exception)
3403 % A description of each parameter follows:
3405 % o image_info: the image info.
3407 % o argc: the number of elements in the argument vector.
3409 % o argv: A text array containing the command line arguments.
3411 % o metadata: any metadata is returned here.
3413 % o exception: return any errors or warnings in this structure.
3417 static MagickBooleanType MogrifyUsage(void)
3420 *channel_operators[]=
3422 "-channel-fx expression",
3423 " exchange, extract, or transfer one or more image channels",
3424 "-separate separate an image channel into a grayscale image",
3429 "-debug events display copious debugging information",
3430 "-distribute-cache port",
3431 " distributed pixel cache spanning one or more servers",
3432 "-help print program options",
3433 "-list type print a list of supported option arguments",
3434 "-log format format of debugging information",
3435 "-version print version information",
3440 "-adaptive-blur geometry",
3441 " adaptively blur pixels; decrease effect near edges",
3442 "-adaptive-resize geometry",
3443 " adaptively resize image using 'mesh' interpolation",
3444 "-adaptive-sharpen geometry",
3445 " adaptively sharpen pixels; increase effect near edges",
3446 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3447 " transparent, extract, background, or shape",
3448 "-annotate geometry text",
3449 " annotate the image with text",
3450 "-auto-gamma automagically adjust gamma level of image",
3451 "-auto-level automagically adjust color levels of image",
3452 "-auto-orient automagically orient (rotate) image",
3453 "-bench iterations measure performance",
3454 "-black-threshold value",
3455 " force all pixels below the threshold into black",
3456 "-blue-shift simulate a scene at nighttime in the moonlight",
3457 "-blur geometry reduce image noise and reduce detail levels",
3458 "-border geometry surround image with a border of color",
3459 "-bordercolor color border color",
3460 "-brightness-contrast geometry",
3461 " improve brightness / contrast of the image",
3462 "-canny geometry detect edges in the image",
3463 "-cdl filename color correct with a color decision list",
3464 "-channel mask set the image channel mask",
3465 "-charcoal geometry simulate a charcoal drawing",
3466 "-chop geometry remove pixels from the image interior",
3467 "-clamp keep pixel values in range (0-QuantumRange)",
3468 "-clip clip along the first path from the 8BIM profile",
3469 "-clip-mask filename associate a clip mask with the image",
3470 "-clip-path id clip along a named path from the 8BIM profile",
3471 "-colorize value colorize the image with the fill color",
3472 "-color-matrix matrix apply color correction to the image",
3473 "-connected-components connectivity",
3474 " connected-components uniquely labeled",
3475 "-contrast enhance or reduce the image contrast",
3476 "-contrast-stretch geometry",
3477 " improve contrast by 'stretching' the intensity range",
3478 "-convolve coefficients",
3479 " apply a convolution kernel to the image",
3480 "-cycle amount cycle the image colormap",
3481 "-decipher filename convert cipher pixels to plain pixels",
3482 "-deskew threshold straighten an image",
3483 "-despeckle reduce the speckles within an image",
3484 "-distort method args",
3485 " distort images according to given method ad args",
3486 "-draw string annotate the image with a graphic primitive",
3487 "-edge radius apply a filter to detect edges in the image",
3488 "-encipher filename convert plain pixels to cipher pixels",
3489 "-emboss radius emboss an image",
3490 "-enhance apply a digital filter to enhance a noisy image",
3491 "-equalize perform histogram equalization to an image",
3492 "-evaluate operator value",
3493 " evaluate an arithmetic, relational, or logical expression",
3494 "-extent geometry set the image size",
3495 "-extract geometry extract area from image",
3496 "-fft implements the discrete Fourier transform (DFT)",
3497 "-flip flip image vertically",
3498 "-floodfill geometry color",
3499 " floodfill the image with color",
3500 "-flop flop image horizontally",
3501 "-frame geometry surround image with an ornamental border",
3502 "-function name parameters",
3503 " apply function over image values",
3504 "-gamma value level of gamma correction",
3505 "-gaussian-blur geometry",
3506 " reduce image noise and reduce detail levels",
3507 "-geometry geometry preferred size or location of the image",
3508 "-grayscale method convert image to grayscale",
3509 "-hough-lines geometry",
3510 " identify lines in the image",
3511 "-identify identify the format and characteristics of the image",
3512 "-ift implements the inverse discrete Fourier transform (DFT)",
3513 "-implode amount implode image pixels about the center",
3514 "-interpolative-resize geometry",
3515 " resize image using interpolation",
3516 "-kuwahara geometry edge preserving noise reduction filter",
3517 "-lat geometry local adaptive thresholding",
3518 "-level value adjust the level of image contrast",
3519 "-level-colors color,color",
3520 " level image with the given colors",
3521 "-linear-stretch geometry",
3522 " improve contrast by 'stretching with saturation'",
3523 "-liquid-rescale geometry",
3524 " rescale image with seam-carving",
3525 "-local-contrast geometry",
3526 " enhance local contrast",
3527 "-magnify double the size of the image with pixel art scaling",
3528 "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
3529 "-median geometry apply a median filter to the image",
3530 "-mode geometry make each pixel the 'predominant color' of the",
3532 "-modulate value vary the brightness, saturation, and hue",
3533 "-monochrome transform image to black and white",
3534 "-morphology method kernel",
3535 " apply a morphology method to the image",
3536 "-motion-blur geometry",
3537 " simulate motion blur",
3538 "-negate replace every pixel with its complementary color ",
3539 "-noise geometry add or reduce noise in an image",
3540 "-normalize transform image to span the full range of colors",
3541 "-opaque color change this color to the fill color",
3542 "-ordered-dither NxN",
3543 " add a noise pattern to the image with specific",
3545 "-paint radius simulate an oil painting",
3546 "-perceptible epsilon",
3547 " pixel value less than |epsilon| become epsilon or",
3549 "-polaroid angle simulate a Polaroid picture",
3550 "-posterize levels reduce the image to a limited number of color levels",
3551 "-profile filename add, delete, or apply an image profile",
3552 "-quantize colorspace reduce colors in this colorspace",
3553 "-raise value lighten/darken image edges to create a 3-D effect",
3554 "-random-threshold low,high",
3555 " random threshold the image",
3556 "-region geometry apply options to a portion of the image",
3557 "-render render vector graphics",
3558 "-repage geometry size and location of an image canvas",
3559 "-resample geometry change the resolution of an image",
3560 "-resize geometry resize the image",
3561 "-roll geometry roll an image vertically or horizontally",
3562 "-rotate degrees apply Paeth rotation to the image",
3563 "-rotational-blur angle",
3564 " rotational blur the image",
3565 "-sample geometry scale image with pixel sampling",
3566 "-scale geometry scale the image",
3567 "-segment values segment an image",
3568 "-selective-blur geometry",
3569 " selectively blur pixels within a contrast threshold",
3570 "-sepia-tone threshold",
3571 " simulate a sepia-toned photo",
3572 "-set property value set an image property",
3573 "-shade degrees shade the image using a distant light source",
3574 "-shadow geometry simulate an image shadow",
3575 "-sharpen geometry sharpen the image",
3576 "-shave geometry shave pixels from the image edges",
3577 "-shear geometry slide one edge of the image along the X or Y axis",
3578 "-sigmoidal-contrast geometry",
3579 " increase the contrast without saturating highlights or",
3581 "-sketch geometry simulate a pencil sketch",
3582 "-solarize threshold negate all pixels above the threshold level",
3583 "-sparse-color method args",
3584 " fill in a image based on a few color points",
3585 "-splice geometry splice the background color into the image",
3586 "-spread radius displace image pixels by a random amount",
3587 "-statistic type radius",
3588 " replace each pixel with corresponding statistic from the neighborhood",
3589 "-strip strip image of all profiles and comments",
3590 "-swirl degrees swirl image pixels about the center",
3591 "-threshold value threshold the image",
3592 "-thumbnail geometry create a thumbnail of the image",
3593 "-tile filename tile image when filling a graphic primitive",
3594 "-tint value tint the image with the fill color",
3595 "-transform affine transform image",
3596 "-transparent color make this color transparent within the image",
3597 "-transpose flip image vertically and rotate 90 degrees",
3598 "-transverse flop image horizontally and rotate 270 degrees",
3599 "-trim trim image edges",
3600 "-type type image type",
3601 "-unique-colors discard all but one of any pixel color",
3602 "-unsharp geometry sharpen the image",
3603 "-vignette geometry soften the edges of the image in vignette style",
3604 "-wave geometry alter an image along a sine wave",
3605 "-wavelet-denoise threshold",
3606 " removes noise from the image using a wavelet transform",
3607 "-white-threshold value",
3608 " force all pixels above the threshold into white",
3611 *sequence_operators[]=
3613 "-affinity filename transform image colors to match this set of colors",
3614 "-append append an image sequence",
3615 "-clut apply a color lookup table to the image",
3616 "-coalesce merge a sequence of images",
3617 "-combine combine a sequence of images",
3618 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3619 "-complex operator perform complex mathematics on an image sequence",
3620 "-composite composite image",
3621 "-copy geometry offset",
3622 " copy pixels from one area of an image to another",
3623 "-crop geometry cut out a rectangular region of the image",
3624 "-deconstruct break down an image sequence into constituent parts",
3625 "-evaluate-sequence operator",
3626 " evaluate an arithmetic, relational, or logical expression",
3627 "-flatten flatten a sequence of images",
3628 "-fx expression apply mathematical expression to an image channel(s)",
3629 "-hald-clut apply a Hald color lookup table to the image",
3630 "-layers method optimize, merge, or compare image layers",
3631 "-morph value morph an image sequence",
3632 "-mosaic create a mosaic from an image sequence",
3633 "-poly terms build a polynomial from the image sequence and the corresponding",
3634 " terms (coefficients and degree pairs).",
3635 "-print string interpret string and print to console",
3636 "-process arguments process the image with a custom image filter",
3637 "-smush geometry smush an image sequence together",
3638 "-write filename write images to this file",
3643 "-adjoin join images into a single multi-image file",
3644 "-affine matrix affine transform matrix",
3645 "-alpha option activate, deactivate, reset, or set the alpha channel",
3646 "-antialias remove pixel-aliasing",
3647 "-authenticate password",
3648 " decipher image with this password",
3649 "-attenuate value lessen (or intensify) when adding noise to an image",
3650 "-background color background color",
3651 "-bias value add bias when convolving an image",
3652 "-black-point-compensation",
3653 " use black point compensation",
3654 "-blue-primary point chromaticity blue primary point",
3655 "-bordercolor color border color",
3656 "-caption string assign a caption to an image",
3657 "-colors value preferred number of colors in the image",
3658 "-colorspace type alternate image colorspace",
3659 "-comment string annotate image with comment",
3660 "-compose operator set image composite operator",
3661 "-compress type type of pixel compression when writing the image",
3662 "-define format:option=value",
3663 " define one or more image format options",
3664 "-delay value display the next image after pausing",
3665 "-density geometry horizontal and vertical density of the image",
3666 "-depth value image depth",
3667 "-direction type render text right-to-left or left-to-right",
3668 "-display server get image or font from this X server",
3669 "-dispose method layer disposal method",
3670 "-dither method apply error diffusion to image",
3671 "-encoding type text encoding type",
3672 "-endian type endianness (MSB or LSB) of the image",
3673 "-family name render text with this font family",
3674 "-features distance analyze image features (e.g. contrast, correlation)",
3675 "-fill color color to use when filling a graphic primitive",
3676 "-filter type use this filter when resizing an image",
3677 "-font name render text with this font",
3678 "-format \"string\" output formatted image characteristics",
3679 "-fuzz distance colors within this distance are considered equal",
3680 "-gravity type horizontal and vertical text placement",
3681 "-green-primary point chromaticity green primary point",
3682 "-intensity method method to generate an intensity value from a pixel",
3683 "-intent type type of rendering intent when managing the image color",
3684 "-interlace type type of image interlacing scheme",
3685 "-interline-spacing value",
3686 " set the space between two text lines",
3687 "-interpolate method pixel color interpolation method",
3688 "-interword-spacing value",
3689 " set the space between two words",
3690 "-kerning value set the space between two letters",
3691 "-label string assign a label to an image",
3692 "-limit type value pixel cache resource limit",
3693 "-loop iterations add Netscape loop extension to your GIF animation",
3694 "-matte store matte channel if the image has one",
3695 "-mattecolor color frame color",
3696 "-monitor monitor progress",
3697 "-orient type image orientation",
3698 "-page geometry size and location of an image canvas (setting)",
3699 "-path path write images to this path on disk",
3700 "-ping efficiently determine image attributes",
3701 "-pointsize value font point size",
3702 "-precision value maximum number of significant digits to print",
3703 "-preview type image preview type",
3704 "-quality value JPEG/MIFF/PNG compression level",
3705 "-quiet suppress all warning messages",
3706 "-read-mask filename associate a read mask with the image",
3707 "-red-primary point chromaticity red primary point",
3708 "-regard-warnings pay attention to warning messages",
3709 "-remap filename transform image colors to match this set of colors",
3710 "-respect-parentheses settings remain in effect until parenthesis boundary",
3711 "-sampling-factor geometry",
3712 " horizontal and vertical sampling factor",
3713 "-scene value image scene number",
3714 "-seed value seed a new sequence of pseudo-random numbers",
3715 "-size geometry width and height of image",
3716 "-stretch type render text with this font stretch",
3717 "-stroke color graphic primitive stroke color",
3718 "-strokewidth value graphic primitive stroke width",
3719 "-style type render text with this font style",
3720 "-synchronize synchronize image to storage device",
3721 "-taint declare the image as modified",
3722 "-texture filename name of texture to tile onto the image background",
3723 "-tile-offset geometry",
3725 "-treedepth value color tree depth",
3726 "-transparent-color color",
3727 " transparent color",
3728 "-undercolor color annotation bounding box color",
3729 "-units type the units of image resolution",
3730 "-verbose print detailed information about the image",
3731 "-view FlashPix viewing transforms",
3732 "-virtual-pixel method",
3733 " virtual pixel access method",
3734 "-weight type render text with this font weight",
3735 "-white-point point chromaticity white point",
3736 "-write-mask filename associate a write mask with the image",
3741 "-delete indexes delete the image from the image sequence",
3742 "-duplicate count,indexes",
3743 " duplicate an image one or more times",
3744 "-insert index insert last image into the image sequence",
3745 "-reverse reverse image sequence",
3746 "-swap indexes swap two images in the image sequence",
3753 ListMagickVersion(stdout);
3754 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3756 (void) printf("\nImage Settings:\n");
3757 for (p=settings; *p != (char *) NULL; p++)
3758 (void) printf(" %s\n",*p);
3759 (void) printf("\nImage Operators:\n");
3760 for (p=operators; *p != (char *) NULL; p++)
3761 (void) printf(" %s\n",*p);
3762 (void) printf("\nImage Channel Operators:\n");
3763 for (p=channel_operators; *p != (char *) NULL; p++)
3764 (void) printf(" %s\n",*p);
3765 (void) printf("\nImage Sequence Operators:\n");
3766 for (p=sequence_operators; *p != (char *) NULL; p++)
3767 (void) printf(" %s\n",*p);
3768 (void) printf("\nImage Stack Operators:\n");
3769 for (p=stack_operators; *p != (char *) NULL; p++)
3770 (void) printf(" %s\n",*p);
3771 (void) printf("\nMiscellaneous Options:\n");
3772 for (p=miscellaneous; *p != (char *) NULL; p++)
3773 (void) printf(" %s\n",*p);
3775 "\nBy default, the image format of 'file' is determined by its magic\n");
3777 "number. To specify a particular image format, precede the filename\n");
3779 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3781 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3782 (void) printf("'-' for standard input or output.\n");
3783 return(MagickFalse);
3786 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3787 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3789 #define DestroyMogrify() \
3791 if (format != (char *) NULL) \
3792 format=DestroyString(format); \
3793 if (path != (char *) NULL) \
3794 path=DestroyString(path); \
3795 DestroyImageStack(); \
3796 for (i=0; i < (ssize_t) argc; i++) \
3797 argv[i]=DestroyString(argv[i]); \
3798 argv=(char **) RelinquishMagickMemory(argv); \
3800 #define ThrowMogrifyException(asperity,tag,option) \
3802 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3805 return(MagickFalse); \
3807 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3809 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3810 "InvalidArgument","'%s': %s",argument,option); \
3812 return(MagickFalse); \
3824 image_stack[MaxImageStackDepth+1];
3832 respect_parenthesis;
3844 wand_unreferenced(metadata);
3849 assert(image_info != (ImageInfo *) NULL);
3850 assert(image_info->signature == MagickCoreSignature);
3851 if (image_info->debug != MagickFalse)
3852 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3853 assert(exception != (ExceptionInfo *) NULL);
3857 if ((LocaleCompare("version",option+1) == 0) ||
3858 (LocaleCompare("-version",option+1) == 0))
3860 ListMagickVersion(stdout);
3865 return(MogrifyUsage());
3866 format=(char *) NULL;
3868 global_colormap=MagickFalse;
3872 option=(char *) NULL;
3874 respect_parenthesis=MagickFalse;
3879 ReadCommandlLine(argc,&argv);
3880 status=ExpandFilenames(&argc,&argv);
3881 if (status == MagickFalse)
3882 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3883 GetExceptionMessage(errno));
3884 for (i=1; i < (ssize_t) argc; i++)
3887 if (LocaleCompare(option,"(") == 0)
3889 FireImageStack(MagickFalse,MagickTrue,pend);
3890 if (k == MaxImageStackDepth)
3891 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3896 if (LocaleCompare(option,")") == 0)
3898 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3900 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3904 if (IsCommandOption(option) == MagickFalse)
3907 backup_filename[MagickPathExtent],
3917 Option is a file name: begin by reading image from specified file.
3919 FireImageStack(MagickFalse,MagickFalse,pend);
3921 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3923 images=ReadImages(image_info,filename,exception);
3924 status&=(images != (Image *) NULL) &&
3925 (exception->severity < ErrorException);
3926 if (images == (Image *) NULL)
3928 properties=(*GetBlobProperties(images));
3929 if (format != (char *) NULL)
3930 (void) CopyMagickString(images->filename,images->magick_filename,
3932 if (path != (char *) NULL)
3934 GetPathComponent(option,TailPath,filename);
3935 (void) FormatLocaleString(images->filename,MagickPathExtent,
3936 "%s%c%s",path,*DirectorySeparator,filename);
3938 if (format != (char *) NULL)
3939 AppendImageFormat(format,images->filename);
3940 AppendImageStack(images);
3941 FinalizeImageSettings(image_info,image,MagickFalse);
3942 if (global_colormap != MagickFalse)
3947 quantize_info=AcquireQuantizeInfo(image_info);
3948 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3949 quantize_info=DestroyQuantizeInfo(quantize_info);
3951 *backup_filename='\0';
3952 if ((LocaleCompare(image->filename,"-") != 0) &&
3953 (IsPathWritable(image->filename) != MagickFalse))
3956 Rename image file as backup.
3958 (void) CopyMagickString(backup_filename,image->filename,
3960 for (j=0; j < 6; j++)
3962 (void) ConcatenateMagickString(backup_filename,"~",
3964 if (IsPathAccessible(backup_filename) == MagickFalse)
3967 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3968 (rename_utf8(image->filename,backup_filename) != 0))
3969 *backup_filename='\0';
3972 Write transmogrified image to disk.
3974 image_info->synchronize=MagickTrue;
3975 status&=WriteImages(image_info,image,image->filename,exception);
3976 if (status != MagickFalse)
3978 #if defined(MAGICKCORE_HAVE_UTIME)
3983 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3984 "preserve-timestamp"));
3985 if (preserve_timestamp != MagickFalse)
3990 timestamp.actime=properties.st_atime;
3991 timestamp.modtime=properties.st_mtime;
3992 (void) utime(image->filename,×tamp);
3996 if (*backup_filename != '\0')
3997 (void) remove_utf8(backup_filename);
3999 RemoveAllImageStack();
4002 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4003 switch (*(option+1))
4007 if (LocaleCompare("adaptive-blur",option+1) == 0)
4010 if (i == (ssize_t) argc)
4011 ThrowMogrifyException(OptionError,"MissingArgument",option);
4012 if (IsGeometry(argv[i]) == MagickFalse)
4013 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4016 if (LocaleCompare("adaptive-resize",option+1) == 0)
4019 if (i == (ssize_t) argc)
4020 ThrowMogrifyException(OptionError,"MissingArgument",option);
4021 if (IsGeometry(argv[i]) == MagickFalse)
4022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4025 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4028 if (i == (ssize_t) argc)
4029 ThrowMogrifyException(OptionError,"MissingArgument",option);
4030 if (IsGeometry(argv[i]) == MagickFalse)
4031 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4034 if (LocaleCompare("affine",option+1) == 0)
4039 if (i == (ssize_t) argc)
4040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4043 if (LocaleCompare("alpha",option+1) == 0)
4051 if (i == (ssize_t) argc)
4052 ThrowMogrifyException(OptionError,"MissingArgument",option);
4053 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4056 ThrowMogrifyException(OptionError,
4057 "UnrecognizedAlphaChannelOption",argv[i]);
4060 if (LocaleCompare("annotate",option+1) == 0)
4065 if (i == (ssize_t) argc)
4066 ThrowMogrifyException(OptionError,"MissingArgument",option);
4067 if (IsGeometry(argv[i]) == MagickFalse)
4068 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4069 if (i == (ssize_t) argc)
4070 ThrowMogrifyException(OptionError,"MissingArgument",option);
4074 if (LocaleCompare("antialias",option+1) == 0)
4076 if (LocaleCompare("append",option+1) == 0)
4078 if (LocaleCompare("attenuate",option+1) == 0)
4083 if (i == (ssize_t) argc)
4084 ThrowMogrifyException(OptionError,"MissingArgument",option);
4085 if (IsGeometry(argv[i]) == MagickFalse)
4086 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4089 if (LocaleCompare("authenticate",option+1) == 0)
4094 if (i == (ssize_t) argc)
4095 ThrowMogrifyException(OptionError,"MissingArgument",option);
4098 if (LocaleCompare("auto-gamma",option+1) == 0)
4100 if (LocaleCompare("auto-level",option+1) == 0)
4102 if (LocaleCompare("auto-orient",option+1) == 0)
4104 if (LocaleCompare("average",option+1) == 0)
4106 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4110 if (LocaleCompare("background",option+1) == 0)
4115 if (i == (ssize_t) argc)
4116 ThrowMogrifyException(OptionError,"MissingArgument",option);
4119 if (LocaleCompare("bias",option+1) == 0)
4124 if (i == (ssize_t) argc)
4125 ThrowMogrifyException(OptionError,"MissingArgument",option);
4126 if (IsGeometry(argv[i]) == MagickFalse)
4127 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4130 if (LocaleCompare("black-point-compensation",option+1) == 0)
4132 if (LocaleCompare("black-threshold",option+1) == 0)
4137 if (i == (ssize_t) argc)
4138 ThrowMogrifyException(OptionError,"MissingArgument",option);
4139 if (IsGeometry(argv[i]) == MagickFalse)
4140 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4143 if (LocaleCompare("blue-primary",option+1) == 0)
4148 if (i == (ssize_t) argc)
4149 ThrowMogrifyException(OptionError,"MissingArgument",option);
4150 if (IsGeometry(argv[i]) == MagickFalse)
4151 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4154 if (LocaleCompare("blue-shift",option+1) == 0)
4157 if (i == (ssize_t) argc)
4158 ThrowMogrifyException(OptionError,"MissingArgument",option);
4159 if (IsGeometry(argv[i]) == MagickFalse)
4160 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4163 if (LocaleCompare("blur",option+1) == 0)
4166 if (i == (ssize_t) argc)
4167 ThrowMogrifyException(OptionError,"MissingArgument",option);
4168 if (IsGeometry(argv[i]) == MagickFalse)
4169 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4172 if (LocaleCompare("border",option+1) == 0)
4177 if (i == (ssize_t) argc)
4178 ThrowMogrifyException(OptionError,"MissingArgument",option);
4179 if (IsGeometry(argv[i]) == MagickFalse)
4180 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4183 if (LocaleCompare("bordercolor",option+1) == 0)
4188 if (i == (ssize_t) argc)
4189 ThrowMogrifyException(OptionError,"MissingArgument",option);
4192 if (LocaleCompare("box",option+1) == 0)
4197 if (i == (ssize_t) argc)
4198 ThrowMogrifyException(OptionError,"MissingArgument",option);
4201 if (LocaleCompare("brightness-contrast",option+1) == 0)
4204 if (i == (ssize_t) argc)
4205 ThrowMogrifyException(OptionError,"MissingArgument",option);
4206 if (IsGeometry(argv[i]) == MagickFalse)
4207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4210 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4214 if (LocaleCompare("cache",option+1) == 0)
4219 if (i == (ssize_t) argc)
4220 ThrowMogrifyException(OptionError,"MissingArgument",option);
4221 if (IsGeometry(argv[i]) == MagickFalse)
4222 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4225 if (LocaleCompare("canny",option+1) == 0)
4230 if (i == (ssize_t) argc)
4231 ThrowMogrifyException(OptionError,"MissingArgument",option);
4232 if (IsGeometry(argv[i]) == MagickFalse)
4233 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4236 if (LocaleCompare("caption",option+1) == 0)
4241 if (i == (ssize_t) argc)
4242 ThrowMogrifyException(OptionError,"MissingArgument",option);
4245 if (LocaleCompare("channel",option+1) == 0)
4253 if (i == (ssize_t) argc)
4254 ThrowMogrifyException(OptionError,"MissingArgument",option);
4255 channel=ParseChannelOption(argv[i]);
4257 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4261 if (LocaleCompare("channel-fx",option+1) == 0)
4269 if (i == (ssize_t) argc)
4270 ThrowMogrifyException(OptionError,"MissingArgument",option);
4271 channel=ParsePixelChannelOption(argv[i]);
4273 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4277 if (LocaleCompare("cdl",option+1) == 0)
4282 if (i == (ssize_t) argc)
4283 ThrowMogrifyException(OptionError,"MissingArgument",option);
4286 if (LocaleCompare("charcoal",option+1) == 0)
4291 if (i == (ssize_t) argc)
4292 ThrowMogrifyException(OptionError,"MissingArgument",option);
4293 if (IsGeometry(argv[i]) == MagickFalse)
4294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4297 if (LocaleCompare("chop",option+1) == 0)
4302 if (i == (ssize_t) argc)
4303 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 if (IsGeometry(argv[i]) == MagickFalse)
4305 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4308 if (LocaleCompare("clamp",option+1) == 0)
4310 if (LocaleCompare("clip",option+1) == 0)
4312 if (LocaleCompare("clip-mask",option+1) == 0)
4317 if (i == (ssize_t) argc)
4318 ThrowMogrifyException(OptionError,"MissingArgument",option);
4321 if (LocaleCompare("clut",option+1) == 0)
4323 if (LocaleCompare("coalesce",option+1) == 0)
4325 if (LocaleCompare("colorize",option+1) == 0)
4330 if (i == (ssize_t) argc)
4331 ThrowMogrifyException(OptionError,"MissingArgument",option);
4332 if (IsGeometry(argv[i]) == MagickFalse)
4333 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4336 if (LocaleCompare("color-matrix",option+1) == 0)
4344 if (i == (ssize_t) argc)
4345 ThrowMogrifyException(OptionError,"MissingArgument",option);
4346 kernel_info=AcquireKernelInfo(argv[i],exception);
4347 if (kernel_info == (KernelInfo *) NULL)
4348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4349 kernel_info=DestroyKernelInfo(kernel_info);
4352 if (LocaleCompare("colors",option+1) == 0)
4357 if (i == (ssize_t) argc)
4358 ThrowMogrifyException(OptionError,"MissingArgument",option);
4359 if (IsGeometry(argv[i]) == MagickFalse)
4360 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4363 if (LocaleCompare("colorspace",option+1) == 0)
4371 if (i == (ssize_t) argc)
4372 ThrowMogrifyException(OptionError,"MissingArgument",option);
4373 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4376 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4380 if (LocaleCompare("combine",option+1) == 0)
4388 if (i == (ssize_t) argc)
4389 ThrowMogrifyException(OptionError,"MissingArgument",option);
4390 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4393 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4397 if (LocaleCompare("compare",option+1) == 0)
4399 if (LocaleCompare("comment",option+1) == 0)
4404 if (i == (ssize_t) argc)
4405 ThrowMogrifyException(OptionError,"MissingArgument",option);
4408 if (LocaleCompare("composite",option+1) == 0)
4410 if (LocaleCompare("compress",option+1) == 0)
4418 if (i == (ssize_t) argc)
4419 ThrowMogrifyException(OptionError,"MissingArgument",option);
4420 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4423 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4427 if (LocaleCompare("concurrent",option+1) == 0)
4429 if (LocaleCompare("connected-components",option+1) == 0)
4432 if (i == (ssize_t) argc)
4433 ThrowMogrifyException(OptionError,"MissingArgument",option);
4434 if (IsGeometry(argv[i]) == MagickFalse)
4435 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4438 if (LocaleCompare("contrast",option+1) == 0)
4440 if (LocaleCompare("contrast-stretch",option+1) == 0)
4443 if (i == (ssize_t) argc)
4444 ThrowMogrifyException(OptionError,"MissingArgument",option);
4445 if (IsGeometry(argv[i]) == MagickFalse)
4446 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4449 if (LocaleCompare("convolve",option+1) == 0)
4457 if (i == (ssize_t) argc)
4458 ThrowMogrifyException(OptionError,"MissingArgument",option);
4459 kernel_info=AcquireKernelInfo(argv[i],exception);
4460 if (kernel_info == (KernelInfo *) NULL)
4461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4462 kernel_info=DestroyKernelInfo(kernel_info);
4465 if (LocaleCompare("copy",option+1) == 0)
4470 if (i == (ssize_t) argc)
4471 ThrowMogrifyException(OptionError,"MissingArgument",option);
4472 if (IsGeometry(argv[i]) == MagickFalse)
4473 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4475 if (i == (ssize_t) argc)
4476 ThrowMogrifyException(OptionError,"MissingArgument",option);
4477 if (IsGeometry(argv[i]) == MagickFalse)
4478 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4481 if (LocaleCompare("crop",option+1) == 0)
4486 if (i == (ssize_t) argc)
4487 ThrowMogrifyException(OptionError,"MissingArgument",option);
4488 if (IsGeometry(argv[i]) == MagickFalse)
4489 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4492 if (LocaleCompare("cycle",option+1) == 0)
4497 if (i == (ssize_t) argc)
4498 ThrowMogrifyException(OptionError,"MissingArgument",option);
4499 if (IsGeometry(argv[i]) == MagickFalse)
4500 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4503 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4507 if (LocaleCompare("decipher",option+1) == 0)
4512 if (i == (ssize_t) argc)
4513 ThrowMogrifyException(OptionError,"MissingArgument",option);
4516 if (LocaleCompare("deconstruct",option+1) == 0)
4518 if (LocaleCompare("debug",option+1) == 0)
4526 if (i == (ssize_t) argc)
4527 ThrowMogrifyException(OptionError,"MissingArgument",option);
4528 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4530 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4532 (void) SetLogEventMask(argv[i]);
4535 if (LocaleCompare("define",option+1) == 0)
4538 if (i == (ssize_t) argc)
4539 ThrowMogrifyException(OptionError,"MissingArgument",option);
4545 define=GetImageOption(image_info,argv[i]);
4546 if (define == (const char *) NULL)
4547 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4552 if (LocaleCompare("delay",option+1) == 0)
4557 if (i == (ssize_t) argc)
4558 ThrowMogrifyException(OptionError,"MissingArgument",option);
4559 if (IsGeometry(argv[i]) == MagickFalse)
4560 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4563 if (LocaleCompare("delete",option+1) == 0)
4568 if (i == (ssize_t) argc)
4569 ThrowMogrifyException(OptionError,"MissingArgument",option);
4570 if (IsGeometry(argv[i]) == MagickFalse)
4571 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4574 if (LocaleCompare("density",option+1) == 0)
4579 if (i == (ssize_t) argc)
4580 ThrowMogrifyException(OptionError,"MissingArgument",option);
4581 if (IsGeometry(argv[i]) == MagickFalse)
4582 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4585 if (LocaleCompare("depth",option+1) == 0)
4590 if (i == (ssize_t) argc)
4591 ThrowMogrifyException(OptionError,"MissingArgument",option);
4592 if (IsGeometry(argv[i]) == MagickFalse)
4593 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4596 if (LocaleCompare("deskew",option+1) == 0)
4601 if (i == (ssize_t) argc)
4602 ThrowMogrifyException(OptionError,"MissingArgument",option);
4603 if (IsGeometry(argv[i]) == MagickFalse)
4604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4607 if (LocaleCompare("despeckle",option+1) == 0)
4609 if (LocaleCompare("dft",option+1) == 0)
4611 if (LocaleCompare("direction",option+1) == 0)
4619 if (i == (ssize_t) argc)
4620 ThrowMogrifyException(OptionError,"MissingArgument",option);
4621 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4624 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4628 if (LocaleCompare("display",option+1) == 0)
4633 if (i == (ssize_t) argc)
4634 ThrowMogrifyException(OptionError,"MissingArgument",option);
4637 if (LocaleCompare("dispose",option+1) == 0)
4645 if (i == (ssize_t) argc)
4646 ThrowMogrifyException(OptionError,"MissingArgument",option);
4647 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4650 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4654 if (LocaleCompare("distort",option+1) == 0)
4660 if (i == (ssize_t) argc)
4661 ThrowMogrifyException(OptionError,"MissingArgument",option);
4662 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4664 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4667 if (i == (ssize_t) argc)
4668 ThrowMogrifyException(OptionError,"MissingArgument",option);
4671 if (LocaleCompare("dither",option+1) == 0)
4679 if (i == (ssize_t) argc)
4680 ThrowMogrifyException(OptionError,"MissingArgument",option);
4681 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4683 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4687 if (LocaleCompare("draw",option+1) == 0)
4692 if (i == (ssize_t) argc)
4693 ThrowMogrifyException(OptionError,"MissingArgument",option);
4696 if (LocaleCompare("duplicate",option+1) == 0)
4701 if (i == (ssize_t) argc)
4702 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 if (IsGeometry(argv[i]) == MagickFalse)
4704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4707 if (LocaleCompare("duration",option+1) == 0)
4712 if (i == (ssize_t) argc)
4713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4714 if (IsGeometry(argv[i]) == MagickFalse)
4715 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4718 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4722 if (LocaleCompare("edge",option+1) == 0)
4727 if (i == (ssize_t) argc)
4728 ThrowMogrifyException(OptionError,"MissingArgument",option);
4729 if (IsGeometry(argv[i]) == MagickFalse)
4730 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4733 if (LocaleCompare("emboss",option+1) == 0)
4738 if (i == (ssize_t) argc)
4739 ThrowMogrifyException(OptionError,"MissingArgument",option);
4740 if (IsGeometry(argv[i]) == MagickFalse)
4741 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4744 if (LocaleCompare("encipher",option+1) == 0)
4749 if (i == (ssize_t) argc)
4750 ThrowMogrifyException(OptionError,"MissingArgument",option);
4753 if (LocaleCompare("encoding",option+1) == 0)
4758 if (i == (ssize_t) argc)
4759 ThrowMogrifyException(OptionError,"MissingArgument",option);
4762 if (LocaleCompare("endian",option+1) == 0)
4770 if (i == (ssize_t) argc)
4771 ThrowMogrifyException(OptionError,"MissingArgument",option);
4772 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4774 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4778 if (LocaleCompare("enhance",option+1) == 0)
4780 if (LocaleCompare("equalize",option+1) == 0)
4782 if (LocaleCompare("evaluate",option+1) == 0)
4790 if (i == (ssize_t) argc)
4791 ThrowMogrifyException(OptionError,"MissingArgument",option);
4792 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4794 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4797 if (i == (ssize_t) argc)
4798 ThrowMogrifyException(OptionError,"MissingArgument",option);
4799 if (IsGeometry(argv[i]) == MagickFalse)
4800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4803 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4811 if (i == (ssize_t) argc)
4812 ThrowMogrifyException(OptionError,"MissingArgument",option);
4813 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4815 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4819 if (LocaleCompare("extent",option+1) == 0)
4824 if (i == (ssize_t) argc)
4825 ThrowMogrifyException(OptionError,"MissingArgument",option);
4826 if (IsGeometry(argv[i]) == MagickFalse)
4827 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4830 if (LocaleCompare("extract",option+1) == 0)
4835 if (i == (ssize_t) argc)
4836 ThrowMogrifyException(OptionError,"MissingArgument",option);
4837 if (IsGeometry(argv[i]) == MagickFalse)
4838 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4841 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4845 if (LocaleCompare("family",option+1) == 0)
4850 if (i == (ssize_t) argc)
4851 ThrowMogrifyException(OptionError,"MissingArgument",option);
4854 if (LocaleCompare("features",option+1) == 0)
4859 if (i == (ssize_t) argc)
4860 ThrowMogrifyException(OptionError,"MissingArgument",option);
4861 if (IsGeometry(argv[i]) == MagickFalse)
4862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4865 if (LocaleCompare("fill",option+1) == 0)
4870 if (i == (ssize_t) argc)
4871 ThrowMogrifyException(OptionError,"MissingArgument",option);
4874 if (LocaleCompare("filter",option+1) == 0)
4882 if (i == (ssize_t) argc)
4883 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4886 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4890 if (LocaleCompare("flatten",option+1) == 0)
4892 if (LocaleCompare("flip",option+1) == 0)
4894 if (LocaleCompare("flop",option+1) == 0)
4896 if (LocaleCompare("floodfill",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,"MissingArgument",option);
4903 if (IsGeometry(argv[i]) == MagickFalse)
4904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4906 if (i == (ssize_t) argc)
4907 ThrowMogrifyException(OptionError,"MissingArgument",option);
4910 if (LocaleCompare("font",option+1) == 0)
4915 if (i == (ssize_t) argc)
4916 ThrowMogrifyException(OptionError,"MissingArgument",option);
4919 if (LocaleCompare("format",option+1) == 0)
4921 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
4922 (void) CloneString(&format,(char *) NULL);
4926 if (i == (ssize_t) argc)
4927 ThrowMogrifyException(OptionError,"MissingArgument",option);
4928 (void) CloneString(&format,argv[i]);
4929 (void) CopyMagickString(image_info->filename,format,
4931 (void) ConcatenateMagickString(image_info->filename,":",
4933 (void) SetImageInfo(image_info,0,exception);
4934 if (*image_info->magick == '\0')
4935 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4939 if (LocaleCompare("frame",option+1) == 0)
4944 if (i == (ssize_t) argc)
4945 ThrowMogrifyException(OptionError,"MissingArgument",option);
4946 if (IsGeometry(argv[i]) == MagickFalse)
4947 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4950 if (LocaleCompare("function",option+1) == 0)
4958 if (i == (ssize_t) argc)
4959 ThrowMogrifyException(OptionError,"MissingArgument",option);
4960 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4962 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4964 if (i == (ssize_t) argc)
4965 ThrowMogrifyException(OptionError,"MissingArgument",option);
4968 if (LocaleCompare("fuzz",option+1) == 0)
4973 if (i == (ssize_t) argc)
4974 ThrowMogrifyException(OptionError,"MissingArgument",option);
4975 if (IsGeometry(argv[i]) == MagickFalse)
4976 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4979 if (LocaleCompare("fx",option+1) == 0)
4984 if (i == (ssize_t) argc)
4985 ThrowMogrifyException(OptionError,"MissingArgument",option);
4988 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4992 if (LocaleCompare("gamma",option+1) == 0)
4995 if (i == (ssize_t) argc)
4996 ThrowMogrifyException(OptionError,"MissingArgument",option);
4997 if (IsGeometry(argv[i]) == MagickFalse)
4998 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5001 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5002 (LocaleCompare("gaussian",option+1) == 0))
5005 if (i == (ssize_t) argc)
5006 ThrowMogrifyException(OptionError,"MissingArgument",option);
5007 if (IsGeometry(argv[i]) == MagickFalse)
5008 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5011 if (LocaleCompare("geometry",option+1) == 0)
5016 if (i == (ssize_t) argc)
5017 ThrowMogrifyException(OptionError,"MissingArgument",option);
5018 if (IsGeometry(argv[i]) == MagickFalse)
5019 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5022 if (LocaleCompare("gravity",option+1) == 0)
5030 if (i == (ssize_t) argc)
5031 ThrowMogrifyException(OptionError,"MissingArgument",option);
5032 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5035 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5039 if (LocaleCompare("grayscale",option+1) == 0)
5047 if (i == (ssize_t) argc)
5048 ThrowMogrifyException(OptionError,"MissingArgument",option);
5049 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5052 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
5056 if (LocaleCompare("green-primary",option+1) == 0)
5061 if (i == (ssize_t) argc)
5062 ThrowMogrifyException(OptionError,"MissingArgument",option);
5063 if (IsGeometry(argv[i]) == MagickFalse)
5064 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5067 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5071 if (LocaleCompare("hald-clut",option+1) == 0)
5073 if ((LocaleCompare("help",option+1) == 0) ||
5074 (LocaleCompare("-help",option+1) == 0))
5075 return(MogrifyUsage());
5076 if (LocaleCompare("hough-lines",option+1) == 0)
5081 if (i == (ssize_t) argc)
5082 ThrowMogrifyException(OptionError,"MissingArgument",option);
5083 if (IsGeometry(argv[i]) == MagickFalse)
5084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5087 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5091 if (LocaleCompare("identify",option+1) == 0)
5093 if (LocaleCompare("idft",option+1) == 0)
5095 if (LocaleCompare("implode",option+1) == 0)
5100 if (i == (ssize_t) argc)
5101 ThrowMogrifyException(OptionError,"MissingArgument",option);
5102 if (IsGeometry(argv[i]) == MagickFalse)
5103 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5106 if (LocaleCompare("intensity",option+1) == 0)
5114 if (i == (ssize_t) argc)
5115 ThrowMogrifyException(OptionError,"MissingArgument",option);
5116 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5117 MagickFalse,argv[i]);
5119 ThrowMogrifyException(OptionError,
5120 "UnrecognizedPixelIntensityMethod",argv[i]);
5123 if (LocaleCompare("intent",option+1) == 0)
5131 if (i == (ssize_t) argc)
5132 ThrowMogrifyException(OptionError,"MissingArgument",option);
5133 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5135 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5139 if (LocaleCompare("interlace",option+1) == 0)
5147 if (i == (ssize_t) argc)
5148 ThrowMogrifyException(OptionError,"MissingArgument",option);
5149 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5152 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5156 if (LocaleCompare("interline-spacing",option+1) == 0)
5161 if (i == (ssize_t) argc)
5162 ThrowMogrifyException(OptionError,"MissingArgument",option);
5163 if (IsGeometry(argv[i]) == MagickFalse)
5164 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5167 if (LocaleCompare("interpolate",option+1) == 0)
5175 if (i == (ssize_t) argc)
5176 ThrowMogrifyException(OptionError,"MissingArgument",option);
5177 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5179 if (interpolate < 0)
5180 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5184 if (LocaleCompare("interword-spacing",option+1) == 0)
5189 if (i == (ssize_t) argc)
5190 ThrowMogrifyException(OptionError,"MissingArgument",option);
5191 if (IsGeometry(argv[i]) == MagickFalse)
5192 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5195 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5199 if (LocaleCompare("kerning",option+1) == 0)
5204 if (i == (ssize_t) argc)
5205 ThrowMogrifyException(OptionError,"MissingArgument",option);
5206 if (IsGeometry(argv[i]) == MagickFalse)
5207 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5210 if (LocaleCompare("kuwahara",option+1) == 0)
5213 if (i == (ssize_t) argc)
5214 ThrowMogrifyException(OptionError,"MissingArgument",option);
5215 if (IsGeometry(argv[i]) == MagickFalse)
5216 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5219 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5223 if (LocaleCompare("label",option+1) == 0)
5228 if (i == (ssize_t) argc)
5229 ThrowMogrifyException(OptionError,"MissingArgument",option);
5232 if (LocaleCompare("lat",option+1) == 0)
5237 if (i == (ssize_t) argc)
5238 ThrowMogrifyException(OptionError,"MissingArgument",option);
5239 if (IsGeometry(argv[i]) == MagickFalse)
5240 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5242 if (LocaleCompare("layers",option+1) == 0)
5250 if (i == (ssize_t) argc)
5251 ThrowMogrifyException(OptionError,"MissingArgument",option);
5252 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5254 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5258 if (LocaleCompare("level",option+1) == 0)
5261 if (i == (ssize_t) argc)
5262 ThrowMogrifyException(OptionError,"MissingArgument",option);
5263 if (IsGeometry(argv[i]) == MagickFalse)
5264 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5267 if (LocaleCompare("level-colors",option+1) == 0)
5270 if (i == (ssize_t) argc)
5271 ThrowMogrifyException(OptionError,"MissingArgument",option);
5274 if (LocaleCompare("limit",option+1) == 0)
5288 if (i == (ssize_t) argc)
5289 ThrowMogrifyException(OptionError,"MissingArgument",option);
5290 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5293 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5296 if (i == (ssize_t) argc)
5297 ThrowMogrifyException(OptionError,"MissingArgument",option);
5298 value=StringToDouble(argv[i],&p);
5300 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5304 if (LocaleCompare("liquid-rescale",option+1) == 0)
5307 if (i == (ssize_t) argc)
5308 ThrowMogrifyException(OptionError,"MissingArgument",option);
5309 if (IsGeometry(argv[i]) == MagickFalse)
5310 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5313 if (LocaleCompare("list",option+1) == 0)
5321 if (i == (ssize_t) argc)
5322 ThrowMogrifyException(OptionError,"MissingArgument",option);
5323 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5325 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5326 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5328 return(status == 0 ? MagickTrue : MagickFalse);
5330 if (LocaleCompare("log",option+1) == 0)
5335 if ((i == (ssize_t) argc) ||
5336 (strchr(argv[i],'%') == (char *) NULL))
5337 ThrowMogrifyException(OptionError,"MissingArgument",option);
5340 if (LocaleCompare("loop",option+1) == 0)
5345 if (i == (ssize_t) argc)
5346 ThrowMogrifyException(OptionError,"MissingArgument",option);
5347 if (IsGeometry(argv[i]) == MagickFalse)
5348 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5351 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5355 if (LocaleCompare("map",option+1) == 0)
5357 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5361 if (i == (ssize_t) argc)
5362 ThrowMogrifyException(OptionError,"MissingArgument",option);
5365 if (LocaleCompare("mask",option+1) == 0)
5370 if (i == (ssize_t) argc)
5371 ThrowMogrifyException(OptionError,"MissingArgument",option);
5374 if (LocaleCompare("matte",option+1) == 0)
5376 if (LocaleCompare("mattecolor",option+1) == 0)
5381 if (i == (ssize_t) argc)
5382 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 if (LocaleCompare("maximum",option+1) == 0)
5387 if (LocaleCompare("mean-shift",option+1) == 0)
5392 if (i == (ssize_t) argc)
5393 ThrowMogrifyException(OptionError,"MissingArgument",option);
5394 if (IsGeometry(argv[i]) == MagickFalse)
5395 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5398 if (LocaleCompare("median",option+1) == 0)
5403 if (i == (ssize_t) argc)
5404 ThrowMogrifyException(OptionError,"MissingArgument",option);
5405 if (IsGeometry(argv[i]) == MagickFalse)
5406 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5409 if (LocaleCompare("metric",option+1) == 0)
5417 if (i == (ssize_t) argc)
5418 ThrowMogrifyException(OptionError,"MissingArgument",option);
5419 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5421 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5425 if (LocaleCompare("minimum",option+1) == 0)
5427 if (LocaleCompare("modulate",option+1) == 0)
5432 if (i == (ssize_t) argc)
5433 ThrowMogrifyException(OptionError,"MissingArgument",option);
5434 if (IsGeometry(argv[i]) == MagickFalse)
5435 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5438 if (LocaleCompare("mode",option+1) == 0)
5443 if (i == (ssize_t) argc)
5444 ThrowMogrifyException(OptionError,"MissingArgument",option);
5445 if (IsGeometry(argv[i]) == MagickFalse)
5446 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5449 if (LocaleCompare("monitor",option+1) == 0)
5451 if (LocaleCompare("monochrome",option+1) == 0)
5453 if (LocaleCompare("morph",option+1) == 0)
5458 if (i == (ssize_t) argc)
5459 ThrowMogrifyException(OptionError,"MissingArgument",option);
5460 if (IsGeometry(argv[i]) == MagickFalse)
5461 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5464 if (LocaleCompare("morphology",option+1) == 0)
5467 token[MagickPathExtent];
5476 if (i == (ssize_t) argc)
5477 ThrowMogrifyException(OptionError,"MissingArgument",option);
5478 GetNextToken(argv[i],(const char **) NULL,MagickPathExtent,token);
5479 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5481 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5484 if (i == (ssize_t) argc)
5485 ThrowMogrifyException(OptionError,"MissingArgument",option);
5486 kernel_info=AcquireKernelInfo(argv[i],exception);
5487 if (kernel_info == (KernelInfo *) NULL)
5488 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5489 kernel_info=DestroyKernelInfo(kernel_info);
5492 if (LocaleCompare("mosaic",option+1) == 0)
5494 if (LocaleCompare("motion-blur",option+1) == 0)
5499 if (i == (ssize_t) argc)
5500 ThrowMogrifyException(OptionError,"MissingArgument",option);
5501 if (IsGeometry(argv[i]) == MagickFalse)
5502 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5505 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5509 if (LocaleCompare("negate",option+1) == 0)
5511 if (LocaleCompare("noise",option+1) == 0)
5514 if (i == (ssize_t) argc)
5515 ThrowMogrifyException(OptionError,"MissingArgument",option);
5521 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5524 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5528 if (IsGeometry(argv[i]) == MagickFalse)
5529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5532 if (LocaleCompare("noop",option+1) == 0)
5534 if (LocaleCompare("normalize",option+1) == 0)
5536 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5540 if (LocaleCompare("opaque",option+1) == 0)
5543 if (i == (ssize_t) argc)
5544 ThrowMogrifyException(OptionError,"MissingArgument",option);
5547 if (LocaleCompare("ordered-dither",option+1) == 0)
5552 if (i == (ssize_t) argc)
5553 ThrowMogrifyException(OptionError,"MissingArgument",option);
5556 if (LocaleCompare("orient",option+1) == 0)
5561 orientation=UndefinedOrientation;
5565 if (i == (ssize_t) argc)
5566 ThrowMogrifyException(OptionError,"MissingArgument",option);
5567 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5569 if (orientation < 0)
5570 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5574 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5578 if (LocaleCompare("page",option+1) == 0)
5583 if (i == (ssize_t) argc)
5584 ThrowMogrifyException(OptionError,"MissingArgument",option);
5587 if (LocaleCompare("paint",option+1) == 0)
5592 if (i == (ssize_t) argc)
5593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (IsGeometry(argv[i]) == MagickFalse)
5595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5598 if (LocaleCompare("path",option+1) == 0)
5600 (void) CloneString(&path,(char *) NULL);
5604 if (i == (ssize_t) argc)
5605 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 (void) CloneString(&path,argv[i]);
5609 if (LocaleCompare("perceptible",option+1) == 0)
5614 if (i == (ssize_t) argc)
5615 ThrowMogrifyException(OptionError,"MissingArgument",option);
5616 if (IsGeometry(argv[i]) == MagickFalse)
5617 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5620 if (LocaleCompare("pointsize",option+1) == 0)
5625 if (i == (ssize_t) argc)
5626 ThrowMogrifyException(OptionError,"MissingArgument",option);
5627 if (IsGeometry(argv[i]) == MagickFalse)
5628 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5631 if (LocaleCompare("polaroid",option+1) == 0)
5636 if (i == (ssize_t) argc)
5637 ThrowMogrifyException(OptionError,"MissingArgument",option);
5638 if (IsGeometry(argv[i]) == MagickFalse)
5639 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5642 if (LocaleCompare("poly",option+1) == 0)
5647 if (i == (ssize_t) argc)
5648 ThrowMogrifyException(OptionError,"MissingArgument",option);
5649 if (IsGeometry(argv[i]) == MagickFalse)
5650 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5653 if (LocaleCompare("posterize",option+1) == 0)
5658 if (i == (ssize_t) argc)
5659 ThrowMogrifyException(OptionError,"MissingArgument",option);
5660 if (IsGeometry(argv[i]) == MagickFalse)
5661 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5664 if (LocaleCompare("precision",option+1) == 0)
5669 if (i == (ssize_t) argc)
5670 ThrowMogrifyException(OptionError,"MissingArgument",option);
5671 if (IsGeometry(argv[i]) == MagickFalse)
5672 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5675 if (LocaleCompare("print",option+1) == 0)
5680 if (i == (ssize_t) argc)
5681 ThrowMogrifyException(OptionError,"MissingArgument",option);
5684 if (LocaleCompare("process",option+1) == 0)
5689 if (i == (ssize_t) argc)
5690 ThrowMogrifyException(OptionError,"MissingArgument",option);
5693 if (LocaleCompare("profile",option+1) == 0)
5696 if (i == (ssize_t) argc)
5697 ThrowMogrifyException(OptionError,"MissingArgument",option);
5700 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5704 if (LocaleCompare("quality",option+1) == 0)
5709 if (i == (ssize_t) argc)
5710 ThrowMogrifyException(OptionError,"MissingArgument",option);
5711 if (IsGeometry(argv[i]) == MagickFalse)
5712 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5715 if (LocaleCompare("quantize",option+1) == 0)
5723 if (i == (ssize_t) argc)
5724 ThrowMogrifyException(OptionError,"MissingArgument",option);
5725 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5728 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5732 if (LocaleCompare("quiet",option+1) == 0)
5734 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5738 if (LocaleCompare("rotational-blur",option+1) == 0)
5741 if (i == (ssize_t) argc)
5742 ThrowMogrifyException(OptionError,"MissingArgument",option);
5743 if (IsGeometry(argv[i]) == MagickFalse)
5744 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5747 if (LocaleCompare("raise",option+1) == 0)
5750 if (i == (ssize_t) argc)
5751 ThrowMogrifyException(OptionError,"MissingArgument",option);
5752 if (IsGeometry(argv[i]) == MagickFalse)
5753 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5756 if (LocaleCompare("random-threshold",option+1) == 0)
5761 if (i == (ssize_t) argc)
5762 ThrowMogrifyException(OptionError,"MissingArgument",option);
5763 if (IsGeometry(argv[i]) == MagickFalse)
5764 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5767 if (LocaleCompare("read-mask",option+1) == 0)
5772 if (i == (ssize_t) argc)
5773 ThrowMogrifyException(OptionError,"MissingArgument",option);
5776 if (LocaleCompare("red-primary",option+1) == 0)
5781 if (i == (ssize_t) argc)
5782 ThrowMogrifyException(OptionError,"MissingArgument",option);
5783 if (IsGeometry(argv[i]) == MagickFalse)
5784 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5786 if (LocaleCompare("regard-warnings",option+1) == 0)
5788 if (LocaleCompare("region",option+1) == 0)
5793 if (i == (ssize_t) argc)
5794 ThrowMogrifyException(OptionError,"MissingArgument",option);
5795 if (IsGeometry(argv[i]) == MagickFalse)
5796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5799 if (LocaleCompare("remap",option+1) == 0)
5804 if (i == (ssize_t) argc)
5805 ThrowMogrifyException(OptionError,"MissingArgument",option);
5808 if (LocaleCompare("render",option+1) == 0)
5810 if (LocaleCompare("repage",option+1) == 0)
5815 if (i == (ssize_t) argc)
5816 ThrowMogrifyException(OptionError,"MissingArgument",option);
5817 if (IsGeometry(argv[i]) == MagickFalse)
5818 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5821 if (LocaleCompare("resample",option+1) == 0)
5826 if (i == (ssize_t) argc)
5827 ThrowMogrifyException(OptionError,"MissingArgument",option);
5828 if (IsGeometry(argv[i]) == MagickFalse)
5829 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5832 if (LocaleCompare("resize",option+1) == 0)
5837 if (i == (ssize_t) argc)
5838 ThrowMogrifyException(OptionError,"MissingArgument",option);
5839 if (IsGeometry(argv[i]) == MagickFalse)
5840 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5843 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5845 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5848 if (LocaleCompare("reverse",option+1) == 0)
5850 if (LocaleCompare("roll",option+1) == 0)
5855 if (i == (ssize_t) argc)
5856 ThrowMogrifyException(OptionError,"MissingArgument",option);
5857 if (IsGeometry(argv[i]) == MagickFalse)
5858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861 if (LocaleCompare("rotate",option+1) == 0)
5864 if (i == (ssize_t) argc)
5865 ThrowMogrifyException(OptionError,"MissingArgument",option);
5866 if (IsGeometry(argv[i]) == MagickFalse)
5867 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5870 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5874 if (LocaleCompare("sample",option+1) == 0)
5879 if (i == (ssize_t) argc)
5880 ThrowMogrifyException(OptionError,"MissingArgument",option);
5881 if (IsGeometry(argv[i]) == MagickFalse)
5882 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5885 if (LocaleCompare("sampling-factor",option+1) == 0)
5890 if (i == (ssize_t) argc)
5891 ThrowMogrifyException(OptionError,"MissingArgument",option);
5892 if (IsGeometry(argv[i]) == MagickFalse)
5893 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5896 if (LocaleCompare("scale",option+1) == 0)
5901 if (i == (ssize_t) argc)
5902 ThrowMogrifyException(OptionError,"MissingArgument",option);
5903 if (IsGeometry(argv[i]) == MagickFalse)
5904 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5907 if (LocaleCompare("scene",option+1) == 0)
5912 if (i == (ssize_t) argc)
5913 ThrowMogrifyException(OptionError,"MissingArgument",option);
5914 if (IsGeometry(argv[i]) == MagickFalse)
5915 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5918 if (LocaleCompare("seed",option+1) == 0)
5923 if (i == (ssize_t) argc)
5924 ThrowMogrifyException(OptionError,"MissingArgument",option);
5925 if (IsGeometry(argv[i]) == MagickFalse)
5926 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5929 if (LocaleCompare("segment",option+1) == 0)
5934 if (i == (ssize_t) argc)
5935 ThrowMogrifyException(OptionError,"MissingArgument",option);
5936 if (IsGeometry(argv[i]) == MagickFalse)
5937 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5940 if (LocaleCompare("selective-blur",option+1) == 0)
5943 if (i == (ssize_t) argc)
5944 ThrowMogrifyException(OptionError,"MissingArgument",option);
5945 if (IsGeometry(argv[i]) == MagickFalse)
5946 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5949 if (LocaleCompare("separate",option+1) == 0)
5951 if (LocaleCompare("sepia-tone",option+1) == 0)
5956 if (i == (ssize_t) argc)
5957 ThrowMogrifyException(OptionError,"MissingArgument",option);
5958 if (IsGeometry(argv[i]) == MagickFalse)
5959 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5962 if (LocaleCompare("set",option+1) == 0)
5965 if (i == (ssize_t) argc)
5966 ThrowMogrifyException(OptionError,"MissingArgument",option);
5970 if (i == (ssize_t) argc)
5971 ThrowMogrifyException(OptionError,"MissingArgument",option);
5974 if (LocaleCompare("shade",option+1) == 0)
5977 if (i == (ssize_t) argc)
5978 ThrowMogrifyException(OptionError,"MissingArgument",option);
5979 if (IsGeometry(argv[i]) == MagickFalse)
5980 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5983 if (LocaleCompare("shadow",option+1) == 0)
5988 if (i == (ssize_t) argc)
5989 ThrowMogrifyException(OptionError,"MissingArgument",option);
5990 if (IsGeometry(argv[i]) == MagickFalse)
5991 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5994 if (LocaleCompare("sharpen",option+1) == 0)
5997 if (i == (ssize_t) argc)
5998 ThrowMogrifyException(OptionError,"MissingArgument",option);
5999 if (IsGeometry(argv[i]) == MagickFalse)
6000 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6003 if (LocaleCompare("shave",option+1) == 0)
6008 if (i == (ssize_t) argc)
6009 ThrowMogrifyException(OptionError,"MissingArgument",option);
6010 if (IsGeometry(argv[i]) == MagickFalse)
6011 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6014 if (LocaleCompare("shear",option+1) == 0)
6017 if (i == (ssize_t) argc)
6018 ThrowMogrifyException(OptionError,"MissingArgument",option);
6019 if (IsGeometry(argv[i]) == MagickFalse)
6020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6023 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
6026 if (i == (ssize_t) argc)
6027 ThrowMogrifyException(OptionError,"MissingArgument",option);
6028 if (IsGeometry(argv[i]) == MagickFalse)
6029 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6032 if (LocaleCompare("size",option+1) == 0)
6037 if (i == (ssize_t) argc)
6038 ThrowMogrifyException(OptionError,"MissingArgument",option);
6039 if (IsGeometry(argv[i]) == MagickFalse)
6040 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6043 if (LocaleCompare("sketch",option+1) == 0)
6048 if (i == (ssize_t) argc)
6049 ThrowMogrifyException(OptionError,"MissingArgument",option);
6050 if (IsGeometry(argv[i]) == MagickFalse)
6051 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6054 if (LocaleCompare("smush",option+1) == 0)
6057 if (i == (ssize_t) argc)
6058 ThrowMogrifyException(OptionError,"MissingArgument",option);
6059 if (IsGeometry(argv[i]) == MagickFalse)
6060 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6064 if (LocaleCompare("solarize",option+1) == 0)
6069 if (i == (ssize_t) argc)
6070 ThrowMogrifyException(OptionError,"MissingArgument",option);
6071 if (IsGeometry(argv[i]) == MagickFalse)
6072 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6075 if (LocaleCompare("sparse-color",option+1) == 0)
6081 if (i == (ssize_t) argc)
6082 ThrowMogrifyException(OptionError,"MissingArgument",option);
6083 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6085 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6088 if (i == (ssize_t) argc)
6089 ThrowMogrifyException(OptionError,"MissingArgument",option);
6092 if (LocaleCompare("splice",option+1) == 0)
6097 if (i == (ssize_t) argc)
6098 ThrowMogrifyException(OptionError,"MissingArgument",option);
6099 if (IsGeometry(argv[i]) == MagickFalse)
6100 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6103 if (LocaleCompare("spread",option+1) == 0)
6108 if (i == (ssize_t) argc)
6109 ThrowMogrifyException(OptionError,"MissingArgument",option);
6110 if (IsGeometry(argv[i]) == MagickFalse)
6111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6114 if (LocaleCompare("statistic",option+1) == 0)
6122 if (i == (ssize_t) argc)
6123 ThrowMogrifyException(OptionError,"MissingArgument",option);
6124 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6126 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6129 if (i == (ssize_t) argc)
6130 ThrowMogrifyException(OptionError,"MissingArgument",option);
6131 if (IsGeometry(argv[i]) == MagickFalse)
6132 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6135 if (LocaleCompare("stretch",option+1) == 0)
6143 if (i == (ssize_t) argc)
6144 ThrowMogrifyException(OptionError,"MissingArgument",option);
6145 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6148 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6152 if (LocaleCompare("strip",option+1) == 0)
6154 if (LocaleCompare("stroke",option+1) == 0)
6159 if (i == (ssize_t) argc)
6160 ThrowMogrifyException(OptionError,"MissingArgument",option);
6163 if (LocaleCompare("strokewidth",option+1) == 0)
6168 if (i == (ssize_t) argc)
6169 ThrowMogrifyException(OptionError,"MissingArgument",option);
6170 if (IsGeometry(argv[i]) == MagickFalse)
6171 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6174 if (LocaleCompare("style",option+1) == 0)
6182 if (i == (ssize_t) argc)
6183 ThrowMogrifyException(OptionError,"MissingArgument",option);
6184 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6186 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6190 if (LocaleCompare("swap",option+1) == 0)
6195 if (i == (ssize_t) argc)
6196 ThrowMogrifyException(OptionError,"MissingArgument",option);
6197 if (IsGeometry(argv[i]) == MagickFalse)
6198 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6201 if (LocaleCompare("swirl",option+1) == 0)
6206 if (i == (ssize_t) argc)
6207 ThrowMogrifyException(OptionError,"MissingArgument",option);
6208 if (IsGeometry(argv[i]) == MagickFalse)
6209 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6212 if (LocaleCompare("synchronize",option+1) == 0)
6214 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6218 if (LocaleCompare("taint",option+1) == 0)
6220 if (LocaleCompare("texture",option+1) == 0)
6225 if (i == (ssize_t) argc)
6226 ThrowMogrifyException(OptionError,"MissingArgument",option);
6229 if (LocaleCompare("tile",option+1) == 0)
6234 if (i == (ssize_t) argc)
6235 ThrowMogrifyException(OptionError,"MissingArgument",option);
6238 if (LocaleCompare("tile-offset",option+1) == 0)
6243 if (i == (ssize_t) argc)
6244 ThrowMogrifyException(OptionError,"MissingArgument",option);
6245 if (IsGeometry(argv[i]) == MagickFalse)
6246 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6249 if (LocaleCompare("tint",option+1) == 0)
6254 if (i == (ssize_t) argc)
6255 ThrowMogrifyException(OptionError,"MissingArgument",option);
6256 if (IsGeometry(argv[i]) == MagickFalse)
6257 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6260 if (LocaleCompare("transform",option+1) == 0)
6262 if (LocaleCompare("transpose",option+1) == 0)
6264 if (LocaleCompare("transverse",option+1) == 0)
6266 if (LocaleCompare("threshold",option+1) == 0)
6271 if (i == (ssize_t) argc)
6272 ThrowMogrifyException(OptionError,"MissingArgument",option);
6273 if (IsGeometry(argv[i]) == MagickFalse)
6274 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6277 if (LocaleCompare("thumbnail",option+1) == 0)
6282 if (i == (ssize_t) argc)
6283 ThrowMogrifyException(OptionError,"MissingArgument",option);
6284 if (IsGeometry(argv[i]) == MagickFalse)
6285 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6288 if (LocaleCompare("transparent",option+1) == 0)
6291 if (i == (ssize_t) argc)
6292 ThrowMogrifyException(OptionError,"MissingArgument",option);
6295 if (LocaleCompare("transparent-color",option+1) == 0)
6300 if (i == (ssize_t) argc)
6301 ThrowMogrifyException(OptionError,"MissingArgument",option);
6304 if (LocaleCompare("treedepth",option+1) == 0)
6309 if (i == (ssize_t) argc)
6310 ThrowMogrifyException(OptionError,"MissingArgument",option);
6311 if (IsGeometry(argv[i]) == MagickFalse)
6312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6315 if (LocaleCompare("trim",option+1) == 0)
6317 if (LocaleCompare("type",option+1) == 0)
6325 if (i == (ssize_t) argc)
6326 ThrowMogrifyException(OptionError,"MissingArgument",option);
6327 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6329 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6333 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6337 if (LocaleCompare("undercolor",option+1) == 0)
6342 if (i == (ssize_t) argc)
6343 ThrowMogrifyException(OptionError,"MissingArgument",option);
6346 if (LocaleCompare("unique-colors",option+1) == 0)
6348 if (LocaleCompare("units",option+1) == 0)
6356 if (i == (ssize_t) argc)
6357 ThrowMogrifyException(OptionError,"MissingArgument",option);
6358 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6361 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6365 if (LocaleCompare("unsharp",option+1) == 0)
6368 if (i == (ssize_t) argc)
6369 ThrowMogrifyException(OptionError,"MissingArgument",option);
6370 if (IsGeometry(argv[i]) == MagickFalse)
6371 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6374 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6378 if (LocaleCompare("verbose",option+1) == 0)
6380 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6383 if ((LocaleCompare("version",option+1) == 0) ||
6384 (LocaleCompare("-version",option+1) == 0))
6386 ListMagickVersion(stdout);
6389 if (LocaleCompare("vignette",option+1) == 0)
6394 if (i == (ssize_t) argc)
6395 ThrowMogrifyException(OptionError,"MissingArgument",option);
6396 if (IsGeometry(argv[i]) == MagickFalse)
6397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6400 if (LocaleCompare("virtual-pixel",option+1) == 0)
6408 if (i == (ssize_t) argc)
6409 ThrowMogrifyException(OptionError,"MissingArgument",option);
6410 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6413 ThrowMogrifyException(OptionError,
6414 "UnrecognizedVirtualPixelMethod",argv[i]);
6417 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6421 if (LocaleCompare("wave",option+1) == 0)
6424 if (i == (ssize_t) argc)
6425 ThrowMogrifyException(OptionError,"MissingArgument",option);
6426 if (IsGeometry(argv[i]) == MagickFalse)
6427 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6430 if (LocaleCompare("wavelet-denoise",option+1) == 0)
6433 if (i == (ssize_t) argc)
6434 ThrowMogrifyException(OptionError,"MissingArgument",option);
6435 if (IsGeometry(argv[i]) == MagickFalse)
6436 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6439 if (LocaleCompare("weight",option+1) == 0)
6444 if (i == (ssize_t) argc)
6445 ThrowMogrifyException(OptionError,"MissingArgument",option);
6448 if (LocaleCompare("white-point",option+1) == 0)
6453 if (i == (ssize_t) argc)
6454 ThrowMogrifyException(OptionError,"MissingArgument",option);
6455 if (IsGeometry(argv[i]) == MagickFalse)
6456 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6459 if (LocaleCompare("white-threshold",option+1) == 0)
6464 if (i == (ssize_t) argc)
6465 ThrowMogrifyException(OptionError,"MissingArgument",option);
6466 if (IsGeometry(argv[i]) == MagickFalse)
6467 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6470 if (LocaleCompare("write",option+1) == 0)
6473 if (i == (ssize_t) argc)
6474 ThrowMogrifyException(OptionError,"MissingArgument",option);
6477 if (LocaleCompare("write-mask",option+1) == 0)
6482 if (i == (ssize_t) argc)
6483 ThrowMogrifyException(OptionError,"MissingArgument",option);
6486 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6491 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6493 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6494 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6495 if (fire != MagickFalse)
6496 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6499 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6500 if (i != (ssize_t) argc)
6501 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6503 return(status != 0 ? MagickTrue : MagickFalse);
6507 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6511 + M o g r i f y I m a g e I n f o %
6515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6517 % MogrifyImageInfo() applies image processing settings to the image as
6518 % prescribed by command line options.
6520 % The format of the MogrifyImageInfo method is:
6522 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6523 % const char **argv,ExceptionInfo *exception)
6525 % A description of each parameter follows:
6527 % o image_info: the image info..
6529 % o argc: Specifies a pointer to an integer describing the number of
6530 % elements in the argument vector.
6532 % o argv: Specifies a pointer to a text array containing the command line
6535 % o exception: return any errors or warnings in this structure.
6538 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6539 const int argc,const char **argv,ExceptionInfo *exception)
6554 Initialize method variables.
6556 assert(image_info != (ImageInfo *) NULL);
6557 assert(image_info->signature == MagickCoreSignature);
6558 if (image_info->debug != MagickFalse)
6559 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6560 image_info->filename);
6564 Set the image settings.
6566 for (i=0; i < (ssize_t) argc; i++)
6569 if (IsCommandOption(option) == MagickFalse)
6571 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6572 count=MagickMax(count,0L);
6573 if ((i+count) >= (ssize_t) argc)
6575 switch (*(option+1))
6579 if (LocaleCompare("adjoin",option+1) == 0)
6581 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6584 if (LocaleCompare("antialias",option+1) == 0)
6586 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6589 if (LocaleCompare("authenticate",option+1) == 0)
6592 (void) DeleteImageOption(image_info,option+1);
6594 (void) SetImageOption(image_info,option+1,argv[i+1]);
6601 if (LocaleCompare("background",option+1) == 0)
6605 (void) DeleteImageOption(image_info,option+1);
6606 (void) QueryColorCompliance(MogrifyBackgroundColor,
6607 AllCompliance,&image_info->background_color,exception);
6610 (void) SetImageOption(image_info,option+1,argv[i+1]);
6611 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6612 &image_info->background_color,exception);
6615 if (LocaleCompare("bias",option+1) == 0)
6619 (void) SetImageOption(image_info,option+1,"0.0");
6622 (void) SetImageOption(image_info,option+1,argv[i+1]);
6625 if (LocaleCompare("black-point-compensation",option+1) == 0)
6629 (void) SetImageOption(image_info,option+1,"false");
6632 (void) SetImageOption(image_info,option+1,"true");
6635 if (LocaleCompare("blue-primary",option+1) == 0)
6639 (void) SetImageOption(image_info,option+1,"0.0");
6642 (void) SetImageOption(image_info,option+1,argv[i+1]);
6645 if (LocaleCompare("bordercolor",option+1) == 0)
6649 (void) DeleteImageOption(image_info,option+1);
6650 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6651 &image_info->border_color,exception);
6654 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6655 &image_info->border_color,exception);
6656 (void) SetImageOption(image_info,option+1,argv[i+1]);
6659 if (LocaleCompare("box",option+1) == 0)
6663 (void) SetImageOption(image_info,"undercolor","none");
6666 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6673 if (LocaleCompare("cache",option+1) == 0)
6678 limit=MagickResourceInfinity;
6679 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6680 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6682 (void) SetMagickResourceLimit(MemoryResource,limit);
6683 (void) SetMagickResourceLimit(MapResource,2*limit);
6686 if (LocaleCompare("caption",option+1) == 0)
6690 (void) DeleteImageOption(image_info,option+1);
6693 (void) SetImageOption(image_info,option+1,argv[i+1]);
6696 if (LocaleCompare("colorspace",option+1) == 0)
6700 image_info->colorspace=UndefinedColorspace;
6701 (void) SetImageOption(image_info,option+1,"undefined");
6704 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6705 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6706 (void) SetImageOption(image_info,option+1,argv[i+1]);
6709 if (LocaleCompare("comment",option+1) == 0)
6713 (void) DeleteImageOption(image_info,option+1);
6716 (void) SetImageOption(image_info,option+1,argv[i+1]);
6719 if (LocaleCompare("compose",option+1) == 0)
6723 (void) SetImageOption(image_info,option+1,"undefined");
6726 (void) SetImageOption(image_info,option+1,argv[i+1]);
6729 if (LocaleCompare("compress",option+1) == 0)
6733 image_info->compression=UndefinedCompression;
6734 (void) SetImageOption(image_info,option+1,"undefined");
6737 image_info->compression=(CompressionType) ParseCommandOption(
6738 MagickCompressOptions,MagickFalse,argv[i+1]);
6739 (void) SetImageOption(image_info,option+1,argv[i+1]);
6746 if (LocaleCompare("debug",option+1) == 0)
6749 (void) SetLogEventMask("none");
6751 (void) SetLogEventMask(argv[i+1]);
6752 image_info->debug=IsEventLogging();
6755 if (LocaleCompare("define",option+1) == 0)
6759 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6760 (void) DeleteImageRegistry(argv[i+1]+9);
6762 (void) DeleteImageOption(image_info,argv[i+1]);
6765 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6767 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6771 (void) DefineImageOption(image_info,argv[i+1]);
6774 if (LocaleCompare("delay",option+1) == 0)
6778 (void) SetImageOption(image_info,option+1,"0");
6781 (void) SetImageOption(image_info,option+1,argv[i+1]);
6784 if (LocaleCompare("density",option+1) == 0)
6791 if (image_info->density != (char *) NULL)
6792 image_info->density=DestroyString(image_info->density);
6793 (void) SetImageOption(image_info,option+1,"72");
6796 (void) CloneString(&image_info->density,argv[i+1]);
6797 (void) SetImageOption(image_info,option+1,argv[i+1]);
6800 if (LocaleCompare("depth",option+1) == 0)
6804 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6807 image_info->depth=StringToUnsignedLong(argv[i+1]);
6810 if (LocaleCompare("direction",option+1) == 0)
6814 (void) SetImageOption(image_info,option+1,"undefined");
6817 (void) SetImageOption(image_info,option+1,argv[i+1]);
6820 if (LocaleCompare("display",option+1) == 0)
6824 if (image_info->server_name != (char *) NULL)
6825 image_info->server_name=DestroyString(
6826 image_info->server_name);
6829 (void) CloneString(&image_info->server_name,argv[i+1]);
6832 if (LocaleCompare("dispose",option+1) == 0)
6836 (void) SetImageOption(image_info,option+1,"undefined");
6839 (void) SetImageOption(image_info,option+1,argv[i+1]);
6842 if (LocaleCompare("dither",option+1) == 0)
6846 image_info->dither=MagickFalse;
6847 (void) SetImageOption(image_info,option+1,"none");
6850 (void) SetImageOption(image_info,option+1,argv[i+1]);
6851 image_info->dither=MagickTrue;
6858 if (LocaleCompare("encoding",option+1) == 0)
6862 (void) SetImageOption(image_info,option+1,"undefined");
6865 (void) SetImageOption(image_info,option+1,argv[i+1]);
6868 if (LocaleCompare("endian",option+1) == 0)
6872 image_info->endian=UndefinedEndian;
6873 (void) SetImageOption(image_info,option+1,"undefined");
6876 image_info->endian=(EndianType) ParseCommandOption(
6877 MagickEndianOptions,MagickFalse,argv[i+1]);
6878 (void) SetImageOption(image_info,option+1,argv[i+1]);
6881 if (LocaleCompare("extract",option+1) == 0)
6884 Set image extract geometry.
6888 if (image_info->extract != (char *) NULL)
6889 image_info->extract=DestroyString(image_info->extract);
6892 (void) CloneString(&image_info->extract,argv[i+1]);
6899 if (LocaleCompare("family",option+1) == 0)
6902 (void) SetImageOption(image_info,option+1,argv[i+1]);
6905 if (LocaleCompare("fill",option+1) == 0)
6909 (void) SetImageOption(image_info,option+1,"none");
6912 (void) SetImageOption(image_info,option+1,argv[i+1]);
6915 if (LocaleCompare("filter",option+1) == 0)
6919 (void) SetImageOption(image_info,option+1,"undefined");
6922 (void) SetImageOption(image_info,option+1,argv[i+1]);
6925 if (LocaleCompare("font",option+1) == 0)
6929 if (image_info->font != (char *) NULL)
6930 image_info->font=DestroyString(image_info->font);
6933 (void) CloneString(&image_info->font,argv[i+1]);
6936 if (LocaleCompare("format",option+1) == 0)
6941 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6942 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6943 image_info->ping=MagickFalse;
6944 (void) SetImageOption(image_info,option+1,argv[i+1]);
6947 if (LocaleCompare("fuzz",option+1) == 0)
6951 image_info->fuzz=0.0;
6952 (void) SetImageOption(image_info,option+1,"0");
6955 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6957 (void) SetImageOption(image_info,option+1,argv[i+1]);
6964 if (LocaleCompare("gravity",option+1) == 0)
6968 (void) SetImageOption(image_info,option+1,"undefined");
6971 (void) SetImageOption(image_info,option+1,argv[i+1]);
6974 if (LocaleCompare("green-primary",option+1) == 0)
6978 (void) SetImageOption(image_info,option+1,"0.0");
6981 (void) SetImageOption(image_info,option+1,argv[i+1]);
6988 if (LocaleCompare("intensity",option+1) == 0)
6992 (void) SetImageOption(image_info,option+1,"undefined");
6995 (void) SetImageOption(image_info,option+1,argv[i+1]);
6998 if (LocaleCompare("intent",option+1) == 0)
7002 (void) SetImageOption(image_info,option+1,"undefined");
7005 (void) SetImageOption(image_info,option+1,argv[i+1]);
7008 if (LocaleCompare("interlace",option+1) == 0)
7012 image_info->interlace=UndefinedInterlace;
7013 (void) SetImageOption(image_info,option+1,"undefined");
7016 image_info->interlace=(InterlaceType) ParseCommandOption(
7017 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7018 (void) SetImageOption(image_info,option+1,argv[i+1]);
7021 if (LocaleCompare("interline-spacing",option+1) == 0)
7025 (void) SetImageOption(image_info,option+1,"undefined");
7028 (void) SetImageOption(image_info,option+1,argv[i+1]);
7031 if (LocaleCompare("interpolate",option+1) == 0)
7035 (void) SetImageOption(image_info,option+1,"undefined");
7038 (void) SetImageOption(image_info,option+1,argv[i+1]);
7041 if (LocaleCompare("interword-spacing",option+1) == 0)
7045 (void) SetImageOption(image_info,option+1,"undefined");
7048 (void) SetImageOption(image_info,option+1,argv[i+1]);
7055 if (LocaleCompare("kerning",option+1) == 0)
7059 (void) SetImageOption(image_info,option+1,"undefined");
7062 (void) SetImageOption(image_info,option+1,argv[i+1]);
7069 if (LocaleCompare("label",option+1) == 0)
7073 (void) DeleteImageOption(image_info,option+1);
7076 (void) SetImageOption(image_info,option+1,argv[i+1]);
7079 if (LocaleCompare("limit",option+1) == 0)
7089 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7090 MagickFalse,argv[i+1]);
7091 limit=MagickResourceInfinity;
7092 if (LocaleCompare("unlimited",argv[i+2]) != 0)
7093 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7094 (void) SetMagickResourceLimit(type,limit);
7097 if (LocaleCompare("list",option+1) == 0)
7103 Display configuration list.
7105 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7108 case MagickCoderOptions:
7110 (void) ListCoderInfo((FILE *) NULL,exception);
7113 case MagickColorOptions:
7115 (void) ListColorInfo((FILE *) NULL,exception);
7118 case MagickConfigureOptions:
7120 (void) ListConfigureInfo((FILE *) NULL,exception);
7123 case MagickDelegateOptions:
7125 (void) ListDelegateInfo((FILE *) NULL,exception);
7128 case MagickFontOptions:
7130 (void) ListTypeInfo((FILE *) NULL,exception);
7133 case MagickFormatOptions:
7135 (void) ListMagickInfo((FILE *) NULL,exception);
7138 case MagickLocaleOptions:
7140 (void) ListLocaleInfo((FILE *) NULL,exception);
7143 case MagickLogOptions:
7145 (void) ListLogInfo((FILE *) NULL,exception);
7148 case MagickMagicOptions:
7150 (void) ListMagicInfo((FILE *) NULL,exception);
7153 case MagickMimeOptions:
7155 (void) ListMimeInfo((FILE *) NULL,exception);
7158 case MagickModuleOptions:
7160 (void) ListModuleInfo((FILE *) NULL,exception);
7163 case MagickPolicyOptions:
7165 (void) ListPolicyInfo((FILE *) NULL,exception);
7168 case MagickResourceOptions:
7170 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7173 case MagickThresholdOptions:
7175 (void) ListThresholdMaps((FILE *) NULL,exception);
7180 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7187 if (LocaleCompare("log",option+1) == 0)
7191 (void) SetLogFormat(argv[i+1]);
7194 if (LocaleCompare("loop",option+1) == 0)
7198 (void) SetImageOption(image_info,option+1,"0");
7201 (void) SetImageOption(image_info,option+1,argv[i+1]);
7208 if (LocaleCompare("matte",option+1) == 0)
7212 (void) SetImageOption(image_info,option+1,"false");
7215 (void) SetImageOption(image_info,option+1,"true");
7218 if (LocaleCompare("mattecolor",option+1) == 0)
7222 (void) SetImageOption(image_info,option+1,argv[i+1]);
7223 (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7224 &image_info->matte_color,exception);
7227 (void) SetImageOption(image_info,option+1,argv[i+1]);
7228 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7229 &image_info->matte_color,exception);
7232 if (LocaleCompare("metric",option+1) == 0)
7235 (void) DeleteImageOption(image_info,option+1);
7237 (void) SetImageOption(image_info,option+1,argv[i+1]);
7240 if (LocaleCompare("monitor",option+1) == 0)
7242 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7246 if (LocaleCompare("monochrome",option+1) == 0)
7248 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7255 if (LocaleCompare("orient",option+1) == 0)
7259 image_info->orientation=UndefinedOrientation;
7260 (void) SetImageOption(image_info,option+1,"undefined");
7263 image_info->orientation=(OrientationType) ParseCommandOption(
7264 MagickOrientationOptions,MagickFalse,argv[i+1]);
7265 (void) SetImageOption(image_info,option+1,argv[i+1]);
7271 if (LocaleCompare("page",option+1) == 0)
7275 page[MagickPathExtent];
7288 (void) DeleteImageOption(image_info,option+1);
7289 (void) CloneString(&image_info->page,(char *) NULL);
7292 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
7293 image_option=GetImageOption(image_info,"page");
7294 if (image_option != (const char *) NULL)
7295 flags=ParseAbsoluteGeometry(image_option,&geometry);
7296 canonical_page=GetPageGeometry(argv[i+1]);
7297 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7298 canonical_page=DestroyString(canonical_page);
7299 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu",
7300 (unsigned long) geometry.width,(unsigned long) geometry.height);
7301 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7302 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu%+ld%+ld",
7303 (unsigned long) geometry.width,(unsigned long) geometry.height,
7304 (long) geometry.x,(long) geometry.y);
7305 (void) SetImageOption(image_info,option+1,page);
7306 (void) CloneString(&image_info->page,page);
7309 if (LocaleCompare("ping",option+1) == 0)
7311 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7314 if (LocaleCompare("pointsize",option+1) == 0)
7317 geometry_info.rho=0.0;
7319 (void) ParseGeometry(argv[i+1],&geometry_info);
7320 image_info->pointsize=geometry_info.rho;
7323 if (LocaleCompare("precision",option+1) == 0)
7325 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7332 if (LocaleCompare("quality",option+1) == 0)
7335 Set image compression quality.
7339 image_info->quality=UndefinedCompressionQuality;
7340 (void) SetImageOption(image_info,option+1,"0");
7343 image_info->quality=StringToUnsignedLong(argv[i+1]);
7344 (void) SetImageOption(image_info,option+1,argv[i+1]);
7347 if (LocaleCompare("quiet",option+1) == 0)
7349 static WarningHandler
7350 warning_handler = (WarningHandler) NULL;
7355 Restore error or warning messages.
7357 warning_handler=SetWarningHandler(warning_handler);
7361 Suppress error or warning messages.
7363 warning_handler=SetWarningHandler((WarningHandler) NULL);
7370 if (LocaleCompare("red-primary",option+1) == 0)
7374 (void) SetImageOption(image_info,option+1,"0.0");
7377 (void) SetImageOption(image_info,option+1,argv[i+1]);
7384 if (LocaleCompare("sampling-factor",option+1) == 0)
7387 Set image sampling factor.
7391 if (image_info->sampling_factor != (char *) NULL)
7392 image_info->sampling_factor=DestroyString(
7393 image_info->sampling_factor);
7396 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7399 if (LocaleCompare("scene",option+1) == 0)
7406 image_info->scene=0;
7407 (void) SetImageOption(image_info,option+1,"0");
7410 image_info->scene=StringToUnsignedLong(argv[i+1]);
7411 (void) SetImageOption(image_info,option+1,argv[i+1]);
7414 if (LocaleCompare("seed",option+1) == 0)
7421 seed=(unsigned long) time((time_t *) NULL);
7422 SetRandomSecretKey(seed);
7425 seed=StringToUnsignedLong(argv[i+1]);
7426 SetRandomSecretKey(seed);
7429 if (LocaleCompare("size",option+1) == 0)
7433 if (image_info->size != (char *) NULL)
7434 image_info->size=DestroyString(image_info->size);
7437 (void) CloneString(&image_info->size,argv[i+1]);
7440 if (LocaleCompare("stroke",option+1) == 0)
7444 (void) SetImageOption(image_info,option+1,"none");
7447 (void) SetImageOption(image_info,option+1,argv[i+1]);
7450 if (LocaleCompare("strokewidth",option+1) == 0)
7453 (void) SetImageOption(image_info,option+1,"0");
7455 (void) SetImageOption(image_info,option+1,argv[i+1]);
7458 if (LocaleCompare("style",option+1) == 0)
7462 (void) SetImageOption(image_info,option+1,"none");
7465 (void) SetImageOption(image_info,option+1,argv[i+1]);
7468 if (LocaleCompare("synchronize",option+1) == 0)
7472 image_info->synchronize=MagickFalse;
7475 image_info->synchronize=MagickTrue;
7482 if (LocaleCompare("taint",option+1) == 0)
7486 (void) SetImageOption(image_info,option+1,"false");
7489 (void) SetImageOption(image_info,option+1,"true");
7492 if (LocaleCompare("texture",option+1) == 0)
7496 if (image_info->texture != (char *) NULL)
7497 image_info->texture=DestroyString(image_info->texture);
7500 (void) CloneString(&image_info->texture,argv[i+1]);
7503 if (LocaleCompare("tile-offset",option+1) == 0)
7506 (void) SetImageOption(image_info,option+1,"0");
7508 (void) SetImageOption(image_info,option+1,argv[i+1]);
7511 if (LocaleCompare("transparent-color",option+1) == 0)
7515 (void) QueryColorCompliance("none",AllCompliance,
7516 &image_info->transparent_color,exception);
7517 (void) SetImageOption(image_info,option+1,"none");
7520 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7521 &image_info->transparent_color,exception);
7522 (void) SetImageOption(image_info,option+1,argv[i+1]);
7525 if (LocaleCompare("type",option+1) == 0)
7529 image_info->type=UndefinedType;
7530 (void) SetImageOption(image_info,option+1,"undefined");
7533 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7534 MagickFalse,argv[i+1]);
7535 (void) SetImageOption(image_info,option+1,argv[i+1]);
7542 if (LocaleCompare("undercolor",option+1) == 0)
7545 (void) DeleteImageOption(image_info,option+1);
7547 (void) SetImageOption(image_info,option+1,argv[i+1]);
7550 if (LocaleCompare("units",option+1) == 0)
7554 image_info->units=UndefinedResolution;
7555 (void) SetImageOption(image_info,option+1,"undefined");
7558 image_info->units=(ResolutionType) ParseCommandOption(
7559 MagickResolutionOptions,MagickFalse,argv[i+1]);
7560 (void) SetImageOption(image_info,option+1,argv[i+1]);
7567 if (LocaleCompare("verbose",option+1) == 0)
7571 image_info->verbose=MagickFalse;
7574 image_info->verbose=MagickTrue;
7575 image_info->ping=MagickFalse;
7578 if (LocaleCompare("virtual-pixel",option+1) == 0)
7581 (void) SetImageOption(image_info,option+1,"undefined");
7583 (void) SetImageOption(image_info,option+1,argv[i+1]);
7590 if (LocaleCompare("weight",option+1) == 0)
7593 (void) SetImageOption(image_info,option+1,"0");
7595 (void) SetImageOption(image_info,option+1,argv[i+1]);
7598 if (LocaleCompare("white-point",option+1) == 0)
7601 (void) SetImageOption(image_info,option+1,"0.0");
7603 (void) SetImageOption(image_info,option+1,argv[i+1]);
7617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7621 + M o g r i f y I m a g e L i s t %
7625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7627 % MogrifyImageList() applies any command line options that might affect the
7628 % entire image list (e.g. -append, -coalesce, etc.).
7630 % The format of the MogrifyImage method is:
7632 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7633 % const char **argv,Image **images,ExceptionInfo *exception)
7635 % A description of each parameter follows:
7637 % o image_info: the image info..
7639 % o argc: Specifies a pointer to an integer describing the number of
7640 % elements in the argument vector.
7642 % o argv: Specifies a pointer to a text array containing the command line
7645 % o images: pointer to pointer of the first image in image list.
7647 % o exception: return any errors or warnings in this structure.
7650 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7651 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7662 PixelInterpolateMethod
7676 Apply options to the image list.
7678 assert(image_info != (ImageInfo *) NULL);
7679 assert(image_info->signature == MagickCoreSignature);
7680 assert(images != (Image **) NULL);
7681 assert((*images)->previous == (Image *) NULL);
7682 assert((*images)->signature == MagickCoreSignature);
7683 if ((*images)->debug != MagickFalse)
7684 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7685 (*images)->filename);
7686 if ((argc <= 0) || (*argv == (char *) NULL))
7688 interpolate_method=UndefinedInterpolatePixel;
7689 mogrify_info=CloneImageInfo(image_info);
7690 quantize_info=AcquireQuantizeInfo(mogrify_info);
7692 for (i=0; i < (ssize_t) argc; i++)
7694 if (*images == (Image *) NULL)
7697 if (IsCommandOption(option) == MagickFalse)
7699 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7700 count=MagickMax(count,0L);
7701 if ((i+count) >= (ssize_t) argc)
7703 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7704 switch (*(option+1))
7708 if (LocaleCompare("affinity",option+1) == 0)
7710 (void) SyncImagesSettings(mogrify_info,*images,exception);
7713 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7720 if (LocaleCompare("append",option+1) == 0)
7725 (void) SyncImagesSettings(mogrify_info,*images,exception);
7726 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7727 MagickFalse,exception);
7728 if (append_image == (Image *) NULL)
7733 *images=DestroyImageList(*images);
7734 *images=append_image;
7737 if (LocaleCompare("average",option+1) == 0)
7743 Average an image sequence (deprecated).
7745 (void) SyncImagesSettings(mogrify_info,*images,exception);
7746 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7748 if (average_image == (Image *) NULL)
7753 *images=DestroyImageList(*images);
7754 *images=average_image;
7761 if (LocaleCompare("channel-fx",option+1) == 0)
7766 (void) SyncImagesSettings(mogrify_info,*images,exception);
7767 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7768 if (channel_image == (Image *) NULL)
7773 *images=DestroyImageList(*images);
7774 *images=channel_image;
7777 if (LocaleCompare("clut",option+1) == 0)
7783 (void) SyncImagesSettings(mogrify_info,*images,exception);
7784 image=RemoveFirstImageFromList(images);
7785 clut_image=RemoveFirstImageFromList(images);
7786 if (clut_image == (Image *) NULL)
7791 (void) ClutImage(image,clut_image,interpolate_method,exception);
7792 clut_image=DestroyImage(clut_image);
7793 *images=DestroyImageList(*images);
7797 if (LocaleCompare("coalesce",option+1) == 0)
7802 (void) SyncImagesSettings(mogrify_info,*images,exception);
7803 coalesce_image=CoalesceImages(*images,exception);
7804 if (coalesce_image == (Image *) NULL)
7809 *images=DestroyImageList(*images);
7810 *images=coalesce_image;
7813 if (LocaleCompare("combine",option+1) == 0)
7821 (void) SyncImagesSettings(mogrify_info,*images,exception);
7822 colorspace=(*images)->colorspace;
7824 colorspace=(ColorspaceType) ParseCommandOption(
7825 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7826 combine_image=CombineImages(*images,colorspace,exception);
7827 if (combine_image == (Image *) NULL)
7832 *images=DestroyImageList(*images);
7833 *images=combine_image;
7836 if (LocaleCompare("compare",option+1) == 0)
7850 Mathematically and visually annotate the difference between an
7851 image and its reconstruction.
7853 (void) SyncImagesSettings(mogrify_info,*images,exception);
7854 image=RemoveFirstImageFromList(images);
7855 reconstruct_image=RemoveFirstImageFromList(images);
7856 if (reconstruct_image == (Image *) NULL)
7861 metric=UndefinedErrorMetric;
7862 option=GetImageOption(mogrify_info,"metric");
7863 if (option != (const char *) NULL)
7864 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7865 MagickFalse,option);
7866 difference_image=CompareImages(image,reconstruct_image,metric,
7867 &distortion,exception);
7868 if (difference_image == (Image *) NULL)
7870 if (*images != (Image *) NULL)
7871 *images=DestroyImage(*images);
7872 *images=difference_image;
7875 if (LocaleCompare("complex",option+1) == 0)
7883 (void) SyncImageSettings(mogrify_info,*images,exception);
7884 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7885 MagickFalse,argv[i+1]);
7886 complex_images=ComplexImages(*images,op,exception);
7887 if (complex_images == (Image *) NULL)
7892 *images=DestroyImageList(*images);
7893 *images=complex_images;
7896 if (LocaleCompare("composite",option+1) == 0)
7915 /* Compose value from "-compose" option only */
7916 (void) SyncImageSettings(mogrify_info,*images,exception);
7917 value=GetImageOption(mogrify_info,"compose");
7918 if (value == (const char *) NULL)
7919 compose=OverCompositeOp; /* use Over not source_image->compose */
7921 compose=(CompositeOperator) ParseCommandOption(
7922 MagickComposeOptions,MagickFalse,value);
7924 /* Get "clip-to-self" expert setting (false is normal) */
7925 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7926 if (value == (const char *) NULL)
7927 clip_to_self=MagickTrue;
7929 clip_to_self=IsStringTrue(GetImageOption(mogrify_info,
7930 "compose:clip-to-self")); /* if this is true */
7931 value=GetImageOption(mogrify_info,"compose:outside-overlay");
7932 if (value != (const char *) NULL) { /* or this false */
7933 /* FUTURE: depreciate warning for "compose:outside-overlay"*/
7934 clip_to_self=IsStringFalse(value);
7937 new_images=RemoveFirstImageFromList(images);
7938 source_image=RemoveFirstImageFromList(images);
7939 if (source_image == (Image *) NULL)
7940 break; /* FUTURE - produce Exception, rather than silent fail */
7942 /* FUTURE: this should not be here! - should be part of -geometry */
7943 if (source_image->geometry != (char *) NULL)
7948 (void) ParseRegionGeometry(source_image,source_image->geometry,
7949 &resize_geometry,exception);
7950 if ((source_image->columns != resize_geometry.width) ||
7951 (source_image->rows != resize_geometry.height))
7956 resize_image=ResizeImage(source_image,resize_geometry.width,
7957 resize_geometry.height,source_image->filter,exception);
7958 if (resize_image != (Image *) NULL)
7960 source_image=DestroyImage(source_image);
7961 source_image=resize_image;
7965 SetGeometry(source_image,&geometry);
7966 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
7967 GravityAdjustGeometry(new_images->columns,new_images->rows,
7968 new_images->gravity,&geometry);
7969 mask_image=RemoveFirstImageFromList(images);
7970 if (mask_image == (Image *) NULL)
7971 status&=CompositeImage(new_images,source_image,compose,
7972 clip_to_self,geometry.x,geometry.y,exception);
7975 if ((compose == DisplaceCompositeOp) ||
7976 (compose == DistortCompositeOp))
7978 status&=CompositeImage(source_image,mask_image,
7979 CopyGreenCompositeOp,MagickTrue,0,0,exception);
7980 status&=CompositeImage(new_images,source_image,compose,
7981 clip_to_self,geometry.x,geometry.y,exception);
7988 clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
7989 if (clone_image == (Image *) NULL)
7991 status&=CompositeImage(new_images,source_image,compose,
7992 clip_to_self,geometry.x,geometry.y,exception);
7993 status&=CompositeImage(new_images,mask_image,
7994 CopyAlphaCompositeOp,MagickTrue,0,0,exception);
7995 status&=CompositeImage(clone_image,new_images,
7996 OverCompositeOp,clip_to_self,0,0,exception);
7997 new_images=DestroyImage(new_images);
7998 new_images=clone_image;
8000 mask_image=DestroyImage(mask_image);
8002 source_image=DestroyImage(source_image);
8003 *images=DestroyImageList(*images);
8008 if (LocaleCompare("copy",option+1) == 0)
8022 (void) SyncImageSettings(mogrify_info,*images,exception);
8023 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8024 offset.x=geometry.x;
8025 offset.y=geometry.y;
8026 source_image=(*images);
8027 if (source_image->next != (Image *) NULL)
8028 source_image=source_image->next;
8029 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8031 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8039 if (LocaleCompare("deconstruct",option+1) == 0)
8044 (void) SyncImagesSettings(mogrify_info,*images,exception);
8045 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8047 if (deconstruct_image == (Image *) NULL)
8052 *images=DestroyImageList(*images);
8053 *images=deconstruct_image;
8056 if (LocaleCompare("delete",option+1) == 0)
8059 DeleteImages(images,"-1",exception);
8061 DeleteImages(images,argv[i+1],exception);
8064 if (LocaleCompare("dither",option+1) == 0)
8068 quantize_info->dither_method=NoDitherMethod;
8071 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8072 MagickDitherOptions,MagickFalse,argv[i+1]);
8075 if (LocaleCompare("duplicate",option+1) == 0)
8081 duplicate_images=DuplicateImages(*images,1,"-1",exception);
8090 number_duplicates=(size_t) StringToLong(argv[i+1]);
8091 p=strchr(argv[i+1],',');
8092 if (p == (const char *) NULL)
8093 duplicate_images=DuplicateImages(*images,number_duplicates,
8096 duplicate_images=DuplicateImages(*images,number_duplicates,p,
8099 AppendImageToList(images, duplicate_images);
8100 (void) SyncImagesSettings(mogrify_info,*images,exception);
8107 if (LocaleCompare("evaluate-sequence",option+1) == 0)
8112 MagickEvaluateOperator
8115 (void) SyncImageSettings(mogrify_info,*images,exception);
8116 op=(MagickEvaluateOperator) ParseCommandOption(
8117 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8118 evaluate_image=EvaluateImages(*images,op,exception);
8119 if (evaluate_image == (Image *) NULL)
8124 *images=DestroyImageList(*images);
8125 *images=evaluate_image;
8132 if (LocaleCompare("fft",option+1) == 0)
8138 Implements the discrete Fourier transform (DFT).
8140 (void) SyncImageSettings(mogrify_info,*images,exception);
8141 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8142 MagickTrue : MagickFalse,exception);
8143 if (fourier_image == (Image *) NULL)
8145 *images=DestroyImage(*images);
8146 *images=fourier_image;
8149 if (LocaleCompare("flatten",option+1) == 0)
8154 (void) SyncImagesSettings(mogrify_info,*images,exception);
8155 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8156 if (flatten_image == (Image *) NULL)
8158 *images=DestroyImageList(*images);
8159 *images=flatten_image;
8162 if (LocaleCompare("fx",option+1) == 0)
8167 (void) SyncImagesSettings(mogrify_info,*images,exception);
8168 fx_image=FxImage(*images,argv[i+1],exception);
8169 if (fx_image == (Image *) NULL)
8174 *images=DestroyImageList(*images);
8182 if (LocaleCompare("hald-clut",option+1) == 0)
8188 (void) SyncImagesSettings(mogrify_info,*images,exception);
8189 image=RemoveFirstImageFromList(images);
8190 hald_image=RemoveFirstImageFromList(images);
8191 if (hald_image == (Image *) NULL)
8196 (void) HaldClutImage(image,hald_image,exception);
8197 hald_image=DestroyImage(hald_image);
8198 if (*images != (Image *) NULL)
8199 *images=DestroyImageList(*images);
8207 if (LocaleCompare("ift",option+1) == 0)
8215 Implements the inverse fourier discrete Fourier transform (DFT).
8217 (void) SyncImagesSettings(mogrify_info,*images,exception);
8218 magnitude_image=RemoveFirstImageFromList(images);
8219 phase_image=RemoveFirstImageFromList(images);
8220 if (phase_image == (Image *) NULL)
8225 fourier_image=InverseFourierTransformImage(magnitude_image,
8226 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
8227 if (fourier_image == (Image *) NULL)
8229 if (*images != (Image *) NULL)
8230 *images=DestroyImage(*images);
8231 *images=fourier_image;
8234 if (LocaleCompare("insert",option+1) == 0)
8242 index=(ssize_t) StringToLong(argv[i+1]);
8243 p=RemoveLastImageFromList(images);
8244 if (p == (Image *) NULL)
8246 (void) ThrowMagickException(exception,GetMagickModule(),
8247 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8253 PrependImageToList(images,q);
8255 if (index == (ssize_t) GetImageListLength(*images))
8256 AppendImageToList(images,q);
8259 q=GetImageFromList(*images,index-1);
8260 if (q == (Image *) NULL)
8262 (void) ThrowMagickException(exception,GetMagickModule(),
8263 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8267 InsertImageInList(&q,p);
8269 *images=GetFirstImageInList(q);
8272 if (LocaleCompare("interpolate",option+1) == 0)
8274 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8275 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8282 if (LocaleCompare("layers",option+1) == 0)
8290 (void) SyncImagesSettings(mogrify_info,*images,exception);
8291 layers=(Image *) NULL;
8292 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8293 MagickFalse,argv[i+1]);
8298 layers=CoalesceImages(*images,exception);
8301 case CompareAnyLayer:
8302 case CompareClearLayer:
8303 case CompareOverlayLayer:
8306 layers=CompareImagesLayers(*images,method,exception);
8312 case TrimBoundsLayer:
8314 layers=MergeImageLayers(*images,method,exception);
8319 layers=DisposeImages(*images,exception);
8322 case OptimizeImageLayer:
8324 layers=OptimizeImageLayers(*images,exception);
8327 case OptimizePlusLayer:
8329 layers=OptimizePlusImageLayers(*images,exception);
8332 case OptimizeTransLayer:
8334 OptimizeImageTransparency(*images,exception);
8337 case RemoveDupsLayer:
8339 RemoveDuplicateLayers(images,exception);
8342 case RemoveZeroLayer:
8344 RemoveZeroDelayLayers(images,exception);
8350 General Purpose, GIF Animation Optimizer.
8352 layers=CoalesceImages(*images,exception);
8353 if (layers == (Image *) NULL)
8358 *images=DestroyImageList(*images);
8360 layers=OptimizeImageLayers(*images,exception);
8361 if (layers == (Image *) NULL)
8366 *images=DestroyImageList(*images);
8368 layers=(Image *) NULL;
8369 OptimizeImageTransparency(*images,exception);
8370 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8374 case CompositeLayer:
8386 Split image sequence at the first 'NULL:' image.
8389 while (source != (Image *) NULL)
8391 source=GetNextImageInList(source);
8392 if ((source != (Image *) NULL) &&
8393 (LocaleCompare(source->magick,"NULL") == 0))
8396 if (source != (Image *) NULL)
8398 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8399 (GetNextImageInList(source) == (Image *) NULL))
8400 source=(Image *) NULL;
8404 Separate the two lists, junk the null: image.
8406 source=SplitImageList(source->previous);
8407 DeleteImageFromList(&source);
8410 if (source == (Image *) NULL)
8412 (void) ThrowMagickException(exception,GetMagickModule(),
8413 OptionError,"MissingNullSeparator","layers Composite");
8418 Adjust offset with gravity and virtual canvas.
8420 SetGeometry(*images,&geometry);
8421 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8422 geometry.width=source->page.width != 0 ?
8423 source->page.width : source->columns;
8424 geometry.height=source->page.height != 0 ?
8425 source->page.height : source->rows;
8426 GravityAdjustGeometry((*images)->page.width != 0 ?
8427 (*images)->page.width : (*images)->columns,
8428 (*images)->page.height != 0 ? (*images)->page.height :
8429 (*images)->rows,(*images)->gravity,&geometry);
8430 compose=OverCompositeOp;
8431 option=GetImageOption(mogrify_info,"compose");
8432 if (option != (const char *) NULL)
8433 compose=(CompositeOperator) ParseCommandOption(
8434 MagickComposeOptions,MagickFalse,option);
8435 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8437 source=DestroyImageList(source);
8441 if (layers == (Image *) NULL)
8443 *images=DestroyImageList(*images);
8451 if (LocaleCompare("map",option+1) == 0)
8453 (void) SyncImagesSettings(mogrify_info,*images,exception);
8456 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8463 if (LocaleCompare("maximum",option+1) == 0)
8469 Maximum image sequence (deprecated).
8471 (void) SyncImagesSettings(mogrify_info,*images,exception);
8472 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8473 if (maximum_image == (Image *) NULL)
8478 *images=DestroyImageList(*images);
8479 *images=maximum_image;
8482 if (LocaleCompare("minimum",option+1) == 0)
8488 Minimum image sequence (deprecated).
8490 (void) SyncImagesSettings(mogrify_info,*images,exception);
8491 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8492 if (minimum_image == (Image *) NULL)
8497 *images=DestroyImageList(*images);
8498 *images=minimum_image;
8501 if (LocaleCompare("morph",option+1) == 0)
8506 (void) SyncImagesSettings(mogrify_info,*images,exception);
8507 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8509 if (morph_image == (Image *) NULL)
8514 *images=DestroyImageList(*images);
8515 *images=morph_image;
8518 if (LocaleCompare("mosaic",option+1) == 0)
8523 (void) SyncImagesSettings(mogrify_info,*images,exception);
8524 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8525 if (mosaic_image == (Image *) NULL)
8530 *images=DestroyImageList(*images);
8531 *images=mosaic_image;
8538 if (LocaleCompare("poly",option+1) == 0)
8542 token[MagickPathExtent];
8562 (void) SyncImageSettings(mogrify_info,*images,exception);
8563 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8565 if (args == (char *) NULL)
8568 for (x=0; *p != '\0'; x++)
8570 GetNextToken(p,&p,MagickPathExtent,token);
8572 GetNextToken(p,&p,MagickPathExtent,token);
8574 number_arguments=(size_t) x;
8575 arguments=(double *) AcquireQuantumMemory(number_arguments,
8576 sizeof(*arguments));
8577 if (arguments == (double *) NULL)
8578 ThrowWandFatalException(ResourceLimitFatalError,
8579 "MemoryAllocationFailed",(*images)->filename);
8580 (void) ResetMagickMemory(arguments,0,number_arguments*
8581 sizeof(*arguments));
8583 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8585 GetNextToken(p,&p,MagickPathExtent,token);
8587 GetNextToken(p,&p,MagickPathExtent,token);
8588 arguments[x]=StringToDouble(token,(char **) NULL);
8590 args=DestroyString(args);
8591 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8592 arguments,exception);
8593 arguments=(double *) RelinquishMagickMemory(arguments);
8594 if (polynomial_image == (Image *) NULL)
8599 *images=DestroyImageList(*images);
8600 *images=polynomial_image;
8602 if (LocaleCompare("print",option+1) == 0)
8607 (void) SyncImagesSettings(mogrify_info,*images,exception);
8608 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8610 if (string == (char *) NULL)
8612 (void) FormatLocaleFile(stdout,"%s",string);
8613 string=DestroyString(string);
8615 if (LocaleCompare("process",option+1) == 0)
8624 (void) SyncImagesSettings(mogrify_info,*images,exception);
8625 arguments=StringToArgv(argv[i+1],&number_arguments);
8626 if (arguments == (char **) NULL)
8628 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8649 Support old style syntax, filter="-option arg".
8651 length=strlen(argv[i+1]);
8652 token=(char *) NULL;
8653 if (~length >= (MagickPathExtent-1))
8654 token=(char *) AcquireQuantumMemory(length+MagickPathExtent,
8656 if (token == (char *) NULL)
8660 token_info=AcquireTokenInfo();
8661 token_status=Tokenizer(token_info,0,token,length,argument,"",
8662 "=","\"",'\0',&breaker,&next,"e);
8663 token_info=DestroyTokenInfo(token_info);
8664 if (token_status == 0)
8669 arg=(&(argument[next]));
8670 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8673 token=DestroyString(token);
8676 (void) SubstituteString(&arguments[1],"-","");
8677 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8678 number_arguments-2,(const char **) arguments+2,exception);
8679 for (j=0; j < number_arguments; j++)
8680 arguments[j]=DestroyString(arguments[j]);
8681 arguments=(char **) RelinquishMagickMemory(arguments);
8688 if (LocaleCompare("reverse",option+1) == 0)
8690 ReverseImageList(images);
8697 if (LocaleCompare("smush",option+1) == 0)
8705 (void) SyncImagesSettings(mogrify_info,*images,exception);
8706 offset=(ssize_t) StringToLong(argv[i+1]);
8707 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8708 MagickFalse,offset,exception);
8709 if (smush_image == (Image *) NULL)
8714 *images=DestroyImageList(*images);
8715 *images=smush_image;
8718 if (LocaleCompare("swap",option+1) == 0)
8739 flags=ParseGeometry(argv[i+1],&geometry_info);
8740 index=(ssize_t) geometry_info.rho;
8741 if ((flags & SigmaValue) != 0)
8742 swap_index=(ssize_t) geometry_info.sigma;
8744 p=GetImageFromList(*images,index);
8745 q=GetImageFromList(*images,swap_index);
8746 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8748 (void) ThrowMagickException(exception,GetMagickModule(),
8749 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8755 swap=CloneImage(p,0,0,MagickTrue,exception);
8756 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8757 ReplaceImageInList(&q,swap);
8758 *images=GetFirstImageInList(q);
8765 if (LocaleCompare("write",option+1) == 0)
8768 key[MagickPathExtent];
8776 (void) SyncImagesSettings(mogrify_info,*images,exception);
8777 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",
8779 (void) DeleteImageRegistry(key);
8780 write_images=(*images);
8782 write_images=CloneImageList(*images,exception);
8783 write_info=CloneImageInfo(mogrify_info);
8784 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8785 write_info=DestroyImageInfo(write_info);
8787 write_images=DestroyImageList(write_images);
8797 quantize_info=DestroyQuantizeInfo(quantize_info);
8798 mogrify_info=DestroyImageInfo(mogrify_info);
8799 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8800 return(status != 0 ? MagickTrue : MagickFalse);
8804 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8808 + M o g r i f y I m a g e s %
8812 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8814 % MogrifyImages() applies image processing options to a sequence of images as
8815 % prescribed by command line options.
8817 % The format of the MogrifyImage method is:
8819 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8820 % const MagickBooleanType post,const int argc,const char **argv,
8821 % Image **images,Exceptioninfo *exception)
8823 % A description of each parameter follows:
8825 % o image_info: the image info..
8827 % o post: If true, post process image list operators otherwise pre-process.
8829 % o argc: Specifies a pointer to an integer describing the number of
8830 % elements in the argument vector.
8832 % o argv: Specifies a pointer to a text array containing the command line
8835 % o images: pointer to a pointer of the first image in image list.
8837 % o exception: return any errors or warnings in this structure.
8840 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8841 const MagickBooleanType post,const int argc,const char **argv,
8842 Image **images,ExceptionInfo *exception)
8844 #define MogrifyImageTag "Mogrify/Image"
8858 assert(image_info != (ImageInfo *) NULL);
8859 assert(image_info->signature == MagickCoreSignature);
8860 if (images == (Image **) NULL)
8861 return(MogrifyImage(image_info,argc,argv,images,exception));
8862 assert((*images)->previous == (Image *) NULL);
8863 assert((*images)->signature == MagickCoreSignature);
8864 if ((*images)->debug != MagickFalse)
8865 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8866 (*images)->filename);
8867 if ((argc <= 0) || (*argv == (char *) NULL))
8869 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8873 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8877 Pre-process multi-image sequence operators
8879 if (post == MagickFalse)
8880 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8882 For each image, process simple single image operators
8885 n=GetImageListLength(*images);
8889 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8890 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8892 status&=MogrifyImage(image_info,argc,argv,images,exception);
8893 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8894 if (proceed == MagickFalse)
8896 if ( (*images)->next == (Image *) NULL )
8898 *images=(*images)->next;
8901 assert( *images != (Image *) NULL );
8903 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8904 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8907 Post-process, multi-image sequence operators
8909 *images=GetFirstImageInList(*images);
8910 if (post != MagickFalse)
8911 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8912 return(status != 0 ? MagickTrue : MagickFalse);