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-2018 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 % https://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/composite-private.h"
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/monitor-private.h"
54 #include "MagickCore/string-private.h"
55 #include "MagickCore/thread-private.h"
56 #include "MagickCore/utility-private.h"
57 #include "MagickCore/blob-private.h"
58 #if defined(MAGICKCORE_HAVE_UTIME_H)
66 MogrifyAlphaColor[] = "#bdbdbd", /* gray */
67 MogrifyBackgroundColor[] = "#ffffff", /* white */
68 MogrifyBorderColor[] = "#dfdfdf"; /* gray */
73 #define UndefinedCompressionQuality 0UL
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 % M a g i c k C o m m a n d G e n e s i s %
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % MagickCommandGenesis() applies image processing options to an image as
87 % prescribed by command line options.
89 % It wiil look for special options like "-debug", "-bench", and
90 % "-distribute-cache" that needs to be applied even before the main
91 % processing begins, and may completely overrule normal command processing.
92 % Such 'Genesis' Options can only be given on the CLI, (not in a script)
93 % and are typically ignored (as they have been handled) if seen later.
95 % The format of the MagickCommandGenesis method is:
97 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
98 % MagickCommand command,int argc,char **argv,char **metadata,
99 % ExceptionInfo *exception)
101 % A description of each parameter follows:
103 % o image_info: the image info.
105 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
106 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
107 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
108 % DisplayImageCommand, or AnimateImageCommand.
110 % o argc: Specifies a pointer to an integer describing the number of
111 % elements in the argument vector.
113 % o argv: Specifies a pointer to a text array containing the command line
116 % o metadata: any metadata is returned here.
118 % o exception: return any errors or warnings in this structure.
121 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
122 MagickCommand command,int argc,char **argv,char **metadata,
123 ExceptionInfo *exception)
126 client_name[MaxTextExtent],
148 (void) setlocale(LC_ALL,"");
149 (void) setlocale(LC_NUMERIC,"C");
150 GetPathComponent(argv[0],TailPath,client_name);
151 (void) SetClientName(client_name);
152 concurrent=MagickFalse;
156 regard_warnings=MagickFalse;
157 for (i=1; i < (ssize_t) (argc-1); i++)
160 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
162 if (LocaleCompare("-bench",option) == 0)
163 iterations=StringToUnsignedLong(argv[++i]);
164 if (LocaleCompare("-concurrent",option) == 0)
165 concurrent=MagickTrue;
166 if (LocaleCompare("-debug",option) == 0)
167 (void) SetLogEventMask(argv[++i]);
168 if (LocaleCompare("-distribute-cache",option) == 0)
170 DistributePixelCacheServer(StringToInteger(argv[++i]),exception);
173 if (LocaleCompare("-duration",option) == 0)
174 duration=StringToDouble(argv[++i],(char **) NULL);
175 if (LocaleCompare("-regard-warnings",option) == 0)
176 regard_warnings=MagickTrue;
184 status=command(image_info,argc,argv,&text,exception);
185 if (exception->severity != UndefinedException)
187 if ((exception->severity > ErrorException) ||
188 (regard_warnings != MagickFalse))
190 CatchException(exception);
192 if (text != (char *) NULL)
194 if (metadata != (char **) NULL)
195 (void) ConcatenateString(&(*metadata),text);
196 text=DestroyString(text);
200 number_threads=GetOpenMPMaximumThreads();
202 for (n=1; n <= (ssize_t) number_threads; n++)
212 (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n);
213 timer=AcquireTimerInfo();
214 if (concurrent == MagickFalse)
216 for (i=0; i < (ssize_t) iterations; i++)
222 if (status == MagickFalse)
226 if (GetElapsedTime(timer) > duration)
228 (void) ContinueTimer(timer);
230 status=command(image_info,argc,argv,&text,exception);
231 if (exception->severity != UndefinedException)
233 if ((exception->severity > ErrorException) ||
234 (regard_warnings != MagickFalse))
236 CatchException(exception);
238 if (text != (char *) NULL)
240 if (metadata != (char **) NULL)
241 (void) ConcatenateString(&(*metadata),text);
242 text=DestroyString(text);
249 #if defined(MAGICKCORE_OPENMP_SUPPORT)
250 # pragma omp parallel for shared(status)
252 for (i=0; i < (ssize_t) iterations; i++)
258 if (status == MagickFalse)
262 if (GetElapsedTime(timer) > duration)
264 (void) ContinueTimer(timer);
266 status=command(image_info,argc,argv,&text,exception);
267 #if defined(MAGICKCORE_OPENMP_SUPPORT)
268 # pragma omp critical (MagickCore_MagickCommandGenesis)
271 if (exception->severity != UndefinedException)
273 if ((exception->severity > ErrorException) ||
274 (regard_warnings != MagickFalse))
276 CatchException(exception);
278 if (text != (char *) NULL)
280 if (metadata != (char **) NULL)
281 (void) ConcatenateString(&(*metadata),text);
282 text=DestroyString(text);
287 user_time=GetUserTime(timer);
288 parallel=GetElapsedTime(timer);
293 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
294 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
295 (void) FormatLocaleFile(stderr,
296 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
297 (double) n,(double) iterations,(double) iterations/parallel,e,user_time,
298 (unsigned long) (parallel/60.0),(unsigned long) floor(fmod(parallel,
299 60.0)),(unsigned long) (1000.0*(parallel-floor(parallel))+0.5));
300 timer=DestroyTimerInfo(timer);
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310 + M o g r i f y I m a g e %
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 % MogrifyImage() applies simple single image processing options to a single
317 % image that may be part of a large list, but also handles any 'region'
320 % The image in the list may be modified in three different ways...
322 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
323 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
324 % * replace by a list of images (only the -separate option!)
326 % In each case the result is returned into the list, and a pointer to the
327 % modified image (last image added if replaced by a list of images) is
330 % ASIDE: The -crop is present but restricted to non-tile single image crops
332 % This means if all the images are being processed (such as by
333 % MogrifyImages(), next image to be processed will be as per the pointer
334 % (*image)->next. Also the image list may grow as a result of some specific
335 % operations but as images are never merged or deleted, it will never shrink
336 % in length. Typically the list will remain the same length.
338 % WARNING: As the image pointed to may be replaced, the first image in the
339 % list may also change. GetFirstImageInList() should be used by caller if
340 % they wish return the Image pointer to the first image in list.
343 % The format of the MogrifyImage method is:
345 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
346 % const char **argv,Image **image)
348 % A description of each parameter follows:
350 % o image_info: the image info..
352 % o argc: Specifies a pointer to an integer describing the number of
353 % elements in the argument vector.
355 % o argv: Specifies a pointer to a text array containing the command line
358 % o image: the image.
360 % o exception: return any errors or warnings in this structure.
364 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
365 ExceptionInfo *exception)
368 key[MagickPathExtent];
380 Read an image into a image cache (for repeated usage) if not already in
381 cache. Then return the image that is in the cache.
383 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",path);
384 sans_exception=AcquireExceptionInfo();
385 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
386 sans_exception=DestroyExceptionInfo(sans_exception);
387 if (image != (Image *) NULL)
389 read_info=CloneImageInfo(image_info);
390 (void) CopyMagickString(read_info->filename,path,MagickPathExtent);
391 image=ReadImage(read_info,exception);
392 read_info=DestroyImageInfo(read_info);
393 if (image != (Image *) NULL)
394 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
398 static inline MagickBooleanType IsPathWritable(const char *path)
400 if (IsPathAccessible(path) == MagickFalse)
402 if (access_utf8(path,W_OK) != 0)
407 static MagickBooleanType MonitorProgress(const char *text,
408 const MagickOffsetType offset,const MagickSizeType extent,
409 void *wand_unused(client_data))
412 message[MagickPathExtent],
413 tag[MagickPathExtent];
421 magick_unreferenced(client_data);
423 if ((extent <= 1) || (offset < 0) || (offset >= (MagickOffsetType) extent))
425 if ((offset != (MagickOffsetType) (extent-1)) && ((offset % 50) != 0))
427 (void) CopyMagickString(tag,text,MagickPathExtent);
429 if (p != (char *) NULL)
431 (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag);
432 locale_message=GetLocaleMessage(message);
433 if (locale_message == message)
435 if (p == (char *) NULL)
436 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
437 locale_message,(long) offset,(unsigned long) extent,(long)
438 (100L*offset/(extent-1)));
440 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
441 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
442 (100L*offset/(extent-1)));
443 if (offset == (MagickOffsetType) (extent-1))
444 (void) FormatLocaleFile(stderr,"\n");
445 (void) fflush(stderr);
449 static Image *SparseColorOption(const Image *image,
450 const SparseColorMethod method,const char *arguments,
451 const MagickBooleanType color_from_image,ExceptionInfo *exception)
454 token[MagickPathExtent];
479 SparseColorOption() parses the complex -sparse-color argument into an an
480 array of floating point values then calls SparseColorImage(). Argument is
481 a complex mix of floating-point pixel coodinates, and color specifications
482 (or direct floating point numbers). The number of floats needed to
483 represent a color varies depending on the current channel setting.
485 assert(image != (Image *) NULL);
486 assert(image->signature == MagickCoreSignature);
487 if (image->debug != MagickFalse)
488 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
489 assert(exception != (ExceptionInfo *) NULL);
490 assert(exception->signature == MagickCoreSignature);
492 Limit channels according to image - and add up number of color channel.
495 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
497 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
499 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
501 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
502 (image->colorspace == CMYKColorspace))
504 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
505 (image->alpha_trait != UndefinedPixelTrait))
509 Read string, to determine number of arguments needed,
515 GetNextToken(p,&p,MagickPathExtent,token);
516 if ( token[0] == ',' ) continue;
517 if ( isalpha((int) token[0]) || token[0] == '#' ) {
518 if ( color_from_image ) {
519 (void) ThrowMagickException(exception,GetMagickModule(),
520 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
521 "Color arg given, when colors are coming from image");
522 return( (Image *) NULL);
524 x += number_colors; /* color argument */
527 x++; /* floating point argument */
531 if ( color_from_image ) {
532 /* just the control points are being given */
533 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
534 number_arguments=(x/2)*(2+number_colors);
537 /* control points and color values */
538 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
542 (void) ThrowMagickException(exception,GetMagickModule(),
543 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
544 "Invalid number of Arguments");
545 return( (Image *) NULL);
548 /* Allocate and fill in the floating point arguments */
549 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
550 sizeof(*sparse_arguments));
551 if (sparse_arguments == (double *) NULL) {
552 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
553 "MemoryAllocationFailed","%s","SparseColorOption");
554 return( (Image *) NULL);
556 (void) memset(sparse_arguments,0,number_arguments*
557 sizeof(*sparse_arguments));
560 while( *p != '\0' && x < number_arguments ) {
562 token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
563 if ( token[0] == '\0' ) break;
564 if ( isalpha((int) token[0]) || token[0] == '#' ) {
565 (void) ThrowMagickException(exception,GetMagickModule(),
566 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
567 "Color found, instead of X-coord");
571 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
573 token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
574 if ( token[0] == '\0' ) break;
575 if ( isalpha((int) token[0]) || token[0] == '#' ) {
576 (void) ThrowMagickException(exception,GetMagickModule(),
577 OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
578 "Color found, instead of Y-coord");
582 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
583 /* color values for this control point */
585 if ( (color_from_image ) {
586 /* get color from image */
592 /* color name or function given in string argument */
593 token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
594 if ( token[0] == '\0' ) break;
595 if ( isalpha((int) token[0]) || token[0] == '#' ) {
596 /* Color string given */
597 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
598 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
599 sparse_arguments[x++] = QuantumScale*color.red;
600 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
601 sparse_arguments[x++] = QuantumScale*color.green;
602 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
603 sparse_arguments[x++] = QuantumScale*color.blue;
604 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
605 (image->colorspace == CMYKColorspace))
606 sparse_arguments[x++] = QuantumScale*color.black;
607 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
608 (image->alpha_trait != UndefinedPixelTrait))
609 sparse_arguments[x++] = QuantumScale*color.alpha;
612 /* Colors given as a set of floating point values - experimental */
613 /* NB: token contains the first floating point value to use! */
614 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
616 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
617 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
619 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
620 token[0] = ','; /* used this token - get another */
622 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
624 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
625 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
627 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
628 token[0] = ','; /* used this token - get another */
630 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
632 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
633 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
635 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
636 token[0] = ','; /* used this token - get another */
638 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
639 (image->colorspace == CMYKColorspace))
641 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
642 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
644 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
645 token[0] = ','; /* used this token - get another */
647 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
648 (image->alpha_trait != UndefinedPixelTrait))
650 while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
651 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
653 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
654 token[0] = ','; /* used this token - get another */
659 if ( number_arguments != x && !error ) {
660 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
661 "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
662 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
663 return( (Image *) NULL);
666 return( (Image *) NULL);
668 /* Call the Interpolation function with the parsed arguments */
669 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
671 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
672 return( sparse_image );
675 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
676 const char **argv,Image **image,ExceptionInfo *exception)
706 PixelInterpolateMethod
720 Initialize method variables.
722 assert(image_info != (const ImageInfo *) NULL);
723 assert(image_info->signature == MagickCoreSignature);
724 assert(image != (Image **) NULL);
725 assert((*image)->signature == MagickCoreSignature);
726 if ((*image)->debug != MagickFalse)
727 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
730 mogrify_info=CloneImageInfo(image_info);
731 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
732 quantize_info=AcquireQuantizeInfo(mogrify_info);
733 SetGeometryInfo(&geometry_info);
734 GetPixelInfo(*image,&fill);
735 fill=(*image)->background_color;
737 compose=(*image)->compose;
738 interpolate_method=UndefinedInterpolatePixel;
739 format=GetImageOption(mogrify_info,"format");
740 SetGeometry(*image,®ion_geometry);
742 Transmogrify the image.
744 for (i=0; i < (ssize_t) argc; i++)
753 if (IsCommandOption(option) == MagickFalse)
755 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
757 if ((i+count) >= (ssize_t) argc)
759 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
760 mogrify_image=(Image *) NULL;
765 if (LocaleCompare("adaptive-blur",option+1) == 0)
770 (void) SyncImageSettings(mogrify_info,*image,exception);
771 flags=ParseGeometry(argv[i+1],&geometry_info);
772 if ((flags & SigmaValue) == 0)
773 geometry_info.sigma=1.0;
774 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
775 geometry_info.sigma,exception);
778 if (LocaleCompare("adaptive-resize",option+1) == 0)
781 Adaptive resize image.
783 (void) SyncImageSettings(mogrify_info,*image,exception);
784 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
785 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
786 geometry.height,exception);
789 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
792 Adaptive sharpen image.
794 (void) SyncImageSettings(mogrify_info,*image,exception);
795 flags=ParseGeometry(argv[i+1],&geometry_info);
796 if ((flags & SigmaValue) == 0)
797 geometry_info.sigma=1.0;
798 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
799 geometry_info.sigma,exception);
802 if (LocaleCompare("affine",option+1) == 0)
809 GetAffineMatrix(&draw_info->affine);
812 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
815 if (LocaleCompare("alpha",option+1) == 0)
820 (void) SyncImageSettings(mogrify_info,*image,exception);
821 alpha_type=(AlphaChannelOption) ParseCommandOption(
822 MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
823 (void) SetImageAlphaChannel(*image,alpha_type,exception);
826 if (LocaleCompare("annotate",option+1) == 0)
830 geometry_str[MagickPathExtent];
835 (void) SyncImageSettings(mogrify_info,*image,exception);
836 SetGeometryInfo(&geometry_info);
837 flags=ParseGeometry(argv[i+1],&geometry_info);
838 if ((flags & SigmaValue) == 0)
839 geometry_info.sigma=geometry_info.rho;
840 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
842 if (text == (char *) NULL)
844 (void) CloneString(&draw_info->text,text);
845 text=DestroyString(text);
846 (void) FormatLocaleString(geometry_str,MagickPathExtent,"%+f%+f",
847 geometry_info.xi,geometry_info.psi);
848 (void) CloneString(&draw_info->geometry,geometry_str);
849 draw_info->affine.sx=cos(DegreesToRadians(
850 fmod(geometry_info.rho,360.0)));
851 draw_info->affine.rx=sin(DegreesToRadians(
852 fmod(geometry_info.rho,360.0)));
853 draw_info->affine.ry=(-sin(DegreesToRadians(
854 fmod(geometry_info.sigma,360.0))));
855 draw_info->affine.sy=cos(DegreesToRadians(
856 fmod(geometry_info.sigma,360.0)));
857 (void) AnnotateImage(*image,draw_info,exception);
860 if (LocaleCompare("antialias",option+1) == 0)
862 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
864 draw_info->text_antialias=(*option == '-') ? MagickTrue :
868 if (LocaleCompare("attenuate",option+1) == 0)
875 attenuate=StringToDouble(argv[i+1],(char **) NULL);
878 if (LocaleCompare("auto-gamma",option+1) == 0)
881 Auto Adjust Gamma of image based on its mean
883 (void) SyncImageSettings(mogrify_info,*image,exception);
884 (void) AutoGammaImage(*image,exception);
887 if (LocaleCompare("auto-level",option+1) == 0)
890 Perfectly Normalize (max/min stretch) the image
892 (void) SyncImageSettings(mogrify_info,*image,exception);
893 (void) AutoLevelImage(*image,exception);
896 if (LocaleCompare("auto-orient",option+1) == 0)
898 (void) SyncImageSettings(mogrify_info,*image,exception);
899 mogrify_image=AutoOrientImage(*image,(*image)->orientation,
903 if (LocaleCompare("auto-threshold",option+1) == 0)
908 (void) SyncImageSettings(mogrify_info,*image,exception);
909 method=(AutoThresholdMethod) ParseCommandOption(
910 MagickAutoThresholdOptions,MagickFalse,argv[i+1]);
911 (void) AutoThresholdImage(*image,method,exception);
918 if (LocaleCompare("black-threshold",option+1) == 0)
921 Black threshold image.
923 (void) SyncImageSettings(mogrify_info,*image,exception);
924 (void) BlackThresholdImage(*image,argv[i+1],exception);
927 if (LocaleCompare("blue-shift",option+1) == 0)
932 (void) SyncImageSettings(mogrify_info,*image,exception);
933 geometry_info.rho=1.5;
935 flags=ParseGeometry(argv[i+1],&geometry_info);
936 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
939 if (LocaleCompare("blur",option+1) == 0)
944 (void) SyncImageSettings(mogrify_info,*image,exception);
945 flags=ParseGeometry(argv[i+1],&geometry_info);
946 if ((flags & SigmaValue) == 0)
947 geometry_info.sigma=1.0;
948 if ((flags & XiValue) == 0)
949 geometry_info.xi=0.0;
950 mogrify_image=BlurImage(*image,geometry_info.rho,
951 geometry_info.sigma,exception);
954 if (LocaleCompare("border",option+1) == 0)
957 Surround image with a border of solid color.
959 (void) SyncImageSettings(mogrify_info,*image,exception);
960 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
961 mogrify_image=BorderImage(*image,&geometry,compose,exception);
964 if (LocaleCompare("bordercolor",option+1) == 0)
968 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
969 &draw_info->border_color,exception);
972 (void) QueryColorCompliance(argv[i+1],AllCompliance,
973 &draw_info->border_color,exception);
976 if (LocaleCompare("box",option+1) == 0)
978 (void) QueryColorCompliance(argv[i+1],AllCompliance,
979 &draw_info->undercolor,exception);
982 if (LocaleCompare("brightness-contrast",option+1) == 0)
989 Brightness / contrast image.
991 (void) SyncImageSettings(mogrify_info,*image,exception);
992 flags=ParseGeometry(argv[i+1],&geometry_info);
993 brightness=geometry_info.rho;
995 if ((flags & SigmaValue) != 0)
996 contrast=geometry_info.sigma;
997 (void) BrightnessContrastImage(*image,brightness,contrast,
1005 if (LocaleCompare("canny",option+1) == 0)
1008 Detect edges in the image.
1010 (void) SyncImageSettings(mogrify_info,*image,exception);
1011 flags=ParseGeometry(argv[i+1],&geometry_info);
1012 if ((flags & SigmaValue) == 0)
1013 geometry_info.sigma=1.0;
1014 if ((flags & XiValue) == 0)
1015 geometry_info.xi=0.10;
1016 if ((flags & PsiValue) == 0)
1017 geometry_info.psi=0.30;
1018 if ((flags & PercentValue) != 0)
1020 geometry_info.xi/=100.0;
1021 geometry_info.psi/=100.0;
1023 mogrify_image=CannyEdgeImage(*image,geometry_info.rho,
1024 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
1027 if (LocaleCompare("cdl",option+1) == 0)
1030 *color_correction_collection;
1033 Color correct with a color decision list.
1035 (void) SyncImageSettings(mogrify_info,*image,exception);
1036 color_correction_collection=FileToString(argv[i+1],~0UL,exception);
1037 if (color_correction_collection == (char *) NULL)
1039 (void) ColorDecisionListImage(*image,color_correction_collection,
1043 if (LocaleCompare("channel",option+1) == 0)
1048 (void) SyncImageSettings(mogrify_info,*image,exception);
1051 (void) SetPixelChannelMask(*image,DefaultChannels);
1054 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1055 (void) SetPixelChannelMask(*image,channel);
1058 if (LocaleCompare("charcoal",option+1) == 0)
1063 (void) SyncImageSettings(mogrify_info,*image,exception);
1064 flags=ParseGeometry(argv[i+1],&geometry_info);
1065 if ((flags & SigmaValue) == 0)
1066 geometry_info.sigma=1.0;
1067 if ((flags & XiValue) == 0)
1068 geometry_info.xi=1.0;
1069 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1070 geometry_info.sigma,exception);
1073 if (LocaleCompare("chop",option+1) == 0)
1078 (void) SyncImageSettings(mogrify_info,*image,exception);
1079 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1080 mogrify_image=ChopImage(*image,&geometry,exception);
1083 if (LocaleCompare("clip",option+1) == 0)
1085 (void) SyncImageSettings(mogrify_info,*image,exception);
1088 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
1092 (void) ClipImage(*image,exception);
1095 if (LocaleCompare("clip-mask",option+1) == 0)
1100 (void) SyncImageSettings(mogrify_info,*image,exception);
1106 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
1113 clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
1114 if (clip_mask == (Image *) NULL)
1116 (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
1117 clip_mask=DestroyImage(clip_mask);
1120 if (LocaleCompare("clip-path",option+1) == 0)
1122 (void) SyncImageSettings(mogrify_info,*image,exception);
1123 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1124 MagickFalse,exception);
1127 if (LocaleCompare("colorize",option+1) == 0)
1132 (void) SyncImageSettings(mogrify_info,*image,exception);
1133 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1136 if (LocaleCompare("color-matrix",option+1) == 0)
1141 (void) SyncImageSettings(mogrify_info,*image,exception);
1142 kernel=AcquireKernelInfo(argv[i+1],exception);
1143 if (kernel == (KernelInfo *) NULL)
1145 /* FUTURE: check on size of the matrix */
1146 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1147 kernel=DestroyKernelInfo(kernel);
1150 if (LocaleCompare("colors",option+1) == 0)
1153 Reduce the number of colors in the image.
1155 (void) SyncImageSettings(mogrify_info,*image,exception);
1156 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1157 if (quantize_info->number_colors == 0)
1159 if (((*image)->storage_class == DirectClass) ||
1160 (*image)->colors > quantize_info->number_colors)
1161 (void) QuantizeImage(quantize_info,*image,exception);
1163 (void) CompressImageColormap(*image,exception);
1166 if (LocaleCompare("colorspace",option+1) == 0)
1171 (void) SyncImageSettings(mogrify_info,*image,exception);
1174 (void) TransformImageColorspace(*image,sRGBColorspace,
1178 colorspace=(ColorspaceType) ParseCommandOption(
1179 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1180 (void) TransformImageColorspace(*image,colorspace,exception);
1183 if (LocaleCompare("compose",option+1) == 0)
1185 (void) SyncImageSettings(mogrify_info,*image,exception);
1186 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1187 MagickFalse,argv[i+1]);
1190 if (LocaleCompare("connected-components",option+1) == 0)
1192 (void) SyncImageSettings(mogrify_info,*image,exception);
1193 mogrify_image=ConnectedComponentsImage(*image,(size_t)
1194 StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);
1197 if (LocaleCompare("contrast",option+1) == 0)
1199 (void) SyncImageSettings(mogrify_info,*image,exception);
1200 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1201 MagickFalse,exception);
1204 if (LocaleCompare("contrast-stretch",option+1) == 0)
1211 Contrast stretch image.
1213 (void) SyncImageSettings(mogrify_info,*image,exception);
1214 flags=ParseGeometry(argv[i+1],&geometry_info);
1215 black_point=geometry_info.rho;
1216 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1218 if ((flags & PercentValue) != 0)
1220 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1221 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1223 white_point=(double) (*image)->columns*(*image)->rows-
1225 (void) ContrastStretchImage(*image,black_point,white_point,
1229 if (LocaleCompare("convolve",option+1) == 0)
1243 (void) SyncImageSettings(mogrify_info,*image,exception);
1244 kernel_info=AcquireKernelInfo(argv[i+1],exception);
1245 if (kernel_info == (KernelInfo *) NULL)
1247 extent=kernel_info->width*kernel_info->height;
1249 for (j=0; j < (ssize_t) extent; j++)
1250 gamma+=kernel_info->values[j];
1251 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1252 for (j=0; j < (ssize_t) extent; j++)
1253 kernel_info->values[j]*=gamma;
1254 mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,
1255 kernel_info,exception);
1256 kernel_info=DestroyKernelInfo(kernel_info);
1259 if (LocaleCompare("crop",option+1) == 0)
1262 Crop a image to a smaller size
1264 (void) SyncImageSettings(mogrify_info,*image,exception);
1265 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1268 if (LocaleCompare("cycle",option+1) == 0)
1271 Cycle an image colormap.
1273 (void) SyncImageSettings(mogrify_info,*image,exception);
1274 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1282 if (LocaleCompare("decipher",option+1) == 0)
1290 (void) SyncImageSettings(mogrify_info,*image,exception);
1291 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1292 if (passkey != (StringInfo *) NULL)
1294 (void) PasskeyDecipherImage(*image,passkey,exception);
1295 passkey=DestroyStringInfo(passkey);
1299 if (LocaleCompare("density",option+1) == 0)
1304 (void) CloneString(&draw_info->density,argv[i+1]);
1307 if (LocaleCompare("depth",option+1) == 0)
1309 (void) SyncImageSettings(mogrify_info,*image,exception);
1312 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1315 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1319 if (LocaleCompare("deskew",option+1) == 0)
1325 Straighten the image.
1327 (void) SyncImageSettings(mogrify_info,*image,exception);
1329 threshold=40.0*QuantumRange/100.0;
1331 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1333 mogrify_image=DeskewImage(*image,threshold,exception);
1336 if (LocaleCompare("despeckle",option+1) == 0)
1339 Reduce the speckles within an image.
1341 (void) SyncImageSettings(mogrify_info,*image,exception);
1342 mogrify_image=DespeckleImage(*image,exception);
1345 if (LocaleCompare("display",option+1) == 0)
1347 (void) CloneString(&draw_info->server_name,argv[i+1]);
1350 if (LocaleCompare("distort",option+1) == 0)
1354 token[MagickPathExtent];
1374 (void) SyncImageSettings(mogrify_info,*image,exception);
1375 method=(DistortMethod) ParseCommandOption(MagickDistortOptions,
1376 MagickFalse,argv[i+1]);
1377 if (method == ResizeDistortion)
1383 Special Case - Argument is actually a resize geometry!
1384 Convert that to an appropriate distortion argument array.
1386 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1388 resize_args[0]=(double) geometry.width;
1389 resize_args[1]=(double) geometry.height;
1390 mogrify_image=DistortImage(*image,method,(size_t)2,
1391 resize_args,MagickTrue,exception);
1394 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1396 if (args == (char *) NULL)
1399 for (x=0; *p != '\0'; x++)
1401 GetNextToken(p,&p,MagickPathExtent,token);
1403 GetNextToken(p,&p,MagickPathExtent,token);
1405 number_arguments=(size_t) x;
1406 arguments=(double *) AcquireQuantumMemory(number_arguments,
1407 sizeof(*arguments));
1408 if (arguments == (double *) NULL)
1409 ThrowWandFatalException(ResourceLimitFatalError,
1410 "MemoryAllocationFailed",(*image)->filename);
1411 (void) memset(arguments,0,number_arguments*
1412 sizeof(*arguments));
1414 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1416 GetNextToken(p,&p,MagickPathExtent,token);
1418 GetNextToken(p,&p,MagickPathExtent,token);
1419 arguments[x]=StringToDouble(token,(char **) NULL);
1421 args=DestroyString(args);
1422 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1423 (*option == '+') ? MagickTrue : MagickFalse,exception);
1424 arguments=(double *) RelinquishMagickMemory(arguments);
1427 if (LocaleCompare("dither",option+1) == 0)
1431 quantize_info->dither_method=NoDitherMethod;
1434 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1435 MagickDitherOptions,MagickFalse,argv[i+1]);
1438 if (LocaleCompare("draw",option+1) == 0)
1443 (void) SyncImageSettings(mogrify_info,*image,exception);
1444 (void) CloneString(&draw_info->primitive,argv[i+1]);
1445 (void) DrawImage(*image,draw_info,exception);
1452 if (LocaleCompare("edge",option+1) == 0)
1455 Enhance edges in the image.
1457 (void) SyncImageSettings(mogrify_info,*image,exception);
1458 flags=ParseGeometry(argv[i+1],&geometry_info);
1459 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1462 if (LocaleCompare("emboss",option+1) == 0)
1467 (void) SyncImageSettings(mogrify_info,*image,exception);
1468 flags=ParseGeometry(argv[i+1],&geometry_info);
1469 if ((flags & SigmaValue) == 0)
1470 geometry_info.sigma=1.0;
1471 mogrify_image=EmbossImage(*image,geometry_info.rho,
1472 geometry_info.sigma,exception);
1475 if (LocaleCompare("encipher",option+1) == 0)
1483 (void) SyncImageSettings(mogrify_info,*image,exception);
1484 passkey=FileToStringInfo(argv[i+1],~0UL,exception);
1485 if (passkey != (StringInfo *) NULL)
1487 (void) PasskeyEncipherImage(*image,passkey,exception);
1488 passkey=DestroyStringInfo(passkey);
1492 if (LocaleCompare("encoding",option+1) == 0)
1494 (void) CloneString(&draw_info->encoding,argv[i+1]);
1497 if (LocaleCompare("enhance",option+1) == 0)
1502 (void) SyncImageSettings(mogrify_info,*image,exception);
1503 mogrify_image=EnhanceImage(*image,exception);
1506 if (LocaleCompare("equalize",option+1) == 0)
1511 (void) SyncImageSettings(mogrify_info,*image,exception);
1512 (void) EqualizeImage(*image,exception);
1515 if (LocaleCompare("evaluate",option+1) == 0)
1520 MagickEvaluateOperator
1523 (void) SyncImageSettings(mogrify_info,*image,exception);
1524 op=(MagickEvaluateOperator) ParseCommandOption(
1525 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1526 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1528 (void) EvaluateImage(*image,op,constant,exception);
1531 if (LocaleCompare("extent",option+1) == 0)
1534 Set the image extent.
1536 (void) SyncImageSettings(mogrify_info,*image,exception);
1537 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1538 if (geometry.width == 0)
1539 geometry.width=(*image)->columns;
1540 if (geometry.height == 0)
1541 geometry.height=(*image)->rows;
1542 mogrify_image=ExtentImage(*image,&geometry,exception);
1549 if (LocaleCompare("family",option+1) == 0)
1553 if (draw_info->family != (char *) NULL)
1554 draw_info->family=DestroyString(draw_info->family);
1557 (void) CloneString(&draw_info->family,argv[i+1]);
1560 if (LocaleCompare("features",option+1) == 0)
1564 (void) DeleteImageArtifact(*image,"identify:features");
1567 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1568 (void) SetImageArtifact(*image,"verbose","true");
1571 if (LocaleCompare("fill",option+1) == 0)
1579 GetPixelInfo(*image,&fill);
1582 (void) QueryColorCompliance("none",AllCompliance,&fill,
1584 draw_info->fill=fill;
1585 if (draw_info->fill_pattern != (Image *) NULL)
1586 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1589 sans=AcquireExceptionInfo();
1590 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
1591 sans=DestroyExceptionInfo(sans);
1592 if (status == MagickFalse)
1593 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1596 draw_info->fill=fill=color;
1599 if (LocaleCompare("flip",option+1) == 0)
1602 Flip image scanlines.
1604 (void) SyncImageSettings(mogrify_info,*image,exception);
1605 mogrify_image=FlipImage(*image,exception);
1608 if (LocaleCompare("floodfill",option+1) == 0)
1616 (void) SyncImageSettings(mogrify_info,*image,exception);
1617 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1618 (void) GetOneVirtualPixelInfo(*image,TileVirtualPixelMethod,
1619 geometry.x,geometry.y,&target,exception);
1620 (void) QueryColorCompliance(argv[i+2],AllCompliance,
1621 &draw_info->fill,exception);
1622 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1623 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1626 if (LocaleCompare("flop",option+1) == 0)
1629 Flop image scanlines.
1631 (void) SyncImageSettings(mogrify_info,*image,exception);
1632 mogrify_image=FlopImage(*image,exception);
1635 if (LocaleCompare("font",option+1) == 0)
1639 if (draw_info->font != (char *) NULL)
1640 draw_info->font=DestroyString(draw_info->font);
1643 (void) CloneString(&draw_info->font,argv[i+1]);
1646 if (LocaleCompare("format",option+1) == 0)
1651 if (LocaleCompare("frame",option+1) == 0)
1657 Surround image with an ornamental border.
1659 (void) SyncImageSettings(mogrify_info,*image,exception);
1660 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1661 frame_info.width=geometry.width;
1662 frame_info.height=geometry.height;
1663 frame_info.outer_bevel=geometry.x;
1664 frame_info.inner_bevel=geometry.y;
1665 frame_info.x=(ssize_t) frame_info.width;
1666 frame_info.y=(ssize_t) frame_info.height;
1667 frame_info.width=(*image)->columns+2*frame_info.width;
1668 frame_info.height=(*image)->rows+2*frame_info.height;
1669 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1672 if (LocaleCompare("function",option+1) == 0)
1676 token[MagickPathExtent];
1694 Function Modify Image Values
1696 (void) SyncImageSettings(mogrify_info,*image,exception);
1697 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1698 MagickFalse,argv[i+1]);
1699 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1701 if (arguments == (char *) NULL)
1703 p=(char *) arguments;
1704 for (x=0; *p != '\0'; x++)
1706 GetNextToken(p,&p,MagickPathExtent,token);
1708 GetNextToken(p,&p,MagickPathExtent,token);
1710 number_parameters=(size_t) x;
1711 parameters=(double *) AcquireQuantumMemory(number_parameters,
1712 sizeof(*parameters));
1713 if (parameters == (double *) NULL)
1714 ThrowWandFatalException(ResourceLimitFatalError,
1715 "MemoryAllocationFailed",(*image)->filename);
1716 (void) memset(parameters,0,number_parameters*
1717 sizeof(*parameters));
1718 p=(char *) arguments;
1719 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1721 GetNextToken(p,&p,MagickPathExtent,token);
1723 GetNextToken(p,&p,MagickPathExtent,token);
1724 parameters[x]=StringToDouble(token,(char **) NULL);
1726 arguments=DestroyString(arguments);
1727 (void) FunctionImage(*image,function,number_parameters,parameters,
1729 parameters=(double *) RelinquishMagickMemory(parameters);
1736 if (LocaleCompare("gamma",option+1) == 0)
1741 (void) SyncImageSettings(mogrify_info,*image,exception);
1743 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1745 (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),
1749 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1750 (LocaleCompare("gaussian",option+1) == 0))
1753 Gaussian blur image.
1755 (void) SyncImageSettings(mogrify_info,*image,exception);
1756 flags=ParseGeometry(argv[i+1],&geometry_info);
1757 if ((flags & SigmaValue) == 0)
1758 geometry_info.sigma=1.0;
1759 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1760 geometry_info.sigma,exception);
1763 if (LocaleCompare("geometry",option+1) == 0)
1766 Record Image offset, Resize last image.
1768 (void) SyncImageSettings(mogrify_info,*image,exception);
1771 if ((*image)->geometry != (char *) NULL)
1772 (*image)->geometry=DestroyString((*image)->geometry);
1775 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1776 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1777 (void) CloneString(&(*image)->geometry,argv[i+1]);
1779 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1780 (*image)->filter,exception);
1783 if (LocaleCompare("gravity",option+1) == 0)
1787 draw_info->gravity=UndefinedGravity;
1790 draw_info->gravity=(GravityType) ParseCommandOption(
1791 MagickGravityOptions,MagickFalse,argv[i+1]);
1794 if (LocaleCompare("grayscale",option+1) == 0)
1796 PixelIntensityMethod
1799 (void) SyncImageSettings(mogrify_info,*image,exception);
1800 method=(PixelIntensityMethod) ParseCommandOption(
1801 MagickPixelIntensityOptions,MagickFalse,argv[i+1]);
1802 (void) GrayscaleImage(*image,method,exception);
1809 if (LocaleCompare("highlight-color",option+1) == 0)
1811 (void) SetImageArtifact(*image,"compare:highlight-color",argv[i+1]);
1814 if (LocaleCompare("hough-lines",option+1) == 0)
1817 Detect edges in the image.
1819 (void) SyncImageSettings(mogrify_info,*image,exception);
1820 flags=ParseGeometry(argv[i+1],&geometry_info);
1821 if ((flags & SigmaValue) == 0)
1822 geometry_info.sigma=geometry_info.rho;
1823 if ((flags & XiValue) == 0)
1824 geometry_info.xi=40;
1825 mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,
1826 (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);
1833 if (LocaleCompare("identify",option+1) == 0)
1838 (void) SyncImageSettings(mogrify_info,*image,exception);
1839 if (format == (char *) NULL)
1841 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1845 text=InterpretImageProperties(mogrify_info,*image,format,
1847 if (text == (char *) NULL)
1849 (void) fputs(text,stdout);
1850 text=DestroyString(text);
1853 if (LocaleCompare("implode",option+1) == 0)
1858 (void) SyncImageSettings(mogrify_info,*image,exception);
1859 (void) ParseGeometry(argv[i+1],&geometry_info);
1860 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1861 interpolate_method,exception);
1864 if (LocaleCompare("interline-spacing",option+1) == 0)
1867 (void) ParseGeometry("0",&geometry_info);
1869 (void) ParseGeometry(argv[i+1],&geometry_info);
1870 draw_info->interline_spacing=geometry_info.rho;
1873 if (LocaleCompare("interpolate",option+1) == 0)
1875 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1876 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1879 if (LocaleCompare("interword-spacing",option+1) == 0)
1882 (void) ParseGeometry("0",&geometry_info);
1884 (void) ParseGeometry(argv[i+1],&geometry_info);
1885 draw_info->interword_spacing=geometry_info.rho;
1888 if (LocaleCompare("interpolative-resize",option+1) == 0)
1891 Interpolative resize image.
1893 (void) SyncImageSettings(mogrify_info,*image,exception);
1894 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1895 mogrify_image=InterpolativeResizeImage(*image,geometry.width,
1896 geometry.height,interpolate_method,exception);
1903 if (LocaleCompare("kerning",option+1) == 0)
1906 (void) ParseGeometry("0",&geometry_info);
1908 (void) ParseGeometry(argv[i+1],&geometry_info);
1909 draw_info->kerning=geometry_info.rho;
1912 if (LocaleCompare("kuwahara",option+1) == 0)
1915 Edge preserving blur.
1917 (void) SyncImageSettings(mogrify_info,*image,exception);
1918 flags=ParseGeometry(argv[i+1],&geometry_info);
1919 if ((flags & SigmaValue) == 0)
1920 geometry_info.sigma=geometry_info.rho-0.5;
1921 mogrify_image=KuwaharaImage(*image,geometry_info.rho,
1922 geometry_info.sigma,exception);
1929 if (LocaleCompare("lat",option+1) == 0)
1932 Local adaptive threshold image.
1934 (void) SyncImageSettings(mogrify_info,*image,exception);
1935 flags=ParseGeometry(argv[i+1],&geometry_info);
1936 if ((flags & PercentValue) != 0)
1937 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1938 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1939 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1940 geometry_info.xi,exception);
1943 if (LocaleCompare("level",option+1) == 0)
1953 (void) SyncImageSettings(mogrify_info,*image,exception);
1954 flags=ParseGeometry(argv[i+1],&geometry_info);
1955 black_point=geometry_info.rho;
1956 white_point=(double) QuantumRange;
1957 if ((flags & SigmaValue) != 0)
1958 white_point=geometry_info.sigma;
1960 if ((flags & XiValue) != 0)
1961 gamma=geometry_info.xi;
1962 if ((flags & PercentValue) != 0)
1964 black_point*=(double) (QuantumRange/100.0);
1965 white_point*=(double) (QuantumRange/100.0);
1967 if ((flags & SigmaValue) == 0)
1968 white_point=(double) QuantumRange-black_point;
1969 if ((*option == '+') || ((flags & AspectValue) != 0))
1970 (void) LevelizeImage(*image,black_point,white_point,gamma,
1973 (void) LevelImage(*image,black_point,white_point,gamma,
1977 if (LocaleCompare("level-colors",option+1) == 0)
1980 token[MagickPathExtent];
1989 p=(const char *) argv[i+1];
1990 GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */
1991 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1992 (void) QueryColorCompliance(token,AllCompliance,
1993 &black_point,exception);
1995 (void) QueryColorCompliance("#000000",AllCompliance,
1996 &black_point,exception);
1997 if (isalpha((int) token[0]) || (token[0] == '#'))
1998 GetNextToken(p,&p,MagickPathExtent,token);
2000 white_point=black_point; /* set everything to that color */
2003 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
2004 GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */
2005 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
2006 (void) QueryColorCompliance(token,AllCompliance,
2007 &white_point,exception);
2009 (void) QueryColorCompliance("#ffffff",AllCompliance,
2010 &white_point,exception);
2012 (void) LevelImageColors(*image,&black_point,&white_point,
2013 *option == '+' ? MagickTrue : MagickFalse,exception);
2016 if (LocaleCompare("linear-stretch",option+1) == 0)
2022 (void) SyncImageSettings(mogrify_info,*image,exception);
2023 flags=ParseGeometry(argv[i+1],&geometry_info);
2024 black_point=geometry_info.rho;
2025 white_point=(double) (*image)->columns*(*image)->rows;
2026 if ((flags & SigmaValue) != 0)
2027 white_point=geometry_info.sigma;
2028 if ((flags & PercentValue) != 0)
2030 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2031 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2033 if ((flags & SigmaValue) == 0)
2034 white_point=(double) (*image)->columns*(*image)->rows-
2036 (void) LinearStretchImage(*image,black_point,white_point,exception);
2039 if (LocaleCompare("liquid-rescale",option+1) == 0)
2042 Liquid rescale image.
2044 (void) SyncImageSettings(mogrify_info,*image,exception);
2045 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2046 if ((flags & XValue) == 0)
2048 if ((flags & YValue) == 0)
2050 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2051 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2054 if (LocaleCompare("local-contrast",option+1) == 0)
2056 (void) SyncImageSettings(mogrify_info,*image,exception);
2057 flags=ParseGeometry(argv[i+1],&geometry_info);
2058 if ((flags & RhoValue) == 0)
2059 geometry_info.rho=10;
2060 if ((flags & SigmaValue) == 0)
2061 geometry_info.sigma=12.5;
2062 mogrify_image=LocalContrastImage(*image,geometry_info.rho,
2063 geometry_info.sigma,exception);
2066 if (LocaleCompare("lowlight-color",option+1) == 0)
2068 (void) SetImageArtifact(*image,"compare:lowlight-color",argv[i+1]);
2075 if (LocaleCompare("magnify",option+1) == 0)
2080 (void) SyncImageSettings(mogrify_info,*image,exception);
2081 mogrify_image=MagnifyImage(*image,exception);
2084 if (LocaleCompare("map",option+1) == 0)
2090 Transform image colors to match this set of colors.
2092 (void) SyncImageSettings(mogrify_info,*image,exception);
2095 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2096 if (remap_image == (Image *) NULL)
2098 (void) RemapImage(quantize_info,*image,remap_image,exception);
2099 remap_image=DestroyImage(remap_image);
2102 if (LocaleCompare("mask",option+1) == 0)
2107 (void) SyncImageSettings(mogrify_info,*image,exception);
2113 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
2120 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2121 if (mask == (Image *) NULL)
2123 (void) SetImageMask(*image,WritePixelMask,mask,exception);
2124 mask=DestroyImage(mask);
2127 if (LocaleCompare("matte",option+1) == 0)
2129 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2130 SetAlphaChannel : DeactivateAlphaChannel,exception);
2133 if (LocaleCompare("mean-shift",option+1) == 0)
2136 Detect edges in the image.
2138 (void) SyncImageSettings(mogrify_info,*image,exception);
2139 flags=ParseGeometry(argv[i+1],&geometry_info);
2140 if ((flags & SigmaValue) == 0)
2141 geometry_info.sigma=geometry_info.rho;
2142 if ((flags & XiValue) == 0)
2143 geometry_info.xi=0.10*QuantumRange;
2144 if ((flags & PercentValue) != 0)
2145 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2146 mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,
2147 (size_t) geometry_info.sigma,geometry_info.xi,exception);
2150 if (LocaleCompare("median",option+1) == 0)
2153 Median filter image.
2155 (void) SyncImageSettings(mogrify_info,*image,exception);
2156 flags=ParseGeometry(argv[i+1],&geometry_info);
2157 if ((flags & SigmaValue) == 0)
2158 geometry_info.sigma=geometry_info.rho;
2159 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2160 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2163 if (LocaleCompare("mode",option+1) == 0)
2168 (void) SyncImageSettings(mogrify_info,*image,exception);
2169 flags=ParseGeometry(argv[i+1],&geometry_info);
2170 if ((flags & SigmaValue) == 0)
2171 geometry_info.sigma=geometry_info.rho;
2172 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2173 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2176 if (LocaleCompare("modulate",option+1) == 0)
2178 (void) SyncImageSettings(mogrify_info,*image,exception);
2179 (void) ModulateImage(*image,argv[i+1],exception);
2182 if (LocaleCompare("moments",option+1) == 0)
2186 (void) DeleteImageArtifact(*image,"identify:moments");
2189 (void) SetImageArtifact(*image,"identify:moments",argv[i+1]);
2190 (void) SetImageArtifact(*image,"verbose","true");
2193 if (LocaleCompare("monitor",option+1) == 0)
2197 (void) SetImageProgressMonitor(*image,
2198 (MagickProgressMonitor) NULL,(void *) NULL);
2201 (void) SetImageProgressMonitor(*image,MonitorProgress,
2205 if (LocaleCompare("monochrome",option+1) == 0)
2207 (void) SyncImageSettings(mogrify_info,*image,exception);
2208 (void) SetImageType(*image,BilevelType,exception);
2211 if (LocaleCompare("morphology",option+1) == 0)
2214 token[MagickPathExtent];
2229 Morphological Image Operation
2231 (void) SyncImageSettings(mogrify_info,*image,exception);
2233 GetNextToken(p,&p,MagickPathExtent,token);
2234 method=(MorphologyMethod) ParseCommandOption(
2235 MagickMorphologyOptions,MagickFalse,token);
2237 GetNextToken(p,&p,MagickPathExtent,token);
2238 if ((*p == ':') || (*p == ','))
2239 GetNextToken(p,&p,MagickPathExtent,token);
2241 iterations=(ssize_t) StringToLong(p);
2242 kernel=AcquireKernelInfo(argv[i+2],exception);
2243 if (kernel == (KernelInfo *) NULL)
2245 (void) ThrowMagickException(exception,GetMagickModule(),
2246 OptionError,"UnabletoParseKernel","morphology");
2250 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2252 kernel=DestroyKernelInfo(kernel);
2255 if (LocaleCompare("motion-blur",option+1) == 0)
2260 (void) SyncImageSettings(mogrify_info,*image,exception);
2261 flags=ParseGeometry(argv[i+1],&geometry_info);
2262 if ((flags & SigmaValue) == 0)
2263 geometry_info.sigma=1.0;
2264 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2265 geometry_info.sigma,geometry_info.xi,exception);
2272 if (LocaleCompare("negate",option+1) == 0)
2274 (void) SyncImageSettings(mogrify_info,*image,exception);
2275 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2276 MagickFalse,exception);
2279 if (LocaleCompare("noise",option+1) == 0)
2281 (void) SyncImageSettings(mogrify_info,*image,exception);
2284 flags=ParseGeometry(argv[i+1],&geometry_info);
2285 if ((flags & SigmaValue) == 0)
2286 geometry_info.sigma=geometry_info.rho;
2287 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2288 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2295 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2296 MagickFalse,argv[i+1]);
2297 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2301 if (LocaleCompare("normalize",option+1) == 0)
2303 (void) SyncImageSettings(mogrify_info,*image,exception);
2304 (void) NormalizeImage(*image,exception);
2311 if (LocaleCompare("opaque",option+1) == 0)
2316 (void) SyncImageSettings(mogrify_info,*image,exception);
2317 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2319 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2320 MagickFalse : MagickTrue,exception);
2323 if (LocaleCompare("ordered-dither",option+1) == 0)
2325 (void) SyncImageSettings(mogrify_info,*image,exception);
2326 (void) OrderedDitherImage(*image,argv[i+1],exception);
2333 if (LocaleCompare("paint",option+1) == 0)
2335 (void) SyncImageSettings(mogrify_info,*image,exception);
2336 (void) ParseGeometry(argv[i+1],&geometry_info);
2337 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2338 geometry_info.sigma,exception);
2341 if (LocaleCompare("perceptible",option+1) == 0)
2346 (void) SyncImageSettings(mogrify_info,*image,exception);
2347 (void) PerceptibleImage(*image,StringToDouble(argv[i+1],
2348 (char **) NULL),exception);
2351 if (LocaleCompare("pointsize",option+1) == 0)
2354 (void) ParseGeometry("12",&geometry_info);
2356 (void) ParseGeometry(argv[i+1],&geometry_info);
2357 draw_info->pointsize=geometry_info.rho;
2360 if (LocaleCompare("polaroid",option+1) == 0)
2372 Simulate a Polaroid picture.
2374 (void) SyncImageSettings(mogrify_info,*image,exception);
2375 random_info=AcquireRandomInfo();
2376 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2377 random_info=DestroyRandomInfo(random_info);
2380 SetGeometryInfo(&geometry_info);
2381 flags=ParseGeometry(argv[i+1],&geometry_info);
2382 angle=geometry_info.rho;
2384 caption=GetImageProperty(*image,"caption",exception);
2385 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2386 interpolate_method,exception);
2389 if (LocaleCompare("posterize",option+1) == 0)
2394 (void) SyncImageSettings(mogrify_info,*image,exception);
2395 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2396 quantize_info->dither_method,exception);
2399 if (LocaleCompare("preview",option+1) == 0)
2407 (void) SyncImageSettings(mogrify_info,*image,exception);
2409 preview_type=UndefinedPreview;
2411 preview_type=(PreviewType) ParseCommandOption(
2412 MagickPreviewOptions,MagickFalse,argv[i+1]);
2413 mogrify_image=PreviewImage(*image,preview_type,exception);
2416 if (LocaleCompare("profile",option+1) == 0)
2430 (void) SyncImageSettings(mogrify_info,*image,exception);
2434 Remove a profile from the image.
2436 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2441 Associate a profile with the image.
2443 profile_info=CloneImageInfo(mogrify_info);
2444 profile=GetImageProfile(*image,"iptc");
2445 if (profile != (StringInfo *) NULL)
2446 profile_info->profile=(void *) CloneStringInfo(profile);
2447 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2448 profile_info=DestroyImageInfo(profile_info);
2449 if (profile_image == (Image *) NULL)
2454 profile_info=CloneImageInfo(mogrify_info);
2455 (void) CopyMagickString(profile_info->filename,argv[i+1],
2457 file_data=FileToStringInfo(profile_info->filename,~0UL,
2459 if (file_data != (StringInfo *) NULL)
2461 (void) SetImageInfo(profile_info,0,exception);
2462 (void) ProfileImage(*image,profile_info->magick,
2463 GetStringInfoDatum(file_data),
2464 GetStringInfoLength(file_data),exception);
2465 file_data=DestroyStringInfo(file_data);
2467 profile_info=DestroyImageInfo(profile_info);
2470 ResetImageProfileIterator(profile_image);
2471 name=GetNextImageProfile(profile_image);
2472 while (name != (const char *) NULL)
2474 profile=GetImageProfile(profile_image,name);
2475 if (profile != (StringInfo *) NULL)
2476 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2477 (size_t) GetStringInfoLength(profile),exception);
2478 name=GetNextImageProfile(profile_image);
2480 profile_image=DestroyImage(profile_image);
2487 if (LocaleCompare("quantize",option+1) == 0)
2491 quantize_info->colorspace=UndefinedColorspace;
2494 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2495 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2502 if (LocaleCompare("rotational-blur",option+1) == 0)
2505 Rotational blur image.
2507 (void) SyncImageSettings(mogrify_info,*image,exception);
2508 flags=ParseGeometry(argv[i+1],&geometry_info);
2509 mogrify_image=RotationalBlurImage(*image,geometry_info.rho,
2513 if (LocaleCompare("raise",option+1) == 0)
2516 Surround image with a raise of solid color.
2518 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2519 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2520 MagickFalse,exception);
2523 if (LocaleCompare("random-threshold",option+1) == 0)
2526 Random threshold image.
2532 (void) SyncImageSettings(mogrify_info,*image,exception);
2534 max_threshold=(double) QuantumRange;
2535 flags=ParseGeometry(argv[i+1],&geometry_info);
2536 min_threshold=geometry_info.rho;
2537 max_threshold=geometry_info.sigma;
2538 if ((flags & SigmaValue) == 0)
2539 max_threshold=min_threshold;
2540 if (strchr(argv[i+1],'%') != (char *) NULL)
2542 max_threshold*=(double) (0.01*QuantumRange);
2543 min_threshold*=(double) (0.01*QuantumRange);
2545 (void) RandomThresholdImage(*image,min_threshold,max_threshold,
2549 if (LocaleCompare("range-threshold",option+1) == 0)
2552 Range threshold image.
2554 (void) SyncImageSettings(mogrify_info,*image,exception);
2555 flags=ParseGeometry(argv[i+1],&geometry_info);
2556 if ((flags & SigmaValue) == 0)
2557 geometry_info.sigma=geometry_info.rho;
2558 if ((flags & XiValue) == 0)
2559 geometry_info.xi=geometry_info.sigma;
2560 if ((flags & PsiValue) == 0)
2561 geometry_info.psi=geometry_info.xi;
2562 if (strchr(argv[i+1],'%') != (char *) NULL)
2564 geometry_info.rho*=(double) (0.01*QuantumRange);
2565 geometry_info.sigma*=(double) (0.01*QuantumRange);
2566 geometry_info.xi*=(double) (0.01*QuantumRange);
2567 geometry_info.psi*=(double) (0.01*QuantumRange);
2569 (void) RangeThresholdImage(*image,geometry_info.rho,
2570 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2573 if (LocaleCompare("read-mask",option+1) == 0)
2578 (void) SyncImageSettings(mogrify_info,*image,exception);
2584 (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
2591 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2592 if (mask == (Image *) NULL)
2594 (void) SetImageMask(*image,ReadPixelMask,mask,exception);
2595 mask=DestroyImage(mask);
2598 if (LocaleCompare("region",option+1) == 0)
2601 Apply read mask as defined by a region geometry.
2603 (void) SyncImageSettings(mogrify_info,*image,exception);
2606 (void) SetImageRegionMask(*image,WritePixelMask,
2607 (const RectangleInfo *) NULL,exception);
2610 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2611 (void) SetImageRegionMask(*image,WritePixelMask,&geometry,
2615 if (LocaleCompare("render",option+1) == 0)
2617 (void) SyncImageSettings(mogrify_info,*image,exception);
2618 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2621 if (LocaleCompare("remap",option+1) == 0)
2627 Transform image colors to match this set of colors.
2629 (void) SyncImageSettings(mogrify_info,*image,exception);
2632 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2633 if (remap_image == (Image *) NULL)
2635 (void) RemapImage(quantize_info,*image,remap_image,exception);
2636 remap_image=DestroyImage(remap_image);
2639 if (LocaleCompare("repage",option+1) == 0)
2643 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2646 (void) ResetImagePage(*image,argv[i+1]);
2649 if (LocaleCompare("resample",option+1) == 0)
2654 (void) SyncImageSettings(mogrify_info,*image,exception);
2655 flags=ParseGeometry(argv[i+1],&geometry_info);
2656 if ((flags & SigmaValue) == 0)
2657 geometry_info.sigma=geometry_info.rho;
2658 mogrify_image=ResampleImage(*image,geometry_info.rho,
2659 geometry_info.sigma,(*image)->filter,exception);
2662 if (LocaleCompare("resize",option+1) == 0)
2667 (void) SyncImageSettings(mogrify_info,*image,exception);
2668 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2669 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2670 (*image)->filter,exception);
2673 if (LocaleCompare("roll",option+1) == 0)
2678 (void) SyncImageSettings(mogrify_info,*image,exception);
2679 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2680 if ((flags & PercentValue) != 0)
2682 geometry.x*=(double) (*image)->columns/100.0;
2683 geometry.y*=(double) (*image)->rows/100.0;
2685 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2688 if (LocaleCompare("rotate",option+1) == 0)
2694 Check for conditional image rotation.
2696 (void) SyncImageSettings(mogrify_info,*image,exception);
2697 if (strchr(argv[i+1],'>') != (char *) NULL)
2698 if ((*image)->columns <= (*image)->rows)
2700 if (strchr(argv[i+1],'<') != (char *) NULL)
2701 if ((*image)->columns >= (*image)->rows)
2706 rotation=ConstantString(argv[i+1]);
2707 (void) SubstituteString(&rotation,">","");
2708 (void) SubstituteString(&rotation,"<","");
2709 (void) ParseGeometry(rotation,&geometry_info);
2710 rotation=DestroyString(rotation);
2711 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2718 if (LocaleCompare("sample",option+1) == 0)
2721 Sample image with pixel replication.
2723 (void) SyncImageSettings(mogrify_info,*image,exception);
2724 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2725 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2729 if (LocaleCompare("scale",option+1) == 0)
2734 (void) SyncImageSettings(mogrify_info,*image,exception);
2735 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2736 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2740 if (LocaleCompare("selective-blur",option+1) == 0)
2743 Selectively blur pixels within a contrast threshold.
2745 (void) SyncImageSettings(mogrify_info,*image,exception);
2746 flags=ParseGeometry(argv[i+1],&geometry_info);
2747 if ((flags & PercentValue) != 0)
2748 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2749 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2750 geometry_info.sigma,geometry_info.xi,exception);
2753 if (LocaleCompare("separate",option+1) == 0)
2756 Break channels into separate images.
2758 (void) SyncImageSettings(mogrify_info,*image,exception);
2759 mogrify_image=SeparateImages(*image,exception);
2762 if (LocaleCompare("sepia-tone",option+1) == 0)
2770 (void) SyncImageSettings(mogrify_info,*image,exception);
2771 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2773 mogrify_image=SepiaToneImage(*image,threshold,exception);
2776 if (LocaleCompare("segment",option+1) == 0)
2781 (void) SyncImageSettings(mogrify_info,*image,exception);
2782 flags=ParseGeometry(argv[i+1],&geometry_info);
2783 if ((flags & SigmaValue) == 0)
2784 geometry_info.sigma=1.0;
2785 (void) SegmentImage(*image,(*image)->colorspace,
2786 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2790 if (LocaleCompare("set",option+1) == 0)
2800 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2801 (void) DeleteImageRegistry(argv[i+1]+9);
2803 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2805 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2806 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2809 (void) DeleteImageProperty(*image,argv[i+1]);
2812 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2814 if (value == (char *) NULL)
2816 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2817 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2820 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2822 (void) SetImageOption(image_info,argv[i+1]+7,value);
2823 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2824 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2827 (void) SetImageProperty(*image,argv[i+1],value,exception);
2828 value=DestroyString(value);
2831 if (LocaleCompare("shade",option+1) == 0)
2836 (void) SyncImageSettings(mogrify_info,*image,exception);
2837 flags=ParseGeometry(argv[i+1],&geometry_info);
2838 if ((flags & SigmaValue) == 0)
2839 geometry_info.sigma=1.0;
2840 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2841 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2844 if (LocaleCompare("shadow",option+1) == 0)
2849 (void) SyncImageSettings(mogrify_info,*image,exception);
2850 flags=ParseGeometry(argv[i+1],&geometry_info);
2851 if ((flags & SigmaValue) == 0)
2852 geometry_info.sigma=1.0;
2853 if ((flags & XiValue) == 0)
2854 geometry_info.xi=4.0;
2855 if ((flags & PsiValue) == 0)
2856 geometry_info.psi=4.0;
2857 mogrify_image=ShadowImage(*image,geometry_info.rho,
2858 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
2859 (ssize_t) ceil(geometry_info.psi-0.5),exception);
2862 if (LocaleCompare("sharpen",option+1) == 0)
2867 (void) SyncImageSettings(mogrify_info,*image,exception);
2868 flags=ParseGeometry(argv[i+1],&geometry_info);
2869 if ((flags & SigmaValue) == 0)
2870 geometry_info.sigma=1.0;
2871 if ((flags & XiValue) == 0)
2872 geometry_info.xi=0.0;
2873 mogrify_image=SharpenImage(*image,geometry_info.rho,
2874 geometry_info.sigma,exception);
2877 if (LocaleCompare("shave",option+1) == 0)
2880 Shave the image edges.
2882 (void) SyncImageSettings(mogrify_info,*image,exception);
2883 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2884 mogrify_image=ShaveImage(*image,&geometry,exception);
2887 if (LocaleCompare("shear",option+1) == 0)
2892 (void) SyncImageSettings(mogrify_info,*image,exception);
2893 flags=ParseGeometry(argv[i+1],&geometry_info);
2894 if ((flags & SigmaValue) == 0)
2895 geometry_info.sigma=geometry_info.rho;
2896 mogrify_image=ShearImage(*image,geometry_info.rho,
2897 geometry_info.sigma,exception);
2900 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2903 Sigmoidal non-linearity contrast control.
2905 (void) SyncImageSettings(mogrify_info,*image,exception);
2906 flags=ParseGeometry(argv[i+1],&geometry_info);
2907 if ((flags & SigmaValue) == 0)
2908 geometry_info.sigma=(double) QuantumRange/2.0;
2909 if ((flags & PercentValue) != 0)
2910 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2912 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2913 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2917 if (LocaleCompare("sketch",option+1) == 0)
2922 (void) SyncImageSettings(mogrify_info,*image,exception);
2923 flags=ParseGeometry(argv[i+1],&geometry_info);
2924 if ((flags & SigmaValue) == 0)
2925 geometry_info.sigma=1.0;
2926 mogrify_image=SketchImage(*image,geometry_info.rho,
2927 geometry_info.sigma,geometry_info.xi,exception);
2930 if (LocaleCompare("solarize",option+1) == 0)
2935 (void) SyncImageSettings(mogrify_info,*image,exception);
2936 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2938 (void) SolarizeImage(*image,threshold,exception);
2941 if (LocaleCompare("sparse-color",option+1) == 0)
2950 Sparse Color Interpolated Gradient
2952 (void) SyncImageSettings(mogrify_info,*image,exception);
2953 method=(SparseColorMethod) ParseCommandOption(
2954 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2955 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2957 if (arguments == (char *) NULL)
2959 mogrify_image=SparseColorOption(*image,method,arguments,
2960 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2961 arguments=DestroyString(arguments);
2964 if (LocaleCompare("splice",option+1) == 0)
2967 Splice a solid color into the image.
2969 (void) SyncImageSettings(mogrify_info,*image,exception);
2970 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2971 mogrify_image=SpliceImage(*image,&geometry,exception);
2974 if (LocaleCompare("spread",option+1) == 0)
2979 (void) SyncImageSettings(mogrify_info,*image,exception);
2980 (void) ParseGeometry(argv[i+1],&geometry_info);
2981 mogrify_image=SpreadImage(*image,interpolate_method,
2982 geometry_info.rho,exception);
2985 if (LocaleCompare("statistic",option+1) == 0)
2990 (void) SyncImageSettings(mogrify_info,*image,exception);
2991 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2992 MagickFalse,argv[i+1]);
2993 (void) ParseGeometry(argv[i+2],&geometry_info);
2994 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2995 (size_t) geometry_info.sigma,exception);
2998 if (LocaleCompare("stretch",option+1) == 0)
3002 draw_info->stretch=UndefinedStretch;
3005 draw_info->stretch=(StretchType) ParseCommandOption(
3006 MagickStretchOptions,MagickFalse,argv[i+1]);
3009 if (LocaleCompare("strip",option+1) == 0)
3012 Strip image of profiles and comments.
3014 (void) SyncImageSettings(mogrify_info,*image,exception);
3015 (void) StripImage(*image,exception);
3018 if (LocaleCompare("stroke",option+1) == 0)
3028 (void) QueryColorCompliance("none",AllCompliance,
3029 &draw_info->stroke,exception);
3030 if (draw_info->stroke_pattern != (Image *) NULL)
3031 draw_info->stroke_pattern=DestroyImage(
3032 draw_info->stroke_pattern);
3035 sans=AcquireExceptionInfo();
3036 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);
3037 sans=DestroyExceptionInfo(sans);
3038 if (status == MagickFalse)
3039 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
3042 draw_info->stroke=color;
3045 if (LocaleCompare("strokewidth",option+1) == 0)
3047 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
3050 if (LocaleCompare("style",option+1) == 0)
3054 draw_info->style=UndefinedStyle;
3057 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
3058 MagickFalse,argv[i+1]);
3061 if (LocaleCompare("swirl",option+1) == 0)
3066 (void) SyncImageSettings(mogrify_info,*image,exception);
3067 (void) ParseGeometry(argv[i+1],&geometry_info);
3068 mogrify_image=SwirlImage(*image,geometry_info.rho,
3069 interpolate_method,exception);
3076 if (LocaleCompare("threshold",option+1) == 0)
3084 (void) SyncImageSettings(mogrify_info,*image,exception);
3086 threshold=(double) QuantumRange/2;
3088 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
3090 (void) BilevelImage(*image,threshold,exception);
3093 if (LocaleCompare("thumbnail",option+1) == 0)
3098 (void) SyncImageSettings(mogrify_info,*image,exception);
3099 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
3100 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
3104 if (LocaleCompare("tile",option+1) == 0)
3108 if (draw_info->fill_pattern != (Image *) NULL)
3109 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3112 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3116 if (LocaleCompare("tint",option+1) == 0)
3121 (void) SyncImageSettings(mogrify_info,*image,exception);
3122 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3125 if (LocaleCompare("transform",option+1) == 0)
3128 Affine transform image.
3130 (void) SyncImageSettings(mogrify_info,*image,exception);
3131 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3135 if (LocaleCompare("transparent",option+1) == 0)
3140 (void) SyncImageSettings(mogrify_info,*image,exception);
3141 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3143 (void) TransparentPaintImage(*image,&target,(Quantum)
3144 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3148 if (LocaleCompare("transpose",option+1) == 0)
3151 Transpose image scanlines.
3153 (void) SyncImageSettings(mogrify_info,*image,exception);
3154 mogrify_image=TransposeImage(*image,exception);
3157 if (LocaleCompare("transverse",option+1) == 0)
3160 Transverse image scanlines.
3162 (void) SyncImageSettings(mogrify_info,*image,exception);
3163 mogrify_image=TransverseImage(*image,exception);
3166 if (LocaleCompare("treedepth",option+1) == 0)
3168 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3171 if (LocaleCompare("trim",option+1) == 0)
3176 (void) SyncImageSettings(mogrify_info,*image,exception);
3177 mogrify_image=TrimImage(*image,exception);
3180 if (LocaleCompare("type",option+1) == 0)
3185 (void) SyncImageSettings(mogrify_info,*image,exception);
3189 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3191 (*image)->type=UndefinedType;
3192 (void) SetImageType(*image,type,exception);
3199 if (LocaleCompare("undercolor",option+1) == 0)
3201 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3202 &draw_info->undercolor,exception);
3205 if (LocaleCompare("unique",option+1) == 0)
3209 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3212 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3213 (void) SetImageArtifact(*image,"verbose","true");
3216 if (LocaleCompare("unique-colors",option+1) == 0)
3219 Unique image colors.
3221 (void) SyncImageSettings(mogrify_info,*image,exception);
3222 mogrify_image=UniqueImageColors(*image,exception);
3225 if (LocaleCompare("unsharp",option+1) == 0)
3230 (void) SyncImageSettings(mogrify_info,*image,exception);
3231 flags=ParseGeometry(argv[i+1],&geometry_info);
3232 if ((flags & SigmaValue) == 0)
3233 geometry_info.sigma=1.0;
3234 if ((flags & XiValue) == 0)
3235 geometry_info.xi=1.0;
3236 if ((flags & PsiValue) == 0)
3237 geometry_info.psi=0.05;
3238 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3239 geometry_info.sigma,geometry_info.xi,geometry_info.psi,
3247 if (LocaleCompare("verbose",option+1) == 0)
3249 (void) SetImageArtifact(*image,option+1,
3250 *option == '+' ? "false" : "true");
3253 if (LocaleCompare("vignette",option+1) == 0)
3258 (void) SyncImageSettings(mogrify_info,*image,exception);
3259 flags=ParseGeometry(argv[i+1],&geometry_info);
3260 if ((flags & SigmaValue) == 0)
3261 geometry_info.sigma=1.0;
3262 if ((flags & XiValue) == 0)
3263 geometry_info.xi=0.1*(*image)->columns;
3264 if ((flags & PsiValue) == 0)
3265 geometry_info.psi=0.1*(*image)->rows;
3266 if ((flags & PercentValue) != 0)
3268 geometry_info.xi*=(double) (*image)->columns/100.0;
3269 geometry_info.psi*=(double) (*image)->rows/100.0;
3271 mogrify_image=VignetteImage(*image,geometry_info.rho,
3272 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
3273 (ssize_t) ceil(geometry_info.psi-0.5),exception);
3276 if (LocaleCompare("virtual-pixel",option+1) == 0)
3280 (void) SetImageVirtualPixelMethod(*image,
3281 UndefinedVirtualPixelMethod,exception);
3284 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3285 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3286 argv[i+1]),exception);
3293 if (LocaleCompare("wave",option+1) == 0)
3298 (void) SyncImageSettings(mogrify_info,*image,exception);
3299 flags=ParseGeometry(argv[i+1],&geometry_info);
3300 if ((flags & SigmaValue) == 0)
3301 geometry_info.sigma=1.0;
3302 mogrify_image=WaveImage(*image,geometry_info.rho,
3303 geometry_info.sigma,interpolate_method,exception);
3306 if (LocaleCompare("wavelet-denoise",option+1) == 0)
3309 Wavelet denoise image.
3311 (void) SyncImageSettings(mogrify_info,*image,exception);
3312 flags=ParseGeometry(argv[i+1],&geometry_info);
3313 if ((flags & PercentValue) != 0)
3315 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
3316 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
3318 if ((flags & SigmaValue) == 0)
3319 geometry_info.sigma=0.0;
3320 mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,
3321 geometry_info.sigma,exception);
3324 if (LocaleCompare("weight",option+1) == 0)
3329 weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
3332 weight=(ssize_t) StringToUnsignedLong(argv[i+1]);
3333 draw_info->weight=(size_t) weight;
3336 if (LocaleCompare("white-threshold",option+1) == 0)
3339 White threshold image.
3341 (void) SyncImageSettings(mogrify_info,*image,exception);
3342 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3345 if (LocaleCompare("write-mask",option+1) == 0)
3350 (void) SyncImageSettings(mogrify_info,*image,exception);
3356 (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
3363 mask=GetImageCache(mogrify_info,argv[i+1],exception);
3364 if (mask == (Image *) NULL)
3366 (void) SetImageMask(*image,WritePixelMask,mask,exception);
3367 mask=DestroyImage(mask);
3376 Replace current image with any image that was generated
3378 if (mogrify_image != (Image *) NULL)
3379 ReplaceImageInListReturnLast(image,mogrify_image);
3385 quantize_info=DestroyQuantizeInfo(quantize_info);
3386 draw_info=DestroyDrawInfo(draw_info);
3387 mogrify_info=DestroyImageInfo(mogrify_info);
3388 status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);
3389 return(status == 0 ? MagickFalse : MagickTrue);
3393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3397 + M o g r i f y I m a g e C o m m a n d %
3401 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3403 % MogrifyImageCommand() transforms an image or a sequence of images. These
3404 % transforms include image scaling, image rotation, color reduction, and
3405 % others. The transmogrified image overwrites the original image.
3407 % The format of the MogrifyImageCommand method is:
3409 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3410 % const char **argv,char **metadata,ExceptionInfo *exception)
3412 % A description of each parameter follows:
3414 % o image_info: the image info.
3416 % o argc: the number of elements in the argument vector.
3418 % o argv: A text array containing the command line arguments.
3420 % o metadata: any metadata is returned here.
3422 % o exception: return any errors or warnings in this structure.
3426 static MagickBooleanType MogrifyUsage(void)
3429 *channel_operators[]=
3431 "-channel-fx expression",
3432 " exchange, extract, or transfer one or more image channels",
3433 "-separate separate an image channel into a grayscale image",
3438 "-debug events display copious debugging information",
3439 "-distribute-cache port",
3440 " distributed pixel cache spanning one or more servers",
3441 "-help print program options",
3442 "-list type print a list of supported option arguments",
3443 "-log format format of debugging information",
3444 "-version print version information",
3449 "-adaptive-blur geometry",
3450 " adaptively blur pixels; decrease effect near edges",
3451 "-adaptive-resize geometry",
3452 " adaptively resize image using 'mesh' interpolation",
3453 "-adaptive-sharpen geometry",
3454 " adaptively sharpen pixels; increase effect near edges",
3455 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3456 " transparent, extract, background, or shape",
3457 "-annotate geometry text",
3458 " annotate the image with text",
3459 "-auto-gamma automagically adjust gamma level of image",
3460 "-auto-level automagically adjust color levels of image",
3461 "-auto-orient automagically orient (rotate) image",
3462 "-auto-threshold method",
3463 " automatically perform image thresholding",
3464 "-bench iterations measure performance",
3465 "-black-threshold value",
3466 " force all pixels below the threshold into black",
3467 "-blue-shift simulate a scene at nighttime in the moonlight",
3468 "-blur geometry reduce image noise and reduce detail levels",
3469 "-border geometry surround image with a border of color",
3470 "-bordercolor color border color",
3471 "-brightness-contrast geometry",
3472 " improve brightness / contrast of the image",
3473 "-canny geometry detect edges in the image",
3474 "-cdl filename color correct with a color decision list",
3475 "-channel mask set the image channel mask",
3476 "-charcoal geometry simulate a charcoal drawing",
3477 "-chop geometry remove pixels from the image interior",
3478 "-clamp keep pixel values in range (0-QuantumRange)",
3479 "-clip clip along the first path from the 8BIM profile",
3480 "-clip-mask filename associate a clip mask with the image",
3481 "-clip-path id clip along a named path from the 8BIM profile",
3482 "-colorize value colorize the image with the fill color",
3483 "-color-matrix matrix apply color correction to the image",
3484 "-connected-components connectivity",
3485 " connected-components uniquely labeled",
3486 "-contrast enhance or reduce the image contrast",
3487 "-contrast-stretch geometry",
3488 " improve contrast by 'stretching' the intensity range",
3489 "-convolve coefficients",
3490 " apply a convolution kernel to the image",
3491 "-cycle amount cycle the image colormap",
3492 "-decipher filename convert cipher pixels to plain pixels",
3493 "-deskew threshold straighten an image",
3494 "-despeckle reduce the speckles within an image",
3495 "-distort method args",
3496 " distort images according to given method ad args",
3497 "-draw string annotate the image with a graphic primitive",
3498 "-edge radius apply a filter to detect edges in the image",
3499 "-encipher filename convert plain pixels to cipher pixels",
3500 "-emboss radius emboss an image",
3501 "-enhance apply a digital filter to enhance a noisy image",
3502 "-equalize perform histogram equalization to an image",
3503 "-evaluate operator value",
3504 " evaluate an arithmetic, relational, or logical expression",
3505 "-extent geometry set the image size",
3506 "-extract geometry extract area from image",
3507 "-fft implements the discrete Fourier transform (DFT)",
3508 "-flip flip image vertically",
3509 "-floodfill geometry color",
3510 " floodfill the image with color",
3511 "-flop flop image horizontally",
3512 "-frame geometry surround image with an ornamental border",
3513 "-function name parameters",
3514 " apply function over image values",
3515 "-gamma value level of gamma correction",
3516 "-gaussian-blur geometry",
3517 " reduce image noise and reduce detail levels",
3518 "-geometry geometry preferred size or location of the image",
3519 "-grayscale method convert image to grayscale",
3520 "-hough-lines geometry",
3521 " identify lines in the image",
3522 "-identify identify the format and characteristics of the image",
3523 "-ift implements the inverse discrete Fourier transform (DFT)",
3524 "-implode amount implode image pixels about the center",
3525 "-interpolative-resize geometry",
3526 " resize image using interpolation",
3527 "-kuwahara geometry edge preserving noise reduction filter",
3528 "-lat geometry local adaptive thresholding",
3529 "-level value adjust the level of image contrast",
3530 "-level-colors color,color",
3531 " level image with the given colors",
3532 "-linear-stretch geometry",
3533 " improve contrast by 'stretching with saturation'",
3534 "-liquid-rescale geometry",
3535 " rescale image with seam-carving",
3536 "-local-contrast geometry",
3537 " enhance local contrast",
3538 "-magnify double the size of the image with pixel art scaling",
3539 "-mean-shift geometry delineate arbitrarily shaped clusters in the image",
3540 "-median geometry apply a median filter to the image",
3541 "-mode geometry make each pixel the 'predominant color' of the",
3543 "-modulate value vary the brightness, saturation, and hue",
3544 "-monochrome transform image to black and white",
3545 "-morphology method kernel",
3546 " apply a morphology method to the image",
3547 "-motion-blur geometry",
3548 " simulate motion blur",
3549 "-negate replace every pixel with its complementary color ",
3550 "-noise geometry add or reduce noise in an image",
3551 "-normalize transform image to span the full range of colors",
3552 "-opaque color change this color to the fill color",
3553 "-ordered-dither NxN",
3554 " add a noise pattern to the image with specific",
3556 "-paint radius simulate an oil painting",
3557 "-perceptible epsilon",
3558 " pixel value less than |epsilon| become epsilon or",
3560 "-polaroid angle simulate a Polaroid picture",
3561 "-posterize levels reduce the image to a limited number of color levels",
3562 "-profile filename add, delete, or apply an image profile",
3563 "-quantize colorspace reduce colors in this colorspace",
3564 "-raise value lighten/darken image edges to create a 3-D effect",
3565 "-random-threshold low,high",
3566 " random threshold the image",
3567 "-range-threshold values",
3568 " perform either hard or soft thresholding within some range of values in an image",
3569 "-region geometry apply options to a portion of the image",
3570 "-render render vector graphics",
3571 "-repage geometry size and location of an image canvas",
3572 "-resample geometry change the resolution of an image",
3573 "-resize geometry resize the image",
3574 "-roll geometry roll an image vertically or horizontally",
3575 "-rotate degrees apply Paeth rotation to the image",
3576 "-rotational-blur angle",
3577 " rotational blur the image",
3578 "-sample geometry scale image with pixel sampling",
3579 "-scale geometry scale the image",
3580 "-segment values segment an image",
3581 "-selective-blur geometry",
3582 " selectively blur pixels within a contrast threshold",
3583 "-sepia-tone threshold",
3584 " simulate a sepia-toned photo",
3585 "-set property value set an image property",
3586 "-shade degrees shade the image using a distant light source",
3587 "-shadow geometry simulate an image shadow",
3588 "-sharpen geometry sharpen the image",
3589 "-shave geometry shave pixels from the image edges",
3590 "-shear geometry slide one edge of the image along the X or Y axis",
3591 "-sigmoidal-contrast geometry",
3592 " increase the contrast without saturating highlights or",
3594 "-sketch geometry simulate a pencil sketch",
3595 "-solarize threshold negate all pixels above the threshold level",
3596 "-sparse-color method args",
3597 " fill in a image based on a few color points",
3598 "-splice geometry splice the background color into the image",
3599 "-spread radius displace image pixels by a random amount",
3600 "-statistic type radius",
3601 " replace each pixel with corresponding statistic from the neighborhood",
3602 "-strip strip image of all profiles and comments",
3603 "-swirl degrees swirl image pixels about the center",
3604 "-threshold value threshold the image",
3605 "-thumbnail geometry create a thumbnail of the image",
3606 "-tile filename tile image when filling a graphic primitive",
3607 "-tint value tint the image with the fill color",
3608 "-transform affine transform image",
3609 "-transparent color make this color transparent within the image",
3610 "-transpose flip image vertically and rotate 90 degrees",
3611 "-transverse flop image horizontally and rotate 270 degrees",
3612 "-trim trim image edges",
3613 "-type type image type",
3614 "-unique-colors discard all but one of any pixel color",
3615 "-unsharp geometry sharpen the image",
3616 "-vignette geometry soften the edges of the image in vignette style",
3617 "-wave geometry alter an image along a sine wave",
3618 "-wavelet-denoise threshold",
3619 " removes noise from the image using a wavelet transform",
3620 "-white-threshold value",
3621 " force all pixels above the threshold into white",
3624 *sequence_operators[]=
3626 "-affinity filename transform image colors to match this set of colors",
3627 "-append append an image sequence",
3628 "-clut apply a color lookup table to the image",
3629 "-coalesce merge a sequence of images",
3630 "-combine combine a sequence of images",
3631 "-compare mathematically and visually annotate the difference between an image and its reconstruction",
3632 "-complex operator perform complex mathematics on an image sequence",
3633 "-composite composite image",
3634 "-copy geometry offset",
3635 " copy pixels from one area of an image to another",
3636 "-crop geometry cut out a rectangular region of the image",
3637 "-deconstruct break down an image sequence into constituent parts",
3638 "-evaluate-sequence operator",
3639 " evaluate an arithmetic, relational, or logical expression",
3640 "-flatten flatten a sequence of images",
3641 "-fx expression apply mathematical expression to an image channel(s)",
3642 "-hald-clut apply a Hald color lookup table to the image",
3643 "-layers method optimize, merge, or compare image layers",
3644 "-morph value morph an image sequence",
3645 "-mosaic create a mosaic from an image sequence",
3646 "-poly terms build a polynomial from the image sequence and the corresponding",
3647 " terms (coefficients and degree pairs).",
3648 "-print string interpret string and print to console",
3649 "-process arguments process the image with a custom image filter",
3650 "-smush geometry smush an image sequence together",
3651 "-write filename write images to this file",
3656 "-adjoin join images into a single multi-image file",
3657 "-affine matrix affine transform matrix",
3658 "-alpha option activate, deactivate, reset, or set the alpha channel",
3659 "-antialias remove pixel-aliasing",
3660 "-authenticate password",
3661 " decipher image with this password",
3662 "-attenuate value lessen (or intensify) when adding noise to an image",
3663 "-background color background color",
3664 "-bias value add bias when convolving an image",
3665 "-black-point-compensation",
3666 " use black point compensation",
3667 "-blue-primary point chromaticity blue primary point",
3668 "-bordercolor color border color",
3669 "-caption string assign a caption to an image",
3670 "-colors value preferred number of colors in the image",
3671 "-colorspace type alternate image colorspace",
3672 "-comment string annotate image with comment",
3673 "-compose operator set image composite operator",
3674 "-compress type type of pixel compression when writing the image",
3675 "-define format:option=value",
3676 " define one or more image format options",
3677 "-delay value display the next image after pausing",
3678 "-density geometry horizontal and vertical density of the image",
3679 "-depth value image depth",
3680 "-direction type render text right-to-left or left-to-right",
3681 "-display server get image or font from this X server",
3682 "-dispose method layer disposal method",
3683 "-dither method apply error diffusion to image",
3684 "-encoding type text encoding type",
3685 "-endian type endianness (MSB or LSB) of the image",
3686 "-family name render text with this font family",
3687 "-features distance analyze image features (e.g. contrast, correlation)",
3688 "-fill color color to use when filling a graphic primitive",
3689 "-filter type use this filter when resizing an image",
3690 "-font name render text with this font",
3691 "-format \"string\" output formatted image characteristics",
3692 "-fuzz distance colors within this distance are considered equal",
3693 "-gravity type horizontal and vertical text placement",
3694 "-green-primary point chromaticity green primary point",
3695 "-intensity method method to generate an intensity value from a pixel",
3696 "-intent type type of rendering intent when managing the image color",
3697 "-interlace type type of image interlacing scheme",
3698 "-interline-spacing value",
3699 " set the space between two text lines",
3700 "-interpolate method pixel color interpolation method",
3701 "-interword-spacing value",
3702 " set the space between two words",
3703 "-kerning value set the space between two letters",
3704 "-label string assign a label to an image",
3705 "-limit type value pixel cache resource limit",
3706 "-loop iterations add Netscape loop extension to your GIF animation",
3707 "-matte store matte channel if the image has one",
3708 "-mattecolor color frame color",
3709 "-monitor monitor progress",
3710 "-orient type image orientation",
3711 "-page geometry size and location of an image canvas (setting)",
3712 "-path path write images to this path on disk",
3713 "-ping efficiently determine image attributes",
3714 "-pointsize value font point size",
3715 "-precision value maximum number of significant digits to print",
3716 "-preview type image preview type",
3717 "-quality value JPEG/MIFF/PNG compression level",
3718 "-quiet suppress all warning messages",
3719 "-read-mask filename associate a read mask with the image",
3720 "-red-primary point chromaticity red primary point",
3721 "-regard-warnings pay attention to warning messages",
3722 "-remap filename transform image colors to match this set of colors",
3723 "-respect-parentheses settings remain in effect until parenthesis boundary",
3724 "-sampling-factor geometry",
3725 " horizontal and vertical sampling factor",
3726 "-scene value image scene number",
3727 "-seed value seed a new sequence of pseudo-random numbers",
3728 "-size geometry width and height of image",
3729 "-stretch type render text with this font stretch",
3730 "-stroke color graphic primitive stroke color",
3731 "-strokewidth value graphic primitive stroke width",
3732 "-style type render text with this font style",
3733 "-synchronize synchronize image to storage device",
3734 "-taint declare the image as modified",
3735 "-texture filename name of texture to tile onto the image background",
3736 "-tile-offset geometry",
3738 "-treedepth value color tree depth",
3739 "-transparent-color color",
3740 " transparent color",
3741 "-undercolor color annotation bounding box color",
3742 "-units type the units of image resolution",
3743 "-verbose print detailed information about the image",
3744 "-view FlashPix viewing transforms",
3745 "-virtual-pixel method",
3746 " virtual pixel access method",
3747 "-weight type render text with this font weight",
3748 "-white-point point chromaticity white point",
3749 "-write-mask filename associate a write mask with the image",
3754 "-delete indexes delete the image from the image sequence",
3755 "-duplicate count,indexes",
3756 " duplicate an image one or more times",
3757 "-insert index insert last image into the image sequence",
3758 "-reverse reverse image sequence",
3759 "-swap indexes swap two images in the image sequence",
3766 ListMagickVersion(stdout);
3767 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3769 (void) printf("\nImage Settings:\n");
3770 for (p=settings; *p != (char *) NULL; p++)
3771 (void) printf(" %s\n",*p);
3772 (void) printf("\nImage Operators:\n");
3773 for (p=operators; *p != (char *) NULL; p++)
3774 (void) printf(" %s\n",*p);
3775 (void) printf("\nImage Channel Operators:\n");
3776 for (p=channel_operators; *p != (char *) NULL; p++)
3777 (void) printf(" %s\n",*p);
3778 (void) printf("\nImage Sequence Operators:\n");
3779 for (p=sequence_operators; *p != (char *) NULL; p++)
3780 (void) printf(" %s\n",*p);
3781 (void) printf("\nImage Stack Operators:\n");
3782 for (p=stack_operators; *p != (char *) NULL; p++)
3783 (void) printf(" %s\n",*p);
3784 (void) printf("\nMiscellaneous Options:\n");
3785 for (p=miscellaneous; *p != (char *) NULL; p++)
3786 (void) printf(" %s\n",*p);
3788 "\nBy default, the image format of 'file' is determined by its magic\n");
3790 "number. To specify a particular image format, precede the filename\n");
3792 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3794 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3795 (void) printf("'-' for standard input or output.\n");
3796 return(MagickFalse);
3799 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3800 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3802 #define DestroyMogrify() \
3804 if (format != (char *) NULL) \
3805 format=DestroyString(format); \
3806 if (path != (char *) NULL) \
3807 path=DestroyString(path); \
3808 DestroyImageStack(); \
3809 for (i=0; i < (ssize_t) argc; i++) \
3810 argv[i]=DestroyString(argv[i]); \
3811 argv=(char **) RelinquishMagickMemory(argv); \
3813 #define ThrowMogrifyException(asperity,tag,option) \
3815 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3818 return(MagickFalse); \
3820 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3822 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3823 "InvalidArgument","'%s': %s",argument,option); \
3825 return(MagickFalse); \
3837 image_stack[MaxImageStackDepth+1];
3845 respect_parenthesis;
3857 wand_unreferenced(metadata);
3862 assert(image_info != (ImageInfo *) NULL);
3863 assert(image_info->signature == MagickCoreSignature);
3864 if (image_info->debug != MagickFalse)
3865 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3866 assert(exception != (ExceptionInfo *) NULL);
3870 if ((LocaleCompare("version",option+1) == 0) ||
3871 (LocaleCompare("-version",option+1) == 0))
3873 ListMagickVersion(stdout);
3878 return(MogrifyUsage());
3879 format=(char *) NULL;
3881 global_colormap=MagickFalse;
3885 option=(char *) NULL;
3887 respect_parenthesis=MagickFalse;
3892 ReadCommandlLine(argc,&argv);
3893 status=ExpandFilenames(&argc,&argv);
3894 if (status == MagickFalse)
3895 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3896 GetExceptionMessage(errno));
3897 for (i=1; i < (ssize_t) argc; i++)
3900 if (LocaleCompare(option,"(") == 0)
3902 FireImageStack(MagickFalse,MagickTrue,pend);
3903 if (k == MaxImageStackDepth)
3904 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3909 if (LocaleCompare(option,")") == 0)
3911 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3913 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3917 if (IsCommandOption(option) == MagickFalse)
3920 backup_filename[MagickPathExtent],
3930 Option is a file name: begin by reading image from specified file.
3932 FireImageStack(MagickFalse,MagickFalse,pend);
3934 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3936 images=ReadImages(image_info,filename,exception);
3937 status&=(images != (Image *) NULL) &&
3938 (exception->severity < ErrorException);
3939 if (images == (Image *) NULL)
3941 properties=(*GetBlobProperties(images));
3942 if (format != (char *) NULL)
3943 (void) CopyMagickString(images->filename,images->magick_filename,
3945 if (path != (char *) NULL)
3947 GetPathComponent(option,TailPath,filename);
3948 (void) FormatLocaleString(images->filename,MagickPathExtent,
3949 "%s%c%s",path,*DirectorySeparator,filename);
3951 if (format != (char *) NULL)
3952 AppendImageFormat(format,images->filename);
3953 AppendImageStack(images);
3954 FinalizeImageSettings(image_info,image,MagickFalse);
3955 if (global_colormap != MagickFalse)
3960 quantize_info=AcquireQuantizeInfo(image_info);
3961 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3962 quantize_info=DestroyQuantizeInfo(quantize_info);
3964 *backup_filename='\0';
3965 if ((LocaleCompare(image->filename,"-") != 0) &&
3966 (IsPathWritable(image->filename) != MagickFalse))
3969 Rename image file as backup.
3971 (void) CopyMagickString(backup_filename,image->filename,
3973 for (j=0; j < 6; j++)
3975 (void) ConcatenateMagickString(backup_filename,"~",
3977 if (IsPathAccessible(backup_filename) == MagickFalse)
3980 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3981 (rename_utf8(image->filename,backup_filename) != 0))
3982 *backup_filename='\0';
3985 Write transmogrified image to disk.
3987 image_info->synchronize=MagickTrue;
3988 status&=WriteImages(image_info,image,image->filename,exception);
3989 if (status != MagickFalse)
3991 #if defined(MAGICKCORE_HAVE_UTIME)
3996 preserve_timestamp=IsStringTrue(GetImageOption(image_info,
3997 "preserve-timestamp"));
3998 if (preserve_timestamp != MagickFalse)
4003 timestamp.actime=properties.st_atime;
4004 timestamp.modtime=properties.st_mtime;
4005 (void) utime(image->filename,×tamp);
4009 if (*backup_filename != '\0')
4010 (void) remove_utf8(backup_filename);
4012 RemoveAllImageStack();
4015 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
4016 switch (*(option+1))
4020 if (LocaleCompare("adaptive-blur",option+1) == 0)
4023 if (i == (ssize_t) argc)
4024 ThrowMogrifyException(OptionError,"MissingArgument",option);
4025 if (IsGeometry(argv[i]) == MagickFalse)
4026 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4029 if (LocaleCompare("adaptive-resize",option+1) == 0)
4032 if (i == (ssize_t) argc)
4033 ThrowMogrifyException(OptionError,"MissingArgument",option);
4034 if (IsGeometry(argv[i]) == MagickFalse)
4035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4038 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
4041 if (i == (ssize_t) argc)
4042 ThrowMogrifyException(OptionError,"MissingArgument",option);
4043 if (IsGeometry(argv[i]) == MagickFalse)
4044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4047 if (LocaleCompare("affine",option+1) == 0)
4052 if (i == (ssize_t) argc)
4053 ThrowMogrifyException(OptionError,"MissingArgument",option);
4056 if (LocaleCompare("alpha",option+1) == 0)
4064 if (i == (ssize_t) argc)
4065 ThrowMogrifyException(OptionError,"MissingArgument",option);
4066 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
4069 ThrowMogrifyException(OptionError,
4070 "UnrecognizedAlphaChannelOption",argv[i]);
4073 if (LocaleCompare("annotate",option+1) == 0)
4078 if (i == (ssize_t) argc)
4079 ThrowMogrifyException(OptionError,"MissingArgument",option);
4080 if (IsGeometry(argv[i]) == MagickFalse)
4081 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4082 if (i == (ssize_t) argc)
4083 ThrowMogrifyException(OptionError,"MissingArgument",option);
4087 if (LocaleCompare("antialias",option+1) == 0)
4089 if (LocaleCompare("append",option+1) == 0)
4091 if (LocaleCompare("attenuate",option+1) == 0)
4096 if (i == (ssize_t) argc)
4097 ThrowMogrifyException(OptionError,"MissingArgument",option);
4098 if (IsGeometry(argv[i]) == MagickFalse)
4099 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4102 if (LocaleCompare("authenticate",option+1) == 0)
4107 if (i == (ssize_t) argc)
4108 ThrowMogrifyException(OptionError,"MissingArgument",option);
4111 if (LocaleCompare("auto-gamma",option+1) == 0)
4113 if (LocaleCompare("auto-level",option+1) == 0)
4115 if (LocaleCompare("auto-orient",option+1) == 0)
4117 if (LocaleCompare("auto-threshold",option+1) == 0)
4125 if (i == (ssize_t) argc)
4126 ThrowMogrifyException(OptionError,"MissingArgument",option);
4127 method=ParseCommandOption(MagickAutoThresholdOptions,MagickFalse,
4130 ThrowMogrifyException(OptionError,"UnrecognizedThresholdMethod",
4134 if (LocaleCompare("average",option+1) == 0)
4136 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4140 if (LocaleCompare("background",option+1) == 0)
4145 if (i == (ssize_t) argc)
4146 ThrowMogrifyException(OptionError,"MissingArgument",option);
4149 if (LocaleCompare("bias",option+1) == 0)
4154 if (i == (ssize_t) argc)
4155 ThrowMogrifyException(OptionError,"MissingArgument",option);
4156 if (IsGeometry(argv[i]) == MagickFalse)
4157 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4160 if (LocaleCompare("black-point-compensation",option+1) == 0)
4162 if (LocaleCompare("black-threshold",option+1) == 0)
4167 if (i == (ssize_t) argc)
4168 ThrowMogrifyException(OptionError,"MissingArgument",option);
4169 if (IsGeometry(argv[i]) == MagickFalse)
4170 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4173 if (LocaleCompare("blue-primary",option+1) == 0)
4178 if (i == (ssize_t) argc)
4179 ThrowMogrifyException(OptionError,"MissingArgument",option);
4180 if (IsGeometry(argv[i]) == MagickFalse)
4181 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4184 if (LocaleCompare("blue-shift",option+1) == 0)
4187 if (i == (ssize_t) argc)
4188 ThrowMogrifyException(OptionError,"MissingArgument",option);
4189 if (IsGeometry(argv[i]) == MagickFalse)
4190 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4193 if (LocaleCompare("blur",option+1) == 0)
4196 if (i == (ssize_t) argc)
4197 ThrowMogrifyException(OptionError,"MissingArgument",option);
4198 if (IsGeometry(argv[i]) == MagickFalse)
4199 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4202 if (LocaleCompare("border",option+1) == 0)
4207 if (i == (ssize_t) argc)
4208 ThrowMogrifyException(OptionError,"MissingArgument",option);
4209 if (IsGeometry(argv[i]) == MagickFalse)
4210 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4213 if (LocaleCompare("bordercolor",option+1) == 0)
4218 if (i == (ssize_t) argc)
4219 ThrowMogrifyException(OptionError,"MissingArgument",option);
4222 if (LocaleCompare("box",option+1) == 0)
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,"MissingArgument",option);
4231 if (LocaleCompare("brightness-contrast",option+1) == 0)
4234 if (i == (ssize_t) argc)
4235 ThrowMogrifyException(OptionError,"MissingArgument",option);
4236 if (IsGeometry(argv[i]) == MagickFalse)
4237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4240 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4244 if (LocaleCompare("cache",option+1) == 0)
4249 if (i == (ssize_t) argc)
4250 ThrowMogrifyException(OptionError,"MissingArgument",option);
4251 if (IsGeometry(argv[i]) == MagickFalse)
4252 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4255 if (LocaleCompare("canny",option+1) == 0)
4260 if (i == (ssize_t) argc)
4261 ThrowMogrifyException(OptionError,"MissingArgument",option);
4262 if (IsGeometry(argv[i]) == MagickFalse)
4263 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4266 if (LocaleCompare("caption",option+1) == 0)
4271 if (i == (ssize_t) argc)
4272 ThrowMogrifyException(OptionError,"MissingArgument",option);
4275 if (LocaleCompare("channel",option+1) == 0)
4283 if (i == (ssize_t) argc)
4284 ThrowMogrifyException(OptionError,"MissingArgument",option);
4285 channel=ParseChannelOption(argv[i]);
4287 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4291 if (LocaleCompare("channel-fx",option+1) == 0)
4299 if (i == (ssize_t) argc)
4300 ThrowMogrifyException(OptionError,"MissingArgument",option);
4301 channel=ParsePixelChannelOption(argv[i]);
4303 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4307 if (LocaleCompare("cdl",option+1) == 0)
4312 if (i == (ssize_t) argc)
4313 ThrowMogrifyException(OptionError,"MissingArgument",option);
4316 if (LocaleCompare("charcoal",option+1) == 0)
4321 if (i == (ssize_t) argc)
4322 ThrowMogrifyException(OptionError,"MissingArgument",option);
4323 if (IsGeometry(argv[i]) == MagickFalse)
4324 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4327 if (LocaleCompare("chop",option+1) == 0)
4332 if (i == (ssize_t) argc)
4333 ThrowMogrifyException(OptionError,"MissingArgument",option);
4334 if (IsGeometry(argv[i]) == MagickFalse)
4335 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4338 if (LocaleCompare("clamp",option+1) == 0)
4340 if (LocaleCompare("clip",option+1) == 0)
4342 if (LocaleCompare("clip-mask",option+1) == 0)
4347 if (i == (ssize_t) argc)
4348 ThrowMogrifyException(OptionError,"MissingArgument",option);
4351 if (LocaleCompare("clut",option+1) == 0)
4353 if (LocaleCompare("coalesce",option+1) == 0)
4355 if (LocaleCompare("colorize",option+1) == 0)
4360 if (i == (ssize_t) argc)
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4362 if (IsGeometry(argv[i]) == MagickFalse)
4363 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4366 if (LocaleCompare("color-matrix",option+1) == 0)
4374 if (i == (ssize_t) argc)
4375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4376 kernel_info=AcquireKernelInfo(argv[i],exception);
4377 if (kernel_info == (KernelInfo *) NULL)
4378 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4379 kernel_info=DestroyKernelInfo(kernel_info);
4382 if (LocaleCompare("colors",option+1) == 0)
4387 if (i == (ssize_t) argc)
4388 ThrowMogrifyException(OptionError,"MissingArgument",option);
4389 if (IsGeometry(argv[i]) == MagickFalse)
4390 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4393 if (LocaleCompare("colorspace",option+1) == 0)
4401 if (i == (ssize_t) argc)
4402 ThrowMogrifyException(OptionError,"MissingArgument",option);
4403 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4406 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4410 if (LocaleCompare("combine",option+1) == 0)
4418 if (i == (ssize_t) argc)
4419 ThrowMogrifyException(OptionError,"MissingArgument",option);
4420 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4423 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4427 if (LocaleCompare("compare",option+1) == 0)
4429 if (LocaleCompare("comment",option+1) == 0)
4434 if (i == (ssize_t) argc)
4435 ThrowMogrifyException(OptionError,"MissingArgument",option);
4438 if (LocaleCompare("composite",option+1) == 0)
4440 if (LocaleCompare("compress",option+1) == 0)
4448 if (i == (ssize_t) argc)
4449 ThrowMogrifyException(OptionError,"MissingArgument",option);
4450 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4453 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4457 if (LocaleCompare("concurrent",option+1) == 0)
4459 if (LocaleCompare("connected-components",option+1) == 0)
4462 if (i == (ssize_t) argc)
4463 ThrowMogrifyException(OptionError,"MissingArgument",option);
4464 if (IsGeometry(argv[i]) == MagickFalse)
4465 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4468 if (LocaleCompare("contrast",option+1) == 0)
4470 if (LocaleCompare("contrast-stretch",option+1) == 0)
4473 if (i == (ssize_t) argc)
4474 ThrowMogrifyException(OptionError,"MissingArgument",option);
4475 if (IsGeometry(argv[i]) == MagickFalse)
4476 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4479 if (LocaleCompare("convolve",option+1) == 0)
4487 if (i == (ssize_t) argc)
4488 ThrowMogrifyException(OptionError,"MissingArgument",option);
4489 kernel_info=AcquireKernelInfo(argv[i],exception);
4490 if (kernel_info == (KernelInfo *) NULL)
4491 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4492 kernel_info=DestroyKernelInfo(kernel_info);
4495 if (LocaleCompare("copy",option+1) == 0)
4500 if (i == (ssize_t) argc)
4501 ThrowMogrifyException(OptionError,"MissingArgument",option);
4502 if (IsGeometry(argv[i]) == MagickFalse)
4503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4505 if (i == (ssize_t) argc)
4506 ThrowMogrifyException(OptionError,"MissingArgument",option);
4507 if (IsGeometry(argv[i]) == MagickFalse)
4508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4511 if (LocaleCompare("crop",option+1) == 0)
4516 if (i == (ssize_t) argc)
4517 ThrowMogrifyException(OptionError,"MissingArgument",option);
4518 if (IsGeometry(argv[i]) == MagickFalse)
4519 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4522 if (LocaleCompare("cycle",option+1) == 0)
4527 if (i == (ssize_t) argc)
4528 ThrowMogrifyException(OptionError,"MissingArgument",option);
4529 if (IsGeometry(argv[i]) == MagickFalse)
4530 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4533 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4537 if (LocaleCompare("decipher",option+1) == 0)
4542 if (i == (ssize_t) argc)
4543 ThrowMogrifyException(OptionError,"MissingArgument",option);
4546 if (LocaleCompare("deconstruct",option+1) == 0)
4548 if (LocaleCompare("debug",option+1) == 0)
4556 if (i == (ssize_t) argc)
4557 ThrowMogrifyException(OptionError,"MissingArgument",option);
4558 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4560 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4562 (void) SetLogEventMask(argv[i]);
4565 if (LocaleCompare("define",option+1) == 0)
4568 if (i == (ssize_t) argc)
4569 ThrowMogrifyException(OptionError,"MissingArgument",option);
4575 define=GetImageOption(image_info,argv[i]);
4576 if (define == (const char *) NULL)
4577 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4582 if (LocaleCompare("delay",option+1) == 0)
4587 if (i == (ssize_t) argc)
4588 ThrowMogrifyException(OptionError,"MissingArgument",option);
4589 if (IsGeometry(argv[i]) == MagickFalse)
4590 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4593 if (LocaleCompare("delete",option+1) == 0)
4598 if (i == (ssize_t) argc)
4599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 if (IsGeometry(argv[i]) == MagickFalse)
4601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4604 if (LocaleCompare("density",option+1) == 0)
4609 if (i == (ssize_t) argc)
4610 ThrowMogrifyException(OptionError,"MissingArgument",option);
4611 if (IsGeometry(argv[i]) == MagickFalse)
4612 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4615 if (LocaleCompare("depth",option+1) == 0)
4620 if (i == (ssize_t) argc)
4621 ThrowMogrifyException(OptionError,"MissingArgument",option);
4622 if (IsGeometry(argv[i]) == MagickFalse)
4623 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4626 if (LocaleCompare("deskew",option+1) == 0)
4631 if (i == (ssize_t) argc)
4632 ThrowMogrifyException(OptionError,"MissingArgument",option);
4633 if (IsGeometry(argv[i]) == MagickFalse)
4634 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4637 if (LocaleCompare("despeckle",option+1) == 0)
4639 if (LocaleCompare("dft",option+1) == 0)
4641 if (LocaleCompare("direction",option+1) == 0)
4649 if (i == (ssize_t) argc)
4650 ThrowMogrifyException(OptionError,"MissingArgument",option);
4651 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4654 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4658 if (LocaleCompare("display",option+1) == 0)
4663 if (i == (ssize_t) argc)
4664 ThrowMogrifyException(OptionError,"MissingArgument",option);
4667 if (LocaleCompare("dispose",option+1) == 0)
4675 if (i == (ssize_t) argc)
4676 ThrowMogrifyException(OptionError,"MissingArgument",option);
4677 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,
4680 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4684 if (LocaleCompare("distort",option+1) == 0)
4690 if (i == (ssize_t) argc)
4691 ThrowMogrifyException(OptionError,"MissingArgument",option);
4692 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4694 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4697 if (i == (ssize_t) argc)
4698 ThrowMogrifyException(OptionError,"MissingArgument",option);
4701 if (LocaleCompare("dither",option+1) == 0)
4709 if (i == (ssize_t) argc)
4710 ThrowMogrifyException(OptionError,"MissingArgument",option);
4711 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4713 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4717 if (LocaleCompare("draw",option+1) == 0)
4722 if (i == (ssize_t) argc)
4723 ThrowMogrifyException(OptionError,"MissingArgument",option);
4726 if (LocaleCompare("duplicate",option+1) == 0)
4731 if (i == (ssize_t) argc)
4732 ThrowMogrifyException(OptionError,"MissingArgument",option);
4733 if (IsGeometry(argv[i]) == MagickFalse)
4734 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4737 if (LocaleCompare("duration",option+1) == 0)
4742 if (i == (ssize_t) argc)
4743 ThrowMogrifyException(OptionError,"MissingArgument",option);
4744 if (IsGeometry(argv[i]) == MagickFalse)
4745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4748 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4752 if (LocaleCompare("edge",option+1) == 0)
4757 if (i == (ssize_t) argc)
4758 ThrowMogrifyException(OptionError,"MissingArgument",option);
4759 if (IsGeometry(argv[i]) == MagickFalse)
4760 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4763 if (LocaleCompare("emboss",option+1) == 0)
4768 if (i == (ssize_t) argc)
4769 ThrowMogrifyException(OptionError,"MissingArgument",option);
4770 if (IsGeometry(argv[i]) == MagickFalse)
4771 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4774 if (LocaleCompare("encipher",option+1) == 0)
4779 if (i == (ssize_t) argc)
4780 ThrowMogrifyException(OptionError,"MissingArgument",option);
4783 if (LocaleCompare("encoding",option+1) == 0)
4788 if (i == (ssize_t) argc)
4789 ThrowMogrifyException(OptionError,"MissingArgument",option);
4792 if (LocaleCompare("endian",option+1) == 0)
4800 if (i == (ssize_t) argc)
4801 ThrowMogrifyException(OptionError,"MissingArgument",option);
4802 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4804 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4808 if (LocaleCompare("enhance",option+1) == 0)
4810 if (LocaleCompare("equalize",option+1) == 0)
4812 if (LocaleCompare("evaluate",option+1) == 0)
4820 if (i == (ssize_t) argc)
4821 ThrowMogrifyException(OptionError,"MissingArgument",option);
4822 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4824 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4827 if (i == (ssize_t) argc)
4828 ThrowMogrifyException(OptionError,"MissingArgument",option);
4829 if (IsGeometry(argv[i]) == MagickFalse)
4830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4833 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4841 if (i == (ssize_t) argc)
4842 ThrowMogrifyException(OptionError,"MissingArgument",option);
4843 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4845 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4849 if (LocaleCompare("extent",option+1) == 0)
4854 if (i == (ssize_t) argc)
4855 ThrowMogrifyException(OptionError,"MissingArgument",option);
4856 if (IsGeometry(argv[i]) == MagickFalse)
4857 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4860 if (LocaleCompare("extract",option+1) == 0)
4865 if (i == (ssize_t) argc)
4866 ThrowMogrifyException(OptionError,"MissingArgument",option);
4867 if (IsGeometry(argv[i]) == MagickFalse)
4868 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4871 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4875 if (LocaleCompare("family",option+1) == 0)
4880 if (i == (ssize_t) argc)
4881 ThrowMogrifyException(OptionError,"MissingArgument",option);
4884 if (LocaleCompare("features",option+1) == 0)
4889 if (i == (ssize_t) argc)
4890 ThrowMogrifyException(OptionError,"MissingArgument",option);
4891 if (IsGeometry(argv[i]) == MagickFalse)
4892 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4895 if (LocaleCompare("fill",option+1) == 0)
4900 if (i == (ssize_t) argc)
4901 ThrowMogrifyException(OptionError,"MissingArgument",option);
4904 if (LocaleCompare("filter",option+1) == 0)
4912 if (i == (ssize_t) argc)
4913 ThrowMogrifyException(OptionError,"MissingArgument",option);
4914 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4916 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4920 if (LocaleCompare("flatten",option+1) == 0)
4922 if (LocaleCompare("flip",option+1) == 0)
4924 if (LocaleCompare("flop",option+1) == 0)
4926 if (LocaleCompare("floodfill",option+1) == 0)
4931 if (i == (ssize_t) argc)
4932 ThrowMogrifyException(OptionError,"MissingArgument",option);
4933 if (IsGeometry(argv[i]) == MagickFalse)
4934 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4936 if (i == (ssize_t) argc)
4937 ThrowMogrifyException(OptionError,"MissingArgument",option);
4940 if (LocaleCompare("font",option+1) == 0)
4945 if (i == (ssize_t) argc)
4946 ThrowMogrifyException(OptionError,"MissingArgument",option);
4949 if (LocaleCompare("format",option+1) == 0)
4951 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
4952 (void) CloneString(&format,(char *) NULL);
4956 if (i == (ssize_t) argc)
4957 ThrowMogrifyException(OptionError,"MissingArgument",option);
4958 (void) CloneString(&format,argv[i]);
4959 (void) CopyMagickString(image_info->filename,format,
4961 (void) ConcatenateMagickString(image_info->filename,":",
4963 (void) SetImageInfo(image_info,0,exception);
4964 if (*image_info->magick == '\0')
4965 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4969 if (LocaleCompare("frame",option+1) == 0)
4974 if (i == (ssize_t) argc)
4975 ThrowMogrifyException(OptionError,"MissingArgument",option);
4976 if (IsGeometry(argv[i]) == MagickFalse)
4977 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4980 if (LocaleCompare("function",option+1) == 0)
4988 if (i == (ssize_t) argc)
4989 ThrowMogrifyException(OptionError,"MissingArgument",option);
4990 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4992 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4994 if (i == (ssize_t) argc)
4995 ThrowMogrifyException(OptionError,"MissingArgument",option);
4998 if (LocaleCompare("fuzz",option+1) == 0)
5003 if (i == (ssize_t) argc)
5004 ThrowMogrifyException(OptionError,"MissingArgument",option);
5005 if (IsGeometry(argv[i]) == MagickFalse)
5006 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5009 if (LocaleCompare("fx",option+1) == 0)
5014 if (i == (ssize_t) argc)
5015 ThrowMogrifyException(OptionError,"MissingArgument",option);
5018 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5022 if (LocaleCompare("gamma",option+1) == 0)
5025 if (i == (ssize_t) argc)
5026 ThrowMogrifyException(OptionError,"MissingArgument",option);
5027 if (IsGeometry(argv[i]) == MagickFalse)
5028 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5031 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
5032 (LocaleCompare("gaussian",option+1) == 0))
5035 if (i == (ssize_t) argc)
5036 ThrowMogrifyException(OptionError,"MissingArgument",option);
5037 if (IsGeometry(argv[i]) == MagickFalse)
5038 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5041 if (LocaleCompare("geometry",option+1) == 0)
5046 if (i == (ssize_t) argc)
5047 ThrowMogrifyException(OptionError,"MissingArgument",option);
5048 if (IsGeometry(argv[i]) == MagickFalse)
5049 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5052 if (LocaleCompare("gravity",option+1) == 0)
5060 if (i == (ssize_t) argc)
5061 ThrowMogrifyException(OptionError,"MissingArgument",option);
5062 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
5065 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
5069 if (LocaleCompare("grayscale",option+1) == 0)
5077 if (i == (ssize_t) argc)
5078 ThrowMogrifyException(OptionError,"MissingArgument",option);
5079 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
5082 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod",
5086 if (LocaleCompare("green-primary",option+1) == 0)
5091 if (i == (ssize_t) argc)
5092 ThrowMogrifyException(OptionError,"MissingArgument",option);
5093 if (IsGeometry(argv[i]) == MagickFalse)
5094 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5097 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5101 if (LocaleCompare("hald-clut",option+1) == 0)
5103 if ((LocaleCompare("help",option+1) == 0) ||
5104 (LocaleCompare("-help",option+1) == 0))
5105 return(MogrifyUsage());
5106 if (LocaleCompare("hough-lines",option+1) == 0)
5111 if (i == (ssize_t) argc)
5112 ThrowMogrifyException(OptionError,"MissingArgument",option);
5113 if (IsGeometry(argv[i]) == MagickFalse)
5114 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5117 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5121 if (LocaleCompare("identify",option+1) == 0)
5123 if (LocaleCompare("idft",option+1) == 0)
5125 if (LocaleCompare("implode",option+1) == 0)
5130 if (i == (ssize_t) argc)
5131 ThrowMogrifyException(OptionError,"MissingArgument",option);
5132 if (IsGeometry(argv[i]) == MagickFalse)
5133 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5136 if (LocaleCompare("intensity",option+1) == 0)
5144 if (i == (ssize_t) argc)
5145 ThrowMogrifyException(OptionError,"MissingArgument",option);
5146 intensity=ParseCommandOption(MagickPixelIntensityOptions,
5147 MagickFalse,argv[i]);
5149 ThrowMogrifyException(OptionError,
5150 "UnrecognizedPixelIntensityMethod",argv[i]);
5153 if (LocaleCompare("intent",option+1) == 0)
5161 if (i == (ssize_t) argc)
5162 ThrowMogrifyException(OptionError,"MissingArgument",option);
5163 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
5165 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
5169 if (LocaleCompare("interlace",option+1) == 0)
5177 if (i == (ssize_t) argc)
5178 ThrowMogrifyException(OptionError,"MissingArgument",option);
5179 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
5182 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
5186 if (LocaleCompare("interline-spacing",option+1) == 0)
5191 if (i == (ssize_t) argc)
5192 ThrowMogrifyException(OptionError,"MissingArgument",option);
5193 if (IsGeometry(argv[i]) == MagickFalse)
5194 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5197 if (LocaleCompare("interpolate",option+1) == 0)
5205 if (i == (ssize_t) argc)
5206 ThrowMogrifyException(OptionError,"MissingArgument",option);
5207 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5209 if (interpolate < 0)
5210 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
5214 if (LocaleCompare("interword-spacing",option+1) == 0)
5219 if (i == (ssize_t) argc)
5220 ThrowMogrifyException(OptionError,"MissingArgument",option);
5221 if (IsGeometry(argv[i]) == MagickFalse)
5222 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5225 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5229 if (LocaleCompare("kerning",option+1) == 0)
5234 if (i == (ssize_t) argc)
5235 ThrowMogrifyException(OptionError,"MissingArgument",option);
5236 if (IsGeometry(argv[i]) == MagickFalse)
5237 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5240 if (LocaleCompare("kuwahara",option+1) == 0)
5243 if (i == (ssize_t) argc)
5244 ThrowMogrifyException(OptionError,"MissingArgument",option);
5245 if (IsGeometry(argv[i]) == MagickFalse)
5246 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5249 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5253 if (LocaleCompare("label",option+1) == 0)
5258 if (i == (ssize_t) argc)
5259 ThrowMogrifyException(OptionError,"MissingArgument",option);
5262 if (LocaleCompare("lat",option+1) == 0)
5267 if (i == (ssize_t) argc)
5268 ThrowMogrifyException(OptionError,"MissingArgument",option);
5269 if (IsGeometry(argv[i]) == MagickFalse)
5270 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5272 if (LocaleCompare("layers",option+1) == 0)
5280 if (i == (ssize_t) argc)
5281 ThrowMogrifyException(OptionError,"MissingArgument",option);
5282 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
5284 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
5288 if (LocaleCompare("level",option+1) == 0)
5291 if (i == (ssize_t) argc)
5292 ThrowMogrifyException(OptionError,"MissingArgument",option);
5293 if (IsGeometry(argv[i]) == MagickFalse)
5294 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5297 if (LocaleCompare("level-colors",option+1) == 0)
5300 if (i == (ssize_t) argc)
5301 ThrowMogrifyException(OptionError,"MissingArgument",option);
5304 if (LocaleCompare("limit",option+1) == 0)
5318 if (i == (ssize_t) argc)
5319 ThrowMogrifyException(OptionError,"MissingArgument",option);
5320 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5323 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
5326 if (i == (ssize_t) argc)
5327 ThrowMogrifyException(OptionError,"MissingArgument",option);
5328 value=StringToDouble(argv[i],&p);
5330 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5331 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5334 if (LocaleCompare("liquid-rescale",option+1) == 0)
5337 if (i == (ssize_t) argc)
5338 ThrowMogrifyException(OptionError,"MissingArgument",option);
5339 if (IsGeometry(argv[i]) == MagickFalse)
5340 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5343 if (LocaleCompare("list",option+1) == 0)
5351 if (i == (ssize_t) argc)
5352 ThrowMogrifyException(OptionError,"MissingArgument",option);
5353 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5355 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5356 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5358 return(status == 0 ? MagickTrue : MagickFalse);
5360 if (LocaleCompare("log",option+1) == 0)
5365 if ((i == (ssize_t) argc) ||
5366 (strchr(argv[i],'%') == (char *) NULL))
5367 ThrowMogrifyException(OptionError,"MissingArgument",option);
5370 if (LocaleCompare("loop",option+1) == 0)
5375 if (i == (ssize_t) argc)
5376 ThrowMogrifyException(OptionError,"MissingArgument",option);
5377 if (IsGeometry(argv[i]) == MagickFalse)
5378 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5381 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5385 if (LocaleCompare("map",option+1) == 0)
5387 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5391 if (i == (ssize_t) argc)
5392 ThrowMogrifyException(OptionError,"MissingArgument",option);
5395 if (LocaleCompare("mask",option+1) == 0)
5400 if (i == (ssize_t) argc)
5401 ThrowMogrifyException(OptionError,"MissingArgument",option);
5404 if (LocaleCompare("matte",option+1) == 0)
5406 if (LocaleCompare("mattecolor",option+1) == 0)
5411 if (i == (ssize_t) argc)
5412 ThrowMogrifyException(OptionError,"MissingArgument",option);
5415 if (LocaleCompare("maximum",option+1) == 0)
5417 if (LocaleCompare("mean-shift",option+1) == 0)
5422 if (i == (ssize_t) argc)
5423 ThrowMogrifyException(OptionError,"MissingArgument",option);
5424 if (IsGeometry(argv[i]) == MagickFalse)
5425 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5428 if (LocaleCompare("median",option+1) == 0)
5433 if (i == (ssize_t) argc)
5434 ThrowMogrifyException(OptionError,"MissingArgument",option);
5435 if (IsGeometry(argv[i]) == MagickFalse)
5436 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5439 if (LocaleCompare("metric",option+1) == 0)
5447 if (i == (ssize_t) argc)
5448 ThrowMogrifyException(OptionError,"MissingArgument",option);
5449 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
5451 ThrowMogrifyException(OptionError,"UnrecognizedMetricType",
5455 if (LocaleCompare("minimum",option+1) == 0)
5457 if (LocaleCompare("modulate",option+1) == 0)
5462 if (i == (ssize_t) argc)
5463 ThrowMogrifyException(OptionError,"MissingArgument",option);
5464 if (IsGeometry(argv[i]) == MagickFalse)
5465 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5468 if (LocaleCompare("mode",option+1) == 0)
5473 if (i == (ssize_t) argc)
5474 ThrowMogrifyException(OptionError,"MissingArgument",option);
5475 if (IsGeometry(argv[i]) == MagickFalse)
5476 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5479 if (LocaleCompare("monitor",option+1) == 0)
5481 if (LocaleCompare("monochrome",option+1) == 0)
5483 if (LocaleCompare("morph",option+1) == 0)
5488 if (i == (ssize_t) argc)
5489 ThrowMogrifyException(OptionError,"MissingArgument",option);
5490 if (IsGeometry(argv[i]) == MagickFalse)
5491 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5494 if (LocaleCompare("morphology",option+1) == 0)
5497 token[MagickPathExtent];
5506 if (i == (ssize_t) argc)
5507 ThrowMogrifyException(OptionError,"MissingArgument",option);
5508 GetNextToken(argv[i],(const char **) NULL,MagickPathExtent,token);
5509 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5511 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5514 if (i == (ssize_t) argc)
5515 ThrowMogrifyException(OptionError,"MissingArgument",option);
5516 kernel_info=AcquireKernelInfo(argv[i],exception);
5517 if (kernel_info == (KernelInfo *) NULL)
5518 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5519 kernel_info=DestroyKernelInfo(kernel_info);
5522 if (LocaleCompare("mosaic",option+1) == 0)
5524 if (LocaleCompare("motion-blur",option+1) == 0)
5529 if (i == (ssize_t) argc)
5530 ThrowMogrifyException(OptionError,"MissingArgument",option);
5531 if (IsGeometry(argv[i]) == MagickFalse)
5532 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5535 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5539 if (LocaleCompare("negate",option+1) == 0)
5541 if (LocaleCompare("noise",option+1) == 0)
5544 if (i == (ssize_t) argc)
5545 ThrowMogrifyException(OptionError,"MissingArgument",option);
5551 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,
5554 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5558 if (IsGeometry(argv[i]) == MagickFalse)
5559 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5562 if (LocaleCompare("noop",option+1) == 0)
5564 if (LocaleCompare("normalize",option+1) == 0)
5566 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5570 if (LocaleCompare("opaque",option+1) == 0)
5573 if (i == (ssize_t) argc)
5574 ThrowMogrifyException(OptionError,"MissingArgument",option);
5577 if (LocaleCompare("ordered-dither",option+1) == 0)
5582 if (i == (ssize_t) argc)
5583 ThrowMogrifyException(OptionError,"MissingArgument",option);
5586 if (LocaleCompare("orient",option+1) == 0)
5591 orientation=UndefinedOrientation;
5595 if (i == (ssize_t) argc)
5596 ThrowMogrifyException(OptionError,"MissingArgument",option);
5597 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5599 if (orientation < 0)
5600 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5604 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5608 if (LocaleCompare("page",option+1) == 0)
5613 if (i == (ssize_t) argc)
5614 ThrowMogrifyException(OptionError,"MissingArgument",option);
5617 if (LocaleCompare("paint",option+1) == 0)
5622 if (i == (ssize_t) argc)
5623 ThrowMogrifyException(OptionError,"MissingArgument",option);
5624 if (IsGeometry(argv[i]) == MagickFalse)
5625 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5628 if (LocaleCompare("path",option+1) == 0)
5630 (void) CloneString(&path,(char *) NULL);
5634 if (i == (ssize_t) argc)
5635 ThrowMogrifyException(OptionError,"MissingArgument",option);
5636 (void) CloneString(&path,argv[i]);
5639 if (LocaleCompare("perceptible",option+1) == 0)
5644 if (i == (ssize_t) argc)
5645 ThrowMogrifyException(OptionError,"MissingArgument",option);
5646 if (IsGeometry(argv[i]) == MagickFalse)
5647 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 if (LocaleCompare("pointsize",option+1) == 0)
5655 if (i == (ssize_t) argc)
5656 ThrowMogrifyException(OptionError,"MissingArgument",option);
5657 if (IsGeometry(argv[i]) == MagickFalse)
5658 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5661 if (LocaleCompare("polaroid",option+1) == 0)
5666 if (i == (ssize_t) argc)
5667 ThrowMogrifyException(OptionError,"MissingArgument",option);
5668 if (IsGeometry(argv[i]) == MagickFalse)
5669 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5672 if (LocaleCompare("poly",option+1) == 0)
5677 if (i == (ssize_t) argc)
5678 ThrowMogrifyException(OptionError,"MissingArgument",option);
5679 if (IsGeometry(argv[i]) == MagickFalse)
5680 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5683 if (LocaleCompare("posterize",option+1) == 0)
5688 if (i == (ssize_t) argc)
5689 ThrowMogrifyException(OptionError,"MissingArgument",option);
5690 if (IsGeometry(argv[i]) == MagickFalse)
5691 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5694 if (LocaleCompare("precision",option+1) == 0)
5699 if (i == (ssize_t) argc)
5700 ThrowMogrifyException(OptionError,"MissingArgument",option);
5701 if (IsGeometry(argv[i]) == MagickFalse)
5702 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5705 if (LocaleCompare("print",option+1) == 0)
5710 if (i == (ssize_t) argc)
5711 ThrowMogrifyException(OptionError,"MissingArgument",option);
5714 if (LocaleCompare("process",option+1) == 0)
5719 if (i == (ssize_t) argc)
5720 ThrowMogrifyException(OptionError,"MissingArgument",option);
5723 if (LocaleCompare("profile",option+1) == 0)
5726 if (i == (ssize_t) argc)
5727 ThrowMogrifyException(OptionError,"MissingArgument",option);
5730 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5734 if (LocaleCompare("quality",option+1) == 0)
5739 if (i == (ssize_t) argc)
5740 ThrowMogrifyException(OptionError,"MissingArgument",option);
5741 if (IsGeometry(argv[i]) == MagickFalse)
5742 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5745 if (LocaleCompare("quantize",option+1) == 0)
5753 if (i == (ssize_t) argc)
5754 ThrowMogrifyException(OptionError,"MissingArgument",option);
5755 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5758 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5762 if (LocaleCompare("quiet",option+1) == 0)
5764 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5768 if (LocaleCompare("rotational-blur",option+1) == 0)
5771 if (i == (ssize_t) argc)
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5773 if (IsGeometry(argv[i]) == MagickFalse)
5774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5777 if (LocaleCompare("raise",option+1) == 0)
5780 if (i == (ssize_t) argc)
5781 ThrowMogrifyException(OptionError,"MissingArgument",option);
5782 if (IsGeometry(argv[i]) == MagickFalse)
5783 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5786 if (LocaleCompare("random-threshold",option+1) == 0)
5791 if (i == (ssize_t) argc)
5792 ThrowMogrifyException(OptionError,"MissingArgument",option);
5793 if (IsGeometry(argv[i]) == MagickFalse)
5794 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5797 if (LocaleCompare("range-threshold",option+1) == 0)
5802 if (i == (ssize_t) argc)
5803 ThrowMogrifyException(OptionError,"MissingArgument",option);
5804 if (IsGeometry(argv[i]) == MagickFalse)
5805 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5808 if (LocaleCompare("read-mask",option+1) == 0)
5813 if (i == (ssize_t) argc)
5814 ThrowMogrifyException(OptionError,"MissingArgument",option);
5817 if (LocaleCompare("red-primary",option+1) == 0)
5822 if (i == (ssize_t) argc)
5823 ThrowMogrifyException(OptionError,"MissingArgument",option);
5824 if (IsGeometry(argv[i]) == MagickFalse)
5825 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5827 if (LocaleCompare("regard-warnings",option+1) == 0)
5829 if (LocaleCompare("region",option+1) == 0)
5834 if (i == (ssize_t) argc)
5835 ThrowMogrifyException(OptionError,"MissingArgument",option);
5836 if (IsGeometry(argv[i]) == MagickFalse)
5837 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5840 if (LocaleCompare("remap",option+1) == 0)
5845 if (i == (ssize_t) argc)
5846 ThrowMogrifyException(OptionError,"MissingArgument",option);
5849 if (LocaleCompare("render",option+1) == 0)
5851 if (LocaleCompare("repage",option+1) == 0)
5856 if (i == (ssize_t) argc)
5857 ThrowMogrifyException(OptionError,"MissingArgument",option);
5858 if (IsGeometry(argv[i]) == MagickFalse)
5859 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5862 if (LocaleCompare("resample",option+1) == 0)
5867 if (i == (ssize_t) argc)
5868 ThrowMogrifyException(OptionError,"MissingArgument",option);
5869 if (IsGeometry(argv[i]) == MagickFalse)
5870 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5873 if (LocaleCompare("resize",option+1) == 0)
5878 if (i == (ssize_t) argc)
5879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 if (IsGeometry(argv[i]) == MagickFalse)
5881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5884 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5886 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5889 if (LocaleCompare("reverse",option+1) == 0)
5891 if (LocaleCompare("roll",option+1) == 0)
5896 if (i == (ssize_t) argc)
5897 ThrowMogrifyException(OptionError,"MissingArgument",option);
5898 if (IsGeometry(argv[i]) == MagickFalse)
5899 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5902 if (LocaleCompare("rotate",option+1) == 0)
5905 if (i == (ssize_t) argc)
5906 ThrowMogrifyException(OptionError,"MissingArgument",option);
5907 if (IsGeometry(argv[i]) == MagickFalse)
5908 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5911 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5915 if (LocaleCompare("sample",option+1) == 0)
5920 if (i == (ssize_t) argc)
5921 ThrowMogrifyException(OptionError,"MissingArgument",option);
5922 if (IsGeometry(argv[i]) == MagickFalse)
5923 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5926 if (LocaleCompare("sampling-factor",option+1) == 0)
5931 if (i == (ssize_t) argc)
5932 ThrowMogrifyException(OptionError,"MissingArgument",option);
5933 if (IsGeometry(argv[i]) == MagickFalse)
5934 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5937 if (LocaleCompare("scale",option+1) == 0)
5942 if (i == (ssize_t) argc)
5943 ThrowMogrifyException(OptionError,"MissingArgument",option);
5944 if (IsGeometry(argv[i]) == MagickFalse)
5945 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5948 if (LocaleCompare("scene",option+1) == 0)
5953 if (i == (ssize_t) argc)
5954 ThrowMogrifyException(OptionError,"MissingArgument",option);
5955 if (IsGeometry(argv[i]) == MagickFalse)
5956 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5959 if (LocaleCompare("seed",option+1) == 0)
5964 if (i == (ssize_t) argc)
5965 ThrowMogrifyException(OptionError,"MissingArgument",option);
5966 if (IsGeometry(argv[i]) == MagickFalse)
5967 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5970 if (LocaleCompare("segment",option+1) == 0)
5975 if (i == (ssize_t) argc)
5976 ThrowMogrifyException(OptionError,"MissingArgument",option);
5977 if (IsGeometry(argv[i]) == MagickFalse)
5978 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5981 if (LocaleCompare("selective-blur",option+1) == 0)
5984 if (i == (ssize_t) argc)
5985 ThrowMogrifyException(OptionError,"MissingArgument",option);
5986 if (IsGeometry(argv[i]) == MagickFalse)
5987 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5990 if (LocaleCompare("separate",option+1) == 0)
5992 if (LocaleCompare("sepia-tone",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("set",option+1) == 0)
6006 if (i == (ssize_t) argc)
6007 ThrowMogrifyException(OptionError,"MissingArgument",option);
6011 if (i == (ssize_t) argc)
6012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6015 if (LocaleCompare("shade",option+1) == 0)
6018 if (i == (ssize_t) argc)
6019 ThrowMogrifyException(OptionError,"MissingArgument",option);
6020 if (IsGeometry(argv[i]) == MagickFalse)
6021 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6024 if (LocaleCompare("shadow",option+1) == 0)
6029 if (i == (ssize_t) argc)
6030 ThrowMogrifyException(OptionError,"MissingArgument",option);
6031 if (IsGeometry(argv[i]) == MagickFalse)
6032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6035 if (LocaleCompare("sharpen",option+1) == 0)
6038 if (i == (ssize_t) argc)
6039 ThrowMogrifyException(OptionError,"MissingArgument",option);
6040 if (IsGeometry(argv[i]) == MagickFalse)
6041 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6044 if (LocaleCompare("shave",option+1) == 0)
6049 if (i == (ssize_t) argc)
6050 ThrowMogrifyException(OptionError,"MissingArgument",option);
6051 if (IsGeometry(argv[i]) == MagickFalse)
6052 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6055 if (LocaleCompare("shear",option+1) == 0)
6058 if (i == (ssize_t) argc)
6059 ThrowMogrifyException(OptionError,"MissingArgument",option);
6060 if (IsGeometry(argv[i]) == MagickFalse)
6061 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6064 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
6067 if (i == (ssize_t) argc)
6068 ThrowMogrifyException(OptionError,"MissingArgument",option);
6069 if (IsGeometry(argv[i]) == MagickFalse)
6070 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6073 if (LocaleCompare("size",option+1) == 0)
6078 if (i == (ssize_t) argc)
6079 ThrowMogrifyException(OptionError,"MissingArgument",option);
6080 if (IsGeometry(argv[i]) == MagickFalse)
6081 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6084 if (LocaleCompare("sketch",option+1) == 0)
6089 if (i == (ssize_t) argc)
6090 ThrowMogrifyException(OptionError,"MissingArgument",option);
6091 if (IsGeometry(argv[i]) == MagickFalse)
6092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6095 if (LocaleCompare("smush",option+1) == 0)
6098 if (i == (ssize_t) argc)
6099 ThrowMogrifyException(OptionError,"MissingArgument",option);
6100 if (IsGeometry(argv[i]) == MagickFalse)
6101 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6105 if (LocaleCompare("solarize",option+1) == 0)
6110 if (i == (ssize_t) argc)
6111 ThrowMogrifyException(OptionError,"MissingArgument",option);
6112 if (IsGeometry(argv[i]) == MagickFalse)
6113 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6116 if (LocaleCompare("sparse-color",option+1) == 0)
6122 if (i == (ssize_t) argc)
6123 ThrowMogrifyException(OptionError,"MissingArgument",option);
6124 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
6126 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
6129 if (i == (ssize_t) argc)
6130 ThrowMogrifyException(OptionError,"MissingArgument",option);
6133 if (LocaleCompare("splice",option+1) == 0)
6138 if (i == (ssize_t) argc)
6139 ThrowMogrifyException(OptionError,"MissingArgument",option);
6140 if (IsGeometry(argv[i]) == MagickFalse)
6141 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6144 if (LocaleCompare("spread",option+1) == 0)
6149 if (i == (ssize_t) argc)
6150 ThrowMogrifyException(OptionError,"MissingArgument",option);
6151 if (IsGeometry(argv[i]) == MagickFalse)
6152 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6155 if (LocaleCompare("statistic",option+1) == 0)
6163 if (i == (ssize_t) argc)
6164 ThrowMogrifyException(OptionError,"MissingArgument",option);
6165 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
6167 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
6170 if (i == (ssize_t) argc)
6171 ThrowMogrifyException(OptionError,"MissingArgument",option);
6172 if (IsGeometry(argv[i]) == MagickFalse)
6173 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6176 if (LocaleCompare("stretch",option+1) == 0)
6184 if (i == (ssize_t) argc)
6185 ThrowMogrifyException(OptionError,"MissingArgument",option);
6186 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,
6189 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6193 if (LocaleCompare("strip",option+1) == 0)
6195 if (LocaleCompare("stroke",option+1) == 0)
6200 if (i == (ssize_t) argc)
6201 ThrowMogrifyException(OptionError,"MissingArgument",option);
6204 if (LocaleCompare("strokewidth",option+1) == 0)
6209 if (i == (ssize_t) argc)
6210 ThrowMogrifyException(OptionError,"MissingArgument",option);
6211 if (IsGeometry(argv[i]) == MagickFalse)
6212 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6215 if (LocaleCompare("style",option+1) == 0)
6223 if (i == (ssize_t) argc)
6224 ThrowMogrifyException(OptionError,"MissingArgument",option);
6225 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
6227 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
6231 if (LocaleCompare("swap",option+1) == 0)
6236 if (i == (ssize_t) argc)
6237 ThrowMogrifyException(OptionError,"MissingArgument",option);
6238 if (IsGeometry(argv[i]) == MagickFalse)
6239 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6242 if (LocaleCompare("swirl",option+1) == 0)
6247 if (i == (ssize_t) argc)
6248 ThrowMogrifyException(OptionError,"MissingArgument",option);
6249 if (IsGeometry(argv[i]) == MagickFalse)
6250 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6253 if (LocaleCompare("synchronize",option+1) == 0)
6255 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6259 if (LocaleCompare("taint",option+1) == 0)
6261 if (LocaleCompare("texture",option+1) == 0)
6266 if (i == (ssize_t) argc)
6267 ThrowMogrifyException(OptionError,"MissingArgument",option);
6270 if (LocaleCompare("tile",option+1) == 0)
6275 if (i == (ssize_t) argc)
6276 ThrowMogrifyException(OptionError,"MissingArgument",option);
6279 if (LocaleCompare("tile-offset",option+1) == 0)
6284 if (i == (ssize_t) argc)
6285 ThrowMogrifyException(OptionError,"MissingArgument",option);
6286 if (IsGeometry(argv[i]) == MagickFalse)
6287 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6290 if (LocaleCompare("tint",option+1) == 0)
6295 if (i == (ssize_t) argc)
6296 ThrowMogrifyException(OptionError,"MissingArgument",option);
6297 if (IsGeometry(argv[i]) == MagickFalse)
6298 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6301 if (LocaleCompare("transform",option+1) == 0)
6303 if (LocaleCompare("transpose",option+1) == 0)
6305 if (LocaleCompare("transverse",option+1) == 0)
6307 if (LocaleCompare("threshold",option+1) == 0)
6312 if (i == (ssize_t) argc)
6313 ThrowMogrifyException(OptionError,"MissingArgument",option);
6314 if (IsGeometry(argv[i]) == MagickFalse)
6315 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6318 if (LocaleCompare("thumbnail",option+1) == 0)
6323 if (i == (ssize_t) argc)
6324 ThrowMogrifyException(OptionError,"MissingArgument",option);
6325 if (IsGeometry(argv[i]) == MagickFalse)
6326 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6329 if (LocaleCompare("transparent",option+1) == 0)
6332 if (i == (ssize_t) argc)
6333 ThrowMogrifyException(OptionError,"MissingArgument",option);
6336 if (LocaleCompare("transparent-color",option+1) == 0)
6341 if (i == (ssize_t) argc)
6342 ThrowMogrifyException(OptionError,"MissingArgument",option);
6345 if (LocaleCompare("treedepth",option+1) == 0)
6350 if (i == (ssize_t) argc)
6351 ThrowMogrifyException(OptionError,"MissingArgument",option);
6352 if (IsGeometry(argv[i]) == MagickFalse)
6353 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6356 if (LocaleCompare("trim",option+1) == 0)
6358 if (LocaleCompare("type",option+1) == 0)
6366 if (i == (ssize_t) argc)
6367 ThrowMogrifyException(OptionError,"MissingArgument",option);
6368 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
6370 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
6374 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6378 if (LocaleCompare("undercolor",option+1) == 0)
6383 if (i == (ssize_t) argc)
6384 ThrowMogrifyException(OptionError,"MissingArgument",option);
6387 if (LocaleCompare("unique-colors",option+1) == 0)
6389 if (LocaleCompare("units",option+1) == 0)
6397 if (i == (ssize_t) argc)
6398 ThrowMogrifyException(OptionError,"MissingArgument",option);
6399 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
6402 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
6406 if (LocaleCompare("unsharp",option+1) == 0)
6409 if (i == (ssize_t) argc)
6410 ThrowMogrifyException(OptionError,"MissingArgument",option);
6411 if (IsGeometry(argv[i]) == MagickFalse)
6412 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6415 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6419 if (LocaleCompare("verbose",option+1) == 0)
6421 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6424 if ((LocaleCompare("version",option+1) == 0) ||
6425 (LocaleCompare("-version",option+1) == 0))
6427 ListMagickVersion(stdout);
6430 if (LocaleCompare("vignette",option+1) == 0)
6435 if (i == (ssize_t) argc)
6436 ThrowMogrifyException(OptionError,"MissingArgument",option);
6437 if (IsGeometry(argv[i]) == MagickFalse)
6438 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6441 if (LocaleCompare("virtual-pixel",option+1) == 0)
6449 if (i == (ssize_t) argc)
6450 ThrowMogrifyException(OptionError,"MissingArgument",option);
6451 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6454 ThrowMogrifyException(OptionError,
6455 "UnrecognizedVirtualPixelMethod",argv[i]);
6458 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6462 if (LocaleCompare("wave",option+1) == 0)
6465 if (i == (ssize_t) argc)
6466 ThrowMogrifyException(OptionError,"MissingArgument",option);
6467 if (IsGeometry(argv[i]) == MagickFalse)
6468 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6471 if (LocaleCompare("wavelet-denoise",option+1) == 0)
6474 if (i == (ssize_t) argc)
6475 ThrowMogrifyException(OptionError,"MissingArgument",option);
6476 if (IsGeometry(argv[i]) == MagickFalse)
6477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6480 if (LocaleCompare("weight",option+1) == 0)
6485 if (i == (ssize_t) argc)
6486 ThrowMogrifyException(OptionError,"MissingArgument",option);
6489 if (LocaleCompare("white-point",option+1) == 0)
6494 if (i == (ssize_t) argc)
6495 ThrowMogrifyException(OptionError,"MissingArgument",option);
6496 if (IsGeometry(argv[i]) == MagickFalse)
6497 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6500 if (LocaleCompare("white-threshold",option+1) == 0)
6505 if (i == (ssize_t) argc)
6506 ThrowMogrifyException(OptionError,"MissingArgument",option);
6507 if (IsGeometry(argv[i]) == MagickFalse)
6508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6511 if (LocaleCompare("write",option+1) == 0)
6514 if (i == (ssize_t) argc)
6515 ThrowMogrifyException(OptionError,"MissingArgument",option);
6518 if (LocaleCompare("write-mask",option+1) == 0)
6523 if (i == (ssize_t) argc)
6524 ThrowMogrifyException(OptionError,"MissingArgument",option);
6527 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6532 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6534 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6535 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6536 if (fire != MagickFalse)
6537 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6540 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6541 if (i != (ssize_t) argc)
6542 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6544 return(status != 0 ? MagickTrue : MagickFalse);
6548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6552 + M o g r i f y I m a g e I n f o %
6556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6558 % MogrifyImageInfo() applies image processing settings to the image as
6559 % prescribed by command line options.
6561 % The format of the MogrifyImageInfo method is:
6563 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6564 % const char **argv,ExceptionInfo *exception)
6566 % A description of each parameter follows:
6568 % o image_info: the image info..
6570 % o argc: Specifies a pointer to an integer describing the number of
6571 % elements in the argument vector.
6573 % o argv: Specifies a pointer to a text array containing the command line
6576 % o exception: return any errors or warnings in this structure.
6579 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6580 const int argc,const char **argv,ExceptionInfo *exception)
6595 Initialize method variables.
6597 assert(image_info != (ImageInfo *) NULL);
6598 assert(image_info->signature == MagickCoreSignature);
6599 if (image_info->debug != MagickFalse)
6600 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6601 image_info->filename);
6605 Set the image settings.
6607 for (i=0; i < (ssize_t) argc; i++)
6610 if (IsCommandOption(option) == MagickFalse)
6612 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6613 count=MagickMax(count,0L);
6614 if ((i+count) >= (ssize_t) argc)
6616 switch (*(option+1))
6620 if (LocaleCompare("adjoin",option+1) == 0)
6622 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6625 if (LocaleCompare("antialias",option+1) == 0)
6627 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6630 if (LocaleCompare("authenticate",option+1) == 0)
6633 (void) DeleteImageOption(image_info,option+1);
6635 (void) SetImageOption(image_info,option+1,argv[i+1]);
6642 if (LocaleCompare("background",option+1) == 0)
6646 (void) DeleteImageOption(image_info,option+1);
6647 (void) QueryColorCompliance(MogrifyBackgroundColor,
6648 AllCompliance,&image_info->background_color,exception);
6651 (void) SetImageOption(image_info,option+1,argv[i+1]);
6652 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6653 &image_info->background_color,exception);
6656 if (LocaleCompare("bias",option+1) == 0)
6660 (void) SetImageOption(image_info,"convolve:bias","0.0");
6663 (void) SetImageOption(image_info,"convolve:bias",argv[i+1]);
6666 if (LocaleCompare("black-point-compensation",option+1) == 0)
6670 (void) SetImageOption(image_info,option+1,"false");
6673 (void) SetImageOption(image_info,option+1,"true");
6676 if (LocaleCompare("blue-primary",option+1) == 0)
6680 (void) SetImageOption(image_info,option+1,"0.0");
6683 (void) SetImageOption(image_info,option+1,argv[i+1]);
6686 if (LocaleCompare("bordercolor",option+1) == 0)
6690 (void) DeleteImageOption(image_info,option+1);
6691 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6692 &image_info->border_color,exception);
6695 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6696 &image_info->border_color,exception);
6697 (void) SetImageOption(image_info,option+1,argv[i+1]);
6700 if (LocaleCompare("box",option+1) == 0)
6704 (void) SetImageOption(image_info,"undercolor","none");
6707 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6714 if (LocaleCompare("cache",option+1) == 0)
6719 limit=MagickResourceInfinity;
6720 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6721 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6723 (void) SetMagickResourceLimit(MemoryResource,limit);
6724 (void) SetMagickResourceLimit(MapResource,2*limit);
6727 if (LocaleCompare("caption",option+1) == 0)
6731 (void) DeleteImageOption(image_info,option+1);
6734 (void) SetImageOption(image_info,option+1,argv[i+1]);
6737 if (LocaleCompare("colorspace",option+1) == 0)
6741 image_info->colorspace=UndefinedColorspace;
6742 (void) SetImageOption(image_info,option+1,"undefined");
6745 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6746 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6747 (void) SetImageOption(image_info,option+1,argv[i+1]);
6750 if (LocaleCompare("comment",option+1) == 0)
6754 (void) DeleteImageOption(image_info,option+1);
6757 (void) SetImageOption(image_info,option+1,argv[i+1]);
6760 if (LocaleCompare("compose",option+1) == 0)
6764 (void) SetImageOption(image_info,option+1,"undefined");
6767 (void) SetImageOption(image_info,option+1,argv[i+1]);
6770 if (LocaleCompare("compress",option+1) == 0)
6774 image_info->compression=UndefinedCompression;
6775 (void) SetImageOption(image_info,option+1,"undefined");
6778 image_info->compression=(CompressionType) ParseCommandOption(
6779 MagickCompressOptions,MagickFalse,argv[i+1]);
6780 (void) SetImageOption(image_info,option+1,argv[i+1]);
6787 if (LocaleCompare("debug",option+1) == 0)
6790 (void) SetLogEventMask("none");
6792 (void) SetLogEventMask(argv[i+1]);
6793 image_info->debug=IsEventLogging();
6796 if (LocaleCompare("define",option+1) == 0)
6800 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6801 (void) DeleteImageRegistry(argv[i+1]+9);
6803 (void) DeleteImageOption(image_info,argv[i+1]);
6806 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6808 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6812 (void) DefineImageOption(image_info,argv[i+1]);
6815 if (LocaleCompare("delay",option+1) == 0)
6819 (void) SetImageOption(image_info,option+1,"0");
6822 (void) SetImageOption(image_info,option+1,argv[i+1]);
6825 if (LocaleCompare("density",option+1) == 0)
6832 if (image_info->density != (char *) NULL)
6833 image_info->density=DestroyString(image_info->density);
6834 (void) SetImageOption(image_info,option+1,"72");
6837 (void) CloneString(&image_info->density,argv[i+1]);
6838 (void) SetImageOption(image_info,option+1,argv[i+1]);
6841 if (LocaleCompare("depth",option+1) == 0)
6845 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6848 image_info->depth=StringToUnsignedLong(argv[i+1]);
6851 if (LocaleCompare("direction",option+1) == 0)
6855 (void) SetImageOption(image_info,option+1,"undefined");
6858 (void) SetImageOption(image_info,option+1,argv[i+1]);
6861 if (LocaleCompare("display",option+1) == 0)
6865 if (image_info->server_name != (char *) NULL)
6866 image_info->server_name=DestroyString(
6867 image_info->server_name);
6870 (void) CloneString(&image_info->server_name,argv[i+1]);
6873 if (LocaleCompare("dispose",option+1) == 0)
6877 (void) SetImageOption(image_info,option+1,"undefined");
6880 (void) SetImageOption(image_info,option+1,argv[i+1]);
6883 if (LocaleCompare("dither",option+1) == 0)
6887 image_info->dither=MagickFalse;
6888 (void) SetImageOption(image_info,option+1,"none");
6891 (void) SetImageOption(image_info,option+1,argv[i+1]);
6892 image_info->dither=MagickTrue;
6899 if (LocaleCompare("encoding",option+1) == 0)
6903 (void) SetImageOption(image_info,option+1,"undefined");
6906 (void) SetImageOption(image_info,option+1,argv[i+1]);
6909 if (LocaleCompare("endian",option+1) == 0)
6913 image_info->endian=UndefinedEndian;
6914 (void) SetImageOption(image_info,option+1,"undefined");
6917 image_info->endian=(EndianType) ParseCommandOption(
6918 MagickEndianOptions,MagickFalse,argv[i+1]);
6919 (void) SetImageOption(image_info,option+1,argv[i+1]);
6922 if (LocaleCompare("extract",option+1) == 0)
6925 Set image extract geometry.
6929 if (image_info->extract != (char *) NULL)
6930 image_info->extract=DestroyString(image_info->extract);
6933 (void) CloneString(&image_info->extract,argv[i+1]);
6940 if (LocaleCompare("family",option+1) == 0)
6943 (void) SetImageOption(image_info,option+1,argv[i+1]);
6946 if (LocaleCompare("fill",option+1) == 0)
6950 (void) SetImageOption(image_info,option+1,"none");
6953 (void) SetImageOption(image_info,option+1,argv[i+1]);
6956 if (LocaleCompare("filter",option+1) == 0)
6960 (void) SetImageOption(image_info,option+1,"undefined");
6963 (void) SetImageOption(image_info,option+1,argv[i+1]);
6966 if (LocaleCompare("font",option+1) == 0)
6970 if (image_info->font != (char *) NULL)
6971 image_info->font=DestroyString(image_info->font);
6974 (void) CloneString(&image_info->font,argv[i+1]);
6977 if (LocaleCompare("format",option+1) == 0)
6982 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6983 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6984 image_info->ping=MagickFalse;
6985 (void) SetImageOption(image_info,option+1,argv[i+1]);
6988 if (LocaleCompare("fuzz",option+1) == 0)
6992 image_info->fuzz=0.0;
6993 (void) SetImageOption(image_info,option+1,"0");
6996 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6998 (void) SetImageOption(image_info,option+1,argv[i+1]);
7005 if (LocaleCompare("gravity",option+1) == 0)
7009 (void) SetImageOption(image_info,option+1,"undefined");
7012 (void) SetImageOption(image_info,option+1,argv[i+1]);
7015 if (LocaleCompare("green-primary",option+1) == 0)
7019 (void) SetImageOption(image_info,option+1,"0.0");
7022 (void) SetImageOption(image_info,option+1,argv[i+1]);
7029 if (LocaleCompare("intensity",option+1) == 0)
7033 (void) SetImageOption(image_info,option+1,"undefined");
7036 (void) SetImageOption(image_info,option+1,argv[i+1]);
7039 if (LocaleCompare("intent",option+1) == 0)
7043 (void) SetImageOption(image_info,option+1,"undefined");
7046 (void) SetImageOption(image_info,option+1,argv[i+1]);
7049 if (LocaleCompare("interlace",option+1) == 0)
7053 image_info->interlace=UndefinedInterlace;
7054 (void) SetImageOption(image_info,option+1,"undefined");
7057 image_info->interlace=(InterlaceType) ParseCommandOption(
7058 MagickInterlaceOptions,MagickFalse,argv[i+1]);
7059 (void) SetImageOption(image_info,option+1,argv[i+1]);
7062 if (LocaleCompare("interline-spacing",option+1) == 0)
7066 (void) SetImageOption(image_info,option+1,"undefined");
7069 (void) SetImageOption(image_info,option+1,argv[i+1]);
7072 if (LocaleCompare("interpolate",option+1) == 0)
7076 (void) SetImageOption(image_info,option+1,"undefined");
7079 (void) SetImageOption(image_info,option+1,argv[i+1]);
7082 if (LocaleCompare("interword-spacing",option+1) == 0)
7086 (void) SetImageOption(image_info,option+1,"undefined");
7089 (void) SetImageOption(image_info,option+1,argv[i+1]);
7096 if (LocaleCompare("kerning",option+1) == 0)
7100 (void) SetImageOption(image_info,option+1,"undefined");
7103 (void) SetImageOption(image_info,option+1,argv[i+1]);
7110 if (LocaleCompare("label",option+1) == 0)
7114 (void) DeleteImageOption(image_info,option+1);
7117 (void) SetImageOption(image_info,option+1,argv[i+1]);
7120 if (LocaleCompare("limit",option+1) == 0)
7130 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
7131 MagickFalse,argv[i+1]);
7132 limit=MagickResourceInfinity;
7133 if (LocaleCompare("unlimited",argv[i+2]) != 0)
7134 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
7135 (void) SetMagickResourceLimit(type,limit);
7138 if (LocaleCompare("list",option+1) == 0)
7144 Display configuration list.
7146 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
7149 case MagickCoderOptions:
7151 (void) ListCoderInfo((FILE *) NULL,exception);
7154 case MagickColorOptions:
7156 (void) ListColorInfo((FILE *) NULL,exception);
7159 case MagickConfigureOptions:
7161 (void) ListConfigureInfo((FILE *) NULL,exception);
7164 case MagickDelegateOptions:
7166 (void) ListDelegateInfo((FILE *) NULL,exception);
7169 case MagickFontOptions:
7171 (void) ListTypeInfo((FILE *) NULL,exception);
7174 case MagickFormatOptions:
7176 (void) ListMagickInfo((FILE *) NULL,exception);
7179 case MagickLocaleOptions:
7181 (void) ListLocaleInfo((FILE *) NULL,exception);
7184 case MagickLogOptions:
7186 (void) ListLogInfo((FILE *) NULL,exception);
7189 case MagickMagicOptions:
7191 (void) ListMagicInfo((FILE *) NULL,exception);
7194 case MagickMimeOptions:
7196 (void) ListMimeInfo((FILE *) NULL,exception);
7199 case MagickModuleOptions:
7201 (void) ListModuleInfo((FILE *) NULL,exception);
7204 case MagickPolicyOptions:
7206 (void) ListPolicyInfo((FILE *) NULL,exception);
7209 case MagickResourceOptions:
7211 (void) ListMagickResourceInfo((FILE *) NULL,exception);
7214 case MagickThresholdOptions:
7216 (void) ListThresholdMaps((FILE *) NULL,exception);
7221 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
7228 if (LocaleCompare("log",option+1) == 0)
7232 (void) SetLogFormat(argv[i+1]);
7235 if (LocaleCompare("loop",option+1) == 0)
7239 (void) SetImageOption(image_info,option+1,"0");
7242 (void) SetImageOption(image_info,option+1,argv[i+1]);
7249 if (LocaleCompare("matte",option+1) == 0)
7253 (void) SetImageOption(image_info,option+1,"false");
7256 (void) SetImageOption(image_info,option+1,"true");
7259 if (LocaleCompare("mattecolor",option+1) == 0)
7263 (void) SetImageOption(image_info,option+1,argv[i+1]);
7264 (void) QueryColorCompliance(MogrifyAlphaColor,AllCompliance,
7265 &image_info->matte_color,exception);
7268 (void) SetImageOption(image_info,option+1,argv[i+1]);
7269 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7270 &image_info->matte_color,exception);
7273 if (LocaleCompare("metric",option+1) == 0)
7276 (void) DeleteImageOption(image_info,option+1);
7278 (void) SetImageOption(image_info,option+1,argv[i+1]);
7281 if (LocaleCompare("monitor",option+1) == 0)
7283 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
7287 if (LocaleCompare("monochrome",option+1) == 0)
7289 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
7296 if (LocaleCompare("orient",option+1) == 0)
7300 image_info->orientation=UndefinedOrientation;
7301 (void) SetImageOption(image_info,option+1,"undefined");
7304 image_info->orientation=(OrientationType) ParseCommandOption(
7305 MagickOrientationOptions,MagickFalse,argv[i+1]);
7306 (void) SetImageOption(image_info,option+1,argv[i+1]);
7312 if (LocaleCompare("page",option+1) == 0)
7316 page[MagickPathExtent];
7329 (void) DeleteImageOption(image_info,option+1);
7330 (void) CloneString(&image_info->page,(char *) NULL);
7333 (void) memset(&geometry,0,sizeof(geometry));
7334 image_option=GetImageOption(image_info,"page");
7335 if (image_option != (const char *) NULL)
7336 flags=ParseAbsoluteGeometry(image_option,&geometry);
7337 canonical_page=GetPageGeometry(argv[i+1]);
7338 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
7339 canonical_page=DestroyString(canonical_page);
7340 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu",
7341 (unsigned long) geometry.width,(unsigned long) geometry.height);
7342 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
7343 (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu%+ld%+ld",
7344 (unsigned long) geometry.width,(unsigned long) geometry.height,
7345 (long) geometry.x,(long) geometry.y);
7346 (void) SetImageOption(image_info,option+1,page);
7347 (void) CloneString(&image_info->page,page);
7350 if (LocaleCompare("ping",option+1) == 0)
7352 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
7355 if (LocaleCompare("pointsize",option+1) == 0)
7358 geometry_info.rho=0.0;
7360 (void) ParseGeometry(argv[i+1],&geometry_info);
7361 image_info->pointsize=geometry_info.rho;
7364 if (LocaleCompare("precision",option+1) == 0)
7366 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
7373 if (LocaleCompare("quality",option+1) == 0)
7376 Set image compression quality.
7380 image_info->quality=UndefinedCompressionQuality;
7381 (void) SetImageOption(image_info,option+1,"0");
7384 image_info->quality=StringToUnsignedLong(argv[i+1]);
7385 (void) SetImageOption(image_info,option+1,argv[i+1]);
7388 if (LocaleCompare("quiet",option+1) == 0)
7390 static WarningHandler
7391 warning_handler = (WarningHandler) NULL;
7396 Restore error or warning messages.
7398 warning_handler=SetWarningHandler(warning_handler);
7402 Suppress error or warning messages.
7404 warning_handler=SetWarningHandler((WarningHandler) NULL);
7411 if (LocaleCompare("red-primary",option+1) == 0)
7415 (void) SetImageOption(image_info,option+1,"0.0");
7418 (void) SetImageOption(image_info,option+1,argv[i+1]);
7425 if (LocaleCompare("sampling-factor",option+1) == 0)
7428 Set image sampling factor.
7432 if (image_info->sampling_factor != (char *) NULL)
7433 image_info->sampling_factor=DestroyString(
7434 image_info->sampling_factor);
7437 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7440 if (LocaleCompare("scene",option+1) == 0)
7447 image_info->scene=0;
7448 (void) SetImageOption(image_info,option+1,"0");
7451 image_info->scene=StringToUnsignedLong(argv[i+1]);
7452 (void) SetImageOption(image_info,option+1,argv[i+1]);
7455 if (LocaleCompare("seed",option+1) == 0)
7462 seed=(unsigned long) time((time_t *) NULL);
7463 SetRandomSecretKey(seed);
7466 seed=StringToUnsignedLong(argv[i+1]);
7467 SetRandomSecretKey(seed);
7470 if (LocaleCompare("size",option+1) == 0)
7474 if (image_info->size != (char *) NULL)
7475 image_info->size=DestroyString(image_info->size);
7478 (void) CloneString(&image_info->size,argv[i+1]);
7481 if (LocaleCompare("stroke",option+1) == 0)
7485 (void) SetImageOption(image_info,option+1,"none");
7488 (void) SetImageOption(image_info,option+1,argv[i+1]);
7491 if (LocaleCompare("strokewidth",option+1) == 0)
7494 (void) SetImageOption(image_info,option+1,"0");
7496 (void) SetImageOption(image_info,option+1,argv[i+1]);
7499 if (LocaleCompare("style",option+1) == 0)
7503 (void) SetImageOption(image_info,option+1,"none");
7506 (void) SetImageOption(image_info,option+1,argv[i+1]);
7509 if (LocaleCompare("synchronize",option+1) == 0)
7513 image_info->synchronize=MagickFalse;
7516 image_info->synchronize=MagickTrue;
7523 if (LocaleCompare("taint",option+1) == 0)
7527 (void) SetImageOption(image_info,option+1,"false");
7530 (void) SetImageOption(image_info,option+1,"true");
7533 if (LocaleCompare("texture",option+1) == 0)
7537 if (image_info->texture != (char *) NULL)
7538 image_info->texture=DestroyString(image_info->texture);
7541 (void) CloneString(&image_info->texture,argv[i+1]);
7544 if (LocaleCompare("tile-offset",option+1) == 0)
7547 (void) SetImageOption(image_info,option+1,"0");
7549 (void) SetImageOption(image_info,option+1,argv[i+1]);
7552 if (LocaleCompare("transparent-color",option+1) == 0)
7556 (void) QueryColorCompliance("none",AllCompliance,
7557 &image_info->transparent_color,exception);
7558 (void) SetImageOption(image_info,option+1,"none");
7561 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7562 &image_info->transparent_color,exception);
7563 (void) SetImageOption(image_info,option+1,argv[i+1]);
7566 if (LocaleCompare("type",option+1) == 0)
7570 image_info->type=UndefinedType;
7571 (void) SetImageOption(image_info,option+1,"undefined");
7574 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7575 MagickFalse,argv[i+1]);
7576 (void) SetImageOption(image_info,option+1,argv[i+1]);
7583 if (LocaleCompare("undercolor",option+1) == 0)
7586 (void) DeleteImageOption(image_info,option+1);
7588 (void) SetImageOption(image_info,option+1,argv[i+1]);
7591 if (LocaleCompare("units",option+1) == 0)
7595 image_info->units=UndefinedResolution;
7596 (void) SetImageOption(image_info,option+1,"undefined");
7599 image_info->units=(ResolutionType) ParseCommandOption(
7600 MagickResolutionOptions,MagickFalse,argv[i+1]);
7601 (void) SetImageOption(image_info,option+1,argv[i+1]);
7608 if (LocaleCompare("verbose",option+1) == 0)
7612 image_info->verbose=MagickFalse;
7615 image_info->verbose=MagickTrue;
7616 image_info->ping=MagickFalse;
7619 if (LocaleCompare("virtual-pixel",option+1) == 0)
7622 (void) SetImageOption(image_info,option+1,"undefined");
7624 (void) SetImageOption(image_info,option+1,argv[i+1]);
7631 if (LocaleCompare("weight",option+1) == 0)
7634 (void) SetImageOption(image_info,option+1,"0");
7636 (void) SetImageOption(image_info,option+1,argv[i+1]);
7639 if (LocaleCompare("white-point",option+1) == 0)
7642 (void) SetImageOption(image_info,option+1,"0.0");
7644 (void) SetImageOption(image_info,option+1,argv[i+1]);
7658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7662 + M o g r i f y I m a g e L i s t %
7666 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7668 % MogrifyImageList() applies any command line options that might affect the
7669 % entire image list (e.g. -append, -coalesce, etc.).
7671 % The format of the MogrifyImage method is:
7673 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7674 % const char **argv,Image **images,ExceptionInfo *exception)
7676 % A description of each parameter follows:
7678 % o image_info: the image info..
7680 % o argc: Specifies a pointer to an integer describing the number of
7681 % elements in the argument vector.
7683 % o argv: Specifies a pointer to a text array containing the command line
7686 % o images: pointer to pointer of the first image in image list.
7688 % o exception: return any errors or warnings in this structure.
7691 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7692 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7703 PixelInterpolateMethod
7717 Apply options to the image list.
7719 assert(image_info != (ImageInfo *) NULL);
7720 assert(image_info->signature == MagickCoreSignature);
7721 assert(images != (Image **) NULL);
7722 assert((*images)->previous == (Image *) NULL);
7723 assert((*images)->signature == MagickCoreSignature);
7724 if ((*images)->debug != MagickFalse)
7725 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7726 (*images)->filename);
7727 if ((argc <= 0) || (*argv == (char *) NULL))
7729 interpolate_method=UndefinedInterpolatePixel;
7730 mogrify_info=CloneImageInfo(image_info);
7731 quantize_info=AcquireQuantizeInfo(mogrify_info);
7733 for (i=0; i < (ssize_t) argc; i++)
7735 if (*images == (Image *) NULL)
7738 if (IsCommandOption(option) == MagickFalse)
7740 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7741 count=MagickMax(count,0L);
7742 if ((i+count) >= (ssize_t) argc)
7744 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7745 switch (*(option+1))
7749 if (LocaleCompare("affinity",option+1) == 0)
7751 (void) SyncImagesSettings(mogrify_info,*images,exception);
7754 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7761 if (LocaleCompare("append",option+1) == 0)
7766 (void) SyncImagesSettings(mogrify_info,*images,exception);
7767 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7768 MagickFalse,exception);
7769 if (append_image == (Image *) NULL)
7774 *images=DestroyImageList(*images);
7775 *images=append_image;
7778 if (LocaleCompare("average",option+1) == 0)
7784 Average an image sequence (deprecated).
7786 (void) SyncImagesSettings(mogrify_info,*images,exception);
7787 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7789 if (average_image == (Image *) NULL)
7794 *images=DestroyImageList(*images);
7795 *images=average_image;
7802 if (LocaleCompare("channel-fx",option+1) == 0)
7807 (void) SyncImagesSettings(mogrify_info,*images,exception);
7808 channel_image=ChannelFxImage(*images,argv[i+1],exception);
7809 if (channel_image == (Image *) NULL)
7814 *images=DestroyImageList(*images);
7815 *images=channel_image;
7818 if (LocaleCompare("clut",option+1) == 0)
7824 (void) SyncImagesSettings(mogrify_info,*images,exception);
7825 image=RemoveFirstImageFromList(images);
7826 clut_image=RemoveFirstImageFromList(images);
7827 if (clut_image == (Image *) NULL)
7832 (void) ClutImage(image,clut_image,interpolate_method,exception);
7833 clut_image=DestroyImage(clut_image);
7834 *images=DestroyImageList(*images);
7838 if (LocaleCompare("coalesce",option+1) == 0)
7843 (void) SyncImagesSettings(mogrify_info,*images,exception);
7844 coalesce_image=CoalesceImages(*images,exception);
7845 if (coalesce_image == (Image *) NULL)
7850 *images=DestroyImageList(*images);
7851 *images=coalesce_image;
7854 if (LocaleCompare("combine",option+1) == 0)
7862 (void) SyncImagesSettings(mogrify_info,*images,exception);
7863 colorspace=(*images)->colorspace;
7864 if ((*images)->number_channels < GetImageListLength(*images))
7865 colorspace=sRGBColorspace;
7867 colorspace=(ColorspaceType) ParseCommandOption(
7868 MagickColorspaceOptions,MagickFalse,argv[i+1]);
7869 combine_image=CombineImages(*images,colorspace,exception);
7870 if (combine_image == (Image *) NULL)
7875 *images=DestroyImageList(*images);
7876 *images=combine_image;
7879 if (LocaleCompare("compare",option+1) == 0)
7893 Mathematically and visually annotate the difference between an
7894 image and its reconstruction.
7896 (void) SyncImagesSettings(mogrify_info,*images,exception);
7897 image=RemoveFirstImageFromList(images);
7898 reconstruct_image=RemoveFirstImageFromList(images);
7899 if (reconstruct_image == (Image *) NULL)
7904 metric=UndefinedErrorMetric;
7905 option=GetImageOption(mogrify_info,"metric");
7906 if (option != (const char *) NULL)
7907 metric=(MetricType) ParseCommandOption(MagickMetricOptions,
7908 MagickFalse,option);
7909 difference_image=CompareImages(image,reconstruct_image,metric,
7910 &distortion,exception);
7911 if (difference_image == (Image *) NULL)
7913 if (*images != (Image *) NULL)
7914 *images=DestroyImage(*images);
7915 *images=difference_image;
7918 if (LocaleCompare("complex",option+1) == 0)
7926 (void) SyncImageSettings(mogrify_info,*images,exception);
7927 op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
7928 MagickFalse,argv[i+1]);
7929 complex_images=ComplexImages(*images,op,exception);
7930 if (complex_images == (Image *) NULL)
7935 *images=DestroyImageList(*images);
7936 *images=complex_images;
7939 if (LocaleCompare("composite",option+1) == 0)
7958 /* Compose value from "-compose" option only */
7959 (void) SyncImageSettings(mogrify_info,*images,exception);
7960 value=GetImageOption(mogrify_info,"compose");
7961 if (value == (const char *) NULL)
7962 compose=OverCompositeOp; /* use Over not source_image->compose */
7964 compose=(CompositeOperator) ParseCommandOption(
7965 MagickComposeOptions,MagickFalse,value);
7967 /* Get "clip-to-self" expert setting (false is normal) */
7968 clip_to_self=GetCompositeClipToSelf(compose);
7969 value=GetImageOption(mogrify_info,"compose:clip-to-self");
7970 if (value != (const char *) NULL)
7971 clip_to_self=IsStringTrue(value);
7972 value=GetImageOption(mogrify_info,"compose:outside-overlay");
7973 if (value != (const char *) NULL)
7974 clip_to_self=IsStringFalse(value); /* deprecated */
7976 new_images=RemoveFirstImageFromList(images);
7977 source_image=RemoveFirstImageFromList(images);
7978 if (source_image == (Image *) NULL)
7979 break; /* FUTURE - produce Exception, rather than silent fail */
7981 /* FUTURE: this should not be here! - should be part of -geometry */
7982 if (source_image->geometry != (char *) NULL)
7987 (void) ParseRegionGeometry(source_image,source_image->geometry,
7988 &resize_geometry,exception);
7989 if ((source_image->columns != resize_geometry.width) ||
7990 (source_image->rows != resize_geometry.height))
7995 resize_image=ResizeImage(source_image,resize_geometry.width,
7996 resize_geometry.height,source_image->filter,exception);
7997 if (resize_image != (Image *) NULL)
7999 source_image=DestroyImage(source_image);
8000 source_image=resize_image;
8004 SetGeometry(source_image,&geometry);
8005 (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
8006 GravityAdjustGeometry(new_images->columns,new_images->rows,
8007 new_images->gravity,&geometry);
8008 mask_image=RemoveFirstImageFromList(images);
8009 if (mask_image == (Image *) NULL)
8010 status&=CompositeImage(new_images,source_image,compose,
8011 clip_to_self,geometry.x,geometry.y,exception);
8014 if ((compose == DisplaceCompositeOp) ||
8015 (compose == DistortCompositeOp))
8017 status&=CompositeImage(source_image,mask_image,
8018 CopyGreenCompositeOp,MagickTrue,0,0,exception);
8019 status&=CompositeImage(new_images,source_image,compose,
8020 clip_to_self,geometry.x,geometry.y,exception);
8027 clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
8028 if (clone_image == (Image *) NULL)
8030 status&=CompositeImage(new_images,source_image,compose,
8031 clip_to_self,geometry.x,geometry.y,exception);
8032 status&=CompositeImage(new_images,mask_image,
8033 CopyAlphaCompositeOp,MagickTrue,0,0,exception);
8034 status&=CompositeImage(clone_image,new_images,
8035 OverCompositeOp,clip_to_self,0,0,exception);
8036 new_images=DestroyImage(new_images);
8037 new_images=clone_image;
8039 mask_image=DestroyImage(mask_image);
8041 source_image=DestroyImage(source_image);
8042 *images=DestroyImageList(*images);
8047 if (LocaleCompare("copy",option+1) == 0)
8061 (void) SyncImageSettings(mogrify_info,*images,exception);
8062 (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
8063 offset.x=geometry.x;
8064 offset.y=geometry.y;
8065 source_image=(*images);
8066 if (source_image->next != (Image *) NULL)
8067 source_image=source_image->next;
8068 (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
8070 status=CopyImagePixels(*images,source_image,&geometry,&offset,
8078 if (LocaleCompare("deconstruct",option+1) == 0)
8083 (void) SyncImagesSettings(mogrify_info,*images,exception);
8084 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
8086 if (deconstruct_image == (Image *) NULL)
8091 *images=DestroyImageList(*images);
8092 *images=deconstruct_image;
8095 if (LocaleCompare("delete",option+1) == 0)
8098 DeleteImages(images,"-1",exception);
8100 DeleteImages(images,argv[i+1],exception);
8103 if (LocaleCompare("dither",option+1) == 0)
8107 quantize_info->dither_method=NoDitherMethod;
8110 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
8111 MagickDitherOptions,MagickFalse,argv[i+1]);
8114 if (LocaleCompare("duplicate",option+1) == 0)
8120 duplicate_images=DuplicateImages(*images,1,"-1",exception);
8129 number_duplicates=(size_t) StringToLong(argv[i+1]);
8130 p=strchr(argv[i+1],',');
8131 if (p == (const char *) NULL)
8132 duplicate_images=DuplicateImages(*images,number_duplicates,
8135 duplicate_images=DuplicateImages(*images,number_duplicates,p,
8138 AppendImageToList(images, duplicate_images);
8139 (void) SyncImagesSettings(mogrify_info,*images,exception);
8146 if (LocaleCompare("evaluate-sequence",option+1) == 0)
8151 MagickEvaluateOperator
8154 (void) SyncImageSettings(mogrify_info,*images,exception);
8155 op=(MagickEvaluateOperator) ParseCommandOption(
8156 MagickEvaluateOptions,MagickFalse,argv[i+1]);
8157 evaluate_image=EvaluateImages(*images,op,exception);
8158 if (evaluate_image == (Image *) NULL)
8163 *images=DestroyImageList(*images);
8164 *images=evaluate_image;
8171 if (LocaleCompare("fft",option+1) == 0)
8177 Implements the discrete Fourier transform (DFT).
8179 (void) SyncImageSettings(mogrify_info,*images,exception);
8180 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
8181 MagickTrue : MagickFalse,exception);
8182 if (fourier_image == (Image *) NULL)
8184 *images=DestroyImage(*images);
8185 *images=fourier_image;
8188 if (LocaleCompare("flatten",option+1) == 0)
8193 (void) SyncImagesSettings(mogrify_info,*images,exception);
8194 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
8195 if (flatten_image == (Image *) NULL)
8197 *images=DestroyImageList(*images);
8198 *images=flatten_image;
8201 if (LocaleCompare("fx",option+1) == 0)
8206 (void) SyncImagesSettings(mogrify_info,*images,exception);
8207 fx_image=FxImage(*images,argv[i+1],exception);
8208 if (fx_image == (Image *) NULL)
8213 *images=DestroyImageList(*images);
8221 if (LocaleCompare("hald-clut",option+1) == 0)
8227 (void) SyncImagesSettings(mogrify_info,*images,exception);
8228 image=RemoveFirstImageFromList(images);
8229 hald_image=RemoveFirstImageFromList(images);
8230 if (hald_image == (Image *) NULL)
8235 (void) HaldClutImage(image,hald_image,exception);
8236 hald_image=DestroyImage(hald_image);
8237 if (*images != (Image *) NULL)
8238 *images=DestroyImageList(*images);
8246 if (LocaleCompare("ift",option+1) == 0)
8254 Implements the inverse fourier discrete Fourier transform (DFT).
8256 (void) SyncImagesSettings(mogrify_info,*images,exception);
8257 magnitude_image=RemoveFirstImageFromList(images);
8258 phase_image=RemoveFirstImageFromList(images);
8259 if (phase_image == (Image *) NULL)
8264 fourier_image=InverseFourierTransformImage(magnitude_image,
8265 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
8266 if (fourier_image == (Image *) NULL)
8268 if (*images != (Image *) NULL)
8269 *images=DestroyImage(*images);
8270 *images=fourier_image;
8273 if (LocaleCompare("insert",option+1) == 0)
8281 index=(ssize_t) StringToLong(argv[i+1]);
8282 p=RemoveLastImageFromList(images);
8283 if (p == (Image *) NULL)
8285 (void) ThrowMagickException(exception,GetMagickModule(),
8286 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8292 PrependImageToList(images,q);
8294 if (index == (ssize_t) GetImageListLength(*images))
8295 AppendImageToList(images,q);
8298 q=GetImageFromList(*images,index-1);
8299 if (q == (Image *) NULL)
8301 (void) ThrowMagickException(exception,GetMagickModule(),
8302 OptionError,"NoSuchImage","`%s'",argv[i+1]);
8306 InsertImageInList(&q,p);
8308 *images=GetFirstImageInList(q);
8311 if (LocaleCompare("interpolate",option+1) == 0)
8313 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
8314 MagickInterpolateOptions,MagickFalse,argv[i+1]);
8321 if (LocaleCompare("layers",option+1) == 0)
8329 (void) SyncImagesSettings(mogrify_info,*images,exception);
8330 layers=(Image *) NULL;
8331 method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
8332 MagickFalse,argv[i+1]);
8337 layers=CoalesceImages(*images,exception);
8340 case CompareAnyLayer:
8341 case CompareClearLayer:
8342 case CompareOverlayLayer:
8345 layers=CompareImagesLayers(*images,method,exception);
8351 case TrimBoundsLayer:
8353 layers=MergeImageLayers(*images,method,exception);
8358 layers=DisposeImages(*images,exception);
8361 case OptimizeImageLayer:
8363 layers=OptimizeImageLayers(*images,exception);
8366 case OptimizePlusLayer:
8368 layers=OptimizePlusImageLayers(*images,exception);
8371 case OptimizeTransLayer:
8373 OptimizeImageTransparency(*images,exception);
8376 case RemoveDupsLayer:
8378 RemoveDuplicateLayers(images,exception);
8381 case RemoveZeroLayer:
8383 RemoveZeroDelayLayers(images,exception);
8389 General Purpose, GIF Animation Optimizer.
8391 layers=CoalesceImages(*images,exception);
8392 if (layers == (Image *) NULL)
8397 *images=DestroyImageList(*images);
8399 layers=OptimizeImageLayers(*images,exception);
8400 if (layers == (Image *) NULL)
8405 *images=DestroyImageList(*images);
8407 layers=(Image *) NULL;
8408 OptimizeImageTransparency(*images,exception);
8409 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8413 case CompositeLayer:
8425 Split image sequence at the first 'NULL:' image.
8428 while (source != (Image *) NULL)
8430 source=GetNextImageInList(source);
8431 if ((source != (Image *) NULL) &&
8432 (LocaleCompare(source->magick,"NULL") == 0))
8435 if (source != (Image *) NULL)
8437 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
8438 (GetNextImageInList(source) == (Image *) NULL))
8439 source=(Image *) NULL;
8443 Separate the two lists, junk the null: image.
8445 source=SplitImageList(source->previous);
8446 DeleteImageFromList(&source);
8449 if (source == (Image *) NULL)
8451 (void) ThrowMagickException(exception,GetMagickModule(),
8452 OptionError,"MissingNullSeparator","layers Composite");
8457 Adjust offset with gravity and virtual canvas.
8459 SetGeometry(*images,&geometry);
8460 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
8461 geometry.width=source->page.width != 0 ?
8462 source->page.width : source->columns;
8463 geometry.height=source->page.height != 0 ?
8464 source->page.height : source->rows;
8465 GravityAdjustGeometry((*images)->page.width != 0 ?
8466 (*images)->page.width : (*images)->columns,
8467 (*images)->page.height != 0 ? (*images)->page.height :
8468 (*images)->rows,(*images)->gravity,&geometry);
8469 compose=OverCompositeOp;
8470 option=GetImageOption(mogrify_info,"compose");
8471 if (option != (const char *) NULL)
8472 compose=(CompositeOperator) ParseCommandOption(
8473 MagickComposeOptions,MagickFalse,option);
8474 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
8476 source=DestroyImageList(source);
8480 if (layers == (Image *) NULL)
8482 *images=DestroyImageList(*images);
8490 if (LocaleCompare("map",option+1) == 0)
8492 (void) SyncImagesSettings(mogrify_info,*images,exception);
8495 (void) RemapImages(quantize_info,*images,(Image *) NULL,
8502 if (LocaleCompare("maximum",option+1) == 0)
8508 Maximum image sequence (deprecated).
8510 (void) SyncImagesSettings(mogrify_info,*images,exception);
8511 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
8512 if (maximum_image == (Image *) NULL)
8517 *images=DestroyImageList(*images);
8518 *images=maximum_image;
8521 if (LocaleCompare("minimum",option+1) == 0)
8527 Minimum image sequence (deprecated).
8529 (void) SyncImagesSettings(mogrify_info,*images,exception);
8530 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
8531 if (minimum_image == (Image *) NULL)
8536 *images=DestroyImageList(*images);
8537 *images=minimum_image;
8540 if (LocaleCompare("morph",option+1) == 0)
8545 (void) SyncImagesSettings(mogrify_info,*images,exception);
8546 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
8548 if (morph_image == (Image *) NULL)
8553 *images=DestroyImageList(*images);
8554 *images=morph_image;
8557 if (LocaleCompare("mosaic",option+1) == 0)
8562 (void) SyncImagesSettings(mogrify_info,*images,exception);
8563 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8564 if (mosaic_image == (Image *) NULL)
8569 *images=DestroyImageList(*images);
8570 *images=mosaic_image;
8577 if (LocaleCompare("poly",option+1) == 0)
8581 token[MagickPathExtent];
8601 (void) SyncImageSettings(mogrify_info,*images,exception);
8602 args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8604 if (args == (char *) NULL)
8607 for (x=0; *p != '\0'; x++)
8609 GetNextToken(p,&p,MagickPathExtent,token);
8611 GetNextToken(p,&p,MagickPathExtent,token);
8613 number_arguments=(size_t) x;
8614 arguments=(double *) AcquireQuantumMemory(number_arguments,
8615 sizeof(*arguments));
8616 if (arguments == (double *) NULL)
8617 ThrowWandFatalException(ResourceLimitFatalError,
8618 "MemoryAllocationFailed",(*images)->filename);
8619 (void) memset(arguments,0,number_arguments*
8620 sizeof(*arguments));
8622 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
8624 GetNextToken(p,&p,MagickPathExtent,token);
8626 GetNextToken(p,&p,MagickPathExtent,token);
8627 arguments[x]=StringToDouble(token,(char **) NULL);
8629 args=DestroyString(args);
8630 polynomial_image=PolynomialImage(*images,number_arguments >> 1,
8631 arguments,exception);
8632 arguments=(double *) RelinquishMagickMemory(arguments);
8633 if (polynomial_image == (Image *) NULL)
8638 *images=DestroyImageList(*images);
8639 *images=polynomial_image;
8641 if (LocaleCompare("print",option+1) == 0)
8646 (void) SyncImagesSettings(mogrify_info,*images,exception);
8647 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8649 if (string == (char *) NULL)
8651 (void) FormatLocaleFile(stdout,"%s",string);
8652 string=DestroyString(string);
8654 if (LocaleCompare("process",option+1) == 0)
8663 (void) SyncImagesSettings(mogrify_info,*images,exception);
8664 arguments=StringToArgv(argv[i+1],&number_arguments);
8665 if (arguments == (char **) NULL)
8667 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8688 Support old style syntax, filter="-option arg".
8690 length=strlen(argv[i+1]);
8691 token=(char *) NULL;
8692 if (~length >= (MagickPathExtent-1))
8693 token=(char *) AcquireQuantumMemory(length+MagickPathExtent,
8695 if (token == (char *) NULL)
8699 token_info=AcquireTokenInfo();
8700 token_status=Tokenizer(token_info,0,token,length,argument,"",
8701 "=","\"",'\0',&breaker,&next,"e);
8702 token_info=DestroyTokenInfo(token_info);
8703 if (token_status == 0)
8708 arg=(&(argument[next]));
8709 (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
8712 token=DestroyString(token);
8715 (void) SubstituteString(&arguments[1],"-","");
8716 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8717 number_arguments-2,(const char **) arguments+2,exception);
8718 for (j=0; j < number_arguments; j++)
8719 arguments[j]=DestroyString(arguments[j]);
8720 arguments=(char **) RelinquishMagickMemory(arguments);
8727 if (LocaleCompare("reverse",option+1) == 0)
8729 ReverseImageList(images);
8736 if (LocaleCompare("smush",option+1) == 0)
8744 (void) SyncImagesSettings(mogrify_info,*images,exception);
8745 offset=(ssize_t) StringToLong(argv[i+1]);
8746 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8747 MagickFalse,offset,exception);
8748 if (smush_image == (Image *) NULL)
8753 *images=DestroyImageList(*images);
8754 *images=smush_image;
8757 if (LocaleCompare("swap",option+1) == 0)
8779 flags=ParseGeometry(argv[i+1],&geometry_info);
8780 index=(ssize_t) geometry_info.rho;
8781 if ((flags & SigmaValue) != 0)
8782 swap_index=(ssize_t) geometry_info.sigma;
8784 p=GetImageFromList(*images,index);
8785 q=GetImageFromList(*images,swap_index);
8786 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8788 (void) ThrowMagickException(exception,GetMagickModule(),
8789 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8795 u=CloneImage(p,0,0,MagickTrue,exception);
8796 if (u == (Image *) NULL)
8798 v=CloneImage(q,0,0,MagickTrue,exception);
8799 if (v == (Image *) NULL)
8804 ReplaceImageInList(&p,v);
8805 ReplaceImageInList(&q,u);
8806 *images=GetFirstImageInList(q);
8813 if (LocaleCompare("write",option+1) == 0)
8816 key[MagickPathExtent];
8824 (void) SyncImagesSettings(mogrify_info,*images,exception);
8825 (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",
8827 (void) DeleteImageRegistry(key);
8828 write_images=(*images);
8830 write_images=CloneImageList(*images,exception);
8831 write_info=CloneImageInfo(mogrify_info);
8832 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8833 write_info=DestroyImageInfo(write_info);
8835 write_images=DestroyImageList(write_images);
8845 quantize_info=DestroyQuantizeInfo(quantize_info);
8846 mogrify_info=DestroyImageInfo(mogrify_info);
8847 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8848 return(status != 0 ? MagickTrue : MagickFalse);
8852 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8856 + M o g r i f y I m a g e s %
8860 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8862 % MogrifyImages() applies image processing options to a sequence of images as
8863 % prescribed by command line options.
8865 % The format of the MogrifyImage method is:
8867 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8868 % const MagickBooleanType post,const int argc,const char **argv,
8869 % Image **images,Exceptioninfo *exception)
8871 % A description of each parameter follows:
8873 % o image_info: the image info..
8875 % o post: If true, post process image list operators otherwise pre-process.
8877 % o argc: Specifies a pointer to an integer describing the number of
8878 % elements in the argument vector.
8880 % o argv: Specifies a pointer to a text array containing the command line
8883 % o images: pointer to a pointer of the first image in image list.
8885 % o exception: return any errors or warnings in this structure.
8888 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8889 const MagickBooleanType post,const int argc,const char **argv,
8890 Image **images,ExceptionInfo *exception)
8892 #define MogrifyImageTag "Mogrify/Image"
8906 assert(image_info != (ImageInfo *) NULL);
8907 assert(image_info->signature == MagickCoreSignature);
8908 if (images == (Image **) NULL)
8909 return(MogrifyImage(image_info,argc,argv,images,exception));
8910 assert((*images)->previous == (Image *) NULL);
8911 assert((*images)->signature == MagickCoreSignature);
8912 if ((*images)->debug != MagickFalse)
8913 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8914 (*images)->filename);
8915 if ((argc <= 0) || (*argv == (char *) NULL))
8917 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8921 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8925 Pre-process multi-image sequence operators
8927 if (post == MagickFalse)
8928 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8930 For each image, process simple single image operators
8933 n=GetImageListLength(*images);
8937 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8938 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8940 status&=MogrifyImage(image_info,argc,argv,images,exception);
8941 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8942 if (proceed == MagickFalse)
8944 if ( (*images)->next == (Image *) NULL )
8946 *images=(*images)->next;
8949 assert( *images != (Image *) NULL );
8951 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8952 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8955 Post-process, multi-image sequence operators
8957 *images=GetFirstImageInList(*images);
8958 if (post != MagickFalse)
8959 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8960 return(status != 0 ? MagickTrue : MagickFalse);