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-2012 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the mogrify program to resize an image, blur, crop, despeckle, dither,
37 % draw on, flip, join, re-sample, and much more. This tool is similiar to
38 % convert except that the original image file is overwritten (unless you
39 % change the file suffix with the -format option) with any changes you
47 #include "MagickWand/studio.h"
48 #include "MagickWand/MagickWand.h"
49 #include "MagickWand/mogrify-private.h"
50 #undef DegreesToRadians
51 #undef RadiansToDegrees
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"
62 MogrifyBackgroundColor[] = "#ffffff", /* white */
63 MogrifyBorderColor[] = "#dfdfdf", /* gray */
64 MogrifyMatteColor[] = "#bdbdbd"; /* gray */
69 #define UndefinedCompressionQuality 0UL
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % M a g i c k C o m m a n d G e n e s i s %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 % MagickCommandGenesis() applies image processing options to an image as
83 % prescribed by command line options.
85 % The format of the MagickCommandGenesis method is:
87 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
88 % MagickCommand command,int argc,char **argv,char **metadata,
89 % ExceptionInfo *exception)
91 % A description of each parameter follows:
93 % o image_info: the image info.
95 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
96 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
97 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
98 % DisplayImageCommand, or AnimateImageCommand.
100 % o argc: Specifies a pointer to an integer describing the number of
101 % elements in the argument vector.
103 % o argv: Specifies a pointer to a text array containing the command line
106 % o metadata: any metadata is returned here.
108 % o exception: return any errors or warnings in this structure.
112 static inline double MagickMin(const double x,const double y)
119 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
120 MagickCommand command,int argc,char **argv,char **metadata,
121 ExceptionInfo *exception)
143 (void) setlocale(LC_ALL,"");
144 (void) setlocale(LC_NUMERIC,"C");
145 concurrent=MagickFalse;
149 regard_warnings=MagickFalse;
150 for (i=1; i < (ssize_t) (argc-1); i++)
153 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
155 if (LocaleCompare("bench",option+1) == 0)
156 iterations=StringToUnsignedLong(argv[++i]);
157 if (LocaleCompare("concurrent",option+1) == 0)
158 concurrent=MagickTrue;
159 if (LocaleCompare("debug",option+1) == 0)
160 (void) SetLogEventMask(argv[++i]);
161 if (LocaleCompare("duration",option+1) == 0)
162 duration=StringToDouble(argv[++i],(char **) NULL);
163 if (LocaleCompare("regard-warnings",option+1) == 0)
164 regard_warnings=MagickTrue;
168 status=command(image_info,argc,argv,metadata,exception);
169 if (exception->severity != UndefinedException)
171 if ((exception->severity > ErrorException) ||
172 (regard_warnings != MagickFalse))
174 CatchException(exception);
176 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
178 (void) fputs(*metadata,stdout);
179 (void) fputc('\n',stdout);
180 *metadata=DestroyString(*metadata);
184 number_threads=GetOpenMPMaximumThreads();
186 for (n=1; n <= number_threads; n++)
196 SetOpenMPMaximumThreads(n);
197 timer=AcquireTimerInfo();
198 if (concurrent == MagickFalse)
200 for (i=0; i < (ssize_t) iterations; i++)
202 if (status != MagickFalse)
206 if (GetElapsedTime(timer) > duration)
208 (void) ContinueTimer(timer);
210 status=command(image_info,argc,argv,metadata,exception);
211 if (exception->severity != UndefinedException)
213 if ((exception->severity > ErrorException) ||
214 (regard_warnings != MagickFalse))
216 CatchException(exception);
218 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
220 (void) fputs(*metadata,stdout);
221 (void) fputc('\n',stdout);
222 *metadata=DestroyString(*metadata);
229 #if defined(MAGICKCORE_OPENMP_SUPPORT)
230 # pragma omp parallel for shared(status)
232 for (i=0; i < (ssize_t) iterations; i++)
234 if (status != MagickFalse)
238 if (GetElapsedTime(timer) > duration)
240 (void) ContinueTimer(timer);
242 status=command(image_info,argc,argv,metadata,exception);
243 #if defined(MAGICKCORE_OPENMP_SUPPORT)
244 # pragma omp critical (MagickCore_CommandGenesis)
247 if (exception->severity != UndefinedException)
249 if ((exception->severity > ErrorException) ||
250 (regard_warnings != MagickFalse))
252 CatchException(exception);
254 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
256 (void) fputs(*metadata,stdout);
257 (void) fputc('\n',stdout);
258 *metadata=DestroyString(*metadata);
263 user_time=GetUserTime(timer);
264 parallel=GetElapsedTime(timer);
269 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/
270 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n);
271 (void) FormatLocaleFile(stderr,
272 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n",
273 (double) n,(double) iterations,(double) iterations/parallel,e,
274 user_time,(unsigned long) (parallel/60.0),(unsigned long)
275 floor(fmod(parallel,60.0)),(unsigned long)
276 (1000.0*(parallel-floor(parallel))+0.5));
277 timer=DestroyTimerInfo(timer);
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 + M o g r i f y I m a g e %
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 % MogrifyImage() applies simple single image processing options to a single
294 % image that may be part of a large list, but also handles any 'region'
297 % The image in the list may be modified in three different ways...
299 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
300 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
301 % * replace by a list of images (only the -separate option!)
303 % In each case the result is returned into the list, and a pointer to the
304 % modified image (last image added if replaced by a list of images) is
307 % ASIDE: The -crop is present but restricted to non-tile single image crops
309 % This means if all the images are being processed (such as by
310 % MogrifyImages(), next image to be processed will be as per the pointer
311 % (*image)->next. Also the image list may grow as a result of some specific
312 % operations but as images are never merged or deleted, it will never shrink
313 % in length. Typically the list will remain the same length.
315 % WARNING: As the image pointed to may be replaced, the first image in the
316 % list may also change. GetFirstImageInList() should be used by caller if
317 % they wish return the Image pointer to the first image in list.
320 % The format of the MogrifyImage method is:
322 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
323 % const char **argv,Image **image)
325 % A description of each parameter follows:
327 % o image_info: the image info..
329 % o argc: Specifies a pointer to an integer describing the number of
330 % elements in the argument vector.
332 % o argv: Specifies a pointer to a text array containing the command line
335 % o image: the image.
337 % o exception: return any errors or warnings in this structure.
341 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
342 ExceptionInfo *exception)
357 Read an image into a image cache if not already present. Return the image
358 that is in the cache under that filename.
360 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
361 sans_exception=AcquireExceptionInfo();
362 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
363 sans_exception=DestroyExceptionInfo(sans_exception);
364 if (image != (Image *) NULL)
366 read_info=CloneImageInfo(image_info);
367 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
368 image=ReadImage(read_info,exception);
369 read_info=DestroyImageInfo(read_info);
370 if (image != (Image *) NULL)
371 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
375 static MagickBooleanType IsPathWritable(const char *path)
377 if (IsPathAccessible(path) == MagickFalse)
379 if (access_utf8(path,W_OK) != 0)
384 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
391 static MagickBooleanType MonitorProgress(const char *text,
392 const MagickOffsetType offset,const MagickSizeType extent,
393 void *wand_unused(client_data))
396 message[MaxTextExtent],
407 (void) CopyMagickMemory(tag,text,MaxTextExtent);
409 if (p != (char *) NULL)
411 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
412 locale_message=GetLocaleMessage(message);
413 if (locale_message == message)
415 if (p == (char *) NULL)
416 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
417 locale_message,(long) offset,(unsigned long) extent,(long)
418 (100L*offset/(extent-1)));
420 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
421 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
422 (100L*offset/(extent-1)));
423 if (offset == (MagickOffsetType) (extent-1))
424 (void) FormatLocaleFile(stderr,"\n");
425 (void) fflush(stderr);
429 static Image *SparseColorOption(const Image *image,
430 const SparseColorMethod method,const char *arguments,
431 const MagickBooleanType color_from_image,ExceptionInfo *exception)
434 token[MaxTextExtent];
459 SparseColorOption() parses the complex -sparse-color argument into an an
460 array of floating point values then calls SparseColorImage(). Argument is
461 a complex mix of floating-point pixel coodinates, and color specifications
462 (or direct floating point numbers). The number of floats needed to
463 represent a color varies depending on the current channel setting.
465 assert(image != (Image *) NULL);
466 assert(image->signature == MagickSignature);
467 if (image->debug != MagickFalse)
468 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
469 assert(exception != (ExceptionInfo *) NULL);
470 assert(exception->signature == MagickSignature);
472 Limit channels according to image - and add up number of color channel.
475 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
477 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
479 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
481 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
482 (image->colorspace == CMYKColorspace))
484 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
485 (image->matte != MagickFalse))
489 Read string, to determine number of arguments needed,
495 GetMagickToken(p,&p,token);
496 if ( token[0] == ',' ) continue;
497 if ( isalpha((int) token[0]) || token[0] == '#' ) {
498 if ( color_from_image ) {
499 (void) ThrowMagickException(exception,GetMagickModule(),
500 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
501 "Color arg given, when colors are coming from image");
502 return( (Image *)NULL);
504 x += number_colors; /* color argument */
507 x++; /* floating point argument */
511 if ( color_from_image ) {
512 /* just the control points are being given */
513 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
514 number_arguments=(x/2)*(2+number_colors);
517 /* control points and color values */
518 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
522 (void) ThrowMagickException(exception,GetMagickModule(),
523 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
524 "Invalid number of Arguments");
525 return( (Image *)NULL);
528 /* Allocate and fill in the floating point arguments */
529 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
530 sizeof(*sparse_arguments));
531 if (sparse_arguments == (double *) NULL) {
532 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
533 "MemoryAllocationFailed","%s","SparseColorOption");
534 return( (Image *)NULL);
536 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
537 sizeof(*sparse_arguments));
540 while( *p != '\0' && x < number_arguments ) {
542 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
543 if ( token[0] == '\0' ) break;
544 if ( isalpha((int) token[0]) || token[0] == '#' ) {
545 (void) ThrowMagickException(exception,GetMagickModule(),
546 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
547 "Color found, instead of X-coord");
551 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
553 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
554 if ( token[0] == '\0' ) break;
555 if ( isalpha((int) token[0]) || token[0] == '#' ) {
556 (void) ThrowMagickException(exception,GetMagickModule(),
557 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
558 "Color found, instead of Y-coord");
562 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
563 /* color values for this control point */
565 if ( (color_from_image ) {
566 /* get color from image */
572 /* color name or function given in string argument */
573 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
574 if ( token[0] == '\0' ) break;
575 if ( isalpha((int) token[0]) || token[0] == '#' ) {
576 /* Color string given */
577 (void) QueryColorCompliance(token,AllCompliance,&color,exception);
578 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
579 sparse_arguments[x++] = QuantumScale*color.red;
580 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
581 sparse_arguments[x++] = QuantumScale*color.green;
582 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
583 sparse_arguments[x++] = QuantumScale*color.blue;
584 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
585 (image->colorspace == CMYKColorspace))
586 sparse_arguments[x++] = QuantumScale*color.black;
587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
588 (image->matte != MagickFalse))
589 sparse_arguments[x++] = QuantumScale*color.alpha;
592 /* Colors given as a set of floating point values - experimental */
593 /* NB: token contains the first floating point value to use! */
594 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
596 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
597 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
599 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
600 token[0] = ','; /* used this token - get another */
602 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
604 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
605 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
607 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
608 token[0] = ','; /* used this token - get another */
610 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
612 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
613 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
615 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
616 token[0] = ','; /* used this token - get another */
618 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
619 (image->colorspace == CMYKColorspace))
621 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
622 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
624 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
625 token[0] = ','; /* used this token - get another */
627 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
628 (image->matte != MagickFalse))
630 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
631 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
633 sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
634 token[0] = ','; /* used this token - get another */
639 if ( number_arguments != x && !error ) {
640 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
641 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
642 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
643 return( (Image *)NULL);
646 return( (Image *)NULL);
648 /* Call the Interpolation function with the parsed arguments */
649 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
651 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
652 return( sparse_image );
655 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
656 const char **argv,Image **image,ExceptionInfo *exception)
692 PixelInterpolateMethod
706 Initialize method variables.
708 assert(image_info != (const ImageInfo *) NULL);
709 assert(image_info->signature == MagickSignature);
710 assert(image != (Image **) NULL);
711 assert((*image)->signature == MagickSignature);
712 if ((*image)->debug != MagickFalse)
713 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
716 mogrify_info=CloneImageInfo(image_info);
717 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
718 quantize_info=AcquireQuantizeInfo(mogrify_info);
719 SetGeometryInfo(&geometry_info);
720 GetPixelInfo(*image,&fill);
721 fill=(*image)->background_color;
723 compose=(*image)->compose;
724 interpolate_method=UndefinedInterpolatePixel;
725 channel=mogrify_info->channel;
726 format=GetImageOption(mogrify_info,"format");
727 SetGeometry(*image,®ion_geometry);
728 region_image=NewImageList();
730 Transmogrify the image.
732 for (i=0; i < (ssize_t) argc; i++)
741 if (IsCommandOption(option) == MagickFalse)
743 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
745 if ((i+count) >= (ssize_t) argc)
747 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
748 mogrify_image=(Image *)NULL;
753 if (LocaleCompare("adaptive-blur",option+1) == 0)
758 (void) SyncImageSettings(mogrify_info,*image,exception);
759 flags=ParseGeometry(argv[i+1],&geometry_info);
760 if ((flags & SigmaValue) == 0)
761 geometry_info.sigma=1.0;
762 if ((flags & XiValue) == 0)
763 geometry_info.xi=0.0;
764 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
765 geometry_info.sigma,geometry_info.xi,exception);
768 if (LocaleCompare("adaptive-resize",option+1) == 0)
771 Adaptive resize image.
773 (void) SyncImageSettings(mogrify_info,*image,exception);
774 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
775 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
776 geometry.height,interpolate_method,exception);
779 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
782 Adaptive sharpen image.
784 (void) SyncImageSettings(mogrify_info,*image,exception);
785 flags=ParseGeometry(argv[i+1],&geometry_info);
786 if ((flags & SigmaValue) == 0)
787 geometry_info.sigma=1.0;
788 if ((flags & XiValue) == 0)
789 geometry_info.xi=0.0;
790 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
791 geometry_info.sigma,geometry_info.xi,exception);
794 if (LocaleCompare("affine",option+1) == 0)
801 GetAffineMatrix(&draw_info->affine);
804 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
807 if (LocaleCompare("alpha",option+1) == 0)
812 (void) SyncImageSettings(mogrify_info,*image,exception);
813 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
814 MagickFalse,argv[i+1]);
815 (void) SetImageAlphaChannel(*image,alpha_type,exception);
818 if (LocaleCompare("annotate",option+1) == 0)
822 geometry[MaxTextExtent];
827 (void) SyncImageSettings(mogrify_info,*image,exception);
828 SetGeometryInfo(&geometry_info);
829 flags=ParseGeometry(argv[i+1],&geometry_info);
830 if ((flags & SigmaValue) == 0)
831 geometry_info.sigma=geometry_info.rho;
832 text=InterpretImageProperties(mogrify_info,*image,argv[i+2],
834 if (text == (char *) NULL)
836 (void) CloneString(&draw_info->text,text);
837 text=DestroyString(text);
838 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
839 geometry_info.xi,geometry_info.psi);
840 (void) CloneString(&draw_info->geometry,geometry);
841 draw_info->affine.sx=cos(DegreesToRadians(
842 fmod(geometry_info.rho,360.0)));
843 draw_info->affine.rx=sin(DegreesToRadians(
844 fmod(geometry_info.rho,360.0)));
845 draw_info->affine.ry=(-sin(DegreesToRadians(
846 fmod(geometry_info.sigma,360.0))));
847 draw_info->affine.sy=cos(DegreesToRadians(
848 fmod(geometry_info.sigma,360.0)));
849 (void) AnnotateImage(*image,draw_info,exception);
852 if (LocaleCompare("antialias",option+1) == 0)
854 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
856 draw_info->text_antialias=(*option == '-') ? MagickTrue :
860 if (LocaleCompare("attenuate",option+1) == 0)
867 attenuate=StringToDouble(argv[i+1],(char **) NULL);
870 if (LocaleCompare("auto-gamma",option+1) == 0)
873 Auto Adjust Gamma of image based on its mean
875 (void) SyncImageSettings(mogrify_info,*image,exception);
876 (void) AutoGammaImage(*image,exception);
879 if (LocaleCompare("auto-level",option+1) == 0)
882 Perfectly Normalize (max/min stretch) the image
884 (void) SyncImageSettings(mogrify_info,*image,exception);
885 (void) AutoLevelImage(*image,exception);
888 if (LocaleCompare("auto-orient",option+1) == 0)
890 (void) SyncImageSettings(mogrify_info,*image,exception);
891 switch ((*image)->orientation)
893 case TopRightOrientation:
895 mogrify_image=FlopImage(*image,exception);
898 case BottomRightOrientation:
900 mogrify_image=RotateImage(*image,180.0,exception);
903 case BottomLeftOrientation:
905 mogrify_image=FlipImage(*image,exception);
908 case LeftTopOrientation:
910 mogrify_image=TransposeImage(*image,exception);
913 case RightTopOrientation:
915 mogrify_image=RotateImage(*image,90.0,exception);
918 case RightBottomOrientation:
920 mogrify_image=TransverseImage(*image,exception);
923 case LeftBottomOrientation:
925 mogrify_image=RotateImage(*image,270.0,exception);
931 if (mogrify_image != (Image *) NULL)
932 mogrify_image->orientation=TopLeftOrientation;
939 if (LocaleCompare("black-threshold",option+1) == 0)
942 Black threshold image.
944 (void) SyncImageSettings(mogrify_info,*image,exception);
945 (void) BlackThresholdImage(*image,argv[i+1],exception);
948 if (LocaleCompare("blue-shift",option+1) == 0)
953 (void) SyncImageSettings(mogrify_info,*image,exception);
954 geometry_info.rho=1.5;
956 flags=ParseGeometry(argv[i+1],&geometry_info);
957 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
960 if (LocaleCompare("blur",option+1) == 0)
965 (void) SyncImageSettings(mogrify_info,*image,exception);
966 flags=ParseGeometry(argv[i+1],&geometry_info);
967 if ((flags & SigmaValue) == 0)
968 geometry_info.sigma=1.0;
969 if ((flags & XiValue) == 0)
970 geometry_info.xi=0.0;
971 mogrify_image=BlurImage(*image,geometry_info.rho,
972 geometry_info.sigma,geometry_info.xi,exception);
975 if (LocaleCompare("border",option+1) == 0)
978 Surround image with a border of solid color.
980 (void) SyncImageSettings(mogrify_info,*image,exception);
981 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
982 if ((flags & SigmaValue) == 0)
983 geometry.height=geometry.width;
984 mogrify_image=BorderImage(*image,&geometry,compose,exception);
987 if (LocaleCompare("bordercolor",option+1) == 0)
991 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
992 &draw_info->border_color,exception);
995 (void) QueryColorCompliance(argv[i+1],AllCompliance,
996 &draw_info->border_color,exception);
999 if (LocaleCompare("box",option+1) == 0)
1001 (void) QueryColorCompliance(argv[i+1],AllCompliance,
1002 &draw_info->undercolor,exception);
1005 if (LocaleCompare("brightness-contrast",option+1) == 0)
1018 Brightness / contrast image.
1020 (void) SyncImageSettings(mogrify_info,*image,exception);
1021 flags=ParseGeometry(argv[i+1],&geometry_info);
1022 brightness=geometry_info.rho;
1024 if ((flags & SigmaValue) != 0)
1025 contrast=geometry_info.sigma;
1026 (void) BrightnessContrastImage(*image,brightness,contrast,
1034 if (LocaleCompare("cdl",option+1) == 0)
1037 *color_correction_collection;
1040 Color correct with a color decision list.
1042 (void) SyncImageSettings(mogrify_info,*image,exception);
1043 color_correction_collection=FileToString(argv[i+1],~0,exception);
1044 if (color_correction_collection == (char *) NULL)
1046 (void) ColorDecisionListImage(*image,color_correction_collection,
1050 if (LocaleCompare("channel",option+1) == 0)
1053 channel=DefaultChannels;
1055 channel=(ChannelType) ParseChannelOption(argv[i+1]);
1056 SetPixelChannelMapMask(*image,channel);
1059 if (LocaleCompare("charcoal",option+1) == 0)
1064 (void) SyncImageSettings(mogrify_info,*image,exception);
1065 flags=ParseGeometry(argv[i+1],&geometry_info);
1066 if ((flags & SigmaValue) == 0)
1067 geometry_info.sigma=1.0;
1068 if ((flags & XiValue) == 0)
1069 geometry_info.xi=1.0;
1070 mogrify_image=CharcoalImage(*image,geometry_info.rho,
1071 geometry_info.sigma,geometry_info.xi,exception);
1074 if (LocaleCompare("chop",option+1) == 0)
1079 (void) SyncImageSettings(mogrify_info,*image,exception);
1080 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1081 mogrify_image=ChopImage(*image,&geometry,exception);
1084 if (LocaleCompare("clamp",option+1) == 0)
1089 (void) SyncImageSettings(mogrify_info,*image,exception);
1090 (void) ClampImage(*image,exception);
1093 if (LocaleCompare("clip",option+1) == 0)
1095 (void) SyncImageSettings(mogrify_info,*image,exception);
1098 (void) SetImageClipMask(*image,(Image *) NULL,exception);
1101 (void) ClipImage(*image,exception);
1104 if (LocaleCompare("clip-mask",option+1) == 0)
1121 (void) SyncImageSettings(mogrify_info,*image,exception);
1127 (void) SetImageMask(*image,(Image *) NULL,exception);
1132 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1134 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1135 if (mask_image == (Image *) NULL)
1137 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
1138 return(MagickFalse);
1139 mask_view=AcquireCacheView(mask_image);
1140 for (y=0; y < (ssize_t) mask_image->rows; y++)
1142 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1144 if (q == (Quantum *) NULL)
1146 for (x=0; x < (ssize_t) mask_image->columns; x++)
1148 if (mask_image->matte == MagickFalse)
1149 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1150 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1151 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1152 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1153 q+=GetPixelChannels(mask_image);
1155 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1158 mask_view=DestroyCacheView(mask_view);
1159 mask_image->matte=MagickTrue;
1160 (void) SetImageClipMask(*image,mask_image,exception);
1163 if (LocaleCompare("clip-path",option+1) == 0)
1165 (void) SyncImageSettings(mogrify_info,*image,exception);
1166 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1167 MagickFalse,exception);
1170 if (LocaleCompare("colorize",option+1) == 0)
1175 (void) SyncImageSettings(mogrify_info,*image,exception);
1176 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
1179 if (LocaleCompare("color-matrix",option+1) == 0)
1184 (void) SyncImageSettings(mogrify_info,*image,exception);
1185 kernel=AcquireKernelInfo(argv[i+1]);
1186 if (kernel == (KernelInfo *) NULL)
1188 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1189 kernel=DestroyKernelInfo(kernel);
1192 if (LocaleCompare("colors",option+1) == 0)
1195 Reduce the number of colors in the image.
1197 (void) SyncImageSettings(mogrify_info,*image,exception);
1198 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1199 if (quantize_info->number_colors == 0)
1201 if (((*image)->storage_class == DirectClass) ||
1202 (*image)->colors > quantize_info->number_colors)
1203 (void) QuantizeImage(quantize_info,*image,exception);
1205 (void) CompressImageColormap(*image,exception);
1208 if (LocaleCompare("colorspace",option+1) == 0)
1213 (void) SyncImageSettings(mogrify_info,*image,exception);
1216 (void) TransformImageColorspace(*image,RGBColorspace,exception);
1219 colorspace=(ColorspaceType) ParseCommandOption(
1220 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1221 (void) TransformImageColorspace(*image,colorspace,exception);
1224 if (LocaleCompare("compose",option+1) == 0)
1226 (void) SyncImageSettings(mogrify_info,*image,exception);
1227 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
1228 MagickFalse,argv[i+1]);
1231 if (LocaleCompare("contrast",option+1) == 0)
1233 (void) SyncImageSettings(mogrify_info,*image,exception);
1234 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1235 MagickFalse,exception);
1238 if (LocaleCompare("contrast-stretch",option+1) == 0)
1248 Contrast stretch image.
1250 (void) SyncImageSettings(mogrify_info,*image,exception);
1251 flags=ParseGeometry(argv[i+1],&geometry_info);
1252 black_point=geometry_info.rho;
1253 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1255 if ((flags & PercentValue) != 0)
1257 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1258 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1260 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1262 (void) ContrastStretchImage(*image,black_point,white_point,
1266 if (LocaleCompare("convolve",option+1) == 0)
1271 (void) SyncImageSettings(mogrify_info,*image,exception);
1272 kernel_info=AcquireKernelInfo(argv[i+1]);
1273 if (kernel_info == (KernelInfo *) NULL)
1275 kernel_info->bias=(*image)->bias;
1276 mogrify_image=ConvolveImage(*image,kernel_info,exception);
1277 kernel_info=DestroyKernelInfo(kernel_info);
1280 if (LocaleCompare("crop",option+1) == 0)
1283 Crop a image to a smaller size
1285 (void) SyncImageSettings(mogrify_info,*image,exception);
1286 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1289 if (LocaleCompare("cycle",option+1) == 0)
1292 Cycle an image colormap.
1294 (void) SyncImageSettings(mogrify_info,*image,exception);
1295 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),
1303 if (LocaleCompare("decipher",option+1) == 0)
1311 (void) SyncImageSettings(mogrify_info,*image,exception);
1312 passkey=FileToStringInfo(argv[i+1],~0,exception);
1313 if (passkey != (StringInfo *) NULL)
1315 (void) PasskeyDecipherImage(*image,passkey,exception);
1316 passkey=DestroyStringInfo(passkey);
1320 if (LocaleCompare("density",option+1) == 0)
1325 (void) CloneString(&draw_info->density,argv[i+1]);
1328 if (LocaleCompare("depth",option+1) == 0)
1330 (void) SyncImageSettings(mogrify_info,*image,exception);
1333 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);
1336 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),
1340 if (LocaleCompare("deskew",option+1) == 0)
1346 Straighten the image.
1348 (void) SyncImageSettings(mogrify_info,*image,exception);
1350 threshold=40.0*QuantumRange/100.0;
1352 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
1354 mogrify_image=DeskewImage(*image,threshold,exception);
1357 if (LocaleCompare("despeckle",option+1) == 0)
1360 Reduce the speckles within an image.
1362 (void) SyncImageSettings(mogrify_info,*image,exception);
1363 mogrify_image=DespeckleImage(*image,exception);
1366 if (LocaleCompare("display",option+1) == 0)
1368 (void) CloneString(&draw_info->server_name,argv[i+1]);
1371 if (LocaleCompare("distort",option+1) == 0)
1375 token[MaxTextExtent];
1395 (void) SyncImageSettings(mogrify_info,*image,exception);
1396 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1397 MagickFalse,argv[i+1]);
1398 if (method == ResizeDistortion)
1404 Special Case - Argument is actually a resize geometry!
1405 Convert that to an appropriate distortion argument array.
1407 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1409 resize_args[0]=(double) geometry.width;
1410 resize_args[1]=(double) geometry.height;
1411 mogrify_image=DistortImage(*image,method,(size_t)2,
1412 resize_args,MagickTrue,exception);
1415 args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1417 if (args == (char *) NULL)
1420 for (x=0; *p != '\0'; x++)
1422 GetMagickToken(p,&p,token);
1424 GetMagickToken(p,&p,token);
1426 number_arguments=(size_t) x;
1427 arguments=(double *) AcquireQuantumMemory(number_arguments,
1428 sizeof(*arguments));
1429 if (arguments == (double *) NULL)
1430 ThrowWandFatalException(ResourceLimitFatalError,
1431 "MemoryAllocationFailed",(*image)->filename);
1432 (void) ResetMagickMemory(arguments,0,number_arguments*
1433 sizeof(*arguments));
1435 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1437 GetMagickToken(p,&p,token);
1439 GetMagickToken(p,&p,token);
1440 arguments[x]=StringToDouble(token,(char **) NULL);
1442 args=DestroyString(args);
1443 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1444 (*option == '+') ? MagickTrue : MagickFalse,exception);
1445 arguments=(double *) RelinquishMagickMemory(arguments);
1448 if (LocaleCompare("dither",option+1) == 0)
1452 quantize_info->dither=MagickFalse;
1455 quantize_info->dither=MagickTrue;
1456 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1457 MagickDitherOptions,MagickFalse,argv[i+1]);
1458 if (quantize_info->dither_method == NoDitherMethod)
1459 quantize_info->dither=MagickFalse;
1462 if (LocaleCompare("draw",option+1) == 0)
1467 (void) SyncImageSettings(mogrify_info,*image,exception);
1468 (void) CloneString(&draw_info->primitive,argv[i+1]);
1469 (void) DrawImage(*image,draw_info,exception);
1476 if (LocaleCompare("edge",option+1) == 0)
1479 Enhance edges in the image.
1481 (void) SyncImageSettings(mogrify_info,*image,exception);
1482 flags=ParseGeometry(argv[i+1],&geometry_info);
1483 if ((flags & SigmaValue) == 0)
1484 geometry_info.sigma=1.0;
1485 mogrify_image=EdgeImage(*image,geometry_info.rho,
1486 geometry_info.sigma,exception);
1489 if (LocaleCompare("emboss",option+1) == 0)
1492 Gaussian embossen image.
1494 (void) SyncImageSettings(mogrify_info,*image,exception);
1495 flags=ParseGeometry(argv[i+1],&geometry_info);
1496 if ((flags & SigmaValue) == 0)
1497 geometry_info.sigma=1.0;
1498 mogrify_image=EmbossImage(*image,geometry_info.rho,
1499 geometry_info.sigma,exception);
1502 if (LocaleCompare("encipher",option+1) == 0)
1510 (void) SyncImageSettings(mogrify_info,*image,exception);
1511 passkey=FileToStringInfo(argv[i+1],~0,exception);
1512 if (passkey != (StringInfo *) NULL)
1514 (void) PasskeyEncipherImage(*image,passkey,exception);
1515 passkey=DestroyStringInfo(passkey);
1519 if (LocaleCompare("encoding",option+1) == 0)
1521 (void) CloneString(&draw_info->encoding,argv[i+1]);
1524 if (LocaleCompare("enhance",option+1) == 0)
1529 (void) SyncImageSettings(mogrify_info,*image,exception);
1530 mogrify_image=EnhanceImage(*image,exception);
1533 if (LocaleCompare("equalize",option+1) == 0)
1538 (void) SyncImageSettings(mogrify_info,*image,exception);
1539 (void) EqualizeImage(*image,exception);
1542 if (LocaleCompare("evaluate",option+1) == 0)
1547 MagickEvaluateOperator
1550 (void) SyncImageSettings(mogrify_info,*image,exception);
1551 op=(MagickEvaluateOperator) ParseCommandOption(
1552 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1553 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+
1555 (void) EvaluateImage(*image,op,constant,exception);
1558 if (LocaleCompare("extent",option+1) == 0)
1561 Set the image extent.
1563 (void) SyncImageSettings(mogrify_info,*image,exception);
1564 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1565 if (geometry.width == 0)
1566 geometry.width=(*image)->columns;
1567 if (geometry.height == 0)
1568 geometry.height=(*image)->rows;
1569 mogrify_image=ExtentImage(*image,&geometry,exception);
1576 if (LocaleCompare("family",option+1) == 0)
1580 if (draw_info->family != (char *) NULL)
1581 draw_info->family=DestroyString(draw_info->family);
1584 (void) CloneString(&draw_info->family,argv[i+1]);
1587 if (LocaleCompare("features",option+1) == 0)
1591 (void) DeleteImageArtifact(*image,"identify:features");
1594 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1597 if (LocaleCompare("fill",option+1) == 0)
1602 GetPixelInfo(*image,&fill);
1605 (void) QueryColorCompliance("none",AllCompliance,&fill,
1607 (void) QueryColorCompliance("none",AllCompliance,
1608 &draw_info->fill,exception);
1609 if (draw_info->fill_pattern != (Image *) NULL)
1610 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1613 sans=AcquireExceptionInfo();
1614 (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill,
1616 status=QueryColorCompliance(argv[i+1],AllCompliance,
1617 &draw_info->fill,sans);
1618 sans=DestroyExceptionInfo(sans);
1619 if (status == MagickFalse)
1620 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1624 if (LocaleCompare("flip",option+1) == 0)
1627 Flip image scanlines.
1629 (void) SyncImageSettings(mogrify_info,*image,exception);
1630 mogrify_image=FlipImage(*image,exception);
1633 if (LocaleCompare("floodfill",option+1) == 0)
1641 (void) SyncImageSettings(mogrify_info,*image,exception);
1642 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1643 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,
1645 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1646 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);
1649 if (LocaleCompare("flop",option+1) == 0)
1652 Flop image scanlines.
1654 (void) SyncImageSettings(mogrify_info,*image,exception);
1655 mogrify_image=FlopImage(*image,exception);
1658 if (LocaleCompare("font",option+1) == 0)
1662 if (draw_info->font != (char *) NULL)
1663 draw_info->font=DestroyString(draw_info->font);
1666 (void) CloneString(&draw_info->font,argv[i+1]);
1669 if (LocaleCompare("format",option+1) == 0)
1674 if (LocaleCompare("frame",option+1) == 0)
1680 Surround image with an ornamental border.
1682 (void) SyncImageSettings(mogrify_info,*image,exception);
1683 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1684 frame_info.width=geometry.width;
1685 frame_info.height=geometry.height;
1686 if ((flags & HeightValue) == 0)
1687 frame_info.height=geometry.width;
1688 frame_info.outer_bevel=geometry.x;
1689 frame_info.inner_bevel=geometry.y;
1690 frame_info.x=(ssize_t) frame_info.width;
1691 frame_info.y=(ssize_t) frame_info.height;
1692 frame_info.width=(*image)->columns+2*frame_info.width;
1693 frame_info.height=(*image)->rows+2*frame_info.height;
1694 mogrify_image=FrameImage(*image,&frame_info,compose,exception);
1697 if (LocaleCompare("function",option+1) == 0)
1701 token[MaxTextExtent];
1719 Function Modify Image Values
1721 (void) SyncImageSettings(mogrify_info,*image,exception);
1722 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1723 MagickFalse,argv[i+1]);
1724 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
1726 if (arguments == (char *) NULL)
1728 p=(char *) arguments;
1729 for (x=0; *p != '\0'; x++)
1731 GetMagickToken(p,&p,token);
1733 GetMagickToken(p,&p,token);
1735 number_parameters=(size_t) x;
1736 parameters=(double *) AcquireQuantumMemory(number_parameters,
1737 sizeof(*parameters));
1738 if (parameters == (double *) NULL)
1739 ThrowWandFatalException(ResourceLimitFatalError,
1740 "MemoryAllocationFailed",(*image)->filename);
1741 (void) ResetMagickMemory(parameters,0,number_parameters*
1742 sizeof(*parameters));
1743 p=(char *) arguments;
1744 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1746 GetMagickToken(p,&p,token);
1748 GetMagickToken(p,&p,token);
1749 parameters[x]=StringToDouble(token,(char **) NULL);
1751 arguments=DestroyString(arguments);
1752 (void) FunctionImage(*image,function,number_parameters,parameters,
1754 parameters=(double *) RelinquishMagickMemory(parameters);
1761 if (LocaleCompare("gamma",option+1) == 0)
1766 (void) SyncImageSettings(mogrify_info,*image,exception);
1768 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);
1770 (void) GammaImage(*image,StringToDouble(argv[i+1],
1771 (char **) NULL),exception);
1774 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1775 (LocaleCompare("gaussian",option+1) == 0))
1778 Gaussian blur image.
1780 (void) SyncImageSettings(mogrify_info,*image,exception);
1781 flags=ParseGeometry(argv[i+1],&geometry_info);
1782 if ((flags & SigmaValue) == 0)
1783 geometry_info.sigma=1.0;
1784 if ((flags & XiValue) == 0)
1785 geometry_info.xi=0.0;
1786 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1787 geometry_info.sigma,geometry_info.xi,exception);
1790 if (LocaleCompare("geometry",option+1) == 0)
1793 Record Image offset, Resize last image.
1795 (void) SyncImageSettings(mogrify_info,*image,exception);
1798 if ((*image)->geometry != (char *) NULL)
1799 (*image)->geometry=DestroyString((*image)->geometry);
1802 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1803 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1804 (void) CloneString(&(*image)->geometry,argv[i+1]);
1806 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1807 (*image)->filter,(*image)->blur,exception);
1810 if (LocaleCompare("gravity",option+1) == 0)
1814 draw_info->gravity=UndefinedGravity;
1817 draw_info->gravity=(GravityType) ParseCommandOption(
1818 MagickGravityOptions,MagickFalse,argv[i+1]);
1825 if (LocaleCompare("highlight-color",option+1) == 0)
1827 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1834 if (LocaleCompare("identify",option+1) == 0)
1839 (void) SyncImageSettings(mogrify_info,*image,exception);
1840 if (format == (char *) NULL)
1842 (void) IdentifyImage(*image,stdout,mogrify_info->verbose,
1846 text=InterpretImageProperties(mogrify_info,*image,format,
1848 if (text == (char *) NULL)
1850 (void) fputs(text,stdout);
1851 (void) fputc('\n',stdout);
1852 text=DestroyString(text);
1855 if (LocaleCompare("implode",option+1) == 0)
1860 (void) SyncImageSettings(mogrify_info,*image,exception);
1861 (void) ParseGeometry(argv[i+1],&geometry_info);
1862 mogrify_image=ImplodeImage(*image,geometry_info.rho,
1863 interpolate_method,exception);
1866 if (LocaleCompare("interline-spacing",option+1) == 0)
1869 (void) ParseGeometry("0",&geometry_info);
1871 (void) ParseGeometry(argv[i+1],&geometry_info);
1872 draw_info->interline_spacing=geometry_info.rho;
1875 if (LocaleCompare("interpolate",option+1) == 0)
1877 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
1878 MagickInterpolateOptions,MagickFalse,argv[i+1]);
1881 if (LocaleCompare("interword-spacing",option+1) == 0)
1884 (void) ParseGeometry("0",&geometry_info);
1886 (void) ParseGeometry(argv[i+1],&geometry_info);
1887 draw_info->interword_spacing=geometry_info.rho;
1894 if (LocaleCompare("kerning",option+1) == 0)
1897 (void) ParseGeometry("0",&geometry_info);
1899 (void) ParseGeometry(argv[i+1],&geometry_info);
1900 draw_info->kerning=geometry_info.rho;
1907 if (LocaleCompare("lat",option+1) == 0)
1910 Local adaptive threshold image.
1912 (void) SyncImageSettings(mogrify_info,*image,exception);
1913 flags=ParseGeometry(argv[i+1],&geometry_info);
1914 if ((flags & PercentValue) != 0)
1915 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1916 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1917 geometry_info.rho,(size_t) geometry_info.sigma,(double)
1918 geometry_info.xi,exception);
1921 if (LocaleCompare("level",option+1) == 0)
1934 (void) SyncImageSettings(mogrify_info,*image,exception);
1935 flags=ParseGeometry(argv[i+1],&geometry_info);
1936 black_point=geometry_info.rho;
1937 white_point=(MagickRealType) QuantumRange;
1938 if ((flags & SigmaValue) != 0)
1939 white_point=geometry_info.sigma;
1941 if ((flags & XiValue) != 0)
1942 gamma=geometry_info.xi;
1943 if ((flags & PercentValue) != 0)
1945 black_point*=(MagickRealType) (QuantumRange/100.0);
1946 white_point*=(MagickRealType) (QuantumRange/100.0);
1948 if ((flags & SigmaValue) == 0)
1949 white_point=(MagickRealType) QuantumRange-black_point;
1950 if ((*option == '+') || ((flags & AspectValue) != 0))
1951 (void) LevelizeImage(*image,black_point,white_point,gamma,
1954 (void) LevelImage(*image,black_point,white_point,gamma,
1958 if (LocaleCompare("level-colors",option+1) == 0)
1961 token[MaxTextExtent];
1970 p=(const char *) argv[i+1];
1971 GetMagickToken(p,&p,token); /* get black point color */
1972 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1973 (void) QueryColorCompliance(token,AllCompliance,
1974 &black_point,exception);
1976 (void) QueryColorCompliance("#000000",AllCompliance,
1977 &black_point,exception);
1978 if (isalpha((int) token[0]) || (token[0] == '#'))
1979 GetMagickToken(p,&p,token);
1981 white_point=black_point; /* set everything to that color */
1984 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1985 GetMagickToken(p,&p,token); /* Get white point color. */
1986 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1987 (void) QueryColorCompliance(token,AllCompliance,
1988 &white_point,exception);
1990 (void) QueryColorCompliance("#ffffff",AllCompliance,
1991 &white_point,exception);
1993 (void) LevelImageColors(*image,&black_point,&white_point,
1994 *option == '+' ? MagickTrue : MagickFalse,exception);
1997 if (LocaleCompare("linear-stretch",option+1) == 0)
2006 (void) SyncImageSettings(mogrify_info,*image,exception);
2007 flags=ParseGeometry(argv[i+1],&geometry_info);
2008 black_point=geometry_info.rho;
2009 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
2010 if ((flags & SigmaValue) != 0)
2011 white_point=geometry_info.sigma;
2012 if ((flags & PercentValue) != 0)
2014 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
2015 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
2017 if ((flags & SigmaValue) == 0)
2018 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
2020 (void) LinearStretchImage(*image,black_point,white_point,exception);
2023 if (LocaleCompare("linewidth",option+1) == 0)
2025 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2028 if (LocaleCompare("liquid-rescale",option+1) == 0)
2031 Liquid rescale image.
2033 (void) SyncImageSettings(mogrify_info,*image,exception);
2034 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2035 if ((flags & XValue) == 0)
2037 if ((flags & YValue) == 0)
2039 mogrify_image=LiquidRescaleImage(*image,geometry.width,
2040 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
2043 if (LocaleCompare("lowlight-color",option+1) == 0)
2045 (void) SetImageArtifact(*image,option+1,argv[i+1]);
2052 if (LocaleCompare("map",option+1) == 0)
2058 Transform image colors to match this set of colors.
2060 (void) SyncImageSettings(mogrify_info,*image,exception);
2063 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2064 if (remap_image == (Image *) NULL)
2066 (void) RemapImage(quantize_info,*image,remap_image,exception);
2067 remap_image=DestroyImage(remap_image);
2070 if (LocaleCompare("mask",option+1) == 0)
2075 (void) SyncImageSettings(mogrify_info,*image,exception);
2081 (void) SetImageMask(*image,(Image *) NULL,exception);
2087 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2088 if (mask == (Image *) NULL)
2090 (void) SetImageMask(*image,mask,exception);
2091 mask=DestroyImage(mask);
2094 if (LocaleCompare("matte",option+1) == 0)
2096 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2097 SetAlphaChannel : DeactivateAlphaChannel,exception);
2100 if (LocaleCompare("median",option+1) == 0)
2103 Median filter image.
2105 (void) SyncImageSettings(mogrify_info,*image,exception);
2106 flags=ParseGeometry(argv[i+1],&geometry_info);
2107 if ((flags & SigmaValue) == 0)
2108 geometry_info.sigma=geometry_info.rho;
2109 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2110 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2113 if (LocaleCompare("mode",option+1) == 0)
2118 (void) SyncImageSettings(mogrify_info,*image,exception);
2119 flags=ParseGeometry(argv[i+1],&geometry_info);
2120 if ((flags & SigmaValue) == 0)
2121 geometry_info.sigma=geometry_info.rho;
2122 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2123 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2126 if (LocaleCompare("modulate",option+1) == 0)
2128 (void) SyncImageSettings(mogrify_info,*image,exception);
2129 (void) ModulateImage(*image,argv[i+1],exception);
2132 if (LocaleCompare("monitor",option+1) == 0)
2136 (void) SetImageProgressMonitor(*image,
2137 (MagickProgressMonitor) NULL,(void *) NULL);
2140 (void) SetImageProgressMonitor(*image,MonitorProgress,
2144 if (LocaleCompare("monochrome",option+1) == 0)
2146 (void) SyncImageSettings(mogrify_info,*image,exception);
2147 (void) SetImageType(*image,BilevelType,exception);
2150 if (LocaleCompare("morphology",option+1) == 0)
2153 token[MaxTextExtent];
2168 Morphological Image Operation
2170 (void) SyncImageSettings(mogrify_info,*image,exception);
2172 GetMagickToken(p,&p,token);
2173 method=(MorphologyMethod) ParseCommandOption(
2174 MagickMorphologyOptions,MagickFalse,token);
2176 GetMagickToken(p,&p,token);
2177 if ((*p == ':') || (*p == ','))
2178 GetMagickToken(p,&p,token);
2180 iterations=(ssize_t) StringToLong(p);
2181 kernel=AcquireKernelInfo(argv[i+2]);
2182 if (kernel == (KernelInfo *) NULL)
2184 (void) ThrowMagickException(exception,GetMagickModule(),
2185 OptionError,"UnabletoParseKernel","morphology");
2189 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2191 kernel=DestroyKernelInfo(kernel);
2194 if (LocaleCompare("motion-blur",option+1) == 0)
2199 (void) SyncImageSettings(mogrify_info,*image,exception);
2200 flags=ParseGeometry(argv[i+1],&geometry_info);
2201 if ((flags & SigmaValue) == 0)
2202 geometry_info.sigma=1.0;
2203 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2204 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2211 if (LocaleCompare("negate",option+1) == 0)
2213 (void) SyncImageSettings(mogrify_info,*image,exception);
2214 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2215 MagickFalse,exception);
2218 if (LocaleCompare("noise",option+1) == 0)
2220 (void) SyncImageSettings(mogrify_info,*image,exception);
2223 flags=ParseGeometry(argv[i+1],&geometry_info);
2224 if ((flags & SigmaValue) == 0)
2225 geometry_info.sigma=geometry_info.rho;
2226 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2227 geometry_info.rho,(size_t) geometry_info.sigma,exception);
2234 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2235 MagickFalse,argv[i+1]);
2236 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);
2240 if (LocaleCompare("normalize",option+1) == 0)
2242 (void) SyncImageSettings(mogrify_info,*image,exception);
2243 (void) NormalizeImage(*image,exception);
2250 if (LocaleCompare("opaque",option+1) == 0)
2255 (void) SyncImageSettings(mogrify_info,*image,exception);
2256 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
2258 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2259 MagickFalse : MagickTrue,exception);
2262 if (LocaleCompare("ordered-dither",option+1) == 0)
2264 (void) SyncImageSettings(mogrify_info,*image,exception);
2265 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2272 if (LocaleCompare("paint",option+1) == 0)
2274 (void) SyncImageSettings(mogrify_info,*image,exception);
2275 (void) ParseGeometry(argv[i+1],&geometry_info);
2276 mogrify_image=OilPaintImage(*image,geometry_info.rho,
2277 geometry_info.sigma,exception);
2280 if (LocaleCompare("pointsize",option+1) == 0)
2283 (void) ParseGeometry("12",&geometry_info);
2285 (void) ParseGeometry(argv[i+1],&geometry_info);
2286 draw_info->pointsize=geometry_info.rho;
2289 if (LocaleCompare("polaroid",option+1) == 0)
2301 Simulate a Polaroid picture.
2303 (void) SyncImageSettings(mogrify_info,*image,exception);
2304 random_info=AcquireRandomInfo();
2305 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2306 random_info=DestroyRandomInfo(random_info);
2309 SetGeometryInfo(&geometry_info);
2310 flags=ParseGeometry(argv[i+1],&geometry_info);
2311 angle=geometry_info.rho;
2313 caption=GetImageProperty(*image,"caption",exception);
2314 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2315 interpolate_method,exception);
2318 if (LocaleCompare("posterize",option+1) == 0)
2323 (void) SyncImageSettings(mogrify_info,*image,exception);
2324 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2325 quantize_info->dither,exception);
2328 if (LocaleCompare("preview",option+1) == 0)
2336 (void) SyncImageSettings(mogrify_info,*image,exception);
2338 preview_type=UndefinedPreview;
2340 preview_type=(PreviewType) ParseCommandOption(
2341 MagickPreviewOptions,MagickFalse,argv[i+1]);
2342 mogrify_image=PreviewImage(*image,preview_type,exception);
2345 if (LocaleCompare("profile",option+1) == 0)
2359 (void) SyncImageSettings(mogrify_info,*image,exception);
2363 Remove a profile from the image.
2365 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2370 Associate a profile with the image.
2372 profile_info=CloneImageInfo(mogrify_info);
2373 profile=GetImageProfile(*image,"iptc");
2374 if (profile != (StringInfo *) NULL)
2375 profile_info->profile=(void *) CloneStringInfo(profile);
2376 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2377 profile_info=DestroyImageInfo(profile_info);
2378 if (profile_image == (Image *) NULL)
2383 profile_info=CloneImageInfo(mogrify_info);
2384 (void) CopyMagickString(profile_info->filename,argv[i+1],
2386 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2387 if (profile != (StringInfo *) NULL)
2389 (void) ProfileImage(*image,profile_info->magick,
2390 GetStringInfoDatum(profile),(size_t)
2391 GetStringInfoLength(profile),exception);
2392 profile=DestroyStringInfo(profile);
2394 profile_info=DestroyImageInfo(profile_info);
2397 ResetImageProfileIterator(profile_image);
2398 name=GetNextImageProfile(profile_image);
2399 while (name != (const char *) NULL)
2401 profile=GetImageProfile(profile_image,name);
2402 if (profile != (StringInfo *) NULL)
2403 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2404 (size_t) GetStringInfoLength(profile),exception);
2405 name=GetNextImageProfile(profile_image);
2407 profile_image=DestroyImage(profile_image);
2414 if (LocaleCompare("quantize",option+1) == 0)
2418 quantize_info->colorspace=UndefinedColorspace;
2421 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2422 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2429 if (LocaleCompare("radial-blur",option+1) == 0)
2434 (void) SyncImageSettings(mogrify_info,*image,exception);
2435 flags=ParseGeometry(argv[i+1],&geometry_info);
2436 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2437 geometry_info.sigma,exception);
2440 if (LocaleCompare("raise",option+1) == 0)
2443 Surround image with a raise of solid color.
2445 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2446 if ((flags & SigmaValue) == 0)
2447 geometry.height=geometry.width;
2448 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2449 MagickFalse,exception);
2452 if (LocaleCompare("random-threshold",option+1) == 0)
2457 (void) SyncImageSettings(mogrify_info,*image,exception);
2458 (void) RandomThresholdImage(*image,argv[i+1],exception);
2461 if (LocaleCompare("recolor",option+1) == 0)
2466 (void) SyncImageSettings(mogrify_info,*image,exception);
2467 kernel=AcquireKernelInfo(argv[i+1]);
2468 if (kernel == (KernelInfo *) NULL)
2470 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2471 kernel=DestroyKernelInfo(kernel);
2474 if (LocaleCompare("region",option+1) == 0)
2476 (void) SyncImageSettings(mogrify_info,*image,exception);
2477 if (region_image != (Image *) NULL)
2482 (void) CompositeImage(region_image,region_image->matte !=
2483 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2484 region_geometry.x,region_geometry.y,exception);
2485 *image=DestroyImage(*image);
2486 *image=region_image;
2487 region_image = (Image *) NULL;
2492 Apply transformations to a selected region of the image.
2494 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2496 mogrify_image=CropImage(*image,®ion_geometry,exception);
2497 if (mogrify_image == (Image *) NULL)
2499 region_image=(*image);
2500 *image=mogrify_image;
2501 mogrify_image=(Image *) NULL;
2504 if (LocaleCompare("render",option+1) == 0)
2506 (void) SyncImageSettings(mogrify_info,*image,exception);
2507 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2510 if (LocaleCompare("remap",option+1) == 0)
2516 Transform image colors to match this set of colors.
2518 (void) SyncImageSettings(mogrify_info,*image,exception);
2521 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2522 if (remap_image == (Image *) NULL)
2524 (void) RemapImage(quantize_info,*image,remap_image,exception);
2525 remap_image=DestroyImage(remap_image);
2528 if (LocaleCompare("repage",option+1) == 0)
2532 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2535 (void) ResetImagePage(*image,argv[i+1]);
2538 if (LocaleCompare("resample",option+1) == 0)
2543 (void) SyncImageSettings(mogrify_info,*image,exception);
2544 flags=ParseGeometry(argv[i+1],&geometry_info);
2545 if ((flags & SigmaValue) == 0)
2546 geometry_info.sigma=geometry_info.rho;
2547 mogrify_image=ResampleImage(*image,geometry_info.rho,
2548 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2551 if (LocaleCompare("resize",option+1) == 0)
2556 (void) SyncImageSettings(mogrify_info,*image,exception);
2557 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2558 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2559 (*image)->filter,(*image)->blur,exception);
2562 if (LocaleCompare("roll",option+1) == 0)
2567 (void) SyncImageSettings(mogrify_info,*image,exception);
2568 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2569 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2572 if (LocaleCompare("rotate",option+1) == 0)
2578 Check for conditional image rotation.
2580 (void) SyncImageSettings(mogrify_info,*image,exception);
2581 if (strchr(argv[i+1],'>') != (char *) NULL)
2582 if ((*image)->columns <= (*image)->rows)
2584 if (strchr(argv[i+1],'<') != (char *) NULL)
2585 if ((*image)->columns >= (*image)->rows)
2590 geometry=ConstantString(argv[i+1]);
2591 (void) SubstituteString(&geometry,">","");
2592 (void) SubstituteString(&geometry,"<","");
2593 (void) ParseGeometry(geometry,&geometry_info);
2594 geometry=DestroyString(geometry);
2595 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2602 if (LocaleCompare("sample",option+1) == 0)
2605 Sample image with pixel replication.
2607 (void) SyncImageSettings(mogrify_info,*image,exception);
2608 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2609 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2613 if (LocaleCompare("scale",option+1) == 0)
2618 (void) SyncImageSettings(mogrify_info,*image,exception);
2619 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2620 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2624 if (LocaleCompare("selective-blur",option+1) == 0)
2627 Selectively blur pixels within a contrast threshold.
2629 (void) SyncImageSettings(mogrify_info,*image,exception);
2630 flags=ParseGeometry(argv[i+1],&geometry_info);
2631 if ((flags & PercentValue) != 0)
2632 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2633 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2634 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2637 if (LocaleCompare("separate",option+1) == 0)
2640 Break channels into separate images.
2642 (void) SyncImageSettings(mogrify_info,*image,exception);
2643 mogrify_image=SeparateImages(*image,exception);
2646 if (LocaleCompare("sepia-tone",option+1) == 0)
2654 (void) SyncImageSettings(mogrify_info,*image,exception);
2655 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2657 mogrify_image=SepiaToneImage(*image,threshold,exception);
2660 if (LocaleCompare("segment",option+1) == 0)
2665 (void) SyncImageSettings(mogrify_info,*image,exception);
2666 flags=ParseGeometry(argv[i+1],&geometry_info);
2667 if ((flags & SigmaValue) == 0)
2668 geometry_info.sigma=1.0;
2669 (void) SegmentImage(*image,(*image)->colorspace,
2670 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2674 if (LocaleCompare("set",option+1) == 0)
2684 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2685 (void) DeleteImageRegistry(argv[i+1]+9);
2687 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2689 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2690 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2693 (void) DeleteImageProperty(*image,argv[i+1]);
2696 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2698 if (value == (char *) NULL)
2700 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2701 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2704 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2706 (void) SetImageOption(image_info,argv[i+1]+7,value);
2707 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2708 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2711 (void) SetImageProperty(*image,argv[i+1],value,exception);
2712 value=DestroyString(value);
2715 if (LocaleCompare("shade",option+1) == 0)
2720 (void) SyncImageSettings(mogrify_info,*image,exception);
2721 flags=ParseGeometry(argv[i+1],&geometry_info);
2722 if ((flags & SigmaValue) == 0)
2723 geometry_info.sigma=1.0;
2724 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2725 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2728 if (LocaleCompare("shadow",option+1) == 0)
2733 (void) SyncImageSettings(mogrify_info,*image,exception);
2734 flags=ParseGeometry(argv[i+1],&geometry_info);
2735 if ((flags & SigmaValue) == 0)
2736 geometry_info.sigma=1.0;
2737 if ((flags & XiValue) == 0)
2738 geometry_info.xi=4.0;
2739 if ((flags & PsiValue) == 0)
2740 geometry_info.psi=4.0;
2741 mogrify_image=ShadowImage(*image,geometry_info.rho,
2742 geometry_info.sigma,(*image)->bias,(ssize_t)
2743 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
2747 if (LocaleCompare("sharpen",option+1) == 0)
2752 (void) SyncImageSettings(mogrify_info,*image,exception);
2753 flags=ParseGeometry(argv[i+1],&geometry_info);
2754 if ((flags & SigmaValue) == 0)
2755 geometry_info.sigma=1.0;
2756 if ((flags & XiValue) == 0)
2757 geometry_info.xi=0.0;
2758 mogrify_image=SharpenImage(*image,geometry_info.rho,
2759 geometry_info.sigma,geometry_info.xi,exception);
2762 if (LocaleCompare("shave",option+1) == 0)
2765 Shave the image edges.
2767 (void) SyncImageSettings(mogrify_info,*image,exception);
2768 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2769 mogrify_image=ShaveImage(*image,&geometry,exception);
2772 if (LocaleCompare("shear",option+1) == 0)
2777 (void) SyncImageSettings(mogrify_info,*image,exception);
2778 flags=ParseGeometry(argv[i+1],&geometry_info);
2779 if ((flags & SigmaValue) == 0)
2780 geometry_info.sigma=geometry_info.rho;
2781 mogrify_image=ShearImage(*image,geometry_info.rho,
2782 geometry_info.sigma,exception);
2785 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2788 Sigmoidal non-linearity contrast control.
2790 (void) SyncImageSettings(mogrify_info,*image,exception);
2791 flags=ParseGeometry(argv[i+1],&geometry_info);
2792 if ((flags & SigmaValue) == 0)
2793 geometry_info.sigma=(double) QuantumRange/2.0;
2794 if ((flags & PercentValue) != 0)
2795 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2797 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2798 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2802 if (LocaleCompare("sketch",option+1) == 0)
2807 (void) SyncImageSettings(mogrify_info,*image,exception);
2808 flags=ParseGeometry(argv[i+1],&geometry_info);
2809 if ((flags & SigmaValue) == 0)
2810 geometry_info.sigma=1.0;
2811 mogrify_image=SketchImage(*image,geometry_info.rho,
2812 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2815 if (LocaleCompare("solarize",option+1) == 0)
2820 (void) SyncImageSettings(mogrify_info,*image,exception);
2821 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2823 (void) SolarizeImage(*image,threshold,exception);
2826 if (LocaleCompare("sparse-color",option+1) == 0)
2835 Sparse Color Interpolated Gradient
2837 (void) SyncImageSettings(mogrify_info,*image,exception);
2838 method=(SparseColorMethod) ParseCommandOption(
2839 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2840 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2842 if (arguments == (char *) NULL)
2844 mogrify_image=SparseColorOption(*image,method,arguments,
2845 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2846 arguments=DestroyString(arguments);
2849 if (LocaleCompare("splice",option+1) == 0)
2852 Splice a solid color into the image.
2854 (void) SyncImageSettings(mogrify_info,*image,exception);
2855 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2856 mogrify_image=SpliceImage(*image,&geometry,exception);
2859 if (LocaleCompare("spread",option+1) == 0)
2864 (void) SyncImageSettings(mogrify_info,*image,exception);
2865 (void) ParseGeometry(argv[i+1],&geometry_info);
2866 mogrify_image=SpreadImage(*image,geometry_info.rho,
2867 interpolate_method,exception);
2870 if (LocaleCompare("statistic",option+1) == 0)
2875 (void) SyncImageSettings(mogrify_info,*image,exception);
2876 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2877 MagickFalse,argv[i+1]);
2878 (void) ParseGeometry(argv[i+2],&geometry_info);
2879 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2880 (size_t) geometry_info.sigma,exception);
2883 if (LocaleCompare("stretch",option+1) == 0)
2887 draw_info->stretch=UndefinedStretch;
2890 draw_info->stretch=(StretchType) ParseCommandOption(
2891 MagickStretchOptions,MagickFalse,argv[i+1]);
2894 if (LocaleCompare("strip",option+1) == 0)
2897 Strip image of profiles and comments.
2899 (void) SyncImageSettings(mogrify_info,*image,exception);
2900 (void) StripImage(*image,exception);
2903 if (LocaleCompare("stroke",option+1) == 0)
2910 (void) QueryColorCompliance("none",AllCompliance,
2911 &draw_info->stroke,exception);
2912 if (draw_info->stroke_pattern != (Image *) NULL)
2913 draw_info->stroke_pattern=DestroyImage(
2914 draw_info->stroke_pattern);
2917 sans=AcquireExceptionInfo();
2918 status=QueryColorCompliance(argv[i+1],AllCompliance,
2919 &draw_info->stroke,sans);
2920 sans=DestroyExceptionInfo(sans);
2921 if (status == MagickFalse)
2922 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2926 if (LocaleCompare("strokewidth",option+1) == 0)
2928 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2931 if (LocaleCompare("style",option+1) == 0)
2935 draw_info->style=UndefinedStyle;
2938 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2939 MagickFalse,argv[i+1]);
2942 if (LocaleCompare("swirl",option+1) == 0)
2947 (void) SyncImageSettings(mogrify_info,*image,exception);
2948 (void) ParseGeometry(argv[i+1],&geometry_info);
2949 mogrify_image=SwirlImage(*image,geometry_info.rho,
2950 interpolate_method,exception);
2957 if (LocaleCompare("threshold",option+1) == 0)
2965 (void) SyncImageSettings(mogrify_info,*image,exception);
2967 threshold=(double) QuantumRange/2;
2969 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2971 (void) BilevelImage(*image,threshold,exception);
2974 if (LocaleCompare("thumbnail",option+1) == 0)
2979 (void) SyncImageSettings(mogrify_info,*image,exception);
2980 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2981 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2985 if (LocaleCompare("tile",option+1) == 0)
2989 if (draw_info->fill_pattern != (Image *) NULL)
2990 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2993 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2997 if (LocaleCompare("tint",option+1) == 0)
3002 (void) SyncImageSettings(mogrify_info,*image,exception);
3003 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3006 if (LocaleCompare("transform",option+1) == 0)
3009 Affine transform image.
3011 (void) SyncImageSettings(mogrify_info,*image,exception);
3012 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3016 if (LocaleCompare("transparent",option+1) == 0)
3021 (void) SyncImageSettings(mogrify_info,*image,exception);
3022 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3024 (void) TransparentPaintImage(*image,&target,(Quantum)
3025 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3029 if (LocaleCompare("transpose",option+1) == 0)
3032 Transpose image scanlines.
3034 (void) SyncImageSettings(mogrify_info,*image,exception);
3035 mogrify_image=TransposeImage(*image,exception);
3038 if (LocaleCompare("transverse",option+1) == 0)
3041 Transverse image scanlines.
3043 (void) SyncImageSettings(mogrify_info,*image,exception);
3044 mogrify_image=TransverseImage(*image,exception);
3047 if (LocaleCompare("treedepth",option+1) == 0)
3049 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3052 if (LocaleCompare("trim",option+1) == 0)
3057 (void) SyncImageSettings(mogrify_info,*image,exception);
3058 mogrify_image=TrimImage(*image,exception);
3061 if (LocaleCompare("type",option+1) == 0)
3066 (void) SyncImageSettings(mogrify_info,*image,exception);
3070 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3072 (*image)->type=UndefinedType;
3073 (void) SetImageType(*image,type,exception);
3080 if (LocaleCompare("undercolor",option+1) == 0)
3082 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3083 &draw_info->undercolor,exception);
3086 if (LocaleCompare("unique",option+1) == 0)
3090 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3093 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3094 (void) SetImageArtifact(*image,"verbose","true");
3097 if (LocaleCompare("unique-colors",option+1) == 0)
3100 Unique image colors.
3102 (void) SyncImageSettings(mogrify_info,*image,exception);
3103 mogrify_image=UniqueImageColors(*image,exception);
3106 if (LocaleCompare("unsharp",option+1) == 0)
3111 (void) SyncImageSettings(mogrify_info,*image,exception);
3112 flags=ParseGeometry(argv[i+1],&geometry_info);
3113 if ((flags & SigmaValue) == 0)
3114 geometry_info.sigma=1.0;
3115 if ((flags & XiValue) == 0)
3116 geometry_info.xi=1.0;
3117 if ((flags & PsiValue) == 0)
3118 geometry_info.psi=0.05;
3119 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3120 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3127 if (LocaleCompare("verbose",option+1) == 0)
3129 (void) SetImageArtifact(*image,option+1,
3130 *option == '+' ? "false" : "true");
3133 if (LocaleCompare("vignette",option+1) == 0)
3138 (void) SyncImageSettings(mogrify_info,*image,exception);
3139 flags=ParseGeometry(argv[i+1],&geometry_info);
3140 if ((flags & SigmaValue) == 0)
3141 geometry_info.sigma=1.0;
3142 if ((flags & XiValue) == 0)
3143 geometry_info.xi=0.1*(*image)->columns;
3144 if ((flags & PsiValue) == 0)
3145 geometry_info.psi=0.1*(*image)->rows;
3146 mogrify_image=VignetteImage(*image,geometry_info.rho,
3147 geometry_info.sigma,(*image)->bias,(ssize_t)
3148 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
3152 if (LocaleCompare("virtual-pixel",option+1) == 0)
3156 (void) SetImageVirtualPixelMethod(*image,
3157 UndefinedVirtualPixelMethod);
3160 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3161 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3169 if (LocaleCompare("wave",option+1) == 0)
3174 (void) SyncImageSettings(mogrify_info,*image,exception);
3175 flags=ParseGeometry(argv[i+1],&geometry_info);
3176 if ((flags & SigmaValue) == 0)
3177 geometry_info.sigma=1.0;
3178 mogrify_image=WaveImage(*image,geometry_info.rho,
3179 geometry_info.sigma,interpolate_method,exception);
3182 if (LocaleCompare("weight",option+1) == 0)
3184 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3185 if (LocaleCompare(argv[i+1],"all") == 0)
3186 draw_info->weight=0;
3187 if (LocaleCompare(argv[i+1],"bold") == 0)
3188 draw_info->weight=700;
3189 if (LocaleCompare(argv[i+1],"bolder") == 0)
3190 if (draw_info->weight <= 800)
3191 draw_info->weight+=100;
3192 if (LocaleCompare(argv[i+1],"lighter") == 0)
3193 if (draw_info->weight >= 100)
3194 draw_info->weight-=100;
3195 if (LocaleCompare(argv[i+1],"normal") == 0)
3196 draw_info->weight=400;
3199 if (LocaleCompare("white-threshold",option+1) == 0)
3202 White threshold image.
3204 (void) SyncImageSettings(mogrify_info,*image,exception);
3205 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3214 Replace current image with any image that was generated
3216 if (mogrify_image != (Image *) NULL)
3217 ReplaceImageInListReturnLast(image,mogrify_image);
3220 if (region_image != (Image *) NULL)
3223 Composite transformed region onto image.
3225 (void) SyncImageSettings(mogrify_info,*image,exception);
3226 (void) CompositeImage(region_image,region_image->matte !=
3227 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3228 region_geometry.x,region_geometry.y,exception);
3229 *image=DestroyImage(*image);
3230 *image=region_image;
3231 region_image = (Image *) NULL;
3236 quantize_info=DestroyQuantizeInfo(quantize_info);
3237 draw_info=DestroyDrawInfo(draw_info);
3238 mogrify_info=DestroyImageInfo(mogrify_info);
3239 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3240 return(status == 0 ? MagickFalse : MagickTrue);
3244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3248 + M o g r i f y I m a g e C o m m a n d %
3252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3254 % MogrifyImageCommand() transforms an image or a sequence of images. These
3255 % transforms include image scaling, image rotation, color reduction, and
3256 % others. The transmogrified image overwrites the original image.
3258 % The format of the MogrifyImageCommand method is:
3260 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3261 % const char **argv,char **metadata,ExceptionInfo *exception)
3263 % A description of each parameter follows:
3265 % o image_info: the image info.
3267 % o argc: the number of elements in the argument vector.
3269 % o argv: A text array containing the command line arguments.
3271 % o metadata: any metadata is returned here.
3273 % o exception: return any errors or warnings in this structure.
3277 static MagickBooleanType MogrifyUsage(void)
3282 "-debug events display copious debugging information",
3283 "-help print program options",
3284 "-list type print a list of supported option arguments",
3285 "-log format format of debugging information",
3286 "-version print version information",
3291 "-adaptive-blur geometry",
3292 " adaptively blur pixels; decrease effect near edges",
3293 "-adaptive-resize geometry",
3294 " adaptively resize image using 'mesh' interpolation",
3295 "-adaptive-sharpen geometry",
3296 " adaptively sharpen pixels; increase effect near edges",
3297 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3298 " transparent, extract, background, or shape",
3299 "-annotate geometry text",
3300 " annotate the image with text",
3301 "-auto-gamma automagically adjust gamma level of image",
3302 "-auto-level automagically adjust color levels of image",
3303 "-auto-orient automagically orient (rotate) image",
3304 "-bench iterations measure performance",
3305 "-black-threshold value",
3306 " force all pixels below the threshold into black",
3307 "-blue-shift simulate a scene at nighttime in the moonlight",
3308 "-blur geometry reduce image noise and reduce detail levels",
3309 "-border geometry surround image with a border of color",
3310 "-bordercolor color border color",
3311 "-brightness-contrast geometry",
3312 " improve brightness / contrast of the image",
3313 "-cdl filename color correct with a color decision list",
3314 "-charcoal geometry simulate a charcoal drawing",
3315 "-chop geometry remove pixels from the image interior",
3316 "-clamp restrict pixel range from 0 to the quantum depth",
3317 "-clip clip along the first path from the 8BIM profile",
3318 "-clip-mask filename associate a clip mask with the image",
3319 "-clip-path id clip along a named path from the 8BIM profile",
3320 "-colorize value colorize the image with the fill color",
3321 "-color-matrix matrix apply color correction to the image",
3322 "-contrast enhance or reduce the image contrast",
3323 "-contrast-stretch geometry",
3324 " improve contrast by `stretching' the intensity range",
3325 "-convolve coefficients",
3326 " apply a convolution kernel to the image",
3327 "-cycle amount cycle the image colormap",
3328 "-decipher filename convert cipher pixels to plain pixels",
3329 "-deskew threshold straighten an image",
3330 "-despeckle reduce the speckles within an image",
3331 "-distort method args",
3332 " distort images according to given method ad args",
3333 "-draw string annotate the image with a graphic primitive",
3334 "-edge radius apply a filter to detect edges in the image",
3335 "-encipher filename convert plain pixels to cipher pixels",
3336 "-emboss radius emboss an image",
3337 "-enhance apply a digital filter to enhance a noisy image",
3338 "-equalize perform histogram equalization to an image",
3339 "-evaluate operator value",
3340 " evaluate an arithmetic, relational, or logical expression",
3341 "-extent geometry set the image size",
3342 "-extract geometry extract area from image",
3343 "-fft implements the discrete Fourier transform (DFT)",
3344 "-flip flip image vertically",
3345 "-floodfill geometry color",
3346 " floodfill the image with color",
3347 "-flop flop image horizontally",
3348 "-frame geometry surround image with an ornamental border",
3349 "-function name parameters",
3350 " apply function over image values",
3351 "-gamma value level of gamma correction",
3352 "-gaussian-blur geometry",
3353 " reduce image noise and reduce detail levels",
3354 "-geometry geometry preferred size or location of the image",
3355 "-identify identify the format and characteristics of the image",
3356 "-ift implements the inverse discrete Fourier transform (DFT)",
3357 "-implode amount implode image pixels about the center",
3358 "-lat geometry local adaptive thresholding",
3359 "-layers method optimize, merge, or compare image layers",
3360 "-level value adjust the level of image contrast",
3361 "-level-colors color,color",
3362 " level image with the given colors",
3363 "-linear-stretch geometry",
3364 " improve contrast by `stretching with saturation'",
3365 "-liquid-rescale geometry",
3366 " rescale image with seam-carving",
3367 "-median geometry apply a median filter to the image",
3368 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3369 "-modulate value vary the brightness, saturation, and hue",
3370 "-monochrome transform image to black and white",
3371 "-morphology method kernel",
3372 " apply a morphology method to the image",
3373 "-motion-blur geometry",
3374 " simulate motion blur",
3375 "-negate replace every pixel with its complementary color ",
3376 "-noise geometry add or reduce noise in an image",
3377 "-normalize transform image to span the full range of colors",
3378 "-opaque color change this color to the fill color",
3379 "-ordered-dither NxN",
3380 " add a noise pattern to the image with specific",
3382 "-paint radius simulate an oil painting",
3383 "-polaroid angle simulate a Polaroid picture",
3384 "-posterize levels reduce the image to a limited number of color levels",
3385 "-profile filename add, delete, or apply an image profile",
3386 "-quantize colorspace reduce colors in this colorspace",
3387 "-radial-blur angle radial blur the image",
3388 "-raise value lighten/darken image edges to create a 3-D effect",
3389 "-random-threshold low,high",
3390 " random threshold the image",
3391 "-region geometry apply options to a portion of the image",
3392 "-render render vector graphics",
3393 "-repage geometry size and location of an image canvas",
3394 "-resample geometry change the resolution of an image",
3395 "-resize geometry resize the image",
3396 "-roll geometry roll an image vertically or horizontally",
3397 "-rotate degrees apply Paeth rotation to the image",
3398 "-sample geometry scale image with pixel sampling",
3399 "-scale geometry scale the image",
3400 "-segment values segment an image",
3401 "-selective-blur geometry",
3402 " selectively blur pixels within a contrast threshold",
3403 "-sepia-tone threshold",
3404 " simulate a sepia-toned photo",
3405 "-set property value set an image property",
3406 "-shade degrees shade the image using a distant light source",
3407 "-shadow geometry simulate an image shadow",
3408 "-sharpen geometry sharpen the image",
3409 "-shave geometry shave pixels from the image edges",
3410 "-shear geometry slide one edge of the image along the X or Y axis",
3411 "-sigmoidal-contrast geometry",
3412 " increase the contrast without saturating highlights or shadows",
3413 "-sketch geometry simulate a pencil sketch",
3414 "-solarize threshold negate all pixels above the threshold level",
3415 "-sparse-color method args",
3416 " fill in a image based on a few color points",
3417 "-splice geometry splice the background color into the image",
3418 "-spread radius displace image pixels by a random amount",
3419 "-statistic type radius",
3420 " replace each pixel with corresponding statistic from the neighborhood",
3421 "-strip strip image of all profiles and comments",
3422 "-swirl degrees swirl image pixels about the center",
3423 "-threshold value threshold the image",
3424 "-thumbnail geometry create a thumbnail of the image",
3425 "-tile filename tile image when filling a graphic primitive",
3426 "-tint value tint the image with the fill color",
3427 "-transform affine transform image",
3428 "-transparent color make this color transparent within the image",
3429 "-transpose flip image vertically and rotate 90 degrees",
3430 "-transverse flop image horizontally and rotate 270 degrees",
3431 "-trim trim image edges",
3432 "-type type image type",
3433 "-unique-colors discard all but one of any pixel color",
3434 "-unsharp geometry sharpen the image",
3435 "-vignette geometry soften the edges of the image in vignette style",
3436 "-wave geometry alter an image along a sine wave",
3437 "-white-threshold value",
3438 " force all pixels above the threshold into white",
3441 *sequence_operators[]=
3443 "-append append an image sequence",
3444 "-clut apply a color lookup table to the image",
3445 "-coalesce merge a sequence of images",
3446 "-combine combine a sequence of images",
3447 "-composite composite image",
3448 "-crop geometry cut out a rectangular region of the image",
3449 "-deconstruct break down an image sequence into constituent parts",
3450 "-evaluate-sequence operator",
3451 " evaluate an arithmetic, relational, or logical expression",
3452 "-flatten flatten a sequence of images",
3453 "-fx expression apply mathematical expression to an image channel(s)",
3454 "-hald-clut apply a Hald color lookup table to the image",
3455 "-morph value morph an image sequence",
3456 "-mosaic create a mosaic from an image sequence",
3457 "-print string interpret string and print to console",
3458 "-process arguments process the image with a custom image filter",
3459 "-separate separate an image channel into a grayscale image",
3460 "-smush geometry smush an image sequence together",
3461 "-write filename write images to this file",
3466 "-adjoin join images into a single multi-image file",
3467 "-affine matrix affine transform matrix",
3468 "-alpha option activate, deactivate, reset, or set the alpha channel",
3469 "-antialias remove pixel-aliasing",
3470 "-authenticate password",
3471 " decipher image with this password",
3472 "-attenuate value lessen (or intensify) when adding noise to an image",
3473 "-background color background color",
3474 "-bias value add bias when convolving an image",
3475 "-black-point-compensation",
3476 " use black point compensation",
3477 "-blue-primary point chromaticity blue primary point",
3478 "-bordercolor color border color",
3479 "-caption string assign a caption to an image",
3480 "-channel type apply option to select image channels",
3481 "-colors value preferred number of colors in the image",
3482 "-colorspace type alternate image colorspace",
3483 "-comment string annotate image with comment",
3484 "-compose operator set image composite operator",
3485 "-compress type type of pixel compression when writing the image",
3486 "-define format:option",
3487 " define one or more image format options",
3488 "-delay value display the next image after pausing",
3489 "-density geometry horizontal and vertical density of the image",
3490 "-depth value image depth",
3491 "-direction type render text right-to-left or left-to-right",
3492 "-display server get image or font from this X server",
3493 "-dispose method layer disposal method",
3494 "-dither method apply error diffusion to image",
3495 "-encoding type text encoding type",
3496 "-endian type endianness (MSB or LSB) of the image",
3497 "-family name render text with this font family",
3498 "-fill color color to use when filling a graphic primitive",
3499 "-filter type use this filter when resizing an image",
3500 "-font name render text with this font",
3501 "-format \"string\" output formatted image characteristics",
3502 "-fuzz distance colors within this distance are considered equal",
3503 "-gravity type horizontal and vertical text placement",
3504 "-green-primary point chromaticity green primary point",
3505 "-intent type type of rendering intent when managing the image color",
3506 "-interlace type type of image interlacing scheme",
3507 "-interline-spacing value",
3508 " set the space between two text lines",
3509 "-interpolate method pixel color interpolation method",
3510 "-interword-spacing value",
3511 " set the space between two words",
3512 "-kerning value set the space between two letters",
3513 "-label string assign a label to an image",
3514 "-limit type value pixel cache resource limit",
3515 "-loop iterations add Netscape loop extension to your GIF animation",
3516 "-mask filename associate a mask with the image",
3517 "-mattecolor color frame color",
3518 "-monitor monitor progress",
3519 "-orient type image orientation",
3520 "-page geometry size and location of an image canvas (setting)",
3521 "-ping efficiently determine image attributes",
3522 "-pointsize value font point size",
3523 "-precision value maximum number of significant digits to print",
3524 "-preview type image preview type",
3525 "-quality value JPEG/MIFF/PNG compression level",
3526 "-quiet suppress all warning messages",
3527 "-red-primary point chromaticity red primary point",
3528 "-regard-warnings pay attention to warning messages",
3529 "-remap filename transform image colors to match this set of colors",
3530 "-respect-parentheses settings remain in effect until parenthesis boundary",
3531 "-sampling-factor geometry",
3532 " horizontal and vertical sampling factor",
3533 "-scene value image scene number",
3534 "-seed value seed a new sequence of pseudo-random numbers",
3535 "-size geometry width and height of image",
3536 "-stretch type render text with this font stretch",
3537 "-stroke color graphic primitive stroke color",
3538 "-strokewidth value graphic primitive stroke width",
3539 "-style type render text with this font style",
3540 "-synchronize synchronize image to storage device",
3541 "-taint declare the image as modified",
3542 "-texture filename name of texture to tile onto the image background",
3543 "-tile-offset geometry",
3545 "-treedepth value color tree depth",
3546 "-transparent-color color",
3547 " transparent color",
3548 "-undercolor color annotation bounding box color",
3549 "-units type the units of image resolution",
3550 "-verbose print detailed information about the image",
3551 "-view FlashPix viewing transforms",
3552 "-virtual-pixel method",
3553 " virtual pixel access method",
3554 "-weight type render text with this font weight",
3555 "-white-point point chromaticity white point",
3560 "-delete indexes delete the image from the image sequence",
3561 "-duplicate count,indexes",
3562 " duplicate an image one or more times",
3563 "-insert index insert last image into the image sequence",
3564 "-reverse reverse image sequence",
3565 "-swap indexes swap two images in the image sequence",
3572 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3573 (void) printf("Copyright: %s\n",GetMagickCopyright());
3574 (void) printf("Features: %s\n\n",GetMagickFeatures());
3575 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3577 (void) printf("\nImage Settings:\n");
3578 for (p=settings; *p != (char *) NULL; p++)
3579 (void) printf(" %s\n",*p);
3580 (void) printf("\nImage Operators:\n");
3581 for (p=operators; *p != (char *) NULL; p++)
3582 (void) printf(" %s\n",*p);
3583 (void) printf("\nImage Sequence Operators:\n");
3584 for (p=sequence_operators; *p != (char *) NULL; p++)
3585 (void) printf(" %s\n",*p);
3586 (void) printf("\nImage Stack Operators:\n");
3587 for (p=stack_operators; *p != (char *) NULL; p++)
3588 (void) printf(" %s\n",*p);
3589 (void) printf("\nMiscellaneous Options:\n");
3590 for (p=miscellaneous; *p != (char *) NULL; p++)
3591 (void) printf(" %s\n",*p);
3593 "\nBy default, the image format of `file' is determined by its magic\n");
3595 "number. To specify a particular image format, precede the filename\n");
3597 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3599 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3600 (void) printf("'-' for standard input or output.\n");
3601 return(MagickFalse);
3604 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3605 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3607 #define DestroyMogrify() \
3609 if (format != (char *) NULL) \
3610 format=DestroyString(format); \
3611 if (path != (char *) NULL) \
3612 path=DestroyString(path); \
3613 DestroyImageStack(); \
3614 for (i=0; i < (ssize_t) argc; i++) \
3615 argv[i]=DestroyString(argv[i]); \
3616 argv=(char **) RelinquishMagickMemory(argv); \
3618 #define ThrowMogrifyException(asperity,tag,option) \
3620 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3623 return(MagickFalse); \
3625 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3627 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3628 "InvalidArgument","`%s': %s",argument,option); \
3630 return(MagickFalse); \
3642 image_stack[MaxImageStackDepth+1];
3650 respect_parenthesis;
3665 assert(image_info != (ImageInfo *) NULL);
3666 assert(image_info->signature == MagickSignature);
3667 if (image_info->debug != MagickFalse)
3668 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3669 assert(exception != (ExceptionInfo *) NULL);
3673 if ((LocaleCompare("version",option+1) == 0) ||
3674 (LocaleCompare("-version",option+1) == 0))
3676 (void) FormatLocaleFile(stdout,"Version: %s\n",
3677 GetMagickVersion((size_t *) NULL));
3678 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3679 GetMagickCopyright());
3680 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3681 GetMagickFeatures());
3682 return(MagickFalse);
3686 return(MogrifyUsage());
3687 format=(char *) NULL;
3689 global_colormap=MagickFalse;
3693 option=(char *) NULL;
3695 respect_parenthesis=MagickFalse;
3700 ReadCommandlLine(argc,&argv);
3701 status=ExpandFilenames(&argc,&argv);
3702 if (status == MagickFalse)
3703 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3704 GetExceptionMessage(errno));
3705 for (i=1; i < (ssize_t) argc; i++)
3708 if (LocaleCompare(option,"(") == 0)
3710 FireImageStack(MagickFalse,MagickTrue,pend);
3711 if (k == MaxImageStackDepth)
3712 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3717 if (LocaleCompare(option,")") == 0)
3719 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3721 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3725 if (IsCommandOption(option) == MagickFalse)
3728 backup_filename[MaxTextExtent],
3735 Option is a file name: begin by reading image from specified file.
3737 FireImageStack(MagickFalse,MagickFalse,pend);
3739 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3741 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3742 images=ReadImages(image_info,exception);
3743 status&=(images != (Image *) NULL) &&
3744 (exception->severity < ErrorException);
3745 if (images == (Image *) NULL)
3747 if (format != (char *) NULL)
3748 (void) CopyMagickString(images->filename,images->magick_filename,
3750 if (path != (char *) NULL)
3752 GetPathComponent(option,TailPath,filename);
3753 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3754 path,*DirectorySeparator,filename);
3756 if (format != (char *) NULL)
3757 AppendImageFormat(format,images->filename);
3758 AppendImageStack(images);
3759 FinalizeImageSettings(image_info,image,MagickFalse);
3760 if (global_colormap != MagickFalse)
3765 quantize_info=AcquireQuantizeInfo(image_info);
3766 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3767 quantize_info=DestroyQuantizeInfo(quantize_info);
3769 *backup_filename='\0';
3770 if ((LocaleCompare(image->filename,"-") != 0) &&
3771 (IsPathWritable(image->filename) != MagickFalse))
3777 Rename image file as backup.
3779 (void) CopyMagickString(backup_filename,image->filename,
3781 for (i=0; i < 6; i++)
3783 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3784 if (IsPathAccessible(backup_filename) == MagickFalse)
3787 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3788 (rename_utf8(image->filename,backup_filename) != 0))
3789 *backup_filename='\0';
3792 Write transmogrified image to disk.
3794 image_info->synchronize=MagickTrue;
3795 status&=WriteImages(image_info,image,image->filename,exception);
3796 if ((status == MagickFalse) && (*backup_filename != '\0'))
3797 (void) remove_utf8(backup_filename);
3798 RemoveAllImageStack();
3801 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3802 switch (*(option+1))
3806 if (LocaleCompare("adaptive-blur",option+1) == 0)
3809 if (i == (ssize_t) argc)
3810 ThrowMogrifyException(OptionError,"MissingArgument",option);
3811 if (IsGeometry(argv[i]) == MagickFalse)
3812 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3815 if (LocaleCompare("adaptive-resize",option+1) == 0)
3818 if (i == (ssize_t) argc)
3819 ThrowMogrifyException(OptionError,"MissingArgument",option);
3820 if (IsGeometry(argv[i]) == MagickFalse)
3821 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3824 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3827 if (i == (ssize_t) argc)
3828 ThrowMogrifyException(OptionError,"MissingArgument",option);
3829 if (IsGeometry(argv[i]) == MagickFalse)
3830 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3833 if (LocaleCompare("affine",option+1) == 0)
3838 if (i == (ssize_t) argc)
3839 ThrowMogrifyException(OptionError,"MissingArgument",option);
3842 if (LocaleCompare("alpha",option+1) == 0)
3850 if (i == (ssize_t) argc)
3851 ThrowMogrifyException(OptionError,"MissingArgument",option);
3852 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3854 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3858 if (LocaleCompare("annotate",option+1) == 0)
3863 if (i == (ssize_t) argc)
3864 ThrowMogrifyException(OptionError,"MissingArgument",option);
3865 if (IsGeometry(argv[i]) == MagickFalse)
3866 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3867 if (i == (ssize_t) argc)
3868 ThrowMogrifyException(OptionError,"MissingArgument",option);
3872 if (LocaleCompare("antialias",option+1) == 0)
3874 if (LocaleCompare("append",option+1) == 0)
3876 if (LocaleCompare("attenuate",option+1) == 0)
3881 if (i == (ssize_t) (argc-1))
3882 ThrowMogrifyException(OptionError,"MissingArgument",option);
3883 if (IsGeometry(argv[i]) == MagickFalse)
3884 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3887 if (LocaleCompare("authenticate",option+1) == 0)
3892 if (i == (ssize_t) argc)
3893 ThrowMogrifyException(OptionError,"MissingArgument",option);
3896 if (LocaleCompare("auto-gamma",option+1) == 0)
3898 if (LocaleCompare("auto-level",option+1) == 0)
3900 if (LocaleCompare("auto-orient",option+1) == 0)
3902 if (LocaleCompare("average",option+1) == 0)
3904 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3908 if (LocaleCompare("background",option+1) == 0)
3913 if (i == (ssize_t) argc)
3914 ThrowMogrifyException(OptionError,"MissingArgument",option);
3917 if (LocaleCompare("bias",option+1) == 0)
3922 if (i == (ssize_t) (argc-1))
3923 ThrowMogrifyException(OptionError,"MissingArgument",option);
3924 if (IsGeometry(argv[i]) == MagickFalse)
3925 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3928 if (LocaleCompare("black-point-compensation",option+1) == 0)
3930 if (LocaleCompare("black-threshold",option+1) == 0)
3935 if (i == (ssize_t) argc)
3936 ThrowMogrifyException(OptionError,"MissingArgument",option);
3937 if (IsGeometry(argv[i]) == MagickFalse)
3938 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3941 if (LocaleCompare("blue-primary",option+1) == 0)
3946 if (i == (ssize_t) argc)
3947 ThrowMogrifyException(OptionError,"MissingArgument",option);
3948 if (IsGeometry(argv[i]) == MagickFalse)
3949 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3952 if (LocaleCompare("blue-shift",option+1) == 0)
3955 if (i == (ssize_t) argc)
3956 ThrowMogrifyException(OptionError,"MissingArgument",option);
3957 if (IsGeometry(argv[i]) == MagickFalse)
3958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3961 if (LocaleCompare("blur",option+1) == 0)
3964 if (i == (ssize_t) argc)
3965 ThrowMogrifyException(OptionError,"MissingArgument",option);
3966 if (IsGeometry(argv[i]) == MagickFalse)
3967 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3970 if (LocaleCompare("border",option+1) == 0)
3975 if (i == (ssize_t) argc)
3976 ThrowMogrifyException(OptionError,"MissingArgument",option);
3977 if (IsGeometry(argv[i]) == MagickFalse)
3978 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3981 if (LocaleCompare("bordercolor",option+1) == 0)
3986 if (i == (ssize_t) argc)
3987 ThrowMogrifyException(OptionError,"MissingArgument",option);
3990 if (LocaleCompare("box",option+1) == 0)
3995 if (i == (ssize_t) argc)
3996 ThrowMogrifyException(OptionError,"MissingArgument",option);
3999 if (LocaleCompare("brightness-contrast",option+1) == 0)
4002 if (i == (ssize_t) argc)
4003 ThrowMogrifyException(OptionError,"MissingArgument",option);
4004 if (IsGeometry(argv[i]) == MagickFalse)
4005 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4008 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4012 if (LocaleCompare("cache",option+1) == 0)
4017 if (i == (ssize_t) argc)
4018 ThrowMogrifyException(OptionError,"MissingArgument",option);
4019 if (IsGeometry(argv[i]) == MagickFalse)
4020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4023 if (LocaleCompare("caption",option+1) == 0)
4028 if (i == (ssize_t) argc)
4029 ThrowMogrifyException(OptionError,"MissingArgument",option);
4032 if (LocaleCompare("channel",option+1) == 0)
4040 if (i == (ssize_t) (argc-1))
4041 ThrowMogrifyException(OptionError,"MissingArgument",option);
4042 channel=ParseChannelOption(argv[i]);
4044 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4048 if (LocaleCompare("cdl",option+1) == 0)
4053 if (i == (ssize_t) (argc-1))
4054 ThrowMogrifyException(OptionError,"MissingArgument",option);
4057 if (LocaleCompare("charcoal",option+1) == 0)
4062 if (i == (ssize_t) argc)
4063 ThrowMogrifyException(OptionError,"MissingArgument",option);
4064 if (IsGeometry(argv[i]) == MagickFalse)
4065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4068 if (LocaleCompare("chop",option+1) == 0)
4073 if (i == (ssize_t) argc)
4074 ThrowMogrifyException(OptionError,"MissingArgument",option);
4075 if (IsGeometry(argv[i]) == MagickFalse)
4076 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4079 if (LocaleCompare("clamp",option+1) == 0)
4081 if (LocaleCompare("clip",option+1) == 0)
4083 if (LocaleCompare("clip-mask",option+1) == 0)
4088 if (i == (ssize_t) argc)
4089 ThrowMogrifyException(OptionError,"MissingArgument",option);
4092 if (LocaleCompare("clut",option+1) == 0)
4094 if (LocaleCompare("coalesce",option+1) == 0)
4096 if (LocaleCompare("colorize",option+1) == 0)
4101 if (i == (ssize_t) argc)
4102 ThrowMogrifyException(OptionError,"MissingArgument",option);
4103 if (IsGeometry(argv[i]) == MagickFalse)
4104 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4107 if (LocaleCompare("color-matrix",option+1) == 0)
4115 if (i == (ssize_t) (argc-1))
4116 ThrowMogrifyException(OptionError,"MissingArgument",option);
4117 kernel_info=AcquireKernelInfo(argv[i]);
4118 if (kernel_info == (KernelInfo *) NULL)
4119 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4120 kernel_info=DestroyKernelInfo(kernel_info);
4123 if (LocaleCompare("colors",option+1) == 0)
4128 if (i == (ssize_t) argc)
4129 ThrowMogrifyException(OptionError,"MissingArgument",option);
4130 if (IsGeometry(argv[i]) == MagickFalse)
4131 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4134 if (LocaleCompare("colorspace",option+1) == 0)
4142 if (i == (ssize_t) argc)
4143 ThrowMogrifyException(OptionError,"MissingArgument",option);
4144 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4147 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4151 if (LocaleCompare("combine",option+1) == 0)
4153 if (LocaleCompare("comment",option+1) == 0)
4158 if (i == (ssize_t) argc)
4159 ThrowMogrifyException(OptionError,"MissingArgument",option);
4162 if (LocaleCompare("composite",option+1) == 0)
4164 if (LocaleCompare("compress",option+1) == 0)
4172 if (i == (ssize_t) argc)
4173 ThrowMogrifyException(OptionError,"MissingArgument",option);
4174 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4177 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4181 if (LocaleCompare("concurrent",option+1) == 0)
4183 if (LocaleCompare("contrast",option+1) == 0)
4185 if (LocaleCompare("contrast-stretch",option+1) == 0)
4188 if (i == (ssize_t) argc)
4189 ThrowMogrifyException(OptionError,"MissingArgument",option);
4190 if (IsGeometry(argv[i]) == MagickFalse)
4191 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4194 if (LocaleCompare("convolve",option+1) == 0)
4202 if (i == (ssize_t) argc)
4203 ThrowMogrifyException(OptionError,"MissingArgument",option);
4204 kernel_info=AcquireKernelInfo(argv[i]);
4205 if (kernel_info == (KernelInfo *) NULL)
4206 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4207 kernel_info=DestroyKernelInfo(kernel_info);
4210 if (LocaleCompare("crop",option+1) == 0)
4215 if (i == (ssize_t) argc)
4216 ThrowMogrifyException(OptionError,"MissingArgument",option);
4217 if (IsGeometry(argv[i]) == MagickFalse)
4218 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4221 if (LocaleCompare("cycle",option+1) == 0)
4226 if (i == (ssize_t) argc)
4227 ThrowMogrifyException(OptionError,"MissingArgument",option);
4228 if (IsGeometry(argv[i]) == MagickFalse)
4229 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4232 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4236 if (LocaleCompare("decipher",option+1) == 0)
4241 if (i == (ssize_t) (argc-1))
4242 ThrowMogrifyException(OptionError,"MissingArgument",option);
4245 if (LocaleCompare("deconstruct",option+1) == 0)
4247 if (LocaleCompare("debug",option+1) == 0)
4255 if (i == (ssize_t) argc)
4256 ThrowMogrifyException(OptionError,"MissingArgument",option);
4257 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4259 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4261 (void) SetLogEventMask(argv[i]);
4264 if (LocaleCompare("define",option+1) == 0)
4267 if (i == (ssize_t) argc)
4268 ThrowMogrifyException(OptionError,"MissingArgument",option);
4274 define=GetImageOption(image_info,argv[i]);
4275 if (define == (const char *) NULL)
4276 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4281 if (LocaleCompare("delay",option+1) == 0)
4286 if (i == (ssize_t) argc)
4287 ThrowMogrifyException(OptionError,"MissingArgument",option);
4288 if (IsGeometry(argv[i]) == MagickFalse)
4289 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4292 if (LocaleCompare("delete",option+1) == 0)
4297 if (i == (ssize_t) (argc-1))
4298 ThrowMogrifyException(OptionError,"MissingArgument",option);
4299 if (IsGeometry(argv[i]) == MagickFalse)
4300 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4303 if (LocaleCompare("density",option+1) == 0)
4308 if (i == (ssize_t) argc)
4309 ThrowMogrifyException(OptionError,"MissingArgument",option);
4310 if (IsGeometry(argv[i]) == MagickFalse)
4311 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4314 if (LocaleCompare("depth",option+1) == 0)
4319 if (i == (ssize_t) argc)
4320 ThrowMogrifyException(OptionError,"MissingArgument",option);
4321 if (IsGeometry(argv[i]) == MagickFalse)
4322 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4325 if (LocaleCompare("deskew",option+1) == 0)
4330 if (i == (ssize_t) argc)
4331 ThrowMogrifyException(OptionError,"MissingArgument",option);
4332 if (IsGeometry(argv[i]) == MagickFalse)
4333 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4336 if (LocaleCompare("despeckle",option+1) == 0)
4338 if (LocaleCompare("dft",option+1) == 0)
4340 if (LocaleCompare("direction",option+1) == 0)
4348 if (i == (ssize_t) argc)
4349 ThrowMogrifyException(OptionError,"MissingArgument",option);
4350 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4353 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4357 if (LocaleCompare("display",option+1) == 0)
4362 if (i == (ssize_t) argc)
4363 ThrowMogrifyException(OptionError,"MissingArgument",option);
4366 if (LocaleCompare("dispose",option+1) == 0)
4374 if (i == (ssize_t) argc)
4375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4376 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4378 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4382 if (LocaleCompare("distort",option+1) == 0)
4388 if (i == (ssize_t) argc)
4389 ThrowMogrifyException(OptionError,"MissingArgument",option);
4390 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4392 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4395 if (i == (ssize_t) (argc-1))
4396 ThrowMogrifyException(OptionError,"MissingArgument",option);
4399 if (LocaleCompare("dither",option+1) == 0)
4407 if (i == (ssize_t) argc)
4408 ThrowMogrifyException(OptionError,"MissingArgument",option);
4409 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4411 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4415 if (LocaleCompare("draw",option+1) == 0)
4420 if (i == (ssize_t) argc)
4421 ThrowMogrifyException(OptionError,"MissingArgument",option);
4424 if (LocaleCompare("duplicate",option+1) == 0)
4429 if (i == (ssize_t) (argc-1))
4430 ThrowMogrifyException(OptionError,"MissingArgument",option);
4431 if (IsGeometry(argv[i]) == MagickFalse)
4432 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4435 if (LocaleCompare("duration",option+1) == 0)
4440 if (i == (ssize_t) (argc-1))
4441 ThrowMogrifyException(OptionError,"MissingArgument",option);
4442 if (IsGeometry(argv[i]) == MagickFalse)
4443 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4446 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4450 if (LocaleCompare("edge",option+1) == 0)
4455 if (i == (ssize_t) argc)
4456 ThrowMogrifyException(OptionError,"MissingArgument",option);
4457 if (IsGeometry(argv[i]) == MagickFalse)
4458 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4461 if (LocaleCompare("emboss",option+1) == 0)
4466 if (i == (ssize_t) argc)
4467 ThrowMogrifyException(OptionError,"MissingArgument",option);
4468 if (IsGeometry(argv[i]) == MagickFalse)
4469 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4472 if (LocaleCompare("encipher",option+1) == 0)
4477 if (i == (ssize_t) argc)
4478 ThrowMogrifyException(OptionError,"MissingArgument",option);
4481 if (LocaleCompare("encoding",option+1) == 0)
4486 if (i == (ssize_t) argc)
4487 ThrowMogrifyException(OptionError,"MissingArgument",option);
4490 if (LocaleCompare("endian",option+1) == 0)
4498 if (i == (ssize_t) argc)
4499 ThrowMogrifyException(OptionError,"MissingArgument",option);
4500 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4502 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4506 if (LocaleCompare("enhance",option+1) == 0)
4508 if (LocaleCompare("equalize",option+1) == 0)
4510 if (LocaleCompare("evaluate",option+1) == 0)
4518 if (i == (ssize_t) argc)
4519 ThrowMogrifyException(OptionError,"MissingArgument",option);
4520 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4522 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4525 if (i == (ssize_t) (argc-1))
4526 ThrowMogrifyException(OptionError,"MissingArgument",option);
4527 if (IsGeometry(argv[i]) == MagickFalse)
4528 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4531 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4539 if (i == (ssize_t) argc)
4540 ThrowMogrifyException(OptionError,"MissingArgument",option);
4541 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4543 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4547 if (LocaleCompare("extent",option+1) == 0)
4552 if (i == (ssize_t) argc)
4553 ThrowMogrifyException(OptionError,"MissingArgument",option);
4554 if (IsGeometry(argv[i]) == MagickFalse)
4555 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4558 if (LocaleCompare("extract",option+1) == 0)
4563 if (i == (ssize_t) argc)
4564 ThrowMogrifyException(OptionError,"MissingArgument",option);
4565 if (IsGeometry(argv[i]) == MagickFalse)
4566 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4569 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4573 if (LocaleCompare("family",option+1) == 0)
4578 if (i == (ssize_t) (argc-1))
4579 ThrowMogrifyException(OptionError,"MissingArgument",option);
4582 if (LocaleCompare("fill",option+1) == 0)
4587 if (i == (ssize_t) argc)
4588 ThrowMogrifyException(OptionError,"MissingArgument",option);
4591 if (LocaleCompare("filter",option+1) == 0)
4599 if (i == (ssize_t) argc)
4600 ThrowMogrifyException(OptionError,"MissingArgument",option);
4601 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4603 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4607 if (LocaleCompare("flatten",option+1) == 0)
4609 if (LocaleCompare("flip",option+1) == 0)
4611 if (LocaleCompare("flop",option+1) == 0)
4613 if (LocaleCompare("floodfill",option+1) == 0)
4618 if (i == (ssize_t) argc)
4619 ThrowMogrifyException(OptionError,"MissingArgument",option);
4620 if (IsGeometry(argv[i]) == MagickFalse)
4621 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4623 if (i == (ssize_t) argc)
4624 ThrowMogrifyException(OptionError,"MissingArgument",option);
4627 if (LocaleCompare("font",option+1) == 0)
4632 if (i == (ssize_t) argc)
4633 ThrowMogrifyException(OptionError,"MissingArgument",option);
4636 if (LocaleCompare("format",option+1) == 0)
4638 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4639 (void) CloneString(&format,(char *) NULL);
4643 if (i == (ssize_t) argc)
4644 ThrowMogrifyException(OptionError,"MissingArgument",option);
4645 (void) CloneString(&format,argv[i]);
4646 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4647 (void) ConcatenateMagickString(image_info->filename,":",
4649 (void) SetImageInfo(image_info,0,exception);
4650 if (*image_info->magick == '\0')
4651 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4655 if (LocaleCompare("frame",option+1) == 0)
4660 if (i == (ssize_t) argc)
4661 ThrowMogrifyException(OptionError,"MissingArgument",option);
4662 if (IsGeometry(argv[i]) == MagickFalse)
4663 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4666 if (LocaleCompare("function",option+1) == 0)
4674 if (i == (ssize_t) argc)
4675 ThrowMogrifyException(OptionError,"MissingArgument",option);
4676 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4678 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4680 if (i == (ssize_t) (argc-1))
4681 ThrowMogrifyException(OptionError,"MissingArgument",option);
4684 if (LocaleCompare("fuzz",option+1) == 0)
4689 if (i == (ssize_t) argc)
4690 ThrowMogrifyException(OptionError,"MissingArgument",option);
4691 if (IsGeometry(argv[i]) == MagickFalse)
4692 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4695 if (LocaleCompare("fx",option+1) == 0)
4700 if (i == (ssize_t) (argc-1))
4701 ThrowMogrifyException(OptionError,"MissingArgument",option);
4704 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4708 if (LocaleCompare("gamma",option+1) == 0)
4711 if (i == (ssize_t) argc)
4712 ThrowMogrifyException(OptionError,"MissingArgument",option);
4713 if (IsGeometry(argv[i]) == MagickFalse)
4714 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4717 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4718 (LocaleCompare("gaussian",option+1) == 0))
4721 if (i == (ssize_t) argc)
4722 ThrowMogrifyException(OptionError,"MissingArgument",option);
4723 if (IsGeometry(argv[i]) == MagickFalse)
4724 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4727 if (LocaleCompare("geometry",option+1) == 0)
4732 if (i == (ssize_t) argc)
4733 ThrowMogrifyException(OptionError,"MissingArgument",option);
4734 if (IsGeometry(argv[i]) == MagickFalse)
4735 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4738 if (LocaleCompare("gravity",option+1) == 0)
4746 if (i == (ssize_t) argc)
4747 ThrowMogrifyException(OptionError,"MissingArgument",option);
4748 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4750 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4754 if (LocaleCompare("green-primary",option+1) == 0)
4759 if (i == (ssize_t) argc)
4760 ThrowMogrifyException(OptionError,"MissingArgument",option);
4761 if (IsGeometry(argv[i]) == MagickFalse)
4762 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4765 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4769 if (LocaleCompare("hald-clut",option+1) == 0)
4771 if ((LocaleCompare("help",option+1) == 0) ||
4772 (LocaleCompare("-help",option+1) == 0))
4773 return(MogrifyUsage());
4774 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4778 if (LocaleCompare("identify",option+1) == 0)
4780 if (LocaleCompare("idft",option+1) == 0)
4782 if (LocaleCompare("implode",option+1) == 0)
4787 if (i == (ssize_t) argc)
4788 ThrowMogrifyException(OptionError,"MissingArgument",option);
4789 if (IsGeometry(argv[i]) == MagickFalse)
4790 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4793 if (LocaleCompare("intent",option+1) == 0)
4801 if (i == (ssize_t) (argc-1))
4802 ThrowMogrifyException(OptionError,"MissingArgument",option);
4803 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4805 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4809 if (LocaleCompare("interlace",option+1) == 0)
4817 if (i == (ssize_t) argc)
4818 ThrowMogrifyException(OptionError,"MissingArgument",option);
4819 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4822 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4826 if (LocaleCompare("interline-spacing",option+1) == 0)
4831 if (i == (ssize_t) (argc-1))
4832 ThrowMogrifyException(OptionError,"MissingArgument",option);
4833 if (IsGeometry(argv[i]) == MagickFalse)
4834 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4837 if (LocaleCompare("interpolate",option+1) == 0)
4845 if (i == (ssize_t) argc)
4846 ThrowMogrifyException(OptionError,"MissingArgument",option);
4847 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4849 if (interpolate < 0)
4850 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4854 if (LocaleCompare("interword-spacing",option+1) == 0)
4859 if (i == (ssize_t) (argc-1))
4860 ThrowMogrifyException(OptionError,"MissingArgument",option);
4861 if (IsGeometry(argv[i]) == MagickFalse)
4862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4865 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4869 if (LocaleCompare("kerning",option+1) == 0)
4874 if (i == (ssize_t) (argc-1))
4875 ThrowMogrifyException(OptionError,"MissingArgument",option);
4876 if (IsGeometry(argv[i]) == MagickFalse)
4877 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4880 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4884 if (LocaleCompare("label",option+1) == 0)
4889 if (i == (ssize_t) argc)
4890 ThrowMogrifyException(OptionError,"MissingArgument",option);
4893 if (LocaleCompare("lat",option+1) == 0)
4898 if (i == (ssize_t) argc)
4899 ThrowMogrifyException(OptionError,"MissingArgument",option);
4900 if (IsGeometry(argv[i]) == MagickFalse)
4901 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4903 if (LocaleCompare("layers",option+1) == 0)
4911 if (i == (ssize_t) (argc-1))
4912 ThrowMogrifyException(OptionError,"MissingArgument",option);
4913 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4915 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4919 if (LocaleCompare("level",option+1) == 0)
4922 if (i == (ssize_t) argc)
4923 ThrowMogrifyException(OptionError,"MissingArgument",option);
4924 if (IsGeometry(argv[i]) == MagickFalse)
4925 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4928 if (LocaleCompare("level-colors",option+1) == 0)
4931 if (i == (ssize_t) argc)
4932 ThrowMogrifyException(OptionError,"MissingArgument",option);
4935 if (LocaleCompare("linewidth",option+1) == 0)
4940 if (i == (ssize_t) argc)
4941 ThrowMogrifyException(OptionError,"MissingArgument",option);
4942 if (IsGeometry(argv[i]) == MagickFalse)
4943 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4946 if (LocaleCompare("limit",option+1) == 0)
4960 if (i == (ssize_t) argc)
4961 ThrowMogrifyException(OptionError,"MissingArgument",option);
4962 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4965 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4968 if (i == (ssize_t) argc)
4969 ThrowMogrifyException(OptionError,"MissingArgument",option);
4970 value=StringToDouble(argv[i],&p);
4972 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4973 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4976 if (LocaleCompare("liquid-rescale",option+1) == 0)
4979 if (i == (ssize_t) argc)
4980 ThrowMogrifyException(OptionError,"MissingArgument",option);
4981 if (IsGeometry(argv[i]) == MagickFalse)
4982 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4985 if (LocaleCompare("list",option+1) == 0)
4993 if (i == (ssize_t) argc)
4994 ThrowMogrifyException(OptionError,"MissingArgument",option);
4995 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4997 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4998 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5000 return(status != 0 ? MagickFalse : MagickTrue);
5002 if (LocaleCompare("log",option+1) == 0)
5007 if ((i == (ssize_t) argc) ||
5008 (strchr(argv[i],'%') == (char *) NULL))
5009 ThrowMogrifyException(OptionError,"MissingArgument",option);
5012 if (LocaleCompare("loop",option+1) == 0)
5017 if (i == (ssize_t) argc)
5018 ThrowMogrifyException(OptionError,"MissingArgument",option);
5019 if (IsGeometry(argv[i]) == MagickFalse)
5020 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5023 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5027 if (LocaleCompare("map",option+1) == 0)
5029 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5033 if (i == (ssize_t) argc)
5034 ThrowMogrifyException(OptionError,"MissingArgument",option);
5037 if (LocaleCompare("mask",option+1) == 0)
5042 if (i == (ssize_t) argc)
5043 ThrowMogrifyException(OptionError,"MissingArgument",option);
5046 if (LocaleCompare("matte",option+1) == 0)
5048 if (LocaleCompare("mattecolor",option+1) == 0)
5053 if (i == (ssize_t) argc)
5054 ThrowMogrifyException(OptionError,"MissingArgument",option);
5057 if (LocaleCompare("maximum",option+1) == 0)
5059 if (LocaleCompare("minimum",option+1) == 0)
5061 if (LocaleCompare("modulate",option+1) == 0)
5066 if (i == (ssize_t) argc)
5067 ThrowMogrifyException(OptionError,"MissingArgument",option);
5068 if (IsGeometry(argv[i]) == MagickFalse)
5069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5072 if (LocaleCompare("median",option+1) == 0)
5077 if (i == (ssize_t) argc)
5078 ThrowMogrifyException(OptionError,"MissingArgument",option);
5079 if (IsGeometry(argv[i]) == MagickFalse)
5080 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5083 if (LocaleCompare("mode",option+1) == 0)
5088 if (i == (ssize_t) argc)
5089 ThrowMogrifyException(OptionError,"MissingArgument",option);
5090 if (IsGeometry(argv[i]) == MagickFalse)
5091 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5094 if (LocaleCompare("monitor",option+1) == 0)
5096 if (LocaleCompare("monochrome",option+1) == 0)
5098 if (LocaleCompare("morph",option+1) == 0)
5103 if (i == (ssize_t) (argc-1))
5104 ThrowMogrifyException(OptionError,"MissingArgument",option);
5105 if (IsGeometry(argv[i]) == MagickFalse)
5106 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5109 if (LocaleCompare("morphology",option+1) == 0)
5112 token[MaxTextExtent];
5121 if (i == (ssize_t) argc)
5122 ThrowMogrifyException(OptionError,"MissingArgument",option);
5123 GetMagickToken(argv[i],NULL,token);
5124 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5126 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5129 if (i == (ssize_t) (argc-1))
5130 ThrowMogrifyException(OptionError,"MissingArgument",option);
5131 kernel_info=AcquireKernelInfo(argv[i]);
5132 if (kernel_info == (KernelInfo *) NULL)
5133 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5134 kernel_info=DestroyKernelInfo(kernel_info);
5137 if (LocaleCompare("mosaic",option+1) == 0)
5139 if (LocaleCompare("motion-blur",option+1) == 0)
5144 if (i == (ssize_t) argc)
5145 ThrowMogrifyException(OptionError,"MissingArgument",option);
5146 if (IsGeometry(argv[i]) == MagickFalse)
5147 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5150 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5154 if (LocaleCompare("negate",option+1) == 0)
5156 if (LocaleCompare("noise",option+1) == 0)
5159 if (i == (ssize_t) argc)
5160 ThrowMogrifyException(OptionError,"MissingArgument",option);
5166 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5168 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5172 if (IsGeometry(argv[i]) == MagickFalse)
5173 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5176 if (LocaleCompare("noop",option+1) == 0)
5178 if (LocaleCompare("normalize",option+1) == 0)
5180 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5184 if (LocaleCompare("opaque",option+1) == 0)
5187 if (i == (ssize_t) argc)
5188 ThrowMogrifyException(OptionError,"MissingArgument",option);
5191 if (LocaleCompare("ordered-dither",option+1) == 0)
5196 if (i == (ssize_t) argc)
5197 ThrowMogrifyException(OptionError,"MissingArgument",option);
5200 if (LocaleCompare("orient",option+1) == 0)
5205 orientation=UndefinedOrientation;
5209 if (i == (ssize_t) (argc-1))
5210 ThrowMogrifyException(OptionError,"MissingArgument",option);
5211 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5213 if (orientation < 0)
5214 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5218 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5222 if (LocaleCompare("page",option+1) == 0)
5227 if (i == (ssize_t) argc)
5228 ThrowMogrifyException(OptionError,"MissingArgument",option);
5231 if (LocaleCompare("paint",option+1) == 0)
5236 if (i == (ssize_t) argc)
5237 ThrowMogrifyException(OptionError,"MissingArgument",option);
5238 if (IsGeometry(argv[i]) == MagickFalse)
5239 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5242 if (LocaleCompare("path",option+1) == 0)
5244 (void) CloneString(&path,(char *) NULL);
5248 if (i == (ssize_t) argc)
5249 ThrowMogrifyException(OptionError,"MissingArgument",option);
5250 (void) CloneString(&path,argv[i]);
5253 if (LocaleCompare("pointsize",option+1) == 0)
5258 if (i == (ssize_t) argc)
5259 ThrowMogrifyException(OptionError,"MissingArgument",option);
5260 if (IsGeometry(argv[i]) == MagickFalse)
5261 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5264 if (LocaleCompare("polaroid",option+1) == 0)
5269 if (i == (ssize_t) argc)
5270 ThrowMogrifyException(OptionError,"MissingArgument",option);
5271 if (IsGeometry(argv[i]) == MagickFalse)
5272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5275 if (LocaleCompare("posterize",option+1) == 0)
5280 if (i == (ssize_t) argc)
5281 ThrowMogrifyException(OptionError,"MissingArgument",option);
5282 if (IsGeometry(argv[i]) == MagickFalse)
5283 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5286 if (LocaleCompare("precision",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("print",option+1) == 0)
5302 if (i == (ssize_t) argc)
5303 ThrowMogrifyException(OptionError,"MissingArgument",option);
5306 if (LocaleCompare("process",option+1) == 0)
5311 if (i == (ssize_t) (argc-1))
5312 ThrowMogrifyException(OptionError,"MissingArgument",option);
5315 if (LocaleCompare("profile",option+1) == 0)
5318 if (i == (ssize_t) argc)
5319 ThrowMogrifyException(OptionError,"MissingArgument",option);
5322 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5326 if (LocaleCompare("quality",option+1) == 0)
5331 if (i == (ssize_t) argc)
5332 ThrowMogrifyException(OptionError,"MissingArgument",option);
5333 if (IsGeometry(argv[i]) == MagickFalse)
5334 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5337 if (LocaleCompare("quantize",option+1) == 0)
5345 if (i == (ssize_t) (argc-1))
5346 ThrowMogrifyException(OptionError,"MissingArgument",option);
5347 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5350 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5354 if (LocaleCompare("quiet",option+1) == 0)
5356 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5360 if (LocaleCompare("radial-blur",option+1) == 0)
5363 if (i == (ssize_t) argc)
5364 ThrowMogrifyException(OptionError,"MissingArgument",option);
5365 if (IsGeometry(argv[i]) == MagickFalse)
5366 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5369 if (LocaleCompare("raise",option+1) == 0)
5372 if (i == (ssize_t) argc)
5373 ThrowMogrifyException(OptionError,"MissingArgument",option);
5374 if (IsGeometry(argv[i]) == MagickFalse)
5375 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5378 if (LocaleCompare("random-threshold",option+1) == 0)
5383 if (i == (ssize_t) argc)
5384 ThrowMogrifyException(OptionError,"MissingArgument",option);
5385 if (IsGeometry(argv[i]) == MagickFalse)
5386 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5389 if (LocaleCompare("recolor",option+1) == 0)
5394 if (i == (ssize_t) (argc-1))
5395 ThrowMogrifyException(OptionError,"MissingArgument",option);
5396 if (IsGeometry(argv[i]) == MagickFalse)
5397 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5400 if (LocaleCompare("red-primary",option+1) == 0)
5405 if (i == (ssize_t) argc)
5406 ThrowMogrifyException(OptionError,"MissingArgument",option);
5407 if (IsGeometry(argv[i]) == MagickFalse)
5408 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5410 if (LocaleCompare("regard-warnings",option+1) == 0)
5412 if (LocaleCompare("region",option+1) == 0)
5417 if (i == (ssize_t) argc)
5418 ThrowMogrifyException(OptionError,"MissingArgument",option);
5419 if (IsGeometry(argv[i]) == MagickFalse)
5420 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5423 if (LocaleCompare("remap",option+1) == 0)
5428 if (i == (ssize_t) (argc-1))
5429 ThrowMogrifyException(OptionError,"MissingArgument",option);
5432 if (LocaleCompare("render",option+1) == 0)
5434 if (LocaleCompare("repage",option+1) == 0)
5439 if (i == (ssize_t) argc)
5440 ThrowMogrifyException(OptionError,"MissingArgument",option);
5441 if (IsGeometry(argv[i]) == MagickFalse)
5442 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5445 if (LocaleCompare("resample",option+1) == 0)
5450 if (i == (ssize_t) argc)
5451 ThrowMogrifyException(OptionError,"MissingArgument",option);
5452 if (IsGeometry(argv[i]) == MagickFalse)
5453 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5456 if (LocaleCompare("resize",option+1) == 0)
5461 if (i == (ssize_t) argc)
5462 ThrowMogrifyException(OptionError,"MissingArgument",option);
5463 if (IsGeometry(argv[i]) == MagickFalse)
5464 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5467 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5469 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5472 if (LocaleCompare("reverse",option+1) == 0)
5474 if (LocaleCompare("roll",option+1) == 0)
5479 if (i == (ssize_t) argc)
5480 ThrowMogrifyException(OptionError,"MissingArgument",option);
5481 if (IsGeometry(argv[i]) == MagickFalse)
5482 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5485 if (LocaleCompare("rotate",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 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5498 if (LocaleCompare("sample",option+1) == 0)
5503 if (i == (ssize_t) argc)
5504 ThrowMogrifyException(OptionError,"MissingArgument",option);
5505 if (IsGeometry(argv[i]) == MagickFalse)
5506 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5509 if (LocaleCompare("sampling-factor",option+1) == 0)
5514 if (i == (ssize_t) argc)
5515 ThrowMogrifyException(OptionError,"MissingArgument",option);
5516 if (IsGeometry(argv[i]) == MagickFalse)
5517 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5520 if (LocaleCompare("scale",option+1) == 0)
5525 if (i == (ssize_t) argc)
5526 ThrowMogrifyException(OptionError,"MissingArgument",option);
5527 if (IsGeometry(argv[i]) == MagickFalse)
5528 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5531 if (LocaleCompare("scene",option+1) == 0)
5536 if (i == (ssize_t) argc)
5537 ThrowMogrifyException(OptionError,"MissingArgument",option);
5538 if (IsGeometry(argv[i]) == MagickFalse)
5539 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5542 if (LocaleCompare("seed",option+1) == 0)
5547 if (i == (ssize_t) argc)
5548 ThrowMogrifyException(OptionError,"MissingArgument",option);
5549 if (IsGeometry(argv[i]) == MagickFalse)
5550 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5553 if (LocaleCompare("segment",option+1) == 0)
5558 if (i == (ssize_t) argc)
5559 ThrowMogrifyException(OptionError,"MissingArgument",option);
5560 if (IsGeometry(argv[i]) == MagickFalse)
5561 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5564 if (LocaleCompare("selective-blur",option+1) == 0)
5567 if (i == (ssize_t) argc)
5568 ThrowMogrifyException(OptionError,"MissingArgument",option);
5569 if (IsGeometry(argv[i]) == MagickFalse)
5570 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5573 if (LocaleCompare("separate",option+1) == 0)
5575 if (LocaleCompare("sepia-tone",option+1) == 0)
5580 if (i == (ssize_t) argc)
5581 ThrowMogrifyException(OptionError,"MissingArgument",option);
5582 if (IsGeometry(argv[i]) == MagickFalse)
5583 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5586 if (LocaleCompare("set",option+1) == 0)
5589 if (i == (ssize_t) argc)
5590 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (i == (ssize_t) argc)
5595 ThrowMogrifyException(OptionError,"MissingArgument",option);
5598 if (LocaleCompare("shade",option+1) == 0)
5601 if (i == (ssize_t) argc)
5602 ThrowMogrifyException(OptionError,"MissingArgument",option);
5603 if (IsGeometry(argv[i]) == MagickFalse)
5604 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5607 if (LocaleCompare("shadow",option+1) == 0)
5612 if (i == (ssize_t) argc)
5613 ThrowMogrifyException(OptionError,"MissingArgument",option);
5614 if (IsGeometry(argv[i]) == MagickFalse)
5615 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5618 if (LocaleCompare("sharpen",option+1) == 0)
5621 if (i == (ssize_t) argc)
5622 ThrowMogrifyException(OptionError,"MissingArgument",option);
5623 if (IsGeometry(argv[i]) == MagickFalse)
5624 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5627 if (LocaleCompare("shave",option+1) == 0)
5632 if (i == (ssize_t) argc)
5633 ThrowMogrifyException(OptionError,"MissingArgument",option);
5634 if (IsGeometry(argv[i]) == MagickFalse)
5635 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5638 if (LocaleCompare("shear",option+1) == 0)
5641 if (i == (ssize_t) argc)
5642 ThrowMogrifyException(OptionError,"MissingArgument",option);
5643 if (IsGeometry(argv[i]) == MagickFalse)
5644 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5647 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5650 if (i == (ssize_t) (argc-1))
5651 ThrowMogrifyException(OptionError,"MissingArgument",option);
5652 if (IsGeometry(argv[i]) == MagickFalse)
5653 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5656 if (LocaleCompare("size",option+1) == 0)
5661 if (i == (ssize_t) argc)
5662 ThrowMogrifyException(OptionError,"MissingArgument",option);
5663 if (IsGeometry(argv[i]) == MagickFalse)
5664 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5667 if (LocaleCompare("sketch",option+1) == 0)
5672 if (i == (ssize_t) argc)
5673 ThrowMogrifyException(OptionError,"MissingArgument",option);
5674 if (IsGeometry(argv[i]) == MagickFalse)
5675 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5678 if (LocaleCompare("smush",option+1) == 0)
5681 if (i == (ssize_t) argc)
5682 ThrowMogrifyException(OptionError,"MissingArgument",option);
5683 if (IsGeometry(argv[i]) == MagickFalse)
5684 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5688 if (LocaleCompare("solarize",option+1) == 0)
5693 if (i == (ssize_t) argc)
5694 ThrowMogrifyException(OptionError,"MissingArgument",option);
5695 if (IsGeometry(argv[i]) == MagickFalse)
5696 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5699 if (LocaleCompare("sparse-color",option+1) == 0)
5705 if (i == (ssize_t) argc)
5706 ThrowMogrifyException(OptionError,"MissingArgument",option);
5707 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5709 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5712 if (i == (ssize_t) (argc-1))
5713 ThrowMogrifyException(OptionError,"MissingArgument",option);
5716 if (LocaleCompare("spread",option+1) == 0)
5721 if (i == (ssize_t) argc)
5722 ThrowMogrifyException(OptionError,"MissingArgument",option);
5723 if (IsGeometry(argv[i]) == MagickFalse)
5724 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5727 if (LocaleCompare("statistic",option+1) == 0)
5735 if (i == (ssize_t) argc)
5736 ThrowMogrifyException(OptionError,"MissingArgument",option);
5737 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5739 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5742 if (i == (ssize_t) (argc-1))
5743 ThrowMogrifyException(OptionError,"MissingArgument",option);
5744 if (IsGeometry(argv[i]) == MagickFalse)
5745 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5748 if (LocaleCompare("stretch",option+1) == 0)
5756 if (i == (ssize_t) (argc-1))
5757 ThrowMogrifyException(OptionError,"MissingArgument",option);
5758 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5760 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5764 if (LocaleCompare("strip",option+1) == 0)
5766 if (LocaleCompare("stroke",option+1) == 0)
5771 if (i == (ssize_t) argc)
5772 ThrowMogrifyException(OptionError,"MissingArgument",option);
5775 if (LocaleCompare("strokewidth",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("style",option+1) == 0)
5794 if (i == (ssize_t) (argc-1))
5795 ThrowMogrifyException(OptionError,"MissingArgument",option);
5796 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5798 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5802 if (LocaleCompare("swap",option+1) == 0)
5807 if (i == (ssize_t) (argc-1))
5808 ThrowMogrifyException(OptionError,"MissingArgument",option);
5809 if (IsGeometry(argv[i]) == MagickFalse)
5810 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5813 if (LocaleCompare("swirl",option+1) == 0)
5818 if (i == (ssize_t) argc)
5819 ThrowMogrifyException(OptionError,"MissingArgument",option);
5820 if (IsGeometry(argv[i]) == MagickFalse)
5821 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5824 if (LocaleCompare("synchronize",option+1) == 0)
5826 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5830 if (LocaleCompare("taint",option+1) == 0)
5832 if (LocaleCompare("texture",option+1) == 0)
5837 if (i == (ssize_t) argc)
5838 ThrowMogrifyException(OptionError,"MissingArgument",option);
5841 if (LocaleCompare("tile",option+1) == 0)
5846 if (i == (ssize_t) (argc-1))
5847 ThrowMogrifyException(OptionError,"MissingArgument",option);
5850 if (LocaleCompare("tile-offset",option+1) == 0)
5855 if (i == (ssize_t) argc)
5856 ThrowMogrifyException(OptionError,"MissingArgument",option);
5857 if (IsGeometry(argv[i]) == MagickFalse)
5858 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5861 if (LocaleCompare("tint",option+1) == 0)
5866 if (i == (ssize_t) (argc-1))
5867 ThrowMogrifyException(OptionError,"MissingArgument",option);
5868 if (IsGeometry(argv[i]) == MagickFalse)
5869 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5872 if (LocaleCompare("transform",option+1) == 0)
5874 if (LocaleCompare("transpose",option+1) == 0)
5876 if (LocaleCompare("transverse",option+1) == 0)
5878 if (LocaleCompare("threshold",option+1) == 0)
5883 if (i == (ssize_t) argc)
5884 ThrowMogrifyException(OptionError,"MissingArgument",option);
5885 if (IsGeometry(argv[i]) == MagickFalse)
5886 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5889 if (LocaleCompare("thumbnail",option+1) == 0)
5894 if (i == (ssize_t) argc)
5895 ThrowMogrifyException(OptionError,"MissingArgument",option);
5896 if (IsGeometry(argv[i]) == MagickFalse)
5897 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5900 if (LocaleCompare("transparent",option+1) == 0)
5903 if (i == (ssize_t) argc)
5904 ThrowMogrifyException(OptionError,"MissingArgument",option);
5907 if (LocaleCompare("transparent-color",option+1) == 0)
5912 if (i == (ssize_t) (argc-1))
5913 ThrowMogrifyException(OptionError,"MissingArgument",option);
5916 if (LocaleCompare("treedepth",option+1) == 0)
5921 if (i == (ssize_t) argc)
5922 ThrowMogrifyException(OptionError,"MissingArgument",option);
5923 if (IsGeometry(argv[i]) == MagickFalse)
5924 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5927 if (LocaleCompare("trim",option+1) == 0)
5929 if (LocaleCompare("type",option+1) == 0)
5937 if (i == (ssize_t) argc)
5938 ThrowMogrifyException(OptionError,"MissingArgument",option);
5939 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5941 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5945 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5949 if (LocaleCompare("undercolor",option+1) == 0)
5954 if (i == (ssize_t) argc)
5955 ThrowMogrifyException(OptionError,"MissingArgument",option);
5958 if (LocaleCompare("unique-colors",option+1) == 0)
5960 if (LocaleCompare("units",option+1) == 0)
5968 if (i == (ssize_t) argc)
5969 ThrowMogrifyException(OptionError,"MissingArgument",option);
5970 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5973 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5977 if (LocaleCompare("unsharp",option+1) == 0)
5980 if (i == (ssize_t) argc)
5981 ThrowMogrifyException(OptionError,"MissingArgument",option);
5982 if (IsGeometry(argv[i]) == MagickFalse)
5983 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5986 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5990 if (LocaleCompare("verbose",option+1) == 0)
5992 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5995 if ((LocaleCompare("version",option+1) == 0) ||
5996 (LocaleCompare("-version",option+1) == 0))
5998 (void) FormatLocaleFile(stdout,"Version: %s\n",
5999 GetMagickVersion((size_t *) NULL));
6000 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
6001 GetMagickCopyright());
6002 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
6003 GetMagickFeatures());
6006 if (LocaleCompare("view",option+1) == 0)
6011 if (i == (ssize_t) argc)
6012 ThrowMogrifyException(OptionError,"MissingArgument",option);
6015 if (LocaleCompare("vignette",option+1) == 0)
6020 if (i == (ssize_t) argc)
6021 ThrowMogrifyException(OptionError,"MissingArgument",option);
6022 if (IsGeometry(argv[i]) == MagickFalse)
6023 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6026 if (LocaleCompare("virtual-pixel",option+1) == 0)
6034 if (i == (ssize_t) argc)
6035 ThrowMogrifyException(OptionError,"MissingArgument",option);
6036 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6039 ThrowMogrifyException(OptionError,
6040 "UnrecognizedVirtualPixelMethod",argv[i]);
6043 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6047 if (LocaleCompare("wave",option+1) == 0)
6050 if (i == (ssize_t) argc)
6051 ThrowMogrifyException(OptionError,"MissingArgument",option);
6052 if (IsGeometry(argv[i]) == MagickFalse)
6053 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6056 if (LocaleCompare("weight",option+1) == 0)
6061 if (i == (ssize_t) (argc-1))
6062 ThrowMogrifyException(OptionError,"MissingArgument",option);
6065 if (LocaleCompare("white-point",option+1) == 0)
6070 if (i == (ssize_t) argc)
6071 ThrowMogrifyException(OptionError,"MissingArgument",option);
6072 if (IsGeometry(argv[i]) == MagickFalse)
6073 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6076 if (LocaleCompare("white-threshold",option+1) == 0)
6081 if (i == (ssize_t) argc)
6082 ThrowMogrifyException(OptionError,"MissingArgument",option);
6083 if (IsGeometry(argv[i]) == MagickFalse)
6084 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6087 if (LocaleCompare("write",option+1) == 0)
6090 if (i == (ssize_t) (argc-1))
6091 ThrowMogrifyException(OptionError,"MissingArgument",option);
6094 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6099 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6101 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6102 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6103 if (fire != MagickFalse)
6104 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6107 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6108 if (i != (ssize_t) argc)
6109 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6111 return(status != 0 ? MagickTrue : MagickFalse);
6115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6119 + M o g r i f y I m a g e I n f o %
6123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6125 % MogrifyImageInfo() applies image processing settings to the image as
6126 % prescribed by command line options.
6128 % The format of the MogrifyImageInfo method is:
6130 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6131 % const char **argv,ExceptionInfo *exception)
6133 % A description of each parameter follows:
6135 % o image_info: the image info..
6137 % o argc: Specifies a pointer to an integer describing the number of
6138 % elements in the argument vector.
6140 % o argv: Specifies a pointer to a text array containing the command line
6143 % o exception: return any errors or warnings in this structure.
6146 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6147 const int argc,const char **argv,ExceptionInfo *exception)
6162 Initialize method variables.
6164 assert(image_info != (ImageInfo *) NULL);
6165 assert(image_info->signature == MagickSignature);
6166 if (image_info->debug != MagickFalse)
6167 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6168 image_info->filename);
6172 Set the image settings.
6174 for (i=0; i < (ssize_t) argc; i++)
6177 if (IsCommandOption(option) == MagickFalse)
6179 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6180 count=MagickMax(count,0L);
6181 if ((i+count) >= (ssize_t) argc)
6183 switch (*(option+1))
6187 if (LocaleCompare("adjoin",option+1) == 0)
6189 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6192 if (LocaleCompare("antialias",option+1) == 0)
6194 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6197 if (LocaleCompare("authenticate",option+1) == 0)
6200 (void) DeleteImageOption(image_info,option+1);
6202 (void) SetImageOption(image_info,option+1,argv[i+1]);
6209 if (LocaleCompare("background",option+1) == 0)
6213 (void) DeleteImageOption(image_info,option+1);
6214 (void) QueryColorCompliance(MogrifyBackgroundColor,
6215 AllCompliance,&image_info->background_color,exception);
6218 (void) SetImageOption(image_info,option+1,argv[i+1]);
6219 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6220 &image_info->background_color,exception);
6223 if (LocaleCompare("bias",option+1) == 0)
6227 (void) SetImageOption(image_info,option+1,"0.0");
6230 (void) SetImageOption(image_info,option+1,argv[i+1]);
6233 if (LocaleCompare("black-point-compensation",option+1) == 0)
6237 (void) SetImageOption(image_info,option+1,"false");
6240 (void) SetImageOption(image_info,option+1,"true");
6243 if (LocaleCompare("blue-primary",option+1) == 0)
6247 (void) SetImageOption(image_info,option+1,"0.0");
6250 (void) SetImageOption(image_info,option+1,argv[i+1]);
6253 if (LocaleCompare("bordercolor",option+1) == 0)
6257 (void) DeleteImageOption(image_info,option+1);
6258 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6259 &image_info->border_color,exception);
6262 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6263 &image_info->border_color,exception);
6264 (void) SetImageOption(image_info,option+1,argv[i+1]);
6267 if (LocaleCompare("box",option+1) == 0)
6271 (void) SetImageOption(image_info,"undercolor","none");
6274 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6281 if (LocaleCompare("cache",option+1) == 0)
6286 limit=MagickResourceInfinity;
6287 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6288 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6290 (void) SetMagickResourceLimit(MemoryResource,limit);
6291 (void) SetMagickResourceLimit(MapResource,2*limit);
6294 if (LocaleCompare("caption",option+1) == 0)
6298 (void) DeleteImageOption(image_info,option+1);
6301 (void) SetImageOption(image_info,option+1,argv[i+1]);
6304 if (LocaleCompare("channel",option+1) == 0)
6308 image_info->channel=DefaultChannels;
6311 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6314 if (LocaleCompare("colorspace",option+1) == 0)
6318 image_info->colorspace=UndefinedColorspace;
6319 (void) SetImageOption(image_info,option+1,"undefined");
6322 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6323 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6324 (void) SetImageOption(image_info,option+1,argv[i+1]);
6327 if (LocaleCompare("comment",option+1) == 0)
6331 (void) DeleteImageOption(image_info,option+1);
6334 (void) SetImageOption(image_info,option+1,argv[i+1]);
6337 if (LocaleCompare("compose",option+1) == 0)
6341 (void) SetImageOption(image_info,option+1,"undefined");
6344 (void) SetImageOption(image_info,option+1,argv[i+1]);
6347 if (LocaleCompare("compress",option+1) == 0)
6351 image_info->compression=UndefinedCompression;
6352 (void) SetImageOption(image_info,option+1,"undefined");
6355 image_info->compression=(CompressionType) ParseCommandOption(
6356 MagickCompressOptions,MagickFalse,argv[i+1]);
6357 (void) SetImageOption(image_info,option+1,argv[i+1]);
6364 if (LocaleCompare("debug",option+1) == 0)
6367 (void) SetLogEventMask("none");
6369 (void) SetLogEventMask(argv[i+1]);
6370 image_info->debug=IsEventLogging();
6373 if (LocaleCompare("define",option+1) == 0)
6377 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6378 (void) DeleteImageRegistry(argv[i+1]+9);
6380 (void) DeleteImageOption(image_info,argv[i+1]);
6383 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6385 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6389 (void) DefineImageOption(image_info,argv[i+1]);
6392 if (LocaleCompare("delay",option+1) == 0)
6396 (void) SetImageOption(image_info,option+1,"0");
6399 (void) SetImageOption(image_info,option+1,argv[i+1]);
6402 if (LocaleCompare("density",option+1) == 0)
6409 if (image_info->density != (char *) NULL)
6410 image_info->density=DestroyString(image_info->density);
6411 (void) SetImageOption(image_info,option+1,"72");
6414 (void) CloneString(&image_info->density,argv[i+1]);
6415 (void) SetImageOption(image_info,option+1,argv[i+1]);
6418 if (LocaleCompare("depth",option+1) == 0)
6422 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6425 image_info->depth=StringToUnsignedLong(argv[i+1]);
6428 if (LocaleCompare("direction",option+1) == 0)
6432 (void) SetImageOption(image_info,option+1,"undefined");
6435 (void) SetImageOption(image_info,option+1,argv[i+1]);
6438 if (LocaleCompare("display",option+1) == 0)
6442 if (image_info->server_name != (char *) NULL)
6443 image_info->server_name=DestroyString(
6444 image_info->server_name);
6447 (void) CloneString(&image_info->server_name,argv[i+1]);
6450 if (LocaleCompare("dispose",option+1) == 0)
6454 (void) SetImageOption(image_info,option+1,"undefined");
6457 (void) SetImageOption(image_info,option+1,argv[i+1]);
6460 if (LocaleCompare("dither",option+1) == 0)
6464 image_info->dither=MagickFalse;
6465 (void) SetImageOption(image_info,option+1,"none");
6468 (void) SetImageOption(image_info,option+1,argv[i+1]);
6469 image_info->dither=MagickTrue;
6476 if (LocaleCompare("encoding",option+1) == 0)
6480 (void) SetImageOption(image_info,option+1,"undefined");
6483 (void) SetImageOption(image_info,option+1,argv[i+1]);
6486 if (LocaleCompare("endian",option+1) == 0)
6490 image_info->endian=UndefinedEndian;
6491 (void) SetImageOption(image_info,option+1,"undefined");
6494 image_info->endian=(EndianType) ParseCommandOption(
6495 MagickEndianOptions,MagickFalse,argv[i+1]);
6496 (void) SetImageOption(image_info,option+1,argv[i+1]);
6499 if (LocaleCompare("extract",option+1) == 0)
6502 Set image extract geometry.
6506 if (image_info->extract != (char *) NULL)
6507 image_info->extract=DestroyString(image_info->extract);
6510 (void) CloneString(&image_info->extract,argv[i+1]);
6517 if (LocaleCompare("fill",option+1) == 0)
6521 (void) SetImageOption(image_info,option+1,"none");
6524 (void) SetImageOption(image_info,option+1,argv[i+1]);
6527 if (LocaleCompare("filter",option+1) == 0)
6531 (void) SetImageOption(image_info,option+1,"undefined");
6534 (void) SetImageOption(image_info,option+1,argv[i+1]);
6537 if (LocaleCompare("font",option+1) == 0)
6541 if (image_info->font != (char *) NULL)
6542 image_info->font=DestroyString(image_info->font);
6545 (void) CloneString(&image_info->font,argv[i+1]);
6548 if (LocaleCompare("format",option+1) == 0)
6553 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6554 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6555 image_info->ping=MagickFalse;
6556 (void) SetImageOption(image_info,option+1,argv[i+1]);
6559 if (LocaleCompare("fuzz",option+1) == 0)
6563 image_info->fuzz=0.0;
6564 (void) SetImageOption(image_info,option+1,"0");
6567 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6569 (void) SetImageOption(image_info,option+1,argv[i+1]);
6576 if (LocaleCompare("gravity",option+1) == 0)
6580 (void) SetImageOption(image_info,option+1,"undefined");
6583 (void) SetImageOption(image_info,option+1,argv[i+1]);
6586 if (LocaleCompare("green-primary",option+1) == 0)
6590 (void) SetImageOption(image_info,option+1,"0.0");
6593 (void) SetImageOption(image_info,option+1,argv[i+1]);
6600 if (LocaleCompare("intent",option+1) == 0)
6604 (void) SetImageOption(image_info,option+1,"undefined");
6607 (void) SetImageOption(image_info,option+1,argv[i+1]);
6610 if (LocaleCompare("interlace",option+1) == 0)
6614 image_info->interlace=UndefinedInterlace;
6615 (void) SetImageOption(image_info,option+1,"undefined");
6618 image_info->interlace=(InterlaceType) ParseCommandOption(
6619 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6620 (void) SetImageOption(image_info,option+1,argv[i+1]);
6623 if (LocaleCompare("interline-spacing",option+1) == 0)
6627 (void) SetImageOption(image_info,option+1,"undefined");
6630 (void) SetImageOption(image_info,option+1,argv[i+1]);
6633 if (LocaleCompare("interpolate",option+1) == 0)
6637 (void) SetImageOption(image_info,option+1,"undefined");
6640 (void) SetImageOption(image_info,option+1,argv[i+1]);
6643 if (LocaleCompare("interword-spacing",option+1) == 0)
6647 (void) SetImageOption(image_info,option+1,"undefined");
6650 (void) SetImageOption(image_info,option+1,argv[i+1]);
6657 if (LocaleCompare("kerning",option+1) == 0)
6661 (void) SetImageOption(image_info,option+1,"undefined");
6664 (void) SetImageOption(image_info,option+1,argv[i+1]);
6671 if (LocaleCompare("label",option+1) == 0)
6675 (void) DeleteImageOption(image_info,option+1);
6678 (void) SetImageOption(image_info,option+1,argv[i+1]);
6681 if (LocaleCompare("limit",option+1) == 0)
6691 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6692 MagickFalse,argv[i+1]);
6693 limit=MagickResourceInfinity;
6694 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6695 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6696 (void) SetMagickResourceLimit(type,limit);
6699 if (LocaleCompare("list",option+1) == 0)
6705 Display configuration list.
6707 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6710 case MagickCoderOptions:
6712 (void) ListCoderInfo((FILE *) NULL,exception);
6715 case MagickColorOptions:
6717 (void) ListColorInfo((FILE *) NULL,exception);
6720 case MagickConfigureOptions:
6722 (void) ListConfigureInfo((FILE *) NULL,exception);
6725 case MagickDelegateOptions:
6727 (void) ListDelegateInfo((FILE *) NULL,exception);
6730 case MagickFontOptions:
6732 (void) ListTypeInfo((FILE *) NULL,exception);
6735 case MagickFormatOptions:
6737 (void) ListMagickInfo((FILE *) NULL,exception);
6740 case MagickLocaleOptions:
6742 (void) ListLocaleInfo((FILE *) NULL,exception);
6745 case MagickLogOptions:
6747 (void) ListLogInfo((FILE *) NULL,exception);
6750 case MagickMagicOptions:
6752 (void) ListMagicInfo((FILE *) NULL,exception);
6755 case MagickMimeOptions:
6757 (void) ListMimeInfo((FILE *) NULL,exception);
6760 case MagickModuleOptions:
6762 (void) ListModuleInfo((FILE *) NULL,exception);
6765 case MagickPolicyOptions:
6767 (void) ListPolicyInfo((FILE *) NULL,exception);
6770 case MagickResourceOptions:
6772 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6775 case MagickThresholdOptions:
6777 (void) ListThresholdMaps((FILE *) NULL,exception);
6782 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6789 if (LocaleCompare("log",option+1) == 0)
6793 (void) SetLogFormat(argv[i+1]);
6796 if (LocaleCompare("loop",option+1) == 0)
6800 (void) SetImageOption(image_info,option+1,"0");
6803 (void) SetImageOption(image_info,option+1,argv[i+1]);
6810 if (LocaleCompare("matte",option+1) == 0)
6814 (void) SetImageOption(image_info,option+1,"false");
6817 (void) SetImageOption(image_info,option+1,"true");
6820 if (LocaleCompare("mattecolor",option+1) == 0)
6824 (void) SetImageOption(image_info,option+1,argv[i+1]);
6825 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6826 &image_info->matte_color,exception);
6829 (void) SetImageOption(image_info,option+1,argv[i+1]);
6830 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6831 &image_info->matte_color,exception);
6834 if (LocaleCompare("monitor",option+1) == 0)
6836 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6840 if (LocaleCompare("monochrome",option+1) == 0)
6842 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6849 if (LocaleCompare("orient",option+1) == 0)
6853 image_info->orientation=UndefinedOrientation;
6854 (void) SetImageOption(image_info,option+1,"undefined");
6857 image_info->orientation=(OrientationType) ParseCommandOption(
6858 MagickOrientationOptions,MagickFalse,argv[i+1]);
6859 (void) SetImageOption(image_info,option+1,argv[i+1]);
6865 if (LocaleCompare("page",option+1) == 0)
6869 page[MaxTextExtent];
6882 (void) DeleteImageOption(image_info,option+1);
6883 (void) CloneString(&image_info->page,(char *) NULL);
6886 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6887 image_option=GetImageOption(image_info,"page");
6888 if (image_option != (const char *) NULL)
6889 flags=ParseAbsoluteGeometry(image_option,&geometry);
6890 canonical_page=GetPageGeometry(argv[i+1]);
6891 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6892 canonical_page=DestroyString(canonical_page);
6893 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6894 (unsigned long) geometry.width,(unsigned long) geometry.height);
6895 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6896 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6897 (unsigned long) geometry.width,(unsigned long) geometry.height,
6898 (long) geometry.x,(long) geometry.y);
6899 (void) SetImageOption(image_info,option+1,page);
6900 (void) CloneString(&image_info->page,page);
6903 if (LocaleCompare("ping",option+1) == 0)
6905 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6908 if (LocaleCompare("pointsize",option+1) == 0)
6911 geometry_info.rho=0.0;
6913 (void) ParseGeometry(argv[i+1],&geometry_info);
6914 image_info->pointsize=geometry_info.rho;
6917 if (LocaleCompare("precision",option+1) == 0)
6919 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6922 if (LocaleCompare("preview",option+1) == 0)
6929 image_info->preview_type=UndefinedPreview;
6932 image_info->preview_type=(PreviewType) ParseCommandOption(
6933 MagickPreviewOptions,MagickFalse,argv[i+1]);
6940 if (LocaleCompare("quality",option+1) == 0)
6943 Set image compression quality.
6947 image_info->quality=UndefinedCompressionQuality;
6948 (void) SetImageOption(image_info,option+1,"0");
6951 image_info->quality=StringToUnsignedLong(argv[i+1]);
6952 (void) SetImageOption(image_info,option+1,argv[i+1]);
6955 if (LocaleCompare("quiet",option+1) == 0)
6957 static WarningHandler
6958 warning_handler = (WarningHandler) NULL;
6963 Restore error or warning messages.
6965 warning_handler=SetWarningHandler(warning_handler);
6969 Suppress error or warning messages.
6971 warning_handler=SetWarningHandler((WarningHandler) NULL);
6978 if (LocaleCompare("red-primary",option+1) == 0)
6982 (void) SetImageOption(image_info,option+1,"0.0");
6985 (void) SetImageOption(image_info,option+1,argv[i+1]);
6992 if (LocaleCompare("sampling-factor",option+1) == 0)
6995 Set image sampling factor.
6999 if (image_info->sampling_factor != (char *) NULL)
7000 image_info->sampling_factor=DestroyString(
7001 image_info->sampling_factor);
7004 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7007 if (LocaleCompare("scene",option+1) == 0)
7014 image_info->scene=0;
7015 (void) SetImageOption(image_info,option+1,"0");
7018 image_info->scene=StringToUnsignedLong(argv[i+1]);
7019 (void) SetImageOption(image_info,option+1,argv[i+1]);
7022 if (LocaleCompare("seed",option+1) == 0)
7029 seed=(size_t) time((time_t *) NULL);
7030 SeedPseudoRandomGenerator(seed);
7033 seed=StringToUnsignedLong(argv[i+1]);
7034 SeedPseudoRandomGenerator(seed);
7037 if (LocaleCompare("size",option+1) == 0)
7041 if (image_info->size != (char *) NULL)
7042 image_info->size=DestroyString(image_info->size);
7045 (void) CloneString(&image_info->size,argv[i+1]);
7048 if (LocaleCompare("stroke",option+1) == 0)
7052 (void) SetImageOption(image_info,option+1,"none");
7055 (void) SetImageOption(image_info,option+1,argv[i+1]);
7058 if (LocaleCompare("strokewidth",option+1) == 0)
7062 (void) SetImageOption(image_info,option+1,"0");
7065 (void) SetImageOption(image_info,option+1,argv[i+1]);
7068 if (LocaleCompare("synchronize",option+1) == 0)
7072 image_info->synchronize=MagickFalse;
7075 image_info->synchronize=MagickTrue;
7082 if (LocaleCompare("taint",option+1) == 0)
7086 (void) SetImageOption(image_info,option+1,"false");
7089 (void) SetImageOption(image_info,option+1,"true");
7092 if (LocaleCompare("texture",option+1) == 0)
7096 if (image_info->texture != (char *) NULL)
7097 image_info->texture=DestroyString(image_info->texture);
7100 (void) CloneString(&image_info->texture,argv[i+1]);
7103 if (LocaleCompare("tile-offset",option+1) == 0)
7107 (void) SetImageOption(image_info,option+1,"0");
7110 (void) SetImageOption(image_info,option+1,argv[i+1]);
7113 if (LocaleCompare("transparent-color",option+1) == 0)
7117 (void) QueryColorCompliance("none",AllCompliance,
7118 &image_info->transparent_color,exception);
7119 (void) SetImageOption(image_info,option+1,"none");
7122 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7123 &image_info->transparent_color,exception);
7124 (void) SetImageOption(image_info,option+1,argv[i+1]);
7127 if (LocaleCompare("type",option+1) == 0)
7131 image_info->type=UndefinedType;
7132 (void) SetImageOption(image_info,option+1,"undefined");
7135 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7136 MagickFalse,argv[i+1]);
7137 (void) SetImageOption(image_info,option+1,argv[i+1]);
7144 if (LocaleCompare("undercolor",option+1) == 0)
7148 (void) DeleteImageOption(image_info,option+1);
7151 (void) SetImageOption(image_info,option+1,argv[i+1]);
7154 if (LocaleCompare("units",option+1) == 0)
7158 image_info->units=UndefinedResolution;
7159 (void) SetImageOption(image_info,option+1,"undefined");
7162 image_info->units=(ResolutionType) ParseCommandOption(
7163 MagickResolutionOptions,MagickFalse,argv[i+1]);
7164 (void) SetImageOption(image_info,option+1,argv[i+1]);
7171 if (LocaleCompare("verbose",option+1) == 0)
7175 image_info->verbose=MagickFalse;
7178 image_info->verbose=MagickTrue;
7179 image_info->ping=MagickFalse;
7182 if (LocaleCompare("view",option+1) == 0)
7186 if (image_info->view != (char *) NULL)
7187 image_info->view=DestroyString(image_info->view);
7190 (void) CloneString(&image_info->view,argv[i+1]);
7193 if (LocaleCompare("virtual-pixel",option+1) == 0)
7197 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7198 (void) SetImageOption(image_info,option+1,"undefined");
7201 image_info->virtual_pixel_method=(VirtualPixelMethod)
7202 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7204 (void) SetImageOption(image_info,option+1,argv[i+1]);
7211 if (LocaleCompare("white-point",option+1) == 0)
7215 (void) SetImageOption(image_info,option+1,"0.0");
7218 (void) SetImageOption(image_info,option+1,argv[i+1]);
7232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7236 + M o g r i f y I m a g e L i s t %
7240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7242 % MogrifyImageList() applies any command line options that might affect the
7243 % entire image list (e.g. -append, -coalesce, etc.).
7245 % The format of the MogrifyImage method is:
7247 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7248 % const char **argv,Image **images,ExceptionInfo *exception)
7250 % A description of each parameter follows:
7252 % o image_info: the image info..
7254 % o argc: Specifies a pointer to an integer describing the number of
7255 % elements in the argument vector.
7257 % o argv: Specifies a pointer to a text array containing the command line
7260 % o images: pointer to pointer of the first image in image list.
7262 % o exception: return any errors or warnings in this structure.
7265 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7266 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7277 PixelInterpolateMethod
7291 Apply options to the image list.
7293 assert(image_info != (ImageInfo *) NULL);
7294 assert(image_info->signature == MagickSignature);
7295 assert(images != (Image **) NULL);
7296 assert((*images)->previous == (Image *) NULL);
7297 assert((*images)->signature == MagickSignature);
7298 if ((*images)->debug != MagickFalse)
7299 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7300 (*images)->filename);
7301 if ((argc <= 0) || (*argv == (char *) NULL))
7303 interpolate_method=UndefinedInterpolatePixel;
7304 mogrify_info=CloneImageInfo(image_info);
7305 quantize_info=AcquireQuantizeInfo(mogrify_info);
7307 for (i=0; i < (ssize_t) argc; i++)
7309 if (*images == (Image *) NULL)
7312 if (IsCommandOption(option) == MagickFalse)
7314 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7315 count=MagickMax(count,0L);
7316 if ((i+count) >= (ssize_t) argc)
7318 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7319 switch (*(option+1))
7323 if (LocaleCompare("affinity",option+1) == 0)
7325 (void) SyncImagesSettings(mogrify_info,*images,exception);
7328 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7335 if (LocaleCompare("append",option+1) == 0)
7340 (void) SyncImagesSettings(mogrify_info,*images,exception);
7341 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7342 MagickFalse,exception);
7343 if (append_image == (Image *) NULL)
7348 *images=DestroyImageList(*images);
7349 *images=append_image;
7352 if (LocaleCompare("average",option+1) == 0)
7358 Average an image sequence (deprecated).
7360 (void) SyncImagesSettings(mogrify_info,*images,exception);
7361 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7363 if (average_image == (Image *) NULL)
7368 *images=DestroyImageList(*images);
7369 *images=average_image;
7376 if (LocaleCompare("channel",option+1) == 0)
7383 channel=DefaultChannels;
7386 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7387 SetPixelChannelMapMask(*images,channel);
7390 if (LocaleCompare("clut",option+1) == 0)
7396 (void) SyncImagesSettings(mogrify_info,*images,exception);
7397 image=RemoveFirstImageFromList(images);
7398 clut_image=RemoveFirstImageFromList(images);
7399 if (clut_image == (Image *) NULL)
7404 (void) ClutImage(image,clut_image,interpolate_method,exception);
7405 clut_image=DestroyImage(clut_image);
7406 *images=DestroyImageList(*images);
7410 if (LocaleCompare("coalesce",option+1) == 0)
7415 (void) SyncImagesSettings(mogrify_info,*images,exception);
7416 coalesce_image=CoalesceImages(*images,exception);
7417 if (coalesce_image == (Image *) NULL)
7422 *images=DestroyImageList(*images);
7423 *images=coalesce_image;
7426 if (LocaleCompare("combine",option+1) == 0)
7431 (void) SyncImagesSettings(mogrify_info,*images,exception);
7432 combine_image=CombineImages(*images,exception);
7433 if (combine_image == (Image *) NULL)
7438 *images=DestroyImageList(*images);
7439 *images=combine_image;
7442 if (LocaleCompare("composite",option+1) == 0)
7452 (void) SyncImagesSettings(mogrify_info,*images,exception);
7453 image=RemoveFirstImageFromList(images);
7454 composite_image=RemoveFirstImageFromList(images);
7455 if (composite_image == (Image *) NULL)
7460 (void) TransformImage(&composite_image,(char *) NULL,
7461 composite_image->geometry,exception);
7462 SetGeometry(composite_image,&geometry);
7463 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7464 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7466 mask_image=RemoveFirstImageFromList(images);
7467 if (mask_image != (Image *) NULL)
7469 if ((image->compose == DisplaceCompositeOp) ||
7470 (image->compose == DistortCompositeOp))
7473 Merge Y displacement into X displacement image.
7475 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7476 mask_image,0,0,exception);
7477 mask_image=DestroyImage(mask_image);
7482 Set a blending mask for the composition.
7483 Posible error, what if image->mask already set.
7485 image->mask=mask_image;
7486 (void) NegateImage(image->mask,MagickFalse,exception);
7489 (void) CompositeImage(image,image->compose,composite_image,
7490 geometry.x,geometry.y,exception);
7491 if (mask_image != (Image *) NULL)
7492 mask_image=image->mask=DestroyImage(image->mask);
7493 composite_image=DestroyImage(composite_image);
7494 *images=DestroyImageList(*images);
7502 if (LocaleCompare("deconstruct",option+1) == 0)
7507 (void) SyncImagesSettings(mogrify_info,*images,exception);
7508 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7510 if (deconstruct_image == (Image *) NULL)
7515 *images=DestroyImageList(*images);
7516 *images=deconstruct_image;
7519 if (LocaleCompare("delete",option+1) == 0)
7522 DeleteImages(images,"-1",exception);
7524 DeleteImages(images,argv[i+1],exception);
7527 if (LocaleCompare("dither",option+1) == 0)
7531 quantize_info->dither=MagickFalse;
7534 quantize_info->dither=MagickTrue;
7535 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7536 MagickDitherOptions,MagickFalse,argv[i+1]);
7539 if (LocaleCompare("duplicate",option+1) == 0)
7545 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7554 number_duplicates=(size_t) StringToLong(argv[i+1]);
7555 p=strchr(argv[i+1],',');
7556 if (p == (const char *) NULL)
7557 duplicate_images=DuplicateImages(*images,number_duplicates,
7560 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7563 AppendImageToList(images, duplicate_images);
7564 (void) SyncImagesSettings(mogrify_info,*images,exception);
7571 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7576 MagickEvaluateOperator
7579 (void) SyncImageSettings(mogrify_info,*images,exception);
7580 op=(MagickEvaluateOperator) ParseCommandOption(
7581 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7582 evaluate_image=EvaluateImages(*images,op,exception);
7583 if (evaluate_image == (Image *) NULL)
7588 *images=DestroyImageList(*images);
7589 *images=evaluate_image;
7596 if (LocaleCompare("fft",option+1) == 0)
7602 Implements the discrete Fourier transform (DFT).
7604 (void) SyncImageSettings(mogrify_info,*images,exception);
7605 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7606 MagickTrue : MagickFalse,exception);
7607 if (fourier_image == (Image *) NULL)
7609 *images=DestroyImage(*images);
7610 *images=fourier_image;
7613 if (LocaleCompare("flatten",option+1) == 0)
7618 (void) SyncImagesSettings(mogrify_info,*images,exception);
7619 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7620 if (flatten_image == (Image *) NULL)
7622 *images=DestroyImageList(*images);
7623 *images=flatten_image;
7626 if (LocaleCompare("fx",option+1) == 0)
7631 (void) SyncImagesSettings(mogrify_info,*images,exception);
7632 fx_image=FxImage(*images,argv[i+1],exception);
7633 if (fx_image == (Image *) NULL)
7638 *images=DestroyImageList(*images);
7646 if (LocaleCompare("hald-clut",option+1) == 0)
7652 (void) SyncImagesSettings(mogrify_info,*images,exception);
7653 image=RemoveFirstImageFromList(images);
7654 hald_image=RemoveFirstImageFromList(images);
7655 if (hald_image == (Image *) NULL)
7660 (void) HaldClutImage(image,hald_image,exception);
7661 hald_image=DestroyImage(hald_image);
7662 if (*images != (Image *) NULL)
7663 *images=DestroyImageList(*images);
7671 if (LocaleCompare("ift",option+1) == 0)
7679 Implements the inverse fourier discrete Fourier transform (DFT).
7681 (void) SyncImagesSettings(mogrify_info,*images,exception);
7682 magnitude_image=RemoveFirstImageFromList(images);
7683 phase_image=RemoveFirstImageFromList(images);
7684 if (phase_image == (Image *) NULL)
7689 fourier_image=InverseFourierTransformImage(magnitude_image,
7690 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7691 if (fourier_image == (Image *) NULL)
7693 if (*images != (Image *) NULL)
7694 *images=DestroyImage(*images);
7695 *images=fourier_image;
7698 if (LocaleCompare("insert",option+1) == 0)
7706 index=(ssize_t) StringToLong(argv[i+1]);
7707 p=RemoveLastImageFromList(images);
7708 if (p == (Image *) NULL)
7710 (void) ThrowMagickException(exception,GetMagickModule(),
7711 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7717 PrependImageToList(images,q);
7719 if (index == (ssize_t) GetImageListLength(*images))
7720 AppendImageToList(images,q);
7723 q=GetImageFromList(*images,index-1);
7724 if (q == (Image *) NULL)
7726 (void) ThrowMagickException(exception,GetMagickModule(),
7727 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7731 InsertImageInList(&q,p);
7733 *images=GetFirstImageInList(q);
7736 if (LocaleCompare("interpolate",option+1) == 0)
7738 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7739 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7746 if (LocaleCompare("layers",option+1) == 0)
7754 (void) SyncImagesSettings(mogrify_info,*images,exception);
7755 layers=(Image *) NULL;
7756 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7757 MagickFalse,argv[i+1]);
7762 layers=CoalesceImages(*images,exception);
7765 case CompareAnyLayer:
7766 case CompareClearLayer:
7767 case CompareOverlayLayer:
7770 layers=CompareImagesLayers(*images,method,exception);
7776 case TrimBoundsLayer:
7778 layers=MergeImageLayers(*images,method,exception);
7783 layers=DisposeImages(*images,exception);
7786 case OptimizeImageLayer:
7788 layers=OptimizeImageLayers(*images,exception);
7791 case OptimizePlusLayer:
7793 layers=OptimizePlusImageLayers(*images,exception);
7796 case OptimizeTransLayer:
7798 OptimizeImageTransparency(*images,exception);
7801 case RemoveDupsLayer:
7803 RemoveDuplicateLayers(images,exception);
7806 case RemoveZeroLayer:
7808 RemoveZeroDelayLayers(images,exception);
7814 General Purpose, GIF Animation Optimizer.
7816 layers=CoalesceImages(*images,exception);
7817 if (layers == (Image *) NULL)
7822 *images=DestroyImageList(*images);
7824 layers=OptimizeImageLayers(*images,exception);
7825 if (layers == (Image *) NULL)
7830 *images=DestroyImageList(*images);
7832 layers=(Image *) NULL;
7833 OptimizeImageTransparency(*images,exception);
7834 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7838 case CompositeLayer:
7850 Split image sequence at the first 'NULL:' image.
7853 while (source != (Image *) NULL)
7855 source=GetNextImageInList(source);
7856 if ((source != (Image *) NULL) &&
7857 (LocaleCompare(source->magick,"NULL") == 0))
7860 if (source != (Image *) NULL)
7862 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7863 (GetNextImageInList(source) == (Image *) NULL))
7864 source=(Image *) NULL;
7868 Separate the two lists, junk the null: image.
7870 source=SplitImageList(source->previous);
7871 DeleteImageFromList(&source);
7874 if (source == (Image *) NULL)
7876 (void) ThrowMagickException(exception,GetMagickModule(),
7877 OptionError,"MissingNullSeparator","layers Composite");
7882 Adjust offset with gravity and virtual canvas.
7884 SetGeometry(*images,&geometry);
7885 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7886 geometry.width=source->page.width != 0 ?
7887 source->page.width : source->columns;
7888 geometry.height=source->page.height != 0 ?
7889 source->page.height : source->rows;
7890 GravityAdjustGeometry((*images)->page.width != 0 ?
7891 (*images)->page.width : (*images)->columns,
7892 (*images)->page.height != 0 ? (*images)->page.height :
7893 (*images)->rows,(*images)->gravity,&geometry);
7894 compose=OverCompositeOp;
7895 option=GetImageOption(mogrify_info,"compose");
7896 if (option != (const char *) NULL)
7897 compose=(CompositeOperator) ParseCommandOption(
7898 MagickComposeOptions,MagickFalse,option);
7899 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7901 source=DestroyImageList(source);
7905 if (layers == (Image *) NULL)
7907 *images=DestroyImageList(*images);
7915 if (LocaleCompare("map",option+1) == 0)
7917 (void) SyncImagesSettings(mogrify_info,*images,exception);
7920 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7927 if (LocaleCompare("maximum",option+1) == 0)
7933 Maximum image sequence (deprecated).
7935 (void) SyncImagesSettings(mogrify_info,*images,exception);
7936 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7937 if (maximum_image == (Image *) NULL)
7942 *images=DestroyImageList(*images);
7943 *images=maximum_image;
7946 if (LocaleCompare("minimum",option+1) == 0)
7952 Minimum image sequence (deprecated).
7954 (void) SyncImagesSettings(mogrify_info,*images,exception);
7955 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7956 if (minimum_image == (Image *) NULL)
7961 *images=DestroyImageList(*images);
7962 *images=minimum_image;
7965 if (LocaleCompare("morph",option+1) == 0)
7970 (void) SyncImagesSettings(mogrify_info,*images,exception);
7971 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7973 if (morph_image == (Image *) NULL)
7978 *images=DestroyImageList(*images);
7979 *images=morph_image;
7982 if (LocaleCompare("mosaic",option+1) == 0)
7987 (void) SyncImagesSettings(mogrify_info,*images,exception);
7988 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7989 if (mosaic_image == (Image *) NULL)
7994 *images=DestroyImageList(*images);
7995 *images=mosaic_image;
8002 if (LocaleCompare("print",option+1) == 0)
8007 (void) SyncImagesSettings(mogrify_info,*images,exception);
8008 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8010 if (string == (char *) NULL)
8012 (void) FormatLocaleFile(stdout,"%s",string);
8013 string=DestroyString(string);
8015 if (LocaleCompare("process",option+1) == 0)
8024 (void) SyncImagesSettings(mogrify_info,*images,exception);
8025 arguments=StringToArgv(argv[i+1],&number_arguments);
8026 if (arguments == (char **) NULL)
8028 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8049 Support old style syntax, filter="-option arg".
8051 length=strlen(argv[i+1]);
8052 token=(char *) NULL;
8053 if (~length >= (MaxTextExtent-1))
8054 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8056 if (token == (char *) NULL)
8059 arguments=argv[i+1];
8060 token_info=AcquireTokenInfo();
8061 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8062 "\"",'\0',&breaker,&next,"e);
8063 token_info=DestroyTokenInfo(token_info);
8069 argv=(&(arguments[next]));
8070 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8073 token=DestroyString(token);
8076 (void) SubstituteString(&arguments[1],"-","");
8077 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8078 number_arguments-2,(const char **) arguments+2,exception);
8079 for (j=0; j < number_arguments; j++)
8080 arguments[j]=DestroyString(arguments[j]);
8081 arguments=(char **) RelinquishMagickMemory(arguments);
8088 if (LocaleCompare("reverse",option+1) == 0)
8090 ReverseImageList(images);
8097 if (LocaleCompare("smush",option+1) == 0)
8105 (void) SyncImagesSettings(mogrify_info,*images,exception);
8106 offset=(ssize_t) StringToLong(argv[i+1]);
8107 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8108 MagickFalse,offset,exception);
8109 if (smush_image == (Image *) NULL)
8114 *images=DestroyImageList(*images);
8115 *images=smush_image;
8118 if (LocaleCompare("swap",option+1) == 0)
8139 flags=ParseGeometry(argv[i+1],&geometry_info);
8140 index=(ssize_t) geometry_info.rho;
8141 if ((flags & SigmaValue) != 0)
8142 swap_index=(ssize_t) geometry_info.sigma;
8144 p=GetImageFromList(*images,index);
8145 q=GetImageFromList(*images,swap_index);
8146 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8148 (void) ThrowMagickException(exception,GetMagickModule(),
8149 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8155 swap=CloneImage(p,0,0,MagickTrue,exception);
8156 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8157 ReplaceImageInList(&q,swap);
8158 *images=GetFirstImageInList(q);
8165 if (LocaleCompare("write",option+1) == 0)
8176 (void) SyncImagesSettings(mogrify_info,*images,exception);
8177 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8178 (void) DeleteImageRegistry(key);
8179 write_images=(*images);
8181 write_images=CloneImageList(*images,exception);
8182 write_info=CloneImageInfo(mogrify_info);
8183 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8184 write_info=DestroyImageInfo(write_info);
8186 write_images=DestroyImageList(write_images);
8196 quantize_info=DestroyQuantizeInfo(quantize_info);
8197 mogrify_info=DestroyImageInfo(mogrify_info);
8198 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8199 return(status != 0 ? MagickTrue : MagickFalse);
8203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8207 + M o g r i f y I m a g e s %
8211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8213 % MogrifyImages() applies image processing options to a sequence of images as
8214 % prescribed by command line options.
8216 % The format of the MogrifyImage method is:
8218 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8219 % const MagickBooleanType post,const int argc,const char **argv,
8220 % Image **images,Exceptioninfo *exception)
8222 % A description of each parameter follows:
8224 % o image_info: the image info..
8226 % o post: If true, post process image list operators otherwise pre-process.
8228 % o argc: Specifies a pointer to an integer describing the number of
8229 % elements in the argument vector.
8231 % o argv: Specifies a pointer to a text array containing the command line
8234 % o images: pointer to a pointer of the first image in image list.
8236 % o exception: return any errors or warnings in this structure.
8239 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8240 const MagickBooleanType post,const int argc,const char **argv,
8241 Image **images,ExceptionInfo *exception)
8243 #define MogrifyImageTag "Mogrify/Image"
8257 assert(image_info != (ImageInfo *) NULL);
8258 assert(image_info->signature == MagickSignature);
8259 if (images == (Image **) NULL)
8260 return(MogrifyImage(image_info,argc,argv,images,exception));
8261 assert((*images)->previous == (Image *) NULL);
8262 assert((*images)->signature == MagickSignature);
8263 if ((*images)->debug != MagickFalse)
8264 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8265 (*images)->filename);
8266 if ((argc <= 0) || (*argv == (char *) NULL))
8268 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8273 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8278 Pre-process multi-image sequence operators
8280 if (post == MagickFalse)
8281 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8283 For each image, process simple single image operators
8286 n=GetImageListLength(*images);
8290 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8291 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8293 status&=MogrifyImage(image_info,argc,argv,images,exception);
8294 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8295 if (proceed == MagickFalse)
8297 if ( (*images)->next == (Image *) NULL )
8299 *images=(*images)->next;
8302 assert( *images != (Image *) NULL );
8304 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8305 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8309 Post-process, multi-image sequence operators
8311 *images=GetFirstImageInList(*images);
8312 if (post != MagickFalse)
8313 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8314 return(status != 0 ? MagickTrue : MagickFalse);