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-2011 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/thread-private.h"
55 #include "MagickCore/string-private.h"
60 #define UndefinedCompressionQuality 0UL
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % M a g i c k C o m m a n d G e n e s i s %
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % MagickCommandGenesis() applies image processing options to an image as
74 % prescribed by command line options.
76 % The format of the MagickCommandGenesis method is:
78 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
79 % MagickCommand command,int argc,char **argv,char **metadata,
80 % ExceptionInfo *exception)
82 % A description of each parameter follows:
84 % o image_info: the image info.
86 % o command: Choose from ConvertImageCommand, IdentifyImageCommand,
87 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand,
88 % ConjureImageCommand, StreamImageCommand, ImportImageCommand,
89 % DisplayImageCommand, or AnimateImageCommand.
91 % o argc: Specifies a pointer to an integer describing the number of
92 % elements in the argument vector.
94 % o argv: Specifies a pointer to a text array containing the command line
97 % o metadata: any metadata is returned here.
99 % o exception: return any errors or warnings in this structure.
102 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
103 MagickCommand command,int argc,char **argv,char **metadata,
104 ExceptionInfo *exception)
128 (void) setlocale(LC_ALL,"");
129 (void) setlocale(LC_NUMERIC,"C");
130 concurrent=MagickFalse;
134 regard_warnings=MagickFalse;
135 for (i=1; i < (ssize_t) (argc-1); i++)
138 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
140 if (LocaleCompare("bench",option+1) == 0)
141 iterations=StringToUnsignedLong(argv[++i]);
142 if (LocaleCompare("concurrent",option+1) == 0)
143 concurrent=MagickTrue;
144 if (LocaleCompare("debug",option+1) == 0)
145 (void) SetLogEventMask(argv[++i]);
146 if (LocaleCompare("duration",option+1) == 0)
147 duration=InterpretLocaleValue(argv[++i],(char **) NULL);
148 if (LocaleCompare("regard-warnings",option+1) == 0)
149 regard_warnings=MagickTrue;
151 timer=AcquireTimerInfo();
152 if (concurrent == MagickFalse)
154 for (i=0; i < (ssize_t) iterations; i++)
156 if (status != MagickFalse)
160 if (GetElapsedTime(timer) > duration)
162 (void) ContinueTimer(timer);
164 status=command(image_info,argc,argv,metadata,exception);
165 if (exception->severity != UndefinedException)
167 if ((exception->severity > ErrorException) ||
168 (regard_warnings != MagickFalse))
170 CatchException(exception);
172 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
174 (void) fputs(*metadata,stdout);
175 (void) fputc('\n',stdout);
176 *metadata=DestroyString(*metadata);
183 #if defined(MAGICKCORE_OPENMP_SUPPORT)
184 # pragma omp parallel for shared(status)
186 for (i=0; i < (ssize_t) iterations; i++)
188 if (status != MagickFalse)
192 if (GetElapsedTime(timer) > duration)
194 (void) ContinueTimer(timer);
196 status=command(image_info,argc,argv,metadata,exception);
197 #if defined(MAGICKCORE_OPENMP_SUPPORT)
198 # pragma omp critical (MagickCore_CommandGenesis)
201 if (exception->severity != UndefinedException)
203 if ((exception->severity > ErrorException) ||
204 (regard_warnings != MagickFalse))
206 CatchException(exception);
208 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
210 (void) fputs(*metadata,stdout);
211 (void) fputc('\n',stdout);
212 *metadata=DestroyString(*metadata);
219 elapsed_time=GetElapsedTime(timer);
220 user_time=GetUserTime(timer);
221 (void) FormatLocaleFile(stderr,
222 "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double)
223 iterations,1.0*iterations/elapsed_time,user_time,(double)
224 (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double)
225 (1000.0*(elapsed_time-floor(elapsed_time))));
226 (void) fflush(stderr);
228 timer=DestroyTimerInfo(timer);
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 + M o g r i f y I m a g e %
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % MogrifyImage() applies simple single image processing options to a single
244 % image that may be part of a large list, but also handles any 'region'
247 % The image in the list may be modified in three different ways...
249 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw),
250 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology)
251 % * replace by a list of images (only the -separate option!)
253 % In each case the result is returned into the list, and a pointer to the
254 % modified image (last image added if replaced by a list of images) is
257 % ASIDE: The -crop is present but restricted to non-tile single image crops
259 % This means if all the images are being processed (such as by
260 % MogrifyImages(), next image to be processed will be as per the pointer
261 % (*image)->next. Also the image list may grow as a result of some specific
262 % operations but as images are never merged or deleted, it will never shrink
263 % in length. Typically the list will remain the same length.
265 % WARNING: As the image pointed to may be replaced, the first image in the
266 % list may also change. GetFirstImageInList() should be used by caller if
267 % they wish return the Image pointer to the first image in list.
270 % The format of the MogrifyImage method is:
272 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
273 % const char **argv,Image **image)
275 % A description of each parameter follows:
277 % o image_info: the image info..
279 % o argc: Specifies a pointer to an integer describing the number of
280 % elements in the argument vector.
282 % o argv: Specifies a pointer to a text array containing the command line
285 % o image: the image.
287 % o exception: return any errors or warnings in this structure.
292 ** GetImageCache() will read an image into a image cache if not already
293 ** present then return the image that is in the cache under that filename.
295 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
296 ExceptionInfo *exception)
310 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
311 sans_exception=AcquireExceptionInfo();
312 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
313 sans_exception=DestroyExceptionInfo(sans_exception);
314 if (image != (Image *) NULL)
316 read_info=CloneImageInfo(image_info);
317 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
318 image=ReadImage(read_info,exception);
319 read_info=DestroyImageInfo(read_info);
320 if (image != (Image *) NULL)
321 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
325 static MagickBooleanType IsPathWritable(const char *path)
327 if (IsPathAccessible(path) == MagickFalse)
329 if (access(path,W_OK) != 0)
334 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
341 static MagickBooleanType MonitorProgress(const char *text,
342 const MagickOffsetType offset,const MagickSizeType extent,
343 void *wand_unused(client_data))
346 message[MaxTextExtent],
357 (void) CopyMagickMemory(tag,text,MaxTextExtent);
359 if (p != (char *) NULL)
361 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag);
362 locale_message=GetLocaleMessage(message);
363 if (locale_message == message)
365 if (p == (char *) NULL)
366 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",
367 locale_message,(long) offset,(unsigned long) extent,(long)
368 (100L*offset/(extent-1)));
370 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
371 locale_message,p+1,(long) offset,(unsigned long) extent,(long)
372 (100L*offset/(extent-1)));
373 if (offset == (MagickOffsetType) (extent-1))
374 (void) FormatLocaleFile(stderr,"\n");
375 (void) fflush(stderr);
380 ** SparseColorOption() parses the complex -sparse-color argument into an
381 ** an array of floating point values then calls SparseColorImage().
382 ** Argument is a complex mix of floating-point pixel coodinates, and color
383 ** specifications (or direct floating point numbers). The number of floats
384 ** needed to represent a color varies depending on the current channel
387 static Image *SparseColorOption(const Image *image,const ChannelType channel,
388 const SparseColorMethod method,const char *arguments,
389 const MagickBooleanType color_from_image,ExceptionInfo *exception)
395 token[MaxTextExtent];
419 assert(image != (Image *) NULL);
420 assert(image->signature == MagickSignature);
421 if (image->debug != MagickFalse)
422 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
423 assert(exception != (ExceptionInfo *) NULL);
424 assert(exception->signature == MagickSignature);
426 Limit channels according to image - and add up number of color channel.
429 if (image->colorspace != CMYKColorspace)
430 channels=(ChannelType) (channels & ~BlackChannel); /* no black channel */
431 if (image->matte == MagickFalse)
432 channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */
434 if ((channels & RedChannel) != 0)
436 if ((channels & GreenChannel) != 0)
438 if ((channels & BlueChannel) != 0)
440 if ((channels & BlackChannel) != 0)
442 if ((channels & OpacityChannel) != 0)
446 Read string, to determine number of arguments needed,
452 GetMagickToken(p,&p,token);
453 if ( token[0] == ',' ) continue;
454 if ( isalpha((int) token[0]) || token[0] == '#' ) {
455 if ( color_from_image ) {
456 (void) ThrowMagickException(exception,GetMagickModule(),
457 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
458 "Color arg given, when colors are coming from image");
459 return( (Image *)NULL);
461 x += number_colors; /* color argument */
464 x++; /* floating point argument */
468 if ( color_from_image ) {
469 /* just the control points are being given */
470 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
471 number_arguments=(x/2)*(2+number_colors);
474 /* control points and color values */
475 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
479 (void) ThrowMagickException(exception,GetMagickModule(),
480 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
481 "Invalid number of Arguments");
482 return( (Image *)NULL);
485 /* Allocate and fill in the floating point arguments */
486 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
487 sizeof(*sparse_arguments));
488 if (sparse_arguments == (double *) NULL) {
489 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
490 "MemoryAllocationFailed","%s","SparseColorOption");
491 return( (Image *)NULL);
493 (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
494 sizeof(*sparse_arguments));
497 while( *p != '\0' && x < number_arguments ) {
499 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
500 if ( token[0] == '\0' ) break;
501 if ( isalpha((int) token[0]) || token[0] == '#' ) {
502 (void) ThrowMagickException(exception,GetMagickModule(),
503 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
504 "Color found, instead of X-coord");
508 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
510 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
511 if ( token[0] == '\0' ) break;
512 if ( isalpha((int) token[0]) || token[0] == '#' ) {
513 (void) ThrowMagickException(exception,GetMagickModule(),
514 OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
515 "Color found, instead of Y-coord");
519 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
520 /* color values for this control point */
522 if ( (color_from_image ) {
523 /* get color from image */
529 /* color name or function given in string argument */
530 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
531 if ( token[0] == '\0' ) break;
532 if ( isalpha((int) token[0]) || token[0] == '#' ) {
533 /* Color string given */
534 (void) QueryMagickColor(token,&color,exception);
535 if (channels & RedChannel)
536 sparse_arguments[x++] = QuantumScale*color.red;
537 if (channels & GreenChannel)
538 sparse_arguments[x++] = QuantumScale*color.green;
539 if (channels & BlueChannel)
540 sparse_arguments[x++] = QuantumScale*color.blue;
541 if (channels & BlackChannel)
542 sparse_arguments[x++] = QuantumScale*color.black;
543 if (channels & OpacityChannel)
544 sparse_arguments[x++] = QuantumScale*color.alpha;
547 /* Colors given as a set of floating point values - experimental */
548 /* NB: token contains the first floating point value to use! */
549 if ( channels & RedChannel ) {
550 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
551 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
553 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
554 token[0] = ','; /* used this token - get another */
556 if ( channels & GreenChannel ) {
557 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
558 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
560 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
561 token[0] = ','; /* used this token - get another */
563 if ( channels & BlueChannel ) {
564 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
565 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
567 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
568 token[0] = ','; /* used this token - get another */
570 if (channels & BlackChannel) {
571 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
572 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
574 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
575 token[0] = ','; /* used this token - get another */
577 if ( channels & OpacityChannel ) {
578 while ( token[0] == ',' ) GetMagickToken(p,&p,token);
579 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
581 sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL);
582 token[0] = ','; /* used this token - get another */
587 if ( number_arguments != x && !error ) {
588 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
589 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
590 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
591 return( (Image *)NULL);
594 return( (Image *)NULL);
596 /* Call the Interpolation function with the parsed arguments */
597 sparse_image=SparseColorImage(image,channels,method,number_arguments,
598 sparse_arguments,exception);
599 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
600 return( sparse_image );
603 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
604 const char **argv,Image **image,ExceptionInfo *exception)
645 Initialize method variables.
647 assert(image_info != (const ImageInfo *) NULL);
648 assert(image_info->signature == MagickSignature);
649 assert(image != (Image **) NULL);
650 assert((*image)->signature == MagickSignature);
651 if ((*image)->debug != MagickFalse)
652 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
655 mogrify_info=CloneImageInfo(image_info);
656 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);
657 quantize_info=AcquireQuantizeInfo(mogrify_info);
658 SetGeometryInfo(&geometry_info);
659 GetPixelInfo(*image,&fill);
660 SetPixelInfoPacket(*image,&(*image)->background_color,&fill);
661 channel=mogrify_info->channel;
662 format=GetImageOption(mogrify_info,"format");
663 SetGeometry(*image,®ion_geometry);
664 region_image=NewImageList();
666 Transmogrify the image.
668 for (i=0; i < (ssize_t) argc; i++)
677 if (IsCommandOption(option) == MagickFalse)
679 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),
681 if ((i+count) >= (ssize_t) argc)
683 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
684 mogrify_image=(Image *)NULL;
689 if (LocaleCompare("adaptive-blur",option+1) == 0)
694 (void) SyncImageSettings(mogrify_info,*image);
695 flags=ParseGeometry(argv[i+1],&geometry_info);
696 if ((flags & SigmaValue) == 0)
697 geometry_info.sigma=1.0;
698 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,
699 geometry_info.sigma,exception);
702 if (LocaleCompare("adaptive-resize",option+1) == 0)
705 Adaptive resize image.
707 (void) SyncImageSettings(mogrify_info,*image);
708 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
709 mogrify_image=AdaptiveResizeImage(*image,geometry.width,
710 geometry.height,exception);
713 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
716 Adaptive sharpen image.
718 (void) SyncImageSettings(mogrify_info,*image);
719 flags=ParseGeometry(argv[i+1],&geometry_info);
720 if ((flags & SigmaValue) == 0)
721 geometry_info.sigma=1.0;
722 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,
723 geometry_info.sigma,exception);
726 if (LocaleCompare("affine",option+1) == 0)
733 GetAffineMatrix(&draw_info->affine);
736 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
739 if (LocaleCompare("alpha",option+1) == 0)
744 (void) SyncImageSettings(mogrify_info,*image);
745 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions,
746 MagickFalse,argv[i+1]);
747 (void) SetImageAlphaChannel(*image,alpha_type);
748 InheritException(exception,&(*image)->exception);
751 if (LocaleCompare("annotate",option+1) == 0)
755 geometry[MaxTextExtent];
760 (void) SyncImageSettings(mogrify_info,*image);
761 SetGeometryInfo(&geometry_info);
762 flags=ParseGeometry(argv[i+1],&geometry_info);
763 if ((flags & SigmaValue) == 0)
764 geometry_info.sigma=geometry_info.rho;
765 text=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
766 InheritException(exception,&(*image)->exception);
767 if (text == (char *) NULL)
769 (void) CloneString(&draw_info->text,text);
770 text=DestroyString(text);
771 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
772 geometry_info.xi,geometry_info.psi);
773 (void) CloneString(&draw_info->geometry,geometry);
774 draw_info->affine.sx=cos(DegreesToRadians(
775 fmod(geometry_info.rho,360.0)));
776 draw_info->affine.rx=sin(DegreesToRadians(
777 fmod(geometry_info.rho,360.0)));
778 draw_info->affine.ry=(-sin(DegreesToRadians(
779 fmod(geometry_info.sigma,360.0))));
780 draw_info->affine.sy=cos(DegreesToRadians(
781 fmod(geometry_info.sigma,360.0)));
782 (void) AnnotateImage(*image,draw_info);
783 InheritException(exception,&(*image)->exception);
786 if (LocaleCompare("antialias",option+1) == 0)
788 draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
790 draw_info->text_antialias=(*option == '-') ? MagickTrue :
794 if (LocaleCompare("auto-gamma",option+1) == 0)
797 Auto Adjust Gamma of image based on its mean
799 (void) SyncImageSettings(mogrify_info,*image);
800 (void) AutoGammaImage(*image);
803 if (LocaleCompare("auto-level",option+1) == 0)
806 Perfectly Normalize (max/min stretch) the image
808 (void) SyncImageSettings(mogrify_info,*image);
809 (void) AutoLevelImage(*image);
812 if (LocaleCompare("auto-orient",option+1) == 0)
814 (void) SyncImageSettings(mogrify_info,*image);
815 switch ((*image)->orientation)
817 case TopRightOrientation:
819 mogrify_image=FlopImage(*image,exception);
822 case BottomRightOrientation:
824 mogrify_image=RotateImage(*image,180.0,exception);
827 case BottomLeftOrientation:
829 mogrify_image=FlipImage(*image,exception);
832 case LeftTopOrientation:
834 mogrify_image=TransposeImage(*image,exception);
837 case RightTopOrientation:
839 mogrify_image=RotateImage(*image,90.0,exception);
842 case RightBottomOrientation:
844 mogrify_image=TransverseImage(*image,exception);
847 case LeftBottomOrientation:
849 mogrify_image=RotateImage(*image,270.0,exception);
855 if (mogrify_image != (Image *) NULL)
856 mogrify_image->orientation=TopLeftOrientation;
863 if (LocaleCompare("black-threshold",option+1) == 0)
866 Black threshold image.
868 (void) SyncImageSettings(mogrify_info,*image);
869 (void) BlackThresholdImage(*image,argv[i+1],exception);
870 InheritException(exception,&(*image)->exception);
873 if (LocaleCompare("blue-shift",option+1) == 0)
878 (void) SyncImageSettings(mogrify_info,*image);
879 geometry_info.rho=1.5;
881 flags=ParseGeometry(argv[i+1],&geometry_info);
882 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);
885 if (LocaleCompare("blur",option+1) == 0)
890 (void) SyncImageSettings(mogrify_info,*image);
891 flags=ParseGeometry(argv[i+1],&geometry_info);
892 if ((flags & SigmaValue) == 0)
893 geometry_info.sigma=1.0;
894 mogrify_image=BlurImage(*image,geometry_info.rho,
895 geometry_info.sigma,exception);
898 if (LocaleCompare("border",option+1) == 0)
901 Surround image with a border of solid color.
903 (void) SyncImageSettings(mogrify_info,*image);
904 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
905 if ((flags & SigmaValue) == 0)
906 geometry.height=geometry.width;
907 mogrify_image=BorderImage(*image,&geometry,exception);
910 if (LocaleCompare("bordercolor",option+1) == 0)
914 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
918 (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
922 if (LocaleCompare("box",option+1) == 0)
924 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
928 if (LocaleCompare("brightness-contrast",option+1) == 0)
941 Brightness / contrast image.
943 (void) SyncImageSettings(mogrify_info,*image);
944 flags=ParseGeometry(argv[i+1],&geometry_info);
945 brightness=geometry_info.rho;
947 if ((flags & SigmaValue) != 0)
948 contrast=geometry_info.sigma;
949 (void) BrightnessContrastImage(*image,brightness,contrast);
950 InheritException(exception,&(*image)->exception);
957 if (LocaleCompare("cdl",option+1) == 0)
960 *color_correction_collection;
963 Color correct with a color decision list.
965 (void) SyncImageSettings(mogrify_info,*image);
966 color_correction_collection=FileToString(argv[i+1],~0,exception);
967 if (color_correction_collection == (char *) NULL)
969 (void) ColorDecisionListImage(*image,color_correction_collection);
970 InheritException(exception,&(*image)->exception);
973 if (LocaleCompare("channel",option+1) == 0)
976 channel=DefaultChannels;
978 channel=(ChannelType) ParseChannelOption(argv[i+1]);
979 SetPixelComponentMap(*image,channel);
982 if (LocaleCompare("charcoal",option+1) == 0)
987 (void) SyncImageSettings(mogrify_info,*image);
988 flags=ParseGeometry(argv[i+1],&geometry_info);
989 if ((flags & SigmaValue) == 0)
990 geometry_info.sigma=1.0;
991 mogrify_image=CharcoalImage(*image,geometry_info.rho,
992 geometry_info.sigma,exception);
995 if (LocaleCompare("chop",option+1) == 0)
1000 (void) SyncImageSettings(mogrify_info,*image);
1001 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1002 mogrify_image=ChopImage(*image,&geometry,exception);
1005 if (LocaleCompare("clamp",option+1) == 0)
1010 (void) SyncImageSettings(mogrify_info,*image);
1011 (void) ClampImage(*image);
1012 InheritException(exception,&(*image)->exception);
1015 if (LocaleCompare("clip",option+1) == 0)
1017 (void) SyncImageSettings(mogrify_info,*image);
1020 (void) SetImageClipMask(*image,(Image *) NULL);
1021 InheritException(exception,&(*image)->exception);
1024 (void) ClipImage(*image);
1025 InheritException(exception,&(*image)->exception);
1028 if (LocaleCompare("clip-mask",option+1) == 0)
1045 (void) SyncImageSettings(mogrify_info,*image);
1051 (void) SetImageMask(*image,(Image *) NULL);
1052 InheritException(exception,&(*image)->exception);
1057 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
1059 mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
1060 if (mask_image == (Image *) NULL)
1062 if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse)
1063 return(MagickFalse);
1064 mask_view=AcquireCacheView(mask_image);
1065 for (y=0; y < (ssize_t) mask_image->rows; y++)
1067 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
1069 if (q == (const Quantum *) NULL)
1071 for (x=0; x < (ssize_t) mask_image->columns; x++)
1073 if (mask_image->matte == MagickFalse)
1074 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q);
1075 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
1076 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
1077 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
1078 q+=GetPixelComponents(mask_image);
1080 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
1083 mask_view=DestroyCacheView(mask_view);
1084 mask_image->matte=MagickTrue;
1085 (void) SetImageClipMask(*image,mask_image);
1086 mask_image=DestroyImage(mask_image);
1087 InheritException(exception,&(*image)->exception);
1090 if (LocaleCompare("clip-path",option+1) == 0)
1092 (void) SyncImageSettings(mogrify_info,*image);
1093 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
1095 InheritException(exception,&(*image)->exception);
1098 if (LocaleCompare("colorize",option+1) == 0)
1103 (void) SyncImageSettings(mogrify_info,*image);
1104 mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
1108 if (LocaleCompare("color-matrix",option+1) == 0)
1113 (void) SyncImageSettings(mogrify_info,*image);
1114 kernel=AcquireKernelInfo(argv[i+1]);
1115 if (kernel == (KernelInfo *) NULL)
1117 mogrify_image=ColorMatrixImage(*image,kernel,exception);
1118 kernel=DestroyKernelInfo(kernel);
1121 if (LocaleCompare("colors",option+1) == 0)
1124 Reduce the number of colors in the image.
1126 (void) SyncImageSettings(mogrify_info,*image);
1127 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);
1128 if (quantize_info->number_colors == 0)
1130 if (((*image)->storage_class == DirectClass) ||
1131 (*image)->colors > quantize_info->number_colors)
1132 (void) QuantizeImage(quantize_info,*image);
1134 (void) CompressImageColormap(*image);
1135 InheritException(exception,&(*image)->exception);
1138 if (LocaleCompare("colorspace",option+1) == 0)
1143 (void) SyncImageSettings(mogrify_info,*image);
1146 (void) TransformImageColorspace(*image,RGBColorspace);
1147 InheritException(exception,&(*image)->exception);
1150 colorspace=(ColorspaceType) ParseCommandOption(
1151 MagickColorspaceOptions,MagickFalse,argv[i+1]);
1152 (void) TransformImageColorspace(*image,colorspace);
1153 InheritException(exception,&(*image)->exception);
1156 if (LocaleCompare("contrast",option+1) == 0)
1158 (void) SyncImageSettings(mogrify_info,*image);
1159 (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
1161 InheritException(exception,&(*image)->exception);
1164 if (LocaleCompare("contrast-stretch",option+1) == 0)
1174 Contrast stretch image.
1176 (void) SyncImageSettings(mogrify_info,*image);
1177 flags=ParseGeometry(argv[i+1],&geometry_info);
1178 black_point=geometry_info.rho;
1179 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
1181 if ((flags & PercentValue) != 0)
1183 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1184 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1186 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1188 (void) ContrastStretchImage(*image,black_point,white_point);
1189 InheritException(exception,&(*image)->exception);
1192 if (LocaleCompare("convolve",option+1) == 0)
1203 (void) SyncImageSettings(mogrify_info,*image);
1204 kernel=AcquireKernelInfo(argv[i+1]);
1205 if (kernel == (KernelInfo *) NULL)
1208 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1209 gamma+=kernel->values[j];
1210 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
1211 for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
1212 kernel->values[j]*=gamma;
1213 mogrify_image=FilterImage(*image,kernel,exception);
1214 kernel=DestroyKernelInfo(kernel);
1217 if (LocaleCompare("crop",option+1) == 0)
1220 Crop a image to a smaller size
1222 (void) SyncImageSettings(mogrify_info,*image);
1224 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1225 if (((geometry.width != 0) || (geometry.height != 0)) &&
1226 ((flags & XValue) == 0) && ((flags & YValue) == 0))
1230 mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
1231 mogrify_image->next = mogrify_image->previous = (Image *)NULL;
1232 (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL);
1233 InheritException(exception,&mogrify_image->exception);
1235 mogrify_image=CropImageToTiles(*image,argv[i+1],exception);
1239 if (LocaleCompare("cycle",option+1) == 0)
1242 Cycle an image colormap.
1244 (void) SyncImageSettings(mogrify_info,*image);
1245 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]));
1246 InheritException(exception,&(*image)->exception);
1253 if (LocaleCompare("decipher",option+1) == 0)
1261 (void) SyncImageSettings(mogrify_info,*image);
1262 passkey=FileToStringInfo(argv[i+1],~0,exception);
1263 if (passkey != (StringInfo *) NULL)
1265 (void) PasskeyDecipherImage(*image,passkey,exception);
1266 passkey=DestroyStringInfo(passkey);
1270 if (LocaleCompare("density",option+1) == 0)
1275 (void) CloneString(&draw_info->density,argv[i+1]);
1278 if (LocaleCompare("depth",option+1) == 0)
1280 (void) SyncImageSettings(mogrify_info,*image);
1283 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
1286 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]));
1289 if (LocaleCompare("deskew",option+1) == 0)
1295 Straighten the image.
1297 (void) SyncImageSettings(mogrify_info,*image);
1299 threshold=40.0*QuantumRange/100.0;
1301 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
1302 mogrify_image=DeskewImage(*image,threshold,exception);
1305 if (LocaleCompare("despeckle",option+1) == 0)
1308 Reduce the speckles within an image.
1310 (void) SyncImageSettings(mogrify_info,*image);
1311 mogrify_image=DespeckleImage(*image,exception);
1314 if (LocaleCompare("display",option+1) == 0)
1316 (void) CloneString(&draw_info->server_name,argv[i+1]);
1319 if (LocaleCompare("distort",option+1) == 0)
1323 token[MaxTextExtent];
1343 (void) SyncImageSettings(mogrify_info,*image);
1344 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions,
1345 MagickFalse,argv[i+1]);
1346 if ( method == ResizeDistortion )
1348 /* Special Case - Argument is actually a resize geometry!
1349 ** Convert that to an appropriate distortion argument array.
1353 (void) ParseRegionGeometry(*image,argv[i+2],&geometry,
1355 resize_args[0]=(double)geometry.width;
1356 resize_args[1]=(double)geometry.height;
1357 mogrify_image=DistortImage(*image,method,(size_t)2,
1358 resize_args,MagickTrue,exception);
1361 args=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1362 InheritException(exception,&(*image)->exception);
1363 if (args == (char *) NULL)
1366 for (x=0; *p != '\0'; x++)
1368 GetMagickToken(p,&p,token);
1370 GetMagickToken(p,&p,token);
1372 number_arguments=(size_t) x;
1373 arguments=(double *) AcquireQuantumMemory(number_arguments,
1374 sizeof(*arguments));
1375 if (arguments == (double *) NULL)
1376 ThrowWandFatalException(ResourceLimitFatalError,
1377 "MemoryAllocationFailed",(*image)->filename);
1378 (void) ResetMagickMemory(arguments,0,number_arguments*
1379 sizeof(*arguments));
1381 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
1383 GetMagickToken(p,&p,token);
1385 GetMagickToken(p,&p,token);
1386 arguments[x]=InterpretLocaleValue(token,(char **) NULL);
1388 args=DestroyString(args);
1389 mogrify_image=DistortImage(*image,method,number_arguments,arguments,
1390 (*option == '+') ? MagickTrue : MagickFalse,exception);
1391 arguments=(double *) RelinquishMagickMemory(arguments);
1394 if (LocaleCompare("dither",option+1) == 0)
1398 quantize_info->dither=MagickFalse;
1401 quantize_info->dither=MagickTrue;
1402 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
1403 MagickDitherOptions,MagickFalse,argv[i+1]);
1404 if (quantize_info->dither_method == NoDitherMethod)
1405 quantize_info->dither=MagickFalse;
1408 if (LocaleCompare("draw",option+1) == 0)
1413 (void) SyncImageSettings(mogrify_info,*image);
1414 (void) CloneString(&draw_info->primitive,argv[i+1]);
1415 (void) DrawImage(*image,draw_info);
1416 InheritException(exception,&(*image)->exception);
1423 if (LocaleCompare("edge",option+1) == 0)
1426 Enhance edges in the image.
1428 (void) SyncImageSettings(mogrify_info,*image);
1429 flags=ParseGeometry(argv[i+1],&geometry_info);
1430 if ((flags & SigmaValue) == 0)
1431 geometry_info.sigma=1.0;
1432 mogrify_image=EdgeImage(*image,geometry_info.rho,exception);
1435 if (LocaleCompare("emboss",option+1) == 0)
1438 Gaussian embossen image.
1440 (void) SyncImageSettings(mogrify_info,*image);
1441 flags=ParseGeometry(argv[i+1],&geometry_info);
1442 if ((flags & SigmaValue) == 0)
1443 geometry_info.sigma=1.0;
1444 mogrify_image=EmbossImage(*image,geometry_info.rho,
1445 geometry_info.sigma,exception);
1448 if (LocaleCompare("encipher",option+1) == 0)
1456 (void) SyncImageSettings(mogrify_info,*image);
1457 passkey=FileToStringInfo(argv[i+1],~0,exception);
1458 if (passkey != (StringInfo *) NULL)
1460 (void) PasskeyEncipherImage(*image,passkey,exception);
1461 passkey=DestroyStringInfo(passkey);
1465 if (LocaleCompare("encoding",option+1) == 0)
1467 (void) CloneString(&draw_info->encoding,argv[i+1]);
1470 if (LocaleCompare("enhance",option+1) == 0)
1475 (void) SyncImageSettings(mogrify_info,*image);
1476 mogrify_image=EnhanceImage(*image,exception);
1479 if (LocaleCompare("equalize",option+1) == 0)
1484 (void) SyncImageSettings(mogrify_info,*image);
1485 (void) EqualizeImage(*image);
1486 InheritException(exception,&(*image)->exception);
1489 if (LocaleCompare("evaluate",option+1) == 0)
1494 MagickEvaluateOperator
1497 (void) SyncImageSettings(mogrify_info,*image);
1498 op=(MagickEvaluateOperator) ParseCommandOption(
1499 MagickEvaluateOptions,MagickFalse,argv[i+1]);
1500 constant=SiPrefixToDouble(argv[i+2],QuantumRange);
1501 (void) EvaluateImage(*image,op,constant,exception);
1504 if (LocaleCompare("extent",option+1) == 0)
1507 Set the image extent.
1509 (void) SyncImageSettings(mogrify_info,*image);
1510 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
1511 if (geometry.width == 0)
1512 geometry.width=(*image)->columns;
1513 if (geometry.height == 0)
1514 geometry.height=(*image)->rows;
1515 mogrify_image=ExtentImage(*image,&geometry,exception);
1522 if (LocaleCompare("family",option+1) == 0)
1526 if (draw_info->family != (char *) NULL)
1527 draw_info->family=DestroyString(draw_info->family);
1530 (void) CloneString(&draw_info->family,argv[i+1]);
1533 if (LocaleCompare("features",option+1) == 0)
1537 (void) DeleteImageArtifact(*image,"identify:features");
1540 (void) SetImageArtifact(*image,"identify:features",argv[i+1]);
1543 if (LocaleCompare("fill",option+1) == 0)
1548 GetPixelInfo(*image,&fill);
1551 (void) QueryMagickColor("none",&fill,exception);
1552 (void) QueryColorDatabase("none",&draw_info->fill,exception);
1553 if (draw_info->fill_pattern != (Image *) NULL)
1554 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
1557 sans=AcquireExceptionInfo();
1558 (void) QueryMagickColor(argv[i+1],&fill,sans);
1559 status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
1560 sans=DestroyExceptionInfo(sans);
1561 if (status == MagickFalse)
1562 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
1566 if (LocaleCompare("flip",option+1) == 0)
1569 Flip image scanlines.
1571 (void) SyncImageSettings(mogrify_info,*image);
1572 mogrify_image=FlipImage(*image,exception);
1575 if (LocaleCompare("floodfill",option+1) == 0)
1583 (void) SyncImageSettings(mogrify_info,*image);
1584 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1585 (void) QueryMagickColor(argv[i+2],&target,exception);
1586 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,
1587 geometry.y,*option == '-' ? MagickFalse : MagickTrue);
1588 InheritException(exception,&(*image)->exception);
1591 if (LocaleCompare("flop",option+1) == 0)
1594 Flop image scanlines.
1596 (void) SyncImageSettings(mogrify_info,*image);
1597 mogrify_image=FlopImage(*image,exception);
1600 if (LocaleCompare("font",option+1) == 0)
1604 if (draw_info->font != (char *) NULL)
1605 draw_info->font=DestroyString(draw_info->font);
1608 (void) CloneString(&draw_info->font,argv[i+1]);
1611 if (LocaleCompare("format",option+1) == 0)
1616 if (LocaleCompare("frame",option+1) == 0)
1622 Surround image with an ornamental border.
1624 (void) SyncImageSettings(mogrify_info,*image);
1625 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
1626 frame_info.width=geometry.width;
1627 frame_info.height=geometry.height;
1628 if ((flags & HeightValue) == 0)
1629 frame_info.height=geometry.width;
1630 frame_info.outer_bevel=geometry.x;
1631 frame_info.inner_bevel=geometry.y;
1632 frame_info.x=(ssize_t) frame_info.width;
1633 frame_info.y=(ssize_t) frame_info.height;
1634 frame_info.width=(*image)->columns+2*frame_info.width;
1635 frame_info.height=(*image)->rows+2*frame_info.height;
1636 mogrify_image=FrameImage(*image,&frame_info,exception);
1639 if (LocaleCompare("function",option+1) == 0)
1643 token[MaxTextExtent];
1661 Function Modify Image Values
1663 (void) SyncImageSettings(mogrify_info,*image);
1664 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,
1665 MagickFalse,argv[i+1]);
1666 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
1667 InheritException(exception,&(*image)->exception);
1668 if (arguments == (char *) NULL)
1670 p=(char *) arguments;
1671 for (x=0; *p != '\0'; x++)
1673 GetMagickToken(p,&p,token);
1675 GetMagickToken(p,&p,token);
1677 number_parameters=(size_t) x;
1678 parameters=(double *) AcquireQuantumMemory(number_parameters,
1679 sizeof(*parameters));
1680 if (parameters == (double *) NULL)
1681 ThrowWandFatalException(ResourceLimitFatalError,
1682 "MemoryAllocationFailed",(*image)->filename);
1683 (void) ResetMagickMemory(parameters,0,number_parameters*
1684 sizeof(*parameters));
1685 p=(char *) arguments;
1686 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
1688 GetMagickToken(p,&p,token);
1690 GetMagickToken(p,&p,token);
1691 parameters[x]=InterpretLocaleValue(token,(char **) NULL);
1693 arguments=DestroyString(arguments);
1694 (void) FunctionImage(*image,function,number_parameters,parameters,
1696 parameters=(double *) RelinquishMagickMemory(parameters);
1703 if (LocaleCompare("gamma",option+1) == 0)
1708 (void) SyncImageSettings(mogrify_info,*image);
1710 (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL);
1713 (void) GammaImage(*image,InterpretLocaleValue(argv[i+1],
1715 InheritException(exception,&(*image)->exception);
1719 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
1720 (LocaleCompare("gaussian",option+1) == 0))
1723 Gaussian blur image.
1725 (void) SyncImageSettings(mogrify_info,*image);
1726 flags=ParseGeometry(argv[i+1],&geometry_info);
1727 if ((flags & SigmaValue) == 0)
1728 geometry_info.sigma=1.0;
1729 mogrify_image=GaussianBlurImage(*image,geometry_info.rho,
1730 geometry_info.sigma,exception);
1733 if (LocaleCompare("geometry",option+1) == 0)
1736 Record Image offset, Resize last image.
1738 (void) SyncImageSettings(mogrify_info,*image);
1741 if ((*image)->geometry != (char *) NULL)
1742 (*image)->geometry=DestroyString((*image)->geometry);
1745 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1746 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
1747 (void) CloneString(&(*image)->geometry,argv[i+1]);
1749 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
1750 (*image)->filter,(*image)->blur,exception);
1753 if (LocaleCompare("gravity",option+1) == 0)
1757 draw_info->gravity=UndefinedGravity;
1760 draw_info->gravity=(GravityType) ParseCommandOption(
1761 MagickGravityOptions,MagickFalse,argv[i+1]);
1768 if (LocaleCompare("highlight-color",option+1) == 0)
1770 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1777 if (LocaleCompare("identify",option+1) == 0)
1782 (void) SyncImageSettings(mogrify_info,*image);
1783 if (format == (char *) NULL)
1785 (void) IdentifyImage(*image,stdout,mogrify_info->verbose);
1786 InheritException(exception,&(*image)->exception);
1789 text=InterpretImageProperties(mogrify_info,*image,format);
1790 InheritException(exception,&(*image)->exception);
1791 if (text == (char *) NULL)
1793 (void) fputs(text,stdout);
1794 (void) fputc('\n',stdout);
1795 text=DestroyString(text);
1798 if (LocaleCompare("implode",option+1) == 0)
1803 (void) SyncImageSettings(mogrify_info,*image);
1804 (void) ParseGeometry(argv[i+1],&geometry_info);
1805 mogrify_image=ImplodeImage(*image,geometry_info.rho,exception);
1808 if (LocaleCompare("interline-spacing",option+1) == 0)
1811 (void) ParseGeometry("0",&geometry_info);
1813 (void) ParseGeometry(argv[i+1],&geometry_info);
1814 draw_info->interline_spacing=geometry_info.rho;
1817 if (LocaleCompare("interword-spacing",option+1) == 0)
1820 (void) ParseGeometry("0",&geometry_info);
1822 (void) ParseGeometry(argv[i+1],&geometry_info);
1823 draw_info->interword_spacing=geometry_info.rho;
1830 if (LocaleCompare("kerning",option+1) == 0)
1833 (void) ParseGeometry("0",&geometry_info);
1835 (void) ParseGeometry(argv[i+1],&geometry_info);
1836 draw_info->kerning=geometry_info.rho;
1843 if (LocaleCompare("lat",option+1) == 0)
1846 Local adaptive threshold image.
1848 (void) SyncImageSettings(mogrify_info,*image);
1849 flags=ParseGeometry(argv[i+1],&geometry_info);
1850 if ((flags & PercentValue) != 0)
1851 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
1852 mogrify_image=AdaptiveThresholdImage(*image,(size_t)
1853 geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t)
1854 geometry_info.xi,exception);
1857 if (LocaleCompare("level",option+1) == 0)
1870 (void) SyncImageSettings(mogrify_info,*image);
1871 flags=ParseGeometry(argv[i+1],&geometry_info);
1872 black_point=geometry_info.rho;
1873 white_point=(MagickRealType) QuantumRange;
1874 if ((flags & SigmaValue) != 0)
1875 white_point=geometry_info.sigma;
1877 if ((flags & XiValue) != 0)
1878 gamma=geometry_info.xi;
1879 if ((flags & PercentValue) != 0)
1881 black_point*=(MagickRealType) (QuantumRange/100.0);
1882 white_point*=(MagickRealType) (QuantumRange/100.0);
1884 if ((flags & SigmaValue) == 0)
1885 white_point=(MagickRealType) QuantumRange-black_point;
1886 if ((*option == '+') || ((flags & AspectValue) != 0))
1887 (void) LevelizeImage(*image,black_point,white_point,gamma);
1889 (void) LevelImage(*image,black_point,white_point,gamma);
1890 InheritException(exception,&(*image)->exception);
1893 if (LocaleCompare("level-colors",option+1) == 0)
1896 token[MaxTextExtent];
1905 p=(const char *) argv[i+1];
1906 GetMagickToken(p,&p,token); /* get black point color */
1907 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1908 (void) QueryMagickColor(token,&black_point,exception);
1910 (void) QueryMagickColor("#000000",&black_point,exception);
1911 if (isalpha((int) token[0]) || (token[0] == '#'))
1912 GetMagickToken(p,&p,token);
1914 white_point=black_point; /* set everything to that color */
1917 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
1918 GetMagickToken(p,&p,token); /* Get white point color. */
1919 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
1920 (void) QueryMagickColor(token,&white_point,exception);
1922 (void) QueryMagickColor("#ffffff",&white_point,exception);
1924 (void) LevelImageColors(*image,&black_point,&white_point,
1925 *option == '+' ? MagickTrue : MagickFalse);
1928 if (LocaleCompare("linear-stretch",option+1) == 0)
1937 (void) SyncImageSettings(mogrify_info,*image);
1938 flags=ParseGeometry(argv[i+1],&geometry_info);
1939 black_point=geometry_info.rho;
1940 white_point=(MagickRealType) (*image)->columns*(*image)->rows;
1941 if ((flags & SigmaValue) != 0)
1942 white_point=geometry_info.sigma;
1943 if ((flags & PercentValue) != 0)
1945 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
1946 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
1948 if ((flags & SigmaValue) == 0)
1949 white_point=(MagickRealType) (*image)->columns*(*image)->rows-
1951 (void) LinearStretchImage(*image,black_point,white_point);
1952 InheritException(exception,&(*image)->exception);
1955 if (LocaleCompare("linewidth",option+1) == 0)
1957 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
1961 if (LocaleCompare("liquid-rescale",option+1) == 0)
1964 Liquid rescale image.
1966 (void) SyncImageSettings(mogrify_info,*image);
1967 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
1968 if ((flags & XValue) == 0)
1970 if ((flags & YValue) == 0)
1972 mogrify_image=LiquidRescaleImage(*image,geometry.width,
1973 geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
1976 if (LocaleCompare("lowlight-color",option+1) == 0)
1978 (void) SetImageArtifact(*image,option+1,argv[i+1]);
1985 if (LocaleCompare("map",option+1) == 0)
1991 Transform image colors to match this set of colors.
1993 (void) SyncImageSettings(mogrify_info,*image);
1996 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
1997 if (remap_image == (Image *) NULL)
1999 (void) RemapImage(quantize_info,*image,remap_image);
2000 InheritException(exception,&(*image)->exception);
2001 remap_image=DestroyImage(remap_image);
2004 if (LocaleCompare("mask",option+1) == 0)
2009 (void) SyncImageSettings(mogrify_info,*image);
2015 (void) SetImageMask(*image,(Image *) NULL);
2016 InheritException(exception,&(*image)->exception);
2022 mask=GetImageCache(mogrify_info,argv[i+1],exception);
2023 if (mask == (Image *) NULL)
2025 (void) SetImageMask(*image,mask);
2026 mask=DestroyImage(mask);
2027 InheritException(exception,&(*image)->exception);
2030 if (LocaleCompare("matte",option+1) == 0)
2032 (void) SetImageAlphaChannel(*image,(*option == '-') ?
2033 SetAlphaChannel : DeactivateAlphaChannel );
2034 InheritException(exception,&(*image)->exception);
2037 if (LocaleCompare("median",option+1) == 0)
2040 Median filter image.
2042 (void) SyncImageSettings(mogrify_info,*image);
2043 (void) ParseGeometry(argv[i+1],&geometry_info);
2044 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)
2045 geometry_info.rho,(size_t) geometry_info.rho,exception);
2048 if (LocaleCompare("mode",option+1) == 0)
2053 (void) SyncImageSettings(mogrify_info,*image);
2054 (void) ParseGeometry(argv[i+1],&geometry_info);
2055 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)
2056 geometry_info.rho,(size_t) geometry_info.rho,exception);
2059 if (LocaleCompare("modulate",option+1) == 0)
2061 (void) SyncImageSettings(mogrify_info,*image);
2062 (void) ModulateImage(*image,argv[i+1]);
2063 InheritException(exception,&(*image)->exception);
2066 if (LocaleCompare("monitor",option+1) == 0)
2070 (void) SetImageProgressMonitor(*image,
2071 (MagickProgressMonitor) NULL,(void *) NULL);
2074 (void) SetImageProgressMonitor(*image,MonitorProgress,
2078 if (LocaleCompare("monochrome",option+1) == 0)
2080 (void) SyncImageSettings(mogrify_info,*image);
2081 (void) SetImageType(*image,BilevelType);
2082 InheritException(exception,&(*image)->exception);
2085 if (LocaleCompare("morphology",option+1) == 0)
2088 token[MaxTextExtent];
2103 Morphological Image Operation
2105 (void) SyncImageSettings(mogrify_info,*image);
2107 GetMagickToken(p,&p,token);
2108 method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions,
2111 GetMagickToken(p,&p,token);
2112 if ((*p == ':') || (*p == ','))
2113 GetMagickToken(p,&p,token);
2115 iterations=(ssize_t) StringToLong(p);
2116 kernel=AcquireKernelInfo(argv[i+2]);
2117 if (kernel == (KernelInfo *) NULL)
2119 (void) ThrowMagickException(exception,GetMagickModule(),
2120 OptionError,"UnabletoParseKernel","morphology");
2124 mogrify_image=MorphologyImage(*image,method,iterations,kernel,
2126 kernel=DestroyKernelInfo(kernel);
2129 if (LocaleCompare("motion-blur",option+1) == 0)
2134 (void) SyncImageSettings(mogrify_info,*image);
2135 flags=ParseGeometry(argv[i+1],&geometry_info);
2136 if ((flags & SigmaValue) == 0)
2137 geometry_info.sigma=1.0;
2138 mogrify_image=MotionBlurImage(*image,geometry_info.rho,
2139 geometry_info.sigma,geometry_info.xi,exception);
2146 if (LocaleCompare("negate",option+1) == 0)
2148 (void) SyncImageSettings(mogrify_info,*image);
2149 (void) NegateImage(*image,*option == '+' ? MagickTrue :
2151 InheritException(exception,&(*image)->exception);
2154 if (LocaleCompare("noise",option+1) == 0)
2156 (void) SyncImageSettings(mogrify_info,*image);
2159 (void) ParseGeometry(argv[i+1],&geometry_info);
2160 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)
2161 geometry_info.rho,(size_t) geometry_info.rho,exception);
2168 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,
2169 MagickFalse,argv[i+1]);
2170 mogrify_image=AddNoiseImage(*image,noise,exception);
2174 if (LocaleCompare("normalize",option+1) == 0)
2176 (void) SyncImageSettings(mogrify_info,*image);
2177 (void) NormalizeImage(*image);
2178 InheritException(exception,&(*image)->exception);
2185 if (LocaleCompare("opaque",option+1) == 0)
2190 (void) SyncImageSettings(mogrify_info,*image);
2191 (void) QueryMagickColor(argv[i+1],&target,exception);
2192 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?
2193 MagickFalse : MagickTrue);
2196 if (LocaleCompare("ordered-dither",option+1) == 0)
2198 (void) SyncImageSettings(mogrify_info,*image);
2199 (void) OrderedPosterizeImage(*image,argv[i+1],exception);
2206 if (LocaleCompare("paint",option+1) == 0)
2208 (void) SyncImageSettings(mogrify_info,*image);
2209 (void) ParseGeometry(argv[i+1],&geometry_info);
2210 mogrify_image=OilPaintImage(*image,geometry_info.rho,exception);
2213 if (LocaleCompare("pen",option+1) == 0)
2217 (void) QueryColorDatabase("none",&draw_info->fill,exception);
2220 (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
2223 if (LocaleCompare("pointsize",option+1) == 0)
2226 (void) ParseGeometry("12",&geometry_info);
2228 (void) ParseGeometry(argv[i+1],&geometry_info);
2229 draw_info->pointsize=geometry_info.rho;
2232 if (LocaleCompare("polaroid",option+1) == 0)
2241 Simulate a Polaroid picture.
2243 (void) SyncImageSettings(mogrify_info,*image);
2244 random_info=AcquireRandomInfo();
2245 angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
2246 random_info=DestroyRandomInfo(random_info);
2249 SetGeometryInfo(&geometry_info);
2250 flags=ParseGeometry(argv[i+1],&geometry_info);
2251 angle=geometry_info.rho;
2253 mogrify_image=PolaroidImage(*image,draw_info,angle,exception);
2256 if (LocaleCompare("posterize",option+1) == 0)
2261 (void) SyncImageSettings(mogrify_info,*image);
2262 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),
2263 quantize_info->dither);
2264 InheritException(exception,&(*image)->exception);
2267 if (LocaleCompare("preview",option+1) == 0)
2275 (void) SyncImageSettings(mogrify_info,*image);
2277 preview_type=UndefinedPreview;
2279 preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
2280 MagickFalse,argv[i+1]);
2281 mogrify_image=PreviewImage(*image,preview_type,exception);
2284 if (LocaleCompare("profile",option+1) == 0)
2298 (void) SyncImageSettings(mogrify_info,*image);
2302 Remove a profile from the image.
2304 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
2306 InheritException(exception,&(*image)->exception);
2310 Associate a profile with the image.
2312 profile_info=CloneImageInfo(mogrify_info);
2313 profile=GetImageProfile(*image,"iptc");
2314 if (profile != (StringInfo *) NULL)
2315 profile_info->profile=(void *) CloneStringInfo(profile);
2316 profile_image=GetImageCache(profile_info,argv[i+1],exception);
2317 profile_info=DestroyImageInfo(profile_info);
2318 if (profile_image == (Image *) NULL)
2323 profile_info=CloneImageInfo(mogrify_info);
2324 (void) CopyMagickString(profile_info->filename,argv[i+1],
2326 profile=FileToStringInfo(profile_info->filename,~0UL,exception);
2327 if (profile != (StringInfo *) NULL)
2329 (void) ProfileImage(*image,profile_info->magick,
2330 GetStringInfoDatum(profile),(size_t)
2331 GetStringInfoLength(profile),MagickFalse);
2332 profile=DestroyStringInfo(profile);
2334 profile_info=DestroyImageInfo(profile_info);
2337 ResetImageProfileIterator(profile_image);
2338 name=GetNextImageProfile(profile_image);
2339 while (name != (const char *) NULL)
2341 profile=GetImageProfile(profile_image,name);
2342 if (profile != (StringInfo *) NULL)
2343 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
2344 (size_t) GetStringInfoLength(profile),MagickFalse);
2345 name=GetNextImageProfile(profile_image);
2347 profile_image=DestroyImage(profile_image);
2354 if (LocaleCompare("quantize",option+1) == 0)
2358 quantize_info->colorspace=UndefinedColorspace;
2361 quantize_info->colorspace=(ColorspaceType) ParseCommandOption(
2362 MagickColorspaceOptions,MagickFalse,argv[i+1]);
2369 if (LocaleCompare("radial-blur",option+1) == 0)
2374 (void) SyncImageSettings(mogrify_info,*image);
2375 mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1],
2376 (char **) NULL),exception);
2379 if (LocaleCompare("raise",option+1) == 0)
2382 Surround image with a raise of solid color.
2384 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2385 if ((flags & SigmaValue) == 0)
2386 geometry.height=geometry.width;
2387 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
2389 InheritException(exception,&(*image)->exception);
2392 if (LocaleCompare("random-threshold",option+1) == 0)
2397 (void) SyncImageSettings(mogrify_info,*image);
2398 (void) RandomThresholdImage(*image,argv[i+1],exception);
2401 if (LocaleCompare("recolor",option+1) == 0)
2406 (void) SyncImageSettings(mogrify_info,*image);
2407 kernel=AcquireKernelInfo(argv[i+1]);
2408 if (kernel == (KernelInfo *) NULL)
2410 mogrify_image=ColorMatrixImage(*image,kernel,exception);
2411 kernel=DestroyKernelInfo(kernel);
2414 if (LocaleCompare("region",option+1) == 0)
2416 (void) SyncImageSettings(mogrify_info,*image);
2417 if (region_image != (Image *) NULL)
2422 (void) CompositeImage(region_image,region_image->matte !=
2423 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
2424 region_geometry.x,region_geometry.y);
2425 InheritException(exception,®ion_image->exception);
2426 *image=DestroyImage(*image);
2427 *image=region_image;
2428 region_image = (Image *) NULL;
2433 Apply transformations to a selected region of the image.
2435 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry,
2437 mogrify_image=CropImage(*image,®ion_geometry,exception);
2438 if (mogrify_image == (Image *) NULL)
2440 region_image=(*image);
2441 *image=mogrify_image;
2442 mogrify_image=(Image *) NULL;
2445 if (LocaleCompare("render",option+1) == 0)
2447 (void) SyncImageSettings(mogrify_info,*image);
2448 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
2451 if (LocaleCompare("remap",option+1) == 0)
2457 Transform image colors to match this set of colors.
2459 (void) SyncImageSettings(mogrify_info,*image);
2462 remap_image=GetImageCache(mogrify_info,argv[i+1],exception);
2463 if (remap_image == (Image *) NULL)
2465 (void) RemapImage(quantize_info,*image,remap_image);
2466 InheritException(exception,&(*image)->exception);
2467 remap_image=DestroyImage(remap_image);
2470 if (LocaleCompare("repage",option+1) == 0)
2474 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
2477 (void) ResetImagePage(*image,argv[i+1]);
2478 InheritException(exception,&(*image)->exception);
2481 if (LocaleCompare("resample",option+1) == 0)
2486 (void) SyncImageSettings(mogrify_info,*image);
2487 flags=ParseGeometry(argv[i+1],&geometry_info);
2488 if ((flags & SigmaValue) == 0)
2489 geometry_info.sigma=geometry_info.rho;
2490 mogrify_image=ResampleImage(*image,geometry_info.rho,
2491 geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
2494 if (LocaleCompare("resize",option+1) == 0)
2499 (void) SyncImageSettings(mogrify_info,*image);
2500 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2501 mogrify_image=ResizeImage(*image,geometry.width,geometry.height,
2502 (*image)->filter,(*image)->blur,exception);
2505 if (LocaleCompare("roll",option+1) == 0)
2510 (void) SyncImageSettings(mogrify_info,*image);
2511 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2512 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);
2515 if (LocaleCompare("rotate",option+1) == 0)
2521 Check for conditional image rotation.
2523 (void) SyncImageSettings(mogrify_info,*image);
2524 if (strchr(argv[i+1],'>') != (char *) NULL)
2525 if ((*image)->columns <= (*image)->rows)
2527 if (strchr(argv[i+1],'<') != (char *) NULL)
2528 if ((*image)->columns >= (*image)->rows)
2533 geometry=ConstantString(argv[i+1]);
2534 (void) SubstituteString(&geometry,">","");
2535 (void) SubstituteString(&geometry,"<","");
2536 (void) ParseGeometry(geometry,&geometry_info);
2537 geometry=DestroyString(geometry);
2538 mogrify_image=RotateImage(*image,geometry_info.rho,exception);
2545 if (LocaleCompare("sample",option+1) == 0)
2548 Sample image with pixel replication.
2550 (void) SyncImageSettings(mogrify_info,*image);
2551 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2552 mogrify_image=SampleImage(*image,geometry.width,geometry.height,
2556 if (LocaleCompare("scale",option+1) == 0)
2561 (void) SyncImageSettings(mogrify_info,*image);
2562 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2563 mogrify_image=ScaleImage(*image,geometry.width,geometry.height,
2567 if (LocaleCompare("selective-blur",option+1) == 0)
2570 Selectively blur pixels within a contrast threshold.
2572 (void) SyncImageSettings(mogrify_info,*image);
2573 flags=ParseGeometry(argv[i+1],&geometry_info);
2574 if ((flags & PercentValue) != 0)
2575 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
2576 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,
2577 geometry_info.sigma,geometry_info.xi,exception);
2580 if (LocaleCompare("separate",option+1) == 0)
2583 Break channels into separate images.
2585 (void) SyncImageSettings(mogrify_info,*image);
2586 mogrify_image=SeparateImages(*image,exception);
2589 if (LocaleCompare("sepia-tone",option+1) == 0)
2597 (void) SyncImageSettings(mogrify_info,*image);
2598 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2599 mogrify_image=SepiaToneImage(*image,threshold,exception);
2602 if (LocaleCompare("segment",option+1) == 0)
2607 (void) SyncImageSettings(mogrify_info,*image);
2608 flags=ParseGeometry(argv[i+1],&geometry_info);
2609 if ((flags & SigmaValue) == 0)
2610 geometry_info.sigma=1.0;
2611 (void) SegmentImage(*image,(*image)->colorspace,
2612 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma);
2613 InheritException(exception,&(*image)->exception);
2616 if (LocaleCompare("set",option+1) == 0)
2626 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2627 (void) DeleteImageRegistry(argv[i+1]+9);
2629 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2631 (void) DeleteImageOption(mogrify_info,argv[i+1]+7);
2632 (void) DeleteImageArtifact(*image,argv[i+1]+7);
2635 (void) DeleteImageProperty(*image,argv[i+1]);
2638 value=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2639 if (value == (char *) NULL)
2641 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
2642 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,
2645 if (LocaleNCompare(argv[i+1],"option:",7) == 0)
2647 (void) SetImageOption(image_info,argv[i+1]+7,value);
2648 (void) SetImageOption(mogrify_info,argv[i+1]+7,value);
2649 (void) SetImageArtifact(*image,argv[i+1]+7,value);
2652 (void) SetImageProperty(*image,argv[i+1],value);
2653 value=DestroyString(value);
2656 if (LocaleCompare("shade",option+1) == 0)
2661 (void) SyncImageSettings(mogrify_info,*image);
2662 flags=ParseGeometry(argv[i+1],&geometry_info);
2663 if ((flags & SigmaValue) == 0)
2664 geometry_info.sigma=1.0;
2665 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
2666 MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
2669 if (LocaleCompare("shadow",option+1) == 0)
2674 (void) SyncImageSettings(mogrify_info,*image);
2675 flags=ParseGeometry(argv[i+1],&geometry_info);
2676 if ((flags & SigmaValue) == 0)
2677 geometry_info.sigma=1.0;
2678 if ((flags & XiValue) == 0)
2679 geometry_info.xi=4.0;
2680 if ((flags & PsiValue) == 0)
2681 geometry_info.psi=4.0;
2682 mogrify_image=ShadowImage(*image,geometry_info.rho,
2683 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
2684 ceil(geometry_info.psi-0.5),exception);
2687 if (LocaleCompare("sharpen",option+1) == 0)
2692 (void) SyncImageSettings(mogrify_info,*image);
2693 flags=ParseGeometry(argv[i+1],&geometry_info);
2694 if ((flags & SigmaValue) == 0)
2695 geometry_info.sigma=1.0;
2696 mogrify_image=SharpenImage(*image,geometry_info.rho,
2697 geometry_info.sigma,exception);
2700 if (LocaleCompare("shave",option+1) == 0)
2703 Shave the image edges.
2705 (void) SyncImageSettings(mogrify_info,*image);
2706 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
2707 mogrify_image=ShaveImage(*image,&geometry,exception);
2710 if (LocaleCompare("shear",option+1) == 0)
2715 (void) SyncImageSettings(mogrify_info,*image);
2716 flags=ParseGeometry(argv[i+1],&geometry_info);
2717 if ((flags & SigmaValue) == 0)
2718 geometry_info.sigma=geometry_info.rho;
2719 mogrify_image=ShearImage(*image,geometry_info.rho,
2720 geometry_info.sigma,exception);
2723 if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
2726 Sigmoidal non-linearity contrast control.
2728 (void) SyncImageSettings(mogrify_info,*image);
2729 flags=ParseGeometry(argv[i+1],&geometry_info);
2730 if ((flags & SigmaValue) == 0)
2731 geometry_info.sigma=(double) QuantumRange/2.0;
2732 if ((flags & PercentValue) != 0)
2733 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
2735 (void) SigmoidalContrastImage(*image,(*option == '-') ?
2736 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma);
2737 InheritException(exception,&(*image)->exception);
2740 if (LocaleCompare("sketch",option+1) == 0)
2745 (void) SyncImageSettings(mogrify_info,*image);
2746 flags=ParseGeometry(argv[i+1],&geometry_info);
2747 if ((flags & SigmaValue) == 0)
2748 geometry_info.sigma=1.0;
2749 mogrify_image=SketchImage(*image,geometry_info.rho,
2750 geometry_info.sigma,geometry_info.xi,exception);
2753 if (LocaleCompare("solarize",option+1) == 0)
2758 (void) SyncImageSettings(mogrify_info,*image);
2759 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2760 (void) SolarizeImage(*image,threshold);
2761 InheritException(exception,&(*image)->exception);
2764 if (LocaleCompare("sparse-color",option+1) == 0)
2773 Sparse Color Interpolated Gradient
2775 (void) SyncImageSettings(mogrify_info,*image);
2776 method=(SparseColorMethod) ParseCommandOption(
2777 MagickSparseColorOptions,MagickFalse,argv[i+1]);
2778 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]);
2779 InheritException(exception,&(*image)->exception);
2780 if (arguments == (char *) NULL)
2782 mogrify_image=SparseColorOption(*image,channel,method,arguments,
2783 option[0] == '+' ? MagickTrue : MagickFalse,exception);
2784 arguments=DestroyString(arguments);
2787 if (LocaleCompare("splice",option+1) == 0)
2790 Splice a solid color into the image.
2792 (void) SyncImageSettings(mogrify_info,*image);
2793 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
2794 mogrify_image=SpliceImage(*image,&geometry,exception);
2797 if (LocaleCompare("spread",option+1) == 0)
2802 (void) SyncImageSettings(mogrify_info,*image);
2803 (void) ParseGeometry(argv[i+1],&geometry_info);
2804 mogrify_image=SpreadImage(*image,geometry_info.rho,exception);
2807 if (LocaleCompare("statistic",option+1) == 0)
2812 (void) SyncImageSettings(mogrify_info,*image);
2813 type=(StatisticType) ParseCommandOption(MagickStatisticOptions,
2814 MagickFalse,argv[i+1]);
2815 (void) ParseGeometry(argv[i+2],&geometry_info);
2816 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,
2817 (size_t) geometry_info.sigma,exception);
2820 if (LocaleCompare("stretch",option+1) == 0)
2824 draw_info->stretch=UndefinedStretch;
2827 draw_info->stretch=(StretchType) ParseCommandOption(
2828 MagickStretchOptions,MagickFalse,argv[i+1]);
2831 if (LocaleCompare("strip",option+1) == 0)
2834 Strip image of profiles and comments.
2836 (void) SyncImageSettings(mogrify_info,*image);
2837 (void) StripImage(*image);
2838 InheritException(exception,&(*image)->exception);
2841 if (LocaleCompare("stroke",option+1) == 0)
2848 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
2849 if (draw_info->stroke_pattern != (Image *) NULL)
2850 draw_info->stroke_pattern=DestroyImage(
2851 draw_info->stroke_pattern);
2854 sans=AcquireExceptionInfo();
2855 status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
2856 sans=DestroyExceptionInfo(sans);
2857 if (status == MagickFalse)
2858 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],
2862 if (LocaleCompare("strokewidth",option+1) == 0)
2864 draw_info->stroke_width=InterpretLocaleValue(argv[i+1],
2868 if (LocaleCompare("style",option+1) == 0)
2872 draw_info->style=UndefinedStyle;
2875 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
2876 MagickFalse,argv[i+1]);
2879 if (LocaleCompare("swirl",option+1) == 0)
2884 (void) SyncImageSettings(mogrify_info,*image);
2885 (void) ParseGeometry(argv[i+1],&geometry_info);
2886 mogrify_image=SwirlImage(*image,geometry_info.rho,exception);
2893 if (LocaleCompare("threshold",option+1) == 0)
2901 (void) SyncImageSettings(mogrify_info,*image);
2903 threshold=(double) QuantumRange/2;
2905 threshold=SiPrefixToDouble(argv[i+1],QuantumRange);
2906 (void) BilevelImage(*image,threshold);
2907 InheritException(exception,&(*image)->exception);
2910 if (LocaleCompare("thumbnail",option+1) == 0)
2915 (void) SyncImageSettings(mogrify_info,*image);
2916 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
2917 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,
2921 if (LocaleCompare("tile",option+1) == 0)
2925 if (draw_info->fill_pattern != (Image *) NULL)
2926 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
2929 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],
2933 if (LocaleCompare("tint",option+1) == 0)
2938 (void) SyncImageSettings(mogrify_info,*image);
2939 mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
2942 if (LocaleCompare("transform",option+1) == 0)
2945 Affine transform image.
2947 (void) SyncImageSettings(mogrify_info,*image);
2948 mogrify_image=AffineTransformImage(*image,&draw_info->affine,
2952 if (LocaleCompare("transparent",option+1) == 0)
2957 (void) SyncImageSettings(mogrify_info,*image);
2958 (void) QueryMagickColor(argv[i+1],&target,exception);
2959 (void) TransparentPaintImage(*image,&target,(Quantum)
2960 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue);
2961 InheritException(exception,&(*image)->exception);
2964 if (LocaleCompare("transpose",option+1) == 0)
2967 Transpose image scanlines.
2969 (void) SyncImageSettings(mogrify_info,*image);
2970 mogrify_image=TransposeImage(*image,exception);
2973 if (LocaleCompare("transverse",option+1) == 0)
2976 Transverse image scanlines.
2978 (void) SyncImageSettings(mogrify_info,*image);
2979 mogrify_image=TransverseImage(*image,exception);
2982 if (LocaleCompare("treedepth",option+1) == 0)
2984 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);
2987 if (LocaleCompare("trim",option+1) == 0)
2992 (void) SyncImageSettings(mogrify_info,*image);
2993 mogrify_image=TrimImage(*image,exception);
2996 if (LocaleCompare("type",option+1) == 0)
3001 (void) SyncImageSettings(mogrify_info,*image);
3005 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3007 (*image)->type=UndefinedType;
3008 (void) SetImageType(*image,type);
3009 InheritException(exception,&(*image)->exception);
3016 if (LocaleCompare("undercolor",option+1) == 0)
3018 (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
3022 if (LocaleCompare("unique",option+1) == 0)
3026 (void) DeleteImageArtifact(*image,"identify:unique-colors");
3029 (void) SetImageArtifact(*image,"identify:unique-colors","true");
3030 (void) SetImageArtifact(*image,"verbose","true");
3033 if (LocaleCompare("unique-colors",option+1) == 0)
3036 Unique image colors.
3038 (void) SyncImageSettings(mogrify_info,*image);
3039 mogrify_image=UniqueImageColors(*image,exception);
3042 if (LocaleCompare("unsharp",option+1) == 0)
3047 (void) SyncImageSettings(mogrify_info,*image);
3048 flags=ParseGeometry(argv[i+1],&geometry_info);
3049 if ((flags & SigmaValue) == 0)
3050 geometry_info.sigma=1.0;
3051 if ((flags & XiValue) == 0)
3052 geometry_info.xi=1.0;
3053 if ((flags & PsiValue) == 0)
3054 geometry_info.psi=0.05;
3055 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,
3056 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
3063 if (LocaleCompare("verbose",option+1) == 0)
3065 (void) SetImageArtifact(*image,option+1,
3066 *option == '+' ? "false" : "true");
3069 if (LocaleCompare("vignette",option+1) == 0)
3074 (void) SyncImageSettings(mogrify_info,*image);
3075 flags=ParseGeometry(argv[i+1],&geometry_info);
3076 if ((flags & SigmaValue) == 0)
3077 geometry_info.sigma=1.0;
3078 if ((flags & XiValue) == 0)
3079 geometry_info.xi=0.1*(*image)->columns;
3080 if ((flags & PsiValue) == 0)
3081 geometry_info.psi=0.1*(*image)->rows;
3082 mogrify_image=VignetteImage(*image,geometry_info.rho,
3083 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
3084 ceil(geometry_info.psi-0.5),exception);
3087 if (LocaleCompare("virtual-pixel",option+1) == 0)
3091 (void) SetImageVirtualPixelMethod(*image,
3092 UndefinedVirtualPixelMethod);
3095 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3096 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3104 if (LocaleCompare("wave",option+1) == 0)
3109 (void) SyncImageSettings(mogrify_info,*image);
3110 flags=ParseGeometry(argv[i+1],&geometry_info);
3111 if ((flags & SigmaValue) == 0)
3112 geometry_info.sigma=1.0;
3113 mogrify_image=WaveImage(*image,geometry_info.rho,
3114 geometry_info.sigma,exception);
3117 if (LocaleCompare("weight",option+1) == 0)
3119 draw_info->weight=StringToUnsignedLong(argv[i+1]);
3120 if (LocaleCompare(argv[i+1],"all") == 0)
3121 draw_info->weight=0;
3122 if (LocaleCompare(argv[i+1],"bold") == 0)
3123 draw_info->weight=700;
3124 if (LocaleCompare(argv[i+1],"bolder") == 0)
3125 if (draw_info->weight <= 800)
3126 draw_info->weight+=100;
3127 if (LocaleCompare(argv[i+1],"lighter") == 0)
3128 if (draw_info->weight >= 100)
3129 draw_info->weight-=100;
3130 if (LocaleCompare(argv[i+1],"normal") == 0)
3131 draw_info->weight=400;
3134 if (LocaleCompare("white-threshold",option+1) == 0)
3137 White threshold image.
3139 (void) SyncImageSettings(mogrify_info,*image);
3140 (void) WhiteThresholdImage(*image,argv[i+1],exception);
3141 InheritException(exception,&(*image)->exception);
3150 Replace current image with any image that was generated
3152 if (mogrify_image != (Image *) NULL)
3153 ReplaceImageInListReturnLast(image,mogrify_image);
3156 if (region_image != (Image *) NULL)
3159 Composite transformed region onto image.
3161 (void) SyncImageSettings(mogrify_info,*image);
3162 (void) CompositeImage(region_image,region_image->matte !=
3163 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image,
3164 region_geometry.x,region_geometry.y);
3165 InheritException(exception,®ion_image->exception);
3166 *image=DestroyImage(*image);
3167 *image=region_image;
3168 region_image = (Image *) NULL;
3173 quantize_info=DestroyQuantizeInfo(quantize_info);
3174 draw_info=DestroyDrawInfo(draw_info);
3175 mogrify_info=DestroyImageInfo(mogrify_info);
3176 status=(MagickStatusType) ((*image)->exception.severity ==
3177 UndefinedException ? 1 : 0);
3178 return(status == 0 ? MagickFalse : MagickTrue);
3182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3186 + M o g r i f y I m a g e C o m m a n d %
3190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3192 % MogrifyImageCommand() transforms an image or a sequence of images. These
3193 % transforms include image scaling, image rotation, color reduction, and
3194 % others. The transmogrified image overwrites the original image.
3196 % The format of the MogrifyImageCommand method is:
3198 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
3199 % const char **argv,char **metadata,ExceptionInfo *exception)
3201 % A description of each parameter follows:
3203 % o image_info: the image info.
3205 % o argc: the number of elements in the argument vector.
3207 % o argv: A text array containing the command line arguments.
3209 % o metadata: any metadata is returned here.
3211 % o exception: return any errors or warnings in this structure.
3215 static MagickBooleanType MogrifyUsage(void)
3220 "-debug events display copious debugging information",
3221 "-help print program options",
3222 "-list type print a list of supported option arguments",
3223 "-log format format of debugging information",
3224 "-version print version information",
3229 "-adaptive-blur geometry",
3230 " adaptively blur pixels; decrease effect near edges",
3231 "-adaptive-resize geometry",
3232 " adaptively resize image using 'mesh' interpolation",
3233 "-adaptive-sharpen geometry",
3234 " adaptively sharpen pixels; increase effect near edges",
3235 "-alpha option on, activate, off, deactivate, set, opaque, copy",
3236 " transparent, extract, background, or shape",
3237 "-annotate geometry text",
3238 " annotate the image with text",
3239 "-auto-gamma automagically adjust gamma level of image",
3240 "-auto-level automagically adjust color levels of image",
3241 "-auto-orient automagically orient (rotate) image",
3242 "-bench iterations measure performance",
3243 "-black-threshold value",
3244 " force all pixels below the threshold into black",
3245 "-blue-shift simulate a scene at nighttime in the moonlight",
3246 "-blur geometry reduce image noise and reduce detail levels",
3247 "-border geometry surround image with a border of color",
3248 "-bordercolor color border color",
3249 "-brightness-contrast geometry",
3250 " improve brightness / contrast of the image",
3251 "-cdl filename color correct with a color decision list",
3252 "-charcoal radius simulate a charcoal drawing",
3253 "-chop geometry remove pixels from the image interior",
3254 "-clamp restrict pixel range from 0 to the quantum depth",
3255 "-clip clip along the first path from the 8BIM profile",
3256 "-clip-mask filename associate a clip mask with the image",
3257 "-clip-path id clip along a named path from the 8BIM profile",
3258 "-colorize value colorize the image with the fill color",
3259 "-color-matrix matrix apply color correction to the image",
3260 "-contrast enhance or reduce the image contrast",
3261 "-contrast-stretch geometry",
3262 " improve contrast by `stretching' the intensity range",
3263 "-convolve coefficients",
3264 " apply a convolution kernel to the image",
3265 "-cycle amount cycle the image colormap",
3266 "-decipher filename convert cipher pixels to plain pixels",
3267 "-deskew threshold straighten an image",
3268 "-despeckle reduce the speckles within an image",
3269 "-distort method args",
3270 " distort images according to given method ad args",
3271 "-draw string annotate the image with a graphic primitive",
3272 "-edge radius apply a filter to detect edges in the image",
3273 "-encipher filename convert plain pixels to cipher pixels",
3274 "-emboss radius emboss an image",
3275 "-enhance apply a digital filter to enhance a noisy image",
3276 "-equalize perform histogram equalization to an image",
3277 "-evaluate operator value",
3278 " evaluate an arithmetic, relational, or logical expression",
3279 "-extent geometry set the image size",
3280 "-extract geometry extract area from image",
3281 "-fft implements the discrete Fourier transform (DFT)",
3282 "-flip flip image vertically",
3283 "-floodfill geometry color",
3284 " floodfill the image with color",
3285 "-flop flop image horizontally",
3286 "-frame geometry surround image with an ornamental border",
3287 "-function name parameters",
3288 " apply function over image values",
3289 "-gamma value level of gamma correction",
3290 "-gaussian-blur geometry",
3291 " reduce image noise and reduce detail levels",
3292 "-geometry geometry preferred size or location of the image",
3293 "-identify identify the format and characteristics of the image",
3294 "-ift implements the inverse discrete Fourier transform (DFT)",
3295 "-implode amount implode image pixels about the center",
3296 "-lat geometry local adaptive thresholding",
3297 "-layers method optimize, merge, or compare image layers",
3298 "-level value adjust the level of image contrast",
3299 "-level-colors color,color",
3300 " level image with the given colors",
3301 "-linear-stretch geometry",
3302 " improve contrast by `stretching with saturation'",
3303 "-liquid-rescale geometry",
3304 " rescale image with seam-carving",
3305 "-median geometry apply a median filter to the image",
3306 "-mode geometry make each pixel the 'predominant color' of the neighborhood",
3307 "-modulate value vary the brightness, saturation, and hue",
3308 "-monochrome transform image to black and white",
3309 "-morphology method kernel",
3310 " apply a morphology method to the image",
3311 "-motion-blur geometry",
3312 " simulate motion blur",
3313 "-negate replace every pixel with its complementary color ",
3314 "-noise geometry add or reduce noise in an image",
3315 "-normalize transform image to span the full range of colors",
3316 "-opaque color change this color to the fill color",
3317 "-ordered-dither NxN",
3318 " add a noise pattern to the image with specific",
3320 "-paint radius simulate an oil painting",
3321 "-polaroid angle simulate a Polaroid picture",
3322 "-posterize levels reduce the image to a limited number of color levels",
3323 "-profile filename add, delete, or apply an image profile",
3324 "-quantize colorspace reduce colors in this colorspace",
3325 "-radial-blur angle radial blur the image",
3326 "-raise value lighten/darken image edges to create a 3-D effect",
3327 "-random-threshold low,high",
3328 " random threshold the image",
3329 "-region geometry apply options to a portion of the image",
3330 "-render render vector graphics",
3331 "-repage geometry size and location of an image canvas",
3332 "-resample geometry change the resolution of an image",
3333 "-resize geometry resize the image",
3334 "-roll geometry roll an image vertically or horizontally",
3335 "-rotate degrees apply Paeth rotation to the image",
3336 "-sample geometry scale image with pixel sampling",
3337 "-scale geometry scale the image",
3338 "-segment values segment an image",
3339 "-selective-blur geometry",
3340 " selectively blur pixels within a contrast threshold",
3341 "-sepia-tone threshold",
3342 " simulate a sepia-toned photo",
3343 "-set property value set an image property",
3344 "-shade degrees shade the image using a distant light source",
3345 "-shadow geometry simulate an image shadow",
3346 "-sharpen geometry sharpen the image",
3347 "-shave geometry shave pixels from the image edges",
3348 "-shear geometry slide one edge of the image along the X or Y axis",
3349 "-sigmoidal-contrast geometry",
3350 " increase the contrast without saturating highlights or shadows",
3351 "-sketch geometry simulate a pencil sketch",
3352 "-solarize threshold negate all pixels above the threshold level",
3353 "-sparse-color method args",
3354 " fill in a image based on a few color points",
3355 "-splice geometry splice the background color into the image",
3356 "-spread radius displace image pixels by a random amount",
3357 "-statistic type radius",
3358 " replace each pixel with corresponding statistic from the neighborhood",
3359 "-strip strip image of all profiles and comments",
3360 "-swirl degrees swirl image pixels about the center",
3361 "-threshold value threshold the image",
3362 "-thumbnail geometry create a thumbnail of the image",
3363 "-tile filename tile image when filling a graphic primitive",
3364 "-tint value tint the image with the fill color",
3365 "-transform affine transform image",
3366 "-transparent color make this color transparent within the image",
3367 "-transpose flip image vertically and rotate 90 degrees",
3368 "-transverse flop image horizontally and rotate 270 degrees",
3369 "-trim trim image edges",
3370 "-type type image type",
3371 "-unique-colors discard all but one of any pixel color",
3372 "-unsharp geometry sharpen the image",
3373 "-vignette geometry soften the edges of the image in vignette style",
3374 "-wave geometry alter an image along a sine wave",
3375 "-white-threshold value",
3376 " force all pixels above the threshold into white",
3379 *sequence_operators[]=
3381 "-append append an image sequence",
3382 "-clut apply a color lookup table to the image",
3383 "-coalesce merge a sequence of images",
3384 "-combine combine a sequence of images",
3385 "-composite composite image",
3386 "-crop geometry cut out a rectangular region of the image",
3387 "-deconstruct break down an image sequence into constituent parts",
3388 "-evaluate-sequence operator",
3389 " evaluate an arithmetic, relational, or logical expression",
3390 "-flatten flatten a sequence of images",
3391 "-fx expression apply mathematical expression to an image channel(s)",
3392 "-hald-clut apply a Hald color lookup table to the image",
3393 "-morph value morph an image sequence",
3394 "-mosaic create a mosaic from an image sequence",
3395 "-print string interpret string and print to console",
3396 "-process arguments process the image with a custom image filter",
3397 "-separate separate an image channel into a grayscale image",
3398 "-smush geometry smush an image sequence together",
3399 "-write filename write images to this file",
3404 "-adjoin join images into a single multi-image file",
3405 "-affine matrix affine transform matrix",
3406 "-alpha option activate, deactivate, reset, or set the alpha channel",
3407 "-antialias remove pixel-aliasing",
3408 "-authenticate password",
3409 " decipher image with this password",
3410 "-attenuate value lessen (or intensify) when adding noise to an image",
3411 "-background color background color",
3412 "-bias value add bias when convolving an image",
3413 "-black-point-compensation",
3414 " use black point compensation",
3415 "-blue-primary point chromaticity blue primary point",
3416 "-bordercolor color border color",
3417 "-caption string assign a caption to an image",
3418 "-channel type apply option to select image channels",
3419 "-colors value preferred number of colors in the image",
3420 "-colorspace type alternate image colorspace",
3421 "-comment string annotate image with comment",
3422 "-compose operator set image composite operator",
3423 "-compress type type of pixel compression when writing the image",
3424 "-define format:option",
3425 " define one or more image format options",
3426 "-delay value display the next image after pausing",
3427 "-density geometry horizontal and vertical density of the image",
3428 "-depth value image depth",
3429 "-direction type render text right-to-left or left-to-right",
3430 "-display server get image or font from this X server",
3431 "-dispose method layer disposal method",
3432 "-dither method apply error diffusion to image",
3433 "-encoding type text encoding type",
3434 "-endian type endianness (MSB or LSB) of the image",
3435 "-family name render text with this font family",
3436 "-fill color color to use when filling a graphic primitive",
3437 "-filter type use this filter when resizing an image",
3438 "-font name render text with this font",
3439 "-format \"string\" output formatted image characteristics",
3440 "-fuzz distance colors within this distance are considered equal",
3441 "-gravity type horizontal and vertical text placement",
3442 "-green-primary point chromaticity green primary point",
3443 "-intent type type of rendering intent when managing the image color",
3444 "-interlace type type of image interlacing scheme",
3445 "-interline-spacing value",
3446 " set the space between two text lines",
3447 "-interpolate method pixel color interpolation method",
3448 "-interword-spacing value",
3449 " set the space between two words",
3450 "-kerning value set the space between two letters",
3451 "-label string assign a label to an image",
3452 "-limit type value pixel cache resource limit",
3453 "-loop iterations add Netscape loop extension to your GIF animation",
3454 "-mask filename associate a mask with the image",
3455 "-mattecolor color frame color",
3456 "-monitor monitor progress",
3457 "-orient type image orientation",
3458 "-page geometry size and location of an image canvas (setting)",
3459 "-ping efficiently determine image attributes",
3460 "-pointsize value font point size",
3461 "-precision value maximum number of significant digits to print",
3462 "-preview type image preview type",
3463 "-quality value JPEG/MIFF/PNG compression level",
3464 "-quiet suppress all warning messages",
3465 "-red-primary point chromaticity red primary point",
3466 "-regard-warnings pay attention to warning messages",
3467 "-remap filename transform image colors to match this set of colors",
3468 "-respect-parentheses settings remain in effect until parenthesis boundary",
3469 "-sampling-factor geometry",
3470 " horizontal and vertical sampling factor",
3471 "-scene value image scene number",
3472 "-seed value seed a new sequence of pseudo-random numbers",
3473 "-size geometry width and height of image",
3474 "-stretch type render text with this font stretch",
3475 "-stroke color graphic primitive stroke color",
3476 "-strokewidth value graphic primitive stroke width",
3477 "-style type render text with this font style",
3478 "-synchronize synchronize image to storage device",
3479 "-taint declare the image as modified",
3480 "-texture filename name of texture to tile onto the image background",
3481 "-tile-offset geometry",
3483 "-treedepth value color tree depth",
3484 "-transparent-color color",
3485 " transparent color",
3486 "-undercolor color annotation bounding box color",
3487 "-units type the units of image resolution",
3488 "-verbose print detailed information about the image",
3489 "-view FlashPix viewing transforms",
3490 "-virtual-pixel method",
3491 " virtual pixel access method",
3492 "-weight type render text with this font weight",
3493 "-white-point point chromaticity white point",
3498 "-delete indexes delete the image from the image sequence",
3499 "-duplicate count,indexes",
3500 " duplicate an image one or more times",
3501 "-insert index insert last image into the image sequence",
3502 "-reverse reverse image sequence",
3503 "-swap indexes swap two images in the image sequence",
3510 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
3511 (void) printf("Copyright: %s\n",GetMagickCopyright());
3512 (void) printf("Features: %s\n\n",GetMagickFeatures());
3513 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
3515 (void) printf("\nImage Settings:\n");
3516 for (p=settings; *p != (char *) NULL; p++)
3517 (void) printf(" %s\n",*p);
3518 (void) printf("\nImage Operators:\n");
3519 for (p=operators; *p != (char *) NULL; p++)
3520 (void) printf(" %s\n",*p);
3521 (void) printf("\nImage Sequence Operators:\n");
3522 for (p=sequence_operators; *p != (char *) NULL; p++)
3523 (void) printf(" %s\n",*p);
3524 (void) printf("\nImage Stack Operators:\n");
3525 for (p=stack_operators; *p != (char *) NULL; p++)
3526 (void) printf(" %s\n",*p);
3527 (void) printf("\nMiscellaneous Options:\n");
3528 for (p=miscellaneous; *p != (char *) NULL; p++)
3529 (void) printf(" %s\n",*p);
3531 "\nBy default, the image format of `file' is determined by its magic\n");
3533 "number. To specify a particular image format, precede the filename\n");
3535 "with an image format name and a colon (i.e. ps:image) or specify the\n");
3537 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
3538 (void) printf("'-' for standard input or output.\n");
3539 return(MagickFalse);
3542 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
3543 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
3545 #define DestroyMogrify() \
3547 if (format != (char *) NULL) \
3548 format=DestroyString(format); \
3549 if (path != (char *) NULL) \
3550 path=DestroyString(path); \
3551 DestroyImageStack(); \
3552 for (i=0; i < (ssize_t) argc; i++) \
3553 argv[i]=DestroyString(argv[i]); \
3554 argv=(char **) RelinquishMagickMemory(argv); \
3556 #define ThrowMogrifyException(asperity,tag,option) \
3558 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
3561 return(MagickFalse); \
3563 #define ThrowMogrifyInvalidArgumentException(option,argument) \
3565 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
3566 "InvalidArgument","`%s': %s",argument,option); \
3568 return(MagickFalse); \
3580 image_stack[MaxImageStackDepth+1];
3588 respect_parenthesis;
3603 assert(image_info != (ImageInfo *) NULL);
3604 assert(image_info->signature == MagickSignature);
3605 if (image_info->debug != MagickFalse)
3606 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3607 assert(exception != (ExceptionInfo *) NULL);
3611 if ((LocaleCompare("version",option+1) == 0) ||
3612 (LocaleCompare("-version",option+1) == 0))
3614 (void) FormatLocaleFile(stdout,"Version: %s\n",
3615 GetMagickVersion((size_t *) NULL));
3616 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
3617 GetMagickCopyright());
3618 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
3619 GetMagickFeatures());
3620 return(MagickFalse);
3624 return(MogrifyUsage());
3625 format=(char *) NULL;
3627 global_colormap=MagickFalse;
3631 option=(char *) NULL;
3633 respect_parenthesis=MagickFalse;
3638 ReadCommandlLine(argc,&argv);
3639 status=ExpandFilenames(&argc,&argv);
3640 if (status == MagickFalse)
3641 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
3642 GetExceptionMessage(errno));
3643 for (i=1; i < (ssize_t) argc; i++)
3646 if (LocaleCompare(option,"(") == 0)
3648 FireImageStack(MagickFalse,MagickTrue,pend);
3649 if (k == MaxImageStackDepth)
3650 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
3655 if (LocaleCompare(option,")") == 0)
3657 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
3659 ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
3663 if (IsCommandOption(option) == MagickFalse)
3666 backup_filename[MaxTextExtent],
3673 Option is a file name: begin by reading image from specified file.
3675 FireImageStack(MagickFalse,MagickFalse,pend);
3677 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
3679 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3680 images=ReadImages(image_info,exception);
3681 status&=(images != (Image *) NULL) &&
3682 (exception->severity < ErrorException);
3683 if (images == (Image *) NULL)
3685 if (format != (char *) NULL)
3686 (void) CopyMagickString(images->filename,images->magick_filename,
3688 if (path != (char *) NULL)
3690 GetPathComponent(option,TailPath,filename);
3691 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s",
3692 path,*DirectorySeparator,filename);
3694 if (format != (char *) NULL)
3695 AppendImageFormat(format,images->filename);
3696 AppendImageStack(images);
3697 FinalizeImageSettings(image_info,image,MagickFalse);
3698 if (global_colormap != MagickFalse)
3703 quantize_info=AcquireQuantizeInfo(image_info);
3704 (void) RemapImages(quantize_info,images,(Image *) NULL);
3705 quantize_info=DestroyQuantizeInfo(quantize_info);
3707 *backup_filename='\0';
3708 if ((LocaleCompare(image->filename,"-") != 0) &&
3709 (IsPathWritable(image->filename) != MagickFalse))
3715 Rename image file as backup.
3717 (void) CopyMagickString(backup_filename,image->filename,
3719 for (i=0; i < 6; i++)
3721 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
3722 if (IsPathAccessible(backup_filename) == MagickFalse)
3725 if ((IsPathAccessible(backup_filename) != MagickFalse) ||
3726 (rename(image->filename,backup_filename) != 0))
3727 *backup_filename='\0';
3730 Write transmogrified image to disk.
3732 image_info->synchronize=MagickTrue;
3733 status&=WriteImages(image_info,image,image->filename,exception);
3734 if ((status == MagickFalse) && (*backup_filename != '\0'))
3735 (void) remove(backup_filename);
3736 RemoveAllImageStack();
3739 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3740 switch (*(option+1))
3744 if (LocaleCompare("adaptive-blur",option+1) == 0)
3747 if (i == (ssize_t) argc)
3748 ThrowMogrifyException(OptionError,"MissingArgument",option);
3749 if (IsGeometry(argv[i]) == MagickFalse)
3750 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3753 if (LocaleCompare("adaptive-resize",option+1) == 0)
3756 if (i == (ssize_t) argc)
3757 ThrowMogrifyException(OptionError,"MissingArgument",option);
3758 if (IsGeometry(argv[i]) == MagickFalse)
3759 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3762 if (LocaleCompare("adaptive-sharpen",option+1) == 0)
3765 if (i == (ssize_t) argc)
3766 ThrowMogrifyException(OptionError,"MissingArgument",option);
3767 if (IsGeometry(argv[i]) == MagickFalse)
3768 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3771 if (LocaleCompare("affine",option+1) == 0)
3776 if (i == (ssize_t) argc)
3777 ThrowMogrifyException(OptionError,"MissingArgument",option);
3780 if (LocaleCompare("alpha",option+1) == 0)
3788 if (i == (ssize_t) argc)
3789 ThrowMogrifyException(OptionError,"MissingArgument",option);
3790 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
3792 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
3796 if (LocaleCompare("annotate",option+1) == 0)
3801 if (i == (ssize_t) argc)
3802 ThrowMogrifyException(OptionError,"MissingArgument",option);
3803 if (IsGeometry(argv[i]) == MagickFalse)
3804 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3805 if (i == (ssize_t) argc)
3806 ThrowMogrifyException(OptionError,"MissingArgument",option);
3810 if (LocaleCompare("antialias",option+1) == 0)
3812 if (LocaleCompare("append",option+1) == 0)
3814 if (LocaleCompare("attenuate",option+1) == 0)
3819 if (i == (ssize_t) (argc-1))
3820 ThrowMogrifyException(OptionError,"MissingArgument",option);
3821 if (IsGeometry(argv[i]) == MagickFalse)
3822 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3825 if (LocaleCompare("authenticate",option+1) == 0)
3830 if (i == (ssize_t) argc)
3831 ThrowMogrifyException(OptionError,"MissingArgument",option);
3834 if (LocaleCompare("auto-gamma",option+1) == 0)
3836 if (LocaleCompare("auto-level",option+1) == 0)
3838 if (LocaleCompare("auto-orient",option+1) == 0)
3840 if (LocaleCompare("average",option+1) == 0)
3842 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3846 if (LocaleCompare("background",option+1) == 0)
3851 if (i == (ssize_t) argc)
3852 ThrowMogrifyException(OptionError,"MissingArgument",option);
3855 if (LocaleCompare("bias",option+1) == 0)
3860 if (i == (ssize_t) (argc-1))
3861 ThrowMogrifyException(OptionError,"MissingArgument",option);
3862 if (IsGeometry(argv[i]) == MagickFalse)
3863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3866 if (LocaleCompare("black-point-compensation",option+1) == 0)
3868 if (LocaleCompare("black-threshold",option+1) == 0)
3873 if (i == (ssize_t) argc)
3874 ThrowMogrifyException(OptionError,"MissingArgument",option);
3875 if (IsGeometry(argv[i]) == MagickFalse)
3876 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3879 if (LocaleCompare("blue-primary",option+1) == 0)
3884 if (i == (ssize_t) argc)
3885 ThrowMogrifyException(OptionError,"MissingArgument",option);
3886 if (IsGeometry(argv[i]) == MagickFalse)
3887 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3890 if (LocaleCompare("blue-shift",option+1) == 0)
3893 if (i == (ssize_t) argc)
3894 ThrowMogrifyException(OptionError,"MissingArgument",option);
3895 if (IsGeometry(argv[i]) == MagickFalse)
3896 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3899 if (LocaleCompare("blur",option+1) == 0)
3902 if (i == (ssize_t) argc)
3903 ThrowMogrifyException(OptionError,"MissingArgument",option);
3904 if (IsGeometry(argv[i]) == MagickFalse)
3905 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3908 if (LocaleCompare("border",option+1) == 0)
3913 if (i == (ssize_t) argc)
3914 ThrowMogrifyException(OptionError,"MissingArgument",option);
3915 if (IsGeometry(argv[i]) == MagickFalse)
3916 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3919 if (LocaleCompare("bordercolor",option+1) == 0)
3924 if (i == (ssize_t) argc)
3925 ThrowMogrifyException(OptionError,"MissingArgument",option);
3928 if (LocaleCompare("box",option+1) == 0)
3933 if (i == (ssize_t) argc)
3934 ThrowMogrifyException(OptionError,"MissingArgument",option);
3937 if (LocaleCompare("brightness-contrast",option+1) == 0)
3940 if (i == (ssize_t) argc)
3941 ThrowMogrifyException(OptionError,"MissingArgument",option);
3942 if (IsGeometry(argv[i]) == MagickFalse)
3943 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3946 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
3950 if (LocaleCompare("cache",option+1) == 0)
3955 if (i == (ssize_t) argc)
3956 ThrowMogrifyException(OptionError,"MissingArgument",option);
3957 if (IsGeometry(argv[i]) == MagickFalse)
3958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
3961 if (LocaleCompare("caption",option+1) == 0)
3966 if (i == (ssize_t) argc)
3967 ThrowMogrifyException(OptionError,"MissingArgument",option);
3970 if (LocaleCompare("channel",option+1) == 0)
3978 if (i == (ssize_t) (argc-1))
3979 ThrowMogrifyException(OptionError,"MissingArgument",option);
3980 channel=ParseChannelOption(argv[i]);
3982 ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
3986 if (LocaleCompare("cdl",option+1) == 0)
3991 if (i == (ssize_t) (argc-1))
3992 ThrowMogrifyException(OptionError,"MissingArgument",option);
3995 if (LocaleCompare("charcoal",option+1) == 0)
4000 if (i == (ssize_t) argc)
4001 ThrowMogrifyException(OptionError,"MissingArgument",option);
4002 if (IsGeometry(argv[i]) == MagickFalse)
4003 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4006 if (LocaleCompare("chop",option+1) == 0)
4011 if (i == (ssize_t) argc)
4012 ThrowMogrifyException(OptionError,"MissingArgument",option);
4013 if (IsGeometry(argv[i]) == MagickFalse)
4014 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4017 if (LocaleCompare("clamp",option+1) == 0)
4019 if (LocaleCompare("clip",option+1) == 0)
4021 if (LocaleCompare("clip-mask",option+1) == 0)
4026 if (i == (ssize_t) argc)
4027 ThrowMogrifyException(OptionError,"MissingArgument",option);
4030 if (LocaleCompare("clut",option+1) == 0)
4032 if (LocaleCompare("coalesce",option+1) == 0)
4034 if (LocaleCompare("colorize",option+1) == 0)
4039 if (i == (ssize_t) argc)
4040 ThrowMogrifyException(OptionError,"MissingArgument",option);
4041 if (IsGeometry(argv[i]) == MagickFalse)
4042 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4045 if (LocaleCompare("color-matrix",option+1) == 0)
4053 if (i == (ssize_t) (argc-1))
4054 ThrowMogrifyException(OptionError,"MissingArgument",option);
4055 kernel_info=AcquireKernelInfo(argv[i]);
4056 if (kernel_info == (KernelInfo *) NULL)
4057 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4058 kernel_info=DestroyKernelInfo(kernel_info);
4061 if (LocaleCompare("colors",option+1) == 0)
4066 if (i == (ssize_t) argc)
4067 ThrowMogrifyException(OptionError,"MissingArgument",option);
4068 if (IsGeometry(argv[i]) == MagickFalse)
4069 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4072 if (LocaleCompare("colorspace",option+1) == 0)
4080 if (i == (ssize_t) argc)
4081 ThrowMogrifyException(OptionError,"MissingArgument",option);
4082 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4085 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
4089 if (LocaleCompare("combine",option+1) == 0)
4091 if (LocaleCompare("comment",option+1) == 0)
4096 if (i == (ssize_t) argc)
4097 ThrowMogrifyException(OptionError,"MissingArgument",option);
4100 if (LocaleCompare("composite",option+1) == 0)
4102 if (LocaleCompare("compress",option+1) == 0)
4110 if (i == (ssize_t) argc)
4111 ThrowMogrifyException(OptionError,"MissingArgument",option);
4112 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
4115 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
4119 if (LocaleCompare("concurrent",option+1) == 0)
4121 if (LocaleCompare("contrast",option+1) == 0)
4123 if (LocaleCompare("contrast-stretch",option+1) == 0)
4126 if (i == (ssize_t) argc)
4127 ThrowMogrifyException(OptionError,"MissingArgument",option);
4128 if (IsGeometry(argv[i]) == MagickFalse)
4129 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4132 if (LocaleCompare("convolve",option+1) == 0)
4140 if (i == (ssize_t) argc)
4141 ThrowMogrifyException(OptionError,"MissingArgument",option);
4142 kernel_info=AcquireKernelInfo(argv[i]);
4143 if (kernel_info == (KernelInfo *) NULL)
4144 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4145 kernel_info=DestroyKernelInfo(kernel_info);
4148 if (LocaleCompare("crop",option+1) == 0)
4153 if (i == (ssize_t) argc)
4154 ThrowMogrifyException(OptionError,"MissingArgument",option);
4155 if (IsGeometry(argv[i]) == MagickFalse)
4156 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4159 if (LocaleCompare("cycle",option+1) == 0)
4164 if (i == (ssize_t) argc)
4165 ThrowMogrifyException(OptionError,"MissingArgument",option);
4166 if (IsGeometry(argv[i]) == MagickFalse)
4167 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4170 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4174 if (LocaleCompare("decipher",option+1) == 0)
4179 if (i == (ssize_t) (argc-1))
4180 ThrowMogrifyException(OptionError,"MissingArgument",option);
4183 if (LocaleCompare("deconstruct",option+1) == 0)
4185 if (LocaleCompare("debug",option+1) == 0)
4193 if (i == (ssize_t) argc)
4194 ThrowMogrifyException(OptionError,"MissingArgument",option);
4195 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
4197 ThrowMogrifyException(OptionError,"UnrecognizedEventType",
4199 (void) SetLogEventMask(argv[i]);
4202 if (LocaleCompare("define",option+1) == 0)
4205 if (i == (ssize_t) argc)
4206 ThrowMogrifyException(OptionError,"MissingArgument",option);
4212 define=GetImageOption(image_info,argv[i]);
4213 if (define == (const char *) NULL)
4214 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
4219 if (LocaleCompare("delay",option+1) == 0)
4224 if (i == (ssize_t) argc)
4225 ThrowMogrifyException(OptionError,"MissingArgument",option);
4226 if (IsGeometry(argv[i]) == MagickFalse)
4227 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4230 if (LocaleCompare("delete",option+1) == 0)
4235 if (i == (ssize_t) (argc-1))
4236 ThrowMogrifyException(OptionError,"MissingArgument",option);
4237 if (IsGeometry(argv[i]) == MagickFalse)
4238 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4241 if (LocaleCompare("density",option+1) == 0)
4246 if (i == (ssize_t) argc)
4247 ThrowMogrifyException(OptionError,"MissingArgument",option);
4248 if (IsGeometry(argv[i]) == MagickFalse)
4249 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4252 if (LocaleCompare("depth",option+1) == 0)
4257 if (i == (ssize_t) argc)
4258 ThrowMogrifyException(OptionError,"MissingArgument",option);
4259 if (IsGeometry(argv[i]) == MagickFalse)
4260 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4263 if (LocaleCompare("deskew",option+1) == 0)
4268 if (i == (ssize_t) argc)
4269 ThrowMogrifyException(OptionError,"MissingArgument",option);
4270 if (IsGeometry(argv[i]) == MagickFalse)
4271 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4274 if (LocaleCompare("despeckle",option+1) == 0)
4276 if (LocaleCompare("dft",option+1) == 0)
4278 if (LocaleCompare("direction",option+1) == 0)
4286 if (i == (ssize_t) argc)
4287 ThrowMogrifyException(OptionError,"MissingArgument",option);
4288 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
4291 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType",
4295 if (LocaleCompare("display",option+1) == 0)
4300 if (i == (ssize_t) argc)
4301 ThrowMogrifyException(OptionError,"MissingArgument",option);
4304 if (LocaleCompare("dispose",option+1) == 0)
4312 if (i == (ssize_t) argc)
4313 ThrowMogrifyException(OptionError,"MissingArgument",option);
4314 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
4316 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
4320 if (LocaleCompare("distort",option+1) == 0)
4326 if (i == (ssize_t) argc)
4327 ThrowMogrifyException(OptionError,"MissingArgument",option);
4328 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
4330 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
4333 if (i == (ssize_t) (argc-1))
4334 ThrowMogrifyException(OptionError,"MissingArgument",option);
4337 if (LocaleCompare("dither",option+1) == 0)
4345 if (i == (ssize_t) argc)
4346 ThrowMogrifyException(OptionError,"MissingArgument",option);
4347 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
4349 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
4353 if (LocaleCompare("draw",option+1) == 0)
4358 if (i == (ssize_t) argc)
4359 ThrowMogrifyException(OptionError,"MissingArgument",option);
4362 if (LocaleCompare("duplicate",option+1) == 0)
4367 if (i == (ssize_t) (argc-1))
4368 ThrowMogrifyException(OptionError,"MissingArgument",option);
4369 if (IsGeometry(argv[i]) == MagickFalse)
4370 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4373 if (LocaleCompare("duration",option+1) == 0)
4378 if (i == (ssize_t) (argc-1))
4379 ThrowMogrifyException(OptionError,"MissingArgument",option);
4380 if (IsGeometry(argv[i]) == MagickFalse)
4381 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4384 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4388 if (LocaleCompare("edge",option+1) == 0)
4393 if (i == (ssize_t) argc)
4394 ThrowMogrifyException(OptionError,"MissingArgument",option);
4395 if (IsGeometry(argv[i]) == MagickFalse)
4396 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4399 if (LocaleCompare("emboss",option+1) == 0)
4404 if (i == (ssize_t) argc)
4405 ThrowMogrifyException(OptionError,"MissingArgument",option);
4406 if (IsGeometry(argv[i]) == MagickFalse)
4407 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4410 if (LocaleCompare("encipher",option+1) == 0)
4415 if (i == (ssize_t) argc)
4416 ThrowMogrifyException(OptionError,"MissingArgument",option);
4419 if (LocaleCompare("encoding",option+1) == 0)
4424 if (i == (ssize_t) argc)
4425 ThrowMogrifyException(OptionError,"MissingArgument",option);
4428 if (LocaleCompare("endian",option+1) == 0)
4436 if (i == (ssize_t) argc)
4437 ThrowMogrifyException(OptionError,"MissingArgument",option);
4438 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]);
4440 ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
4444 if (LocaleCompare("enhance",option+1) == 0)
4446 if (LocaleCompare("equalize",option+1) == 0)
4448 if (LocaleCompare("evaluate",option+1) == 0)
4456 if (i == (ssize_t) argc)
4457 ThrowMogrifyException(OptionError,"MissingArgument",option);
4458 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4460 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4463 if (i == (ssize_t) (argc-1))
4464 ThrowMogrifyException(OptionError,"MissingArgument",option);
4465 if (IsGeometry(argv[i]) == MagickFalse)
4466 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4469 if (LocaleCompare("evaluate-sequence",option+1) == 0)
4477 if (i == (ssize_t) argc)
4478 ThrowMogrifyException(OptionError,"MissingArgument",option);
4479 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]);
4481 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
4485 if (LocaleCompare("extent",option+1) == 0)
4490 if (i == (ssize_t) argc)
4491 ThrowMogrifyException(OptionError,"MissingArgument",option);
4492 if (IsGeometry(argv[i]) == MagickFalse)
4493 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4496 if (LocaleCompare("extract",option+1) == 0)
4501 if (i == (ssize_t) argc)
4502 ThrowMogrifyException(OptionError,"MissingArgument",option);
4503 if (IsGeometry(argv[i]) == MagickFalse)
4504 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4507 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4511 if (LocaleCompare("family",option+1) == 0)
4516 if (i == (ssize_t) (argc-1))
4517 ThrowMogrifyException(OptionError,"MissingArgument",option);
4520 if (LocaleCompare("fill",option+1) == 0)
4525 if (i == (ssize_t) argc)
4526 ThrowMogrifyException(OptionError,"MissingArgument",option);
4529 if (LocaleCompare("filter",option+1) == 0)
4537 if (i == (ssize_t) argc)
4538 ThrowMogrifyException(OptionError,"MissingArgument",option);
4539 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
4541 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
4545 if (LocaleCompare("flatten",option+1) == 0)
4547 if (LocaleCompare("flip",option+1) == 0)
4549 if (LocaleCompare("flop",option+1) == 0)
4551 if (LocaleCompare("floodfill",option+1) == 0)
4556 if (i == (ssize_t) argc)
4557 ThrowMogrifyException(OptionError,"MissingArgument",option);
4558 if (IsGeometry(argv[i]) == MagickFalse)
4559 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4561 if (i == (ssize_t) argc)
4562 ThrowMogrifyException(OptionError,"MissingArgument",option);
4565 if (LocaleCompare("font",option+1) == 0)
4570 if (i == (ssize_t) argc)
4571 ThrowMogrifyException(OptionError,"MissingArgument",option);
4574 if (LocaleCompare("format",option+1) == 0)
4576 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
4577 (void) CloneString(&format,(char *) NULL);
4581 if (i == (ssize_t) argc)
4582 ThrowMogrifyException(OptionError,"MissingArgument",option);
4583 (void) CloneString(&format,argv[i]);
4584 (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
4585 (void) ConcatenateMagickString(image_info->filename,":",
4587 (void) SetImageInfo(image_info,0,exception);
4588 if (*image_info->magick == '\0')
4589 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
4593 if (LocaleCompare("frame",option+1) == 0)
4598 if (i == (ssize_t) argc)
4599 ThrowMogrifyException(OptionError,"MissingArgument",option);
4600 if (IsGeometry(argv[i]) == MagickFalse)
4601 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4604 if (LocaleCompare("function",option+1) == 0)
4612 if (i == (ssize_t) argc)
4613 ThrowMogrifyException(OptionError,"MissingArgument",option);
4614 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]);
4616 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
4618 if (i == (ssize_t) (argc-1))
4619 ThrowMogrifyException(OptionError,"MissingArgument",option);
4622 if (LocaleCompare("fuzz",option+1) == 0)
4627 if (i == (ssize_t) argc)
4628 ThrowMogrifyException(OptionError,"MissingArgument",option);
4629 if (IsGeometry(argv[i]) == MagickFalse)
4630 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4633 if (LocaleCompare("fx",option+1) == 0)
4638 if (i == (ssize_t) (argc-1))
4639 ThrowMogrifyException(OptionError,"MissingArgument",option);
4642 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4646 if (LocaleCompare("gamma",option+1) == 0)
4649 if (i == (ssize_t) argc)
4650 ThrowMogrifyException(OptionError,"MissingArgument",option);
4651 if (IsGeometry(argv[i]) == MagickFalse)
4652 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4655 if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
4656 (LocaleCompare("gaussian",option+1) == 0))
4659 if (i == (ssize_t) argc)
4660 ThrowMogrifyException(OptionError,"MissingArgument",option);
4661 if (IsGeometry(argv[i]) == MagickFalse)
4662 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4665 if (LocaleCompare("geometry",option+1) == 0)
4670 if (i == (ssize_t) argc)
4671 ThrowMogrifyException(OptionError,"MissingArgument",option);
4672 if (IsGeometry(argv[i]) == MagickFalse)
4673 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4676 if (LocaleCompare("gravity",option+1) == 0)
4684 if (i == (ssize_t) argc)
4685 ThrowMogrifyException(OptionError,"MissingArgument",option);
4686 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
4688 ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
4692 if (LocaleCompare("green-primary",option+1) == 0)
4697 if (i == (ssize_t) argc)
4698 ThrowMogrifyException(OptionError,"MissingArgument",option);
4699 if (IsGeometry(argv[i]) == MagickFalse)
4700 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4703 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4707 if (LocaleCompare("hald-clut",option+1) == 0)
4709 if ((LocaleCompare("help",option+1) == 0) ||
4710 (LocaleCompare("-help",option+1) == 0))
4711 return(MogrifyUsage());
4712 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4716 if (LocaleCompare("identify",option+1) == 0)
4718 if (LocaleCompare("idft",option+1) == 0)
4720 if (LocaleCompare("implode",option+1) == 0)
4725 if (i == (ssize_t) argc)
4726 ThrowMogrifyException(OptionError,"MissingArgument",option);
4727 if (IsGeometry(argv[i]) == MagickFalse)
4728 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4731 if (LocaleCompare("intent",option+1) == 0)
4739 if (i == (ssize_t) (argc-1))
4740 ThrowMogrifyException(OptionError,"MissingArgument",option);
4741 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]);
4743 ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
4747 if (LocaleCompare("interlace",option+1) == 0)
4755 if (i == (ssize_t) argc)
4756 ThrowMogrifyException(OptionError,"MissingArgument",option);
4757 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4760 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
4764 if (LocaleCompare("interline-spacing",option+1) == 0)
4769 if (i == (ssize_t) (argc-1))
4770 ThrowMogrifyException(OptionError,"MissingArgument",option);
4771 if (IsGeometry(argv[i]) == MagickFalse)
4772 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4775 if (LocaleCompare("interpolate",option+1) == 0)
4783 if (i == (ssize_t) argc)
4784 ThrowMogrifyException(OptionError,"MissingArgument",option);
4785 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4787 if (interpolate < 0)
4788 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
4792 if (LocaleCompare("interword-spacing",option+1) == 0)
4797 if (i == (ssize_t) (argc-1))
4798 ThrowMogrifyException(OptionError,"MissingArgument",option);
4799 if (IsGeometry(argv[i]) == MagickFalse)
4800 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4803 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4807 if (LocaleCompare("kerning",option+1) == 0)
4812 if (i == (ssize_t) (argc-1))
4813 ThrowMogrifyException(OptionError,"MissingArgument",option);
4814 if (IsGeometry(argv[i]) == MagickFalse)
4815 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4818 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4822 if (LocaleCompare("label",option+1) == 0)
4827 if (i == (ssize_t) argc)
4828 ThrowMogrifyException(OptionError,"MissingArgument",option);
4831 if (LocaleCompare("lat",option+1) == 0)
4836 if (i == (ssize_t) argc)
4837 ThrowMogrifyException(OptionError,"MissingArgument",option);
4838 if (IsGeometry(argv[i]) == MagickFalse)
4839 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4841 if (LocaleCompare("layers",option+1) == 0)
4849 if (i == (ssize_t) (argc-1))
4850 ThrowMogrifyException(OptionError,"MissingArgument",option);
4851 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]);
4853 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
4857 if (LocaleCompare("level",option+1) == 0)
4860 if (i == (ssize_t) argc)
4861 ThrowMogrifyException(OptionError,"MissingArgument",option);
4862 if (IsGeometry(argv[i]) == MagickFalse)
4863 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4866 if (LocaleCompare("level-colors",option+1) == 0)
4869 if (i == (ssize_t) argc)
4870 ThrowMogrifyException(OptionError,"MissingArgument",option);
4873 if (LocaleCompare("linewidth",option+1) == 0)
4878 if (i == (ssize_t) argc)
4879 ThrowMogrifyException(OptionError,"MissingArgument",option);
4880 if (IsGeometry(argv[i]) == MagickFalse)
4881 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4884 if (LocaleCompare("limit",option+1) == 0)
4898 if (i == (ssize_t) argc)
4899 ThrowMogrifyException(OptionError,"MissingArgument",option);
4900 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
4903 ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
4906 if (i == (ssize_t) argc)
4907 ThrowMogrifyException(OptionError,"MissingArgument",option);
4908 value=InterpretLocaleValue(argv[i],&p);
4910 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
4911 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4914 if (LocaleCompare("liquid-rescale",option+1) == 0)
4917 if (i == (ssize_t) argc)
4918 ThrowMogrifyException(OptionError,"MissingArgument",option);
4919 if (IsGeometry(argv[i]) == MagickFalse)
4920 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4923 if (LocaleCompare("list",option+1) == 0)
4931 if (i == (ssize_t) argc)
4932 ThrowMogrifyException(OptionError,"MissingArgument",option);
4933 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
4935 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
4936 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
4938 return(status != 0 ? MagickFalse : MagickTrue);
4940 if (LocaleCompare("log",option+1) == 0)
4945 if ((i == (ssize_t) argc) ||
4946 (strchr(argv[i],'%') == (char *) NULL))
4947 ThrowMogrifyException(OptionError,"MissingArgument",option);
4950 if (LocaleCompare("loop",option+1) == 0)
4955 if (i == (ssize_t) argc)
4956 ThrowMogrifyException(OptionError,"MissingArgument",option);
4957 if (IsGeometry(argv[i]) == MagickFalse)
4958 ThrowMogrifyInvalidArgumentException(option,argv[i]);
4961 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
4965 if (LocaleCompare("map",option+1) == 0)
4967 global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
4971 if (i == (ssize_t) argc)
4972 ThrowMogrifyException(OptionError,"MissingArgument",option);
4975 if (LocaleCompare("mask",option+1) == 0)
4980 if (i == (ssize_t) argc)
4981 ThrowMogrifyException(OptionError,"MissingArgument",option);
4984 if (LocaleCompare("matte",option+1) == 0)
4986 if (LocaleCompare("mattecolor",option+1) == 0)
4991 if (i == (ssize_t) argc)
4992 ThrowMogrifyException(OptionError,"MissingArgument",option);
4995 if (LocaleCompare("maximum",option+1) == 0)
4997 if (LocaleCompare("minimum",option+1) == 0)
4999 if (LocaleCompare("modulate",option+1) == 0)
5004 if (i == (ssize_t) argc)
5005 ThrowMogrifyException(OptionError,"MissingArgument",option);
5006 if (IsGeometry(argv[i]) == MagickFalse)
5007 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5010 if (LocaleCompare("median",option+1) == 0)
5015 if (i == (ssize_t) argc)
5016 ThrowMogrifyException(OptionError,"MissingArgument",option);
5017 if (IsGeometry(argv[i]) == MagickFalse)
5018 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5021 if (LocaleCompare("mode",option+1) == 0)
5026 if (i == (ssize_t) argc)
5027 ThrowMogrifyException(OptionError,"MissingArgument",option);
5028 if (IsGeometry(argv[i]) == MagickFalse)
5029 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5032 if (LocaleCompare("monitor",option+1) == 0)
5034 if (LocaleCompare("monochrome",option+1) == 0)
5036 if (LocaleCompare("morph",option+1) == 0)
5041 if (i == (ssize_t) (argc-1))
5042 ThrowMogrifyException(OptionError,"MissingArgument",option);
5043 if (IsGeometry(argv[i]) == MagickFalse)
5044 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5047 if (LocaleCompare("morphology",option+1) == 0)
5050 token[MaxTextExtent];
5059 if (i == (ssize_t) argc)
5060 ThrowMogrifyException(OptionError,"MissingArgument",option);
5061 GetMagickToken(argv[i],NULL,token);
5062 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
5064 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
5067 if (i == (ssize_t) (argc-1))
5068 ThrowMogrifyException(OptionError,"MissingArgument",option);
5069 kernel_info=AcquireKernelInfo(argv[i]);
5070 if (kernel_info == (KernelInfo *) NULL)
5071 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5072 kernel_info=DestroyKernelInfo(kernel_info);
5075 if (LocaleCompare("mosaic",option+1) == 0)
5077 if (LocaleCompare("motion-blur",option+1) == 0)
5082 if (i == (ssize_t) argc)
5083 ThrowMogrifyException(OptionError,"MissingArgument",option);
5084 if (IsGeometry(argv[i]) == MagickFalse)
5085 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5088 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5092 if (LocaleCompare("negate",option+1) == 0)
5094 if (LocaleCompare("noise",option+1) == 0)
5097 if (i == (ssize_t) argc)
5098 ThrowMogrifyException(OptionError,"MissingArgument",option);
5104 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]);
5106 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
5110 if (IsGeometry(argv[i]) == MagickFalse)
5111 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5114 if (LocaleCompare("noop",option+1) == 0)
5116 if (LocaleCompare("normalize",option+1) == 0)
5118 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5122 if (LocaleCompare("opaque",option+1) == 0)
5125 if (i == (ssize_t) argc)
5126 ThrowMogrifyException(OptionError,"MissingArgument",option);
5129 if (LocaleCompare("ordered-dither",option+1) == 0)
5134 if (i == (ssize_t) argc)
5135 ThrowMogrifyException(OptionError,"MissingArgument",option);
5138 if (LocaleCompare("orient",option+1) == 0)
5143 orientation=UndefinedOrientation;
5147 if (i == (ssize_t) (argc-1))
5148 ThrowMogrifyException(OptionError,"MissingArgument",option);
5149 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse,
5151 if (orientation < 0)
5152 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
5156 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5160 if (LocaleCompare("page",option+1) == 0)
5165 if (i == (ssize_t) argc)
5166 ThrowMogrifyException(OptionError,"MissingArgument",option);
5169 if (LocaleCompare("paint",option+1) == 0)
5174 if (i == (ssize_t) argc)
5175 ThrowMogrifyException(OptionError,"MissingArgument",option);
5176 if (IsGeometry(argv[i]) == MagickFalse)
5177 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5180 if (LocaleCompare("path",option+1) == 0)
5182 (void) CloneString(&path,(char *) NULL);
5186 if (i == (ssize_t) argc)
5187 ThrowMogrifyException(OptionError,"MissingArgument",option);
5188 (void) CloneString(&path,argv[i]);
5191 if (LocaleCompare("pointsize",option+1) == 0)
5196 if (i == (ssize_t) argc)
5197 ThrowMogrifyException(OptionError,"MissingArgument",option);
5198 if (IsGeometry(argv[i]) == MagickFalse)
5199 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5202 if (LocaleCompare("polaroid",option+1) == 0)
5207 if (i == (ssize_t) argc)
5208 ThrowMogrifyException(OptionError,"MissingArgument",option);
5209 if (IsGeometry(argv[i]) == MagickFalse)
5210 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5213 if (LocaleCompare("posterize",option+1) == 0)
5218 if (i == (ssize_t) argc)
5219 ThrowMogrifyException(OptionError,"MissingArgument",option);
5220 if (IsGeometry(argv[i]) == MagickFalse)
5221 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5224 if (LocaleCompare("precision",option+1) == 0)
5229 if (i == (ssize_t) argc)
5230 ThrowMogrifyException(OptionError,"MissingArgument",option);
5231 if (IsGeometry(argv[i]) == MagickFalse)
5232 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5235 if (LocaleCompare("print",option+1) == 0)
5240 if (i == (ssize_t) argc)
5241 ThrowMogrifyException(OptionError,"MissingArgument",option);
5244 if (LocaleCompare("process",option+1) == 0)
5249 if (i == (ssize_t) (argc-1))
5250 ThrowMogrifyException(OptionError,"MissingArgument",option);
5253 if (LocaleCompare("profile",option+1) == 0)
5256 if (i == (ssize_t) argc)
5257 ThrowMogrifyException(OptionError,"MissingArgument",option);
5260 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5264 if (LocaleCompare("quality",option+1) == 0)
5269 if (i == (ssize_t) argc)
5270 ThrowMogrifyException(OptionError,"MissingArgument",option);
5271 if (IsGeometry(argv[i]) == MagickFalse)
5272 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5275 if (LocaleCompare("quantize",option+1) == 0)
5283 if (i == (ssize_t) (argc-1))
5284 ThrowMogrifyException(OptionError,"MissingArgument",option);
5285 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
5288 ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
5292 if (LocaleCompare("quiet",option+1) == 0)
5294 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5298 if (LocaleCompare("radial-blur",option+1) == 0)
5301 if (i == (ssize_t) argc)
5302 ThrowMogrifyException(OptionError,"MissingArgument",option);
5303 if (IsGeometry(argv[i]) == MagickFalse)
5304 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5307 if (LocaleCompare("raise",option+1) == 0)
5310 if (i == (ssize_t) argc)
5311 ThrowMogrifyException(OptionError,"MissingArgument",option);
5312 if (IsGeometry(argv[i]) == MagickFalse)
5313 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5316 if (LocaleCompare("random-threshold",option+1) == 0)
5321 if (i == (ssize_t) argc)
5322 ThrowMogrifyException(OptionError,"MissingArgument",option);
5323 if (IsGeometry(argv[i]) == MagickFalse)
5324 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5327 if (LocaleCompare("recolor",option+1) == 0)
5332 if (i == (ssize_t) (argc-1))
5333 ThrowMogrifyException(OptionError,"MissingArgument",option);
5334 if (IsGeometry(argv[i]) == MagickFalse)
5335 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5338 if (LocaleCompare("red-primary",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]);
5348 if (LocaleCompare("regard-warnings",option+1) == 0)
5350 if (LocaleCompare("region",option+1) == 0)
5355 if (i == (ssize_t) argc)
5356 ThrowMogrifyException(OptionError,"MissingArgument",option);
5357 if (IsGeometry(argv[i]) == MagickFalse)
5358 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5361 if (LocaleCompare("remap",option+1) == 0)
5366 if (i == (ssize_t) (argc-1))
5367 ThrowMogrifyException(OptionError,"MissingArgument",option);
5370 if (LocaleCompare("render",option+1) == 0)
5372 if (LocaleCompare("repage",option+1) == 0)
5377 if (i == (ssize_t) argc)
5378 ThrowMogrifyException(OptionError,"MissingArgument",option);
5379 if (IsGeometry(argv[i]) == MagickFalse)
5380 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5383 if (LocaleCompare("resample",option+1) == 0)
5388 if (i == (ssize_t) argc)
5389 ThrowMogrifyException(OptionError,"MissingArgument",option);
5390 if (IsGeometry(argv[i]) == MagickFalse)
5391 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5394 if (LocaleCompare("resize",option+1) == 0)
5399 if (i == (ssize_t) argc)
5400 ThrowMogrifyException(OptionError,"MissingArgument",option);
5401 if (IsGeometry(argv[i]) == MagickFalse)
5402 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5405 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
5407 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
5410 if (LocaleCompare("reverse",option+1) == 0)
5412 if (LocaleCompare("roll",option+1) == 0)
5417 if (i == (ssize_t) argc)
5418 ThrowMogrifyException(OptionError,"MissingArgument",option);
5419 if (IsGeometry(argv[i]) == MagickFalse)
5420 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5423 if (LocaleCompare("rotate",option+1) == 0)
5426 if (i == (ssize_t) argc)
5427 ThrowMogrifyException(OptionError,"MissingArgument",option);
5428 if (IsGeometry(argv[i]) == MagickFalse)
5429 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5432 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5436 if (LocaleCompare("sample",option+1) == 0)
5441 if (i == (ssize_t) argc)
5442 ThrowMogrifyException(OptionError,"MissingArgument",option);
5443 if (IsGeometry(argv[i]) == MagickFalse)
5444 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5447 if (LocaleCompare("sampling-factor",option+1) == 0)
5452 if (i == (ssize_t) argc)
5453 ThrowMogrifyException(OptionError,"MissingArgument",option);
5454 if (IsGeometry(argv[i]) == MagickFalse)
5455 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5458 if (LocaleCompare("scale",option+1) == 0)
5463 if (i == (ssize_t) argc)
5464 ThrowMogrifyException(OptionError,"MissingArgument",option);
5465 if (IsGeometry(argv[i]) == MagickFalse)
5466 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5469 if (LocaleCompare("scene",option+1) == 0)
5474 if (i == (ssize_t) argc)
5475 ThrowMogrifyException(OptionError,"MissingArgument",option);
5476 if (IsGeometry(argv[i]) == MagickFalse)
5477 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5480 if (LocaleCompare("seed",option+1) == 0)
5485 if (i == (ssize_t) argc)
5486 ThrowMogrifyException(OptionError,"MissingArgument",option);
5487 if (IsGeometry(argv[i]) == MagickFalse)
5488 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5491 if (LocaleCompare("segment",option+1) == 0)
5496 if (i == (ssize_t) argc)
5497 ThrowMogrifyException(OptionError,"MissingArgument",option);
5498 if (IsGeometry(argv[i]) == MagickFalse)
5499 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5502 if (LocaleCompare("selective-blur",option+1) == 0)
5505 if (i == (ssize_t) argc)
5506 ThrowMogrifyException(OptionError,"MissingArgument",option);
5507 if (IsGeometry(argv[i]) == MagickFalse)
5508 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5511 if (LocaleCompare("separate",option+1) == 0)
5513 if (LocaleCompare("sepia-tone",option+1) == 0)
5518 if (i == (ssize_t) argc)
5519 ThrowMogrifyException(OptionError,"MissingArgument",option);
5520 if (IsGeometry(argv[i]) == MagickFalse)
5521 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5524 if (LocaleCompare("set",option+1) == 0)
5527 if (i == (ssize_t) argc)
5528 ThrowMogrifyException(OptionError,"MissingArgument",option);
5532 if (i == (ssize_t) argc)
5533 ThrowMogrifyException(OptionError,"MissingArgument",option);
5536 if (LocaleCompare("shade",option+1) == 0)
5539 if (i == (ssize_t) argc)
5540 ThrowMogrifyException(OptionError,"MissingArgument",option);
5541 if (IsGeometry(argv[i]) == MagickFalse)
5542 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5545 if (LocaleCompare("shadow",option+1) == 0)
5550 if (i == (ssize_t) argc)
5551 ThrowMogrifyException(OptionError,"MissingArgument",option);
5552 if (IsGeometry(argv[i]) == MagickFalse)
5553 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5556 if (LocaleCompare("sharpen",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("shave",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("shear",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("sigmoidal-contrast",option+1) == 0)
5588 if (i == (ssize_t) (argc-1))
5589 ThrowMogrifyException(OptionError,"MissingArgument",option);
5590 if (IsGeometry(argv[i]) == MagickFalse)
5591 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5594 if (LocaleCompare("size",option+1) == 0)
5599 if (i == (ssize_t) argc)
5600 ThrowMogrifyException(OptionError,"MissingArgument",option);
5601 if (IsGeometry(argv[i]) == MagickFalse)
5602 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5605 if (LocaleCompare("sketch",option+1) == 0)
5610 if (i == (ssize_t) argc)
5611 ThrowMogrifyException(OptionError,"MissingArgument",option);
5612 if (IsGeometry(argv[i]) == MagickFalse)
5613 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5616 if (LocaleCompare("smush",option+1) == 0)
5619 if (i == (ssize_t) argc)
5620 ThrowMogrifyException(OptionError,"MissingArgument",option);
5621 if (IsGeometry(argv[i]) == MagickFalse)
5622 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5626 if (LocaleCompare("solarize",option+1) == 0)
5631 if (i == (ssize_t) argc)
5632 ThrowMogrifyException(OptionError,"MissingArgument",option);
5633 if (IsGeometry(argv[i]) == MagickFalse)
5634 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5637 if (LocaleCompare("sparse-color",option+1) == 0)
5643 if (i == (ssize_t) argc)
5644 ThrowMogrifyException(OptionError,"MissingArgument",option);
5645 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]);
5647 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
5650 if (i == (ssize_t) (argc-1))
5651 ThrowMogrifyException(OptionError,"MissingArgument",option);
5654 if (LocaleCompare("spread",option+1) == 0)
5659 if (i == (ssize_t) argc)
5660 ThrowMogrifyException(OptionError,"MissingArgument",option);
5661 if (IsGeometry(argv[i]) == MagickFalse)
5662 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5665 if (LocaleCompare("statistic",option+1) == 0)
5673 if (i == (ssize_t) argc)
5674 ThrowMogrifyException(OptionError,"MissingArgument",option);
5675 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]);
5677 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType",
5680 if (i == (ssize_t) (argc-1))
5681 ThrowMogrifyException(OptionError,"MissingArgument",option);
5682 if (IsGeometry(argv[i]) == MagickFalse)
5683 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5686 if (LocaleCompare("stretch",option+1) == 0)
5694 if (i == (ssize_t) (argc-1))
5695 ThrowMogrifyException(OptionError,"MissingArgument",option);
5696 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]);
5698 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5702 if (LocaleCompare("strip",option+1) == 0)
5704 if (LocaleCompare("stroke",option+1) == 0)
5709 if (i == (ssize_t) argc)
5710 ThrowMogrifyException(OptionError,"MissingArgument",option);
5713 if (LocaleCompare("strokewidth",option+1) == 0)
5718 if (i == (ssize_t) argc)
5719 ThrowMogrifyException(OptionError,"MissingArgument",option);
5720 if (IsGeometry(argv[i]) == MagickFalse)
5721 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5724 if (LocaleCompare("style",option+1) == 0)
5732 if (i == (ssize_t) (argc-1))
5733 ThrowMogrifyException(OptionError,"MissingArgument",option);
5734 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]);
5736 ThrowMogrifyException(OptionError,"UnrecognizedStyleType",
5740 if (LocaleCompare("swap",option+1) == 0)
5745 if (i == (ssize_t) (argc-1))
5746 ThrowMogrifyException(OptionError,"MissingArgument",option);
5747 if (IsGeometry(argv[i]) == MagickFalse)
5748 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5751 if (LocaleCompare("swirl",option+1) == 0)
5756 if (i == (ssize_t) argc)
5757 ThrowMogrifyException(OptionError,"MissingArgument",option);
5758 if (IsGeometry(argv[i]) == MagickFalse)
5759 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5762 if (LocaleCompare("synchronize",option+1) == 0)
5764 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5768 if (LocaleCompare("taint",option+1) == 0)
5770 if (LocaleCompare("texture",option+1) == 0)
5775 if (i == (ssize_t) argc)
5776 ThrowMogrifyException(OptionError,"MissingArgument",option);
5779 if (LocaleCompare("tile",option+1) == 0)
5784 if (i == (ssize_t) (argc-1))
5785 ThrowMogrifyException(OptionError,"MissingArgument",option);
5788 if (LocaleCompare("tile-offset",option+1) == 0)
5793 if (i == (ssize_t) argc)
5794 ThrowMogrifyException(OptionError,"MissingArgument",option);
5795 if (IsGeometry(argv[i]) == MagickFalse)
5796 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5799 if (LocaleCompare("tint",option+1) == 0)
5804 if (i == (ssize_t) (argc-1))
5805 ThrowMogrifyException(OptionError,"MissingArgument",option);
5806 if (IsGeometry(argv[i]) == MagickFalse)
5807 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5810 if (LocaleCompare("transform",option+1) == 0)
5812 if (LocaleCompare("transpose",option+1) == 0)
5814 if (LocaleCompare("transverse",option+1) == 0)
5816 if (LocaleCompare("threshold",option+1) == 0)
5821 if (i == (ssize_t) argc)
5822 ThrowMogrifyException(OptionError,"MissingArgument",option);
5823 if (IsGeometry(argv[i]) == MagickFalse)
5824 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5827 if (LocaleCompare("thumbnail",option+1) == 0)
5832 if (i == (ssize_t) argc)
5833 ThrowMogrifyException(OptionError,"MissingArgument",option);
5834 if (IsGeometry(argv[i]) == MagickFalse)
5835 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5838 if (LocaleCompare("transparent",option+1) == 0)
5841 if (i == (ssize_t) argc)
5842 ThrowMogrifyException(OptionError,"MissingArgument",option);
5845 if (LocaleCompare("transparent-color",option+1) == 0)
5850 if (i == (ssize_t) (argc-1))
5851 ThrowMogrifyException(OptionError,"MissingArgument",option);
5854 if (LocaleCompare("treedepth",option+1) == 0)
5859 if (i == (ssize_t) argc)
5860 ThrowMogrifyException(OptionError,"MissingArgument",option);
5861 if (IsGeometry(argv[i]) == MagickFalse)
5862 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5865 if (LocaleCompare("trim",option+1) == 0)
5867 if (LocaleCompare("type",option+1) == 0)
5875 if (i == (ssize_t) argc)
5876 ThrowMogrifyException(OptionError,"MissingArgument",option);
5877 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
5879 ThrowMogrifyException(OptionError,"UnrecognizedImageType",
5883 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5887 if (LocaleCompare("undercolor",option+1) == 0)
5892 if (i == (ssize_t) argc)
5893 ThrowMogrifyException(OptionError,"MissingArgument",option);
5896 if (LocaleCompare("unique-colors",option+1) == 0)
5898 if (LocaleCompare("units",option+1) == 0)
5906 if (i == (ssize_t) argc)
5907 ThrowMogrifyException(OptionError,"MissingArgument",option);
5908 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
5911 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType",
5915 if (LocaleCompare("unsharp",option+1) == 0)
5918 if (i == (ssize_t) argc)
5919 ThrowMogrifyException(OptionError,"MissingArgument",option);
5920 if (IsGeometry(argv[i]) == MagickFalse)
5921 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5924 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5928 if (LocaleCompare("verbose",option+1) == 0)
5930 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse;
5933 if ((LocaleCompare("version",option+1) == 0) ||
5934 (LocaleCompare("-version",option+1) == 0))
5936 (void) FormatLocaleFile(stdout,"Version: %s\n",
5937 GetMagickVersion((size_t *) NULL));
5938 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
5939 GetMagickCopyright());
5940 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
5941 GetMagickFeatures());
5944 if (LocaleCompare("view",option+1) == 0)
5949 if (i == (ssize_t) argc)
5950 ThrowMogrifyException(OptionError,"MissingArgument",option);
5953 if (LocaleCompare("vignette",option+1) == 0)
5958 if (i == (ssize_t) argc)
5959 ThrowMogrifyException(OptionError,"MissingArgument",option);
5960 if (IsGeometry(argv[i]) == MagickFalse)
5961 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5964 if (LocaleCompare("virtual-pixel",option+1) == 0)
5972 if (i == (ssize_t) argc)
5973 ThrowMogrifyException(OptionError,"MissingArgument",option);
5974 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
5977 ThrowMogrifyException(OptionError,
5978 "UnrecognizedVirtualPixelMethod",argv[i]);
5981 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
5985 if (LocaleCompare("wave",option+1) == 0)
5988 if (i == (ssize_t) argc)
5989 ThrowMogrifyException(OptionError,"MissingArgument",option);
5990 if (IsGeometry(argv[i]) == MagickFalse)
5991 ThrowMogrifyInvalidArgumentException(option,argv[i]);
5994 if (LocaleCompare("weight",option+1) == 0)
5999 if (i == (ssize_t) (argc-1))
6000 ThrowMogrifyException(OptionError,"MissingArgument",option);
6003 if (LocaleCompare("white-point",option+1) == 0)
6008 if (i == (ssize_t) argc)
6009 ThrowMogrifyException(OptionError,"MissingArgument",option);
6010 if (IsGeometry(argv[i]) == MagickFalse)
6011 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6014 if (LocaleCompare("white-threshold",option+1) == 0)
6019 if (i == (ssize_t) argc)
6020 ThrowMogrifyException(OptionError,"MissingArgument",option);
6021 if (IsGeometry(argv[i]) == MagickFalse)
6022 ThrowMogrifyInvalidArgumentException(option,argv[i]);
6025 if (LocaleCompare("write",option+1) == 0)
6028 if (i == (ssize_t) (argc-1))
6029 ThrowMogrifyException(OptionError,"MissingArgument",option);
6032 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6037 ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
6039 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
6040 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
6041 if (fire != MagickFalse)
6042 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
6045 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]);
6046 if (i != (ssize_t) argc)
6047 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]);
6049 return(status != 0 ? MagickTrue : MagickFalse);
6053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6057 + M o g r i f y I m a g e I n f o %
6061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6063 % MogrifyImageInfo() applies image processing settings to the image as
6064 % prescribed by command line options.
6066 % The format of the MogrifyImageInfo method is:
6068 % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc,
6069 % const char **argv,ExceptionInfo *exception)
6071 % A description of each parameter follows:
6073 % o image_info: the image info..
6075 % o argc: Specifies a pointer to an integer describing the number of
6076 % elements in the argument vector.
6078 % o argv: Specifies a pointer to a text array containing the command line
6081 % o exception: return any errors or warnings in this structure.
6084 WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,
6085 const int argc,const char **argv,ExceptionInfo *exception)
6100 Initialize method variables.
6102 assert(image_info != (ImageInfo *) NULL);
6103 assert(image_info->signature == MagickSignature);
6104 if (image_info->debug != MagickFalse)
6105 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
6106 image_info->filename);
6110 Set the image settings.
6112 for (i=0; i < (ssize_t) argc; i++)
6115 if (IsCommandOption(option) == MagickFalse)
6117 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
6118 count=MagickMax(count,0L);
6119 if ((i+count) >= (ssize_t) argc)
6121 switch (*(option+1))
6125 if (LocaleCompare("adjoin",option+1) == 0)
6127 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse;
6130 if (LocaleCompare("antialias",option+1) == 0)
6132 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse;
6135 if (LocaleCompare("attenuate",option+1) == 0)
6139 (void) DeleteImageOption(image_info,option+1);
6142 (void) SetImageOption(image_info,option+1,argv[i+1]);
6145 if (LocaleCompare("authenticate",option+1) == 0)
6148 (void) CloneString(&image_info->authenticate,(char *) NULL);
6150 (void) CloneString(&image_info->authenticate,argv[i+1]);
6157 if (LocaleCompare("background",option+1) == 0)
6161 (void) DeleteImageOption(image_info,option+1);
6162 (void) QueryColorDatabase(BackgroundColor,
6163 &image_info->background_color,exception);
6166 (void) SetImageOption(image_info,option+1,argv[i+1]);
6167 (void) QueryColorDatabase(argv[i+1],&image_info->background_color,
6171 if (LocaleCompare("bias",option+1) == 0)
6175 (void) SetImageOption(image_info,option+1,"0.0");
6178 (void) SetImageOption(image_info,option+1,argv[i+1]);
6181 if (LocaleCompare("black-point-compensation",option+1) == 0)
6185 (void) SetImageOption(image_info,option+1,"false");
6188 (void) SetImageOption(image_info,option+1,"true");
6191 if (LocaleCompare("blue-primary",option+1) == 0)
6195 (void) SetImageOption(image_info,option+1,"0.0");
6198 (void) SetImageOption(image_info,option+1,argv[i+1]);
6201 if (LocaleCompare("bordercolor",option+1) == 0)
6205 (void) DeleteImageOption(image_info,option+1);
6206 (void) QueryColorDatabase(BorderColor,&image_info->border_color,
6210 (void) QueryColorDatabase(argv[i+1],&image_info->border_color,
6212 (void) SetImageOption(image_info,option+1,argv[i+1]);
6215 if (LocaleCompare("box",option+1) == 0)
6219 (void) SetImageOption(image_info,"undercolor","none");
6222 (void) SetImageOption(image_info,"undercolor",argv[i+1]);
6229 if (LocaleCompare("cache",option+1) == 0)
6234 limit=MagickResourceInfinity;
6235 if (LocaleCompare("unlimited",argv[i+1]) != 0)
6236 limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0);
6237 (void) SetMagickResourceLimit(MemoryResource,limit);
6238 (void) SetMagickResourceLimit(MapResource,2*limit);
6241 if (LocaleCompare("caption",option+1) == 0)
6245 (void) DeleteImageOption(image_info,option+1);
6248 (void) SetImageOption(image_info,option+1,argv[i+1]);
6251 if (LocaleCompare("channel",option+1) == 0)
6255 image_info->channel=DefaultChannels;
6258 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
6261 if (LocaleCompare("colors",option+1) == 0)
6263 image_info->colors=StringToUnsignedLong(argv[i+1]);
6266 if (LocaleCompare("colorspace",option+1) == 0)
6270 image_info->colorspace=UndefinedColorspace;
6271 (void) SetImageOption(image_info,option+1,"undefined");
6274 image_info->colorspace=(ColorspaceType) ParseCommandOption(
6275 MagickColorspaceOptions,MagickFalse,argv[i+1]);
6276 (void) SetImageOption(image_info,option+1,argv[i+1]);
6279 if (LocaleCompare("comment",option+1) == 0)
6283 (void) DeleteImageOption(image_info,option+1);
6286 (void) SetImageOption(image_info,option+1,argv[i+1]);
6289 if (LocaleCompare("compose",option+1) == 0)
6293 (void) SetImageOption(image_info,option+1,"undefined");
6296 (void) SetImageOption(image_info,option+1,argv[i+1]);
6299 if (LocaleCompare("compress",option+1) == 0)
6303 image_info->compression=UndefinedCompression;
6304 (void) SetImageOption(image_info,option+1,"undefined");
6307 image_info->compression=(CompressionType) ParseCommandOption(
6308 MagickCompressOptions,MagickFalse,argv[i+1]);
6309 (void) SetImageOption(image_info,option+1,argv[i+1]);
6316 if (LocaleCompare("debug",option+1) == 0)
6319 (void) SetLogEventMask("none");
6321 (void) SetLogEventMask(argv[i+1]);
6322 image_info->debug=IsEventLogging();
6325 if (LocaleCompare("define",option+1) == 0)
6329 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6330 (void) DeleteImageRegistry(argv[i+1]+9);
6332 (void) DeleteImageOption(image_info,argv[i+1]);
6335 if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
6337 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9,
6341 (void) DefineImageOption(image_info,argv[i+1]);
6344 if (LocaleCompare("delay",option+1) == 0)
6348 (void) SetImageOption(image_info,option+1,"0");
6351 (void) SetImageOption(image_info,option+1,argv[i+1]);
6354 if (LocaleCompare("density",option+1) == 0)
6361 if (image_info->density != (char *) NULL)
6362 image_info->density=DestroyString(image_info->density);
6363 (void) SetImageOption(image_info,option+1,"72");
6366 (void) CloneString(&image_info->density,argv[i+1]);
6367 (void) SetImageOption(image_info,option+1,argv[i+1]);
6370 if (LocaleCompare("depth",option+1) == 0)
6374 image_info->depth=MAGICKCORE_QUANTUM_DEPTH;
6377 image_info->depth=StringToUnsignedLong(argv[i+1]);
6380 if (LocaleCompare("direction",option+1) == 0)
6384 (void) SetImageOption(image_info,option+1,"undefined");
6387 (void) SetImageOption(image_info,option+1,argv[i+1]);
6390 if (LocaleCompare("display",option+1) == 0)
6394 if (image_info->server_name != (char *) NULL)
6395 image_info->server_name=DestroyString(
6396 image_info->server_name);
6399 (void) CloneString(&image_info->server_name,argv[i+1]);
6402 if (LocaleCompare("dispose",option+1) == 0)
6406 (void) SetImageOption(image_info,option+1,"undefined");
6409 (void) SetImageOption(image_info,option+1,argv[i+1]);
6412 if (LocaleCompare("dither",option+1) == 0)
6416 image_info->dither=MagickFalse;
6417 (void) SetImageOption(image_info,option+1,"none");
6420 (void) SetImageOption(image_info,option+1,argv[i+1]);
6421 image_info->dither=MagickTrue;
6428 if (LocaleCompare("encoding",option+1) == 0)
6432 (void) SetImageOption(image_info,option+1,"undefined");
6435 (void) SetImageOption(image_info,option+1,argv[i+1]);
6438 if (LocaleCompare("endian",option+1) == 0)
6442 image_info->endian=UndefinedEndian;
6443 (void) SetImageOption(image_info,option+1,"undefined");
6446 image_info->endian=(EndianType) ParseCommandOption(
6447 MagickEndianOptions,MagickFalse,argv[i+1]);
6448 (void) SetImageOption(image_info,option+1,argv[i+1]);
6451 if (LocaleCompare("extract",option+1) == 0)
6454 Set image extract geometry.
6458 if (image_info->extract != (char *) NULL)
6459 image_info->extract=DestroyString(image_info->extract);
6462 (void) CloneString(&image_info->extract,argv[i+1]);
6469 if (LocaleCompare("fill",option+1) == 0)
6473 (void) SetImageOption(image_info,option+1,"none");
6476 (void) SetImageOption(image_info,option+1,argv[i+1]);
6479 if (LocaleCompare("filter",option+1) == 0)
6483 (void) SetImageOption(image_info,option+1,"undefined");
6486 (void) SetImageOption(image_info,option+1,argv[i+1]);
6489 if (LocaleCompare("font",option+1) == 0)
6493 if (image_info->font != (char *) NULL)
6494 image_info->font=DestroyString(image_info->font);
6497 (void) CloneString(&image_info->font,argv[i+1]);
6500 if (LocaleCompare("format",option+1) == 0)
6505 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%'))
6506 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL)
6507 image_info->ping=MagickFalse;
6508 (void) SetImageOption(image_info,option+1,argv[i+1]);
6511 if (LocaleCompare("fuzz",option+1) == 0)
6515 image_info->fuzz=0.0;
6516 (void) SetImageOption(image_info,option+1,"0");
6519 image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+
6521 (void) SetImageOption(image_info,option+1,argv[i+1]);
6528 if (LocaleCompare("gravity",option+1) == 0)
6532 (void) SetImageOption(image_info,option+1,"undefined");
6535 (void) SetImageOption(image_info,option+1,argv[i+1]);
6538 if (LocaleCompare("green-primary",option+1) == 0)
6542 (void) SetImageOption(image_info,option+1,"0.0");
6545 (void) SetImageOption(image_info,option+1,argv[i+1]);
6552 if (LocaleCompare("intent",option+1) == 0)
6556 (void) SetImageOption(image_info,option+1,"undefined");
6559 (void) SetImageOption(image_info,option+1,argv[i+1]);
6562 if (LocaleCompare("interlace",option+1) == 0)
6566 image_info->interlace=UndefinedInterlace;
6567 (void) SetImageOption(image_info,option+1,"undefined");
6570 image_info->interlace=(InterlaceType) ParseCommandOption(
6571 MagickInterlaceOptions,MagickFalse,argv[i+1]);
6572 (void) SetImageOption(image_info,option+1,argv[i+1]);
6575 if (LocaleCompare("interline-spacing",option+1) == 0)
6579 (void) SetImageOption(image_info,option+1,"undefined");
6582 (void) SetImageOption(image_info,option+1,argv[i+1]);
6585 if (LocaleCompare("interpolate",option+1) == 0)
6589 (void) SetImageOption(image_info,option+1,"undefined");
6592 (void) SetImageOption(image_info,option+1,argv[i+1]);
6595 if (LocaleCompare("interword-spacing",option+1) == 0)
6599 (void) SetImageOption(image_info,option+1,"undefined");
6602 (void) SetImageOption(image_info,option+1,argv[i+1]);
6609 if (LocaleCompare("kerning",option+1) == 0)
6613 (void) SetImageOption(image_info,option+1,"undefined");
6616 (void) SetImageOption(image_info,option+1,argv[i+1]);
6623 if (LocaleCompare("label",option+1) == 0)
6627 (void) DeleteImageOption(image_info,option+1);
6630 (void) SetImageOption(image_info,option+1,argv[i+1]);
6633 if (LocaleCompare("limit",option+1) == 0)
6643 type=(ResourceType) ParseCommandOption(MagickResourceOptions,
6644 MagickFalse,argv[i+1]);
6645 limit=MagickResourceInfinity;
6646 if (LocaleCompare("unlimited",argv[i+2]) != 0)
6647 limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0);
6648 (void) SetMagickResourceLimit(type,limit);
6651 if (LocaleCompare("list",option+1) == 0)
6657 Display configuration list.
6659 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]);
6662 case MagickCoderOptions:
6664 (void) ListCoderInfo((FILE *) NULL,exception);
6667 case MagickColorOptions:
6669 (void) ListColorInfo((FILE *) NULL,exception);
6672 case MagickConfigureOptions:
6674 (void) ListConfigureInfo((FILE *) NULL,exception);
6677 case MagickDelegateOptions:
6679 (void) ListDelegateInfo((FILE *) NULL,exception);
6682 case MagickFontOptions:
6684 (void) ListTypeInfo((FILE *) NULL,exception);
6687 case MagickFormatOptions:
6689 (void) ListMagickInfo((FILE *) NULL,exception);
6692 case MagickLocaleOptions:
6694 (void) ListLocaleInfo((FILE *) NULL,exception);
6697 case MagickLogOptions:
6699 (void) ListLogInfo((FILE *) NULL,exception);
6702 case MagickMagicOptions:
6704 (void) ListMagicInfo((FILE *) NULL,exception);
6707 case MagickMimeOptions:
6709 (void) ListMimeInfo((FILE *) NULL,exception);
6712 case MagickModuleOptions:
6714 (void) ListModuleInfo((FILE *) NULL,exception);
6717 case MagickPolicyOptions:
6719 (void) ListPolicyInfo((FILE *) NULL,exception);
6722 case MagickResourceOptions:
6724 (void) ListMagickResourceInfo((FILE *) NULL,exception);
6727 case MagickThresholdOptions:
6729 (void) ListThresholdMaps((FILE *) NULL,exception);
6734 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
6741 if (LocaleCompare("log",option+1) == 0)
6745 (void) SetLogFormat(argv[i+1]);
6748 if (LocaleCompare("loop",option+1) == 0)
6752 (void) SetImageOption(image_info,option+1,"0");
6755 (void) SetImageOption(image_info,option+1,argv[i+1]);
6762 if (LocaleCompare("matte",option+1) == 0)
6766 (void) SetImageOption(image_info,option+1,"false");
6769 (void) SetImageOption(image_info,option+1,"true");
6772 if (LocaleCompare("mattecolor",option+1) == 0)
6776 (void) SetImageOption(image_info,option+1,argv[i+1]);
6777 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,
6781 (void) SetImageOption(image_info,option+1,argv[i+1]);
6782 (void) QueryColorDatabase(argv[i+1],&image_info->matte_color,
6786 if (LocaleCompare("monitor",option+1) == 0)
6788 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress,
6792 if (LocaleCompare("monochrome",option+1) == 0)
6794 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse;
6801 if (LocaleCompare("orient",option+1) == 0)
6805 image_info->orientation=UndefinedOrientation;
6806 (void) SetImageOption(image_info,option+1,"undefined");
6809 image_info->orientation=(OrientationType) ParseCommandOption(
6810 MagickOrientationOptions,MagickFalse,argv[i+1]);
6811 (void) SetImageOption(image_info,option+1,argv[i+1]);
6817 if (LocaleCompare("page",option+1) == 0)
6821 page[MaxTextExtent];
6834 (void) DeleteImageOption(image_info,option+1);
6835 (void) CloneString(&image_info->page,(char *) NULL);
6838 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6839 image_option=GetImageOption(image_info,"page");
6840 if (image_option != (const char *) NULL)
6841 flags=ParseAbsoluteGeometry(image_option,&geometry);
6842 canonical_page=GetPageGeometry(argv[i+1]);
6843 flags=ParseAbsoluteGeometry(canonical_page,&geometry);
6844 canonical_page=DestroyString(canonical_page);
6845 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu",
6846 (unsigned long) geometry.width,(unsigned long) geometry.height);
6847 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6848 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6849 (unsigned long) geometry.width,(unsigned long) geometry.height,
6850 (long) geometry.x,(long) geometry.y);
6851 (void) SetImageOption(image_info,option+1,page);
6852 (void) CloneString(&image_info->page,page);
6855 if (LocaleCompare("pen",option+1) == 0)
6859 (void) SetImageOption(image_info,option+1,"none");
6862 (void) SetImageOption(image_info,option+1,argv[i+1]);
6865 if (LocaleCompare("ping",option+1) == 0)
6867 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse;
6870 if (LocaleCompare("pointsize",option+1) == 0)
6873 geometry_info.rho=0.0;
6875 (void) ParseGeometry(argv[i+1],&geometry_info);
6876 image_info->pointsize=geometry_info.rho;
6879 if (LocaleCompare("precision",option+1) == 0)
6881 (void) SetMagickPrecision(StringToInteger(argv[i+1]));
6884 if (LocaleCompare("preview",option+1) == 0)
6891 image_info->preview_type=UndefinedPreview;
6894 image_info->preview_type=(PreviewType) ParseCommandOption(
6895 MagickPreviewOptions,MagickFalse,argv[i+1]);
6902 if (LocaleCompare("quality",option+1) == 0)
6905 Set image compression quality.
6909 image_info->quality=UndefinedCompressionQuality;
6910 (void) SetImageOption(image_info,option+1,"0");
6913 image_info->quality=StringToUnsignedLong(argv[i+1]);
6914 (void) SetImageOption(image_info,option+1,argv[i+1]);
6917 if (LocaleCompare("quiet",option+1) == 0)
6919 static WarningHandler
6920 warning_handler = (WarningHandler) NULL;
6925 Restore error or warning messages.
6927 warning_handler=SetWarningHandler(warning_handler);
6931 Suppress error or warning messages.
6933 warning_handler=SetWarningHandler((WarningHandler) NULL);
6940 if (LocaleCompare("red-primary",option+1) == 0)
6944 (void) SetImageOption(image_info,option+1,"0.0");
6947 (void) SetImageOption(image_info,option+1,argv[i+1]);
6954 if (LocaleCompare("sampling-factor",option+1) == 0)
6957 Set image sampling factor.
6961 if (image_info->sampling_factor != (char *) NULL)
6962 image_info->sampling_factor=DestroyString(
6963 image_info->sampling_factor);
6966 (void) CloneString(&image_info->sampling_factor,argv[i+1]);
6969 if (LocaleCompare("scene",option+1) == 0)
6976 image_info->scene=0;
6977 (void) SetImageOption(image_info,option+1,"0");
6980 image_info->scene=StringToUnsignedLong(argv[i+1]);
6981 (void) SetImageOption(image_info,option+1,argv[i+1]);
6984 if (LocaleCompare("seed",option+1) == 0)
6991 seed=(size_t) time((time_t *) NULL);
6992 SeedPseudoRandomGenerator(seed);
6995 seed=StringToUnsignedLong(argv[i+1]);
6996 SeedPseudoRandomGenerator(seed);
6999 if (LocaleCompare("size",option+1) == 0)
7003 if (image_info->size != (char *) NULL)
7004 image_info->size=DestroyString(image_info->size);
7007 (void) CloneString(&image_info->size,argv[i+1]);
7010 if (LocaleCompare("stroke",option+1) == 0)
7014 (void) SetImageOption(image_info,option+1,"none");
7017 (void) SetImageOption(image_info,option+1,argv[i+1]);
7020 if (LocaleCompare("strokewidth",option+1) == 0)
7024 (void) SetImageOption(image_info,option+1,"0");
7027 (void) SetImageOption(image_info,option+1,argv[i+1]);
7030 if (LocaleCompare("synchronize",option+1) == 0)
7034 image_info->synchronize=MagickFalse;
7037 image_info->synchronize=MagickTrue;
7044 if (LocaleCompare("taint",option+1) == 0)
7048 (void) SetImageOption(image_info,option+1,"false");
7051 (void) SetImageOption(image_info,option+1,"true");
7054 if (LocaleCompare("texture",option+1) == 0)
7058 if (image_info->texture != (char *) NULL)
7059 image_info->texture=DestroyString(image_info->texture);
7062 (void) CloneString(&image_info->texture,argv[i+1]);
7065 if (LocaleCompare("tile-offset",option+1) == 0)
7069 (void) SetImageOption(image_info,option+1,"0");
7072 (void) SetImageOption(image_info,option+1,argv[i+1]);
7075 if (LocaleCompare("transparent-color",option+1) == 0)
7079 (void) QueryColorDatabase("none",&image_info->transparent_color, exception);
7080 (void) SetImageOption(image_info,option+1,"none");
7083 (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color,
7085 (void) SetImageOption(image_info,option+1,argv[i+1]);
7088 if (LocaleCompare("type",option+1) == 0)
7092 image_info->type=UndefinedType;
7093 (void) SetImageOption(image_info,option+1,"undefined");
7096 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
7097 MagickFalse,argv[i+1]);
7098 (void) SetImageOption(image_info,option+1,argv[i+1]);
7105 if (LocaleCompare("undercolor",option+1) == 0)
7109 (void) DeleteImageOption(image_info,option+1);
7112 (void) SetImageOption(image_info,option+1,argv[i+1]);
7115 if (LocaleCompare("units",option+1) == 0)
7119 image_info->units=UndefinedResolution;
7120 (void) SetImageOption(image_info,option+1,"undefined");
7123 image_info->units=(ResolutionType) ParseCommandOption(
7124 MagickResolutionOptions,MagickFalse,argv[i+1]);
7125 (void) SetImageOption(image_info,option+1,argv[i+1]);
7132 if (LocaleCompare("verbose",option+1) == 0)
7136 image_info->verbose=MagickFalse;
7139 image_info->verbose=MagickTrue;
7140 image_info->ping=MagickFalse;
7143 if (LocaleCompare("view",option+1) == 0)
7147 if (image_info->view != (char *) NULL)
7148 image_info->view=DestroyString(image_info->view);
7151 (void) CloneString(&image_info->view,argv[i+1]);
7154 if (LocaleCompare("virtual-pixel",option+1) == 0)
7158 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
7159 (void) SetImageOption(image_info,option+1,"undefined");
7162 image_info->virtual_pixel_method=(VirtualPixelMethod)
7163 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7165 (void) SetImageOption(image_info,option+1,argv[i+1]);
7172 if (LocaleCompare("white-point",option+1) == 0)
7176 (void) SetImageOption(image_info,option+1,"0.0");
7179 (void) SetImageOption(image_info,option+1,argv[i+1]);
7193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7197 + M o g r i f y I m a g e L i s t %
7201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7203 % MogrifyImageList() applies any command line options that might affect the
7204 % entire image list (e.g. -append, -coalesce, etc.).
7206 % The format of the MogrifyImage method is:
7208 % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc,
7209 % const char **argv,Image **images,ExceptionInfo *exception)
7211 % A description of each parameter follows:
7213 % o image_info: the image info..
7215 % o argc: Specifies a pointer to an integer describing the number of
7216 % elements in the argument vector.
7218 % o argv: Specifies a pointer to a text array containing the command line
7221 % o images: pointer to pointer of the first image in image list.
7223 % o exception: return any errors or warnings in this structure.
7226 WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
7227 const int argc,const char **argv,Image **images,ExceptionInfo *exception)
7249 Apply options to the image list.
7251 assert(image_info != (ImageInfo *) NULL);
7252 assert(image_info->signature == MagickSignature);
7253 assert(images != (Image **) NULL);
7254 assert((*images)->previous == (Image *) NULL);
7255 assert((*images)->signature == MagickSignature);
7256 if ((*images)->debug != MagickFalse)
7257 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7258 (*images)->filename);
7259 if ((argc <= 0) || (*argv == (char *) NULL))
7261 mogrify_info=CloneImageInfo(image_info);
7262 quantize_info=AcquireQuantizeInfo(mogrify_info);
7264 for (i=0; i < (ssize_t) argc; i++)
7266 if (*images == (Image *) NULL)
7269 if (IsCommandOption(option) == MagickFalse)
7271 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
7272 count=MagickMax(count,0L);
7273 if ((i+count) >= (ssize_t) argc)
7275 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
7276 switch (*(option+1))
7280 if (LocaleCompare("affinity",option+1) == 0)
7282 (void) SyncImagesSettings(mogrify_info,*images);
7285 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7286 InheritException(exception,&(*images)->exception);
7292 if (LocaleCompare("append",option+1) == 0)
7297 (void) SyncImagesSettings(mogrify_info,*images);
7298 append_image=AppendImages(*images,*option == '-' ? MagickTrue :
7299 MagickFalse,exception);
7300 if (append_image == (Image *) NULL)
7305 *images=DestroyImageList(*images);
7306 *images=append_image;
7309 if (LocaleCompare("average",option+1) == 0)
7315 Average an image sequence (deprecated).
7317 (void) SyncImagesSettings(mogrify_info,*images);
7318 average_image=EvaluateImages(*images,MeanEvaluateOperator,
7320 if (average_image == (Image *) NULL)
7325 *images=DestroyImageList(*images);
7326 *images=average_image;
7333 if (LocaleCompare("channel",option+1) == 0)
7340 channel=DefaultChannels;
7343 channel=(ChannelType) ParseChannelOption(argv[i+1]);
7344 SetPixelComponentMap(*images,channel);
7347 if (LocaleCompare("clut",option+1) == 0)
7353 (void) SyncImagesSettings(mogrify_info,*images);
7354 image=RemoveFirstImageFromList(images);
7355 clut_image=RemoveFirstImageFromList(images);
7356 if (clut_image == (Image *) NULL)
7361 (void) ClutImage(image,clut_image);
7362 clut_image=DestroyImage(clut_image);
7363 InheritException(exception,&image->exception);
7364 *images=DestroyImageList(*images);
7368 if (LocaleCompare("coalesce",option+1) == 0)
7373 (void) SyncImagesSettings(mogrify_info,*images);
7374 coalesce_image=CoalesceImages(*images,exception);
7375 if (coalesce_image == (Image *) NULL)
7380 *images=DestroyImageList(*images);
7381 *images=coalesce_image;
7384 if (LocaleCompare("combine",option+1) == 0)
7389 (void) SyncImagesSettings(mogrify_info,*images);
7390 combine_image=CombineImages(*images,exception);
7391 if (combine_image == (Image *) NULL)
7396 *images=DestroyImageList(*images);
7397 *images=combine_image;
7400 if (LocaleCompare("composite",option+1) == 0)
7410 (void) SyncImagesSettings(mogrify_info,*images);
7411 image=RemoveFirstImageFromList(images);
7412 composite_image=RemoveFirstImageFromList(images);
7413 if (composite_image == (Image *) NULL)
7418 (void) TransformImage(&composite_image,(char *) NULL,
7419 composite_image->geometry);
7420 SetGeometry(composite_image,&geometry);
7421 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry);
7422 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
7424 mask_image=RemoveFirstImageFromList(images);
7425 if (mask_image != (Image *) NULL)
7427 if ((image->compose == DisplaceCompositeOp) ||
7428 (image->compose == DistortCompositeOp))
7431 Merge Y displacement into X displacement image.
7433 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
7435 mask_image=DestroyImage(mask_image);
7440 Set a blending mask for the composition.
7442 /* POSIBLE ERROR; what if image->mask already set */
7443 image->mask=mask_image;
7444 (void) NegateImage(image->mask,MagickFalse);
7447 (void) CompositeImage(image,image->compose,composite_image,
7448 geometry.x,geometry.y);
7449 if (mask_image != (Image *) NULL)
7450 mask_image=image->mask=DestroyImage(image->mask);
7451 composite_image=DestroyImage(composite_image);
7452 InheritException(exception,&image->exception);
7453 *images=DestroyImageList(*images);
7458 This has been merged completely into MogrifyImage()
7459 if (LocaleCompare("crop",option+1) == 0)
7470 (void) SyncImagesSettings(mogrify_info,*images);
7471 flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception);
7472 if (((geometry.width == 0) && (geometry.height == 0)) ||
7473 ((flags & XValue) != 0) || ((flags & YValue) != 0))
7475 (void) TransformImages(images,argv[i+1],(char *) NULL);
7476 InheritException(exception,&(*images)->exception);
7484 if (LocaleCompare("deconstruct",option+1) == 0)
7489 (void) SyncImagesSettings(mogrify_info,*images);
7490 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
7492 if (deconstruct_image == (Image *) NULL)
7497 *images=DestroyImageList(*images);
7498 *images=deconstruct_image;
7501 if (LocaleCompare("delete",option+1) == 0)
7504 DeleteImages(images,"-1",exception);
7506 DeleteImages(images,argv[i+1],exception);
7509 if (LocaleCompare("dither",option+1) == 0)
7513 quantize_info->dither=MagickFalse;
7516 quantize_info->dither=MagickTrue;
7517 quantize_info->dither_method=(DitherMethod) ParseCommandOption(
7518 MagickDitherOptions,MagickFalse,argv[i+1]);
7521 if (LocaleCompare("duplicate",option+1) == 0)
7527 duplicate_images=DuplicateImages(*images,1,"-1",exception);
7536 number_duplicates=(size_t) StringToLong(argv[i+1]);
7537 p=strchr(argv[i+1],',');
7538 if (p == (const char *) NULL)
7539 duplicate_images=DuplicateImages(*images,number_duplicates,
7542 duplicate_images=DuplicateImages(*images,number_duplicates,p,
7545 AppendImageToList(images, duplicate_images);
7546 (void) SyncImagesSettings(mogrify_info,*images);
7553 if (LocaleCompare("evaluate-sequence",option+1) == 0)
7558 MagickEvaluateOperator
7561 (void) SyncImageSettings(mogrify_info,*images);
7562 op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions,
7563 MagickFalse,argv[i+1]);
7564 evaluate_image=EvaluateImages(*images,op,exception);
7565 if (evaluate_image == (Image *) NULL)
7570 *images=DestroyImageList(*images);
7571 *images=evaluate_image;
7578 if (LocaleCompare("fft",option+1) == 0)
7584 Implements the discrete Fourier transform (DFT).
7586 (void) SyncImageSettings(mogrify_info,*images);
7587 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
7588 MagickTrue : MagickFalse,exception);
7589 if (fourier_image == (Image *) NULL)
7591 *images=DestroyImage(*images);
7592 *images=fourier_image;
7595 if (LocaleCompare("flatten",option+1) == 0)
7600 (void) SyncImagesSettings(mogrify_info,*images);
7601 flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
7602 if (flatten_image == (Image *) NULL)
7604 *images=DestroyImageList(*images);
7605 *images=flatten_image;
7608 if (LocaleCompare("fx",option+1) == 0)
7613 (void) SyncImagesSettings(mogrify_info,*images);
7614 fx_image=FxImage(*images,argv[i+1],exception);
7615 if (fx_image == (Image *) NULL)
7620 *images=DestroyImageList(*images);
7628 if (LocaleCompare("hald-clut",option+1) == 0)
7634 (void) SyncImagesSettings(mogrify_info,*images);
7635 image=RemoveFirstImageFromList(images);
7636 hald_image=RemoveFirstImageFromList(images);
7637 if (hald_image == (Image *) NULL)
7642 (void) HaldClutImage(image,hald_image);
7643 hald_image=DestroyImage(hald_image);
7644 InheritException(exception,&image->exception);
7645 if (*images != (Image *) NULL)
7646 *images=DestroyImageList(*images);
7654 if (LocaleCompare("ift",option+1) == 0)
7662 Implements the inverse fourier discrete Fourier transform (DFT).
7664 (void) SyncImagesSettings(mogrify_info,*images);
7665 magnitude_image=RemoveFirstImageFromList(images);
7666 phase_image=RemoveFirstImageFromList(images);
7667 if (phase_image == (Image *) NULL)
7672 fourier_image=InverseFourierTransformImage(magnitude_image,
7673 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
7674 if (fourier_image == (Image *) NULL)
7676 if (*images != (Image *) NULL)
7677 *images=DestroyImage(*images);
7678 *images=fourier_image;
7681 if (LocaleCompare("insert",option+1) == 0)
7689 index=(ssize_t) StringToLong(argv[i+1]);
7690 p=RemoveLastImageFromList(images);
7691 if (p == (Image *) NULL)
7693 (void) ThrowMagickException(exception,GetMagickModule(),
7694 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7700 PrependImageToList(images,q);
7702 if (index == (ssize_t) GetImageListLength(*images))
7703 AppendImageToList(images,q);
7706 q=GetImageFromList(*images,index-1);
7707 if (q == (Image *) NULL)
7709 (void) ThrowMagickException(exception,GetMagickModule(),
7710 OptionError,"NoSuchImage","`%s'",argv[i+1]);
7714 InsertImageInList(&q,p);
7716 *images=GetFirstImageInList(q);
7723 if (LocaleCompare("layers",option+1) == 0)
7731 (void) SyncImagesSettings(mogrify_info,*images);
7732 layers=(Image *) NULL;
7733 method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions,
7734 MagickFalse,argv[i+1]);
7739 layers=CoalesceImages(*images,exception);
7742 case CompareAnyLayer:
7743 case CompareClearLayer:
7744 case CompareOverlayLayer:
7747 layers=CompareImagesLayers(*images,method,exception);
7753 case TrimBoundsLayer:
7755 layers=MergeImageLayers(*images,method,exception);
7760 layers=DisposeImages(*images,exception);
7763 case OptimizeImageLayer:
7765 layers=OptimizeImageLayers(*images,exception);
7768 case OptimizePlusLayer:
7770 layers=OptimizePlusImageLayers(*images,exception);
7773 case OptimizeTransLayer:
7775 OptimizeImageTransparency(*images,exception);
7778 case RemoveDupsLayer:
7780 RemoveDuplicateLayers(images,exception);
7783 case RemoveZeroLayer:
7785 RemoveZeroDelayLayers(images,exception);
7791 General Purpose, GIF Animation Optimizer.
7793 layers=CoalesceImages(*images,exception);
7794 if (layers == (Image *) NULL)
7799 InheritException(exception,&layers->exception);
7800 *images=DestroyImageList(*images);
7802 layers=OptimizeImageLayers(*images,exception);
7803 if (layers == (Image *) NULL)
7808 InheritException(exception,&layers->exception);
7809 *images=DestroyImageList(*images);
7811 layers=(Image *) NULL;
7812 OptimizeImageTransparency(*images,exception);
7813 InheritException(exception,&(*images)->exception);
7814 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7817 case CompositeLayer:
7829 Split image sequence at the first 'NULL:' image.
7832 while (source != (Image *) NULL)
7834 source=GetNextImageInList(source);
7835 if ((source != (Image *) NULL) &&
7836 (LocaleCompare(source->magick,"NULL") == 0))
7839 if (source != (Image *) NULL)
7841 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7842 (GetNextImageInList(source) == (Image *) NULL))
7843 source=(Image *) NULL;
7847 Separate the two lists, junk the null: image.
7849 source=SplitImageList(source->previous);
7850 DeleteImageFromList(&source);
7853 if (source == (Image *) NULL)
7855 (void) ThrowMagickException(exception,GetMagickModule(),
7856 OptionError,"MissingNullSeparator","layers Composite");
7861 Adjust offset with gravity and virtual canvas.
7863 SetGeometry(*images,&geometry);
7864 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
7865 geometry.width=source->page.width != 0 ?
7866 source->page.width : source->columns;
7867 geometry.height=source->page.height != 0 ?
7868 source->page.height : source->rows;
7869 GravityAdjustGeometry((*images)->page.width != 0 ?
7870 (*images)->page.width : (*images)->columns,
7871 (*images)->page.height != 0 ? (*images)->page.height :
7872 (*images)->rows,(*images)->gravity,&geometry);
7873 compose=OverCompositeOp;
7874 option=GetImageOption(mogrify_info,"compose");
7875 if (option != (const char *) NULL)
7876 compose=(CompositeOperator) ParseCommandOption(
7877 MagickComposeOptions,MagickFalse,option);
7878 CompositeLayers(*images,compose,source,geometry.x,geometry.y,
7880 source=DestroyImageList(source);
7884 if (layers == (Image *) NULL)
7886 InheritException(exception,&layers->exception);
7887 *images=DestroyImageList(*images);
7895 if (LocaleCompare("map",option+1) == 0)
7897 (void) SyncImagesSettings(mogrify_info,*images);
7900 (void) RemapImages(quantize_info,*images,(Image *) NULL);
7901 InheritException(exception,&(*images)->exception);
7907 if (LocaleCompare("maximum",option+1) == 0)
7913 Maximum image sequence (deprecated).
7915 (void) SyncImagesSettings(mogrify_info,*images);
7916 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
7917 if (maximum_image == (Image *) NULL)
7922 *images=DestroyImageList(*images);
7923 *images=maximum_image;
7926 if (LocaleCompare("minimum",option+1) == 0)
7932 Minimum image sequence (deprecated).
7934 (void) SyncImagesSettings(mogrify_info,*images);
7935 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
7936 if (minimum_image == (Image *) NULL)
7941 *images=DestroyImageList(*images);
7942 *images=minimum_image;
7945 if (LocaleCompare("morph",option+1) == 0)
7950 (void) SyncImagesSettings(mogrify_info,*images);
7951 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
7953 if (morph_image == (Image *) NULL)
7958 *images=DestroyImageList(*images);
7959 *images=morph_image;
7962 if (LocaleCompare("mosaic",option+1) == 0)
7967 (void) SyncImagesSettings(mogrify_info,*images);
7968 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
7969 if (mosaic_image == (Image *) NULL)
7974 *images=DestroyImageList(*images);
7975 *images=mosaic_image;
7982 if (LocaleCompare("print",option+1) == 0)
7987 (void) SyncImagesSettings(mogrify_info,*images);
7988 string=InterpretImageProperties(mogrify_info,*images,argv[i+1]);
7989 if (string == (char *) NULL)
7991 InheritException(exception,&(*images)->exception);
7992 (void) FormatLocaleFile(stdout,"%s",string);
7993 string=DestroyString(string);
7995 if (LocaleCompare("process",option+1) == 0)
8004 (void) SyncImagesSettings(mogrify_info,*images);
8005 arguments=StringToArgv(argv[i+1],&number_arguments);
8006 if (arguments == (char **) NULL)
8008 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
8029 Support old style syntax, filter="-option arg".
8031 length=strlen(argv[i+1]);
8032 token=(char *) NULL;
8033 if (~length >= (MaxTextExtent-1))
8034 token=(char *) AcquireQuantumMemory(length+MaxTextExtent,
8036 if (token == (char *) NULL)
8039 arguments=argv[i+1];
8040 token_info=AcquireTokenInfo();
8041 status=Tokenizer(token_info,0,token,length,arguments,"","=",
8042 "\"",'\0',&breaker,&next,"e);
8043 token_info=DestroyTokenInfo(token_info);
8049 argv=(&(arguments[next]));
8050 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv,
8053 token=DestroyString(token);
8056 (void) SubstituteString(&arguments[1],"-","");
8057 (void) InvokeDynamicImageFilter(arguments[1],&(*images),
8058 number_arguments-2,(const char **) arguments+2,exception);
8059 for (j=0; j < number_arguments; j++)
8060 arguments[j]=DestroyString(arguments[j]);
8061 arguments=(char **) RelinquishMagickMemory(arguments);
8068 if (LocaleCompare("reverse",option+1) == 0)
8070 ReverseImageList(images);
8071 InheritException(exception,&(*images)->exception);
8078 if (LocaleCompare("smush",option+1) == 0)
8086 (void) SyncImagesSettings(mogrify_info,*images);
8087 offset=(ssize_t) StringToLong(argv[i+1]);
8088 smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
8089 MagickFalse,offset,exception);
8090 if (smush_image == (Image *) NULL)
8095 *images=DestroyImageList(*images);
8096 *images=smush_image;
8099 if (LocaleCompare("swap",option+1) == 0)
8120 flags=ParseGeometry(argv[i+1],&geometry_info);
8121 index=(ssize_t) geometry_info.rho;
8122 if ((flags & SigmaValue) != 0)
8123 swap_index=(ssize_t) geometry_info.sigma;
8125 p=GetImageFromList(*images,index);
8126 q=GetImageFromList(*images,swap_index);
8127 if ((p == (Image *) NULL) || (q == (Image *) NULL))
8129 (void) ThrowMagickException(exception,GetMagickModule(),
8130 OptionError,"NoSuchImage","`%s'",(*images)->filename);
8136 swap=CloneImage(p,0,0,MagickTrue,exception);
8137 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception));
8138 ReplaceImageInList(&q,swap);
8139 *images=GetFirstImageInList(q);
8146 if (LocaleCompare("write",option+1) == 0)
8157 (void) SyncImagesSettings(mogrify_info,*images);
8158 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]);
8159 (void) DeleteImageRegistry(key);
8160 write_images=(*images);
8162 write_images=CloneImageList(*images,exception);
8163 write_info=CloneImageInfo(mogrify_info);
8164 status&=WriteImages(write_info,write_images,argv[i+1],exception);
8165 write_info=DestroyImageInfo(write_info);
8167 write_images=DestroyImageList(write_images);
8177 quantize_info=DestroyQuantizeInfo(quantize_info);
8178 mogrify_info=DestroyImageInfo(mogrify_info);
8179 status&=MogrifyImageInfo(image_info,argc,argv,exception);
8180 return(status != 0 ? MagickTrue : MagickFalse);
8184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8188 + M o g r i f y I m a g e s %
8192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8194 % MogrifyImages() applies image processing options to a sequence of images as
8195 % prescribed by command line options.
8197 % The format of the MogrifyImage method is:
8199 % MagickBooleanType MogrifyImages(ImageInfo *image_info,
8200 % const MagickBooleanType post,const int argc,const char **argv,
8201 % Image **images,Exceptioninfo *exception)
8203 % A description of each parameter follows:
8205 % o image_info: the image info..
8207 % o post: If true, post process image list operators otherwise pre-process.
8209 % o argc: Specifies a pointer to an integer describing the number of
8210 % elements in the argument vector.
8212 % o argv: Specifies a pointer to a text array containing the command line
8215 % o images: pointer to a pointer of the first image in image list.
8217 % o exception: return any errors or warnings in this structure.
8220 WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info,
8221 const MagickBooleanType post,const int argc,const char **argv,
8222 Image **images,ExceptionInfo *exception)
8224 #define MogrifyImageTag "Mogrify/Image"
8238 assert(image_info != (ImageInfo *) NULL);
8239 assert(image_info->signature == MagickSignature);
8240 if (images == (Image **) NULL)
8241 return(MogrifyImage(image_info,argc,argv,images,exception));
8242 assert((*images)->previous == (Image *) NULL);
8243 assert((*images)->signature == MagickSignature);
8244 if ((*images)->debug != MagickFalse)
8245 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
8246 (*images)->filename);
8247 if ((argc <= 0) || (*argv == (char *) NULL))
8249 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL,
8254 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,
8259 Pre-process multi-image sequence operators
8261 if (post == MagickFalse)
8262 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8264 For each image, process simple single image operators
8267 n=GetImageListLength(*images);
8271 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long)
8272 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8274 status&=MogrifyImage(image_info,argc,argv,images,exception);
8275 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n);
8276 if (proceed == MagickFalse)
8278 if ( (*images)->next == (Image *) NULL )
8280 *images=(*images)->next;
8283 assert( *images != (Image *) NULL );
8285 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long)
8286 GetImageIndexInList(*images),(long)GetImageListLength(*images));
8290 Post-process, multi-image sequence operators
8292 *images=GetFirstImageInList(*images);
8293 if (post != MagickFalse)
8294 status&=MogrifyImageList(image_info,argc,argv,images,exception);
8295 return(status != 0 ? MagickTrue : MagickFalse);