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("pen",option+1) == 0)
2284 (void) QueryColorCompliance("none",AllCompliance,
2285 &draw_info->fill,exception);
2288 (void) QueryColorCompliance(argv[i+1],AllCompliance,
2289 &draw_info->fill,exception);
2292 if (LocaleCompare("pointsize",option+1) == 0)
2295 (void) ParseGeometry("12",&geometry_info);
2297 (void) ParseGeometry(argv[i+1],&geometry_info);
2298 draw_info->pointsize=geometry_info.rho;
2301 if (LocaleCompare("polaroid",option+1) == 0)
2313 Simulate a Polaroid picture.
2315 (void) SyncImageSettings(mogrify_info,*image,exception);
2316 random_info=AcquireRandomInfo();
2317 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2318 random_info=DestroyRandomInfo(random_info);
2321 SetGeometryInfo(&geometry_info);
2322 flags=ParseGeometry(argv[i+1],&geometry_info);
2323 angle=geometry_info.rho;
2325 caption=GetImageProperty(*image,"caption",exception);
2326 mogrify_image=PolaroidImage(*image,draw_info,caption,angle,
2327 interpolate_method,exception);
2330 if (LocaleCompare("posterize",option+1) == 0)
2335 (void) SyncImageSettings(mogrify_info,*image,exception);
2336 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2337 quantize_info->dither,exception);
2340 if (LocaleCompare("preview",option+1) == 0)
2348 (void) SyncImageSettings(mogrify_info,*image,exception);
2350 preview_type=UndefinedPreview;
2352 preview_type=(PreviewType) ParseCommandOption(
2353 MagickPreviewOptions,MagickFalse,argv[i+1]);
2354 mogrify_image=PreviewImage(*image,preview_type,exception);
2357 if (LocaleCompare("profile",option+1) == 0)
2371 (void) SyncImageSettings(mogrify_info,*image,exception);
2375 Remove a profile from the image.
2377 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2382 Associate a profile with the image.
2384 profile_info=CloneImageInfo(mogrify_info);
2385 profile=GetImageProfile(*image,"iptc");
2386 if (profile != (StringInfo *) NULL)
2387 profile_info->profile=(void *) CloneStringInfo(profile);
2388 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2389 profile_info=DestroyImageInfo(profile_info);
2390 if (profile_image == (Image *) NULL)
2395 profile_info=CloneImageInfo(mogrify_info);
2396 (void) CopyMagickString(profile_info->filename,argv[i+1],
2398 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2399 if (profile != (StringInfo *) NULL)
2401 (void) ProfileImage(*image,profile_info->magick,
2402 GetStringInfoDatum(profile),(size_t)
2403 GetStringInfoLength(profile),exception);
2404 profile=DestroyStringInfo(profile);
2406 profile_info=DestroyImageInfo(profile_info);
2409 ResetImageProfileIterator(profile_image);
2410 name=GetNextImageProfile(profile_image);
2411 while (name != (const char *) NULL)
2413 profile=GetImageProfile(profile_image,name);
2414 if (profile != (StringInfo *) NULL)
2415 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2416 (size_t) GetStringInfoLength(profile),exception);
2417 name=GetNextImageProfile(profile_image);
2419 profile_image=DestroyImage(profile_image);
2426 if (LocaleCompare("quantize",option+1) == 0)
2430 quantize_info->colorspace=UndefinedColorspace;
2433 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2434 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2441 if (LocaleCompare("radial-blur",option+1) == 0)
2446 (void) SyncImageSettings(mogrify_info,*image,exception);
2447 flags=ParseGeometry(argv[i+1],&geometry_info);
2448 mogrify_image=RadialBlurImage(*image,geometry_info.rho,
2449 geometry_info.sigma,exception);
2452 if (LocaleCompare("raise",option+1) == 0)
2455 Surround image with a raise of solid color.
2457 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2458 if ((flags & SigmaValue) == 0)
2459 geometry.height=geometry.width;
2460 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2461 MagickFalse,exception);
2464 if (LocaleCompare("random-threshold",option+1) == 0)
2469 (void) SyncImageSettings(mogrify_info,*image,exception);
2470 (void) RandomThresholdImage(*image,argv[i+1],exception);
2473 if (LocaleCompare("recolor",option+1) == 0)
2478 (void) SyncImageSettings(mogrify_info,*image,exception);
2479 kernel=AcquireKernelInfo(argv[i+1]);
2480 if (kernel == (KernelInfo *) NULL)
2482 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2483 kernel=DestroyKernelInfo(kernel);
2486 if (LocaleCompare("region",option+1) == 0)
2488 (void) SyncImageSettings(mogrify_info,*image,exception);
2489 if (region_image != (Image *) NULL)
2494 (void) CompositeImage(region_image,region_image->matte !=
2495 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2496 region_geometry.x,region_geometry.y,exception);
2497 *image=DestroyImage(*image);
2498 *image=region_image;
2499 region_image = (Image *) NULL;
2504 Apply transformations to a selected region of the image.
2506 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2508 mogrify_image=CropImage(*image,®ion_geometry,exception);
2509 if (mogrify_image == (Image *) NULL)
2511 region_image=(*image);
2512 *image=mogrify_image;
2513 mogrify_image=(Image *) NULL;
2516 if (LocaleCompare("render",option+1) == 0)
2518 (void) SyncImageSettings(mogrify_info,*image,exception);
2519 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2522 if (LocaleCompare("remap",option+1) == 0)
2528 Transform image colors to match this set of colors.
2530 (void) SyncImageSettings(mogrify_info,*image,exception);
2533 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2534 if (remap_image == (Image *) NULL)
2536 (void) RemapImage(quantize_info,*image,remap_image,exception);
2537 remap_image=DestroyImage(remap_image);
2540 if (LocaleCompare("repage",option+1) == 0)
2544 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2547 (void) ResetImagePage(*image,argv[i+1]);
2550 if (LocaleCompare("resample",option+1) == 0)
2555 (void) SyncImageSettings(mogrify_info,*image,exception);
2556 flags=ParseGeometry(argv[i+1],&geometry_info);
2557 if ((flags & SigmaValue) == 0)
2558 geometry_info.sigma=geometry_info.rho;
2559 mogrify_image=ResampleImage(*image,geometry_info.rho,
2560 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2563 if (LocaleCompare("resize",option+1) == 0)
2568 (void) SyncImageSettings(mogrify_info,*image,exception);
2569 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2570 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2571 (*image)->filter,(*image)->blur,exception);
2574 if (LocaleCompare("roll",option+1) == 0)
2579 (void) SyncImageSettings(mogrify_info,*image,exception);
2580 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2581 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2584 if (LocaleCompare("rotate",option+1) == 0)
2590 Check for conditional image rotation.
2592 (void) SyncImageSettings(mogrify_info,*image,exception);
2593 if (strchr(argv[i+1],'>') != (char *) NULL)
2594 if ((*image)->columns <= (*image)->rows)
2596 if (strchr(argv[i+1],'<') != (char *) NULL)
2597 if ((*image)->columns >= (*image)->rows)
2602 geometry=ConstantString(argv[i+1]);
2603 (void) SubstituteString(&geometry,">","");
2604 (void) SubstituteString(&geometry,"<","");
2605 (void) ParseGeometry(geometry,&geometry_info);
2606 geometry=DestroyString(geometry);
2607 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2614 if (LocaleCompare("sample",option+1) == 0)
2617 Sample image with pixel replication.
2619 (void) SyncImageSettings(mogrify_info,*image,exception);
2620 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2621 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2625 if (LocaleCompare("scale",option+1) == 0)
2630 (void) SyncImageSettings(mogrify_info,*image,exception);
2631 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2632 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2636 if (LocaleCompare("selective-blur",option+1) == 0)
2639 Selectively blur pixels within a contrast threshold.
2641 (void) SyncImageSettings(mogrify_info,*image,exception);
2642 flags=ParseGeometry(argv[i+1],&geometry_info);
2643 if ((flags & PercentValue) != 0)
2644 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2645 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2646 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2649 if (LocaleCompare("separate",option+1) == 0)
2652 Break channels into separate images.
2654 (void) SyncImageSettings(mogrify_info,*image,exception);
2655 mogrify_image=SeparateImages(*image,exception);
2658 if (LocaleCompare("sepia-tone",option+1) == 0)
2666 (void) SyncImageSettings(mogrify_info,*image,exception);
2667 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2669 mogrify_image=SepiaToneImage(*image,threshold,exception);
2672 if (LocaleCompare("segment",option+1) == 0)
2677 (void) SyncImageSettings(mogrify_info,*image,exception);
2678 flags=ParseGeometry(argv[i+1],&geometry_info);
2679 if ((flags & SigmaValue) == 0)
2680 geometry_info.sigma=1.0;
2681 (void) SegmentImage(*image,(*image)->colorspace,
2682 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,
2686 if (LocaleCompare("set",option+1) == 0)
2696 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2697 (void) DeleteImageRegistry(argv[i+1]+9);
2699 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2701 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2702 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2705 (void) DeleteImageProperty(*image,argv[i+1]);
2708 value=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2710 if (value == (char *) NULL)
2712 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2713 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2716 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2718 (void) SetImageOption(image_info,argv[i+1]+7,value);
2719 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2720 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2723 (void) SetImageProperty(*image,argv[i+1],value,exception);
2724 value=DestroyString(value);
2727 if (LocaleCompare("shade",option+1) == 0)
2732 (void) SyncImageSettings(mogrify_info,*image,exception);
2733 flags=ParseGeometry(argv[i+1],&geometry_info);
2734 if ((flags & SigmaValue) == 0)
2735 geometry_info.sigma=1.0;
2736 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2737 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2740 if (LocaleCompare("shadow",option+1) == 0)
2745 (void) SyncImageSettings(mogrify_info,*image,exception);
2746 flags=ParseGeometry(argv[i+1],&geometry_info);
2747 if ((flags & SigmaValue) == 0)
2748 geometry_info.sigma=1.0;
2749 if ((flags & XiValue) == 0)
2750 geometry_info.xi=4.0;
2751 if ((flags & PsiValue) == 0)
2752 geometry_info.psi=4.0;
2753 mogrify_image=ShadowImage(*image,geometry_info.rho,
2754 geometry_info.sigma,(*image)->bias,(ssize_t)
2755 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
2759 if (LocaleCompare("sharpen",option+1) == 0)
2764 (void) SyncImageSettings(mogrify_info,*image,exception);
2765 flags=ParseGeometry(argv[i+1],&geometry_info);
2766 if ((flags & SigmaValue) == 0)
2767 geometry_info.sigma=1.0;
2768 if ((flags & XiValue) == 0)
2769 geometry_info.xi=0.0;
2770 mogrify_image=SharpenImage(*image,geometry_info.rho,
2771 geometry_info.sigma,geometry_info.xi,exception);
2774 if (LocaleCompare("shave",option+1) == 0)
2777 Shave the image edges.
2779 (void) SyncImageSettings(mogrify_info,*image,exception);
2780 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2781 mogrify_image=ShaveImage(*image,&geometry,exception);
2784 if (LocaleCompare("shear",option+1) == 0)
2789 (void) SyncImageSettings(mogrify_info,*image,exception);
2790 flags=ParseGeometry(argv[i+1],&geometry_info);
2791 if ((flags & SigmaValue) == 0)
2792 geometry_info.sigma=geometry_info.rho;
2793 mogrify_image=ShearImage(*image,geometry_info.rho,
2794 geometry_info.sigma,exception);
2797 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2800 Sigmoidal non-linearity contrast control.
2802 (void) SyncImageSettings(mogrify_info,*image,exception);
2803 flags=ParseGeometry(argv[i+1],&geometry_info);
2804 if ((flags & SigmaValue) == 0)
2805 geometry_info.sigma=(double) QuantumRange/2.0;
2806 if ((flags & PercentValue) != 0)
2807 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2809 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2810 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,
2814 if (LocaleCompare("sketch",option+1) == 0)
2819 (void) SyncImageSettings(mogrify_info,*image,exception);
2820 flags=ParseGeometry(argv[i+1],&geometry_info);
2821 if ((flags & SigmaValue) == 0)
2822 geometry_info.sigma=1.0;
2823 mogrify_image=SketchImage(*image,geometry_info.rho,
2824 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
2827 if (LocaleCompare("solarize",option+1) == 0)
2832 (void) SyncImageSettings(mogrify_info,*image,exception);
2833 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2835 (void) SolarizeImage(*image,threshold,exception);
2838 if (LocaleCompare("sparse-color",option+1) == 0)
2847 Sparse Color Interpolated Gradient
2849 (void) SyncImageSettings(mogrify_info,*image,exception);
2850 method=(SparseColorMethod) ParseCommandOption(
2851 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2852 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],
2854 if (arguments == (char *) NULL)
2856 mogrify_image=SparseColorOption(*image,method,arguments,
2857 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2858 arguments=DestroyString(arguments);
2861 if (LocaleCompare("splice",option+1) == 0)
2864 Splice a solid color into the image.
2866 (void) SyncImageSettings(mogrify_info,*image,exception);
2867 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2868 mogrify_image=SpliceImage(*image,&geometry,exception);
2871 if (LocaleCompare("spread",option+1) == 0)
2876 (void) SyncImageSettings(mogrify_info,*image,exception);
2877 (void) ParseGeometry(argv[i+1],&geometry_info);
2878 mogrify_image=SpreadImage(*image,geometry_info.rho,
2879 interpolate_method,exception);
2882 if (LocaleCompare("statistic",option+1) == 0)
2887 (void) SyncImageSettings(mogrify_info,*image,exception);
2888 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2889 MagickFalse,argv[i+1]);
2890 (void) ParseGeometry(argv[i+2],&geometry_info);
2891 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2892 (size_t) geometry_info.sigma,exception);
2895 if (LocaleCompare("stretch",option+1) == 0)
2899 draw_info->stretch=UndefinedStretch;
2902 draw_info->stretch=(StretchType) ParseCommandOption(
2903 MagickStretchOptions,MagickFalse,argv[i+1]);
2906 if (LocaleCompare("strip",option+1) == 0)
2909 Strip image of profiles and comments.
2911 (void) SyncImageSettings(mogrify_info,*image,exception);
2912 (void) StripImage(*image,exception);
2915 if (LocaleCompare("stroke",option+1) == 0)
2922 (void) QueryColorCompliance("none",AllCompliance,
2923 &draw_info->stroke,exception);
2924 if (draw_info->stroke_pattern != (Image *) NULL)
2925 draw_info->stroke_pattern=DestroyImage(
2926 draw_info->stroke_pattern);
2929 sans=AcquireExceptionInfo();
2930 status=QueryColorCompliance(argv[i+1],AllCompliance,
2931 &draw_info->stroke,sans);
2932 sans=DestroyExceptionInfo(sans);
2933 if (status == MagickFalse)
2934 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2938 if (LocaleCompare("strokewidth",option+1) == 0)
2940 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);
2943 if (LocaleCompare("style",option+1) == 0)
2947 draw_info->style=UndefinedStyle;
2950 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2951 MagickFalse,argv[i+1]);
2954 if (LocaleCompare("swirl",option+1) == 0)
2959 (void) SyncImageSettings(mogrify_info,*image,exception);
2960 (void) ParseGeometry(argv[i+1],&geometry_info);
2961 mogrify_image=SwirlImage(*image,geometry_info.rho,
2962 interpolate_method,exception);
2969 if (LocaleCompare("threshold",option+1) == 0)
2977 (void) SyncImageSettings(mogrify_info,*image,exception);
2979 threshold=(double) QuantumRange/2;
2981 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+
2983 (void) BilevelImage(*image,threshold,exception);
2986 if (LocaleCompare("thumbnail",option+1) == 0)
2991 (void) SyncImageSettings(mogrify_info,*image,exception);
2992 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2993 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2997 if (LocaleCompare("tile",option+1) == 0)
3001 if (draw_info->fill_pattern != (Image *) NULL)
3002 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
3005 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
3009 if (LocaleCompare("tint",option+1) == 0)
3014 (void) SyncImageSettings(mogrify_info,*image,exception);
3015 mogrify_image=TintImage(*image,argv[i+1],&fill,exception);
3018 if (LocaleCompare("transform",option+1) == 0)
3021 Affine transform image.
3023 (void) SyncImageSettings(mogrify_info,*image,exception);
3024 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
3028 if (LocaleCompare("transparent",option+1) == 0)
3033 (void) SyncImageSettings(mogrify_info,*image,exception);
3034 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,
3036 (void) TransparentPaintImage(*image,&target,(Quantum)
3037 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,
3041 if (LocaleCompare("transpose",option+1) == 0)
3044 Transpose image scanlines.
3046 (void) SyncImageSettings(mogrify_info,*image,exception);
3047 mogrify_image=TransposeImage(*image,exception);
3050 if (LocaleCompare("transverse",option+1) == 0)
3053 Transverse image scanlines.
3055 (void) SyncImageSettings(mogrify_info,*image,exception);
3056 mogrify_image=TransverseImage(*image,exception);
3059 if (LocaleCompare("treedepth",option+1) == 0)
3061 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
3064 if (LocaleCompare("trim",option+1) == 0)
3069 (void) SyncImageSettings(mogrify_info,*image,exception);
3070 mogrify_image=TrimImage(*image,exception);
3073 if (LocaleCompare("type",option+1) == 0)
3078 (void) SyncImageSettings(mogrify_info,*image,exception);
3082 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3084 (*image)->type=UndefinedType;
3085 (void) SetImageType(*image,type,exception);
3092 if (LocaleCompare("undercolor",option+1) == 0)
3094 (void) QueryColorCompliance(argv[i+1],AllCompliance,
3095 &draw_info->undercolor,exception);
3098 if (LocaleCompare("unique",option+1) == 0)
3102 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3105 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3106 (void) SetImageArtifact(*image,"verbose","true");
3109 if (LocaleCompare("unique-colors",option+1) == 0)
3112 Unique image colors.
3114 (void) SyncImageSettings(mogrify_info,*image,exception);
3115 mogrify_image=UniqueImageColors(*image,exception);
3118 if (LocaleCompare("unsharp",option+1) == 0)
3123 (void) SyncImageSettings(mogrify_info,*image,exception);
3124 flags=ParseGeometry(argv[i+1],&geometry_info);
3125 if ((flags & SigmaValue) == 0)
3126 geometry_info.sigma=1.0;
3127 if ((flags & XiValue) == 0)
3128 geometry_info.xi=1.0;
3129 if ((flags & PsiValue) == 0)
3130 geometry_info.psi=0.05;
3131 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3132 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3139 if (LocaleCompare("verbose",option+1) == 0)
3141 (void) SetImageArtifact(*image,option+1,
3142 *option == '+' ? "false" : "true");
3145 if (LocaleCompare("vignette",option+1) == 0)
3150 (void) SyncImageSettings(mogrify_info,*image,exception);
3151 flags=ParseGeometry(argv[i+1],&geometry_info);
3152 if ((flags & SigmaValue) == 0)
3153 geometry_info.sigma=1.0;
3154 if ((flags & XiValue) == 0)
3155 geometry_info.xi=0.1*(*image)->columns;
3156 if ((flags & PsiValue) == 0)
3157 geometry_info.psi=0.1*(*image)->rows;
3158 mogrify_image=VignetteImage(*image,geometry_info.rho,
3159 geometry_info.sigma,(*image)->bias,(ssize_t)
3160 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
3164 if (LocaleCompare("virtual-pixel",option+1) == 0)
3168 (void) SetImageVirtualPixelMethod(*image,
3169 UndefinedVirtualPixelMethod);
3172 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3173 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3181 if (LocaleCompare("wave",option+1) == 0)
3186 (void) SyncImageSettings(mogrify_info,*image,exception);
3187 flags=ParseGeometry(argv[i+1],&geometry_info);
3188 if ((flags & SigmaValue) == 0)
3189 geometry_info.sigma=1.0;
3190 mogrify_image=WaveImage(*image,geometry_info.rho,
3191 geometry_info.sigma,interpolate_method,exception);
3194 if (LocaleCompare("weight",option+1) == 0)
3196 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3197 if (LocaleCompare(argv[i+1],"all") == 0)
3198 draw_info->weight=0;
3199 if (LocaleCompare(argv[i+1],"bold") == 0)
3200 draw_info->weight=700;
3201 if (LocaleCompare(argv[i+1],"bolder") == 0)
3202 if (draw_info->weight <= 800)
3203 draw_info->weight+=100;
3204 if (LocaleCompare(argv[i+1],"lighter") == 0)
3205 if (draw_info->weight >= 100)
3206 draw_info->weight-=100;
3207 if (LocaleCompare(argv[i+1],"normal") == 0)
3208 draw_info->weight=400;
3211 if (LocaleCompare("white-threshold",option+1) == 0)
3214 White threshold image.
3216 (void) SyncImageSettings(mogrify_info,*image,exception);
3217 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3226 Replace current image with any image that was generated
3228 if (mogrify_image != (Image *) NULL)
3229 ReplaceImageInListReturnLast(image,mogrify_image);
3232 if (region_image != (Image *) NULL)
3235 Composite transformed region onto image.
3237 (void) SyncImageSettings(mogrify_info,*image,exception);
3238 (void) CompositeImage(region_image,region_image->matte !=
3239 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3240 region_geometry.x,region_geometry.y,exception);
3241 *image=DestroyImage(*image);
3242 *image=region_image;
3243 region_image = (Image *) NULL;
3248 quantize_info=DestroyQuantizeInfo(quantize_info);
3249 draw_info=DestroyDrawInfo(draw_info);
3250 mogrify_info=DestroyImageInfo(mogrify_info);
3251 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0);
3252 return(status == 0 ? MagickFalse : MagickTrue);
3256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3260 + M o g r i f y I m a g e C o m m a n d %
3264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3266 % MogrifyImageCommand() transforms an image or a sequence of images. These
3267 % transforms include image scaling, image rotation, color reduction, and
3268 % others. The transmogrified image overwrites the original image.
3270 % The format of the MogrifyImageCommand method is:
3272 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3273 % const char **argv,char **metadata,ExceptionInfo *exception)
3275 % A description of each parameter follows:
3277 % o image_info: the image info.
3279 % o argc: the number of elements in the argument vector.
3281 % o argv: A text array containing the command line arguments.
3283 % o metadata: any metadata is returned here.
3285 % o exception: return any errors or warnings in this structure.
3289 static MagickBooleanType MogrifyUsage(void)
3294 "-debug events display copious debugging information",
3295 "-help print program options",
3296 "-list type print a list of supported option arguments",
3297 "-log format format of debugging information",
3298 "-version print version information",
3303 "-adaptive-blur geometry",
3304 " adaptively blur pixels; decrease effect near edges",
3305 "-adaptive-resize geometry",
3306 " adaptively resize image using 'mesh' interpolation",
3307 "-adaptive-sharpen geometry",
3308 " adaptively sharpen pixels; increase effect near edges",
3309 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3310 " transparent, extract, background, or shape",
3311 "-annotate geometry text",
3312 " annotate the image with text",
3313 "-auto-gamma automagically adjust gamma level of image",
3314 "-auto-level automagically adjust color levels of image",
3315 "-auto-orient automagically orient (rotate) image",
3316 "-bench iterations measure performance",
3317 "-black-threshold value",
3318 " force all pixels below the threshold into black",
3319 "-blue-shift simulate a scene at nighttime in the moonlight",
3320 "-blur geometry reduce image noise and reduce detail levels",
3321 "-border geometry surround image with a border of color",
3322 "-bordercolor color border color",
3323 "-brightness-contrast geometry",
3324 " improve brightness / contrast of the image",
3325 "-cdl filename color correct with a color decision list",
3326 "-charcoal geometry simulate a charcoal drawing",
3327 "-chop geometry remove pixels from the image interior",
3328 "-clamp restrict pixel range from 0 to the quantum depth",
3329 "-clip clip along the first path from the 8BIM profile",
3330 "-clip-mask filename associate a clip mask with the image",
3331 "-clip-path id clip along a named path from the 8BIM profile",
3332 "-colorize value colorize the image with the fill color",
3333 "-color-matrix matrix apply color correction to the image",
3334 "-contrast enhance or reduce the image contrast",
3335 "-contrast-stretch geometry",
3336 " improve contrast by `stretching' the intensity range",
3337 "-convolve coefficients",
3338 " apply a convolution kernel to the image",
3339 "-cycle amount cycle the image colormap",
3340 "-decipher filename convert cipher pixels to plain pixels",
3341 "-deskew threshold straighten an image",
3342 "-despeckle reduce the speckles within an image",
3343 "-distort method args",
3344 " distort images according to given method ad args",
3345 "-draw string annotate the image with a graphic primitive",
3346 "-edge radius apply a filter to detect edges in the image",
3347 "-encipher filename convert plain pixels to cipher pixels",
3348 "-emboss radius emboss an image",
3349 "-enhance apply a digital filter to enhance a noisy image",
3350 "-equalize perform histogram equalization to an image",
3351 "-evaluate operator value",
3352 " evaluate an arithmetic, relational, or logical expression",
3353 "-extent geometry set the image size",
3354 "-extract geometry extract area from image",
3355 "-fft implements the discrete Fourier transform (DFT)",
3356 "-flip flip image vertically",
3357 "-floodfill geometry color",
3358 " floodfill the image with color",
3359 "-flop flop image horizontally",
3360 "-frame geometry surround image with an ornamental border",
3361 "-function name parameters",
3362 " apply function over image values",
3363 "-gamma value level of gamma correction",
3364 "-gaussian-blur geometry",
3365 " reduce image noise and reduce detail levels",
3366 "-geometry geometry preferred size or location of the image",
3367 "-identify identify the format and characteristics of the image",
3368 "-ift implements the inverse discrete Fourier transform (DFT)",
3369 "-implode amount implode image pixels about the center",
3370 "-lat geometry local adaptive thresholding",
3371 "-layers method optimize, merge, or compare image layers",
3372 "-level value adjust the level of image contrast",
3373 "-level-colors color,color",
3374 " level image with the given colors",
3375 "-linear-stretch geometry",
3376 " improve contrast by `stretching with saturation'",
3377 "-liquid-rescale geometry",
3378 " rescale image with seam-carving",
3379 "-median geometry apply a median filter to the image",
3380 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3381 "-modulate value vary the brightness, saturation, and hue",
3382 "-monochrome transform image to black and white",
3383 "-morphology method kernel",
3384 " apply a morphology method to the image",
3385 "-motion-blur geometry",
3386 " simulate motion blur",
3387 "-negate replace every pixel with its complementary color ",
3388 "-noise geometry add or reduce noise in an image",
3389 "-normalize transform image to span the full range of colors",
3390 "-opaque color change this color to the fill color",
3391 "-ordered-dither NxN",
3392 " add a noise pattern to the image with specific",
3394 "-paint radius simulate an oil painting",
3395 "-polaroid angle simulate a Polaroid picture",
3396 "-posterize levels reduce the image to a limited number of color levels",
3397 "-profile filename add, delete, or apply an image profile",
3398 "-quantize colorspace reduce colors in this colorspace",
3399 "-radial-blur angle radial blur the image",
3400 "-raise value lighten/darken image edges to create a 3-D effect",
3401 "-random-threshold low,high",
3402 " random threshold the image",
3403 "-region geometry apply options to a portion of the image",
3404 "-render render vector graphics",
3405 "-repage geometry size and location of an image canvas",
3406 "-resample geometry change the resolution of an image",
3407 "-resize geometry resize the image",
3408 "-roll geometry roll an image vertically or horizontally",
3409 "-rotate degrees apply Paeth rotation to the image",
3410 "-sample geometry scale image with pixel sampling",
3411 "-scale geometry scale the image",
3412 "-segment values segment an image",
3413 "-selective-blur geometry",
3414 " selectively blur pixels within a contrast threshold",
3415 "-sepia-tone threshold",
3416 " simulate a sepia-toned photo",
3417 "-set property value set an image property",
3418 "-shade degrees shade the image using a distant light source",
3419 "-shadow geometry simulate an image shadow",
3420 "-sharpen geometry sharpen the image",
3421 "-shave geometry shave pixels from the image edges",
3422 "-shear geometry slide one edge of the image along the X or Y axis",
3423 "-sigmoidal-contrast geometry",
3424 " increase the contrast without saturating highlights or shadows",
3425 "-sketch geometry simulate a pencil sketch",
3426 "-solarize threshold negate all pixels above the threshold level",
3427 "-sparse-color method args",
3428 " fill in a image based on a few color points",
3429 "-splice geometry splice the background color into the image",
3430 "-spread radius displace image pixels by a random amount",
3431 "-statistic type radius",
3432 " replace each pixel with corresponding statistic from the neighborhood",
3433 "-strip strip image of all profiles and comments",
3434 "-swirl degrees swirl image pixels about the center",
3435 "-threshold value threshold the image",
3436 "-thumbnail geometry create a thumbnail of the image",
3437 "-tile filename tile image when filling a graphic primitive",
3438 "-tint value tint the image with the fill color",
3439 "-transform affine transform image",
3440 "-transparent color make this color transparent within the image",
3441 "-transpose flip image vertically and rotate 90 degrees",
3442 "-transverse flop image horizontally and rotate 270 degrees",
3443 "-trim trim image edges",
3444 "-type type image type",
3445 "-unique-colors discard all but one of any pixel color",
3446 "-unsharp geometry sharpen the image",
3447 "-vignette geometry soften the edges of the image in vignette style",
3448 "-wave geometry alter an image along a sine wave",
3449 "-white-threshold value",
3450 " force all pixels above the threshold into white",
3453 *sequence_operators[]=
3455 "-append append an image sequence",
3456 "-clut apply a color lookup table to the image",
3457 "-coalesce merge a sequence of images",
3458 "-combine combine a sequence of images",
3459 "-composite composite image",
3460 "-crop geometry cut out a rectangular region of the image",
3461 "-deconstruct break down an image sequence into constituent parts",
3462 "-evaluate-sequence operator",
3463 " evaluate an arithmetic, relational, or logical expression",
3464 "-flatten flatten a sequence of images",
3465 "-fx expression apply mathematical expression to an image channel(s)",
3466 "-hald-clut apply a Hald color lookup table to the image",
3467 "-morph value morph an image sequence",
3468 "-mosaic create a mosaic from an image sequence",
3469 "-print string interpret string and print to console",
3470 "-process arguments process the image with a custom image filter",
3471 "-separate separate an image channel into a grayscale image",
3472 "-smush geometry smush an image sequence together",
3473 "-write filename write images to this file",
3478 "-adjoin join images into a single multi-image file",
3479 "-affine matrix affine transform matrix",
3480 "-alpha option activate, deactivate, reset, or set the alpha channel",
3481 "-antialias remove pixel-aliasing",
3482 "-authenticate password",
3483 " decipher image with this password",
3484 "-attenuate value lessen (or intensify) when adding noise to an image",
3485 "-background color background color",
3486 "-bias value add bias when convolving an image",
3487 "-black-point-compensation",
3488 " use black point compensation",
3489 "-blue-primary point chromaticity blue primary point",
3490 "-bordercolor color border color",
3491 "-caption string assign a caption to an image",
3492 "-channel type apply option to select image channels",
3493 "-colors value preferred number of colors in the image",
3494 "-colorspace type alternate image colorspace",
3495 "-comment string annotate image with comment",
3496 "-compose operator set image composite operator",
3497 "-compress type type of pixel compression when writing the image",
3498 "-define format:option",
3499 " define one or more image format options",
3500 "-delay value display the next image after pausing",
3501 "-density geometry horizontal and vertical density of the image",
3502 "-depth value image depth",
3503 "-direction type render text right-to-left or left-to-right",
3504 "-display server get image or font from this X server",
3505 "-dispose method layer disposal method",
3506 "-dither method apply error diffusion to image",
3507 "-encoding type text encoding type",
3508 "-endian type endianness (MSB or LSB) of the image",
3509 "-family name render text with this font family",
3510 "-fill color color to use when filling a graphic primitive",
3511 "-filter type use this filter when resizing an image",
3512 "-font name render text with this font",
3513 "-format \"string\" output formatted image characteristics",
3514 "-fuzz distance colors within this distance are considered equal",
3515 "-gravity type horizontal and vertical text placement",
3516 "-green-primary point chromaticity green primary point",
3517 "-intent type type of rendering intent when managing the image color",
3518 "-interlace type type of image interlacing scheme",
3519 "-interline-spacing value",
3520 " set the space between two text lines",
3521 "-interpolate method pixel color interpolation method",
3522 "-interword-spacing value",
3523 " set the space between two words",
3524 "-kerning value set the space between two letters",
3525 "-label string assign a label to an image",
3526 "-limit type value pixel cache resource limit",
3527 "-loop iterations add Netscape loop extension to your GIF animation",
3528 "-mask filename associate a mask with the image",
3529 "-mattecolor color frame color",
3530 "-monitor monitor progress",
3531 "-orient type image orientation",
3532 "-page geometry size and location of an image canvas (setting)",
3533 "-ping efficiently determine image attributes",
3534 "-pointsize value font point size",
3535 "-precision value maximum number of significant digits to print",
3536 "-preview type image preview type",
3537 "-quality value JPEG/MIFF/PNG compression level",
3538 "-quiet suppress all warning messages",
3539 "-red-primary point chromaticity red primary point",
3540 "-regard-warnings pay attention to warning messages",
3541 "-remap filename transform image colors to match this set of colors",
3542 "-respect-parentheses settings remain in effect until parenthesis boundary",
3543 "-sampling-factor geometry",
3544 " horizontal and vertical sampling factor",
3545 "-scene value image scene number",
3546 "-seed value seed a new sequence of pseudo-random numbers",
3547 "-size geometry width and height of image",
3548 "-stretch type render text with this font stretch",
3549 "-stroke color graphic primitive stroke color",
3550 "-strokewidth value graphic primitive stroke width",
3551 "-style type render text with this font style",
3552 "-synchronize synchronize image to storage device",
3553 "-taint declare the image as modified",
3554 "-texture filename name of texture to tile onto the image background",
3555 "-tile-offset geometry",
3557 "-treedepth value color tree depth",
3558 "-transparent-color color",
3559 " transparent color",
3560 "-undercolor color annotation bounding box color",
3561 "-units type the units of image resolution",
3562 "-verbose print detailed information about the image",
3563 "-view FlashPix viewing transforms",
3564 "-virtual-pixel method",
3565 " virtual pixel access method",
3566 "-weight type render text with this font weight",
3567 "-white-point point chromaticity white point",
3572 "-delete indexes delete the image from the image sequence",
3573 "-duplicate count,indexes",
3574 " duplicate an image one or more times",
3575 "-insert index insert last image into the image sequence",
3576 "-reverse reverse image sequence",
3577 "-swap indexes swap two images in the image sequence",
3584 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3585 (void) printf("Copyright: %s\n",GetMagickCopyright());
3586 (void) printf("Features: %s\n\n",GetMagickFeatures());
3587 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3589 (void) printf("\nImage Settings:\n");
3590 for (p=settings; *p != (char *) NULL; p++)
3591 (void) printf(" %s\n",*p);
3592 (void) printf("\nImage Operators:\n");
3593 for (p=operators; *p != (char *) NULL; p++)
3594 (void) printf(" %s\n",*p);
3595 (void) printf("\nImage Sequence Operators:\n");
3596 for (p=sequence_operators; *p != (char *) NULL; p++)
3597 (void) printf(" %s\n",*p);
3598 (void) printf("\nImage Stack Operators:\n");
3599 for (p=stack_operators; *p != (char *) NULL; p++)
3600 (void) printf(" %s\n",*p);
3601 (void) printf("\nMiscellaneous Options:\n");
3602 for (p=miscellaneous; *p != (char *) NULL; p++)
3603 (void) printf(" %s\n",*p);
3605 "\nBy default, the image format of `file' is determined by its magic\n");
3607 "number. To specify a particular image format, precede the filename\n");
3609 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3611 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3612 (void) printf("'-' for standard input or output.\n");
3613 return(MagickFalse);
3616 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3617 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3619 #define DestroyMogrify() \
3621 if (format != (char *) NULL) \
3622 format=DestroyString(format); \
3623 if (path != (char *) NULL) \
3624 path=DestroyString(path); \
3625 DestroyImageStack(); \
3626 for (i=0; i < (ssize_t) argc; i++) \
3627 argv[i]=DestroyString(argv[i]); \
3628 argv=(char **) RelinquishMagickMemory(argv); \
3630 #define ThrowMogrifyException(asperity,tag,option) \
3632 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3635 return(MagickFalse); \
3637 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3639 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3640 "InvalidArgument","`%s': %s",argument,option); \
3642 return(MagickFalse); \
3654 image_stack[MaxImageStackDepth+1];
3662 respect_parenthesis;
3677 assert(image_info != (ImageInfo *) NULL);
3678 assert(image_info->signature == MagickSignature);
3679 if (image_info->debug != MagickFalse)
3680 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3681 assert(exception != (ExceptionInfo *) NULL);
3685 if ((LocaleCompare("version",option+1) == 0) ||
3686 (LocaleCompare("-version",option+1) == 0))
3688 (void) FormatLocaleFile(stdout,"Version: %s\n",
3689 GetMagickVersion((size_t *) NULL));
3690 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3691 GetMagickCopyright());
3692 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3693 GetMagickFeatures());
3694 return(MagickFalse);
3698 return(MogrifyUsage());
3699 format=(char *) NULL;
3701 global_colormap=MagickFalse;
3705 option=(char *) NULL;
3707 respect_parenthesis=MagickFalse;
3712 ReadCommandlLine(argc,&argv);
3713 status=ExpandFilenames(&argc,&argv);
3714 if (status == MagickFalse)
3715 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3716 GetExceptionMessage(errno));
3717 for (i=1; i < (ssize_t) argc; i++)
3720 if (LocaleCompare(option,"(") == 0)
3722 FireImageStack(MagickFalse,MagickTrue,pend);
3723 if (k == MaxImageStackDepth)
3724 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3729 if (LocaleCompare(option,")") == 0)
3731 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3733 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3737 if (IsCommandOption(option) == MagickFalse)
3740 backup_filename[MaxTextExtent],
3747 Option is a file name: begin by reading image from specified file.
3749 FireImageStack(MagickFalse,MagickFalse,pend);
3751 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3753 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3754 images=ReadImages(image_info,exception);
3755 status&=(images != (Image *) NULL) &&
3756 (exception->severity < ErrorException);
3757 if (images == (Image *) NULL)
3759 if (format != (char *) NULL)
3760 (void) CopyMagickString(images->filename,images->magick_filename,
3762 if (path != (char *) NULL)
3764 GetPathComponent(option,TailPath,filename);
3765 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3766 path,*DirectorySeparator,filename);
3768 if (format != (char *) NULL)
3769 AppendImageFormat(format,images->filename);
3770 AppendImageStack(images);
3771 FinalizeImageSettings(image_info,image,MagickFalse);
3772 if (global_colormap != MagickFalse)
3777 quantize_info=AcquireQuantizeInfo(image_info);
3778 (void) RemapImages(quantize_info,images,(Image *) NULL,exception);
3779 quantize_info=DestroyQuantizeInfo(quantize_info);
3781 *backup_filename='\0';
3782 if ((LocaleCompare(image->filename,"-") != 0) &&
3783 (IsPathWritable(image->filename) != MagickFalse))
3789 Rename image file as backup.
3791 (void) CopyMagickString(backup_filename,image->filename,
3793 for (i=0; i < 6; i++)
3795 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3796 if (IsPathAccessible(backup_filename) == MagickFalse)
3799 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3800 (rename_utf8(image->filename,backup_filename) != 0))
3801 *backup_filename='\0';
3804 Write transmogrified image to disk.
3806 image_info->synchronize=MagickTrue;
3807 status&=WriteImages(image_info,image,image->filename,exception);
3808 if ((status == MagickFalse) && (*backup_filename != '\0'))
3809 (void) remove_utf8(backup_filename);
3810 RemoveAllImageStack();
3813 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3814 switch (*(option+1))
3818 if (LocaleCompare("adaptive-blur",option+1) == 0)
3821 if (i == (ssize_t) argc)
3822 ThrowMogrifyException(OptionError,"MissingArgument",option);
3823 if (IsGeometry(argv[i]) == MagickFalse)
3824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3827 if (LocaleCompare("adaptive-resize",option+1) == 0)
3830 if (i == (ssize_t) argc)
3831 ThrowMogrifyException(OptionError,"MissingArgument",option);
3832 if (IsGeometry(argv[i]) == MagickFalse)
3833 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3836 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3839 if (i == (ssize_t) argc)
3840 ThrowMogrifyException(OptionError,"MissingArgument",option);
3841 if (IsGeometry(argv[i]) == MagickFalse)
3842 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3845 if (LocaleCompare("affine",option+1) == 0)
3850 if (i == (ssize_t) argc)
3851 ThrowMogrifyException(OptionError,"MissingArgument",option);
3854 if (LocaleCompare("alpha",option+1) == 0)
3862 if (i == (ssize_t) argc)
3863 ThrowMogrifyException(OptionError,"MissingArgument",option);
3864 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3866 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3870 if (LocaleCompare("annotate",option+1) == 0)
3875 if (i == (ssize_t) argc)
3876 ThrowMogrifyException(OptionError,"MissingArgument",option);
3877 if (IsGeometry(argv[i]) == MagickFalse)
3878 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3879 if (i == (ssize_t) argc)
3880 ThrowMogrifyException(OptionError,"MissingArgument",option);
3884 if (LocaleCompare("antialias",option+1) == 0)
3886 if (LocaleCompare("append",option+1) == 0)
3888 if (LocaleCompare("attenuate",option+1) == 0)
3893 if (i == (ssize_t) (argc-1))
3894 ThrowMogrifyException(OptionError,"MissingArgument",option);
3895 if (IsGeometry(argv[i]) == MagickFalse)
3896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3899 if (LocaleCompare("authenticate",option+1) == 0)
3904 if (i == (ssize_t) argc)
3905 ThrowMogrifyException(OptionError,"MissingArgument",option);
3908 if (LocaleCompare("auto-gamma",option+1) == 0)
3910 if (LocaleCompare("auto-level",option+1) == 0)
3912 if (LocaleCompare("auto-orient",option+1) == 0)
3914 if (LocaleCompare("average",option+1) == 0)
3916 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3920 if (LocaleCompare("background",option+1) == 0)
3925 if (i == (ssize_t) argc)
3926 ThrowMogrifyException(OptionError,"MissingArgument",option);
3929 if (LocaleCompare("bias",option+1) == 0)
3934 if (i == (ssize_t) (argc-1))
3935 ThrowMogrifyException(OptionError,"MissingArgument",option);
3936 if (IsGeometry(argv[i]) == MagickFalse)
3937 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3940 if (LocaleCompare("black-point-compensation",option+1) == 0)
3942 if (LocaleCompare("black-threshold",option+1) == 0)
3947 if (i == (ssize_t) argc)
3948 ThrowMogrifyException(OptionError,"MissingArgument",option);
3949 if (IsGeometry(argv[i]) == MagickFalse)
3950 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3953 if (LocaleCompare("blue-primary",option+1) == 0)
3958 if (i == (ssize_t) argc)
3959 ThrowMogrifyException(OptionError,"MissingArgument",option);
3960 if (IsGeometry(argv[i]) == MagickFalse)
3961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3964 if (LocaleCompare("blue-shift",option+1) == 0)
3967 if (i == (ssize_t) argc)
3968 ThrowMogrifyException(OptionError,"MissingArgument",option);
3969 if (IsGeometry(argv[i]) == MagickFalse)
3970 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3973 if (LocaleCompare("blur",option+1) == 0)
3976 if (i == (ssize_t) argc)
3977 ThrowMogrifyException(OptionError,"MissingArgument",option);
3978 if (IsGeometry(argv[i]) == MagickFalse)
3979 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3982 if (LocaleCompare("border",option+1) == 0)
3987 if (i == (ssize_t) argc)
3988 ThrowMogrifyException(OptionError,"MissingArgument",option);
3989 if (IsGeometry(argv[i]) == MagickFalse)
3990 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3993 if (LocaleCompare("bordercolor",option+1) == 0)
3998 if (i == (ssize_t) argc)
3999 ThrowMogrifyException(OptionError,"MissingArgument",option);
4002 if (LocaleCompare("box",option+1) == 0)
4007 if (i == (ssize_t) argc)
4008 ThrowMogrifyException(OptionError,"MissingArgument",option);
4011 if (LocaleCompare("brightness-contrast",option+1) == 0)
4014 if (i == (ssize_t) argc)
4015 ThrowMogrifyException(OptionError,"MissingArgument",option);
4016 if (IsGeometry(argv[i]) == MagickFalse)
4017 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4020 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4024 if (LocaleCompare("cache",option+1) == 0)
4029 if (i == (ssize_t) argc)
4030 ThrowMogrifyException(OptionError,"MissingArgument",option);
4031 if (IsGeometry(argv[i]) == MagickFalse)
4032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4035 if (LocaleCompare("caption",option+1) == 0)
4040 if (i == (ssize_t) argc)
4041 ThrowMogrifyException(OptionError,"MissingArgument",option);
4044 if (LocaleCompare("channel",option+1) == 0)
4052 if (i == (ssize_t) (argc-1))
4053 ThrowMogrifyException(OptionError,"MissingArgument",option);
4054 channel=ParseChannelOption(argv[i]);
4056 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
4060 if (LocaleCompare("cdl",option+1) == 0)
4065 if (i == (ssize_t) (argc-1))
4066 ThrowMogrifyException(OptionError,"MissingArgument",option);
4069 if (LocaleCompare("charcoal",option+1) == 0)
4074 if (i == (ssize_t) argc)
4075 ThrowMogrifyException(OptionError,"MissingArgument",option);
4076 if (IsGeometry(argv[i]) == MagickFalse)
4077 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4080 if (LocaleCompare("chop",option+1) == 0)
4085 if (i == (ssize_t) argc)
4086 ThrowMogrifyException(OptionError,"MissingArgument",option);
4087 if (IsGeometry(argv[i]) == MagickFalse)
4088 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4091 if (LocaleCompare("clamp",option+1) == 0)
4093 if (LocaleCompare("clip",option+1) == 0)
4095 if (LocaleCompare("clip-mask",option+1) == 0)
4100 if (i == (ssize_t) argc)
4101 ThrowMogrifyException(OptionError,"MissingArgument",option);
4104 if (LocaleCompare("clut",option+1) == 0)
4106 if (LocaleCompare("coalesce",option+1) == 0)
4108 if (LocaleCompare("colorize",option+1) == 0)
4113 if (i == (ssize_t) argc)
4114 ThrowMogrifyException(OptionError,"MissingArgument",option);
4115 if (IsGeometry(argv[i]) == MagickFalse)
4116 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4119 if (LocaleCompare("color-matrix",option+1) == 0)
4127 if (i == (ssize_t) (argc-1))
4128 ThrowMogrifyException(OptionError,"MissingArgument",option);
4129 kernel_info=AcquireKernelInfo(argv[i]);
4130 if (kernel_info == (KernelInfo *) NULL)
4131 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4132 kernel_info=DestroyKernelInfo(kernel_info);
4135 if (LocaleCompare("colors",option+1) == 0)
4140 if (i == (ssize_t) argc)
4141 ThrowMogrifyException(OptionError,"MissingArgument",option);
4142 if (IsGeometry(argv[i]) == MagickFalse)
4143 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4146 if (LocaleCompare("colorspace",option+1) == 0)
4154 if (i == (ssize_t) argc)
4155 ThrowMogrifyException(OptionError,"MissingArgument",option);
4156 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4159 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4163 if (LocaleCompare("combine",option+1) == 0)
4165 if (LocaleCompare("comment",option+1) == 0)
4170 if (i == (ssize_t) argc)
4171 ThrowMogrifyException(OptionError,"MissingArgument",option);
4174 if (LocaleCompare("composite",option+1) == 0)
4176 if (LocaleCompare("compress",option+1) == 0)
4184 if (i == (ssize_t) argc)
4185 ThrowMogrifyException(OptionError,"MissingArgument",option);
4186 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4189 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4193 if (LocaleCompare("concurrent",option+1) == 0)
4195 if (LocaleCompare("contrast",option+1) == 0)
4197 if (LocaleCompare("contrast-stretch",option+1) == 0)
4200 if (i == (ssize_t) argc)
4201 ThrowMogrifyException(OptionError,"MissingArgument",option);
4202 if (IsGeometry(argv[i]) == MagickFalse)
4203 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4206 if (LocaleCompare("convolve",option+1) == 0)
4214 if (i == (ssize_t) argc)
4215 ThrowMogrifyException(OptionError,"MissingArgument",option);
4216 kernel_info=AcquireKernelInfo(argv[i]);
4217 if (kernel_info == (KernelInfo *) NULL)
4218 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4219 kernel_info=DestroyKernelInfo(kernel_info);
4222 if (LocaleCompare("crop",option+1) == 0)
4227 if (i == (ssize_t) argc)
4228 ThrowMogrifyException(OptionError,"MissingArgument",option);
4229 if (IsGeometry(argv[i]) == MagickFalse)
4230 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4233 if (LocaleCompare("cycle",option+1) == 0)
4238 if (i == (ssize_t) argc)
4239 ThrowMogrifyException(OptionError,"MissingArgument",option);
4240 if (IsGeometry(argv[i]) == MagickFalse)
4241 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4244 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4248 if (LocaleCompare("decipher",option+1) == 0)
4253 if (i == (ssize_t) (argc-1))
4254 ThrowMogrifyException(OptionError,"MissingArgument",option);
4257 if (LocaleCompare("deconstruct",option+1) == 0)
4259 if (LocaleCompare("debug",option+1) == 0)
4267 if (i == (ssize_t) argc)
4268 ThrowMogrifyException(OptionError,"MissingArgument",option);
4269 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4271 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4273 (void) SetLogEventMask(argv[i]);
4276 if (LocaleCompare("define",option+1) == 0)
4279 if (i == (ssize_t) argc)
4280 ThrowMogrifyException(OptionError,"MissingArgument",option);
4286 define=GetImageOption(image_info,argv[i]);
4287 if (define == (const char *) NULL)
4288 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4293 if (LocaleCompare("delay",option+1) == 0)
4298 if (i == (ssize_t) argc)
4299 ThrowMogrifyException(OptionError,"MissingArgument",option);
4300 if (IsGeometry(argv[i]) == MagickFalse)
4301 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4304 if (LocaleCompare("delete",option+1) == 0)
4309 if (i == (ssize_t) (argc-1))
4310 ThrowMogrifyException(OptionError,"MissingArgument",option);
4311 if (IsGeometry(argv[i]) == MagickFalse)
4312 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4315 if (LocaleCompare("density",option+1) == 0)
4320 if (i == (ssize_t) argc)
4321 ThrowMogrifyException(OptionError,"MissingArgument",option);
4322 if (IsGeometry(argv[i]) == MagickFalse)
4323 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4326 if (LocaleCompare("depth",option+1) == 0)
4331 if (i == (ssize_t) argc)
4332 ThrowMogrifyException(OptionError,"MissingArgument",option);
4333 if (IsGeometry(argv[i]) == MagickFalse)
4334 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4337 if (LocaleCompare("deskew",option+1) == 0)
4342 if (i == (ssize_t) argc)
4343 ThrowMogrifyException(OptionError,"MissingArgument",option);
4344 if (IsGeometry(argv[i]) == MagickFalse)
4345 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4348 if (LocaleCompare("despeckle",option+1) == 0)
4350 if (LocaleCompare("dft",option+1) == 0)
4352 if (LocaleCompare("direction",option+1) == 0)
4360 if (i == (ssize_t) argc)
4361 ThrowMogrifyException(OptionError,"MissingArgument",option);
4362 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4365 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4369 if (LocaleCompare("display",option+1) == 0)
4374 if (i == (ssize_t) argc)
4375 ThrowMogrifyException(OptionError,"MissingArgument",option);
4378 if (LocaleCompare("dispose",option+1) == 0)
4386 if (i == (ssize_t) argc)
4387 ThrowMogrifyException(OptionError,"MissingArgument",option);
4388 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4390 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4394 if (LocaleCompare("distort",option+1) == 0)
4400 if (i == (ssize_t) argc)
4401 ThrowMogrifyException(OptionError,"MissingArgument",option);
4402 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4404 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4407 if (i == (ssize_t) (argc-1))
4408 ThrowMogrifyException(OptionError,"MissingArgument",option);
4411 if (LocaleCompare("dither",option+1) == 0)
4419 if (i == (ssize_t) argc)
4420 ThrowMogrifyException(OptionError,"MissingArgument",option);
4421 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4423 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4427 if (LocaleCompare("draw",option+1) == 0)
4432 if (i == (ssize_t) argc)
4433 ThrowMogrifyException(OptionError,"MissingArgument",option);
4436 if (LocaleCompare("duplicate",option+1) == 0)
4441 if (i == (ssize_t) (argc-1))
4442 ThrowMogrifyException(OptionError,"MissingArgument",option);
4443 if (IsGeometry(argv[i]) == MagickFalse)
4444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4447 if (LocaleCompare("duration",option+1) == 0)
4452 if (i == (ssize_t) (argc-1))
4453 ThrowMogrifyException(OptionError,"MissingArgument",option);
4454 if (IsGeometry(argv[i]) == MagickFalse)
4455 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4458 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4462 if (LocaleCompare("edge",option+1) == 0)
4467 if (i == (ssize_t) argc)
4468 ThrowMogrifyException(OptionError,"MissingArgument",option);
4469 if (IsGeometry(argv[i]) == MagickFalse)
4470 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4473 if (LocaleCompare("emboss",option+1) == 0)
4478 if (i == (ssize_t) argc)
4479 ThrowMogrifyException(OptionError,"MissingArgument",option);
4480 if (IsGeometry(argv[i]) == MagickFalse)
4481 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4484 if (LocaleCompare("encipher",option+1) == 0)
4489 if (i == (ssize_t) argc)
4490 ThrowMogrifyException(OptionError,"MissingArgument",option);
4493 if (LocaleCompare("encoding",option+1) == 0)
4498 if (i == (ssize_t) argc)
4499 ThrowMogrifyException(OptionError,"MissingArgument",option);
4502 if (LocaleCompare("endian",option+1) == 0)
4510 if (i == (ssize_t) argc)
4511 ThrowMogrifyException(OptionError,"MissingArgument",option);
4512 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4514 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4518 if (LocaleCompare("enhance",option+1) == 0)
4520 if (LocaleCompare("equalize",option+1) == 0)
4522 if (LocaleCompare("evaluate",option+1) == 0)
4530 if (i == (ssize_t) argc)
4531 ThrowMogrifyException(OptionError,"MissingArgument",option);
4532 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4534 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4537 if (i == (ssize_t) (argc-1))
4538 ThrowMogrifyException(OptionError,"MissingArgument",option);
4539 if (IsGeometry(argv[i]) == MagickFalse)
4540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4543 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4551 if (i == (ssize_t) argc)
4552 ThrowMogrifyException(OptionError,"MissingArgument",option);
4553 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4555 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4559 if (LocaleCompare("extent",option+1) == 0)
4564 if (i == (ssize_t) argc)
4565 ThrowMogrifyException(OptionError,"MissingArgument",option);
4566 if (IsGeometry(argv[i]) == MagickFalse)
4567 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4570 if (LocaleCompare("extract",option+1) == 0)
4575 if (i == (ssize_t) argc)
4576 ThrowMogrifyException(OptionError,"MissingArgument",option);
4577 if (IsGeometry(argv[i]) == MagickFalse)
4578 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4581 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4585 if (LocaleCompare("family",option+1) == 0)
4590 if (i == (ssize_t) (argc-1))
4591 ThrowMogrifyException(OptionError,"MissingArgument",option);
4594 if (LocaleCompare("fill",option+1) == 0)
4599 if (i == (ssize_t) argc)
4600 ThrowMogrifyException(OptionError,"MissingArgument",option);
4603 if (LocaleCompare("filter",option+1) == 0)
4611 if (i == (ssize_t) argc)
4612 ThrowMogrifyException(OptionError,"MissingArgument",option);
4613 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4615 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4619 if (LocaleCompare("flatten",option+1) == 0)
4621 if (LocaleCompare("flip",option+1) == 0)
4623 if (LocaleCompare("flop",option+1) == 0)
4625 if (LocaleCompare("floodfill",option+1) == 0)
4630 if (i == (ssize_t) argc)
4631 ThrowMogrifyException(OptionError,"MissingArgument",option);
4632 if (IsGeometry(argv[i]) == MagickFalse)
4633 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4635 if (i == (ssize_t) argc)
4636 ThrowMogrifyException(OptionError,"MissingArgument",option);
4639 if (LocaleCompare("font",option+1) == 0)
4644 if (i == (ssize_t) argc)
4645 ThrowMogrifyException(OptionError,"MissingArgument",option);
4648 if (LocaleCompare("format",option+1) == 0)
4650 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4651 (void) CloneString(&format,(char *) NULL);
4655 if (i == (ssize_t) argc)
4656 ThrowMogrifyException(OptionError,"MissingArgument",option);
4657 (void) CloneString(&format,argv[i]);
4658 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4659 (void) ConcatenateMagickString(image_info->filename,":",
4661 (void) SetImageInfo(image_info,0,exception);
4662 if (*image_info->magick == '\0')
4663 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4667 if (LocaleCompare("frame",option+1) == 0)
4672 if (i == (ssize_t) argc)
4673 ThrowMogrifyException(OptionError,"MissingArgument",option);
4674 if (IsGeometry(argv[i]) == MagickFalse)
4675 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4678 if (LocaleCompare("function",option+1) == 0)
4686 if (i == (ssize_t) argc)
4687 ThrowMogrifyException(OptionError,"MissingArgument",option);
4688 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4690 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4692 if (i == (ssize_t) (argc-1))
4693 ThrowMogrifyException(OptionError,"MissingArgument",option);
4696 if (LocaleCompare("fuzz",option+1) == 0)
4701 if (i == (ssize_t) argc)
4702 ThrowMogrifyException(OptionError,"MissingArgument",option);
4703 if (IsGeometry(argv[i]) == MagickFalse)
4704 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4707 if (LocaleCompare("fx",option+1) == 0)
4712 if (i == (ssize_t) (argc-1))
4713 ThrowMogrifyException(OptionError,"MissingArgument",option);
4716 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4720 if (LocaleCompare("gamma",option+1) == 0)
4723 if (i == (ssize_t) argc)
4724 ThrowMogrifyException(OptionError,"MissingArgument",option);
4725 if (IsGeometry(argv[i]) == MagickFalse)
4726 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4729 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4730 (LocaleCompare("gaussian",option+1) == 0))
4733 if (i == (ssize_t) argc)
4734 ThrowMogrifyException(OptionError,"MissingArgument",option);
4735 if (IsGeometry(argv[i]) == MagickFalse)
4736 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4739 if (LocaleCompare("geometry",option+1) == 0)
4744 if (i == (ssize_t) argc)
4745 ThrowMogrifyException(OptionError,"MissingArgument",option);
4746 if (IsGeometry(argv[i]) == MagickFalse)
4747 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4750 if (LocaleCompare("gravity",option+1) == 0)
4758 if (i == (ssize_t) argc)
4759 ThrowMogrifyException(OptionError,"MissingArgument",option);
4760 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4762 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4766 if (LocaleCompare("green-primary",option+1) == 0)
4771 if (i == (ssize_t) argc)
4772 ThrowMogrifyException(OptionError,"MissingArgument",option);
4773 if (IsGeometry(argv[i]) == MagickFalse)
4774 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4777 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4781 if (LocaleCompare("hald-clut",option+1) == 0)
4783 if ((LocaleCompare("help",option+1) == 0) ||
4784 (LocaleCompare("-help",option+1) == 0))
4785 return(MogrifyUsage());
4786 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4790 if (LocaleCompare("identify",option+1) == 0)
4792 if (LocaleCompare("idft",option+1) == 0)
4794 if (LocaleCompare("implode",option+1) == 0)
4799 if (i == (ssize_t) argc)
4800 ThrowMogrifyException(OptionError,"MissingArgument",option);
4801 if (IsGeometry(argv[i]) == MagickFalse)
4802 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4805 if (LocaleCompare("intent",option+1) == 0)
4813 if (i == (ssize_t) (argc-1))
4814 ThrowMogrifyException(OptionError,"MissingArgument",option);
4815 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4817 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4821 if (LocaleCompare("interlace",option+1) == 0)
4829 if (i == (ssize_t) argc)
4830 ThrowMogrifyException(OptionError,"MissingArgument",option);
4831 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4834 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4838 if (LocaleCompare("interline-spacing",option+1) == 0)
4843 if (i == (ssize_t) (argc-1))
4844 ThrowMogrifyException(OptionError,"MissingArgument",option);
4845 if (IsGeometry(argv[i]) == MagickFalse)
4846 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4849 if (LocaleCompare("interpolate",option+1) == 0)
4857 if (i == (ssize_t) argc)
4858 ThrowMogrifyException(OptionError,"MissingArgument",option);
4859 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4861 if (interpolate < 0)
4862 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4866 if (LocaleCompare("interword-spacing",option+1) == 0)
4871 if (i == (ssize_t) (argc-1))
4872 ThrowMogrifyException(OptionError,"MissingArgument",option);
4873 if (IsGeometry(argv[i]) == MagickFalse)
4874 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4877 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4881 if (LocaleCompare("kerning",option+1) == 0)
4886 if (i == (ssize_t) (argc-1))
4887 ThrowMogrifyException(OptionError,"MissingArgument",option);
4888 if (IsGeometry(argv[i]) == MagickFalse)
4889 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4892 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4896 if (LocaleCompare("label",option+1) == 0)
4901 if (i == (ssize_t) argc)
4902 ThrowMogrifyException(OptionError,"MissingArgument",option);
4905 if (LocaleCompare("lat",option+1) == 0)
4910 if (i == (ssize_t) argc)
4911 ThrowMogrifyException(OptionError,"MissingArgument",option);
4912 if (IsGeometry(argv[i]) == MagickFalse)
4913 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4915 if (LocaleCompare("layers",option+1) == 0)
4923 if (i == (ssize_t) (argc-1))
4924 ThrowMogrifyException(OptionError,"MissingArgument",option);
4925 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4927 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4931 if (LocaleCompare("level",option+1) == 0)
4934 if (i == (ssize_t) argc)
4935 ThrowMogrifyException(OptionError,"MissingArgument",option);
4936 if (IsGeometry(argv[i]) == MagickFalse)
4937 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4940 if (LocaleCompare("level-colors",option+1) == 0)
4943 if (i == (ssize_t) argc)
4944 ThrowMogrifyException(OptionError,"MissingArgument",option);
4947 if (LocaleCompare("linewidth",option+1) == 0)
4952 if (i == (ssize_t) argc)
4953 ThrowMogrifyException(OptionError,"MissingArgument",option);
4954 if (IsGeometry(argv[i]) == MagickFalse)
4955 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4958 if (LocaleCompare("limit",option+1) == 0)
4972 if (i == (ssize_t) argc)
4973 ThrowMogrifyException(OptionError,"MissingArgument",option);
4974 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4977 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4980 if (i == (ssize_t) argc)
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4982 value=StringToDouble(argv[i],&p);
4984 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4985 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4988 if (LocaleCompare("liquid-rescale",option+1) == 0)
4991 if (i == (ssize_t) argc)
4992 ThrowMogrifyException(OptionError,"MissingArgument",option);
4993 if (IsGeometry(argv[i]) == MagickFalse)
4994 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4997 if (LocaleCompare("list",option+1) == 0)
5005 if (i == (ssize_t) argc)
5006 ThrowMogrifyException(OptionError,"MissingArgument",option);
5007 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5009 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
5010 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5012 return(status != 0 ? MagickFalse : MagickTrue);
5014 if (LocaleCompare("log",option+1) == 0)
5019 if ((i == (ssize_t) argc) ||
5020 (strchr(argv[i],'%') == (char *) NULL))
5021 ThrowMogrifyException(OptionError,"MissingArgument",option);
5024 if (LocaleCompare("loop",option+1) == 0)
5029 if (i == (ssize_t) argc)
5030 ThrowMogrifyException(OptionError,"MissingArgument",option);
5031 if (IsGeometry(argv[i]) == MagickFalse)
5032 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5035 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5039 if (LocaleCompare("map",option+1) == 0)
5041 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
5045 if (i == (ssize_t) argc)
5046 ThrowMogrifyException(OptionError,"MissingArgument",option);
5049 if (LocaleCompare("mask",option+1) == 0)
5054 if (i == (ssize_t) argc)
5055 ThrowMogrifyException(OptionError,"MissingArgument",option);
5058 if (LocaleCompare("matte",option+1) == 0)
5060 if (LocaleCompare("mattecolor",option+1) == 0)
5065 if (i == (ssize_t) argc)
5066 ThrowMogrifyException(OptionError,"MissingArgument",option);
5069 if (LocaleCompare("maximum",option+1) == 0)
5071 if (LocaleCompare("minimum",option+1) == 0)
5073 if (LocaleCompare("modulate",option+1) == 0)
5078 if (i == (ssize_t) argc)
5079 ThrowMogrifyException(OptionError,"MissingArgument",option);
5080 if (IsGeometry(argv[i]) == MagickFalse)
5081 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5084 if (LocaleCompare("median",option+1) == 0)
5089 if (i == (ssize_t) argc)
5090 ThrowMogrifyException(OptionError,"MissingArgument",option);
5091 if (IsGeometry(argv[i]) == MagickFalse)
5092 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5095 if (LocaleCompare("mode",option+1) == 0)
5100 if (i == (ssize_t) argc)
5101 ThrowMogrifyException(OptionError,"MissingArgument",option);
5102 if (IsGeometry(argv[i]) == MagickFalse)
5103 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5106 if (LocaleCompare("monitor",option+1) == 0)
5108 if (LocaleCompare("monochrome",option+1) == 0)
5110 if (LocaleCompare("morph",option+1) == 0)
5115 if (i == (ssize_t) (argc-1))
5116 ThrowMogrifyException(OptionError,"MissingArgument",option);
5117 if (IsGeometry(argv[i]) == MagickFalse)
5118 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5121 if (LocaleCompare("morphology",option+1) == 0)
5124 token[MaxTextExtent];
5133 if (i == (ssize_t) argc)
5134 ThrowMogrifyException(OptionError,"MissingArgument",option);
5135 GetMagickToken(argv[i],NULL,token);
5136 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5138 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5141 if (i == (ssize_t) (argc-1))
5142 ThrowMogrifyException(OptionError,"MissingArgument",option);
5143 kernel_info=AcquireKernelInfo(argv[i]);
5144 if (kernel_info == (KernelInfo *) NULL)
5145 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5146 kernel_info=DestroyKernelInfo(kernel_info);
5149 if (LocaleCompare("mosaic",option+1) == 0)
5151 if (LocaleCompare("motion-blur",option+1) == 0)
5156 if (i == (ssize_t) argc)
5157 ThrowMogrifyException(OptionError,"MissingArgument",option);
5158 if (IsGeometry(argv[i]) == MagickFalse)
5159 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5162 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5166 if (LocaleCompare("negate",option+1) == 0)
5168 if (LocaleCompare("noise",option+1) == 0)
5171 if (i == (ssize_t) argc)
5172 ThrowMogrifyException(OptionError,"MissingArgument",option);
5178 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5180 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5184 if (IsGeometry(argv[i]) == MagickFalse)
5185 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5188 if (LocaleCompare("noop",option+1) == 0)
5190 if (LocaleCompare("normalize",option+1) == 0)
5192 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5196 if (LocaleCompare("opaque",option+1) == 0)
5199 if (i == (ssize_t) argc)
5200 ThrowMogrifyException(OptionError,"MissingArgument",option);
5203 if (LocaleCompare("ordered-dither",option+1) == 0)
5208 if (i == (ssize_t) argc)
5209 ThrowMogrifyException(OptionError,"MissingArgument",option);
5212 if (LocaleCompare("orient",option+1) == 0)
5217 orientation=UndefinedOrientation;
5221 if (i == (ssize_t) (argc-1))
5222 ThrowMogrifyException(OptionError,"MissingArgument",option);
5223 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5225 if (orientation < 0)
5226 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5230 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5234 if (LocaleCompare("page",option+1) == 0)
5239 if (i == (ssize_t) argc)
5240 ThrowMogrifyException(OptionError,"MissingArgument",option);
5243 if (LocaleCompare("paint",option+1) == 0)
5248 if (i == (ssize_t) argc)
5249 ThrowMogrifyException(OptionError,"MissingArgument",option);
5250 if (IsGeometry(argv[i]) == MagickFalse)
5251 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5254 if (LocaleCompare("path",option+1) == 0)
5256 (void) CloneString(&path,(char *) NULL);
5260 if (i == (ssize_t) argc)
5261 ThrowMogrifyException(OptionError,"MissingArgument",option);
5262 (void) CloneString(&path,argv[i]);
5265 if (LocaleCompare("pointsize",option+1) == 0)
5270 if (i == (ssize_t) argc)
5271 ThrowMogrifyException(OptionError,"MissingArgument",option);
5272 if (IsGeometry(argv[i]) == MagickFalse)
5273 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5276 if (LocaleCompare("polaroid",option+1) == 0)
5281 if (i == (ssize_t) argc)
5282 ThrowMogrifyException(OptionError,"MissingArgument",option);
5283 if (IsGeometry(argv[i]) == MagickFalse)
5284 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5287 if (LocaleCompare("posterize",option+1) == 0)
5292 if (i == (ssize_t) argc)
5293 ThrowMogrifyException(OptionError,"MissingArgument",option);
5294 if (IsGeometry(argv[i]) == MagickFalse)
5295 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5298 if (LocaleCompare("precision",option+1) == 0)
5303 if (i == (ssize_t) argc)
5304 ThrowMogrifyException(OptionError,"MissingArgument",option);
5305 if (IsGeometry(argv[i]) == MagickFalse)
5306 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5309 if (LocaleCompare("print",option+1) == 0)
5314 if (i == (ssize_t) argc)
5315 ThrowMogrifyException(OptionError,"MissingArgument",option);
5318 if (LocaleCompare("process",option+1) == 0)
5323 if (i == (ssize_t) (argc-1))
5324 ThrowMogrifyException(OptionError,"MissingArgument",option);
5327 if (LocaleCompare("profile",option+1) == 0)
5330 if (i == (ssize_t) argc)
5331 ThrowMogrifyException(OptionError,"MissingArgument",option);
5334 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5338 if (LocaleCompare("quality",option+1) == 0)
5343 if (i == (ssize_t) argc)
5344 ThrowMogrifyException(OptionError,"MissingArgument",option);
5345 if (IsGeometry(argv[i]) == MagickFalse)
5346 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5349 if (LocaleCompare("quantize",option+1) == 0)
5357 if (i == (ssize_t) (argc-1))
5358 ThrowMogrifyException(OptionError,"MissingArgument",option);
5359 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5362 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5366 if (LocaleCompare("quiet",option+1) == 0)
5368 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5372 if (LocaleCompare("radial-blur",option+1) == 0)
5375 if (i == (ssize_t) argc)
5376 ThrowMogrifyException(OptionError,"MissingArgument",option);
5377 if (IsGeometry(argv[i]) == MagickFalse)
5378 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5381 if (LocaleCompare("raise",option+1) == 0)
5384 if (i == (ssize_t) argc)
5385 ThrowMogrifyException(OptionError,"MissingArgument",option);
5386 if (IsGeometry(argv[i]) == MagickFalse)
5387 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5390 if (LocaleCompare("random-threshold",option+1) == 0)
5395 if (i == (ssize_t) argc)
5396 ThrowMogrifyException(OptionError,"MissingArgument",option);
5397 if (IsGeometry(argv[i]) == MagickFalse)
5398 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5401 if (LocaleCompare("recolor",option+1) == 0)
5406 if (i == (ssize_t) (argc-1))
5407 ThrowMogrifyException(OptionError,"MissingArgument",option);
5408 if (IsGeometry(argv[i]) == MagickFalse)
5409 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5412 if (LocaleCompare("red-primary",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]);
5422 if (LocaleCompare("regard-warnings",option+1) == 0)
5424 if (LocaleCompare("region",option+1) == 0)
5429 if (i == (ssize_t) argc)
5430 ThrowMogrifyException(OptionError,"MissingArgument",option);
5431 if (IsGeometry(argv[i]) == MagickFalse)
5432 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5435 if (LocaleCompare("remap",option+1) == 0)
5440 if (i == (ssize_t) (argc-1))
5441 ThrowMogrifyException(OptionError,"MissingArgument",option);
5444 if (LocaleCompare("render",option+1) == 0)
5446 if (LocaleCompare("repage",option+1) == 0)
5451 if (i == (ssize_t) argc)
5452 ThrowMogrifyException(OptionError,"MissingArgument",option);
5453 if (IsGeometry(argv[i]) == MagickFalse)
5454 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5457 if (LocaleCompare("resample",option+1) == 0)
5462 if (i == (ssize_t) argc)
5463 ThrowMogrifyException(OptionError,"MissingArgument",option);
5464 if (IsGeometry(argv[i]) == MagickFalse)
5465 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5468 if (LocaleCompare("resize",option+1) == 0)
5473 if (i == (ssize_t) argc)
5474 ThrowMogrifyException(OptionError,"MissingArgument",option);
5475 if (IsGeometry(argv[i]) == MagickFalse)
5476 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5479 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5481 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5484 if (LocaleCompare("reverse",option+1) == 0)
5486 if (LocaleCompare("roll",option+1) == 0)
5491 if (i == (ssize_t) argc)
5492 ThrowMogrifyException(OptionError,"MissingArgument",option);
5493 if (IsGeometry(argv[i]) == MagickFalse)
5494 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5497 if (LocaleCompare("rotate",option+1) == 0)
5500 if (i == (ssize_t) argc)
5501 ThrowMogrifyException(OptionError,"MissingArgument",option);
5502 if (IsGeometry(argv[i]) == MagickFalse)
5503 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5506 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5510 if (LocaleCompare("sample",option+1) == 0)
5515 if (i == (ssize_t) argc)
5516 ThrowMogrifyException(OptionError,"MissingArgument",option);
5517 if (IsGeometry(argv[i]) == MagickFalse)
5518 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5521 if (LocaleCompare("sampling-factor",option+1) == 0)
5526 if (i == (ssize_t) argc)
5527 ThrowMogrifyException(OptionError,"MissingArgument",option);
5528 if (IsGeometry(argv[i]) == MagickFalse)
5529 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5532 if (LocaleCompare("scale",option+1) == 0)
5537 if (i == (ssize_t) argc)
5538 ThrowMogrifyException(OptionError,"MissingArgument",option);
5539 if (IsGeometry(argv[i]) == MagickFalse)
5540 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5543 if (LocaleCompare("scene",option+1) == 0)
5548 if (i == (ssize_t) argc)
5549 ThrowMogrifyException(OptionError,"MissingArgument",option);
5550 if (IsGeometry(argv[i]) == MagickFalse)
5551 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5554 if (LocaleCompare("seed",option+1) == 0)
5559 if (i == (ssize_t) argc)
5560 ThrowMogrifyException(OptionError,"MissingArgument",option);
5561 if (IsGeometry(argv[i]) == MagickFalse)
5562 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5565 if (LocaleCompare("segment",option+1) == 0)
5570 if (i == (ssize_t) argc)
5571 ThrowMogrifyException(OptionError,"MissingArgument",option);
5572 if (IsGeometry(argv[i]) == MagickFalse)
5573 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5576 if (LocaleCompare("selective-blur",option+1) == 0)
5579 if (i == (ssize_t) argc)
5580 ThrowMogrifyException(OptionError,"MissingArgument",option);
5581 if (IsGeometry(argv[i]) == MagickFalse)
5582 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5585 if (LocaleCompare("separate",option+1) == 0)
5587 if (LocaleCompare("sepia-tone",option+1) == 0)
5592 if (i == (ssize_t) argc)
5593 ThrowMogrifyException(OptionError,"MissingArgument",option);
5594 if (IsGeometry(argv[i]) == MagickFalse)
5595 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5598 if (LocaleCompare("set",option+1) == 0)
5601 if (i == (ssize_t) argc)
5602 ThrowMogrifyException(OptionError,"MissingArgument",option);
5606 if (i == (ssize_t) argc)
5607 ThrowMogrifyException(OptionError,"MissingArgument",option);
5610 if (LocaleCompare("shade",option+1) == 0)
5613 if (i == (ssize_t) argc)
5614 ThrowMogrifyException(OptionError,"MissingArgument",option);
5615 if (IsGeometry(argv[i]) == MagickFalse)
5616 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5619 if (LocaleCompare("shadow",option+1) == 0)
5624 if (i == (ssize_t) argc)
5625 ThrowMogrifyException(OptionError,"MissingArgument",option);
5626 if (IsGeometry(argv[i]) == MagickFalse)
5627 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5630 if (LocaleCompare("sharpen",option+1) == 0)
5633 if (i == (ssize_t) argc)
5634 ThrowMogrifyException(OptionError,"MissingArgument",option);
5635 if (IsGeometry(argv[i]) == MagickFalse)
5636 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5639 if (LocaleCompare("shave",option+1) == 0)
5644 if (i == (ssize_t) argc)
5645 ThrowMogrifyException(OptionError,"MissingArgument",option);
5646 if (IsGeometry(argv[i]) == MagickFalse)
5647 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5650 if (LocaleCompare("shear",option+1) == 0)
5653 if (i == (ssize_t) argc)
5654 ThrowMogrifyException(OptionError,"MissingArgument",option);
5655 if (IsGeometry(argv[i]) == MagickFalse)
5656 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5659 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
5662 if (i == (ssize_t) (argc-1))
5663 ThrowMogrifyException(OptionError,"MissingArgument",option);
5664 if (IsGeometry(argv[i]) == MagickFalse)
5665 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5668 if (LocaleCompare("size",option+1) == 0)
5673 if (i == (ssize_t) argc)
5674 ThrowMogrifyException(OptionError,"MissingArgument",option);
5675 if (IsGeometry(argv[i]) == MagickFalse)
5676 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5679 if (LocaleCompare("sketch",option+1) == 0)
5684 if (i == (ssize_t) argc)
5685 ThrowMogrifyException(OptionError,"MissingArgument",option);
5686 if (IsGeometry(argv[i]) == MagickFalse)
5687 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5690 if (LocaleCompare("smush",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]);
5700 if (LocaleCompare("solarize",option+1) == 0)
5705 if (i == (ssize_t) argc)
5706 ThrowMogrifyException(OptionError,"MissingArgument",option);
5707 if (IsGeometry(argv[i]) == MagickFalse)
5708 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5711 if (LocaleCompare("sparse-color",option+1) == 0)
5717 if (i == (ssize_t) argc)
5718 ThrowMogrifyException(OptionError,"MissingArgument",option);
5719 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5721 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5724 if (i == (ssize_t) (argc-1))
5725 ThrowMogrifyException(OptionError,"MissingArgument",option);
5728 if (LocaleCompare("spread",option+1) == 0)
5733 if (i == (ssize_t) argc)
5734 ThrowMogrifyException(OptionError,"MissingArgument",option);
5735 if (IsGeometry(argv[i]) == MagickFalse)
5736 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5739 if (LocaleCompare("statistic",option+1) == 0)
5747 if (i == (ssize_t) argc)
5748 ThrowMogrifyException(OptionError,"MissingArgument",option);
5749 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5751 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5754 if (i == (ssize_t) (argc-1))
5755 ThrowMogrifyException(OptionError,"MissingArgument",option);
5756 if (IsGeometry(argv[i]) == MagickFalse)
5757 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5760 if (LocaleCompare("stretch",option+1) == 0)
5768 if (i == (ssize_t) (argc-1))
5769 ThrowMogrifyException(OptionError,"MissingArgument",option);
5770 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5772 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5776 if (LocaleCompare("strip",option+1) == 0)
5778 if (LocaleCompare("stroke",option+1) == 0)
5783 if (i == (ssize_t) argc)
5784 ThrowMogrifyException(OptionError,"MissingArgument",option);
5787 if (LocaleCompare("strokewidth",option+1) == 0)
5792 if (i == (ssize_t) argc)
5793 ThrowMogrifyException(OptionError,"MissingArgument",option);
5794 if (IsGeometry(argv[i]) == MagickFalse)
5795 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5798 if (LocaleCompare("style",option+1) == 0)
5806 if (i == (ssize_t) (argc-1))
5807 ThrowMogrifyException(OptionError,"MissingArgument",option);
5808 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5810 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5814 if (LocaleCompare("swap",option+1) == 0)
5819 if (i == (ssize_t) (argc-1))
5820 ThrowMogrifyException(OptionError,"MissingArgument",option);
5821 if (IsGeometry(argv[i]) == MagickFalse)
5822 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5825 if (LocaleCompare("swirl",option+1) == 0)
5830 if (i == (ssize_t) argc)
5831 ThrowMogrifyException(OptionError,"MissingArgument",option);
5832 if (IsGeometry(argv[i]) == MagickFalse)
5833 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5836 if (LocaleCompare("synchronize",option+1) == 0)
5838 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5842 if (LocaleCompare("taint",option+1) == 0)
5844 if (LocaleCompare("texture",option+1) == 0)
5849 if (i == (ssize_t) argc)
5850 ThrowMogrifyException(OptionError,"MissingArgument",option);
5853 if (LocaleCompare("tile",option+1) == 0)
5858 if (i == (ssize_t) (argc-1))
5859 ThrowMogrifyException(OptionError,"MissingArgument",option);
5862 if (LocaleCompare("tile-offset",option+1) == 0)
5867 if (i == (ssize_t) argc)
5868 ThrowMogrifyException(OptionError,"MissingArgument",option);
5869 if (IsGeometry(argv[i]) == MagickFalse)
5870 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5873 if (LocaleCompare("tint",option+1) == 0)
5878 if (i == (ssize_t) (argc-1))
5879 ThrowMogrifyException(OptionError,"MissingArgument",option);
5880 if (IsGeometry(argv[i]) == MagickFalse)
5881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5884 if (LocaleCompare("transform",option+1) == 0)
5886 if (LocaleCompare("transpose",option+1) == 0)
5888 if (LocaleCompare("transverse",option+1) == 0)
5890 if (LocaleCompare("threshold",option+1) == 0)
5895 if (i == (ssize_t) argc)
5896 ThrowMogrifyException(OptionError,"MissingArgument",option);
5897 if (IsGeometry(argv[i]) == MagickFalse)
5898 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5901 if (LocaleCompare("thumbnail",option+1) == 0)
5906 if (i == (ssize_t) argc)
5907 ThrowMogrifyException(OptionError,"MissingArgument",option);
5908 if (IsGeometry(argv[i]) == MagickFalse)
5909 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5912 if (LocaleCompare("transparent",option+1) == 0)
5915 if (i == (ssize_t) argc)
5916 ThrowMogrifyException(OptionError,"MissingArgument",option);
5919 if (LocaleCompare("transparent-color",option+1) == 0)
5924 if (i == (ssize_t) (argc-1))
5925 ThrowMogrifyException(OptionError,"MissingArgument",option);
5928 if (LocaleCompare("treedepth",option+1) == 0)
5933 if (i == (ssize_t) argc)
5934 ThrowMogrifyException(OptionError,"MissingArgument",option);
5935 if (IsGeometry(argv[i]) == MagickFalse)
5936 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5939 if (LocaleCompare("trim",option+1) == 0)
5941 if (LocaleCompare("type",option+1) == 0)
5949 if (i == (ssize_t) argc)
5950 ThrowMogrifyException(OptionError,"MissingArgument",option);
5951 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5953 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5957 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5961 if (LocaleCompare("undercolor",option+1) == 0)
5966 if (i == (ssize_t) argc)
5967 ThrowMogrifyException(OptionError,"MissingArgument",option);
5970 if (LocaleCompare("unique-colors",option+1) == 0)
5972 if (LocaleCompare("units",option+1) == 0)
5980 if (i == (ssize_t) argc)
5981 ThrowMogrifyException(OptionError,"MissingArgument",option);
5982 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5985 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5989 if (LocaleCompare("unsharp",option+1) == 0)
5992 if (i == (ssize_t) argc)
5993 ThrowMogrifyException(OptionError,"MissingArgument",option);
5994 if (IsGeometry(argv[i]) == MagickFalse)
5995 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5998 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6002 if (LocaleCompare("verbose",option+1) == 0)
6004 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
6007 if ((LocaleCompare("version",option+1) == 0) ||
6008 (LocaleCompare("-version",option+1) == 0))
6010 (void) FormatLocaleFile(stdout,"Version: %s\n",
6011 GetMagickVersion((size_t *) NULL));
6012 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
6013 GetMagickCopyright());
6014 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
6015 GetMagickFeatures());
6018 if (LocaleCompare("view",option+1) == 0)
6023 if (i == (ssize_t) argc)
6024 ThrowMogrifyException(OptionError,"MissingArgument",option);
6027 if (LocaleCompare("vignette",option+1) == 0)
6032 if (i == (ssize_t) argc)
6033 ThrowMogrifyException(OptionError,"MissingArgument",option);
6034 if (IsGeometry(argv[i]) == MagickFalse)
6035 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6038 if (LocaleCompare("virtual-pixel",option+1) == 0)
6046 if (i == (ssize_t) argc)
6047 ThrowMogrifyException(OptionError,"MissingArgument",option);
6048 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
6051 ThrowMogrifyException(OptionError,
6052 "UnrecognizedVirtualPixelMethod",argv[i]);
6055 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6059 if (LocaleCompare("wave",option+1) == 0)
6062 if (i == (ssize_t) argc)
6063 ThrowMogrifyException(OptionError,"MissingArgument",option);
6064 if (IsGeometry(argv[i]) == MagickFalse)
6065 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6068 if (LocaleCompare("weight",option+1) == 0)
6073 if (i == (ssize_t) (argc-1))
6074 ThrowMogrifyException(OptionError,"MissingArgument",option);
6077 if (LocaleCompare("white-point",option+1) == 0)
6082 if (i == (ssize_t) argc)
6083 ThrowMogrifyException(OptionError,"MissingArgument",option);
6084 if (IsGeometry(argv[i]) == MagickFalse)
6085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6088 if (LocaleCompare("white-threshold",option+1) == 0)
6093 if (i == (ssize_t) argc)
6094 ThrowMogrifyException(OptionError,"MissingArgument",option);
6095 if (IsGeometry(argv[i]) == MagickFalse)
6096 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6099 if (LocaleCompare("write",option+1) == 0)
6102 if (i == (ssize_t) (argc-1))
6103 ThrowMogrifyException(OptionError,"MissingArgument",option);
6106 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6111 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6113 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6114 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6115 if (fire != MagickFalse)
6116 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6119 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6120 if (i != (ssize_t) argc)
6121 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6123 return(status != 0 ? MagickTrue : MagickFalse);
6127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6131 + M o g r i f y I m a g e I n f o %
6135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6137 % MogrifyImageInfo() applies image processing settings to the image as
6138 % prescribed by command line options.
6140 % The format of the MogrifyImageInfo method is:
6142 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6143 % const char **argv,ExceptionInfo *exception)
6145 % A description of each parameter follows:
6147 % o image_info: the image info..
6149 % o argc: Specifies a pointer to an integer describing the number of
6150 % elements in the argument vector.
6152 % o argv: Specifies a pointer to a text array containing the command line
6155 % o exception: return any errors or warnings in this structure.
6158 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6159 const int argc,const char **argv,ExceptionInfo *exception)
6174 Initialize method variables.
6176 assert(image_info != (ImageInfo *) NULL);
6177 assert(image_info->signature == MagickSignature);
6178 if (image_info->debug != MagickFalse)
6179 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6180 image_info->filename);
6184 Set the image settings.
6186 for (i=0; i < (ssize_t) argc; i++)
6189 if (IsCommandOption(option) == MagickFalse)
6191 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6192 count=MagickMax(count,0L);
6193 if ((i+count) >= (ssize_t) argc)
6195 switch (*(option+1))
6199 if (LocaleCompare("adjoin",option+1) == 0)
6201 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6204 if (LocaleCompare("antialias",option+1) == 0)
6206 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6209 if (LocaleCompare("authenticate",option+1) == 0)
6212 (void) DeleteImageOption(image_info,option+1);
6214 (void) SetImageOption(image_info,option+1,argv[i+1]);
6221 if (LocaleCompare("background",option+1) == 0)
6225 (void) DeleteImageOption(image_info,option+1);
6226 (void) QueryColorCompliance(MogrifyBackgroundColor,
6227 AllCompliance,&image_info->background_color,exception);
6230 (void) SetImageOption(image_info,option+1,argv[i+1]);
6231 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6232 &image_info->background_color,exception);
6235 if (LocaleCompare("bias",option+1) == 0)
6239 (void) SetImageOption(image_info,option+1,"0.0");
6242 (void) SetImageOption(image_info,option+1,argv[i+1]);
6245 if (LocaleCompare("black-point-compensation",option+1) == 0)
6249 (void) SetImageOption(image_info,option+1,"false");
6252 (void) SetImageOption(image_info,option+1,"true");
6255 if (LocaleCompare("blue-primary",option+1) == 0)
6259 (void) SetImageOption(image_info,option+1,"0.0");
6262 (void) SetImageOption(image_info,option+1,argv[i+1]);
6265 if (LocaleCompare("bordercolor",option+1) == 0)
6269 (void) DeleteImageOption(image_info,option+1);
6270 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
6271 &image_info->border_color,exception);
6274 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6275 &image_info->border_color,exception);
6276 (void) SetImageOption(image_info,option+1,argv[i+1]);
6279 if (LocaleCompare("box",option+1) == 0)
6283 (void) SetImageOption(image_info,"undercolor","none");
6286 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6293 if (LocaleCompare("cache",option+1) == 0)
6298 limit=MagickResourceInfinity;
6299 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6300 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1],
6302 (void) SetMagickResourceLimit(MemoryResource,limit);
6303 (void) SetMagickResourceLimit(MapResource,2*limit);
6306 if (LocaleCompare("caption",option+1) == 0)
6310 (void) DeleteImageOption(image_info,option+1);
6313 (void) SetImageOption(image_info,option+1,argv[i+1]);
6316 if (LocaleCompare("channel",option+1) == 0)
6320 image_info->channel=DefaultChannels;
6323 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6326 if (LocaleCompare("colorspace",option+1) == 0)
6330 image_info->colorspace=UndefinedColorspace;
6331 (void) SetImageOption(image_info,option+1,"undefined");
6334 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6335 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6336 (void) SetImageOption(image_info,option+1,argv[i+1]);
6339 if (LocaleCompare("comment",option+1) == 0)
6343 (void) DeleteImageOption(image_info,option+1);
6346 (void) SetImageOption(image_info,option+1,argv[i+1]);
6349 if (LocaleCompare("compose",option+1) == 0)
6353 (void) SetImageOption(image_info,option+1,"undefined");
6356 (void) SetImageOption(image_info,option+1,argv[i+1]);
6359 if (LocaleCompare("compress",option+1) == 0)
6363 image_info->compression=UndefinedCompression;
6364 (void) SetImageOption(image_info,option+1,"undefined");
6367 image_info->compression=(CompressionType) ParseCommandOption(
6368 MagickCompressOptions,MagickFalse,argv[i+1]);
6369 (void) SetImageOption(image_info,option+1,argv[i+1]);
6376 if (LocaleCompare("debug",option+1) == 0)
6379 (void) SetLogEventMask("none");
6381 (void) SetLogEventMask(argv[i+1]);
6382 image_info->debug=IsEventLogging();
6385 if (LocaleCompare("define",option+1) == 0)
6389 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6390 (void) DeleteImageRegistry(argv[i+1]+9);
6392 (void) DeleteImageOption(image_info,argv[i+1]);
6395 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6397 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6401 (void) DefineImageOption(image_info,argv[i+1]);
6404 if (LocaleCompare("delay",option+1) == 0)
6408 (void) SetImageOption(image_info,option+1,"0");
6411 (void) SetImageOption(image_info,option+1,argv[i+1]);
6414 if (LocaleCompare("density",option+1) == 0)
6421 if (image_info->density != (char *) NULL)
6422 image_info->density=DestroyString(image_info->density);
6423 (void) SetImageOption(image_info,option+1,"72");
6426 (void) CloneString(&image_info->density,argv[i+1]);
6427 (void) SetImageOption(image_info,option+1,argv[i+1]);
6430 if (LocaleCompare("depth",option+1) == 0)
6434 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6437 image_info->depth=StringToUnsignedLong(argv[i+1]);
6440 if (LocaleCompare("direction",option+1) == 0)
6444 (void) SetImageOption(image_info,option+1,"undefined");
6447 (void) SetImageOption(image_info,option+1,argv[i+1]);
6450 if (LocaleCompare("display",option+1) == 0)
6454 if (image_info->server_name != (char *) NULL)
6455 image_info->server_name=DestroyString(
6456 image_info->server_name);
6459 (void) CloneString(&image_info->server_name,argv[i+1]);
6462 if (LocaleCompare("dispose",option+1) == 0)
6466 (void) SetImageOption(image_info,option+1,"undefined");
6469 (void) SetImageOption(image_info,option+1,argv[i+1]);
6472 if (LocaleCompare("dither",option+1) == 0)
6476 image_info->dither=MagickFalse;
6477 (void) SetImageOption(image_info,option+1,"none");
6480 (void) SetImageOption(image_info,option+1,argv[i+1]);
6481 image_info->dither=MagickTrue;
6488 if (LocaleCompare("encoding",option+1) == 0)
6492 (void) SetImageOption(image_info,option+1,"undefined");
6495 (void) SetImageOption(image_info,option+1,argv[i+1]);
6498 if (LocaleCompare("endian",option+1) == 0)
6502 image_info->endian=UndefinedEndian;
6503 (void) SetImageOption(image_info,option+1,"undefined");
6506 image_info->endian=(EndianType) ParseCommandOption(
6507 MagickEndianOptions,MagickFalse,argv[i+1]);
6508 (void) SetImageOption(image_info,option+1,argv[i+1]);
6511 if (LocaleCompare("extract",option+1) == 0)
6514 Set image extract geometry.
6518 if (image_info->extract != (char *) NULL)
6519 image_info->extract=DestroyString(image_info->extract);
6522 (void) CloneString(&image_info->extract,argv[i+1]);
6529 if (LocaleCompare("fill",option+1) == 0)
6533 (void) SetImageOption(image_info,option+1,"none");
6536 (void) SetImageOption(image_info,option+1,argv[i+1]);
6539 if (LocaleCompare("filter",option+1) == 0)
6543 (void) SetImageOption(image_info,option+1,"undefined");
6546 (void) SetImageOption(image_info,option+1,argv[i+1]);
6549 if (LocaleCompare("font",option+1) == 0)
6553 if (image_info->font != (char *) NULL)
6554 image_info->font=DestroyString(image_info->font);
6557 (void) CloneString(&image_info->font,argv[i+1]);
6560 if (LocaleCompare("format",option+1) == 0)
6565 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6566 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6567 image_info->ping=MagickFalse;
6568 (void) SetImageOption(image_info,option+1,argv[i+1]);
6571 if (LocaleCompare("fuzz",option+1) == 0)
6575 image_info->fuzz=0.0;
6576 (void) SetImageOption(image_info,option+1,"0");
6579 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double)
6581 (void) SetImageOption(image_info,option+1,argv[i+1]);
6588 if (LocaleCompare("gravity",option+1) == 0)
6592 (void) SetImageOption(image_info,option+1,"undefined");
6595 (void) SetImageOption(image_info,option+1,argv[i+1]);
6598 if (LocaleCompare("green-primary",option+1) == 0)
6602 (void) SetImageOption(image_info,option+1,"0.0");
6605 (void) SetImageOption(image_info,option+1,argv[i+1]);
6612 if (LocaleCompare("intent",option+1) == 0)
6616 (void) SetImageOption(image_info,option+1,"undefined");
6619 (void) SetImageOption(image_info,option+1,argv[i+1]);
6622 if (LocaleCompare("interlace",option+1) == 0)
6626 image_info->interlace=UndefinedInterlace;
6627 (void) SetImageOption(image_info,option+1,"undefined");
6630 image_info->interlace=(InterlaceType) ParseCommandOption(
6631 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6632 (void) SetImageOption(image_info,option+1,argv[i+1]);
6635 if (LocaleCompare("interline-spacing",option+1) == 0)
6639 (void) SetImageOption(image_info,option+1,"undefined");
6642 (void) SetImageOption(image_info,option+1,argv[i+1]);
6645 if (LocaleCompare("interpolate",option+1) == 0)
6649 (void) SetImageOption(image_info,option+1,"undefined");
6652 (void) SetImageOption(image_info,option+1,argv[i+1]);
6655 if (LocaleCompare("interword-spacing",option+1) == 0)
6659 (void) SetImageOption(image_info,option+1,"undefined");
6662 (void) SetImageOption(image_info,option+1,argv[i+1]);
6669 if (LocaleCompare("kerning",option+1) == 0)
6673 (void) SetImageOption(image_info,option+1,"undefined");
6676 (void) SetImageOption(image_info,option+1,argv[i+1]);
6683 if (LocaleCompare("label",option+1) == 0)
6687 (void) DeleteImageOption(image_info,option+1);
6690 (void) SetImageOption(image_info,option+1,argv[i+1]);
6693 if (LocaleCompare("limit",option+1) == 0)
6703 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6704 MagickFalse,argv[i+1]);
6705 limit=MagickResourceInfinity;
6706 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6707 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0);
6708 (void) SetMagickResourceLimit(type,limit);
6711 if (LocaleCompare("list",option+1) == 0)
6717 Display configuration list.
6719 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6722 case MagickCoderOptions:
6724 (void) ListCoderInfo((FILE *) NULL,exception);
6727 case MagickColorOptions:
6729 (void) ListColorInfo((FILE *) NULL,exception);
6732 case MagickConfigureOptions:
6734 (void) ListConfigureInfo((FILE *) NULL,exception);
6737 case MagickDelegateOptions:
6739 (void) ListDelegateInfo((FILE *) NULL,exception);
6742 case MagickFontOptions:
6744 (void) ListTypeInfo((FILE *) NULL,exception);
6747 case MagickFormatOptions:
6749 (void) ListMagickInfo((FILE *) NULL,exception);
6752 case MagickLocaleOptions:
6754 (void) ListLocaleInfo((FILE *) NULL,exception);
6757 case MagickLogOptions:
6759 (void) ListLogInfo((FILE *) NULL,exception);
6762 case MagickMagicOptions:
6764 (void) ListMagicInfo((FILE *) NULL,exception);
6767 case MagickMimeOptions:
6769 (void) ListMimeInfo((FILE *) NULL,exception);
6772 case MagickModuleOptions:
6774 (void) ListModuleInfo((FILE *) NULL,exception);
6777 case MagickPolicyOptions:
6779 (void) ListPolicyInfo((FILE *) NULL,exception);
6782 case MagickResourceOptions:
6784 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6787 case MagickThresholdOptions:
6789 (void) ListThresholdMaps((FILE *) NULL,exception);
6794 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6801 if (LocaleCompare("log",option+1) == 0)
6805 (void) SetLogFormat(argv[i+1]);
6808 if (LocaleCompare("loop",option+1) == 0)
6812 (void) SetImageOption(image_info,option+1,"0");
6815 (void) SetImageOption(image_info,option+1,argv[i+1]);
6822 if (LocaleCompare("matte",option+1) == 0)
6826 (void) SetImageOption(image_info,option+1,"false");
6829 (void) SetImageOption(image_info,option+1,"true");
6832 if (LocaleCompare("mattecolor",option+1) == 0)
6836 (void) SetImageOption(image_info,option+1,argv[i+1]);
6837 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance,
6838 &image_info->matte_color,exception);
6841 (void) SetImageOption(image_info,option+1,argv[i+1]);
6842 (void) QueryColorCompliance(argv[i+1],AllCompliance,
6843 &image_info->matte_color,exception);
6846 if (LocaleCompare("monitor",option+1) == 0)
6848 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6852 if (LocaleCompare("monochrome",option+1) == 0)
6854 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6861 if (LocaleCompare("orient",option+1) == 0)
6865 image_info->orientation=UndefinedOrientation;
6866 (void) SetImageOption(image_info,option+1,"undefined");
6869 image_info->orientation=(OrientationType) ParseCommandOption(
6870 MagickOrientationOptions,MagickFalse,argv[i+1]);
6871 (void) SetImageOption(image_info,option+1,argv[i+1]);
6877 if (LocaleCompare("page",option+1) == 0)
6881 page[MaxTextExtent];
6894 (void) DeleteImageOption(image_info,option+1);
6895 (void) CloneString(&image_info->page,(char *) NULL);
6898 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6899 image_option=GetImageOption(image_info,"page");
6900 if (image_option != (const char *) NULL)
6901 flags=ParseAbsoluteGeometry(image_option,&geometry);
6902 canonical_page=GetPageGeometry(argv[i+1]);
6903 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6904 canonical_page=DestroyString(canonical_page);
6905 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6906 (unsigned long) geometry.width,(unsigned long) geometry.height);
6907 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6908 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6909 (unsigned long) geometry.width,(unsigned long) geometry.height,
6910 (long) geometry.x,(long) geometry.y);
6911 (void) SetImageOption(image_info,option+1,page);
6912 (void) CloneString(&image_info->page,page);
6915 if (LocaleCompare("pen",option+1) == 0)
6919 (void) SetImageOption(image_info,option+1,"none");
6922 (void) SetImageOption(image_info,option+1,argv[i+1]);
6925 if (LocaleCompare("ping",option+1) == 0)
6927 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6930 if (LocaleCompare("pointsize",option+1) == 0)
6933 geometry_info.rho=0.0;
6935 (void) ParseGeometry(argv[i+1],&geometry_info);
6936 image_info->pointsize=geometry_info.rho;
6939 if (LocaleCompare("precision",option+1) == 0)
6941 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6944 if (LocaleCompare("preview",option+1) == 0)
6951 image_info->preview_type=UndefinedPreview;
6954 image_info->preview_type=(PreviewType) ParseCommandOption(
6955 MagickPreviewOptions,MagickFalse,argv[i+1]);
6962 if (LocaleCompare("quality",option+1) == 0)
6965 Set image compression quality.
6969 image_info->quality=UndefinedCompressionQuality;
6970 (void) SetImageOption(image_info,option+1,"0");
6973 image_info->quality=StringToUnsignedLong(argv[i+1]);
6974 (void) SetImageOption(image_info,option+1,argv[i+1]);
6977 if (LocaleCompare("quiet",option+1) == 0)
6979 static WarningHandler
6980 warning_handler = (WarningHandler) NULL;
6985 Restore error or warning messages.
6987 warning_handler=SetWarningHandler(warning_handler);
6991 Suppress error or warning messages.
6993 warning_handler=SetWarningHandler((WarningHandler) NULL);
7000 if (LocaleCompare("red-primary",option+1) == 0)
7004 (void) SetImageOption(image_info,option+1,"0.0");
7007 (void) SetImageOption(image_info,option+1,argv[i+1]);
7014 if (LocaleCompare("sampling-factor",option+1) == 0)
7017 Set image sampling factor.
7021 if (image_info->sampling_factor != (char *) NULL)
7022 image_info->sampling_factor=DestroyString(
7023 image_info->sampling_factor);
7026 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
7029 if (LocaleCompare("scene",option+1) == 0)
7036 image_info->scene=0;
7037 (void) SetImageOption(image_info,option+1,"0");
7040 image_info->scene=StringToUnsignedLong(argv[i+1]);
7041 (void) SetImageOption(image_info,option+1,argv[i+1]);
7044 if (LocaleCompare("seed",option+1) == 0)
7051 seed=(size_t) time((time_t *) NULL);
7052 SeedPseudoRandomGenerator(seed);
7055 seed=StringToUnsignedLong(argv[i+1]);
7056 SeedPseudoRandomGenerator(seed);
7059 if (LocaleCompare("size",option+1) == 0)
7063 if (image_info->size != (char *) NULL)
7064 image_info->size=DestroyString(image_info->size);
7067 (void) CloneString(&image_info->size,argv[i+1]);
7070 if (LocaleCompare("stroke",option+1) == 0)
7074 (void) SetImageOption(image_info,option+1,"none");
7077 (void) SetImageOption(image_info,option+1,argv[i+1]);
7080 if (LocaleCompare("strokewidth",option+1) == 0)
7084 (void) SetImageOption(image_info,option+1,"0");
7087 (void) SetImageOption(image_info,option+1,argv[i+1]);
7090 if (LocaleCompare("synchronize",option+1) == 0)
7094 image_info->synchronize=MagickFalse;
7097 image_info->synchronize=MagickTrue;
7104 if (LocaleCompare("taint",option+1) == 0)
7108 (void) SetImageOption(image_info,option+1,"false");
7111 (void) SetImageOption(image_info,option+1,"true");
7114 if (LocaleCompare("texture",option+1) == 0)
7118 if (image_info->texture != (char *) NULL)
7119 image_info->texture=DestroyString(image_info->texture);
7122 (void) CloneString(&image_info->texture,argv[i+1]);
7125 if (LocaleCompare("tile-offset",option+1) == 0)
7129 (void) SetImageOption(image_info,option+1,"0");
7132 (void) SetImageOption(image_info,option+1,argv[i+1]);
7135 if (LocaleCompare("transparent-color",option+1) == 0)
7139 (void) QueryColorCompliance("none",AllCompliance,
7140 &image_info->transparent_color,exception);
7141 (void) SetImageOption(image_info,option+1,"none");
7144 (void) QueryColorCompliance(argv[i+1],AllCompliance,
7145 &image_info->transparent_color,exception);
7146 (void) SetImageOption(image_info,option+1,argv[i+1]);
7149 if (LocaleCompare("type",option+1) == 0)
7153 image_info->type=UndefinedType;
7154 (void) SetImageOption(image_info,option+1,"undefined");
7157 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7158 MagickFalse,argv[i+1]);
7159 (void) SetImageOption(image_info,option+1,argv[i+1]);
7166 if (LocaleCompare("undercolor",option+1) == 0)
7170 (void) DeleteImageOption(image_info,option+1);
7173 (void) SetImageOption(image_info,option+1,argv[i+1]);
7176 if (LocaleCompare("units",option+1) == 0)
7180 image_info->units=UndefinedResolution;
7181 (void) SetImageOption(image_info,option+1,"undefined");
7184 image_info->units=(ResolutionType) ParseCommandOption(
7185 MagickResolutionOptions,MagickFalse,argv[i+1]);
7186 (void) SetImageOption(image_info,option+1,argv[i+1]);
7193 if (LocaleCompare("verbose",option+1) == 0)
7197 image_info->verbose=MagickFalse;
7200 image_info->verbose=MagickTrue;
7201 image_info->ping=MagickFalse;
7204 if (LocaleCompare("view",option+1) == 0)
7208 if (image_info->view != (char *) NULL)
7209 image_info->view=DestroyString(image_info->view);
7212 (void) CloneString(&image_info->view,argv[i+1]);
7215 if (LocaleCompare("virtual-pixel",option+1) == 0)
7219 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7220 (void) SetImageOption(image_info,option+1,"undefined");
7223 image_info->virtual_pixel_method=(VirtualPixelMethod)
7224 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7226 (void) SetImageOption(image_info,option+1,argv[i+1]);
7233 if (LocaleCompare("white-point",option+1) == 0)
7237 (void) SetImageOption(image_info,option+1,"0.0");
7240 (void) SetImageOption(image_info,option+1,argv[i+1]);
7254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7258 + M o g r i f y I m a g e L i s t %
7262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7264 % MogrifyImageList() applies any command line options that might affect the
7265 % entire image list (e.g. -append, -coalesce, etc.).
7267 % The format of the MogrifyImage method is:
7269 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7270 % const char **argv,Image **images,ExceptionInfo *exception)
7272 % A description of each parameter follows:
7274 % o image_info: the image info..
7276 % o argc: Specifies a pointer to an integer describing the number of
7277 % elements in the argument vector.
7279 % o argv: Specifies a pointer to a text array containing the command line
7282 % o images: pointer to pointer of the first image in image list.
7284 % o exception: return any errors or warnings in this structure.
7287 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7288 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7299 PixelInterpolateMethod
7313 Apply options to the image list.
7315 assert(image_info != (ImageInfo *) NULL);
7316 assert(image_info->signature == MagickSignature);
7317 assert(images != (Image **) NULL);
7318 assert((*images)->previous == (Image *) NULL);
7319 assert((*images)->signature == MagickSignature);
7320 if ((*images)->debug != MagickFalse)
7321 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7322 (*images)->filename);
7323 if ((argc <= 0) || (*argv == (char *) NULL))
7325 interpolate_method=UndefinedInterpolatePixel;
7326 mogrify_info=CloneImageInfo(image_info);
7327 quantize_info=AcquireQuantizeInfo(mogrify_info);
7329 for (i=0; i < (ssize_t) argc; i++)
7331 if (*images == (Image *) NULL)
7334 if (IsCommandOption(option) == MagickFalse)
7336 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7337 count=MagickMax(count,0L);
7338 if ((i+count) >= (ssize_t) argc)
7340 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7341 switch (*(option+1))
7345 if (LocaleCompare("affinity",option+1) == 0)
7347 (void) SyncImagesSettings(mogrify_info,*images,exception);
7350 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7357 if (LocaleCompare("append",option+1) == 0)
7362 (void) SyncImagesSettings(mogrify_info,*images,exception);
7363 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7364 MagickFalse,exception);
7365 if (append_image == (Image *) NULL)
7370 *images=DestroyImageList(*images);
7371 *images=append_image;
7374 if (LocaleCompare("average",option+1) == 0)
7380 Average an image sequence (deprecated).
7382 (void) SyncImagesSettings(mogrify_info,*images,exception);
7383 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7385 if (average_image == (Image *) NULL)
7390 *images=DestroyImageList(*images);
7391 *images=average_image;
7398 if (LocaleCompare("channel",option+1) == 0)
7405 channel=DefaultChannels;
7408 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7409 SetPixelChannelMapMask(*images,channel);
7412 if (LocaleCompare("clut",option+1) == 0)
7418 (void) SyncImagesSettings(mogrify_info,*images,exception);
7419 image=RemoveFirstImageFromList(images);
7420 clut_image=RemoveFirstImageFromList(images);
7421 if (clut_image == (Image *) NULL)
7426 (void) ClutImage(image,clut_image,interpolate_method,exception);
7427 clut_image=DestroyImage(clut_image);
7428 *images=DestroyImageList(*images);
7432 if (LocaleCompare("coalesce",option+1) == 0)
7437 (void) SyncImagesSettings(mogrify_info,*images,exception);
7438 coalesce_image=CoalesceImages(*images,exception);
7439 if (coalesce_image == (Image *) NULL)
7444 *images=DestroyImageList(*images);
7445 *images=coalesce_image;
7448 if (LocaleCompare("combine",option+1) == 0)
7453 (void) SyncImagesSettings(mogrify_info,*images,exception);
7454 combine_image=CombineImages(*images,exception);
7455 if (combine_image == (Image *) NULL)
7460 *images=DestroyImageList(*images);
7461 *images=combine_image;
7464 if (LocaleCompare("composite",option+1) == 0)
7474 (void) SyncImagesSettings(mogrify_info,*images,exception);
7475 image=RemoveFirstImageFromList(images);
7476 composite_image=RemoveFirstImageFromList(images);
7477 if (composite_image == (Image *) NULL)
7482 (void) TransformImage(&composite_image,(char *) NULL,
7483 composite_image->geometry,exception);
7484 SetGeometry(composite_image,&geometry);
7485 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7486 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7488 mask_image=RemoveFirstImageFromList(images);
7489 if (mask_image != (Image *) NULL)
7491 if ((image->compose == DisplaceCompositeOp) ||
7492 (image->compose == DistortCompositeOp))
7495 Merge Y displacement into X displacement image.
7497 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7498 mask_image,0,0,exception);
7499 mask_image=DestroyImage(mask_image);
7504 Set a blending mask for the composition.
7505 Posible error, what if image->mask already set.
7507 image->mask=mask_image;
7508 (void) NegateImage(image->mask,MagickFalse,exception);
7511 (void) CompositeImage(image,image->compose,composite_image,
7512 geometry.x,geometry.y,exception);
7513 if (mask_image != (Image *) NULL)
7514 mask_image=image->mask=DestroyImage(image->mask);
7515 composite_image=DestroyImage(composite_image);
7516 *images=DestroyImageList(*images);
7524 if (LocaleCompare("deconstruct",option+1) == 0)
7529 (void) SyncImagesSettings(mogrify_info,*images,exception);
7530 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7532 if (deconstruct_image == (Image *) NULL)
7537 *images=DestroyImageList(*images);
7538 *images=deconstruct_image;
7541 if (LocaleCompare("delete",option+1) == 0)
7544 DeleteImages(images,"-1",exception);
7546 DeleteImages(images,argv[i+1],exception);
7549 if (LocaleCompare("dither",option+1) == 0)
7553 quantize_info->dither=MagickFalse;
7556 quantize_info->dither=MagickTrue;
7557 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7558 MagickDitherOptions,MagickFalse,argv[i+1]);
7561 if (LocaleCompare("duplicate",option+1) == 0)
7567 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7576 number_duplicates=(size_t) StringToLong(argv[i+1]);
7577 p=strchr(argv[i+1],',');
7578 if (p == (const char *) NULL)
7579 duplicate_images=DuplicateImages(*images,number_duplicates,
7582 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7585 AppendImageToList(images, duplicate_images);
7586 (void) SyncImagesSettings(mogrify_info,*images,exception);
7593 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7598 MagickEvaluateOperator
7601 (void) SyncImageSettings(mogrify_info,*images,exception);
7602 op=(MagickEvaluateOperator) ParseCommandOption(
7603 MagickEvaluateOptions,MagickFalse,argv[i+1]);
7604 evaluate_image=EvaluateImages(*images,op,exception);
7605 if (evaluate_image == (Image *) NULL)
7610 *images=DestroyImageList(*images);
7611 *images=evaluate_image;
7618 if (LocaleCompare("fft",option+1) == 0)
7624 Implements the discrete Fourier transform (DFT).
7626 (void) SyncImageSettings(mogrify_info,*images,exception);
7627 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7628 MagickTrue : MagickFalse,exception);
7629 if (fourier_image == (Image *) NULL)
7631 *images=DestroyImage(*images);
7632 *images=fourier_image;
7635 if (LocaleCompare("flatten",option+1) == 0)
7640 (void) SyncImagesSettings(mogrify_info,*images,exception);
7641 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7642 if (flatten_image == (Image *) NULL)
7644 *images=DestroyImageList(*images);
7645 *images=flatten_image;
7648 if (LocaleCompare("fx",option+1) == 0)
7653 (void) SyncImagesSettings(mogrify_info,*images,exception);
7654 fx_image=FxImage(*images,argv[i+1],exception);
7655 if (fx_image == (Image *) NULL)
7660 *images=DestroyImageList(*images);
7668 if (LocaleCompare("hald-clut",option+1) == 0)
7674 (void) SyncImagesSettings(mogrify_info,*images,exception);
7675 image=RemoveFirstImageFromList(images);
7676 hald_image=RemoveFirstImageFromList(images);
7677 if (hald_image == (Image *) NULL)
7682 (void) HaldClutImage(image,hald_image,exception);
7683 hald_image=DestroyImage(hald_image);
7684 if (*images != (Image *) NULL)
7685 *images=DestroyImageList(*images);
7693 if (LocaleCompare("ift",option+1) == 0)
7701 Implements the inverse fourier discrete Fourier transform (DFT).
7703 (void) SyncImagesSettings(mogrify_info,*images,exception);
7704 magnitude_image=RemoveFirstImageFromList(images);
7705 phase_image=RemoveFirstImageFromList(images);
7706 if (phase_image == (Image *) NULL)
7711 fourier_image=InverseFourierTransformImage(magnitude_image,
7712 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7713 if (fourier_image == (Image *) NULL)
7715 if (*images != (Image *) NULL)
7716 *images=DestroyImage(*images);
7717 *images=fourier_image;
7720 if (LocaleCompare("insert",option+1) == 0)
7728 index=(ssize_t) StringToLong(argv[i+1]);
7729 p=RemoveLastImageFromList(images);
7730 if (p == (Image *) NULL)
7732 (void) ThrowMagickException(exception,GetMagickModule(),
7733 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7739 PrependImageToList(images,q);
7741 if (index == (ssize_t) GetImageListLength(*images))
7742 AppendImageToList(images,q);
7745 q=GetImageFromList(*images,index-1);
7746 if (q == (Image *) NULL)
7748 (void) ThrowMagickException(exception,GetMagickModule(),
7749 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7753 InsertImageInList(&q,p);
7755 *images=GetFirstImageInList(q);
7758 if (LocaleCompare("interpolate",option+1) == 0)
7760 interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
7761 MagickInterpolateOptions,MagickFalse,argv[i+1]);
7768 if (LocaleCompare("layers",option+1) == 0)
7776 (void) SyncImagesSettings(mogrify_info,*images,exception);
7777 layers=(Image *) NULL;
7778 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7779 MagickFalse,argv[i+1]);
7784 layers=CoalesceImages(*images,exception);
7787 case CompareAnyLayer:
7788 case CompareClearLayer:
7789 case CompareOverlayLayer:
7792 layers=CompareImagesLayers(*images,method,exception);
7798 case TrimBoundsLayer:
7800 layers=MergeImageLayers(*images,method,exception);
7805 layers=DisposeImages(*images,exception);
7808 case OptimizeImageLayer:
7810 layers=OptimizeImageLayers(*images,exception);
7813 case OptimizePlusLayer:
7815 layers=OptimizePlusImageLayers(*images,exception);
7818 case OptimizeTransLayer:
7820 OptimizeImageTransparency(*images,exception);
7823 case RemoveDupsLayer:
7825 RemoveDuplicateLayers(images,exception);
7828 case RemoveZeroLayer:
7830 RemoveZeroDelayLayers(images,exception);
7836 General Purpose, GIF Animation Optimizer.
7838 layers=CoalesceImages(*images,exception);
7839 if (layers == (Image *) NULL)
7844 *images=DestroyImageList(*images);
7846 layers=OptimizeImageLayers(*images,exception);
7847 if (layers == (Image *) NULL)
7852 *images=DestroyImageList(*images);
7854 layers=(Image *) NULL;
7855 OptimizeImageTransparency(*images,exception);
7856 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7860 case CompositeLayer:
7872 Split image sequence at the first 'NULL:' image.
7875 while (source != (Image *) NULL)
7877 source=GetNextImageInList(source);
7878 if ((source != (Image *) NULL) &&
7879 (LocaleCompare(source->magick,"NULL") == 0))
7882 if (source != (Image *) NULL)
7884 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7885 (GetNextImageInList(source) == (Image *) NULL))
7886 source=(Image *) NULL;
7890 Separate the two lists, junk the null: image.
7892 source=SplitImageList(source->previous);
7893 DeleteImageFromList(&source);
7896 if (source == (Image *) NULL)
7898 (void) ThrowMagickException(exception,GetMagickModule(),
7899 OptionError,"MissingNullSeparator","layers Composite");
7904 Adjust offset with gravity and virtual canvas.
7906 SetGeometry(*images,&geometry);
7907 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7908 geometry.width=source->page.width != 0 ?
7909 source->page.width : source->columns;
7910 geometry.height=source->page.height != 0 ?
7911 source->page.height : source->rows;
7912 GravityAdjustGeometry((*images)->page.width != 0 ?
7913 (*images)->page.width : (*images)->columns,
7914 (*images)->page.height != 0 ? (*images)->page.height :
7915 (*images)->rows,(*images)->gravity,&geometry);
7916 compose=OverCompositeOp;
7917 option=GetImageOption(mogrify_info,"compose");
7918 if (option != (const char *) NULL)
7919 compose=(CompositeOperator) ParseCommandOption(
7920 MagickComposeOptions,MagickFalse,option);
7921 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7923 source=DestroyImageList(source);
7927 if (layers == (Image *) NULL)
7929 *images=DestroyImageList(*images);
7937 if (LocaleCompare("map",option+1) == 0)
7939 (void) SyncImagesSettings(mogrify_info,*images,exception);
7942 (void) RemapImages(quantize_info,*images,(Image *) NULL,
7949 if (LocaleCompare("maximum",option+1) == 0)
7955 Maximum image sequence (deprecated).
7957 (void) SyncImagesSettings(mogrify_info,*images,exception);
7958 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7959 if (maximum_image == (Image *) NULL)
7964 *images=DestroyImageList(*images);
7965 *images=maximum_image;
7968 if (LocaleCompare("minimum",option+1) == 0)
7974 Minimum image sequence (deprecated).
7976 (void) SyncImagesSettings(mogrify_info,*images,exception);
7977 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7978 if (minimum_image == (Image *) NULL)
7983 *images=DestroyImageList(*images);
7984 *images=minimum_image;
7987 if (LocaleCompare("morph",option+1) == 0)
7992 (void) SyncImagesSettings(mogrify_info,*images,exception);
7993 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7995 if (morph_image == (Image *) NULL)
8000 *images=DestroyImageList(*images);
8001 *images=morph_image;
8004 if (LocaleCompare("mosaic",option+1) == 0)
8009 (void) SyncImagesSettings(mogrify_info,*images,exception);
8010 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
8011 if (mosaic_image == (Image *) NULL)
8016 *images=DestroyImageList(*images);
8017 *images=mosaic_image;
8024 if (LocaleCompare("print",option+1) == 0)
8029 (void) SyncImagesSettings(mogrify_info,*images,exception);
8030 string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
8032 if (string == (char *) NULL)
8034 (void) FormatLocaleFile(stdout,"%s",string);
8035 string=DestroyString(string);
8037 if (LocaleCompare("process",option+1) == 0)
8046 (void) SyncImagesSettings(mogrify_info,*images,exception);
8047 arguments=StringToArgv(argv[i+1],&number_arguments);
8048 if (arguments == (char **) NULL)
8050 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8071 Support old style syntax, filter="-option arg".
8073 length=strlen(argv[i+1]);
8074 token=(char *) NULL;
8075 if (~length >= (MaxTextExtent-1))
8076 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8078 if (token == (char *) NULL)
8081 arguments=argv[i+1];
8082 token_info=AcquireTokenInfo();
8083 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8084 "\"",'\0',&breaker,&next,"e);
8085 token_info=DestroyTokenInfo(token_info);
8091 argv=(&(arguments[next]));
8092 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8095 token=DestroyString(token);
8098 (void) SubstituteString(&arguments[1],"-","");
8099 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8100 number_arguments-2,(const char **) arguments+2,exception);
8101 for (j=0; j < number_arguments; j++)
8102 arguments[j]=DestroyString(arguments[j]);
8103 arguments=(char **) RelinquishMagickMemory(arguments);
8110 if (LocaleCompare("reverse",option+1) == 0)
8112 ReverseImageList(images);
8119 if (LocaleCompare("smush",option+1) == 0)
8127 (void) SyncImagesSettings(mogrify_info,*images,exception);
8128 offset=(ssize_t) StringToLong(argv[i+1]);
8129 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8130 MagickFalse,offset,exception);
8131 if (smush_image == (Image *) NULL)
8136 *images=DestroyImageList(*images);
8137 *images=smush_image;
8140 if (LocaleCompare("swap",option+1) == 0)
8161 flags=ParseGeometry(argv[i+1],&geometry_info);
8162 index=(ssize_t) geometry_info.rho;
8163 if ((flags & SigmaValue) != 0)
8164 swap_index=(ssize_t) geometry_info.sigma;
8166 p=GetImageFromList(*images,index);
8167 q=GetImageFromList(*images,swap_index);
8168 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8170 (void) ThrowMagickException(exception,GetMagickModule(),
8171 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8177 swap=CloneImage(p,0,0,MagickTrue,exception);
8178 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8179 ReplaceImageInList(&q,swap);
8180 *images=GetFirstImageInList(q);
8187 if (LocaleCompare("write",option+1) == 0)
8198 (void) SyncImagesSettings(mogrify_info,*images,exception);
8199 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8200 (void) DeleteImageRegistry(key);
8201 write_images=(*images);
8203 write_images=CloneImageList(*images,exception);
8204 write_info=CloneImageInfo(mogrify_info);
8205 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8206 write_info=DestroyImageInfo(write_info);
8208 write_images=DestroyImageList(write_images);
8218 quantize_info=DestroyQuantizeInfo(quantize_info);
8219 mogrify_info=DestroyImageInfo(mogrify_info);
8220 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8221 return(status != 0 ? MagickTrue : MagickFalse);
8225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8229 + M o g r i f y I m a g e s %
8233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8235 % MogrifyImages() applies image processing options to a sequence of images as
8236 % prescribed by command line options.
8238 % The format of the MogrifyImage method is:
8240 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8241 % const MagickBooleanType post,const int argc,const char **argv,
8242 % Image **images,Exceptioninfo *exception)
8244 % A description of each parameter follows:
8246 % o image_info: the image info..
8248 % o post: If true, post process image list operators otherwise pre-process.
8250 % o argc: Specifies a pointer to an integer describing the number of
8251 % elements in the argument vector.
8253 % o argv: Specifies a pointer to a text array containing the command line
8256 % o images: pointer to a pointer of the first image in image list.
8258 % o exception: return any errors or warnings in this structure.
8261 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8262 const MagickBooleanType post,const int argc,const char **argv,
8263 Image **images,ExceptionInfo *exception)
8265 #define MogrifyImageTag "Mogrify/Image"
8279 assert(image_info != (ImageInfo *) NULL);
8280 assert(image_info->signature == MagickSignature);
8281 if (images == (Image **) NULL)
8282 return(MogrifyImage(image_info,argc,argv,images,exception));
8283 assert((*images)->previous == (Image *) NULL);
8284 assert((*images)->signature == MagickSignature);
8285 if ((*images)->debug != MagickFalse)
8286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8287 (*images)->filename);
8288 if ((argc <= 0) || (*argv == (char *) NULL))
8290 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8295 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8300 Pre-process multi-image sequence operators
8302 if (post == MagickFalse)
8303 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8305 For each image, process simple single image operators
8308 n=GetImageListLength(*images);
8312 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8313 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8315 status&=MogrifyImage(image_info,argc,argv,images,exception);
8316 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8317 if (proceed == MagickFalse)
8319 if ( (*images)->next == (Image *) NULL )
8321 *images=(*images)->next;
8324 assert( *images != (Image *) NULL );
8326 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8327 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8331 Post-process, multi-image sequence operators
8333 *images=GetFirstImageInList(*images);
8334 if (post != MagickFalse)
8335 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8336 return(status != 0 ? MagickTrue : MagickFalse);